+ debug message

This commit is contained in:
坏黑 2018-11-23 10:58:23 +08:00
parent 39f3eb3081
commit 0094bdf3b6
6 changed files with 22 additions and 7 deletions

View File

@ -6,7 +6,7 @@
<groupId>me.skymc</groupId> <groupId>me.skymc</groupId>
<artifactId>TabooLib</artifactId> <artifactId>TabooLib</artifactId>
<version>4.61</version> <version>4.62</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -1,9 +1,9 @@
package me.skymc.taboolib.common.function; package me.skymc.taboolib.common.function;
import com.ilummc.tlib.logger.TLogger; import com.ilummc.tlib.logger.TLogger;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.TabooLibLoader; import me.skymc.taboolib.TabooLibLoader;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -21,6 +21,7 @@ public class TFunctionLoader implements TabooLibLoader.Loader {
Method method = pluginClass.getDeclaredMethod(function.enable()); Method method = pluginClass.getDeclaredMethod(function.enable());
method.setAccessible(true); method.setAccessible(true);
method.invoke(null); method.invoke(null);
TabooLib.debug("Function " + pluginClass.getSimpleName() + " loaded. (" + plugin.getName() + ")");
} catch (NoSuchMethodException ignore) { } catch (NoSuchMethodException ignore) {
} catch (Exception e) { } catch (Exception e) {
TLogger.getGlobalLogger().warn("TFunction load Failed: " + pluginClass.getName()); 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 method = pluginClass.getDeclaredMethod(function.disable());
method.setAccessible(true); method.setAccessible(true);
method.invoke(null); method.invoke(null);
TabooLib.debug("Function " + pluginClass.getSimpleName() + " unloaded. (" + plugin.getName() + ")");
} catch (NoSuchMethodException ignore) { } catch (NoSuchMethodException ignore) {
} catch (Exception e) { } catch (Exception e) {
TLogger.getGlobalLogger().warn("TFunction unload Failed: " + pluginClass.getName()); TLogger.getGlobalLogger().warn("TFunction unload Failed: " + pluginClass.getName());

View File

@ -2,6 +2,7 @@ package me.skymc.taboolib.common.loader;
import com.ilummc.tlib.logger.TLogger; import com.ilummc.tlib.logger.TLogger;
import com.ilummc.tlib.util.Ref; import com.ilummc.tlib.util.Ref;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.TabooLibLoader; import me.skymc.taboolib.TabooLibLoader;
import me.skymc.taboolib.listener.TListener; import me.skymc.taboolib.listener.TListener;
import me.skymc.taboolib.methods.ReflectionUtils; import me.skymc.taboolib.methods.ReflectionUtils;
@ -59,6 +60,7 @@ public class InstantiableLoader implements Listener {
Instantiable instantiable = (Instantiable) pluginClass.getAnnotation(Instantiable.class); Instantiable instantiable = (Instantiable) pluginClass.getAnnotation(Instantiable.class);
try { try {
instance.put(instantiable.value(), ReflectionUtils.instantiateObject(pluginClass)); instance.put(instantiable.value(), ReflectionUtils.instantiateObject(pluginClass));
TabooLib.debug("Instantiable " + pluginClass.getSimpleName() + " instanced. (" + plugin.getName() + ")");
} catch (Exception e) { } catch (Exception e) {
TLogger.getGlobalLogger().warn("Instance Failed: " + pluginClass.getName()); TLogger.getGlobalLogger().warn("Instance Failed: " + pluginClass.getName());
e.printStackTrace(); e.printStackTrace();

View File

@ -1,5 +1,7 @@
package me.skymc.taboolib.common.nms; 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.function.TFunction;
import me.skymc.taboolib.common.versioncontrol.SimpleVersionControl; import me.skymc.taboolib.common.versioncontrol.SimpleVersionControl;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -19,6 +21,11 @@ public abstract class NMSHandler {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); 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); abstract public void sendTitle(Player player, String title, int titleFadein, int titleStay, int titleFadeout, String subtitle, int subtitleFadein, int subtitleStay, int subtitleFadeout);

View File

@ -16,9 +16,7 @@ public class NMSHandlerImpl extends NMSHandler {
@Override @Override
public void sendTitle(Player player, String title, int titleFadein, int titleStay, int titleFadeout, String subtitle, int subtitleFadein, int subtitleStay, int subtitleFadeout) { 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.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)))); TPacketHandler.sendPacket(player, new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, new ChatComponentText(String.valueOf(subtitle))));
} }

View File

@ -1,5 +1,6 @@
package me.skymc.taboolib.listener; package me.skymc.taboolib.listener;
import com.ilummc.tlib.logger.TLogger;
import com.ilummc.tlib.util.Strings; import com.ilummc.tlib.util.Strings;
import me.skymc.taboolib.TabooLib; import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.TabooLibLoader; 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); Listener listener = plugin.getClass().equals(pluginClass) ? (Listener) plugin : (Listener) ReflectionUtils.instantiateObject(pluginClass);
listeners.computeIfAbsent(plugin.getName(), name -> new ArrayList<>()).add(listener); try {
TabooLib.debug("Listener " + listener.getClass().getSimpleName() + " setup successfully. (" + plugin.getName() + ")"); 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) { } catch (Exception e) {
TabooLib.debug("Listener setup failed: " + e.toString()); TabooLib.debug("Listener " + pluginClass.getSimpleName() + "(" + plugin.getName() + ")" + " setup failed: " + e.toString());
} }
} }
} }