TabooLib v4.55

+ 对插件本体进行大面积整改,将一些过失或不再更新的工具类转移至 TabooLibDeprecated.jar 中。
+ 对 SimpleCommandBuilder 进行了微调,动态注册后的命令前缀将显示为注册插件。
+ 对 SimpleVersionControl 进行了微调,允许在 translate 类中选择所属插件。
+ 对 ItemBuilder 进行了微调,允许使用 ItemStack 作为构造参数。
+ ...
This commit is contained in:
坏黑
2018-10-13 21:36:49 +08:00
parent 64aba798c3
commit d793444dd5
134 changed files with 129 additions and 21103 deletions

View File

@@ -1,18 +0,0 @@
package me.skymc.taboolib.object;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @Author sky
* @Since 2018-08-27 10:04
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Instantiable {
String value();
}

View File

@@ -1,82 +0,0 @@
package me.skymc.taboolib.object;
import com.ilummc.tlib.util.Ref;
import me.skymc.taboolib.TabooLibLoader;
import me.skymc.taboolib.listener.TListener;
import me.skymc.taboolib.methods.ReflectionUtils;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
/**
* @Author sky
* @Since 2018-08-27 10:04
*/
@TListener
public class InstantiableLoader implements Listener {
private static ConcurrentHashMap<String, Object> instance = new ConcurrentHashMap<>();
public InstantiableLoader() {
loadInstantiable();
}
@EventHandler
public void onEnable(PluginEnableEvent e) {
loadInstantiable(e.getPlugin());
}
@EventHandler
public void onDisable(PluginDisableEvent e) {
clear(e.getPlugin());
}
public static void clear(Plugin plugin) {
instance.entrySet().stream().filter(entry -> Ref.getCallerPlugin(entry.getValue().getClass()).equals(plugin)).forEach(entry -> instance.remove(entry.getKey()));
}
public static void loadInstantiable() {
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
try {
loadInstantiable(plugin);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void loadInstantiable(Plugin plugin) {
TabooLibLoader.getPluginClasses(plugin).ifPresent(classes -> {
for (Class pluginClass : classes) {
if (pluginClass.isAnnotationPresent(Instantiable.class)) {
Instantiable instantiable = (Instantiable) pluginClass.getAnnotation(Instantiable.class);
try {
instance.put(instantiable.value(), ReflectionUtils.instantiateObject(pluginClass));
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
}
// *********************************
//
// Getter and Setter
//
// *********************************
public static ConcurrentHashMap<String, Object> getInstance() {
return instance;
}
public static Optional<Object> getInstance(String name) {
return Optional.ofNullable(instance.get(name));
}
}

View File

@@ -1,34 +0,0 @@
package me.skymc.taboolib.object;
@Deprecated
public class WeightCategory {
private String category;
private Integer weight;
public WeightCategory() {
super();
}
public WeightCategory(String category, Integer weight) {
super();
this.setCategory(category);
this.setWeight(weight);
}
public Integer getWeight() {
return weight;
}
public void setWeight(Integer weight) {
this.weight = weight;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
}