Skip to content

Commit

Permalink
perf: 更新了两处style相关, 移除两处不必要的翻译文本
Browse files Browse the repository at this point in the history
  • Loading branch information
winsrewu committed May 1, 2024
1 parent c3c282f commit ac3881c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
59 changes: 33 additions & 26 deletions src/main/java/org/jawbts/noglerr/tweak/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import java.util.Map;

public class Utils {
private static boolean tempReadyState = false;
private static boolean tempGameReadyState = false;

public static String escapeString(String input) {
input = input.replaceAll("\\\\", "");
return input.replaceAll("\"", "\\\\\"");
Expand All @@ -26,6 +29,36 @@ public static Text createTextFromJsonOrString(String s) {
}
}

/**
* 玩家是否在游戏, 没开任何gui
*
* @return 玩家是否准备好接受消息
*/
public static boolean playerReadyCheck() {
if (TickUpdateChecker.check("READY_CHECK")) {
return tempReadyState;
}
TickUpdateChecker.mark("READY_CHECK");

tempReadyState = ClientTickHandler.mc != null && ClientTickHandler.mc.currentScreen == null;
return tempReadyState;
}

/**
* 和gui没关系 开不开无所谓
*
* @return 玩家是否在游戏里
*/
public static boolean gameReadyCheck() {
if (TickUpdateChecker.check("G_READY_CHECK")) {
return tempGameReadyState;
}
TickUpdateChecker.mark("G_READY_CHECK");

tempGameReadyState = ClientTickHandler.mc != null && ClientTickHandler.mc.player != null;
return tempGameReadyState;
}

// 检查1tick内只需调用一次的是否会调用多次
// 每gt重置
public static class TickUpdateChecker {
Expand Down Expand Up @@ -53,30 +86,4 @@ public static void tick() {
}
}
}

// 玩家是否准备好接受消息
// 玩家是否在游戏, 没开任何gui
private static boolean tempReadyState = false;
public static boolean playerReadyCheck() {
if (TickUpdateChecker.check("READY_CHECK")) {
return tempReadyState;
}
TickUpdateChecker.mark("READY_CHECK");

tempReadyState = ClientTickHandler.mc != null && ClientTickHandler.mc.currentScreen == null;
return tempReadyState;
}

// 玩家是否在游戏里
// 和gui没关系 开不开无所谓
private static boolean tempGameReadyState = false;
public static boolean gameReadyCheck() {
if (TickUpdateChecker.check("G_READY_CHECK")) {
return tempGameReadyState;
}
TickUpdateChecker.mark("G_READY_CHECK");

tempGameReadyState = ClientTickHandler.mc != null && ClientTickHandler.mc.player != null;
return tempGameReadyState;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.text.*;
import net.minecraft.util.Formatting;
import org.jawbts.noglerr.tweak.Utils;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/assets/noglerr/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,5 @@
"noglerr.info.safeVersionNotReady": "Safe version not ready yet. Please disable your mod for now.",
"noglerr.info.checkFiled": "Check failed, check your log for further information.",
"noglerr.info.versionPerfect": "Noglerr at latest safe version.",
"noglerr.info.folderOpenFailed": "The folder could not be opened. Please open it manually.",
"noglerr.hotkeys.openConfigScreen": "OpenConfigScreen"
}
1 change: 0 additions & 1 deletion src/main/resources/assets/noglerr/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,5 @@
"noglerr.info.safeVersionNotReady": "安全的版本尚未就绪, 请暂时禁用您的模组.",
"noglerr.info.checkFiled": "更新检测失败, 请检查您的日志.",
"noglerr.info.versionPerfect": "Noglerr 是最新安全版本.",
"noglerr.info.folderOpenFailed": "文件夹无法打开. 请手动打开.",
"noglerr.hotkeys.openConfigScreen": "打开配置界面"
}

0 comments on commit ac3881c

Please sign in to comment.