在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);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
TLIB:
 | 
			
		||||
  INJECTION-SUCCESS: '注入成功'
 | 
			
		||||
  INJECTION-FAILED: '注入失败'
 | 
			
		||||
  INJECTION-FAILED:
 | 
			
		||||
    - '注入失败'
 | 
			
		||||
    - '&c提前加载依赖于 TabooLib 的所有插件的相关功能'
 | 
			
		||||
  LOAD-FAIL-OFFLINE:
 | 
			
		||||
  - '**********************************************'
 | 
			
		||||
  - '** TabooLib-{0} 无法在您的服务器上使用'
 | 
			
		||||
@@ -61,6 +63,8 @@ LOCALE:
 | 
			
		||||
  BAR-COLOR-IDENTIFICATION-FAILED: 'TLocaleBossBar 的颜色识别失败: {0}'
 | 
			
		||||
  BAR-STYLE-IDENTIFICATION-FAILED: 'TLocaleBossBar 的类型识别失败: {0}'
 | 
			
		||||
  BAR-PLUGIN-NOT-FOUND: 'TLocaleBossBar 的依赖插件 BossBarAPI 不存在'
 | 
			
		||||
  CALLER-PLUGIN-NOT-FOUND: '{0} 不是一个由插件加载的类'
 | 
			
		||||
  STATIC-CLASS-LOADER: '{0} 由静态类加载器初始化,无法获得其从属的插件'
 | 
			
		||||
  
 | 
			
		||||
MISC:
 | 
			
		||||
  FIELD-COPY-FAILED: '拷贝 {0} 对象失败'
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user