Fix CatServer

This commit is contained in:
sky 2020-02-20 15:52:55 +08:00
parent 98251ec4aa
commit edc1ff56c1
3 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,6 @@
package io.izzel.taboolib.module.dependency; package io.izzel.taboolib.module.dependency;
import io.izzel.taboolib.TabooLib;
import io.izzel.taboolib.util.Files; import io.izzel.taboolib.util.Files;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
@ -11,10 +12,16 @@ import org.objectweb.asm.ClassWriter;
*/ */
public class TDependencyInjector { public class TDependencyInjector {
private static boolean libInjected;
public static void inject(Plugin plugin, Class<?> clazz) { public static void inject(Plugin plugin, Class<?> clazz) {
if (!plugin.getName().equals("TabooLib") || !libInjected) { if (clazz.equals(TabooLib.class)) {
for (Dependency dependency : TabooLib.class.getAnnotationsByType(Dependency.class)) {
try {
TDependency.requestLib(dependency.maven(), dependency.mavenRepo(), dependency.url());
} catch (Throwable t) {
t.printStackTrace();
}
}
} else {
try { try {
ClassReader classReader = new ClassReader(Files.getResource(plugin, clazz.getName().replace(".", "/") + ".class")); ClassReader classReader = new ClassReader(Files.getResource(plugin, clazz.getName().replace(".", "/") + ".class"));
ClassWriter classWriter = new ClassWriter(0); ClassWriter classWriter = new ClassWriter(0);
@ -24,8 +31,6 @@ public class TDependencyInjector {
classVisitor.visitEnd(); classVisitor.visitEnd();
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
} finally {
libInjected = true;
} }
} }
} }

View File

@ -9,11 +9,8 @@ import java.io.File;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodType; import java.lang.invoke.MethodType;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader;
public class TDependencyLoader { public class TDependencyLoader {

View File

@ -97,7 +97,7 @@ public class Effects {
} }
public static void buildPolygon(Location center, double range, double interval, Consumer<Location> action) { public static void buildPolygon(Location center, double range, double interval, Consumer<Location> action) {
for (double i = 0; i < 360; i += (360 / interval)) { for (double i = 0; i < 360; i += interval) {
double radians = Math.toRadians(i); double radians = Math.toRadians(i);
double cos = Math.cos(radians) * range; double cos = Math.cos(radians) * range;
double sin = Math.sin(radians) * range; double sin = Math.sin(radians) * range;