How to use logToConsole method in wpt

Best JavaScript code snippet using wpt

BehaviorLog.lxl.js

Source:BehaviorLog.lxl.js Github

copy

Full Screen

1//UpgradeEX* {"name":"LlsePlugins","platform":"github","repo":"LiteLScript-Dev\/LXL-Plugins","currentRelease":"v1.0.0"} */2// 文件名:BehaviorLog.lxl.js3// 文件功能:LXL平台下BehaviorLog行为监控日志4// 作者:yqs1123585// 首发平台:MineBBS6var _VER = [2, 1, 4];7var _CONFIG_PATH = './plugins/BehaviorLog/config.json';8var _SHOW_ERROR_INFO = false;9if (!lxl.requireVersion(0, 5, 3))10 throw new Error("\n\n【加载失败】LXL版本过旧!请升级你的LXL版本到0.5.3及以上再使用此插件\n");11if (lxl.requireVersion(2, 1, 3))12 lxl.registerPlugin("BehaviorLog", "Behavior Log for LiteLoaderBDS", _VER, { "GitHub": "https://github.com/LiteLScript-Dev/LXL-Plugins" });13var _DEFAULT_CONFIG_FILE = String.raw14 `{15 "ShowLogInConsole": 1,16 "Language":"zh-cn",17 "Settings": {18 "onPreJoin": {19 "LogToFile": 1,20 "LogToConsole": 1,21 "NoOutputContent": []22 },23 "onJoin": {24 "LogToFile": 1,25 "LogToConsole": 1,26 "NoOutputContent": []27 },28 "onLeft": {29 "LogToFile": 1,30 "LogToConsole": 1,31 "NoOutputContent": []32 },33 "onRespawn": {34 "LogToFile": 1,35 "LogToConsole": 1,36 "NoOutputContent": []37 },38 "onPlayerDie": {39 "LogToFile": 1,40 "LogToConsole": 1,41 "NoOutputContent": []42 },43 "onPlayerCmd": {44 "LogToFile": 1,45 "LogToConsole": 1,46 "NoOutputContent": []47 },48 "onChat": {49 "LogToFile": 1,50 "LogToConsole": 1,51 "NoOutputContent": [52 "{\"rawtext\":[{"53 ]54 },55 "onChangeDim": {56 "LogToFile": 1,57 "LogToConsole": 1,58 "NoOutputContent": []59 },60 "onJump": {61 "LogToFile": 0,62 "LogToConsole": 0,63 "NoOutputContent": []64 },65 "onSneak": {66 "LogToFile": 0,67 "LogToConsole": 0,68 "NoOutputContent": []69 },70 "onAttack": {71 "LogToFile": 1,72 "LogToConsole": 1,73 "NoOutputContent": []74 },75 "onUseItem": {76 "LogToFile": 1,77 "LogToConsole": 1,78 "NoOutputContent": []79 },80 "onUseItemOn": {81 "LogToFile": 0,82 "LogToConsole": 0,83 "NoOutputContent": []84 },85 "onTakeItem": {86 "LogToFile": 1,87 "LogToConsole": 1,88 "NoOutputContent": []89 },90 "onDropItem": {91 "LogToFile": 1,92 "LogToConsole": 1,93 "NoOutputContent": []94 },95 "onEat": {96 "LogToFile": 1,97 "LogToConsole": 1,98 "NoOutputContent": []99 },100 "onStartDestroyBlock": {101 "LogToFile": 0,102 "LogToConsole": 0,103 "NoOutputContent": []104 },105 "onDestroyBlock": {106 "LogToFile": 1,107 "LogToConsole": 1,108 "NoOutputContent": []109 },110 "onPlaceBlock": {111 "LogToFile": 1,112 "LogToConsole": 1,113 "NoOutputContent": []114 },115 "onOpenContainer": {116 "LogToFile": 1,117 "LogToConsole": 1,118 "NoOutputContent": []119 },120 "onCloseContainer": {121 "LogToFile": 1,122 "LogToConsole": 1,123 "NoOutputContent": []124 },125 "onInventoryChange": {126 "LogToFile": 0,127 "LogToConsole": 0,128 "NoOutputContent": []129 },130 "onSetArmor": {131 "LogToFile": 0,132 "LogToConsole": 0,133 "NoOutputContent": []134 },135 "onUseRespawnAnchor": {136 "LogToFile": 1,137 "LogToConsole": 1,138 "NoOutputContent": []139 },140 "onOpenContainerScreen": {141 "LogToFile": 0,142 "LogToConsole": 0,143 "NoOutputContent": []144 },145 "onMobDie": {146 "LogToFile": 1,147 "LogToConsole": 1,148 "NoOutputContent": []149 },150 "onMobHurt": {151 "LogToFile": 0,152 "LogToConsole": 0,153 "NoOutputContent": []154 },155 "onExplode": {156 "LogToFile": 1,157 "LogToConsole": 1,158 "NoOutputContent": []159 },160 "onProjectileHitEntity": {161 "LogToFile": 1,162 "LogToConsole": 1,163 "NoOutputContent": []164 },165 "onWitherBossDestroy": {166 "LogToFile": 1,167 "LogToConsole": 1,168 "NoOutputContent": []169 },170 "onRide": {171 "LogToFile": 0,172 "LogToConsole": 0,173 "NoOutputContent": []174 },175 "onStepOnPressurePlate": {176 "LogToFile": 0,177 "LogToConsole": 0,178 "NoOutputContent": []179 },180 "onBlockInteracted": {181 "LogToFile": 1,182 "LogToConsole": 1,183 "NoOutputContent": []184 },185 "onBedExplode": {186 "LogToFile": 1,187 "LogToConsole": 1,188 "NoOutputContent": []189 },190 "onRespawnAnchorExplode": {191 "LogToFile": 1,192 "LogToConsole": 1,193 "NoOutputContent": []194 },195 "onBlockExploded": {196 "LogToFile": 0,197 "LogToConsole": 0,198 "NoOutputContent": []199 },200 "onCmdBlockExecute": {201 "LogToFile": 1,202 "LogToConsole": 1,203 "NoOutputContent": []204 },205 "onContainerChange": {206 "LogToFile": 1,207 "LogToConsole": 1,208 "NoOutputContent": []209 },210 "onProjectileHitBlock": {211 "LogToFile": 0,212 "LogToConsole": 0,213 "NoOutputContent": []214 },215 "onRedStoneUpdate": {216 "LogToFile": 0,217 "LogToConsole": 0,218 "NoOutputContent": []219 },220 "onHopperPushOut": {221 "LogToFile": 0,222 "LogToConsole": 0,223 "NoOutputContent": []224 },225 "onPistonPush": {226 "LogToFile": 1,227 "LogToConsole": 1,228 "NoOutputContent": []229 },230 "onFarmLandDecay": {231 "LogToFile": 1,232 "LogToConsole": 1,233 "NoOutputContent": []234 },235 "onUseFrameBlock": {236 "LogToFile": 0,237 "LogToConsole": 0,238 "NoOutputContent": []239 },240 "onScoreChanged": {241 "LogToFile": 0,242 "LogToConsole": 0,243 "NoOutputContent": []244 },245 "onFireSpread": {246 "LogToFile": 0,247 "LogToConsole": 0,248 "NoOutputContent": []249 },250 "onConsoleCmd": {251 "LogToFile": 1,252 "LogToConsole": 0,253 "NoOutputContent": []254 }255 }256}`;257//配置文件258var confFile = data.openConfig(_CONFIG_PATH, "json", _DEFAULT_CONFIG_FILE);259const conf = JSON.parse(confFile.read());260const i18n = {261 data: {},262 /**263 * 翻译主代码264 * @param {string} sentence 翻译字段265 * @param {Array[string]} replacer 替换字符266 * @returns {string}267 */268 $t(sentence, replacer = []) {269 if (!this.data[sentence]) {270 return `Translate Error:${sentence}`;271 }272 let output = this.data[sentence];273 for (let index = 0; index < replacer.length; index++) {274 const element = replacer[index];275 output = output.replace("%s" + index, element);276 }277 return output;278 },279 reload() {280 if (file.exists("./plugins/BehaviorLog/i18n/" + conf["Language"] + ".json")) {281 this.data = data.parseJson(File.readFrom("./plugins/BehaviorLog/i18n/" + conf["Language"] + ".json"));282 }283 }284};285i18n.reload();286//日志文件287function GetTodayLogPath() {288 return './logs/BehaviorLog-' + system.getTimeStr().substr(0, 10) + '.csv';289}290var logFile;291function OpenNewFile() {292 let nowLogPath = GetTodayLogPath();293 var isNewFile = false;294 if (!file.exists(nowLogPath))295 isNewFile = true;296 logFile = file.open(nowLogPath, file.AppendMode);297 if (!logFile) {298 throw Error(i18n.$t("notify.openError"));299 }300 if (isNewFile)301 file.writeLine(nowLogPath, `\ufeff${i18n.$t("common.time")},${i18n.$t("common.dim")},${i18n.$t("common.source")},X,Y,Z,${i18n.$t("common.event")},${i18n.$t("common.target")},x,y,z,${i18n.$t("common.extra")}`);302}303OpenNewFile();304//定时更新文件305var lastDay = system.getTimeObj().D;306setInterval(function () {307 if (lastDay != system.getTimeObj().D) {308 //新的一天309 lastDay = system.getTimeObj().D;310 logFile.close();311 OpenNewFile();312 }313}, 30000);314//输出日志315var consoleQueue = [], fileQueue = [];316setInterval(function () {317 //File Log318 let logStr = "";319 if (fileQueue.length != 0) {320 try {321 while (fileQueue.length > 1) {322 logStr += fileQueue.shift() + "\n";323 }324 logStr += fileQueue.shift();325 logFile.writeLine(String(logStr));326 }327 catch (exception) {328 if (_SHOW_ERROR_INFO) throw exception;329 }330 }331 //Console Log332 logStr = "";333 if (consoleQueue.length != 0) {334 while (consoleQueue.length > 1) {335 logStr += consoleQueue.shift() + "\n";336 }337 logStr += consoleQueue.shift();338 if (conf.ShowLogInConsole)339 fastLog(String(logStr));340 }341}, 50);342setInterval(function () {343 try {344 logFile.flush();345 }346 catch (exception) {347 if (_SHOW_ERROR_INFO) throw exception;348 }349}, 5000);350function writeLog(logToFile, logToConsole, NoOutputContent, event, dim, doer, dx, dy, dz, target, tx, ty, tz, notes) {351 let logStr = system.getTimeStr() + ',' + dim + ',' + doer + ',' + dx + ',' + dy + ',' + dz352 + ',' + event + ',' + target + ',' + tx + ',' + ty + ',' + tz + ',' + notes;353 if (NoOutputContent.length != 0) {354 let no = false355 NoOutputContent.forEach(element => {356 if (logStr.indexOf(element) != -1) {357 no = true;358 return false;359 }360 });361 if (no) return;362 }363 if (logToFile)364 fileQueue.push(logStr);365 if (conf.ShowLogInConsole && logToConsole) {366 logStr = '[' + system.getTimeStr() + '][' + event + '] ';367 if (dim != '')368 logStr += i18n.$t("common.at") + dim + ' ';369 if (doer != '')370 logStr += doer;371 if (dx != '')372 logStr += ' (' + dx + ',' + dy + ',' + dz + ')';373 logStr += ' ' + event + ' ';374 if (target != '')375 logStr += target;376 if (tx != '')377 logStr += ' (' + tx + ',' + ty + ',' + tz + ')';378 logStr += ' ' + notes;379 consoleQueue.push(logStr);380 }381}382//导出接口383function writeLogExported(event, dim, doer, dx, dy, dz, target, tx, ty, tz, notes, logToConsole, logToFile) {384 writeLog(logToFile, logToConsole, [], event, dim, doer, dx, dy, dz, target, tx, ty, tz, notes);385}386lxl.export(writeLogExported, "BehaviorLog_WriteLog");387//监控部分388var settings = conf.Settings;389//onPreJoin390if (settings.onPreJoin.LogToFile || settings.onPreJoin.LogToConsole) {391 let logToFile = settings.onPreJoin.LogToFile;392 let logToConsole = settings.onPreJoin.LogToConsole;393 let noOutputContent = settings.onPreJoin.NoOutputContent;394 mc.listen("onPreJoin", function (pl) {395 try {396 writeLog(logToFile, logToConsole, noOutputContent,397 i18n.$t("event.onPreJoin"), '', pl.realName, '', '', '', '', '', '', '', 'xuid=' + pl.xuid);398 }399 catch (exception) {400 if (_SHOW_ERROR_INFO) throw exception;401 }402 });403}404//onJoin405if (settings.onJoin.LogToFile || settings.onJoin.LogToConsole) {406 let logToFile = settings.onJoin.LogToFile;407 let logToConsole = settings.onJoin.LogToConsole;408 let noOutputContent = settings.onJoin.NoOutputContent;409 mc.listen("onJoin", function (pl) {410 try {411 let pos = pl.pos;412 writeLog(logToFile, logToConsole, noOutputContent,413 i18n.$t("event.onJoin"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', 'xuid=' + pl.xuid);414 }415 catch (exception) {416 if (_SHOW_ERROR_INFO) throw exception;417 }418 });419}420//onLeft421if (settings.onLeft.LogToFile || settings.onLeft.LogToConsole) {422 let logToFile = settings.onLeft.LogToFile;423 let logToConsole = settings.onLeft.LogToConsole;424 let noOutputContent = settings.onLeft.NoOutputContent;425 mc.listen("onLeft", function (pl) {426 try {427 writeLog(logToFile, logToConsole, noOutputContent,428 i18n.$t("event.onLeft"), '', pl.realName, '', '', '', '', '', '', '', '');429 }430 catch (exception) {431 if (_SHOW_ERROR_INFO) throw exception;432 }433 });434}435//onRespawn436if (settings.onRespawn.LogToFile || settings.onRespawn.LogToConsole) {437 let logToFile = settings.onRespawn.LogToFile;438 let logToConsole = settings.onRespawn.LogToConsole;439 let noOutputContent = settings.onRespawn.NoOutputContent;440 mc.listen("onRespawn", function (pl) {441 try {442 let pos = pl.pos;443 writeLog(logToFile, logToConsole, noOutputContent,444 i18n.$t("event.onRespawn"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', '');445 }446 catch (exception) {447 if (_SHOW_ERROR_INFO) throw exception;448 }449 });450}451//onPlayerDie452if (settings.onPlayerDie.LogToFile || settings.onPlayerDie.LogToConsole) {453 let logToFile = settings.onPlayerDie.LogToFile;454 let logToConsole = settings.onPlayerDie.LogToConsole;455 let noOutputContent = settings.onPlayerDie.NoOutputContent;456 mc.listen("onPlayerDie", function (pl) {457 try {458 let pos = pl.pos;459 writeLog(logToFile, logToConsole, noOutputContent,460 i18n.$t("event.onPlayerDie"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', '');461 }462 catch (exception) {463 if (_SHOW_ERROR_INFO) throw exception;464 }465 });466}467//onPlayerCmd468if (settings.onPlayerCmd.LogToFile || settings.onPlayerCmd.LogToConsole) {469 let logToFile = settings.onPlayerCmd.LogToFile;470 let logToConsole = settings.onPlayerCmd.LogToConsole;471 let noOutputContent = settings.onPlayerCmd.NoOutputContent;472 mc.listen("onPlayerCmd", function (pl, cmd) {473 try {474 let pos = pl.pos;475 writeLog(logToFile, logToConsole, noOutputContent,476 i18n.$t("event.onPlayerCmd"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), cmd, '', '', '', '');477 }478 catch (exception) {479 if (_SHOW_ERROR_INFO) throw exception;480 }481 });482}483//onChat484if (settings.onChat.LogToFile || settings.onChat.LogToConsole) {485 let logToFile = settings.onChat.LogToFile;486 let logToConsole = settings.onChat.LogToConsole;487 let noOutputContent = settings.onChat.NoOutputContent;488 mc.listen("onChat", function (pl, msg) {489 try {490 let pos = pl.pos;491 writeLog(logToFile, logToConsole, noOutputContent,492 i18n.$t("event.onChat"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), msg, '', '', '', '');493 }494 catch (exception) {495 if (_SHOW_ERROR_INFO) throw exception;496 }497 });498}499//onChangeDim500if (settings.onChangeDim.LogToFile || settings.onChangeDim.LogToConsole) {501 let logToFile = settings.onChangeDim.LogToFile;502 let logToConsole = settings.onChangeDim.LogToConsole;503 let noOutputContent = settings.onChangeDim.NoOutputContent;504 mc.listen("onChangeDim", function (pl, to) {505 try {506 let dimName = "Unknown";507 if (to == 0)508 dimName = i18n.$t("dim.0");509 else if (to == 1)510 dimName = i18n.$t("dim.1");511 else if (to == 2)512 dimName = i18n.$t("dim.2");513 let pos = pl.pos;514 writeLog(logToFile, logToConsole, noOutputContent,515 i18n.$t("event.onChangeDim"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), i18n.$t("common.to") + dimName, '', '', '', '');516 }517 catch (exception) {518 if (_SHOW_ERROR_INFO) throw exception;519 }520 });521}522//onJump523if (settings.onJump.LogToFile || settings.onJump.LogToConsole) {524 let logToFile = settings.onJump.LogToFile;525 let logToConsole = settings.onJump.LogToConsole;526 let noOutputContent = settings.onJump.NoOutputContent;527 mc.listen("onJump", function (pl) {528 try {529 let pos = pl.pos;530 writeLog(logToFile, logToConsole, noOutputContent,531 i18n.$t("event.onJump"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', '');532 }533 catch (exception) {534 if (_SHOW_ERROR_INFO) throw exception;535 }536 });537}538//onSneak539if (settings.onSneak.LogToFile || settings.onSneak.LogToConsole) {540 let logToFile = settings.onSneak.LogToFile;541 let logToConsole = settings.onSneak.LogToConsole;542 let noOutputContent = settings.onSneak.NoOutputContent;543 mc.listen("onSneak", function (pl, isSneaking) {544 try {545 let pos = pl.pos;546 if (isSneaking)547 writeLog(logToFile, logToConsole, noOutputContent,548 i18n.$t("event.onSneak"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', '');549 }550 catch (exception) {551 if (_SHOW_ERROR_INFO) throw exception;552 }553 });554}555//onAttack556if (settings.onAttack.LogToFile || settings.onAttack.LogToConsole) {557 let logToFile = settings.onAttack.LogToFile;558 let logToConsole = settings.onAttack.LogToConsole;559 let noOutputContent = settings.onAttack.NoOutputContent;560 mc.listen("onAttack", function (pl, ac) {561 try {562 let pos = pl.pos;563 let acPos = ac.pos;564 writeLog(logToFile, logToConsole, noOutputContent,565 i18n.$t("event.onAttack"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), ac.name, acPos.x.toFixed(0), acPos.y.toFixed(0), acPos.z.toFixed(0),i18n.$t("detial.attack",[pl.getHand().name,pl.getHand().type]));566 }567 catch (exception) {568 if (_SHOW_ERROR_INFO) throw exception;569 }570 });571}572//onUseItem573if (settings.onUseItem.LogToFile || settings.onUseItem.LogToConsole) {574 let logToFile = settings.onUseItem.LogToFile;575 let logToConsole = settings.onUseItem.LogToConsole;576 let noOutputContent = settings.onUseItem.NoOutputContent;577 mc.listen("onUseItem", function (pl, it) {578 try {579 let pos = pl.pos;580 writeLog(logToFile, logToConsole, noOutputContent,581 i18n.$t("event.onUseItem"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), it.name, '', '', '', i18n.$t("detial.useItem",[it.type]));582 }583 catch (exception) {584 if (_SHOW_ERROR_INFO) throw exception;585 }586 });587}588//onUseItemOn589if (settings.onUseItemOn.LogToFile || settings.onUseItemOn.LogToConsole) {590 let logToFile = settings.onUseItemOn.LogToFile;591 let logToConsole = settings.onUseItemOn.LogToConsole;592 let noOutputContent = settings.onUseItemOn.NoOutputContent;593 mc.listen("onUseItemOn", function (pl, it, bl) {594 try {595 //防抖596 if (pl.getExtraData("_BEHAVIOR_LOG_PLACE_BLOCK"))597 return;598 let pos = pl.pos;599 let blPos = bl.pos;600 writeLog(logToFile, logToConsole, noOutputContent,601 i18n.$t("event.onUseItemOn"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), bl.name, blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), i18n.$t("detial.onUseItemOn",[it.name,it.type]));602 }603 catch (exception) {604 if (_SHOW_ERROR_INFO) throw exception;605 }606 });607}608//onTakeItem609if (settings.onTakeItem.LogToFile || settings.onTakeItem.LogToConsole) {610 let logToFile = settings.onTakeItem.LogToFile;611 let logToConsole = settings.onTakeItem.LogToConsole;612 let noOutputContent = settings.onTakeItem.NoOutputContent;613 mc.listen("onTakeItem", function (pl, en, it) {614 try {615 let enPos = en.pos;616 let pos = pl.pos;617 writeLog(logToFile, logToConsole, noOutputContent,618 i18n.$t("event.onTakeItem"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), it.name, enPos.x.toFixed(0), enPos.y.toFixed(0), enPos.z.toFixed(0), `${it.count}个`);619 }620 catch (exception) {621 if (_SHOW_ERROR_INFO) throw exception;622 }623 });624}625//onDropItem626if (settings.onDropItem.LogToFile || settings.onDropItem.LogToConsole) {627 let logToFile = settings.onDropItem.LogToFile;628 let logToConsole = settings.onDropItem.LogToConsole;629 let noOutputContent = settings.onDropItem.NoOutputContent;630 mc.listen("onDropItem", function (pl, it) {631 try {632 let pos = pl.pos;633 writeLog(logToFile, logToConsole, noOutputContent,634 i18n.$t("event.onDropItem"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), it.name, '', '', '', `${it.count}`);635 }636 catch (exception) {637 if (_SHOW_ERROR_INFO) throw exception;638 }639 });640}641//onEat642if (settings.onEat.LogToFile || settings.onEat.LogToConsole) {643 let logToFile = settings.onEat.LogToFile;644 let logToConsole = settings.onEat.LogToConsole;645 let noOutputContent = settings.onEat.NoOutputContent;646 mc.listen("onEat", function (pl, it) {647 try {648 let pos = pl.pos;649 writeLog(logToFile, logToConsole, noOutputContent,650 i18n.$t("event.onEat"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), it.name, '', '', '', '');651 }652 catch (exception) {653 if (_SHOW_ERROR_INFO) throw exception;654 }655 });656}657//onStartDestroyBlock658if (settings.onStartDestroyBlock.LogToFile || settings.onStartDestroyBlock.LogToConsole) {659 let logToFile = settings.onStartDestroyBlock.LogToFile;660 let logToConsole = settings.onStartDestroyBlock.LogToConsole;661 let noOutputContent = settings.onStartDestroyBlock.NoOutputContent;662 mc.listen("onStartDestroyBlock", function (pl, bl) {663 try {664 let blPos = bl.pos;665 let pos = pl.pos;666 writeLog(logToFile, logToConsole, noOutputContent,667 i18n.$t("event.onStartDestroyBlock"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), bl.name, blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), '');668 }669 catch (exception) {670 if (_SHOW_ERROR_INFO) throw exception;671 }672 });673}674//onDestroyBlock675if (settings.onDestroyBlock.LogToFile || settings.onDestroyBlock.LogToConsole) {676 let logToFile = settings.onDestroyBlock.LogToFile;677 let logToConsole = settings.onDestroyBlock.LogToConsole;678 let noOutputContent = settings.onDestroyBlock.NoOutputContent;679 mc.listen("onDestroyBlock", function (pl, bl) {680 try {681 let blPos = bl.pos;682 let pos = pl.pos;683 writeLog(logToFile, logToConsole, noOutputContent,684 i18n.$t("event.onDestroyBlock"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), bl.name, blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), '');685 }686 catch (exception) {687 if (_SHOW_ERROR_INFO) throw exception;688 }689 });690}691//onPlaceBlock692if (settings.onPlaceBlock.LogToFile || settings.onPlaceBlock.LogToConsole) {693 let logToFile = settings.onPlaceBlock.LogToFile;694 let logToConsole = settings.onPlaceBlock.LogToConsole;695 let noOutputContent = settings.onPlaceBlock.NoOutputContent;696 mc.listen("onPlaceBlock", function (pl, bl) {697 try {698 //防抖699 if (pl.getExtraData("_BEHAVIOR_LOG_PLACE_BLOCK"))700 return;701 else {702 pl.setExtraData("_BEHAVIOR_LOG_PLACE_BLOCK", true);703 setTimeout(function () { pl.setExtraData("_BEHAVIOR_LOG_PLACE_BLOCK", null); }, 100);704 }705 let blPos = bl.pos;706 let pos = pl.pos;707 writeLog(logToFile, logToConsole, noOutputContent,708 i18n.$t("event.onPlaceBlock"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), bl.name, blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), '');709 }710 catch (exception) {711 if (_SHOW_ERROR_INFO) throw exception;712 }713 });714}715//onOpenContainer716if (settings.onOpenContainer.LogToFile || settings.onOpenContainer.LogToConsole) {717 let logToFile = settings.onOpenContainer.LogToFile;718 let logToConsole = settings.onOpenContainer.LogToConsole;719 let noOutputContent = settings.onOpenContainer.NoOutputContent;720 mc.listen("onOpenContainer", function (pl, bl) {721 try {722 let blPos = bl.pos;723 let pos = pl.pos;724 writeLog(logToFile, logToConsole, noOutputContent,725 i18n.$t("event.onOpenContainer"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), bl.name, blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), '');726 }727 catch (exception) {728 if (_SHOW_ERROR_INFO) throw exception;729 }730 });731}732//onCloseContainer733if (settings.onCloseContainer.LogToFile || settings.onCloseContainer.LogToConsole) {734 let logToFile = settings.onCloseContainer.LogToFile;735 let logToConsole = settings.onCloseContainer.LogToConsole;736 let noOutputContent = settings.onCloseContainer.NoOutputContent;737 mc.listen("onCloseContainer", function (pl, bl) {738 try {739 let blPos = bl.pos;740 let pos = pl.pos;741 writeLog(logToFile, logToConsole, noOutputContent,742 i18n.$t("event.onCloseContainer"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), bl.name, blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), '');743 }744 catch (exception) {745 if (_SHOW_ERROR_INFO) throw exception;746 }747 });748}749////////////////////////// 细化修改 //////////////////////////750//onInventoryChange751if (settings.onInventoryChange.LogToFile || settings.onInventoryChange.LogToConsole) {752 let logToFile = settings.onInventoryChange.LogToFile;753 let logToConsole = settings.onInventoryChange.LogToConsole;754 let noOutputContent = settings.onInventoryChange.NoOutputContent;755 mc.listen("onInventoryChange", function (pl, slotNum, oldItem, newItem) {756 try {757 if (pl.getExtraData("_BEHAVIOR_LOG_PLAYER_IS_JOINING_SERVER"))758 return;759 let pos = pl.pos;760 if (newItem.isNull())761 writeLog(logToFile, logToConsole, noOutputContent,762 i18n.$t("event.onInventoryOut"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), oldItem.name, '', '', '', i18n.$t("detial.onInventory",[oldItem.count,slotNum]));763 else764 writeLog(logToFile, logToConsole, noOutputContent,765 i18n.$t("event.onInventoryIn"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), newItem.name, '', '', '', i18n.$t("detial.onInventory",[newItem.count,slotNum]));766 }767 catch (exception) {768 if (_SHOW_ERROR_INFO) throw exception;769 }770 });771}772//onSetArmor773if (settings.onSetArmor.LogToFile || settings.onSetArmor.LogToConsole) {774 let logToFile = settings.onSetArmor.LogToFile;775 let logToConsole = settings.onSetArmor.LogToConsole;776 let noOutputContent = settings.onSetArmor.NoOutputContent;777 mc.listen("onSetArmor", function (pl, slotNum, newItem) {778 try {779 if (pl.getExtraData("_BEHAVIOR_LOG_PLAYER_IS_JOINING_SERVER"))780 return;781 let pos = pl.pos;782 if (newItem.isNull())783 writeLog(logToFile, logToConsole, noOutputContent,784 i18n.$t("event.onSetArmorOut"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', i18n.$t("detial.slot",[slotNum]));785 else786 writeLog(logToFile, logToConsole, noOutputContent,787 i18n.$t("event.onSetArmorIn"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), newItem.name, '', '', '', i18n.$t("detial.onInventory",[newItem.count,slotNum]));788 }789 catch (exception) {790 if (_SHOW_ERROR_INFO) throw exception;791 }792 });793}794//onUseRespawnAnchor795if (settings.onUseRespawnAnchor.LogToFile || settings.onUseRespawnAnchor.LogToConsole) {796 let logToFile = settings.onUseRespawnAnchor.LogToFile;797 let logToConsole = settings.onUseRespawnAnchor.LogToConsole;798 let noOutputContent = settings.onUseRespawnAnchor.NoOutputContent;799 mc.listen("onUseRespawnAnchor", function (pl, blPos) {800 try {801 let pos = pl.pos;802 writeLog(logToFile, logToConsole, noOutputContent,803 i18n.$t("event.onUseRespawnAnchor"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), 'minecraft:respawn_anchor', blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), '');804 }805 catch (exception) {806 if (_SHOW_ERROR_INFO) throw exception;807 }808 });809}810//onOpenContainerScreen811if (settings.onOpenContainerScreen.LogToFile || settings.onOpenContainerScreen.LogToConsole) {812 let logToFile = settings.onOpenContainerScreen.LogToFile;813 let logToConsole = settings.onOpenContainerScreen.LogToConsole;814 let noOutputContent = settings.onOpenContainerScreen.NoOutputContent;815 mc.listen("onOpenContainerScreen", function (pl) {816 try {817 let pos = pl.pos;818 writeLog(logToFile, logToConsole, noOutputContent,819 i18n.$t("event.onOpenContainerScreen"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', '');820 }821 catch (exception) {822 if (_SHOW_ERROR_INFO) throw exception;823 }824 });825}826//onMobDie827if (settings.onMobDie.LogToFile || settings.onMobDie.LogToConsole) {828 let logToFile = settings.onMobDie.LogToFile;829 let logToConsole = settings.onMobDie.LogToConsole;830 let noOutputContent = settings.onMobDie.NoOutputContent;831 mc.listen("onMobDie", function (mob, source) {832 try {833 if (mob.type != "minecraft:player") {834 let pos = mob.pos;835 writeLog(logToFile, logToConsole, noOutputContent,836 i18n.$t("event.onMobDie"), pos.dim, mob.name, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', i18n.$t("detial.attickFrom",[source.name]));837 }838 }839 catch (exception) {840 if (_SHOW_ERROR_INFO) throw exception;841 }842 });843}844//onMobHurt845if (settings.onMobHurt.LogToFile || settings.onMobHurt.LogToConsole) {846 let logToFile = settings.onMobHurt.LogToFile;847 let logToConsole = settings.onMobHurt.LogToConsole;848 let noOutputContent = settings.onMobHurt.NoOutputContent;849 mc.listen("onMobHurt", function (mob, source, damage) {850 try {851 let pos = mob.pos;852 writeLog(logToFile, logToConsole, noOutputContent,853 i18n.$t("event.onMobHurt"), pos.dim, mob.name, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', i18n.$t("detial.hurt",[source.name,damage]));854 }855 catch (exception) {856 if (_SHOW_ERROR_INFO) throw exception;857 }858 });859}860//onExplode861if (settings.onExplode.LogToFile || settings.onExplode.LogToConsole) {862 let logToFile = settings.onExplode.LogToFile;863 let logToConsole = settings.onExplode.LogToConsole;864 let noOutputContent = settings.onExplode.NoOutputContent;865 mc.listen("onExplode", function (source, pos) {866 try {867 writeLog(logToFile, logToConsole, noOutputContent,868 i18n.$t("event.onExplode"), pos.dim, source.name, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', '');869 }870 catch (exception) {871 if (_SHOW_ERROR_INFO) throw exception;872 }873 });874}875//onProjectileHitEntity876if (settings.onProjectileHitEntity.LogToFile || settings.onProjectileHitEntity.LogToConsole) {877 let logToFile = settings.onProjectileHitEntity.LogToFile;878 let logToConsole = settings.onProjectileHitEntity.LogToConsole;879 let noOutputContent = settings.onProjectileHitEntity.NoOutputContent;880 mc.listen("onProjectileHitEntity", function (entity, source) {881 try {882 let pos = entity.pos;883 writeLog(logToFile, logToConsole, noOutputContent,884 i18n.$t("event.onProjectileHitEntity"), pos.dim, source.name, '', '', '', entity.name, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '');885 }886 catch (exception) {887 if (_SHOW_ERROR_INFO) throw exception;888 }889 });890}891//onWitherBossDestroy892if (settings.onWitherBossDestroy.LogToFile || settings.onWitherBossDestroy.LogToConsole) {893 let logToFile = settings.onWitherBossDestroy.LogToFile;894 let logToConsole = settings.onWitherBossDestroy.LogToConsole;895 let noOutputContent = settings.onWitherBossDestroy.NoOutputContent;896 mc.listen("onWitherBossDestroy", function (witherBoss, AAbb, aaBB) {897 try {898 let pos = witherBoss.pos;899 writeLog(logToFile, logToConsole, noOutputContent,900 i18n.$t("event.onWitherBossDestroy"), pos.dim, witherBoss.name, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', i18n.$t("detial.witherDestpry",[Pos2String(AAbb),Pos2String(aaBB)]));901 }902 catch (exception) {903 if (_SHOW_ERROR_INFO) throw exception;904 }905 });906}907//onRide908if (settings.onRide.LogToFile || settings.onRide.LogToConsole) {909 let logToFile = settings.onRide.LogToFile;910 let logToConsole = settings.onRide.LogToConsole;911 let noOutputContent = settings.onRide.NoOutputContent;912 mc.listen("onRide", function (ac1, ac2) {913 try {914 let pos = ac1.pos;915 let pos2 = ac2.pos;916 writeLog(logToFile, logToConsole, noOutputContent,917 i18n.$t("event.onRide"), pos.dim, ac1.name, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), ac2.name, pos2.x.toFixed(0), pos2.y.toFixed(0), pos2.z.toFixed(0), '');918 }919 catch (exception) {920 if (_SHOW_ERROR_INFO) throw exception;921 }922 });923}924//onStepOnPressurePlate925if (settings.onStepOnPressurePlate.LogToFile || settings.onStepOnPressurePlate.LogToConsole) {926 let logToFile = settings.onStepOnPressurePlate.LogToFile;927 let logToConsole = settings.onStepOnPressurePlate.LogToConsole;928 let noOutputContent = settings.onStepOnPressurePlate.NoOutputContent;929 mc.listen("onStepOnPressurePlate", function (ac, plate) {930 try {931 let pos = ac.pos;932 let blPos = plate.pos;933 writeLog(logToFile, logToConsole, noOutputContent,934 i18n.$t("event.onStepOnPressurePlate"), pos.dim, ac.name, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), plate.name, blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), '');935 }936 catch (exception) {937 if (_SHOW_ERROR_INFO) throw exception;938 }939 });940}941//onBlockInteracted942if (settings.onBlockInteracted.LogToFile || settings.onBlockInteracted.LogToConsole) {943 let logToFile = settings.onBlockInteracted.LogToFile;944 let logToConsole = settings.onBlockInteracted.LogToConsole;945 let noOutputContent = settings.onBlockInteracted.NoOutputContent;946 mc.listen("onBlockInteracted", function (pl, bl) {947 try {948 let pos = pl.pos;949 let blPos = bl.pos;950 writeLog(logToFile, logToConsole, noOutputContent,951 i18n.$t("event.onBlockInteracted"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), bl.name, blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), '');952 }953 catch (exception) {954 if (_SHOW_ERROR_INFO) throw exception;955 }956 });957}958//onBedExplode959if (settings.onBedExplode.LogToFile || settings.onBedExplode.LogToConsole) {960 let logToFile = settings.onBedExplode.LogToFile;961 let logToConsole = settings.onBedExplode.LogToConsole;962 let noOutputContent = settings.onBedExplode.NoOutputContent;963 mc.listen("onBedExplode", function (pos) {964 try {965 writeLog(logToFile, logToConsole, noOutputContent,966 i18n.$t("event.onBedExplode"), pos.dim, "minecraft:bed", pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', '');967 }968 catch (exception) {969 if (_SHOW_ERROR_INFO) throw exception;970 }971 });972}973//onRespawnAnchorExplode974if (settings.onRespawnAnchorExplode.LogToFile || settings.onRespawnAnchorExplode.LogToConsole) {975 let logToFile = settings.onRespawnAnchorExplode.LogToFile;976 let logToConsole = settings.onRespawnAnchorExplode.LogToConsole;977 let noOutputContent = settings.onRespawnAnchorExplode.NoOutputContent;978 mc.listen("onRespawnAnchorExplode", function (pos, pl) {979 try {980 writeLog(logToFile, logToConsole, noOutputContent,981 i18n.$t("event.onRespawnAnchorExplode"), pos.dim, "minecraft:respawn_anchor", pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', i18n.$t("detial.causeBy",[pl.realName]));982 }983 catch (exception) {984 if (_SHOW_ERROR_INFO) throw exception;985 }986 });987}988//onBlockExploded989if (settings.onBlockExploded.LogToFile || settings.onBlockExploded.LogToConsole) {990 let logToFile = settings.onBlockExploded.LogToFile;991 let logToConsole = settings.onBlockExploded.LogToConsole;992 let noOutputContent = settings.onBlockExploded.NoOutputContent;993 mc.listen("onBlockExploded", function (bl, source) {994 try {995 let pos = bl.pos;996 writeLog(logToFile, logToConsole, noOutputContent,997 i18n.$t("event.onBlockExploded"), pos.dim, bl.name, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', i18n.$t("detial.causeBy",[source.name]));998 }999 catch (exception) {1000 if (_SHOW_ERROR_INFO) throw exception;1001 }1002 });1003}1004//onCmdBlockExecute1005if (settings.onCmdBlockExecute.LogToFile || settings.onCmdBlockExecute.LogToConsole) {1006 let logToFile = settings.onCmdBlockExecute.LogToFile;1007 let logToConsole = settings.onCmdBlockExecute.LogToConsole;1008 let noOutputContent = settings.onCmdBlockExecute.NoOutputContent;1009 mc.listen("onCmdBlockExecute", function (cmd, pos) {1010 try {1011 writeLog(logToFile, logToConsole, noOutputContent,1012 i18n.$t("event.onCmdBlockExecute"), pos.dim, "minecraft:command_block", pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), cmd, '', '', '', '');1013 }1014 catch (exception) {1015 if (_SHOW_ERROR_INFO) throw exception;1016 }1017 });1018}1019////////////////////////// 细化修改 //////////////////////////1020//onContainerChange1021if (settings.onContainerChange.LogToFile || settings.onContainerChange.LogToConsole) {1022 let logToFile = settings.onContainerChange.LogToFile;1023 let logToConsole = settings.onContainerChange.LogToConsole;1024 let noOutputContent = settings.onContainerChange.NoOutputContent;1025 mc.listen("onContainerChange", function (pl, bl, slotNum, oldItem, newItem) {1026 try {1027 let pos = pl.pos;1028 let blPos = bl.pos;1029 if (newItem.isNull())1030 writeLog(logToFile, logToConsole, noOutputContent,1031 i18n.$t("event.onContainerOut"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), bl.name, blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), i18n.$t("detial.ContainOut",[slotNum,oldItem.count,oldItem.name]));1032 else1033 writeLog(logToFile, logToConsole, noOutputContent,1034 i18n.$t("event.onContainerIn"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), bl.name, blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), i18n.$t("detial.ContainIn",[slotNum,newItem.count,newItem.name]));1035 }1036 catch (exception) {1037 if (_SHOW_ERROR_INFO) throw exception;1038 }1039 });1040}1041//onProjectileHitBlock1042if (settings.onProjectileHitBlock.LogToFile || settings.onProjectileHitBlock.LogToConsole) {1043 let logToFile = settings.onProjectileHitBlock.LogToFile;1044 let logToConsole = settings.onProjectileHitBlock.LogToConsole;1045 let noOutputContent = settings.onProjectileHitBlock.NoOutputContent;1046 mc.listen("onProjectileHitBlock", function (bl, source) {1047 try {1048 let pos = bl.pos;1049 writeLog(logToFile, logToConsole, noOutputContent,1050 i18n.$t("event.onProjectileHitBlock"), pos.dim, source.name, '', '', '', bl.name, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '');1051 }1052 catch (exception) {1053 if (_SHOW_ERROR_INFO) throw exception;1054 }1055 });1056}1057//onRedStoneUpdate1058if (settings.onRedStoneUpdate.LogToFile || settings.onRedStoneUpdate.LogToConsole) {1059 let logToFile = settings.onRedStoneUpdate.LogToFile;1060 let logToConsole = settings.onRedStoneUpdate.LogToConsole;1061 let noOutputContent = settings.onRedStoneUpdate.NoOutputContent;1062 mc.listen("onRedStoneUpdate", function (bl, level, isActive) {1063 try {1064 let pos = bl.pos;1065 writeLog(logToFile, logToConsole, noOutputContent,1066 i18n.$t("event.onRedStoneUpdate"), pos.dim, bl.name, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', isActive ? i18n.$t("detial.on",[level]): i18n.$t("detial.off"));1067 }1068 catch (exception) {1069 if (_SHOW_ERROR_INFO) throw exception;1070 }1071 });1072}1073//onHopperPushOut1074if (settings.onHopperPushOut.LogToFile || settings.onHopperPushOut.LogToConsole) {1075 let logToFile = settings.onHopperPushOut.LogToFile;1076 let logToConsole = settings.onHopperPushOut.LogToConsole;1077 let noOutputContent = settings.onHopperPushOut.NoOutputContent;1078 mc.listen("onHopperPushOut", function (pos) {1079 try {1080 writeLog(logToFile, logToConsole, noOutputContent,1081 i18n.$t("event.onHopperPushOut"), pos.dim, "Hopper", pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', '');1082 }1083 catch (exception) {1084 if (_SHOW_ERROR_INFO) throw exception;1085 }1086 });1087}1088//onPistonPush1089if (settings.onPistonPush.LogToFile || settings.onPistonPush.LogToConsole) {1090 let logToFile = settings.onPistonPush.LogToFile;1091 let logToConsole = settings.onPistonPush.LogToConsole;1092 let noOutputContent = settings.onPistonPush.NoOutputContent;1093 mc.listen("onPistonPush", function (pos, bl) {1094 try {1095 let pis = mc.getBlock(pos);1096 let blPos = bl.pos;1097 writeLog(logToFile, logToConsole, noOutputContent,1098 i18n.$t("event.onPistonPush"), pos.dim, pis.name, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), bl.name, blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), '');1099 }1100 catch (exception) {1101 if (_SHOW_ERROR_INFO) throw exception;1102 }1103 });1104}1105//onFarmLandDecay1106if (settings.onFarmLandDecay.LogToFile || settings.onFarmLandDecay.LogToConsole) {1107 let logToFile = settings.onFarmLandDecay.LogToFile;1108 let logToConsole = settings.onFarmLandDecay.LogToConsole;1109 let noOutputContent = settings.onFarmLandDecay.NoOutputContent;1110 mc.listen("onFarmLandDecay", function (blPos, ac) {1111 try {1112 let pos = ac.pos;1113 writeLog(logToFile, logToConsole, noOutputContent,1114 i18n.$t("event.onFarmLandDecay"), pos.dim, ac.name, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), 'minecraft:farm_land', blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), '');1115 }1116 catch (exception) {1117 if (_SHOW_ERROR_INFO) throw exception;1118 }1119 });1120}1121//onUseFrameBlock1122if (settings.onUseFrameBlock.LogToFile || settings.onUseFrameBlock.LogToConsole) {1123 let logToFile = settings.onUseFrameBlock.LogToFile;1124 let logToConsole = settings.onUseFrameBlock.LogToConsole;1125 let noOutputContent = settings.onUseFrameBlock.NoOutputContent;1126 mc.listen("onUseFrameBlock", function (pl, bl) {1127 try {1128 let pos = pl.pos;1129 let blPos = bl.pos;1130 writeLog(logToFile, logToConsole, noOutputContent,1131 i18n.$t("event.onUseFrameBlock"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), bl.name, blPos.x.toFixed(0), blPos.y.toFixed(0), blPos.z.toFixed(0), '');1132 }1133 catch (exception) {1134 if (_SHOW_ERROR_INFO) throw exception;1135 }1136 });1137}1138//onScoreChanged1139if (settings.onScoreChanged.LogToFile || settings.onScoreChanged.LogToConsole) {1140 let logToFile = settings.onScoreChanged.LogToFile;1141 let logToConsole = settings.onScoreChanged.LogToConsole;1142 let noOutputContent = settings.onScoreChanged.NoOutputContent;1143 mc.listen("onScoreChanged", function (pl, num, name, disName) {1144 try {1145 let pos = pl.pos;1146 writeLog(logToFile, logToConsole, noOutputContent,1147 i18n.$t("event.onScoreChanged"), pos.dim, pl.realName, pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', i18n.$t("detial.scoreboardChange",[name,num]));1148 }1149 catch (exception) {1150 if (_SHOW_ERROR_INFO) throw exception;1151 }1152 });1153}1154//onFireSpread1155if (settings.onFireSpread.LogToFile || settings.onFireSpread.LogToConsole) {1156 let logToFile = settings.onFireSpread.LogToFile;1157 let logToConsole = settings.onFireSpread.LogToConsole;1158 let noOutputContent = settings.onFireSpread.NoOutputContent;1159 mc.listen("onFireSpread", function (pos) {1160 try {1161 if (pos.dimid != 1)1162 writeLog(logToFile, logToConsole, noOutputContent,1163 i18n.$t("event.onFireSpread"), pos.dim, "minecraft:fire", pos.x.toFixed(0), pos.y.toFixed(0), pos.z.toFixed(0), '', '', '', '', '');1164 }1165 catch (exception) {1166 if (_SHOW_ERROR_INFO) throw exception;1167 }1168 });1169}1170//onConsoleCmd1171if (settings.onConsoleCmd.LogToFile || settings.onConsoleCmd.LogToConsole) {1172 let logToFile = settings.onConsoleCmd.LogToFile;1173 let logToConsole = settings.onConsoleCmd.LogToConsole;1174 let noOutputContent = settings.onConsoleCmd.NoOutputContent;1175 mc.listen("onConsoleCmd", function (cmd) {1176 try {1177 writeLog(logToFile, logToConsole, noOutputContent,1178 i18n.$t("event.onConsoleCmd"), '', '', '', '', '', cmd, '', '', '', '');1179 }1180 catch (exception) {1181 if (_SHOW_ERROR_INFO) throw exception;1182 }1183 });1184}1185//特殊记录1186mc.listen("onPreJoin", function (pl) {1187 pl.setExtraData("_BEHAVIOR_LOG_PLAYER_IS_JOINING_SERVER", true);1188});1189mc.listen("onJoin", function (pl) {1190 pl.setExtraData("_BEHAVIOR_LOG_PLAYER_IS_JOINING_SERVER", false);1191});1192//实用1193function Pos2String(pos) {1194 return `(${pos.x.toFixed(0)},${pos.y.toFixed(0)},${pos.z.toFixed(0)})`;1195}1196//清理1197delete settings;1198//注册临时关闭1199mc.regConsoleCmd("behaviorlog", "Contorl BehaviorLog", function (args) {1200 if (args[0] == 'hide') {1201 if (conf.ShowLogInConsole)1202 conf.ShowLogInConsole = false;1203 log(i18n.$t("console.off"));1204 }1205 else if (args[0] == 'show') {1206 if (!conf.ShowLogInConsole)1207 conf.ShowLogInConsole = true;1208 log(i18n.$t("console.on"));1209 }1210 else1211 log(i18n.$t("console.error"));1212});1213log(i18n.$t("info.log") + _VER[0] + "." + _VER[1] + "." + _VER[2]);1214log(i18n.$t("info.configD") + _CONFIG_PATH);1215log('作者:yqs112358 发布平台:MineBBS');...

