MCPcopy Create free account
hub / github.com/MCSLTeam/MCSL2 / colorConsoleText

Method colorConsoleText

MCSL2Lib/ServerControllers/windowCreator.py:1616–1738  ·  view source on GitHub ↗
(self, serverOutput)

Source from the content-addressed store, hash-verified

1614
1615 @pyqtSlot(str)
1616 def colorConsoleText(self, serverOutput):
1617 readServerProperties(self.serverConfig)
1618 fmt = QTextCharFormat()
1619 # fmt: off
1620 greenText = ["INFO", "Info", "info", "tip", "tips", "hint", "HINT", "提示"]
1621 orangeText = ["WARN", "Warning", "warn", "alert", "ALERT", "Alert", "CAUTION", "Caution", "警告"] # noqa: E501
1622 redText = ["ERR", "Err", "Fatal", "FATAL", "Critical", "Danger", "DANGER", "错", "at java", "at net", "at oolloo", "Caused by", "at sun"] # noqa: E501
1623 blueText = ["DEBUG", "Debug", "debug", "调试", "TEST", "Test", "Unknown command", "MCSL2"]
1624 color = [QColor(52, 185, 96), QColor(196, 139, 33), QColor(214, 39, 21), QColor(22, 122, 232)] # noqa: E501
1625 for keyword in greenText:
1626 if keyword in serverOutput:
1627 fmt.setForeground(QBrush(color[0]))
1628 for keyword in orangeText:
1629 if keyword in serverOutput:
1630 fmt.setForeground(QBrush(color[1]))
1631 for keyword in redText:
1632 if keyword in serverOutput:
1633 fmt.setForeground(QBrush(color[2]))
1634 for keyword in blueText:
1635 if keyword in serverOutput:
1636 fmt.setForeground(QBrush(color[3]))
1637 self.serverOutput.mergeCurrentCharFormat(fmt)
1638 serverOutput = (
1639 serverOutput.replace("[38;2;170;170;170m", "")
1640 .replace("[38;2;255;170;0m", "")
1641 .replace("[38;2;255;255;255m", "")
1642 .replace("[0m", "")
1643 .replace("[38;2;255;255;85m", "")
1644 .replace("[38;2;255;255;0m", "")
1645 .replace("[38;2;255;85;85m", "")
1646 .replace("[38;2;255;255;255m", "")
1647 .replace("[3m", "")
1648 .replace("[m[", "[")
1649 .replace("[32m", "")
1650 .replace("Preparing spawn area", self.tr("准备生成点区域中"))
1651 .replace("main/INFO", self.tr("主类 | 信息"))
1652 .replace("main/WARN", self.tr("主类 | 警告"))
1653 .replace("main/ERROR", self.tr("主类 | 错误"))
1654 .replace("main/FATAL", self.tr("主类 | 致命错误"))
1655 .replace("main/DEBUG", self.tr("主类 | 调试信息"))
1656 .replace("INFO", self.tr("信息"))
1657 .replace("WARN", self.tr("警告"))
1658 .replace("ERROR", self.tr("错误"))
1659 .replace("FATAL", self.tr("致命错误"))
1660 .replace("DEBUG", self.tr("调试信息"))
1661 .replace("Server thread", self.tr("服务器线程"))
1662 .replace("Server-Worker", self.tr("服务器工作进程"))
1663 .replace("DEBUG", self.tr("调试信息"))
1664 .replace("Forge Version Check", self.tr("Forge 版本检查"))
1665 .replace("ModLauncher running: args", self.tr("ModLauncher 运行中: 参数"))
1666 .replace("All chunks are saved", self.tr("所有区块已保存"))
1667 .replace("Saving the game (this may take a moment!)", self.tr("保存游戏存档中 (可能需要一些时间)")) # noqa: E501
1668 .replace("Saved the game", self.tr("已保存游戏存档"))
1669 .replace("[", "[")
1670 .replace("[", "[")
1671 .replace("搂2", "")
1672 )
1673 if "Disabling terminal, you're running in an unsupported environment." in serverOutput:

Callers 2

registerCommandOutputMethod · 0.95

Calls 7

recordPlayersMethod · 0.95
readServerPropertiesFunction · 0.90
warningMethod · 0.80
currentWidgetMethod · 0.80
successMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected