Fix
This commit is contained in:
		@@ -10,6 +10,7 @@ import io.izzel.taboolib.module.db.local.Local;
 | 
				
			|||||||
import io.izzel.taboolib.module.db.source.DBSource;
 | 
					import io.izzel.taboolib.module.db.source.DBSource;
 | 
				
			||||||
import io.izzel.taboolib.module.dependency.TDependencyInjector;
 | 
					import io.izzel.taboolib.module.dependency.TDependencyInjector;
 | 
				
			||||||
import io.izzel.taboolib.module.inject.TListenerHandler;
 | 
					import io.izzel.taboolib.module.inject.TListenerHandler;
 | 
				
			||||||
 | 
					import io.izzel.taboolib.module.inject.TScheduleLoader;
 | 
				
			||||||
import io.izzel.taboolib.module.locale.TLocaleLoader;
 | 
					import io.izzel.taboolib.module.locale.TLocaleLoader;
 | 
				
			||||||
import org.bukkit.plugin.Plugin;
 | 
					import org.bukkit.plugin.Plugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -55,10 +56,14 @@ public abstract class PluginLoader {
 | 
				
			|||||||
            public void onActivated(Plugin plugin) {
 | 
					            public void onActivated(Plugin plugin) {
 | 
				
			||||||
                // 注册监听器
 | 
					                // 注册监听器
 | 
				
			||||||
                TListenerHandler.registerListener(plugin);
 | 
					                TListenerHandler.registerListener(plugin);
 | 
				
			||||||
 | 
					                // 注册调度器
 | 
				
			||||||
 | 
					                TScheduleLoader.run(plugin);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void onStopping(Plugin plugin) {
 | 
					            public void onStopping(Plugin plugin) {
 | 
				
			||||||
 | 
					                // 卸载语言文件
 | 
				
			||||||
 | 
					                TLocaleLoader.unload(plugin);
 | 
				
			||||||
                // 保存数据
 | 
					                // 保存数据
 | 
				
			||||||
                Local.saveFiles(plugin.getName());
 | 
					                Local.saveFiles(plugin.getName());
 | 
				
			||||||
                Local.clearFiles(plugin.getName());
 | 
					                Local.clearFiles(plugin.getName());
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -63,7 +63,7 @@ public class TabooLib {
 | 
				
			|||||||
        TabooLibLoader.init();
 | 
					        TabooLibLoader.init();
 | 
				
			||||||
        // 创建线程检测服务器是否关闭
 | 
					        // 创建线程检测服务器是否关闭
 | 
				
			||||||
        Executors.newSingleThreadExecutor().submit(() -> {
 | 
					        Executors.newSingleThreadExecutor().submit(() -> {
 | 
				
			||||||
            while (NMS.getHandler().isRunning()) {
 | 
					            while (NMS.handle().isRunning()) {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            // 保存数据
 | 
					            // 保存数据
 | 
				
			||||||
            Local.saveFiles();
 | 
					            Local.saveFiles();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,7 +42,7 @@ public class TabooLibAPI {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static double[] getTPS() {
 | 
					    public static double[] getTPS() {
 | 
				
			||||||
        return NMS.getHandler().getTPS();
 | 
					        return NMS.handle().getTPS();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static boolean isDebug() {
 | 
					    public static boolean isDebug() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,13 @@ public class TScheduleLoader implements TabooLibLoader.Loader {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    static Map<String, List<TScheduleData>> schedules = Maps.newHashMap();
 | 
					    static Map<String, List<TScheduleData>> schedules = Maps.newHashMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void run(Plugin plugin) {
 | 
				
			||||||
 | 
					        List<TScheduleData> list = schedules.get(plugin.getName());
 | 
				
			||||||
 | 
					        if (list != null) {
 | 
				
			||||||
 | 
					            list.forEach(data -> run(plugin, data.getRunnable(), data.getAnnotation().delay(), data.getAnnotation().period(), data.getAnnotation().async()));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void run(Plugin plugin, BukkitRunnable runnable, int delay, int period, boolean async) {
 | 
					    public static void run(Plugin plugin, BukkitRunnable runnable, int delay, int period, boolean async) {
 | 
				
			||||||
        if (async) {
 | 
					        if (async) {
 | 
				
			||||||
            runnable.runTaskTimerAsynchronously(plugin, delay, period);
 | 
					            runnable.runTaskTimerAsynchronously(plugin, delay, period);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,7 +56,7 @@ public class SimpleI18n {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static String getName(Entity entity) {
 | 
					    public static String getName(Entity entity) {
 | 
				
			||||||
        return entity == null ? "-" : lang.getString(NMS.getHandler().getName(entity).replace(".", "_"), entity.getName());
 | 
					        return entity == null ? "-" : lang.getString(NMS.handle().getName(entity).replace(".", "_"), entity.getName());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static String getName(ItemStack item) {
 | 
					    public static String getName(ItemStack item) {
 | 
				
			||||||
@@ -69,7 +69,7 @@ public class SimpleI18n {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!Version.isAfter(Version.v1_11)) {
 | 
					        if (!Version.isAfter(Version.v1_11)) {
 | 
				
			||||||
            if (item.getType().name().equals("MONSTER_EGG")) {
 | 
					            if (item.getType().name().equals("MONSTER_EGG")) {
 | 
				
			||||||
                NBTCompound nbtCompound = NMS.getHandler().loadNBT(item);
 | 
					                NBTCompound nbtCompound = NMS.handle().loadNBT(item);
 | 
				
			||||||
                if (nbtCompound.containsKey("EntityTag")) {
 | 
					                if (nbtCompound.containsKey("EntityTag")) {
 | 
				
			||||||
                    return lang.getString("item_monsterPlacer_name") + " " + lang.getString("entity_" + nbtCompound.get("EntityTag").asCompound().get("id").asString() + "_name");
 | 
					                    return lang.getString("item_monsterPlacer_name") + " " + lang.getString("entity_" + nbtCompound.get("EntityTag").asCompound().get("id").asString() + "_name");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -79,11 +79,11 @@ public class SimpleI18n {
 | 
				
			|||||||
            if (itemMeta instanceof SpawnEggMeta) {
 | 
					            if (itemMeta instanceof SpawnEggMeta) {
 | 
				
			||||||
                String spawnEggType = lang.getString("entity_" + ((SpawnEggMeta) itemMeta).getSpawnedType().getEntityClass().getSimpleName().replace(".", "_") + "_name");
 | 
					                String spawnEggType = lang.getString("entity_" + ((SpawnEggMeta) itemMeta).getSpawnedType().getEntityClass().getSimpleName().replace(".", "_") + "_name");
 | 
				
			||||||
                if (spawnEggType != null) {
 | 
					                if (spawnEggType != null) {
 | 
				
			||||||
                    return lang.getString(NMS.getHandler().getName(item).replace(".", "_"), item.getType().name().toLowerCase().replace("_", "")) + " " + spawnEggType;
 | 
					                    return lang.getString(NMS.handle().getName(item).replace(".", "_"), item.getType().name().toLowerCase().replace("_", "")) + " " + spawnEggType;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return lang.getString(NMS.getHandler().getName(item).replace(".", "_"), item.getType().name().toLowerCase().replace("_", ""));
 | 
					        return lang.getString(NMS.handle().getName(item).replace(".", "_"), item.getType().name().toLowerCase().replace("_", ""));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static void releaseLocales(Plugin plugin) {
 | 
					    private static void releaseLocales(Plugin plugin) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -96,11 +96,11 @@ public class TLocale {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static void sendTitle(Player player, String title, String subTitle, int fadein, int stay, int fadeout) {
 | 
					        public static void sendTitle(Player player, String title, String subTitle, int fadein, int stay, int fadeout) {
 | 
				
			||||||
            NMS.getHandler().sendTitle(player, title, fadein, stay, fadeout, subTitle, fadein, stay, fadeout);
 | 
					            NMS.handle().sendTitle(player, title, fadein, stay, fadeout, subTitle, fadein, stay, fadeout);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static void sendActionBar(Player player, String text) {
 | 
					        public static void sendActionBar(Player player, String text) {
 | 
				
			||||||
            NMS.getHandler().sendActionBar(player, text);
 | 
					            NMS.handle().sendActionBar(player, text);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -87,6 +87,10 @@ public class TLocaleLoader {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void unload(Plugin plugin) {
 | 
				
			||||||
 | 
					        map.remove(plugin.getName());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static boolean isLocaleLoaded(Plugin plugin) {
 | 
					    public static boolean isLocaleLoaded(Plugin plugin) {
 | 
				
			||||||
        return map.containsKey(plugin.getName());
 | 
					        return map.containsKey(plugin.getName());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,15 +15,15 @@ import org.bukkit.inventory.ItemStack;
 | 
				
			|||||||
@TFunction(enable = "init")
 | 
					@TFunction(enable = "init")
 | 
				
			||||||
public abstract class NMS {
 | 
					public abstract class NMS {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static NMS handler;
 | 
					    private static NMS impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static NMS getHandler() {
 | 
					    public static NMS handle() {
 | 
				
			||||||
        return handler;
 | 
					        return impl;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static void init() {
 | 
					    static void init() {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            handler = (NMS) SimpleVersionControl.createNMS("io.izzel.taboolib.module.nms.NMSHandlerImpl").translate().newInstance();
 | 
					            impl = (NMS) SimpleVersionControl.createNMS("io.izzel.taboolib.module.nms.NMSImpl").translate().newInstance();
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -232,7 +232,7 @@ public class Items {
 | 
				
			|||||||
        // 元数据
 | 
					        // 元数据
 | 
				
			||||||
        item.setItemMeta(meta);
 | 
					        item.setItemMeta(meta);
 | 
				
			||||||
        // 数据
 | 
					        // 数据
 | 
				
			||||||
        NBTCompound nbt = NMS.getHandler().loadNBT(item);
 | 
					        NBTCompound nbt = NMS.handle().loadNBT(item);
 | 
				
			||||||
        // 物品标签
 | 
					        // 物品标签
 | 
				
			||||||
        if (section.contains("nbt")) {
 | 
					        if (section.contains("nbt")) {
 | 
				
			||||||
            for (String name : section.getConfigurationSection("nbt").getKeys(false)) {
 | 
					            for (String name : section.getConfigurationSection("nbt").getKeys(false)) {
 | 
				
			||||||
@@ -281,6 +281,6 @@ public class Items {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            nbt.put("AttributeModifiers", attr);
 | 
					            nbt.put("AttributeModifiers", attr);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return NMS.getHandler().saveNBT(item, nbt);
 | 
					        return NMS.handle().saveNBT(item, nbt);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -843,7 +843,7 @@ public enum Particles {
 | 
				
			|||||||
                        data = getDustColor((OrdinaryColor) data, size);
 | 
					                        data = getDustColor((OrdinaryColor) data, size);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                this.packet = NMS.getHandler().toPacketPlayOutWorldParticles(effect.getBukkitParticle(), longDistance, (float) center.getX(), (float) center.getY(), (float) center.getZ(), offsetX, offsetY, offsetZ, speed, amount, data);
 | 
					                this.packet = NMS.handle().toPacketPlayOutWorldParticles(effect.getBukkitParticle(), longDistance, (float) center.getX(), (float) center.getY(), (float) center.getZ(), offsetX, offsetY, offsetZ, speed, amount, data);
 | 
				
			||||||
            } catch (Throwable exception) {
 | 
					            } catch (Throwable exception) {
 | 
				
			||||||
                throw new PacketInstantiationException("Packet instantiation failed", exception);
 | 
					                throw new PacketInstantiationException("Packet instantiation failed", exception);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user