在boom的边缘悬崖勒马,太刺激了
某个类现在跑的更溜了 画了个假的饼
This commit is contained in:
@@ -17,6 +17,7 @@ import me.skymc.taboolib.fileutils.FileUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -97,12 +98,12 @@ public class TLib {
|
||||
Field field = Bukkit.getServer().getClass().getDeclaredField("pluginManager");
|
||||
field.setAccessible(true);
|
||||
field.set(Bukkit.getServer(), new TPluginManager());
|
||||
} catch (NoSuchFieldException | IllegalAccessException ignored) {
|
||||
}
|
||||
if (Bukkit.getPluginManager() instanceof TPluginManager) {
|
||||
TLocale.Logger.info("TLIB.INJECTION-SUCCESS");
|
||||
} else {
|
||||
} catch (NoSuchFieldException | IllegalAccessException ignored) {
|
||||
TLocale.Logger.fatal("TLIB.INJECTION-FAILED");
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
if (plugin != Main.getInst()) TDependencyInjector.inject(plugin, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.ilummc.tlib.annotations.clr;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Repeatable(CommandHandlers.class)
|
||||
public @interface CommandHandler {
|
||||
|
||||
/**
|
||||
* Name of the command
|
||||
*
|
||||
* @return Name of the command
|
||||
*/
|
||||
String value();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ilummc.tlib.annotations.clr;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface CommandHandlers {
|
||||
|
||||
CommandHandler[] value();
|
||||
|
||||
}
|
||||
14
src/main/java/com/ilummc/tlib/annotations/clr/Sub.java
Normal file
14
src/main/java/com/ilummc/tlib/annotations/clr/Sub.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.ilummc.tlib.annotations.clr;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Sub {
|
||||
|
||||
String value();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ilummc.tlib.clr;
|
||||
|
||||
public class CommandLineResolver {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -101,11 +101,11 @@ public class Ref {
|
||||
|
||||
public static JavaPlugin getCallerPlugin(Class<?> callerClass) {
|
||||
try {
|
||||
Field pluginField = callerClass.getClassLoader().getClass().getDeclaredField("plugin");
|
||||
pluginField.setAccessible(true);
|
||||
return (JavaPlugin) pluginField.get(callerClass.getClassLoader());
|
||||
} catch (Exception ignored) {
|
||||
return JavaPlugin.getProvidingPlugin(callerClass);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
TLocale.Logger.error("LOCALE.CALLER-PLUGIN-NOT-FOUND", callerClass.getName());
|
||||
} catch (IllegalStateException e) {
|
||||
TLocale.Logger.error("LOCALE.STATIC-CLASS-LOADER", callerClass.getName());
|
||||
}
|
||||
return (JavaPlugin) Main.getInst();
|
||||
}
|
||||
|
||||
@@ -2,12 +2,20 @@ package com.ilummc.tlib.util.asm;
|
||||
|
||||
public class AsmClassLoader extends ClassLoader {
|
||||
|
||||
public AsmClassLoader() {
|
||||
private static final class AsmClassLoaderHolder {
|
||||
private static AsmClassLoader instance = new AsmClassLoader();
|
||||
}
|
||||
|
||||
public static AsmClassLoader getInstance() {
|
||||
return AsmClassLoaderHolder.instance;
|
||||
}
|
||||
|
||||
private AsmClassLoader() {
|
||||
super(AsmClassLoader.class.getClassLoader());
|
||||
}
|
||||
|
||||
public Class<?> createNewClass(String name, byte[] arr) {
|
||||
return defineClass(name, arr, 0, arr.length, AsmClassLoader.class.getProtectionDomain());
|
||||
public static Class<?> createNewClass(String name, byte[] arr) {
|
||||
return getInstance().defineClass(name, arr, 0, arr.length, AsmClassLoader.class.getProtectionDomain());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class AsmClassTransformer extends ClassVisitor implements Opcodes {
|
||||
newClassName = from.getName() + "_TabooLibRemap_" + this.hashCode() + "_" + toVer;
|
||||
prevName = from.getName().replace('.', '/');
|
||||
classReader.accept(this, ClassReader.SKIP_DEBUG);
|
||||
Class<?> clazz = new AsmClassLoader().createNewClass(newClassName, writer.toByteArray());
|
||||
Class<?> clazz = AsmClassLoader.createNewClass(newClassName, writer.toByteArray());
|
||||
Field field = from.getClassLoader().getClass().getDeclaredField("classes");
|
||||
field.setAccessible(true);
|
||||
((Map<String, Class<?>>) field.get(from.getClassLoader())).put(newClassName, clazz);
|
||||
|
||||
Reference in New Issue
Block a user