Full Screen

Full Screen

websock.js

Source:websock.js Github

copy

Full Screen

...18 function runAcc(e) {19 if (!e || e==-1 || e.which == 13 || e.keyCode == 13) {20 if(!connected) 21 {22 logToConsole("No connection!");23 return false; 24 }25 var ss = document.getElementById("setacc");26 if(e==-1) ss.value="";27 if(ss.value[0]!='-') ss.value="-Y"+ss.value;28 logToConsole("Setting access to secret key...");29 websocket.send(ss.value);30 ss.value="";31 return false;32 }33}34 35 function runPas(e) {36 if (!e || e==-1 || e.which == 13 || e.keyCode == 13) {37 if(!connected) 38 {39 logToConsole("No connection!");40 return false; 41 }42 var ss = document.getElementById("setpas");43 if(e==-1) 44 {45 if(ss.value!="") ss.value="Please enter our password (for '" + ss.value +"')!";46 else ss.value="Please enter our password (for me)!";47 logToConsole("Sending request for indentification...");48 }49 else50 {51 if(ss.value[0]!='-') ss.value="-P"+ss.value;52 logToConsole("Setting shared password...");53 }54 websocket.send(ss.value);55 ss.value="";56 return false;57 }58} 59 60 function runKey(e) {61 if (!e || e==-1 || e.which == 13 || e.keyCode == 13) {62 if(!connected) 63 {64 logToConsole("No connection!");65 return false; 66 }67 var ss = document.getElementById("setkey");68 if(e==-1) ss.value="";69 if(ss.value[0]!='-') ss.value="-K"+ss.value;70 logToConsole("Sending public key: "+ss.value);71 websocket.send(ss.value);72 ss.value="";73 return false;74 }75}76 77 function runScript(e) {78 if (e.which == 13 || e.keyCode == 13) {79 if(!connected) 80 {81 logToConsole("No connection!");82 return false; 83 }84 85 logToConsole(sendMessage.value);86 websocket.send(sendMessage.value);87 sendMessage.value="";88 return false;89 }90}91 function echoHandlePageLoad()92 {93 if (window.WebSocket)94 {95 document.getElementById("webSocketSupp").style.display = "block";96 }97 else98 {99 document.getElementById("noWebSocketSupp").style.display = "block";100 }101 secureCb = document.getElementById("secureCb");102 secureCb.checked = false;103 secureCb.onclick = toggleTls;104 105 secureCbLabel = document.getElementById("secureCbLabel")106 107 helpCb = document.getElementById("helpCb");108 helpCb.checked = true;109 110 wsUri = document.getElementById("wsUri");111 toggleTls();112 113 connectBut = document.getElementById("connect");114 connectBut.onclick = doConnect;115 116 sendMessage = document.getElementById("sendMessage");117 sendMessage.ondblclick = doMsg;118 sendBut = document.getElementById("send");119 sendBut.onclick = doSend;120 udpBut = document.getElementById("budp");121 udpBut.onclick = doUdp;122 123 upBut = document.getElementById("bup");124 upBut.onclick = doUp;125 126 tcpBut = document.getElementById("btcp");127 tcpBut.onclick = doTcp;128 129 callBut = document.getElementById("bcall");130 callBut.onclick = doCall;131 132 leftBut = document.getElementById("bleft");133 leftBut.onclick = doLeft;134 135 rightBut = document.getElementById("bright");136 rightBut.onclick = doRight;137 138 talkBut = document.getElementById("btalk");139 talkBut.onmousedown = doSpeek;140 talkBut.onmouseup = doMute;141 142 exitBut = document.getElementById("bexit");143 exitBut.onclick = doExit;144 145 downBut = document.getElementById("bdown");146 downBut.onclick = doDown;147 148 vadBut = document.getElementById("bvad");149 vadBut.onclick = doVad;150 151 brkBut = document.getElementById("bbrk");152 brkBut.onclick = doBrk;153 154 haltBut = document.getElementById("bhalt");155 haltBut.ondblclick = doHalt;156 157 ansBut = document.getElementById("bans");158 ansBut.onclick = doAns;159 160 pingBut = document.getElementById("bping");161 pingBut.onclick = doPing;162 163 findBut = document.getElementById("bfind");164 findBut.onclick = doFind;165 166 nameBut = document.getElementById("bname");167 nameBut.onclick = doName;168 169 bookBut = document.getElementById("bbook");170 bookBut.onclick = doBook;171 172 autBut = document.getElementById("baut");173 autBut.onclick = doAut;174 175 otherBut = document.getElementById("bother");176 otherBut.onclick = doOther;177 178 179 //accBut = document.getElementById("bacc");180 //pasSet = document.getElementById("setpas");181 //pasBut = document.getElementById("bpas");182 //keySet = document.getElementById("setkey");183 //keyBut = document.getElementById("bkey");184 consoleLog = document.getElementById("consoleLog");185 clearLogBut = document.getElementById("clearLogBut");186 clearLogBut.onclick = clearLog;187 var nojavaDiv=document.getElementById("nojava");188 nojavaDiv.style.display="none";189 setGuiConnected(false);190 doBook();191 doAut();192 doOther();193 194 document.getElementById("send").onclick = doSend;195 196 codecSel = document.getElementById("codec");197 codecSel.onchange = setCodec;198 199 noiseCb = document.getElementById("noiseCb");200 noiseCb.onclick = setNoise;201 202 vocCb = document.getElementById("vocCb");203 vocCb.onclick = setVoc;204 205 testCb = document.getElementById("testCb");206 testCb.onclick = setTest;207 208 gainCb = document.getElementById("gainCb");209 gainCb.onclick = setGain;210 211 jitterSel = document.getElementById("jitter");212 jitterSel.onchange = setJitter;213 }214 function toggleTls()215 {216 var wsPort = (window.location.port.toString() === "" ? "" : ":"+window.location.port)217 if (wsUri.value === "") {218 wsUri.value = "ws://localhost:8000" + window.location.hostname.replace("www", "echo") + wsPort;219 }220 221 if (secureCb.checked)222 {223 wsUri.value = wsUri.value.replace("ws:", "wss:");224 }225 else226 {227 wsUri.value = wsUri.value.replace ("wss:", "ws:");228 }229 }230 231 function doConnect()232 {233 if(connected)234 {235 websocket.close();236 return;237 }238 239 if (window.MozWebSocket)240 {241 logToConsole('<span style="color: red;"><strong>Info:</strong> This browser supports WebSocket using the MozWebSocket constructor</span>');242 window.WebSocket = window.MozWebSocket;243 }244 else if (!window.WebSocket)245 {246 logToConsole('<span style="color: red;"><strong>Error:</strong> This browser does not have support for WebSocket</span>');247 return;248 }249 // prefer text messages250 var uri = wsUri.value;251 if (uri.indexOf("?") == -1) {252 uri += "?encoding=text";253 } else {254 uri += "&encoding=text";255 }256 websocket = new WebSocket(uri);257 websocket.onopen = function(evt) { onOpen(evt) };258 websocket.onclose = function(evt) { onClose(evt) };259 websocket.onmessage = function(evt) { onMessage(evt) };260 websocket.onerror = function(evt) { onError(evt) };261 }262 263 function doSend()264 {265 if(!connected) 266 {267 logToConsole("No connection!");268 return; 269 }270 if(sendMessage.value!="")271 {272 logToConsole(sendMessage.value);273 websocket.send(sendMessage.value);274 sendMessage.value="";275 }276 else277 {278 logToConsole("Sending OK");279 websocket.send("#10"); 280 }281 }282 283 function doUdp()284 {285 if(!connected) 286 {287 logToConsole("No connection!");288 return; 289 }290 291 logToConsole("Trying UDP...");292 websocket.send("-S");293 }294 295 function doUp()296 {297 if(!connected) 298 {299 logToConsole("No connection!");300 return; 301 }302 303 websocket.send("#4");304 }305 306 function doTcp()307 {308 if(!connected) 309 {310 logToConsole("No connection!");311 return; 312 }313 314 logToConsole("Back to Onion...");315 websocket.send("-O");316 }317 318 function doCall()319 {320 if(!connected) 321 {322 logToConsole("No connection!");323 return; 324 }325 326 if(sendMessage.value[0] != '-') sendMessage.value = "-O" + sendMessage.value;327 else328 {329 logToConsole("Call: " + sendMessage.value);330 websocket.send(sendMessage.value);331 sendMessage.value="";332 }333 }334 335 function doLeft()336 {337 if(!connected) 338 {339 logToConsole("No connection!");340 return; 341 }342 343 websocket.send("#7");344 }345 346 function doRight()347 {348 if(!connected) 349 {350 logToConsole("No connection!");351 return; 352 }353 354 websocket.send("#6");355 }356 357 function doSpeek()358 {359 if(!connected) 360 {361 logToConsole("No connection!");362 return; 363 }364 365 //logToConsole("Speek");366 websocket.send("-R1");367 }368 369 function doMute()370 {371 if(!connected) 372 {373 logToConsole("No connection!");374 return; 375 }376 377 //logToConsole("Mute");378 websocket.send("-R0");379 }380 function doExit()381 {382 if(!connected) 383 {384 logToConsole("No connection!");385 return; 386 }387 388 logToConsole("OnionPhone status:");389 websocket.send("-RI");390 }391 392 function doDown()393 {394 if(!connected) 395 {396 logToConsole("No connection!");397 return; 398 }399 400 websocket.send("#5");401 }402 403 function doVad()404 {405 if(!connected) 406 {407 logToConsole("No connection!");408 return; 409 }410 411 logToConsole("Enabling VAD");412 websocket.send("#3");413 }414 415 function doBrk()416 {417 if(!connected) 418 {419 logToConsole("No connection!");420 return; 421 }422 423 logToConsole("Termination of the call...");424 websocket.send("-H");425 }426 427 428 429 430 function doAns()431 {432 if(!connected) 433 {434 logToConsole("No connection!");435 return; 436 }437 438 logToConsole("Accepts the call...");439 websocket.send("#10");440 }441 442 function doPing()443 {444 if(!connected) 445 {446 logToConsole("No connection!");447 return; 448 }449 450 logToConsole("Ping...");451 websocket.send("-RL");452 }453 454 function doFind()455 {456 if(!connected) 457 {458 logToConsole("No connection!");459 return; 460 }461 462 logToConsole("Searching in Address Book: "+sendMessage.value);463 sendMessage.value = "-V" + sendMessage.value;464 websocket.send(sendMessage.value);465 sendMessage.value="";466 }467 468 function doName()469 {470 if(!connected) 471 {472 logToConsole("No connection!");473 return; 474 }475 476 logToConsole("Extracting the name..."+sendMessage.value);477 sendMessage.value = "-E" + sendMessage.value;478 websocket.send(sendMessage.value);479 sendMessage.value="";480 }481 482 483 484 485 486 function doMsg()487 {488 if(!connected) 489 {490 logToConsole("No connection!");491 return; 492 }493 494 logToConsole(sendMessage.value);495 websocket.send(sendMessage.value);496 sendMessage.value="";497 }498 499 function doBook()500 { 501 bl = document.getElementById("book");502 if(bookBut.innerHTML==="+")503 {504 bookBut.innerHTML="-";505 bl.style.display="block";506 }507 else 508 { 509 bookBut.innerHTML="+";510 bl.style.display="none";511 }512 }513 514 function doAut()515 {516 bl = document.getElementById("aut");517 if(autBut.innerHTML==="+")518 {519 autBut.innerHTML="-";520 bl.style.display="block";521 }522 else 523 { 524 autBut.innerHTML="+";525 bl.style.display="none";526 }527 }528 529 function doOther()530 {531 bl = document.getElementById("other");532 if(otherBut.innerHTML==="+")533 {534 otherBut.innerHTML="-";535 bl.style.display="block";536 }537 else 538 { 539 otherBut.innerHTML="+";540 bl.style.display="none";541 }542 }543 544 function setCodec()545 {546 if(!connected) 547 {548 logToConsole("No connection!");549 return; 550 }551 552 logToConsole("Changing audio Codec...");553 websocket.send(codecSel.value); 554 }555 556 function doHalt()557 {558 if(!connected) 559 {560 logToConsole("No connection!");561 return; 562 }563 564 logToConsole("Shutdown OnionPhone...");565 websocket.send("-X");566 }567 568 function setGain()569 {570 var cm;571 if(!connected) 572 {573 logToConsole("No connection!");574 return; 575 }576 577 if(gainCb.checked) cm="-Q1"; else cm="-Q-1";578 logToConsole("Changing AGC...");579 websocket.send(cm); 580 }581 function setNoise()582 {583 var cm;584 if(!connected) 585 {586 logToConsole("No connection!");587 return; 588 }589 590 if(noiseCb.checked) cm="-Q2"; else cm="-Q-2";591 logToConsole("Changing NPP...");592 websocket.send(cm);593 }594 595 function setVoc()596 {597 var cm;598 if(!connected) 599 {600 logToConsole("No connection!");601 return; 602 }603 604 if(vocCb.checked) cm="-Q3"; else cm="-Q-3";605 logToConsole("Changing VOC...");606 websocket.send(cm); 607 }608 609 function setTest()610 {611 var cm;612 if(!connected) 613 {614 logToConsole("No connection!");615 return; 616 }617 618 if(testCb.checked) cm="-RV"; else cm="-R";619 logToConsole("Changing Test_mode...");620 websocket.send(cm); 621 }622 623 function setJitter()624 {625 if(!connected) 626 {627 logToConsole("No connection!");628 return; 629 }630 631 logToConsole("Setting Jitter compensation...");632 websocket.send(jitterSel.value); 633 }634 function logToConsole(message)635 {636 var pre = document.createElement("p");637 pre.style.wordWrap = "break-word";638 pre.innerHTML = getSecureTag()+message;639 consoleLog.appendChild(pre);640 while (consoleLog.childNodes.length > 50)641 {642 consoleLog.removeChild(consoleLog.firstChild);643 }644 645 consoleLog.scrollTop = consoleLog.scrollHeight;646 }647 648 function onOpen(evt)649 {650 logToConsole("CONNECTED");651 setGuiConnected(true);652 }653 654 function onClose(evt)655 {656 logToConsole("DISCONNECTED");657 setGuiConnected(false);658 }659 660 function onMessage(evt)661 {662 if(evt.data.charAt(0) == '-' || evt.data.charAt(0) == '*')663 sendMessage.value=evt.data;664 else if(evt.data.charAt(0) == '!') 665 logToConsole('<span style="color: red;">' + evt.data+'</span>');666 else if(evt.data.charAt(0) == '>') 667 logToConsole('<span style="color: green;">' + evt.data+'</span>');668 else logToConsole('<span style="color: blue;">' + evt.data+'</span>');669 }670 function onError(evt)671 {672 logToConsole('<span style="color: red;">ERROR:</span> ' + evt.data);673 }674 675 function setGuiConnected(isConnected)676 {677 if(isConnected)678 {679 connectBut.innerHTML="Disconnect";680 connectBut.style.color="green";681 connected=1;682 }683 else684 {685 connectBut.innerHTML="Connect";686 connectBut.style.color="red";...

Full Screen

Full Screen

inline.js

Source:inline.js Github

copy

Full Screen

2function regLinkClickHandlers() {3 var $j = jQuery.noConflict();4 var logToConsole = cordova.require("com.salesforce.util.logger").logToConsole;5 $j('#link_fetch_device_contacts').click(function() {6 logToConsole("link_fetch_device_contacts clicked");7 var options = new ContactFindOptions();8 options.filter = ""; // empty search string returns all contacts9 options.multiple = true;10 options.hasPhoneNumber = true;11 var fields = [navigator.contacts.fieldType.displayName, navigator.contacts.fieldType.name];12 navigator.contacts.find(fields, onSuccessDevice, onErrorDevice, options);13 });14 15 $j('#link_fetch_sfdc_contacts').click(function() {16 logToConsole("link_fetch_sfdc_contacts clicked");17 force.query("SELECT Name FROM Contact LIMIT 25", onSuccessSfdcContacts, onErrorSfdc); 18 });19 20 $j('#link_fetch_sfdc_accounts').click(function() {21 logToConsole("link_fetch_sfdc_accounts clicked");22 force.query("SELECT Name FROM Account LIMIT 25", onSuccessSfdcAccounts, onErrorSfdc); 23 });24 25 $j('#link_reset').click(function() {26 logToConsole("link_reset clicked");27 $j("#div_device_contact_list").html("")28 $j("#div_sfdc_contact_list").html("")29 $j("#div_sfdc_account_list").html("")30 $j("#console").html("")31 });32 33 $j('#link_logout').click(function() {34 logToConsole("link_logout clicked");35 var sfAccManagerPlugin = cordova.require("com.salesforce.plugin.sfaccountmanager");36 sfAccManagerPlugin.logout();37 });38 $j('#link_get_current_user').click(function() {39 logToConsole("link_get_current_user clicked");40 var sfAccManagerPlugin = cordova.require("com.salesforce.plugin.sfaccountmanager");41 sfAccManagerPlugin.getCurrentUser(function(user) {42 logToConsole("Success callback");43 logToConsole("Auth Token: " + user.authToken);44 logToConsole("Refresh Token: " + user.refreshToken);45 logToConsole("Login Server: " + user.loginServer);46 logToConsole("ID URL: " + user.idUrl);47 logToConsole("Instance Server: " + user.instanceServer);48 logToConsole("Org ID: " + user.orgId);49 logToConsole("User ID: " + user.userId);50 logToConsole("Username: " + user.username);51 logToConsole("Client ID: " + user.clientId);52 }, null)53 });54 $j('#link_switch_user').click(function() {55 logToConsole("link_switch_user clicked");56 var sfAccManagerPlugin = cordova.require("com.salesforce.plugin.sfaccountmanager");57 sfAccManagerPlugin.switchToUser();58 });59 $j('#link_get_all_users').click(function() {60 logToConsole("link_get_all_users clicked");61 var sfAccManagerPlugin = cordova.require("com.salesforce.plugin.sfaccountmanager");62 sfAccManagerPlugin.getUsers(function(user) {63 logToConsole("Success callback");64 var size = user.length;65 for (var i = 0; i < size; i++) {66 logToConsole("Auth Token: " + user[i].authToken);67 logToConsole("Refresh Token: " + user[i].refreshToken);68 logToConsole("Login Server: " + user[i].loginServer);69 logToConsole("ID URL: " + user[i].idUrl);70 logToConsole("Instance Server: " + user[i].instanceServer);71 logToConsole("Org ID: " + user[i].orgId);72 logToConsole("User ID: " + user[i].userId);73 logToConsole("Username: " + user[i].username);74 logToConsole("Client ID: " + user[i].clientId);75 }76 }, null)77 });78}79function onSuccessDevice(contacts) {80 var $j = jQuery.noConflict();81 cordova.require("com.salesforce.util.logger").logToConsole("onSuccessDevice: received " + contacts.length + " contacts");82 $j("#div_device_contact_list").html("")83 var ul = $j('<ul data-role="listview" data-inset="true" data-theme="a" data-dividertheme="a"></ul>');84 $j("#div_device_contact_list").append(ul);85 86 ul.append($j('<li data-role="list-divider">Device Contacts: ' + contacts.length + '</li>'));87 $j.each(contacts, function(i, contact) {88 var formattedName = contact.name.formatted;89 if (formattedName) {90 var newLi = $j("<li><a href='#'>" + (i+1) + " - " + formattedName + "</a></li>");91 ul.append(newLi);92 }93 });94 95 $j("#div_device_contact_list").trigger( "create" )96}97function onErrorDevice(error) {98 cordova.require("com.salesforce.util.logger").logToConsole("onErrorDevice: " + JSON.stringify(error) );99 alert('Error getting device contacts!');100}101function onSuccessSfdcContacts(response) {102 var $j = jQuery.noConflict();103 cordova.require("com.salesforce.util.logger").logToConsole("onSuccessSfdcContacts: received " + response.totalSize + " contacts");104 105 $j("#div_sfdc_contact_list").html("")106 var ul = $j('<ul data-role="listview" data-inset="true" data-theme="a" data-dividertheme="a"></ul>');107 $j("#div_sfdc_contact_list").append(ul);108 109 ul.append($j('<li data-role="list-divider">Salesforce Contacts: ' + response.totalSize + '</li>'));110 $j.each(response.records, function(i, contact) {111 var newLi = $j("<li><a href='#'>" + (i+1) + " - " + contact.Name + "</a></li>");112 ul.append(newLi);113 });114 115 $j("#div_sfdc_contact_list").trigger( "create" )116}117function onSuccessSfdcAccounts(response) {118 var $j = jQuery.noConflict();119 cordova.require("com.salesforce.util.logger").logToConsole("onSuccessSfdcAccounts: received " + response.totalSize + " accounts");120 121 $j("#div_sfdc_account_list").html("")122 var ul = $j('<ul data-role="listview" data-inset="true" data-theme="a" data-dividertheme="a"></ul>');123 $j("#div_sfdc_account_list").append(ul);124 125 ul.append($j('<li data-role="list-divider">Salesforce Accounts: ' + response.totalSize + '</li>'));126 $j.each(response.records, function(i, record) {127 var newLi = $j("<li><a href='#'>" + (i+1) + " - " + record.Name + "</a></li>");128 ul.append(newLi);129 });130 131 $j("#div_sfdc_account_list").trigger( "create" )132}133function onErrorSfdc(error) {134 cordova.require("com.salesforce.util.logger").logToConsole("onErrorSfdc: " + JSON.stringify(error));135 alert('Error getting sfdc contacts!');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptLogger = require('wpt-logger');2wptLogger.logToConsole('Hello World');3const wptLogger = require('wpt-logger');4wptLogger.logToFile('Hello World');5const wptLogger = require('wpt-logger');6wptLogger.logToMongo('Hello World');7const wptLogger = require('wpt-logger');8wptLogger.logToConsole('Hello World');9const wptLogger = require('wpt-logger');10wptLogger.logToConsole('Hello World');11const wptLogger = require('wpt-logger');12wptLogger.logToConsole('Hello World');13const wptLogger = require('wpt-logger');14wptLogger.logToConsole('Hello World');15const wptLogger = require('wpt-logger');16wptLogger.logToConsole('Hello World');17const wptLogger = require('wpt-logger');18wptLogger.logToConsole('Hello World');19const wptLogger = require('wpt-logger');20wptLogger.logToConsole('Hello World');21const wptLogger = require('wpt-logger');22wptLogger.logToConsole('Hello World');23const wptLogger = require('wpt-logger');24wptLogger.logToConsole('Hello World');25const wptLogger = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.logToConsole('Hello World');3var wpt = require('wpt');4wpt.logToConsole('Hello World');5var wpt = require('wpt');6wpt.logToConsole('Hello World');7var wpt = require('wpt');8wpt.logToConsole('Hello World');9var wpt = require('wpt');10wpt.logToConsole('Hello World');11var wpt = require('wpt');12wpt.logToConsole('Hello World');13var wpt = require('wpt');14wpt.logToConsole('Hello World');15var wpt = require('wpt');16wpt.logToConsole('Hello World');

Full Screen

Using AI Code Generation

copy

Full Screen

1require('wptLog').logToConsole('test');2require('wptLog').logToFile('test');3require('wptLog').logToConsoleAndFile('test');4require('wptLog').logToConsoleAndFile('test');5require('wptLog').logToConsoleAndFile('test');6require('wptLog').logToConsoleAndFile('test');7require('wptLog').logToConsoleAndFile('test');8require('wptLog').logToConsoleAndFile('test');9require('wptLog').logToConsoleAndFile('test');10require('wptLog').logToConsoleAndFile('test');11require('wptLog').logToConsoleAndFile('test');12require('wptLog').logToConsoleAndFile('test');13require('wptLog').logToConsoleAndFile('test');14require('wptLog').logToConsoleAndFile('test');15require('wptLog').logToConsoleAndFile('test');

Full Screen

Using AI Code Generation

copy

Full Screen

1wpt.logToConsole('Hello World!');2wpt.logToConsole('Hello World!');3wpt.logToConsole('Hello World!');4wpt.logToConsole('Hello World!');5wpt.logToConsole('Hello World!');6wpt.logToConsole('Hello World!');7wpt.logToConsole('Hello World!');8wpt.logToConsole('Hello World!');9wpt.logToConsole('Hello World!');10wpt.logToConsole('Hello World!');11wpt.logToConsole('Hello World!');12wpt.logToConsole('Hello World!');13wpt.logToConsole('Hello World!');

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful