mirror of
				https://e.coding.net/circlecloud/Yum.git
				synced 2025-11-04 13:16:02 +00:00 
			
		
		
		
	@@ -125,7 +125,7 @@ public class CommandInjector implements TabExecutor {
 | 
				
			|||||||
            sender.sendMessage("§6异常说明: §3" + e.getMessage());
 | 
					            sender.sendMessage("§6异常说明: §3" + e.getMessage());
 | 
				
			||||||
            MonitorCommand.lastError = e;
 | 
					            MonitorCommand.lastError = e;
 | 
				
			||||||
            MonitorManager.log(prefix + "§6玩家 §a" + sender.getName() + " §6执行 §b" + plugin.getName() + " §6插件 §d" + label + " " + StrKit.join(args, " ") + " §6命令时发生异常!");
 | 
					            MonitorManager.log(prefix + "§6玩家 §a" + sender.getName() + " §6执行 §b" + plugin.getName() + " §6插件 §d" + label + " " + StrKit.join(args, " ") + " §6命令时发生异常!");
 | 
				
			||||||
            MonitorManager.print(e);
 | 
					            MonitorManager.printThrowable(e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,6 @@ import org.bukkit.plugin.RegisteredListener;
 | 
				
			|||||||
import org.bukkit.plugin.TimedRegisteredListener;
 | 
					import org.bukkit.plugin.TimedRegisteredListener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import cn.citycraft.PluginHelper.ext.kit.Reflect;
 | 
					import cn.citycraft.PluginHelper.ext.kit.Reflect;
 | 
				
			||||||
import cn.citycraft.PluginHelper.kit.PluginKit;
 | 
					 | 
				
			||||||
import pw.yumc.Yum.commands.MonitorCommand;
 | 
					import pw.yumc.Yum.commands.MonitorCommand;
 | 
				
			||||||
import pw.yumc.Yum.managers.ConfigManager;
 | 
					import pw.yumc.Yum.managers.ConfigManager;
 | 
				
			||||||
import pw.yumc.Yum.managers.MonitorManager;
 | 
					import pw.yumc.Yum.managers.MonitorManager;
 | 
				
			||||||
@@ -65,7 +64,7 @@ public class ListenerInjector implements EventExecutor {
 | 
				
			|||||||
                    Reflect.on(listener).set("executor", listenerInjector);
 | 
					                    Reflect.on(listener).set("executor", listenerInjector);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } catch (final Throwable e) {
 | 
					            } catch (final Throwable e) {
 | 
				
			||||||
                PluginKit.sc(String.format(inject_error, plugin.getName(), listener.getClass().getName()));
 | 
					                MonitorManager.log(String.format(inject_error, plugin.getName(), listener.getClass().getName()));
 | 
				
			||||||
                e.printStackTrace();
 | 
					                e.printStackTrace();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -118,7 +117,7 @@ public class ListenerInjector implements EventExecutor {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            MonitorCommand.lastError = e;
 | 
					            MonitorCommand.lastError = e;
 | 
				
			||||||
            MonitorManager.log(prefix + "§6插件 §b" + plugin.getName() + " §6处理 §d" + event.getEventName() + " §6事件时发生异常!");
 | 
					            MonitorManager.log(prefix + "§6插件 §b" + plugin.getName() + " §6处理 §d" + event.getEventName() + " §6事件时发生异常!");
 | 
				
			||||||
            MonitorManager.print(e);
 | 
					            MonitorManager.printThrowable(e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,6 @@ import org.bukkit.scheduler.BukkitScheduler;
 | 
				
			|||||||
import org.bukkit.scheduler.BukkitTask;
 | 
					import org.bukkit.scheduler.BukkitTask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import cn.citycraft.PluginHelper.ext.kit.Reflect;
 | 
					import cn.citycraft.PluginHelper.ext.kit.Reflect;
 | 
				
			||||||
import cn.citycraft.PluginHelper.kit.PluginKit;
 | 
					 | 
				
			||||||
import cn.citycraft.PluginHelper.kit.StrKit;
 | 
					import cn.citycraft.PluginHelper.kit.StrKit;
 | 
				
			||||||
import pw.yumc.Yum.commands.MonitorCommand;
 | 
					import pw.yumc.Yum.commands.MonitorCommand;
 | 
				
			||||||
import pw.yumc.Yum.managers.MonitorManager;
 | 
					import pw.yumc.Yum.managers.MonitorManager;
 | 
				
			||||||
@@ -52,7 +51,7 @@ public class TaskInjector implements Runnable {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } catch (final Throwable e) {
 | 
					        } catch (final Throwable e) {
 | 
				
			||||||
            PluginKit.sc(String.format(inject_error, plugin.getName()));
 | 
					            MonitorManager.log(String.format(inject_error, plugin.getName()));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -98,7 +97,7 @@ public class TaskInjector implements Runnable {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            MonitorCommand.lastError = e;
 | 
					            MonitorCommand.lastError = e;
 | 
				
			||||||
            MonitorManager.log(prefix + "§6插件 §b" + plugin.getName() + " §6执行 §d" + taskName + " §6任务时发生异常!");
 | 
					            MonitorManager.log(prefix + "§6插件 §b" + plugin.getName() + " §6执行 §d" + taskName + " §6任务时发生异常!");
 | 
				
			||||||
            MonitorManager.print(e);
 | 
					            MonitorManager.printThrowable(e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,6 +68,10 @@ public class ConfigManager {
 | 
				
			|||||||
        return network.getBoolean("AllowPrimaryThread", false);
 | 
					        return network.getBoolean("AllowPrimaryThread", false);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isLogToFile() {
 | 
				
			||||||
 | 
					        return monitor.getBoolean("LogToFile");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public boolean isMainThreadCheck() {
 | 
					    public boolean isMainThreadCheck() {
 | 
				
			||||||
        return thread.getBoolean("MainThreadCheck", true);
 | 
					        return thread.getBoolean("MainThreadCheck", true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,6 +22,7 @@ public class MonitorManager {
 | 
				
			|||||||
    public static String prefix = "§6[§bYum §a能耗监控§6] ";
 | 
					    public static String prefix = "§6[§bYum §a能耗监控§6] ";
 | 
				
			||||||
    public static int lagTime = 20;
 | 
					    public static int lagTime = 20;
 | 
				
			||||||
    public static boolean debug = ConfigManager.i().isMonitorDebug();
 | 
					    public static boolean debug = ConfigManager.i().isMonitorDebug();
 | 
				
			||||||
 | 
					    public static boolean log_to_file = ConfigManager.i().isLogToFile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static Map<String, Long> monitor = new HashMap<>();
 | 
					    private static Map<String, Long> monitor = new HashMap<>();
 | 
				
			||||||
    private static Map<String, Long> task = new HashMap<>();
 | 
					    private static Map<String, Long> task = new HashMap<>();
 | 
				
			||||||
@@ -54,21 +55,25 @@ public class MonitorManager {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void lagTip(final String message) {
 | 
					    public static void lagTip(final String message) {
 | 
				
			||||||
        LogKit.DEFAULT.logSender(prefix + message);
 | 
					        log(prefix + message);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void log(final String message) {
 | 
					    public static void log(final String message) {
 | 
				
			||||||
        LogKit.DEFAULT.logSender(message);
 | 
					        if (log_to_file) {
 | 
				
			||||||
 | 
					            LogKit.DEFAULT.logSender(message);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            PluginKit.sc(message);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void print(final Throwable e) {
 | 
					    public static void printThrowable(final Throwable e) {
 | 
				
			||||||
        LogKit.DEFAULT.logSender("§6异常名称: §c" + e.getClass().getName());
 | 
					        log("§6异常名称: §c" + e.getClass().getName());
 | 
				
			||||||
        LogKit.DEFAULT.logSender("§6异常说明: §3" + e.getMessage());
 | 
					        log("§6异常说明: §3" + e.getMessage());
 | 
				
			||||||
        LogKit.DEFAULT.logSender("§6简易错误信息如下:");
 | 
					        log("§6简易错误信息如下:");
 | 
				
			||||||
        final int l = e.getStackTrace().length > 5 ? 5 : e.getStackTrace().length;
 | 
					        final int l = e.getStackTrace().length > 5 ? 5 : e.getStackTrace().length;
 | 
				
			||||||
        for (int i = 0; i < l; i++) {
 | 
					        for (int i = 0; i < l; i++) {
 | 
				
			||||||
            final StackTraceElement ste = e.getStackTrace()[i];
 | 
					            final StackTraceElement ste = e.getStackTrace()[i];
 | 
				
			||||||
            LogKit.DEFAULT.logSender("    §e位于 §c" + ste.getClassName() + "." + ste.getMethodName() + "(§4" + ste.getFileName() + ":" + ste.getLineNumber() + "§c)");
 | 
					            log("    §e位于 §c" + ste.getClassName() + "." + ste.getMethodName() + "(§4" + ste.getFileName() + ":" + ste.getLineNumber() + "§c)");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (debug) {
 | 
					        if (debug) {
 | 
				
			||||||
            PluginKit.sc("§c开发人员调试信息如下:");
 | 
					            PluginKit.sc("§c开发人员调试信息如下:");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,12 +3,14 @@
 | 
				
			|||||||
############################
 | 
					############################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#配置版本号 请勿修改!!!
 | 
					#配置版本号 请勿修改!!!
 | 
				
			||||||
Version: 1.2
 | 
					Version: 1.3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#是否开启
 | 
					#是否开启
 | 
				
			||||||
Enable: true
 | 
					Enable: true
 | 
				
			||||||
#是否显示开发人员信息
 | 
					#是否显示开发人员信息
 | 
				
			||||||
Debug: false
 | 
					Debug: false
 | 
				
			||||||
 | 
					#是否保存Lag日志到文件
 | 
				
			||||||
 | 
					LogToFile: true
 | 
				
			||||||
#忽略检测列表
 | 
					#忽略检测列表
 | 
				
			||||||
Ignore:
 | 
					Ignore:
 | 
				
			||||||
- PluginHelper
 | 
					- PluginHelper
 | 
				
			||||||
		Reference in New Issue
	
	Block a user