Class GlobalContext

java.lang.Object
com.github.theword.queqiao.tool.GlobalContext

public class GlobalContext extends Object
  • Constructor Details

    • GlobalContext

      public GlobalContext()
  • Method Details

    • init

      public static void init(boolean isModServer, String serverVersion, String serverType, HandleApiService handleApiImpl, HandleCommandReturnMessageService handleCommandReturnMessageImpl)
    • executeReloadCommand

      public static void executeReloadCommand(Object commandReturner)
      执行全局重载命令

      1. 先重新读取配置文件

      2. 加载翻译功能

      3. 再重新连接所有 Websocket Client

      4. 重连 Rcon

      Parameters:
      commandReturner - 命令返回者
    • shutdown

      public static void shutdown()
      关闭鹊桥
    • sendEvent

      public static void sendEvent(BaseEvent baseEvent)
      同时向所有已连接的 WebSocket 客户端和服务端广播事件
      Parameters:
      baseEvent - 事件对象
    • sendRconCommand

      public static String sendRconCommand(String command) throws IOException
      发送 Rcon 命令
      Parameters:
      command - 命令
      Returns:
      命令返回结果
      Throws:
      IOException
    • initMessagePrefixJsonObject

      public static com.google.gson.JsonElement initMessagePrefixJsonObject(String messagePrefixText)
      初始化消息前缀 JsonObject

      自 0.6.0 开始,支持对 "" 前缀的处理,对 Json 更加智能的处理

      Returns:
      JsonElement 消息前缀
      Since:
      0.6.0
    • isTranslationEnabled

      public static boolean isTranslationEnabled()
    • translate

      public static String translate(String key, String[] args)
      翻译指定键值
      Parameters:
      key - 翻译键值
      args - 翻译参数
      Returns:
      翻译结果
      Since:
      0.6.0
    • getConfig

      public static Config getConfig()
    • setConfig

      public static void setConfig(Config config)
    • getLogger

      public static org.slf4j.Logger getLogger()
    • setLogger

      public static void setLogger(org.slf4j.Logger logger)
    • getWebsocketManager

      public static WebsocketManager getWebsocketManager()
    • getHandleApiService

      public static HandleApiService getHandleApiService()
    • getHandleCommandReturnMessageService

      public static HandleCommandReturnMessageService getHandleCommandReturnMessageService()
    • getServerVersion

      public static String getServerVersion()
    • getServerType

      public static String getServerType()
    • getGson

      public static com.google.gson.Gson getGson()
    • getMessagePrefixJsonObject

      public static com.google.gson.JsonElement getMessagePrefixJsonObject()
      获取消息前缀的 JsonElement

      自 0.6.0 开始,返回类型从 JsonObject 改为 JsonElement

      Returns:
      JsonElement 消息前缀
      Since:
      0.6.0