update 5.03 beta 23
This commit is contained in:
parent
a102bcaf7f
commit
b6c154e914
@ -1,6 +1,5 @@
|
||||
package io.izzel.taboolib.common.plugin;
|
||||
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import io.izzel.taboolib.module.lite.SimpleVersionControl;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -52,8 +51,6 @@ public abstract class InternalPluginBridge {
|
||||
|
||||
abstract public boolean permissionHas(Player player, String perm);
|
||||
|
||||
abstract public RegionManager worldguardRegionManager(World world);
|
||||
|
||||
abstract public Collection<String> worldguardGetRegions(World world);
|
||||
|
||||
abstract public List<String> worldguardGetRegion(World world, Location location);
|
||||
|
@ -128,20 +128,6 @@ public class BridgeImpl extends InternalPluginBridge {
|
||||
return worldguardRegionManager(world).getRegions().values().stream().filter(r -> r.contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())).map(ProtectedRegion::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionManager worldguardRegionManager(World world) {
|
||||
if (WorldGuardPlugin.inst().getDescription().getVersion().startsWith("7")) {
|
||||
return WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world));
|
||||
} else {
|
||||
try {
|
||||
return (RegionManager) getRegionManager.invoke(WorldGuardPlugin.inst(), world);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean economyHooked() {
|
||||
return economy != null;
|
||||
@ -237,4 +223,17 @@ public class BridgeImpl extends InternalPluginBridge {
|
||||
public Class getClass(String name) throws ClassNotFoundException {
|
||||
return Class.forName(name);
|
||||
}
|
||||
|
||||
private RegionManager worldguardRegionManager(World world) {
|
||||
if (WorldGuardPlugin.inst().getDescription().getVersion().startsWith("7")) {
|
||||
return WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world));
|
||||
} else {
|
||||
try {
|
||||
return (RegionManager) getRegionManager.invoke(WorldGuardPlugin.inst(), world);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +1,18 @@
|
||||
package io.izzel.taboolib.module.ai;
|
||||
|
||||
import io.izzel.taboolib.module.inject.TFunction;
|
||||
import io.izzel.taboolib.module.lite.SimpleVersionControl;
|
||||
import io.izzel.taboolib.module.inject.TInject;
|
||||
|
||||
/**
|
||||
* @Author sky
|
||||
* @Since 2018-09-19 20:31
|
||||
*/
|
||||
@TFunction(enable = "init")
|
||||
public class SimpleAiSelector {
|
||||
|
||||
@TInject(asm = "io.izzel.taboolib.module.ai.internal.InternalPathfinderCreator")
|
||||
private static PathfinderCreator internalPathfinderCreator;
|
||||
@TInject(asm = "io.izzel.taboolib.module.ai.internal.InternalPathfinderExecutor")
|
||||
private static PathfinderExecutor internalPathfinderExecutor;
|
||||
|
||||
static void init() {
|
||||
try {
|
||||
internalPathfinderCreator = (PathfinderCreator) SimpleVersionControl.createNMS("io.izzel.taboolib.module.ai.internal.InternalPathfinderCreator").translate().newInstance();
|
||||
internalPathfinderExecutor = (PathfinderExecutor) SimpleVersionControl.createNMS("io.izzel.taboolib.module.ai.internal.InternalPathfinderExecutor").translate().newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// *********************************
|
||||
//
|
||||
// Getter and Setter
|
||||
//
|
||||
// *********************************
|
||||
|
||||
public static PathfinderExecutor getExecutor() {
|
||||
return internalPathfinderExecutor;
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
package io.izzel.taboolib.module.inject;
|
||||
|
||||
import io.izzel.taboolib.TabooLibLoader;
|
||||
import io.izzel.taboolib.module.lite.SimpleVersionControl;
|
||||
import io.izzel.taboolib.module.locale.logger.TLogger;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
* @Author sky
|
||||
* @Since 2019-08-18 0:47
|
||||
*/
|
||||
public class TInjectAsm implements TabooLibLoader.Loader {
|
||||
|
||||
@Override
|
||||
public void postLoad(Plugin plugin, Class<?> pluginClass) {
|
||||
for (Field declaredField : pluginClass.getDeclaredFields()) {
|
||||
TInject annotation = declaredField.getAnnotation(TInject.class);
|
||||
if (annotation == null || annotation.asm().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
Object instance = null;
|
||||
// 如果是非静态类型
|
||||
if (!Modifier.isStatic(declaredField.getModifiers())) {
|
||||
// 是否为主类
|
||||
if (pluginClass.equals(plugin.getClass())) {
|
||||
instance = plugin;
|
||||
} else {
|
||||
TLogger.getGlobalLogger().error(declaredField.getName() + " is not a static field. (" + pluginClass.getName() + ")");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try {
|
||||
declaredField.setAccessible(true);
|
||||
declaredField.set(instance, SimpleVersionControl.createNMS(annotation.asm()).useCache().translate(plugin).newInstance());
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -148,8 +148,6 @@ public class TInjectLoader implements TabooLibLoader.Loader {
|
||||
TInjectTask tInjectTask = injectTypes.get(declaredField.getType());
|
||||
if (tInjectTask != null) {
|
||||
inject(plugin, declaredField, instance, annotation, tInjectTask, pluginClass);
|
||||
} else if (annotation.state() == TInject.State.NONE) {
|
||||
TLogger.getGlobalLogger().error(declaredField.getName() + " is an invalid inject type. (" + pluginClass.getName() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,7 +158,7 @@ public class TInjectLoader implements TabooLibLoader.Loader {
|
||||
injectTask.run(plugin, field, annotation, pluginClass, instance);
|
||||
TabooLibAPI.debug(field.getName() + " injected. (" + field.getType().getName() + ")");
|
||||
} catch (Throwable e) {
|
||||
TLogger.getGlobalLogger().error(field.getName() + " inject failed: " + e.getMessage() + " (" + field.getType().getName() + ")");
|
||||
TLogger.getGlobalLogger().error(field.getName() + " inject failed: " + e.getMessage() + " (" + field.getName() + ")");
|
||||
if (e.getMessage() == null) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.izzel.taboolib.module.nms;
|
||||
|
||||
import io.izzel.taboolib.module.inject.TFunction;
|
||||
import io.izzel.taboolib.module.lite.SimpleVersionControl;
|
||||
import io.izzel.taboolib.module.inject.TInject;
|
||||
import io.izzel.taboolib.module.nms.nbt.NBTCompound;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -12,23 +11,15 @@ import org.bukkit.inventory.ItemStack;
|
||||
* @Author 坏黑
|
||||
* @Since 2018-11-09 14:38
|
||||
*/
|
||||
@TFunction(enable = "init")
|
||||
public abstract class NMS {
|
||||
|
||||
@TInject(asm = "io.izzel.taboolib.module.nms.NMSImpl")
|
||||
private static NMS impl;
|
||||
|
||||
public static NMS handle() {
|
||||
return impl;
|
||||
}
|
||||
|
||||
static void init() {
|
||||
try {
|
||||
impl = (NMS) SimpleVersionControl.createNMS("io.izzel.taboolib.module.nms.NMSImpl").translate().newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
abstract public boolean isRunning();
|
||||
|
||||
abstract public Object toPacketPlayOutWorldParticles(Particle var1, boolean var2, float var3, float var4, float var5, float var6, float var7, float var8, float var9, int var10, Object var11);
|
||||
|
@ -2,9 +2,9 @@ package io.izzel.taboolib.module.packet;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import io.izzel.taboolib.module.packet.channel.ChannelExecutor;
|
||||
import io.izzel.taboolib.module.lite.SimpleVersionControl;
|
||||
import io.izzel.taboolib.module.inject.TInject;
|
||||
import io.izzel.taboolib.module.inject.TListener;
|
||||
import io.izzel.taboolib.module.packet.channel.ChannelExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -25,16 +25,9 @@ import java.util.Optional;
|
||||
@TListener
|
||||
public class TPacketHandler implements Listener {
|
||||
|
||||
private static Map<String, List<TPacketListener>> packetListeners = Maps.newHashMap();
|
||||
@TInject(asm = "io.izzel.taboolib.module.packet.channel.InternalChannelExecutor")
|
||||
private static ChannelExecutor channelExecutor;
|
||||
|
||||
public TPacketHandler() {
|
||||
try {
|
||||
channelExecutor = (ChannelExecutor) SimpleVersionControl.createNMS("io.izzel.taboolib.module.packet.channel.InternalChannelExecutor").translate().newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private static Map<String, List<TPacketListener>> packetListeners = Maps.newHashMap();
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
|
@ -1,8 +1,7 @@
|
||||
package io.izzel.taboolib.module.tellraw;
|
||||
|
||||
import io.izzel.taboolib.module.inject.TFunction;
|
||||
import io.izzel.taboolib.module.inject.TInject;
|
||||
import io.izzel.taboolib.module.inject.TSchedule;
|
||||
import io.izzel.taboolib.module.lite.SimpleVersionControl;
|
||||
import io.izzel.taboolib.module.tellraw.internal.AbstractTellraw;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@ -10,33 +9,19 @@ import org.bukkit.Bukkit;
|
||||
* @Author 坏黑
|
||||
* @Since 2018-11-07 22:58
|
||||
*/
|
||||
@TFunction(enable = "init")
|
||||
public class TellrawCreator {
|
||||
|
||||
@TInject(asm = "io.izzel.taboolib.module.tellraw.internal.InternalTellraw")
|
||||
private static AbstractTellraw abstractTellraw;
|
||||
private static boolean viaVersionLoaded;
|
||||
private static boolean protocolSupportLoaded;
|
||||
|
||||
public static void init() {
|
||||
try {
|
||||
abstractTellraw = (AbstractTellraw) SimpleVersionControl.createNMS("io.izzel.taboolib.module.tellraw.internal.InternalTellraw").translate().newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@TSchedule
|
||||
static void tick() {
|
||||
viaVersionLoaded = Bukkit.getPluginManager().getPlugin("ViaVersion") != null;
|
||||
protocolSupportLoaded = Bukkit.getPluginManager().getPlugin("ProtocolSupport") != null;
|
||||
}
|
||||
|
||||
// *********************************
|
||||
//
|
||||
// Getter and Setter
|
||||
//
|
||||
// *********************************
|
||||
|
||||
public static AbstractTellraw getAbstractTellraw() {
|
||||
return abstractTellraw;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user