Skip to content

Commit

Permalink
perf: 仅在Debug启用时输出堆栈
Browse files Browse the repository at this point in the history
  • Loading branch information
0XPYEX0 committed Aug 31, 2024
1 parent 152f04b commit f12cd2f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/main/java/me/xpyex/module/cnusername/CnUsername.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public static void premain(final String agentArgs, final Instrumentation inst) {
addToBanList("CS-CoreLib");
Logging.info("补丁应用完成");
} catch (Exception e) {
Logging.warning("添加补丁失败");
e.printStackTrace();
Logging.warning("添加补丁失败: " + e);
if (DEBUG) e.printStackTrace();
Logging.warning("建议服务器启动后手动封禁CS-CoreLib玩家名");
}
UpdateChecker.check();
Expand Down Expand Up @@ -118,7 +118,7 @@ public byte[] transform(ClassLoader loader, String className, Class<?> classBein
}
return writer.toByteArray();
} catch (Exception e) {
e.printStackTrace();
if (DEBUG) e.printStackTrace();
Logging.warning("修改失败: " + e);
}
break;
Expand All @@ -133,7 +133,7 @@ public byte[] transform(ClassLoader loader, String className, Class<?> classBein
classBeingRedefined.getConstructor(JavaPlugin.class, int.class).newInstance(Bukkit.getPluginManager().getPlugin("XPLib"), 19275);
} catch (ReflectiveOperationException e) {
Logging.warning("无法调用XPLib的BStats库: " + e);
e.printStackTrace();
if (DEBUG) e.printStackTrace();
Logging.info("不用担心,这并不会影响你的使用 :)");
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.concurrent.atomic.AtomicReference;
import me.xpyex.module.cnusername.CnUsername;
import me.xpyex.module.cnusername.Logging;
import sun.misc.Unsafe;

Expand Down Expand Up @@ -48,7 +49,7 @@ default String readPluginPattern() {
}
return Files.readString(f.toPath(), StandardCharsets.UTF_8);
} catch (Throwable e) {
e.printStackTrace();
if (CnUsername.DEBUG) e.printStackTrace();
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void onLoad() {
}
}
} catch (Exception e) {
e.printStackTrace();
if (CnUsername.DEBUG) e.printStackTrace();
Logging.warning("修改StringUtil类失败: " + e);
Logging.warning("1.20.5以下的版本忽略此条,无用");
}
Expand Down Expand Up @@ -93,7 +93,7 @@ public void onLoad() {
}
}
} catch (Exception e) {
e.printStackTrace();
if (CnUsername.DEBUG) e.printStackTrace();
Logging.warning("修改LoginListener类失败: " + e);
}
}
Expand All @@ -114,7 +114,7 @@ public void onEnable() {
metricsClass.getConstructor(JavaPlugin.class, int.class).newInstance(this, 19275);
} catch (ReflectiveOperationException e) {
Logging.warning("无法调用XPLib的BStats库: " + e);
e.printStackTrace();
if (CnUsername.DEBUG) e.printStackTrace();
Logging.info("不用担心,这并不会影响你的使用 :)");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public void onEnable() {
}
}
} catch (Exception e) {
e.printStackTrace();
Logging.warning("修改失败");
if (CnUsername.DEBUG) e.printStackTrace();
Logging.warning("修改失败: " + e);
}
getProxy().getPluginManager().registerListener(this, new Listener() {
@EventHandler
Expand Down

0 comments on commit f12cd2f

Please sign in to comment.