更新
This commit is contained in:
parent
c573617a01
commit
b49a779859
@ -1,9 +1,10 @@
|
||||
package com.ilummc.tlib;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.ilummc.tlib.annotations.Config;
|
||||
import com.ilummc.tlib.bean.Property;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@Config(name = "cfg.yml", charset = "GBK")
|
||||
public class ExampleMain extends JavaPlugin {
|
||||
|
@ -1,105 +1,76 @@
|
||||
package com.ilummc.tlib;
|
||||
|
||||
import com.ilummc.tlib.annotations.Config;
|
||||
import com.ilummc.tlib.annotations.Dependency;
|
||||
import com.ilummc.tlib.annotations.Logger;
|
||||
import com.ilummc.tlib.compat.PlaceholderApiHook;
|
||||
import com.ilummc.tlib.inject.DependencyInjector;
|
||||
import com.ilummc.tlib.inject.TConfigWatcher;
|
||||
import com.ilummc.tlib.inject.TLibPluginManager;
|
||||
import com.ilummc.tlib.resources.LocaleLoader;
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import com.ilummc.tlib.util.TLogger;
|
||||
import me.skymc.taboolib.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.ilummc.tlib.annotations.Dependency;
|
||||
import com.ilummc.tlib.compat.PlaceholderHook;
|
||||
import com.ilummc.tlib.config.TLibConfig;
|
||||
import com.ilummc.tlib.filter.TLoggerFilter;
|
||||
import com.ilummc.tlib.inject.TConfigWatcher;
|
||||
import com.ilummc.tlib.inject.TDependencyInjector;
|
||||
import com.ilummc.tlib.inject.TPluginManager;
|
||||
import com.ilummc.tlib.resources.TLocaleLoader;
|
||||
import com.ilummc.tlib.util.TLogger;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.skymc.taboolib.Main;
|
||||
|
||||
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.ow2.asm:asm:6.1.1")
|
||||
@Dependency(type = Dependency.Type.LIBRARY, maven = "com.zaxxer:HikariCP:3.1.0")
|
||||
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.slf4j:slf4j-api:1.7.25")
|
||||
public class TLib {
|
||||
|
||||
@Getter
|
||||
private static TLib tLib;
|
||||
|
||||
@Logger("§8[§3§lTabooLib§8][§r{1}§8] §f{2}")
|
||||
private TLogger tLogger = new TLogger("§8[§3§lTabooLib§8][§r{1}§8] §f{2}", Main.getInst(), TLogger.FINE);
|
||||
@Getter
|
||||
private TLogger logger = new TLogger("§8[§3§lTabooLib§8][§r{1}§8] §f{2}", Main.getInst(), TLogger.FINE);
|
||||
|
||||
@Getter
|
||||
private TLibConfig config;
|
||||
|
||||
@Getter
|
||||
private TConfigWatcher configWatcher = new TConfigWatcher();
|
||||
|
||||
@Getter
|
||||
private File libsFolder;
|
||||
|
||||
private TLib() {
|
||||
}
|
||||
|
||||
public TLibConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public TLogger getLogger() {
|
||||
return tLogger;
|
||||
}
|
||||
|
||||
public TConfigWatcher getConfigWatcher() {
|
||||
return configWatcher;
|
||||
}
|
||||
|
||||
public static TLib getTLib() {
|
||||
return tLib;
|
||||
}
|
||||
|
||||
public static void injectPluginManager() {
|
||||
// 注入 PluginLoader 用于加载依赖
|
||||
try {
|
||||
Field field = Bukkit.getServer().getClass().getDeclaredField("pluginManager");
|
||||
field.setAccessible(true);
|
||||
field.set(Bukkit.getServer(), new TLibPluginManager());
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
libsFolder = new File(Main.getInst().getDataFolder(), "/libs");
|
||||
if (!libsFolder.exists()) {
|
||||
libsFolder.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
new File(Main.getInst().getDataFolder(), "/libs").mkdirs();
|
||||
tLib = new TLib();
|
||||
LocaleLoader.init();
|
||||
PlaceholderApiHook.init();
|
||||
DependencyInjector.inject(Main.getInst(), tLib);
|
||||
if (Bukkit.getPluginManager() instanceof TLibPluginManager)
|
||||
|
||||
TLoggerFilter.init();
|
||||
TLocaleLoader.init();
|
||||
PlaceholderHook.init();
|
||||
TDependencyInjector.inject(Main.getInst(), tLib);
|
||||
|
||||
if (Bukkit.getPluginManager() instanceof TPluginManager) {
|
||||
tLib.getLogger().info("注入成功");
|
||||
else
|
||||
} else {
|
||||
tLib.getLogger().fatal("注入失败");
|
||||
TLocale.sendToConsole("test1");
|
||||
TLocale.sendToConsole("test2");
|
||||
TLocale.sendToConsole("test3");
|
||||
TLocale.sendToConsole("test4.node1", "Hello", "world");
|
||||
}
|
||||
}
|
||||
|
||||
public static void unload() {
|
||||
tLib.getConfigWatcher().unregisterAll();
|
||||
DependencyInjector.eject(Main.getInst(), tLib);
|
||||
TDependencyInjector.eject(Main.getInst(), tLib);
|
||||
}
|
||||
|
||||
@Config(name = "tlib.yml", listenChanges = true, readOnly = false)
|
||||
public static class TLibConfig {
|
||||
|
||||
private int downloadPoolSize = 4;
|
||||
|
||||
public int getDownloadPoolSize() {
|
||||
return downloadPoolSize;
|
||||
}
|
||||
|
||||
private String[] locale = {"zh_CN", "en_US"};
|
||||
|
||||
public String[] getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
private boolean enablePapiByDefault = false;
|
||||
|
||||
public boolean isEnablePapiByDefault() {
|
||||
return enablePapiByDefault;
|
||||
public static void injectPluginManager() {
|
||||
try {
|
||||
Field field = Bukkit.getServer().getClass().getDeclaredField("pluginManager");
|
||||
field.setAccessible(true);
|
||||
field.set(Bukkit.getServer(), new TPluginManager());
|
||||
} catch (NoSuchFieldException | IllegalAccessException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package com.ilummc.tlib.annotations;
|
||||
|
||||
import com.ilummc.tlib.util.Ref;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import com.ilummc.tlib.util.Ref;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Config {
|
||||
|
@ -1,8 +1,12 @@
|
||||
package com.ilummc.tlib.annotations;
|
||||
|
||||
import com.ilummc.tlib.dependency.TDependency;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Repeatable;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import com.ilummc.tlib.dependency.TDependency;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.ilummc.tlib.annotations;
|
||||
|
||||
import com.ilummc.tlib.util.TLogger;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.ilummc.tlib.util.TLogger;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Logger {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.ilummc.tlib.bean;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class PropertyTypeAdaptor implements JsonDeserializer<Property> {
|
||||
|
||||
@Override
|
||||
|
41
src/main/java/com/ilummc/tlib/compat/PlaceholderHook.java
Normal file
41
src/main/java/com/ilummc/tlib/compat/PlaceholderHook.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.ilummc.tlib.compat;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
|
||||
public abstract class PlaceholderHook {
|
||||
|
||||
private static PlaceholderHook impl;
|
||||
|
||||
public static void init() {
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null)
|
||||
impl = new PlaceholderImpl();
|
||||
else impl = new AbstractImpl();
|
||||
}
|
||||
|
||||
public static String replace(CommandSender sender, String text) {
|
||||
return sender instanceof Player ? impl.replace(((Player) sender), text) : text;
|
||||
}
|
||||
|
||||
abstract String replace(Player player, String text);
|
||||
|
||||
private static class PlaceholderImpl extends PlaceholderHook {
|
||||
|
||||
@Override
|
||||
String replace(Player player, String text) {
|
||||
return PlaceholderAPI.setPlaceholders(player, text);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AbstractImpl extends PlaceholderHook {
|
||||
|
||||
@Override
|
||||
String replace(Player player, String text) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
23
src/main/java/com/ilummc/tlib/config/TLibConfig.java
Normal file
23
src/main/java/com/ilummc/tlib/config/TLibConfig.java
Normal file
@ -0,0 +1,23 @@
|
||||
package com.ilummc.tlib.config;
|
||||
|
||||
import com.ilummc.tlib.annotations.Config;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018-04-22 14:31:11
|
||||
*/
|
||||
@Config(name = "tlib.yml", listenChanges = true, readOnly = false)
|
||||
public class TLibConfig {
|
||||
|
||||
private String[] locale = {"zh_CN", "en_US"};
|
||||
|
||||
public String[] getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
private boolean enablePlaceholderHookByDefault = false;
|
||||
|
||||
public boolean isEnablePlaceholderHookByDefault() {
|
||||
return enablePlaceholderHookByDefault;
|
||||
}
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
package com.ilummc.tlib.dependency;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.ilummc.eagletdl.EagletTask;
|
||||
import com.ilummc.eagletdl.ProgressEvent;
|
||||
import com.ilummc.tlib.TLib;
|
||||
import me.skymc.taboolib.Main;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import me.skymc.taboolib.Main;
|
||||
|
||||
public class TDependency {
|
||||
|
||||
@ -43,10 +44,11 @@ public class TDependency {
|
||||
if (downloadMaven(repo, arr[0], arr[1], arr[2], file, url)) {
|
||||
TDependencyLoader.addToPath(Main.getInst(), file);
|
||||
return true;
|
||||
} else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -60,14 +62,10 @@ public class TDependency {
|
||||
new EagletTask()
|
||||
.url(link)
|
||||
.file(target)
|
||||
.setThreads(TLib.getTLib().getConfig().getDownloadPoolSize())
|
||||
.setOnError(event -> {
|
||||
})
|
||||
.setOnConnected(event -> TLib.getTLib().getLogger().info(" 正在下载 " + String.join(":",
|
||||
new String[]{groupId, artifactId, version}) +
|
||||
" 大小 " + ProgressEvent.format(event.getContentLength())))
|
||||
.setOnProgress(event -> TLib.getTLib().getLogger().info(" 下载速度 " + event.getSpeedFormatted()
|
||||
+ " 进度 " + event.getPercentageFormatted()))
|
||||
.setThreads(getDownloadPoolSize())
|
||||
.setOnError(event -> {})
|
||||
.setOnConnected(event -> TLib.getTLib().getLogger().info(" 正在下载 " + String.join(":", new String[]{groupId, artifactId, version}) + " 大小 " + ProgressEvent.format(event.getContentLength())))
|
||||
.setOnProgress(event -> TLib.getTLib().getLogger().info(" 下载速度 " + event.getSpeedFormatted() + " 进度 " + event.getPercentageFormatted()))
|
||||
.setOnComplete(event -> {
|
||||
if (event.isSuccess()) {
|
||||
TLib.getTLib().getLogger().info(" 下载 " + String.join(":", new String[]{groupId, artifactId, version}) + " 完成");
|
||||
@ -80,4 +78,7 @@ public class TDependency {
|
||||
return !failed.get();
|
||||
}
|
||||
|
||||
private static int getDownloadPoolSize() {
|
||||
return Main.getInst().getConfig().contains("DOWNLOAD-POOL-SIZE") ? Main.getInst().getConfig().getInt("DOWNLOAD-POOL-SIZE") : 4;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.ilummc.tlib.dependency;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -9,6 +7,8 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TDependencyLoader {
|
||||
|
||||
public static synchronized void addToPath(Plugin plugin, URL url) {
|
||||
|
32
src/main/java/com/ilummc/tlib/filter/TLoggerFilter.java
Normal file
32
src/main/java/com/ilummc/tlib/filter/TLoggerFilter.java
Normal file
@ -0,0 +1,32 @@
|
||||
package com.ilummc.tlib.filter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Filter;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
/**
|
||||
* @author Bkm016
|
||||
* @since 2018-04-22
|
||||
*/
|
||||
public class TLoggerFilter implements Filter {
|
||||
|
||||
public static void init() {
|
||||
Bukkit.getLogger().setFilter(new TLoggerFilter());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoggable(LogRecord e) {
|
||||
if (e.getMessage().contains("Cannot load configuration from stream")) {
|
||||
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
|
||||
for (StackTraceElement element : elements) {
|
||||
if (element.getClassName().contains("ConfigUtils")) {
|
||||
System.out.println(Arrays.asList(e.getParameters()));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,5 +1,25 @@
|
||||
package com.ilummc.tlib.inject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.Files;
|
||||
@ -9,24 +29,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.ilummc.tlib.TLib;
|
||||
import com.ilummc.tlib.annotations.Config;
|
||||
import com.ilummc.tlib.bean.Property;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TConfigInjector {
|
||||
|
||||
public static void fixUnicode(YamlConfiguration configuration) {
|
||||
public static void fixUnicode(FileConfiguration configuration) {
|
||||
try {
|
||||
Field field = YamlConfiguration.class.getDeclaredField("yamlOptions");
|
||||
field.setAccessible(true);
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.ilummc.tlib.inject;
|
||||
|
||||
import com.ilummc.tlib.TLib;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.StandardWatchEventKinds;
|
||||
import java.nio.file.WatchEvent;
|
||||
import java.nio.file.WatchKey;
|
||||
import java.nio.file.WatchService;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -14,6 +15,8 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
public class TConfigWatcher {
|
||||
|
||||
private ScheduledExecutorService service = Executors.newScheduledThreadPool(1);
|
||||
|
173
src/main/java/com/ilummc/tlib/inject/TDependencyInjector.java
Normal file
173
src/main/java/com/ilummc/tlib/inject/TDependencyInjector.java
Normal file
@ -0,0 +1,173 @@
|
||||
package com.ilummc.tlib.inject;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.ilummc.tlib.TLib;
|
||||
import com.ilummc.tlib.annotations.Config;
|
||||
import com.ilummc.tlib.annotations.Dependencies;
|
||||
import com.ilummc.tlib.annotations.Dependency;
|
||||
import com.ilummc.tlib.annotations.Logger;
|
||||
import com.ilummc.tlib.annotations.PluginInstance;
|
||||
import com.ilummc.tlib.dependency.TDependency;
|
||||
import com.ilummc.tlib.resources.TLocaleLoader;
|
||||
import com.ilummc.tlib.util.Ref;
|
||||
import com.ilummc.tlib.util.TLogger;
|
||||
|
||||
public class TDependencyInjector {
|
||||
|
||||
public static void inject(Plugin plugin, Object o) {
|
||||
injectDependencies(plugin, o);
|
||||
injectLogger(plugin, o);
|
||||
injectConfig(plugin, o);
|
||||
injectPluginInstance(plugin, o);
|
||||
TLocaleLoader.load(plugin, true);
|
||||
}
|
||||
|
||||
static void injectOnEnable(Plugin plugin) {
|
||||
inject(plugin, plugin);
|
||||
}
|
||||
|
||||
static void onDisable(Plugin plugin) {
|
||||
eject(plugin, plugin);
|
||||
}
|
||||
|
||||
public static void eject(Plugin plugin, Object o) {
|
||||
try {
|
||||
ejectConfig(plugin, o);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void ejectConfig(Plugin plugin, Object o) {
|
||||
for (Field field : Ref.getDeclaredFields(o.getClass())) {
|
||||
Config config;
|
||||
if ((config = field.getType().getAnnotation(Config.class)) != null && config.saveOnExit()) {
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
TConfigInjector.saveConfig(plugin, field.get(o));
|
||||
TLib.getTLib().getLogger().info("插件 " + plugin + " 的配置 " + config.name() + " 已保存");
|
||||
} catch (Exception e) {
|
||||
TLib.getTLib().getLogger().warn("插件 " + plugin + " 的配置 " + config.name() + " 保存失败");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void injectConfig(Plugin plugin, Object o) {
|
||||
for (Field field : Ref.getDeclaredFields(o.getClass())) {
|
||||
try {
|
||||
Config config;
|
||||
if ((config = field.getType().getAnnotation(Config.class)) != null) {
|
||||
field.setAccessible(true);
|
||||
Object obj = TConfigInjector.loadConfig(plugin, field.getType());
|
||||
if (obj != null) {
|
||||
TLib.getTLib().getLogger().info("插件 " + plugin.getName() + " 的 " + config.name() + " 配置文件成功加载");
|
||||
field.set(o, obj);
|
||||
if (config.listenChanges()) {
|
||||
TLib.getTLib().getLogger().info("开始监听插件 " + plugin.getName() + " 的 " + config.name() + " 配置文件");
|
||||
TLib.getTLib().getConfigWatcher().addOnListen(
|
||||
new File(plugin.getDataFolder(), config.name()),
|
||||
obj,
|
||||
object -> {
|
||||
try {
|
||||
Object newObj = TConfigInjector.loadConfig(plugin, object.getClass());
|
||||
for (Field f : newObj.getClass().getDeclaredFields()) {
|
||||
f.setAccessible(true);
|
||||
f.set(obj, f.get(newObj));
|
||||
}
|
||||
TLib.getTLib().getLogger().info("插件 " + plugin.getName() + " 的 " + config.name() + " 配置文件成功重载");
|
||||
} catch (Exception ignored) {
|
||||
TLib.getTLib().getLogger().warn("插件 " + plugin.getName() + " 的 " + config.name() + " 配置文件重载时发生错误");
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void injectLogger(Plugin plugin, Object o) {
|
||||
for (Field field : Ref.getDeclaredFields(o.getClass())) {
|
||||
try {
|
||||
Logger logger;
|
||||
if ((logger = field.getAnnotation(Logger.class)) != null) {
|
||||
field.getType().asSubclass(TLogger.class);
|
||||
TLogger tLogger = new TLogger(logger.value(), plugin, logger.level());
|
||||
if (!field.isAccessible())
|
||||
field.setAccessible(true);
|
||||
field.set(o, tLogger);
|
||||
}
|
||||
} catch (Exception ignored2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void injectPluginInstance(Plugin plugin, Object o) {
|
||||
for (Field field : Ref.getDeclaredFields(o.getClass())) {
|
||||
try {
|
||||
PluginInstance instance;
|
||||
if ((instance = field.getAnnotation(PluginInstance.class)) != null) {
|
||||
if (!field.isAccessible())
|
||||
field.setAccessible(true);
|
||||
field.getType().asSubclass(JavaPlugin.class);
|
||||
Plugin pl;
|
||||
if ((pl = Bukkit.getPluginManager().getPlugin(instance.value())) == null) {
|
||||
if (!TDependency.requestPlugin(instance.value())) {
|
||||
TLib.getTLib().getLogger().warn(plugin.getName() + " 所需的依赖插件 " + instance.value() + " 自动加载失败");
|
||||
return;
|
||||
} else {
|
||||
pl = Bukkit.getPluginManager().getPlugin(instance.value());
|
||||
}
|
||||
}
|
||||
if (pl != null)
|
||||
field.set(o, pl);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void injectDependencies(Plugin plugin, Object o) {
|
||||
Dependency[] dependencies = new Dependency[0];
|
||||
{
|
||||
Dependencies d = o.getClass().getAnnotation(Dependencies.class);
|
||||
if (d != null) {
|
||||
dependencies = d.value();
|
||||
}
|
||||
Dependency d2 = o.getClass().getAnnotation(Dependency.class);
|
||||
if (d2 != null) {
|
||||
dependencies = new Dependency[]{d2};
|
||||
}
|
||||
}
|
||||
if (dependencies.length != 0) {
|
||||
TLib.getTLib().getLogger().info("正在加载 " + plugin.getName() + " 插件所需的依赖");
|
||||
for (Dependency dependency : dependencies) {
|
||||
if (dependency.type() == Dependency.Type.PLUGIN) {
|
||||
if (TDependency.requestPlugin(dependency.plugin())) {
|
||||
TLib.getTLib().getLogger().info(" " + plugin.getName() + " 请求的插件 " + dependency.plugin() + " 加载成功。");
|
||||
} else {
|
||||
TLib.getTLib().getLogger().warn(" " + plugin.getName() + " 请求的插件 " + dependency.plugin() + " 加载失败。");
|
||||
}
|
||||
}
|
||||
if (dependency.type() == Dependency.Type.LIBRARY) {
|
||||
if (TDependency.requestLib(dependency.maven(), dependency.mavenRepo(), dependency.url())) {
|
||||
TLib.getTLib().getLogger().info(" " + plugin.getName() + " 请求的库文件 " + String.join(":", dependency.maven()) + " 加载成功。");
|
||||
} else {
|
||||
TLib.getTLib().getLogger().warn(" " + plugin.getName() + " 请求的库文件 " + String.join(":", dependency.maven()) + " 加载失败。");
|
||||
}
|
||||
}
|
||||
}
|
||||
TLib.getTLib().getLogger().info("依赖加载完成");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
181
src/main/java/com/ilummc/tlib/inject/TPluginManager.java
Normal file
181
src/main/java/com/ilummc/tlib/inject/TPluginManager.java
Normal file
@ -0,0 +1,181 @@
|
||||
package com.ilummc.tlib.inject;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.EventExecutor;
|
||||
import org.bukkit.plugin.InvalidDescriptionException;
|
||||
import org.bukkit.plugin.InvalidPluginException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginLoader;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.UnknownDependencyException;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
|
||||
public class TPluginManager implements PluginManager {
|
||||
|
||||
private final PluginManager instance;
|
||||
|
||||
private final Main main = (Main) Main.getInst();
|
||||
|
||||
public TPluginManager() {
|
||||
instance = Bukkit.getPluginManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerInterface(Class<? extends PluginLoader> aClass) throws IllegalArgumentException {
|
||||
instance.registerInterface(aClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin getPlugin(String s) {
|
||||
return instance.getPlugin(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin[] getPlugins() {
|
||||
return instance.getPlugins();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPluginEnabled(String s) {
|
||||
return instance.isPluginEnabled(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPluginEnabled(Plugin plugin) {
|
||||
return instance.isPluginEnabled(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
|
||||
return instance.loadPlugin(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin[] loadPlugins(File file) {
|
||||
return instance.loadPlugins(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disablePlugins() {
|
||||
for (Plugin plugin : getPlugins()) {
|
||||
if (plugin != main) disablePlugin(plugin);
|
||||
}
|
||||
disablePlugin(main);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPlugins() {
|
||||
instance.clearPlugins();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callEvent(Event event) throws IllegalStateException {
|
||||
instance.callEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvents(Listener listener, Plugin plugin) {
|
||||
instance.registerEvents(listener, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvent(Class<? extends Event> aClass, Listener listener, EventPriority eventPriority, EventExecutor eventExecutor, Plugin plugin) {
|
||||
instance.registerEvent(aClass, listener, eventPriority, eventExecutor, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvent(Class<? extends Event> aClass, Listener listener, EventPriority eventPriority, EventExecutor eventExecutor, Plugin plugin, boolean b) {
|
||||
instance.registerEvent(aClass, listener, eventPriority, eventExecutor, plugin, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enablePlugin(Plugin plugin) {
|
||||
TDependencyInjector.injectOnEnable(plugin);
|
||||
instance.enablePlugin(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disablePlugin(Plugin plugin) {
|
||||
TDependencyInjector.onDisable(plugin);
|
||||
instance.disablePlugin(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission getPermission(String s) {
|
||||
return instance.getPermission(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission(Permission permission) {
|
||||
instance.addPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission(Permission permission) {
|
||||
instance.removePermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission(String s) {
|
||||
instance.removePermission(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Permission> getDefaultPermissions(boolean b) {
|
||||
return instance.getDefaultPermissions(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculatePermissionDefaults(Permission permission) {
|
||||
instance.recalculatePermissionDefaults(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribeToPermission(String s, Permissible permissible) {
|
||||
instance.subscribeToPermission(s, permissible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribeFromPermission(String s, Permissible permissible) {
|
||||
instance.unsubscribeFromPermission(s, permissible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Permissible> getPermissionSubscriptions(String s) {
|
||||
return instance.getPermissionSubscriptions(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribeToDefaultPerms(boolean b, Permissible permissible) {
|
||||
instance.subscribeToDefaultPerms(b, permissible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribeFromDefaultPerms(boolean b, Permissible permissible) {
|
||||
instance.unsubscribeFromDefaultPerms(b, permissible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Permissible> getDefaultPermSubscriptions(boolean b) {
|
||||
return instance.getDefaultPermSubscriptions(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Permission> getPermissions() {
|
||||
return instance.getPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useTimings() {
|
||||
return instance.useTimings();
|
||||
}
|
||||
}
|
@ -1,11 +1,20 @@
|
||||
package com.ilummc.tlib.resources;
|
||||
|
||||
import com.ilummc.tlib.util.Ref;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import com.google.common.base.Strings;
|
||||
import com.ilummc.tlib.TLib;
|
||||
import com.ilummc.tlib.util.Ref;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
|
||||
public final class TLocale {
|
||||
|
||||
@ -13,42 +22,48 @@ public final class TLocale {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
private static void sendTo(String path, CommandSender sender, String[] args, Class<?> callerClass) {
|
||||
private static JavaPlugin getCallerPlugin(Class<?> callerClass) {
|
||||
try {
|
||||
Field pluginField = callerClass.getClassLoader().getClass().getDeclaredField("plugin");
|
||||
pluginField.setAccessible(true);
|
||||
JavaPlugin plugin = (JavaPlugin) pluginField.get(callerClass.getClassLoader());
|
||||
if (args.length == 0)
|
||||
LocaleLoader.sendTo(plugin, path, sender);
|
||||
else
|
||||
LocaleLoader.sendTo(plugin, path, sender, args);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return (JavaPlugin) pluginField.get(callerClass.getClassLoader());
|
||||
} catch (Exception ignored) {
|
||||
TLib.getTLib().getLogger().error("无效的语言文件发送形式: &4" + callerClass.getName());
|
||||
}
|
||||
return (JavaPlugin) Main.getInst();
|
||||
}
|
||||
|
||||
public static void sendTo(String path, CommandSender sender, String... args) {
|
||||
Ref.getCallerClass(3).ifPresent(clazz -> sendTo(path, sender, args, clazz));
|
||||
private static void sendTo(String path, CommandSender sender, String[] args, Class<?> callerClass) {
|
||||
TLocaleLoader.sendTo(getCallerPlugin(callerClass), path, sender, args);
|
||||
}
|
||||
|
||||
public static void sendTo(String path, CommandSender sender) {
|
||||
Ref.getCallerClass(3).ifPresent(clazz -> sendTo(path, sender, new String[0], clazz));
|
||||
}
|
||||
|
||||
public static void sendTo(CommandSender sender, String path, String... args) {
|
||||
Ref.getCallerClass(3).ifPresent(clazz -> sendTo(path, sender, args, clazz));
|
||||
}
|
||||
|
||||
public static void sendTo(CommandSender sender, String path) {
|
||||
Ref.getCallerClass(3).ifPresent(clazz -> sendTo(path, sender, new String[0], clazz));
|
||||
private static String asString(String path, String[] args, Class<?> callerClass) {
|
||||
return TLocaleLoader.asString(getCallerPlugin(callerClass), path);
|
||||
}
|
||||
|
||||
public static void sendToConsole(String path, String... args) {
|
||||
Ref.getCallerClass(3).ifPresent(clazz -> sendTo(path, Bukkit.getConsoleSender(), args, clazz));
|
||||
}
|
||||
|
||||
public static void sendToConsole(String path) {
|
||||
Ref.getCallerClass(3).ifPresent(clazz -> sendTo(path, Bukkit.getConsoleSender(), new String[0], clazz));
|
||||
public static void sendTo(CommandSender sender, String path, String... args) {
|
||||
Ref.getCallerClass(3).ifPresent(clazz -> sendTo(path, sender, args, clazz));
|
||||
}
|
||||
|
||||
public static void sendTo(String path, CommandSender sender, String... args) {
|
||||
Ref.getCallerClass(3).ifPresent(clazz -> sendTo(path, sender, args, clazz));
|
||||
}
|
||||
|
||||
public static String asString(String path, String... args) {
|
||||
try {
|
||||
return asString(path, args, Ref.getCallerClass(3).get());
|
||||
} catch (Exception e) {
|
||||
TLib.getTLib().getLogger().error("语言文件获取失败: " + path);
|
||||
TLib.getTLib().getLogger().error("原因: " + e.getMessage());
|
||||
return "§4<" + path + "§4>";
|
||||
}
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
Ref.getCallerClass(3).ifPresent(clazz -> TLocaleLoader.load(getCallerPlugin(clazz), false));
|
||||
}
|
||||
}
|
||||
|
98
src/main/java/com/ilummc/tlib/resources/TLocaleInstance.java
Normal file
98
src/main/java/com/ilummc/tlib/resources/TLocaleInstance.java
Normal file
@ -0,0 +1,98 @@
|
||||
package com.ilummc.tlib.resources;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.ilummc.tlib.TLib;
|
||||
import com.ilummc.tlib.resources.type.TLocaleText;
|
||||
|
||||
@ThreadSafe
|
||||
@SuppressWarnings("rawtypes")
|
||||
class TLocaleInstance {
|
||||
|
||||
TLocaleInstance() {
|
||||
}
|
||||
|
||||
void sendTo(String path, CommandSender sender) {
|
||||
try {
|
||||
map.getOrDefault(path, ImmutableList.of(TLocaleSendable.getEmpty(path))).forEach(sendable -> sendable.sendTo(sender));
|
||||
} catch (Exception e) {
|
||||
TLib.getTLib().getLogger().error("语言文件发送失败: " + path);
|
||||
TLib.getTLib().getLogger().error("原因: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
void sendTo(String path, CommandSender sender, String... args) {
|
||||
try {
|
||||
map.getOrDefault(path, ImmutableList.of(TLocaleSendable.getEmpty(path))).forEach(sendable -> sendable.sendTo(sender, args));
|
||||
} catch (Exception e) {
|
||||
TLib.getTLib().getLogger().error("语言文件发送失败: " + path);
|
||||
TLib.getTLib().getLogger().error("原因: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
String asString(String path) {
|
||||
return map.getOrDefault(path, ImmutableList.of(TLocaleSendable.getEmpty(path))).get(0).asString();
|
||||
}
|
||||
|
||||
void load(FileConfiguration configuration) {
|
||||
configuration.getKeys(false).forEach(s -> {
|
||||
Object object = configuration.get(s);
|
||||
if (object instanceof ConfigurationSection) {
|
||||
loadRecursively(s, (ConfigurationSection) object);
|
||||
}
|
||||
else if (object instanceof TLocaleSendable) {
|
||||
map.put(s, Collections.singletonList((TLocaleSendable) object));
|
||||
}
|
||||
else if (object instanceof List && !((List) object).isEmpty()) {
|
||||
map.put(s, ((List<?>) object).stream().map(TO_SENDABLE).collect(Collectors.toList()));
|
||||
}
|
||||
else {
|
||||
map.put(s, Collections.singletonList(TLocaleText.of(String.valueOf(object))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final Function<Object, TLocaleSendable> TO_SENDABLE = o -> {
|
||||
if (o instanceof TLocaleSendable) {
|
||||
return ((TLocaleSendable) o);
|
||||
} else if (o instanceof String) {
|
||||
return TLocaleText.of(((String) o));
|
||||
} else {
|
||||
return TLocaleText.of(String.valueOf(o));
|
||||
}
|
||||
};
|
||||
|
||||
private final Map<String, List<TLocaleSendable>> map = new ConcurrentHashMap<>();
|
||||
|
||||
private void loadRecursively(String path, ConfigurationSection section) {
|
||||
section.getKeys(false).forEach(s -> {
|
||||
Object object = section.get(path + "." + s);
|
||||
if (object instanceof ConfigurationSection) {
|
||||
loadRecursively(path + "." + s, (ConfigurationSection) object);
|
||||
}
|
||||
else if (object instanceof TLocaleSendable) {
|
||||
map.put(path + "." + s, Collections.singletonList((TLocaleSendable) object));
|
||||
}
|
||||
else if (object instanceof List && !((List) object).isEmpty()) {
|
||||
map.put(path + "." + s, ((List<?>) object).stream().map(TO_SENDABLE).collect(Collectors.toList()));
|
||||
}
|
||||
else {
|
||||
map.put(path + "." + s, Collections.singletonList(TLocaleText.of(String.valueOf(object))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
104
src/main/java/com/ilummc/tlib/resources/TLocaleLoader.java
Normal file
104
src/main/java/com/ilummc/tlib/resources/TLocaleLoader.java
Normal file
@ -0,0 +1,104 @@
|
||||
package com.ilummc.tlib.resources;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.ilummc.tlib.TLib;
|
||||
import com.ilummc.tlib.inject.TConfigInjector;
|
||||
import com.ilummc.tlib.resources.type.TLocaleText;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
import me.skymc.taboolib.fileutils.FileUtils;
|
||||
|
||||
public class TLocaleLoader {
|
||||
|
||||
private static final Map<String, TLocaleInstance> map = new HashMap<>();
|
||||
|
||||
static void sendTo(Plugin plugin, String path, CommandSender sender, String... args) {
|
||||
Optional.ofNullable(map.get(plugin.getName())).ifPresent(localeInstance -> localeInstance.sendTo(path, sender, args));
|
||||
}
|
||||
|
||||
static String asString(Plugin plugin, String path) {
|
||||
return Optional.ofNullable(map.get(plugin.getName())).get().asString(path);
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
ConfigurationSerialization.registerClass(TLocaleText.class, "TEXT");
|
||||
}
|
||||
|
||||
public static void load(Plugin plugin, boolean ignoreLoaded) {
|
||||
try {
|
||||
if ((!ignoreLoaded || !map.containsKey(plugin.getName())) && plugin == Main.getInst() || plugin.getDescription().getDepend().contains("TabooLib") || plugin.getDescription().getSoftDepend().contains("TabooLib")) {
|
||||
InputStream inputStream = null;
|
||||
File file = null;
|
||||
String lang = null;
|
||||
for (String s : TLib.getTLib().getConfig().getLocale()) {
|
||||
lang = s;
|
||||
file = new File(plugin.getDataFolder(), "/lang/" + s + ".yml");
|
||||
if (file.exists()) {
|
||||
inputStream = Files.newInputStream(file.toPath(), StandardOpenOption.READ);
|
||||
break;
|
||||
} else if ((inputStream = plugin.getClass().getResourceAsStream("/lang/" + s + ".yml")) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (inputStream == null) {
|
||||
TLib.getTLib().getLogger().error("语言文件加载失败");
|
||||
return;
|
||||
}
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
saveResource(inputStream, file);
|
||||
}
|
||||
TLib.getTLib().getLogger().info("尝试加载 " + lang + ".yml 作为语言文件");
|
||||
FileConfiguration configuration = ConfigUtils.load(plugin, file);
|
||||
TLocaleInstance localeInstance = new TLocaleInstance();
|
||||
localeInstance.load(configuration);
|
||||
map.put(plugin.getName(), localeInstance);
|
||||
TConfigInjector.fixUnicode(configuration);
|
||||
TLib.getTLib().getLogger().info("成功加载 " + lang + " 语言文件");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
TLib.getTLib().getLogger().error("载入语言文件发生异常:" + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void saveResource(InputStream inputStream, File file) {
|
||||
FileOutputStream fileOutputStream = null;
|
||||
try {
|
||||
byte[] data = FileUtils.read(inputStream);
|
||||
fileOutputStream = new FileOutputStream(file);
|
||||
fileOutputStream.write(data);
|
||||
} catch (Exception e) {
|
||||
TLib.getTLib().getLogger().error("资源文件写入失败: " + file);
|
||||
TLib.getTLib().getLogger().error("原因: " + e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (fileOutputStream != null) {
|
||||
fileOutputStream.close();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
src/main/java/com/ilummc/tlib/resources/TLocaleSendable.java
Normal file
25
src/main/java/com/ilummc/tlib/resources/TLocaleSendable.java
Normal file
@ -0,0 +1,25 @@
|
||||
package com.ilummc.tlib.resources;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public interface TLocaleSendable {
|
||||
|
||||
public static TLocaleSendable getEmpty(String path) {
|
||||
return new TLocaleSendable() {
|
||||
|
||||
@Override
|
||||
public void sendTo(CommandSender sender, String... args) {
|
||||
sender.sendMessage("§4<" + path + "§4>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString(String... args) {
|
||||
return "§4<" + path + "§4>";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void sendTo(CommandSender sender, String... args);
|
||||
|
||||
String asString(String... args);
|
||||
}
|
107
src/main/java/com/ilummc/tlib/resources/type/TLocaleText.java
Normal file
107
src/main/java/com/ilummc/tlib/resources/type/TLocaleText.java
Normal file
@ -0,0 +1,107 @@
|
||||
package com.ilummc.tlib.resources.type;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.ilummc.tlib.TLib;
|
||||
import com.ilummc.tlib.compat.PlaceholderHook;
|
||||
import com.ilummc.tlib.resources.TLocaleSendable;
|
||||
import com.ilummc.tlib.util.Strings;
|
||||
|
||||
@Immutable
|
||||
@SerializableAs("TEXT")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public class TLocaleText implements TLocaleSendable, ConfigurationSerializable {
|
||||
|
||||
private final Object text;
|
||||
|
||||
private final boolean usePlaceholder;
|
||||
|
||||
private TLocaleText(Object text, boolean usePlaceholder) {
|
||||
this.usePlaceholder = usePlaceholder;
|
||||
if (text instanceof String) {
|
||||
this.text = text;
|
||||
}
|
||||
else if (text instanceof List) {
|
||||
this.text = ImmutableList.copyOf(((List) text));
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Param 'text' can only be an instance of String or String[] or List<String>");
|
||||
}
|
||||
}
|
||||
|
||||
private String replaceMsg(CommandSender sender, String s) {
|
||||
return usePlaceholder ? PlaceholderHook.replace(sender, s) : s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTo(CommandSender sender, String... args) {
|
||||
if (text instanceof String) {
|
||||
sender.sendMessage(replaceMsg(sender, Strings.replaceWithOrder((String) text, args)));
|
||||
}
|
||||
else if (text instanceof List) {
|
||||
((List) text).forEach(s -> sender.sendMessage(replaceMsg(sender, Strings.replaceWithOrder(String.valueOf(s), args))));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString(String... args) {
|
||||
return Strings.replaceWithOrder((String) text, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (text instanceof String[]) {
|
||||
return Arrays.toString((String[]) text);
|
||||
} else {
|
||||
return text.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
if (usePlaceholder) {
|
||||
return Maps.newHashMap(ImmutableMap.of("text", text, "papi", true));
|
||||
}
|
||||
return Maps.newHashMap(ImmutableMap.of("text", text));
|
||||
}
|
||||
|
||||
public static TLocaleText valueOf(Map<String, Object> map) {
|
||||
if (map.containsKey("text")) {
|
||||
Object object = map.get("text");
|
||||
Object objPapi = map.getOrDefault("papi", TLib.getTLib().getConfig().isEnablePlaceholderHookByDefault());
|
||||
boolean papi = objPapi instanceof Boolean ? (boolean) objPapi : objPapi instanceof String && objPapi.equals("true");
|
||||
if (object instanceof List) {
|
||||
return new TLocaleText(((List<String>) object).stream()
|
||||
.map(s -> ChatColor.translateAlternateColorCodes('&', s))
|
||||
.collect(Collectors.toList()), papi);
|
||||
}
|
||||
else if (object instanceof String[]) {
|
||||
return new TLocaleText(Arrays.stream(((String[]) object))
|
||||
.map(s -> ChatColor.translateAlternateColorCodes('&', s))
|
||||
.collect(Collectors.toList()), papi);
|
||||
}
|
||||
else {
|
||||
return new TLocaleText(ChatColor.translateAlternateColorCodes('&', Objects.toString(object)), papi);
|
||||
}
|
||||
}
|
||||
return new TLocaleText("§cError chat message loaded.", TLib.getTLib().getConfig().isEnablePlaceholderHookByDefault());
|
||||
}
|
||||
|
||||
public static TLocaleText of(String s) {
|
||||
return new TLocaleText(ChatColor.translateAlternateColorCodes('&', s), TLib.getTLib().getConfig().isEnablePlaceholderHookByDefault());
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.ilummc.tlib.resources.type;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.ilummc.tlib.TLib;
|
||||
import com.ilummc.tlib.resources.TLocaleSendable;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.server.v1_11_R1.EntityEvoker.e;
|
||||
|
||||
/**
|
||||
* @author Bkm016
|
||||
* @since 2018-04-22
|
||||
*/
|
||||
|
||||
@Immutable
|
||||
@SerializableAs("TITLE")
|
||||
@Data
|
||||
public class TLocaleTitle implements TLocaleSendable, ConfigurationSerializable {
|
||||
|
||||
private String title;
|
||||
private String subtitle;
|
||||
private int fadein;
|
||||
private int fadeout;
|
||||
private int stay;
|
||||
|
||||
private boolean usePlaceholder;
|
||||
|
||||
private TLocaleTitle(boolean usePlaceholder) {
|
||||
this.usePlaceholder = usePlaceholder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTo(CommandSender sender, String... args) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString(String... args) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
HashMap<String, Object> map = Maps.newHashMap();
|
||||
map.put("papi", usePlaceholder);
|
||||
map.put("title", title);
|
||||
map.put("subtitle", subtitle);
|
||||
map.put("fadein", fadein);
|
||||
map.put("fadeout", fadeout);
|
||||
map.put("stay", stay);
|
||||
return map;
|
||||
}
|
||||
|
||||
public static TLocaleTitle valueOf(Map<String, Object> map) {
|
||||
TLocaleTitle title;
|
||||
try {
|
||||
title = new TLocaleTitle((boolean) map.getOrDefault("papi", TLib.getTLib().getConfig().isEnablePlaceholderHookByDefault()));
|
||||
title.setTitle((String) map.getOrDefault("title", ""));
|
||||
title.setSubtitle((String) map.getOrDefault("subtitle", ""));
|
||||
title.setFadein((int) map.getOrDefault("fadein", 10));
|
||||
title.setFadeout((int) map.getOrDefault("fadeout", 10));
|
||||
title.setStay((int) map.getOrDefault("stay", 10));
|
||||
} catch (Exception e) {
|
||||
title = new TLocaleTitle(false);
|
||||
title.setTitle("§4Load failed!");
|
||||
title.setSubtitle("§c" + e.getMessage());
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
}
|
@ -1,16 +1,24 @@
|
||||
package com.ilummc.tlib.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
|
||||
import com.ilummc.tlib.TLib;
|
||||
import com.ilummc.tlib.util.asm.AsmAnalyser;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import sun.reflect.Reflection;
|
||||
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import sun.reflect.Reflection;
|
||||
|
||||
@ThreadSafe
|
||||
public class Ref {
|
||||
@ -79,6 +87,8 @@ public class Ref {
|
||||
abstract Class<?> getCallerClass(int i);
|
||||
|
||||
private static class ReflectionImpl extends CallerClass {
|
||||
|
||||
@SuppressWarnings({ "deprecation", "restriction" })
|
||||
@Override
|
||||
Class<?> getCallerClass(int i) {
|
||||
return Reflection.getCallerClass(i);
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.ilummc.tlib.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TLogger {
|
||||
|
||||
@ -27,37 +29,37 @@ public class TLogger {
|
||||
|
||||
public void verbose(String msg) {
|
||||
if (level <= VERBOSE)
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§f全部", msg));
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§f全部", ChatColor.translateAlternateColorCodes('&', msg)));
|
||||
}
|
||||
|
||||
public void finest(String msg) {
|
||||
if (level <= FINEST)
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§e良好", msg));
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§e良好", ChatColor.translateAlternateColorCodes('&', msg)));
|
||||
}
|
||||
|
||||
public void fine(String msg) {
|
||||
if (level <= FINE)
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§a正常", msg));
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§a正常", ChatColor.translateAlternateColorCodes('&', msg)));
|
||||
}
|
||||
|
||||
public void info(String msg) {
|
||||
if (level <= INFO)
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§b信息", msg));
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§b信息", ChatColor.translateAlternateColorCodes('&', msg)));
|
||||
}
|
||||
|
||||
public void warn(String msg) {
|
||||
if (level <= WARN)
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§6警告", "§6" + msg));
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§6警告", "§6" + ChatColor.translateAlternateColorCodes('&', msg)));
|
||||
}
|
||||
|
||||
public void error(String msg) {
|
||||
if (level <= ERROR)
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§c错误", "§c" + msg));
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§c错误", "§c" + ChatColor.translateAlternateColorCodes('&', msg)));
|
||||
}
|
||||
|
||||
public void fatal(String msg) {
|
||||
if (level <= FATAL)
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§4致命错误", "§4" + msg));
|
||||
Bukkit.getConsoleSender().sendMessage(Strings.replaceWithOrder(pattern, plugin.getName(), "§4致命错误", "§4" + ChatColor.translateAlternateColorCodes('&', msg)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.ilummc.tlib.util.asm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AsmAnalyser extends ClassVisitor implements Opcodes {
|
||||
|
||||
private final List<String> fields = new ArrayList<>();
|
||||
|
@ -1,6 +1,17 @@
|
||||
package me.skymc.taboolib;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.ilummc.tlib.TLib;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.skymc.taboolib.anvil.AnvilContainerAPI;
|
||||
@ -8,6 +19,7 @@ import me.skymc.taboolib.bstats.Metrics;
|
||||
import me.skymc.taboolib.client.LogClient;
|
||||
import me.skymc.taboolib.commands.MainCommands;
|
||||
import me.skymc.taboolib.commands.language.Language2Command;
|
||||
import me.skymc.taboolib.commands.locale.TabooLibLocaleCommand;
|
||||
import me.skymc.taboolib.commands.sub.itemlist.listener.ItemLibraryPatch;
|
||||
import me.skymc.taboolib.commands.sub.sounds.listener.SoundsLibraryPatch;
|
||||
import me.skymc.taboolib.database.GlobalDataManager;
|
||||
@ -18,7 +30,11 @@ import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.inventory.speciaitem.SpecialItem;
|
||||
import me.skymc.taboolib.javashell.JavaShell;
|
||||
import me.skymc.taboolib.listener.*;
|
||||
import me.skymc.taboolib.listener.ListenerNetWork;
|
||||
import me.skymc.taboolib.listener.ListenerPlayerCommand;
|
||||
import me.skymc.taboolib.listener.ListenerPlayerJump;
|
||||
import me.skymc.taboolib.listener.ListenerPlayerQuit;
|
||||
import me.skymc.taboolib.listener.ListenerPluginDisable;
|
||||
import me.skymc.taboolib.message.ChatCatcher;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.mysql.protect.MySQLConnection;
|
||||
@ -38,15 +54,6 @@ import me.skymc.tlm.TLM;
|
||||
import me.skymc.tlm.command.TLMCommands;
|
||||
import me.skymc.tlm.module.TabooLibraryModule;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Main extends JavaPlugin implements Listener {
|
||||
@ -162,6 +169,7 @@ public class Main extends JavaPlugin implements Listener {
|
||||
getCommand("taboolib").setExecutor(new MainCommands());
|
||||
getCommand("language2").setExecutor(new Language2Command());
|
||||
getCommand("taboolibrarymodule").setExecutor(new TLMCommands());
|
||||
getCommand("tabooliblocale").setExecutor(new TabooLibLocaleCommand());
|
||||
|
||||
// 注册监听
|
||||
registerListener();
|
||||
|
@ -1,42 +1,35 @@
|
||||
package me.skymc.taboolib;
|
||||
|
||||
import me.skymc.taboolib.playerdata.DataUtils;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import me.skymc.taboolib.playerdata.DataUtils;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class TabooLib {
|
||||
|
||||
/**
|
||||
* 获取插件版本
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static void debug(Plugin plugin, String... args) {
|
||||
if (Main.getInst().getConfig().getBoolean("DEBUG")) {
|
||||
for (String var : args) {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_RED + "[TabooLib - DEBUG][" + plugin.getName() + "] " + ChatColor.RED + var);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static double getPluginVersion() {
|
||||
try {
|
||||
return Double.valueOf(Main.getInst().getDescription().getVersion());
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
return 0D;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 NMS 版本
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getVersion() {
|
||||
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器 UID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getServerUID() {
|
||||
if (!DataUtils.getPluginData("TabooLibrary", null).contains("serverUID")) {
|
||||
DataUtils.getPluginData("TabooLibrary", null).set("serverUID", UUID.randomUUID().toString());
|
||||
@ -44,53 +37,24 @@ public class TabooLib {
|
||||
return DataUtils.getPluginData("TabooLibrary", null).getString("serverUID");
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置服务器 UID
|
||||
*/
|
||||
public static void resetServerUID() {
|
||||
DataUtils.getPluginData("TabooLibrary", null).set("serverUID", UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 向后台发送 DEBUG 信息
|
||||
*
|
||||
* @param plugin
|
||||
* @param ss
|
||||
*/
|
||||
public static void debug(Plugin plugin, String... ss) {
|
||||
if (Main.getInst().getConfig().getBoolean("DEBUG")) {
|
||||
for (String s : ss) {
|
||||
// [00:42:41 INFO]: [TabooLib - DEBUG][TabooPlugin] Example bug message
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_RED + "[TabooLib - DEBUG][" + plugin.getName() + "] " + ChatColor.RED + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 NMS 版本(数字)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static int getVerint() {
|
||||
if (getVersion().startsWith("v1_7")) {
|
||||
return 10700;
|
||||
}
|
||||
else if (getVersion().startsWith("v1_8")) {
|
||||
} else if (getVersion().startsWith("v1_8")) {
|
||||
return 10800;
|
||||
}
|
||||
else if (getVersion().startsWith("v1_9")) {
|
||||
} else if (getVersion().startsWith("v1_9")) {
|
||||
return 10900;
|
||||
}
|
||||
else if (getVersion().startsWith("v1_10")) {
|
||||
} else if (getVersion().startsWith("v1_10")) {
|
||||
return 11000;
|
||||
}
|
||||
else if (getVersion().startsWith("v1_11")) {
|
||||
} else if (getVersion().startsWith("v1_11")) {
|
||||
return 11100;
|
||||
}
|
||||
else if (getVersion().startsWith("v1_12")) {
|
||||
} else if (getVersion().startsWith("v1_12")) {
|
||||
return 11200;
|
||||
}
|
||||
else if (getVersion().startsWith("v1_13")) {
|
||||
} else if (getVersion().startsWith("v1_13")) {
|
||||
return 11300;
|
||||
}
|
||||
return 0;
|
||||
|
@ -1,6 +1,9 @@
|
||||
package me.skymc.taboolib.anvil;
|
||||
|
||||
import me.skymc.taboolib.anvil.versions.AnvilContainer_V1_9_4;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -15,9 +18,7 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import me.skymc.taboolib.anvil.versions.AnvilContainer_V1_9_4;
|
||||
|
||||
public class AnvilContainerAPI implements Listener{
|
||||
|
||||
|
@ -1,9 +1,15 @@
|
||||
package me.skymc.taboolib.anvil.versions;
|
||||
|
||||
import net.minecraft.server.v1_11_R1.*;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.minecraft.server.v1_11_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_11_R1.ChatMessage;
|
||||
import net.minecraft.server.v1_11_R1.ContainerAnvil;
|
||||
import net.minecraft.server.v1_11_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_11_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutOpenWindow;
|
||||
|
||||
public class AnvilContainer_V1_11_R1 extends ContainerAnvil {
|
||||
|
||||
public AnvilContainer_V1_11_R1(EntityHuman player)
|
||||
|
@ -1,9 +1,15 @@
|
||||
package me.skymc.taboolib.anvil.versions;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R3.ChatMessage;
|
||||
import net.minecraft.server.v1_8_R3.ContainerAnvil;
|
||||
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow;
|
||||
|
||||
public class AnvilContainer_V1_8_R3 extends ContainerAnvil {
|
||||
|
||||
public AnvilContainer_V1_8_R3(EntityHuman player)
|
||||
|
@ -1,9 +1,15 @@
|
||||
package me.skymc.taboolib.anvil.versions;
|
||||
|
||||
import net.minecraft.server.v1_9_R2.*;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.minecraft.server.v1_9_R2.BlockPosition;
|
||||
import net.minecraft.server.v1_9_R2.ChatMessage;
|
||||
import net.minecraft.server.v1_9_R2.ContainerAnvil;
|
||||
import net.minecraft.server.v1_9_R2.EntityHuman;
|
||||
import net.minecraft.server.v1_9_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_9_R2.PacketPlayOutOpenWindow;
|
||||
|
||||
public class AnvilContainer_V1_9_4 extends ContainerAnvil {
|
||||
|
||||
public AnvilContainer_V1_9_4(EntityHuman player)
|
||||
|
@ -1,10 +1,43 @@
|
||||
package me.skymc.taboolib.bookformatter;
|
||||
|
||||
import org.bukkit.Achievement;
|
||||
import static org.bukkit.Achievement.ACQUIRE_IRON;
|
||||
import static org.bukkit.Achievement.BAKE_CAKE;
|
||||
import static org.bukkit.Achievement.BOOKCASE;
|
||||
import static org.bukkit.Achievement.BREED_COW;
|
||||
import static org.bukkit.Achievement.BREW_POTION;
|
||||
import static org.bukkit.Achievement.BUILD_BETTER_PICKAXE;
|
||||
import static org.bukkit.Achievement.BUILD_FURNACE;
|
||||
import static org.bukkit.Achievement.BUILD_HOE;
|
||||
import static org.bukkit.Achievement.BUILD_PICKAXE;
|
||||
import static org.bukkit.Achievement.BUILD_SWORD;
|
||||
import static org.bukkit.Achievement.BUILD_WORKBENCH;
|
||||
import static org.bukkit.Achievement.COOK_FISH;
|
||||
import static org.bukkit.Achievement.DIAMONDS_TO_YOU;
|
||||
import static org.bukkit.Achievement.ENCHANTMENTS;
|
||||
import static org.bukkit.Achievement.END_PORTAL;
|
||||
import static org.bukkit.Achievement.EXPLORE_ALL_BIOMES;
|
||||
import static org.bukkit.Achievement.FLY_PIG;
|
||||
import static org.bukkit.Achievement.FULL_BEACON;
|
||||
import static org.bukkit.Achievement.GET_BLAZE_ROD;
|
||||
import static org.bukkit.Achievement.GET_DIAMONDS;
|
||||
import static org.bukkit.Achievement.GHAST_RETURN;
|
||||
import static org.bukkit.Achievement.KILL_COW;
|
||||
import static org.bukkit.Achievement.KILL_ENEMY;
|
||||
import static org.bukkit.Achievement.KILL_WITHER;
|
||||
import static org.bukkit.Achievement.MAKE_BREAD;
|
||||
import static org.bukkit.Achievement.MINE_WOOD;
|
||||
import static org.bukkit.Achievement.NETHER_PORTAL;
|
||||
import static org.bukkit.Achievement.ON_A_RAIL;
|
||||
import static org.bukkit.Achievement.OPEN_INVENTORY;
|
||||
import static org.bukkit.Achievement.OVERKILL;
|
||||
import static org.bukkit.Achievement.OVERPOWERED;
|
||||
import static org.bukkit.Achievement.SNIPE_SKELETON;
|
||||
import static org.bukkit.Achievement.SPAWN_WITHER;
|
||||
import static org.bukkit.Achievement.THE_END;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.bukkit.Achievement.*;
|
||||
import org.bukkit.Achievement;
|
||||
|
||||
public final class BookAchievement {
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
package me.skymc.taboolib.bookformatter;
|
||||
|
||||
import me.skymc.taboolib.bookformatter.builder.BookBuilder;
|
||||
import me.skymc.taboolib.events.CustomBookOpenEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.bookformatter.builder.BookBuilder;
|
||||
import me.skymc.taboolib.events.CustomBookOpenEvent;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public final class BookFormatter {
|
||||
|
||||
|
@ -1,14 +1,5 @@
|
||||
package me.skymc.taboolib.bookformatter;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -17,6 +8,16 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
|
||||
/**
|
||||
* The NMS helper for all the Book-API
|
||||
*/
|
||||
|
@ -1,5 +1,25 @@
|
||||
package me.skymc.taboolib.bstats;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -9,19 +29,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* bStats collects some data for plugin authors.
|
||||
*
|
||||
|
@ -1,15 +1,30 @@
|
||||
package me.skymc.taboolib.commands;
|
||||
|
||||
import me.skymc.taboolib.commands.sub.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import me.skymc.taboolib.commands.sub.AttributesCommand;
|
||||
import me.skymc.taboolib.commands.sub.EnchantCommand;
|
||||
import me.skymc.taboolib.commands.sub.FlagCommand;
|
||||
import me.skymc.taboolib.commands.sub.HelpCommand;
|
||||
import me.skymc.taboolib.commands.sub.ImportCommand;
|
||||
import me.skymc.taboolib.commands.sub.InfoCommand;
|
||||
import me.skymc.taboolib.commands.sub.ItemCommand;
|
||||
import me.skymc.taboolib.commands.sub.PotionCommand;
|
||||
import me.skymc.taboolib.commands.sub.SaveCommand;
|
||||
import me.skymc.taboolib.commands.sub.SlotCommand;
|
||||
import me.skymc.taboolib.commands.sub.TagDeleteCommand;
|
||||
import me.skymc.taboolib.commands.sub.TagPrefixCommand;
|
||||
import me.skymc.taboolib.commands.sub.TagSuffixCommand;
|
||||
import me.skymc.taboolib.commands.sub.VariableGetCommand;
|
||||
import me.skymc.taboolib.commands.sub.VariableSetCommand;
|
||||
import me.skymc.taboolib.commands.sub.cycle.CycleCommand;
|
||||
import me.skymc.taboolib.commands.sub.itemlist.ItemListCommand;
|
||||
import me.skymc.taboolib.commands.sub.shell.ShellCommand;
|
||||
import me.skymc.taboolib.commands.sub.sounds.SoundsCommand;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class MainCommands implements CommandExecutor{
|
||||
|
||||
|
@ -0,0 +1,75 @@
|
||||
package me.skymc.taboolib.commands.locale;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018-04-22 14:36:28
|
||||
*/
|
||||
public class TabooLibLocaleCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command arg1, String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
TLocale.sendTo(sender, "commands-taboolocale-helps", label);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("send")) {
|
||||
send(sender, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("reload")) {
|
||||
reload(sender);
|
||||
}
|
||||
else {
|
||||
TLocale.sendTo(sender, "commands-taboolocale-invalid");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void send(CommandSender sender, String[] args) {
|
||||
if (args.length < 3) {
|
||||
TLocale.sendTo(sender, "commands-taboolocale-send-empty");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Player> target = new ArrayList<>();
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
target.addAll(Bukkit.getOnlinePlayers());
|
||||
} else {
|
||||
Player player = Bukkit.getPlayerExact(args[1]);
|
||||
if (player == null) {
|
||||
TLocale.sendTo(sender, "commands-taboolocale-send-offline", args[1]);
|
||||
return;
|
||||
}
|
||||
target.add(player);
|
||||
}
|
||||
|
||||
if (args.length > 3) {
|
||||
String[] vars = new String[args.length - 3];
|
||||
for (int i = 3 ; i < args.length ; i++) {
|
||||
vars[i - 3] = args[i];
|
||||
}
|
||||
target.forEach(x -> TLocale.sendTo(x, args[2], vars));
|
||||
} else {
|
||||
target.forEach(x -> TLocale.sendTo(x, args[2]));
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
TLocale.sendTo(sender, "commands-taboolocale-send-success");
|
||||
}
|
||||
}
|
||||
|
||||
void reload(CommandSender sender) {
|
||||
TLocale.reload();
|
||||
TLocale.sendTo(sender, "commands-taboolocale-reload");
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.jsonformatter.JSONFormatter;
|
||||
import me.skymc.taboolib.jsonformatter.click.SuggestCommandEvent;
|
||||
import me.skymc.taboolib.jsonformatter.hover.ShowTextEvent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AttributesCommand extends SubCommand {
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.jsonformatter.JSONFormatter;
|
||||
import me.skymc.taboolib.jsonformatter.click.SuggestCommandEvent;
|
||||
import me.skymc.taboolib.jsonformatter.hover.ShowTextEvent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class HelpCommand extends SubCommand {
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.itemnbtapi.NBTItem;
|
||||
@ -8,9 +12,6 @@ import me.skymc.taboolib.jsonformatter.click.SuggestCommandEvent;
|
||||
import me.skymc.taboolib.jsonformatter.hover.ShowItemEvent;
|
||||
import me.skymc.taboolib.jsonformatter.hover.ShowTextEvent;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InfoCommand extends SubCommand {
|
||||
|
||||
|
@ -11,8 +11,8 @@ import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.message.ChatCatcher;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.message.ChatCatcher.Catcher;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.playerdata.DataUtils;
|
||||
|
||||
public class SaveCommand extends SubCommand {
|
||||
|
@ -1,11 +1,12 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.jsonformatter.JSONFormatter;
|
||||
import me.skymc.taboolib.jsonformatter.click.SuggestCommandEvent;
|
||||
import me.skymc.taboolib.jsonformatter.hover.ShowTextEvent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SlotCommand extends SubCommand {
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.team.TagManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
|
@ -1,8 +1,9 @@
|
||||
package me.skymc.taboolib.commands.sub.cycle;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CycleCommand extends SubCommand {
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
package me.skymc.taboolib.commands.sub.cycle;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.other.DateUtils;
|
||||
import me.skymc.taboolib.timecycle.TimeCycle;
|
||||
import me.skymc.taboolib.timecycle.TimeCycleManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CycleInfoCommand extends SubCommand {
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
package me.skymc.taboolib.commands.sub.cycle;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.jsonformatter.JSONFormatter;
|
||||
import me.skymc.taboolib.jsonformatter.click.SuggestCommandEvent;
|
||||
import me.skymc.taboolib.jsonformatter.hover.ShowTextEvent;
|
||||
import me.skymc.taboolib.timecycle.TimeCycle;
|
||||
import me.skymc.taboolib.timecycle.TimeCycleManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CycleListCommand extends SubCommand {
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
package me.skymc.taboolib.commands.sub.cycle;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.database.GlobalDataManager;
|
||||
@ -7,9 +11,6 @@ import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.timecycle.TimeCycle;
|
||||
import me.skymc.taboolib.timecycle.TimeCycleEvent;
|
||||
import me.skymc.taboolib.timecycle.TimeCycleManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class CycleUpdateCommand extends SubCommand {
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
package me.skymc.taboolib.commands.sub.itemlist.listener;
|
||||
|
||||
import me.skymc.taboolib.inventory.InventoryUtil;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -13,10 +16,8 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import me.skymc.taboolib.inventory.InventoryUtil;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
|
@ -1,8 +1,9 @@
|
||||
package me.skymc.taboolib.commands.sub.shell;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class ShellCommand extends SubCommand {
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
package me.skymc.taboolib.commands.sub.sounds.listener;
|
||||
|
||||
import me.skymc.taboolib.inventory.InventoryUtil;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -14,8 +15,8 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import me.skymc.taboolib.inventory.InventoryUtil;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
|
@ -1,13 +1,14 @@
|
||||
package me.skymc.taboolib.cooldown;
|
||||
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
@Deprecated
|
||||
public class CooldownUtils implements Listener {
|
||||
|
@ -1,13 +1,13 @@
|
||||
package me.skymc.taboolib.cooldown.seconds;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class CooldownUtils2 implements Listener {
|
||||
|
||||
private static ConcurrentHashMap<String, CooldownPack2> packlist = new ConcurrentHashMap<>();
|
||||
|
@ -1,6 +1,14 @@
|
||||
package me.skymc.taboolib.csvutils;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.HashMap;
|
||||
|
@ -1,6 +1,11 @@
|
||||
package me.skymc.taboolib.csvutils;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class CsvWriter
|
||||
|
@ -1,11 +1,12 @@
|
||||
package me.skymc.taboolib.damage;
|
||||
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
|
||||
public class DamageUtils {
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
package me.skymc.taboolib.database;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.Main.StorageType;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.playerdata.DataUtils;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class GlobalDataManager {
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
package me.skymc.taboolib.database;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.Main.StorageType;
|
||||
import me.skymc.taboolib.events.PlayerLoadedEvent;
|
||||
import me.skymc.taboolib.exception.PlayerOfflineException;
|
||||
import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
import me.skymc.taboolib.fileutils.FileUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -18,9 +15,13 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.Main.StorageType;
|
||||
import me.skymc.taboolib.events.PlayerLoadedEvent;
|
||||
import me.skymc.taboolib.exception.PlayerOfflineException;
|
||||
import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
import me.skymc.taboolib.fileutils.FileUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
public class PlayerDataManager implements Listener {
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
package me.skymc.taboolib.display;
|
||||
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
|
||||
public class ActionUtils {
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package me.skymc.taboolib.display;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TitleUtils {
|
||||
|
||||
private static void sendPacket(Player player, Object packet)
|
||||
|
@ -1,13 +1,14 @@
|
||||
package me.skymc.taboolib.entity;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
|
||||
/**
|
||||
* 伪 - MetaData
|
||||
*
|
||||
|
@ -1,13 +1,14 @@
|
||||
package me.skymc.taboolib.events;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* The event called when a book is opened trough this Util
|
||||
*/
|
||||
|
@ -1,8 +1,9 @@
|
||||
package me.skymc.taboolib.events;
|
||||
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
public class DefaultEvent2 extends PlayerEvent
|
||||
{
|
||||
|
@ -1,13 +1,21 @@
|
||||
package me.skymc.taboolib.fileutils;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringReader;
|
||||
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import java.io.*;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.ilummc.tlib.TLib;
|
||||
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
public class ConfigUtils {
|
||||
|
||||
@ -43,12 +51,13 @@ public class ConfigUtils {
|
||||
*/
|
||||
public static FileConfiguration load(Plugin plugin, File file) {
|
||||
YamlConfiguration yaml = new YamlConfiguration();
|
||||
|
||||
try {
|
||||
yaml = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8));
|
||||
} catch (FileNotFoundException e) {
|
||||
MsgUtils.warn("配置文件载入失败!");
|
||||
MsgUtils.warn("插件: &4" + plugin.getName());
|
||||
MsgUtils.warn("文件: &4" + file.getName());
|
||||
} catch (Exception e) {
|
||||
TLib.getTLib().getLogger().error("配置文件载入失败!");
|
||||
TLib.getTLib().getLogger().error("插件: &4" + plugin.getName());
|
||||
TLib.getTLib().getLogger().error("文件: &4" + file);
|
||||
}
|
||||
return yaml;
|
||||
}
|
||||
|
@ -1,6 +1,13 @@
|
||||
package me.skymc.taboolib.fileutils;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
|
||||
|
@ -1,13 +1,22 @@
|
||||
package me.skymc.taboolib.fileutils;
|
||||
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
||||
import ch.njol.util.Closeable;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
public static String ip() {
|
||||
@ -282,13 +291,7 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取字节
|
||||
*
|
||||
* @param in
|
||||
* @return
|
||||
*/
|
||||
private static byte[] read(InputStream in) {
|
||||
public static byte[] read(InputStream in) {
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = 0;
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
@ -296,11 +299,18 @@ public class FileUtils {
|
||||
while((len = in.read(buffer)) != -1) {
|
||||
bos.write(buffer, 0, len);
|
||||
}
|
||||
bos.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
catch (Exception ignored) {
|
||||
}
|
||||
return bos.toByteArray();
|
||||
}
|
||||
|
||||
public static void close(Closeable closeable) {
|
||||
try {
|
||||
if (closeable != null) {
|
||||
closeable.close();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
package me.skymc.taboolib.fileutils;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.other.DateUtils;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.other.DateUtils;
|
||||
|
||||
@Deprecated
|
||||
public class LogUtils {
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
package me.skymc.taboolib.inventory;
|
||||
|
||||
import me.skymc.taboolib.other.NumberUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import me.skymc.taboolib.other.NumberUtils;
|
||||
|
||||
public class DropUtils {
|
||||
|
||||
public static Item drop(Player player, ItemStack itemStack, double bulletSpread, double radius) {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package me.skymc.taboolib.inventory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class InventoryUtil {
|
||||
|
||||
public final static LinkedList<Integer> SLOT_OF_CENTENTS = new LinkedList<>(Arrays.asList(
|
||||
|
@ -1,17 +1,10 @@
|
||||
package me.skymc.taboolib.inventory;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
import me.skymc.taboolib.itemnbtapi.NBTItem;
|
||||
import me.skymc.taboolib.itemnbtapi.NBTList;
|
||||
import me.skymc.taboolib.itemnbtapi.NBTListCompound;
|
||||
import me.skymc.taboolib.itemnbtapi.NBTType;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.other.NumberUtils;
|
||||
import me.skymc.taboolib.string.Language;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -28,10 +21,18 @@ import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
import me.skymc.taboolib.itemnbtapi.NBTItem;
|
||||
import me.skymc.taboolib.itemnbtapi.NBTList;
|
||||
import me.skymc.taboolib.itemnbtapi.NBTListCompound;
|
||||
import me.skymc.taboolib.itemnbtapi.NBTType;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.other.NumberUtils;
|
||||
import me.skymc.taboolib.string.Language;
|
||||
|
||||
public class ItemUtils {
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
package me.skymc.taboolib.inventory.speciaitem;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -13,8 +12,10 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import lombok.Getter;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
|
@ -1,14 +1,5 @@
|
||||
package me.skymc.taboolib.itemnbtapi;
|
||||
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.itemnbtapi.utils.GsonWrapper;
|
||||
import me.skymc.taboolib.itemnbtapi.utils.MethodNames;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
@ -17,6 +8,16 @@ import java.lang.reflect.Method;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.itemnbtapi.utils.GsonWrapper;
|
||||
import me.skymc.taboolib.itemnbtapi.utils.MethodNames;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
// TODO: finish codestyle cleanup -sgdc3
|
||||
public class NBTReflectionUtil {
|
||||
|
||||
|
@ -1,14 +1,15 @@
|
||||
package me.skymc.taboolib.javascript;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
|
||||
public class JavaScriptUtils {
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
package me.skymc.taboolib.javashell;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.javashell.utils.JarUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -12,11 +13,11 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.HashMap;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.javashell.utils.JarUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
public class JavaShell {
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
package me.skymc.taboolib.javashell.utils;
|
||||
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
@ -12,6 +15,10 @@ import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
public class JarUtils {
|
||||
|
||||
public static boolean extractFromJar(final String fileName, final String dest) throws IOException {
|
||||
|
@ -6,7 +6,13 @@ import java.io.Writer;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public class JSONObject {
|
||||
|
@ -1,7 +1,12 @@
|
||||
package me.skymc.taboolib.json;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
|
||||
public class JSONTokener {
|
||||
|
||||
|
@ -1,20 +1,21 @@
|
||||
package me.skymc.taboolib.jsonformatter;
|
||||
|
||||
import me.skymc.taboolib.json.JSONArray;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
import me.skymc.taboolib.jsonformatter.click.ClickEvent;
|
||||
import me.skymc.taboolib.jsonformatter.hover.HoverEvent;
|
||||
import me.skymc.taboolib.nms.NMSUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.json.JSONArray;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
import me.skymc.taboolib.jsonformatter.click.ClickEvent;
|
||||
import me.skymc.taboolib.jsonformatter.hover.HoverEvent;
|
||||
import me.skymc.taboolib.nms.NMSUtils;
|
||||
|
||||
public class JSONFormatter {
|
||||
|
||||
private JSONArray ja = new JSONArray();
|
||||
|
@ -1,18 +1,19 @@
|
||||
package me.skymc.taboolib.jsonformatter.hover;
|
||||
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
import me.skymc.taboolib.nms.item.DabItemUtils;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
import me.skymc.taboolib.nms.item.DabItemUtils;
|
||||
|
||||
public class ShowItemEvent extends HoverEvent{
|
||||
|
||||
private JSONObject object = new JSONObject();
|
||||
|
@ -1,5 +1,11 @@
|
||||
package me.skymc.taboolib.listener;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.database.PlayerDataManager;
|
||||
@ -7,11 +13,6 @@ import me.skymc.taboolib.itemnbtapi.NBTItem;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.permission.PermissionUtils;
|
||||
import me.skymc.taboolib.playerdata.DataUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
public class ListenerPlayerCommand implements Listener {
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.skymc.taboolib.listener;
|
||||
|
||||
import me.skymc.taboolib.events.PlayerJumpEvent;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -12,7 +13,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import me.skymc.taboolib.events.PlayerJumpEvent;
|
||||
|
||||
public class ListenerPlayerJump
|
||||
implements Listener
|
||||
|
@ -1,11 +1,12 @@
|
||||
package me.skymc.taboolib.listener;
|
||||
|
||||
import me.skymc.taboolib.playerdata.DataUtils;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import me.skymc.taboolib.playerdata.DataUtils;
|
||||
|
||||
public class ListenerPlayerQuit implements Listener{
|
||||
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
|
@ -1,17 +1,18 @@
|
||||
package me.skymc.taboolib.listener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.mysql.MysqlUtils;
|
||||
import me.skymc.taboolib.mysql.protect.MySQLConnection;
|
||||
import me.skymc.taboolib.timecycle.TimeCycleManager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ListenerPluginDisable implements Listener {
|
||||
|
||||
|
@ -1,14 +1,15 @@
|
||||
package me.skymc.taboolib.message;
|
||||
|
||||
import lombok.Getter;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import lombok.Getter;
|
||||
|
||||
public class ChatCatcher implements Listener {
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
package me.skymc.taboolib.methods;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -9,6 +7,8 @@ import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
/**
|
||||
* <b>ReflectionUtils</b>
|
||||
* <p>
|
||||
|
@ -1,6 +1,10 @@
|
||||
package me.skymc.taboolib.mysql;
|
||||
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
package me.skymc.taboolib.mysql;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.mysql.protect.MySQLConnection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class MysqlUtils {
|
||||
|
||||
|
@ -1,16 +1,21 @@
|
||||
package me.skymc.taboolib.mysql.protect;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.skymc.taboolib.Main;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.skymc.taboolib.Main;
|
||||
|
||||
public class MySQLConnection {
|
||||
|
||||
@Getter
|
||||
|
@ -1,16 +1,5 @@
|
||||
package me.skymc.taboolib.nms;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
@ -20,6 +9,21 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Deprecated
|
||||
public class NMSUtil18 {
|
||||
|
@ -1,7 +1,24 @@
|
||||
package me.skymc.taboolib.nms;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
@ -15,13 +32,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Deprecated
|
||||
public class NMSUtil19 {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package me.skymc.taboolib.nms;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class NMSUtils {
|
||||
|
||||
public static String getVersion(){
|
||||
|
@ -1,5 +1,15 @@
|
||||
package me.skymc.taboolib.nms.item;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.json.JSONArray;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
@ -7,15 +17,6 @@ import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.nms.item.impl._164ItemUtils;
|
||||
import me.skymc.taboolib.nms.item.impl._1710ItemUtils;
|
||||
import me.skymc.taboolib.nms.item.impl._194ItemUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DabItemUtils {
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
package me.skymc.taboolib.nms.item;
|
||||
|
||||
import me.skymc.taboolib.json.JSONArray;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.json.JSONArray;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
|
||||
public interface IDabItemUtils{
|
||||
|
||||
//@formatter:off
|
||||
|
@ -1,19 +1,27 @@
|
||||
package me.skymc.taboolib.nms.item.impl;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.json.JSONArray;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
import me.skymc.taboolib.nms.NMSUtils;
|
||||
import me.skymc.taboolib.nms.item.IDabItemUtils;
|
||||
import me.skymc.taboolib.nms.nbt.NBTConstants;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class _164ItemUtils implements IDabItemUtils{
|
||||
|
||||
|
@ -1,19 +1,27 @@
|
||||
package me.skymc.taboolib.nms.item.impl;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.json.JSONArray;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
import me.skymc.taboolib.nms.NMSUtils;
|
||||
import me.skymc.taboolib.nms.item.IDabItemUtils;
|
||||
import me.skymc.taboolib.nms.nbt.NBTConstants;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class _1710ItemUtils implements IDabItemUtils{
|
||||
|
||||
|
@ -1,19 +1,26 @@
|
||||
package me.skymc.taboolib.nms.item.impl;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.json.JSONArray;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
import me.skymc.taboolib.nms.NMSUtils;
|
||||
import me.skymc.taboolib.nms.item.IDabItemUtils;
|
||||
import me.skymc.taboolib.nms.nbt.NBTConstants;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class _194ItemUtils implements IDabItemUtils{
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package me.skymc.taboolib.other;
|
||||
|
||||
import me.skymc.taboolib.object.WeightCategory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.skymc.taboolib.object.WeightCategory;
|
||||
|
||||
public class WeightUtils {
|
||||
|
||||
public static String getStringByWeight(List<WeightCategory> categorys) {
|
||||
|
@ -1,11 +1,12 @@
|
||||
package me.skymc.taboolib.packet;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PacketUtils {
|
||||
|
||||
|
@ -1,14 +1,5 @@
|
||||
package me.skymc.taboolib.particle;
|
||||
|
||||
import me.skymc.taboolib.methods.ReflectionUtils;
|
||||
import me.skymc.taboolib.methods.ReflectionUtils.PackageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@ -18,6 +9,16 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import me.skymc.taboolib.methods.ReflectionUtils;
|
||||
import me.skymc.taboolib.methods.ReflectionUtils.PackageType;
|
||||
|
||||
/**
|
||||
* <b>ParticleEffect Library</b>
|
||||
* <p>
|
||||
|
@ -1,9 +1,10 @@
|
||||
package me.skymc.taboolib.permission;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class PermissionUtils {
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.skymc.taboolib.playerdata;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.database.PlayerDataManager;
|
||||
import me.skymc.taboolib.exception.PlayerOfflineException;
|
||||
import me.skymc.taboolib.fileutils.FileUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -14,10 +14,11 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.database.PlayerDataManager;
|
||||
import me.skymc.taboolib.exception.PlayerOfflineException;
|
||||
import me.skymc.taboolib.fileutils.FileUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
public class DataUtils implements Listener {
|
||||
|
||||
|
@ -1,23 +1,34 @@
|
||||
package me.skymc.taboolib.plugin;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import me.skymc.taboolib.Main;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.SortedSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.SimpleCommandMap;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.plugin.*;
|
||||
import org.bukkit.plugin.InvalidDescriptionException;
|
||||
import org.bukkit.plugin.InvalidPluginException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
|
||||
public class PluginUtils
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user