From 0094bdf3b6739a514e31679736aa24e283cb3572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Fri, 23 Nov 2018 10:58:23 +0800 Subject: [PATCH] + debug message --- pom.xml | 2 +- .../taboolib/common/function/TFunctionLoader.java | 4 +++- .../taboolib/common/loader/InstantiableLoader.java | 2 ++ .../me/skymc/taboolib/common/nms/NMSHandler.java | 7 +++++++ .../me/skymc/taboolib/common/nms/NMSHandlerImpl.java | 2 -- .../me/skymc/taboolib/listener/TListenerHandler.java | 12 +++++++++--- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 7f56c79..d7af26c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.skymc TabooLib - 4.61 + 4.62 UTF-8 diff --git a/src/main/java/me/skymc/taboolib/common/function/TFunctionLoader.java b/src/main/java/me/skymc/taboolib/common/function/TFunctionLoader.java index 711d732..a74fee2 100644 --- a/src/main/java/me/skymc/taboolib/common/function/TFunctionLoader.java +++ b/src/main/java/me/skymc/taboolib/common/function/TFunctionLoader.java @@ -1,9 +1,9 @@ package me.skymc.taboolib.common.function; import com.ilummc.tlib.logger.TLogger; +import me.skymc.taboolib.TabooLib; import me.skymc.taboolib.TabooLibLoader; import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.java.JavaPlugin; import java.lang.reflect.Method; @@ -21,6 +21,7 @@ public class TFunctionLoader implements TabooLibLoader.Loader { Method method = pluginClass.getDeclaredMethod(function.enable()); method.setAccessible(true); method.invoke(null); + TabooLib.debug("Function " + pluginClass.getSimpleName() + " loaded. (" + plugin.getName() + ")"); } catch (NoSuchMethodException ignore) { } catch (Exception e) { TLogger.getGlobalLogger().warn("TFunction load Failed: " + pluginClass.getName()); @@ -37,6 +38,7 @@ public class TFunctionLoader implements TabooLibLoader.Loader { Method method = pluginClass.getDeclaredMethod(function.disable()); method.setAccessible(true); method.invoke(null); + TabooLib.debug("Function " + pluginClass.getSimpleName() + " unloaded. (" + plugin.getName() + ")"); } catch (NoSuchMethodException ignore) { } catch (Exception e) { TLogger.getGlobalLogger().warn("TFunction unload Failed: " + pluginClass.getName()); diff --git a/src/main/java/me/skymc/taboolib/common/loader/InstantiableLoader.java b/src/main/java/me/skymc/taboolib/common/loader/InstantiableLoader.java index 95a906c..7ab178e 100644 --- a/src/main/java/me/skymc/taboolib/common/loader/InstantiableLoader.java +++ b/src/main/java/me/skymc/taboolib/common/loader/InstantiableLoader.java @@ -2,6 +2,7 @@ package me.skymc.taboolib.common.loader; import com.ilummc.tlib.logger.TLogger; import com.ilummc.tlib.util.Ref; +import me.skymc.taboolib.TabooLib; import me.skymc.taboolib.TabooLibLoader; import me.skymc.taboolib.listener.TListener; import me.skymc.taboolib.methods.ReflectionUtils; @@ -59,6 +60,7 @@ public class InstantiableLoader implements Listener { Instantiable instantiable = (Instantiable) pluginClass.getAnnotation(Instantiable.class); try { instance.put(instantiable.value(), ReflectionUtils.instantiateObject(pluginClass)); + TabooLib.debug("Instantiable " + pluginClass.getSimpleName() + " instanced. (" + plugin.getName() + ")"); } catch (Exception e) { TLogger.getGlobalLogger().warn("Instance Failed: " + pluginClass.getName()); e.printStackTrace(); diff --git a/src/main/java/me/skymc/taboolib/common/nms/NMSHandler.java b/src/main/java/me/skymc/taboolib/common/nms/NMSHandler.java index 1373f2b..0a2ddab 100644 --- a/src/main/java/me/skymc/taboolib/common/nms/NMSHandler.java +++ b/src/main/java/me/skymc/taboolib/common/nms/NMSHandler.java @@ -1,5 +1,7 @@ package me.skymc.taboolib.common.nms; +import me.skymc.taboolib.TabooLib; +import me.skymc.taboolib.commands.builder.SimpleCommandBuilder; import me.skymc.taboolib.common.function.TFunction; import me.skymc.taboolib.common.versioncontrol.SimpleVersionControl; import org.bukkit.entity.Player; @@ -19,6 +21,11 @@ public abstract class NMSHandler { } catch (Exception e) { e.printStackTrace(); } + SimpleCommandBuilder.create("title", TabooLib.instance()) + .execute((sender, args) -> { + handler.sendTitle((Player) sender, "TabooLib", 10, 40, 10, "author Bkm016", 10, 40, 10); + return true; + }).build(); } abstract public void sendTitle(Player player, String title, int titleFadein, int titleStay, int titleFadeout, String subtitle, int subtitleFadein, int subtitleStay, int subtitleFadeout); diff --git a/src/main/java/me/skymc/taboolib/common/nms/NMSHandlerImpl.java b/src/main/java/me/skymc/taboolib/common/nms/NMSHandlerImpl.java index e954c0c..d365346 100644 --- a/src/main/java/me/skymc/taboolib/common/nms/NMSHandlerImpl.java +++ b/src/main/java/me/skymc/taboolib/common/nms/NMSHandlerImpl.java @@ -16,9 +16,7 @@ public class NMSHandlerImpl extends NMSHandler { @Override public void sendTitle(Player player, String title, int titleFadein, int titleStay, int titleFadeout, String subtitle, int subtitleFadein, int subtitleStay, int subtitleFadeout) { - TPacketHandler.sendPacket(player, new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TIMES, new ChatComponentText(String.valueOf(title)), titleFadein, titleStay, titleFadeout)); TPacketHandler.sendPacket(player, new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, new ChatComponentText(String.valueOf(title)))); - TPacketHandler.sendPacket(player, new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TIMES, new ChatComponentText(String.valueOf(subtitle)), subtitleFadein, subtitleStay, subtitleFadeout)); TPacketHandler.sendPacket(player, new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, new ChatComponentText(String.valueOf(subtitle)))); } diff --git a/src/main/java/me/skymc/taboolib/listener/TListenerHandler.java b/src/main/java/me/skymc/taboolib/listener/TListenerHandler.java index cc5d97b..33518ff 100644 --- a/src/main/java/me/skymc/taboolib/listener/TListenerHandler.java +++ b/src/main/java/me/skymc/taboolib/listener/TListenerHandler.java @@ -1,5 +1,6 @@ package me.skymc.taboolib.listener; +import com.ilummc.tlib.logger.TLogger; import com.ilummc.tlib.util.Strings; import me.skymc.taboolib.TabooLib; import me.skymc.taboolib.TabooLibLoader; @@ -56,10 +57,15 @@ public class TListenerHandler implements Listener { } // 实例化监听器 Listener listener = plugin.getClass().equals(pluginClass) ? (Listener) plugin : (Listener) ReflectionUtils.instantiateObject(pluginClass); - listeners.computeIfAbsent(plugin.getName(), name -> new ArrayList<>()).add(listener); - TabooLib.debug("Listener " + listener.getClass().getSimpleName() + " setup successfully. (" + plugin.getName() + ")"); + try { + listeners.computeIfAbsent(plugin.getName(), name -> new ArrayList<>()).add(listener); + TabooLib.debug("Listener " + listener.getClass().getSimpleName() + " setup successfully. (" + plugin.getName() + ")"); + } catch (Exception e) { + TLogger.getGlobalLogger().warn("TListener setup Failed: " + pluginClass.getName()); + e.printStackTrace(); + } } catch (Exception e) { - TabooLib.debug("Listener setup failed: " + e.toString()); + TabooLib.debug("Listener " + pluginClass.getSimpleName() + "(" + plugin.getName() + ")" + " setup failed: " + e.toString()); } } }