From d02882193f2bbf07cea1b543fc96ae634d20ceb0 Mon Sep 17 00:00:00 2001 From: suwings Date: Wed, 23 May 2018 20:56:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20-=20=E6=9B=B4=E5=BC=BA?= =?UTF-8?q?=E7=9A=84=E9=A2=9C=E8=89=B2=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/common/js/tools.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/public/common/js/tools.js b/public/common/js/tools.js index 1f29089b..3b5fe3a5 100644 --- a/public/common/js/tools.js +++ b/public/common/js/tools.js @@ -110,23 +110,29 @@ //Minecraft 服务器输出基本颜色 TOOLS.encodeConsoleColor = function (text) { - text = text.replace(/\[/igm, ""); - text = text.replace(/\]/igm, " ]"); + text = text.replace(/([A-Za-z _&;-]{1,}:)/igm, "$1"); + text = text.replace(/\[/igm, ""); + text = text.replace(/\]/igm, " ]"); text = text.replace(/INFO/gm, "INFO"); text = text.replace(/(\d{2,}:\d{2,}:\d{2,})/gm, " $1 "); RegExpStringArr = [ //蓝色 ["Unknown command", "Loading libraries, please wait...", - "Preparing" + "Loading", "Loaded", + "Preparing start region for level", "\\d{1,3}%", "true", "false", ], //绿色 - ["/help", "left the game", "Enabling"], + ["/help", "left the game", "Enabling", + "Saving chunks for level", "--------", "UUID", "Starting minecraft server version", + "Timings Reset", + "\\(", "\\)", "\\{", "\\}", "<", ">" + ], //红色 ["WARN", "EULA", "Error", "Exception", "Stopping the server", "Caused by", "Stopping"], //黄色 - ["\\d{1,3}%", "true", "false", - "Starting Minecraft server on", "--------", + [ + "Starting Minecraft server on", "world_the_end", "world_nether", "Usage", @@ -136,15 +142,16 @@ for (var k in RegExpStringArr) { for (var y in RegExpStringArr[k]) { - var reg = new RegExp("(" + RegExpStringArr[k][y].replace(/ /igm, " ") + ")", "igm"); - console.log("当前:", k, y, "正则是:", "(" + RegExpStringArr[k][y] + ")", reg) + var reg = new RegExp( + "(" + RegExpStringArr[k][y].replace(/ /igm, " ") + ")", + "igm"); if (k == 0) //蓝色 text = text.replace(reg, "$1"); if (k == 1) //绿色 - text = text.replace(reg, "$1"); + text = text.replace(reg, "$1"); if (k == 2) //红色 text = text.replace(reg, "$1"); - if (k == 3) + if (k == 3) //黄色 text = text.replace(reg, "$1"); }