105
									
								
								obf.dict
									
									
									
									
									
								
							
							
						
						
									
										105
									
								
								obf.dict
									
									
									
									
									
								
							@@ -1,105 +0,0 @@
 | 
			
		||||
™
 | 
			
		||||
▄
 | 
			
		||||
▒
 | 
			
		||||
░
 | 
			
		||||
▓
 | 
			
		||||
™™
 | 
			
		||||
▄™
 | 
			
		||||
▒™
 | 
			
		||||
░™
 | 
			
		||||
▓™
 | 
			
		||||
™▄
 | 
			
		||||
▄▄
 | 
			
		||||
▒▄
 | 
			
		||||
░▄
 | 
			
		||||
▓▄
 | 
			
		||||
™▒
 | 
			
		||||
▄▒
 | 
			
		||||
▒▒
 | 
			
		||||
░▒
 | 
			
		||||
▓▒
 | 
			
		||||
™░
 | 
			
		||||
▄░
 | 
			
		||||
▒░
 | 
			
		||||
░░
 | 
			
		||||
▓░
 | 
			
		||||
™▓
 | 
			
		||||
▄▓
 | 
			
		||||
▒▓
 | 
			
		||||
░▓
 | 
			
		||||
▓▓
 | 
			
		||||
 ™
 | 
			
		||||
™▄
 | 
			
		||||
™▒
 | 
			
		||||
™░
 | 
			
		||||
™▓
 | 
			
		||||
▄™
 | 
			
		||||
▄▄
 | 
			
		||||
▄▒
 | 
			
		||||
▄░
 | 
			
		||||
▄▓
 | 
			
		||||
▒™
 | 
			
		||||
▒▄
 | 
			
		||||
 ▒
 | 
			
		||||
▒░
 | 
			
		||||
▒▓
 | 
			
		||||
░™
 | 
			
		||||
░▄
 | 
			
		||||
░▒
 | 
			
		||||
 ░
 | 
			
		||||
░▓
 | 
			
		||||
▓™
 | 
			
		||||
▓▄
 | 
			
		||||
▓▒
 | 
			
		||||
▓░
 | 
			
		||||
 ▓
 | 
			
		||||
™™™
 | 
			
		||||
▄™▄
 | 
			
		||||
▒™▒
 | 
			
		||||
░™░
 | 
			
		||||
▓™▓
 | 
			
		||||
™▄™
 | 
			
		||||
▄▄▄
 | 
			
		||||
▒▄▒
 | 
			
		||||
░▄░
 | 
			
		||||
▓▄▓
 | 
			
		||||
™▒™
 | 
			
		||||
▄▒▄
 | 
			
		||||
▒▒▒
 | 
			
		||||
░▒░
 | 
			
		||||
▓▒▓
 | 
			
		||||
™░™
 | 
			
		||||
▄░▄
 | 
			
		||||
▒░▒
 | 
			
		||||
░░░
 | 
			
		||||
▓░▓
 | 
			
		||||
™▓™
 | 
			
		||||
▄▓▄
 | 
			
		||||
▒▓▒
 | 
			
		||||
░▓░
 | 
			
		||||
▓▓▓
 | 
			
		||||
™ ™
 | 
			
		||||
™▄™
 | 
			
		||||
™▒™
 | 
			
		||||
™░™
 | 
			
		||||
™▓™
 | 
			
		||||
▄™▄
 | 
			
		||||
▄ ▄
 | 
			
		||||
▄▒▄
 | 
			
		||||
▄░▄
 | 
			
		||||
▄▓▄
 | 
			
		||||
▒™▒
 | 
			
		||||
▒▄▒
 | 
			
		||||
▒ ▒
 | 
			
		||||
▒░▒
 | 
			
		||||
▒▓▒
 | 
			
		||||
░™░
 | 
			
		||||
░▄░
 | 
			
		||||
░▒░
 | 
			
		||||
░ ░
 | 
			
		||||
░▓░
 | 
			
		||||
▓™▓
 | 
			
		||||
▓▄▓
 | 
			
		||||
▓▒▓
 | 
			
		||||
▓░▓
 | 
			
		||||
▓ ▓
 | 
			
		||||
							
								
								
									
										73
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										73
									
								
								pom.xml
									
									
									
									
									
								
							@@ -23,59 +23,6 @@
 | 
			
		||||
                <filtering>true</filtering>
 | 
			
		||||
            </resource>
 | 
			
		||||
        </resources>
 | 
			
		||||
        <plugins>
 | 
			
		||||
            <plugin>
 | 
			
		||||
                <groupId>org.apache.maven.plugins</groupId>
 | 
			
		||||
                <artifactId>maven-shade-plugin</artifactId>
 | 
			
		||||
                <version>2.4.3</version>
 | 
			
		||||
                <executions>
 | 
			
		||||
                    <execution>
 | 
			
		||||
                        <phase>package</phase>
 | 
			
		||||
                        <goals>
 | 
			
		||||
                            <goal>shade</goal>
 | 
			
		||||
                        </goals>
 | 
			
		||||
                        <configuration>
 | 
			
		||||
                            <createDependencyReducedPom>false</createDependencyReducedPom>
 | 
			
		||||
                            <minimizeJar>true</minimizeJar>
 | 
			
		||||
                            <artifactSet>
 | 
			
		||||
                                <includes>
 | 
			
		||||
                                    <include>pw.yumc:YumCore</include>
 | 
			
		||||
                                </includes>
 | 
			
		||||
                            </artifactSet>
 | 
			
		||||
                            <relocations>
 | 
			
		||||
                                <relocation>
 | 
			
		||||
                                    <pattern>pw.yumc.YumCore</pattern>
 | 
			
		||||
                                    <shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
 | 
			
		||||
                                </relocation>
 | 
			
		||||
                            </relocations>
 | 
			
		||||
                        </configuration>
 | 
			
		||||
                    </execution>
 | 
			
		||||
                </executions>
 | 
			
		||||
            </plugin>
 | 
			
		||||
            <plugin>
 | 
			
		||||
                <groupId>com.github.wvengen</groupId>
 | 
			
		||||
                <artifactId>proguard-maven-plugin</artifactId>
 | 
			
		||||
                <version>2.0.13</version>
 | 
			
		||||
                <executions>
 | 
			
		||||
                    <execution>
 | 
			
		||||
                        <phase>package</phase>
 | 
			
		||||
                        <goals>
 | 
			
		||||
                            <goal>proguard</goal>
 | 
			
		||||
                        </goals>
 | 
			
		||||
                        <configuration>
 | 
			
		||||
                            <options>
 | 
			
		||||
                                <option>-repackageclasses \ʼ.ʽ.ʾ.${project.artifactId}</option>
 | 
			
		||||
                                <option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}</option>
 | 
			
		||||
                                <option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}Bungee</option>
 | 
			
		||||
                            </options>
 | 
			
		||||
                            <libs>
 | 
			
		||||
                                <lib>${java.home}/lib/rt.jar</lib>
 | 
			
		||||
                            </libs>
 | 
			
		||||
                        </configuration>
 | 
			
		||||
                    </execution>
 | 
			
		||||
                </executions>
 | 
			
		||||
            </plugin>
 | 
			
		||||
        </plugins>
 | 
			
		||||
    </build>
 | 
			
		||||
    <ciManagement>
 | 
			
		||||
        <system>Jenkins</system>
 | 
			
		||||
@@ -181,21 +128,19 @@
 | 
			
		||||
    </distributionManagement>
 | 
			
		||||
    <dependencies>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>pw.yumc</groupId>
 | 
			
		||||
            <artifactId>YumCore</artifactId>
 | 
			
		||||
            <type>jar</type>
 | 
			
		||||
            <version>1.8.8</version>
 | 
			
		||||
            <exclusions>
 | 
			
		||||
                <exclusion>
 | 
			
		||||
                    <groupId>org.bukkit</groupId>
 | 
			
		||||
                    <artifactId>craftbukkit</artifactId>
 | 
			
		||||
                </exclusion>
 | 
			
		||||
            </exclusions>
 | 
			
		||||
            <groupId>org.projectlombok</groupId>
 | 
			
		||||
            <artifactId>lombok</artifactId>
 | 
			
		||||
            <version>1.18.6</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.spigotmc</groupId>
 | 
			
		||||
            <artifactId>spigot-api</artifactId>
 | 
			
		||||
            <version>1.13.2-R0.1-SNAPSHOT</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.spongepowered</groupId>
 | 
			
		||||
            <artifactId>spongeapi</artifactId>
 | 
			
		||||
            <version>6.0.0</version>
 | 
			
		||||
            <version>7.1.0</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
    </dependencies>
 | 
			
		||||
</project>
 | 
			
		||||
@@ -1,61 +0,0 @@
 | 
			
		||||
# -----不优化-----
 | 
			
		||||
-dontoptimize
 | 
			
		||||
 | 
			
		||||
# -----忽略所有警告-----
 | 
			
		||||
-dontwarn
 | 
			
		||||
-dontnote
 | 
			
		||||
 | 
			
		||||
# -----混淆时应用侵入式重载-----
 | 
			
		||||
-overloadaggressively
 | 
			
		||||
 | 
			
		||||
# -----启用混淆字典-----
 | 
			
		||||
-obfuscationdictionary obf.dict
 | 
			
		||||
-classobfuscationdictionary obf.dict
 | 
			
		||||
-packageobfuscationdictionary obf.dict
 | 
			
		||||
 | 
			
		||||
# -----保留所有属性
 | 
			
		||||
-keepattributes **
 | 
			
		||||
 | 
			
		||||
# -----保护所有实体中的字段名称-----
 | 
			
		||||
-keepclassmembers class * implements java.io.Serializable { <fields>; }  
 | 
			
		||||
 | 
			
		||||
# -----保护监听方法不被清理-----
 | 
			
		||||
-keepclassmembers class * implements org.bukkit.event.Listener {
 | 
			
		||||
  @org.bukkit.event.EventHandler <methods>;
 | 
			
		||||
}
 | 
			
		||||
-keepclassmembers class * implements net.md_5.bungee.api.plugin.Listener {
 | 
			
		||||
	@net.md_5.bungee.event.EventHandler <methods>;
 | 
			
		||||
}
 | 
			
		||||
-keepclassmembers class * {
 | 
			
		||||
  @org.spongepowered.api.event.Listener <methods>;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# -----保护继承事件不被清理-----
 | 
			
		||||
-keep class ** extends org.bukkit.event.Event {*;}
 | 
			
		||||
 | 
			
		||||
# -----保护枚举方法的完整性-----
 | 
			
		||||
-keepclassmembers enum * {
 | 
			
		||||
  public static **[] values();
 | 
			
		||||
  public static ** valueOf(java.lang.String);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# -----保护配置注入不被清理-----
 | 
			
		||||
-keepclassmembers class * extends **.config.inject.Inject** {
 | 
			
		||||
	<fields>;
 | 
			
		||||
  public <init>(org.bukkit.configuration.ConfigurationSection);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# -----保护注解命令方法不被清理-----
 | 
			
		||||
-keepclassmembers class **.commands.annotation.** {<methods>;}
 | 
			
		||||
-keepclassmembers class * implements **.commands.interfaces.Executor {<methods>;}
 | 
			
		||||
 | 
			
		||||
# -----保护注解命令方法不被清理-----
 | 
			
		||||
-keep @org.spongepowered.api.plugin.Plugin class * {*;}
 | 
			
		||||
 | 
			
		||||
# -----保护注解NotProguard标记-----
 | 
			
		||||
-keep class **.NotProguard
 | 
			
		||||
-keep @**.NotProguard class * {*;}
 | 
			
		||||
-keepclassmembers class * {
 | 
			
		||||
  @**.NotProguard <fields>;
 | 
			
		||||
  @**.NotProguard <methods>;
 | 
			
		||||
}
 | 
			
		||||
@@ -7,8 +7,6 @@ import java.nio.file.Path;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
import lombok.val;
 | 
			
		||||
import pw.yumc.YumCore.annotation.NotProguard;
 | 
			
		||||
import pw.yumc.YumCore.mc.MinecraftTools;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created with IntelliJ IDEA
 | 
			
		||||
@@ -16,7 +14,6 @@ import pw.yumc.YumCore.mc.MinecraftTools;
 | 
			
		||||
 * @author 喵♂呜
 | 
			
		||||
 * Created on 2017/10/9 12:40.
 | 
			
		||||
 */
 | 
			
		||||
@NotProguard
 | 
			
		||||
public class Base {
 | 
			
		||||
    public Class getClass(String name) throws ClassNotFoundException {
 | 
			
		||||
        return Class.forName(name);
 | 
			
		||||
@@ -46,8 +43,4 @@ public class Base {
 | 
			
		||||
        }
 | 
			
		||||
        Files.delete(path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Class getTools() {
 | 
			
		||||
        return MinecraftTools.class;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										182
									
								
								src/main/java/pw/yumc/MiaoScript/MiaoScriptEngine.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										182
									
								
								src/main/java/pw/yumc/MiaoScript/MiaoScriptEngine.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,182 @@
 | 
			
		||||
package pw.yumc.MiaoScript;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.Reader;
 | 
			
		||||
import java.lang.reflect.InvocationTargetException;
 | 
			
		||||
import java.lang.reflect.Method;
 | 
			
		||||
import java.net.MalformedURLException;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.net.URLClassLoader;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
 | 
			
		||||
import javax.script.Bindings;
 | 
			
		||||
import javax.script.Invocable;
 | 
			
		||||
import javax.script.ScriptContext;
 | 
			
		||||
import javax.script.ScriptEngine;
 | 
			
		||||
import javax.script.ScriptEngineFactory;
 | 
			
		||||
import javax.script.ScriptEngineManager;
 | 
			
		||||
import javax.script.ScriptException;
 | 
			
		||||
import javax.script.SimpleBindings;
 | 
			
		||||
 | 
			
		||||
import lombok.val;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 喵式脚本引擎
 | 
			
		||||
 *
 | 
			
		||||
 * @author 喵♂呜
 | 
			
		||||
 * @since 2016年8月29日 上午7:51:43
 | 
			
		||||
 */
 | 
			
		||||
public class MiaoScriptEngine implements ScriptEngine, Invocable {
 | 
			
		||||
    private static MiaoScriptEngine DEFAULT;
 | 
			
		||||
    private static ScriptEngineManager manager;
 | 
			
		||||
    private ScriptEngine engine;
 | 
			
		||||
 | 
			
		||||
    static {
 | 
			
		||||
        manager = new ScriptEngineManager(ClassLoader.getSystemClassLoader());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void setBindings(Bindings bindings) {
 | 
			
		||||
        manager.setBindings(bindings);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Bindings getBindings() {
 | 
			
		||||
        return manager.getBindings();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public MiaoScriptEngine() {
 | 
			
		||||
        this("js");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public MiaoScriptEngine(final String engineType) {
 | 
			
		||||
        this(manager, engineType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public MiaoScriptEngine(ScriptEngineManager engineManager) {
 | 
			
		||||
        this(engineManager, "js");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public MiaoScriptEngine(ScriptEngineManager engineManager, final String engineType) {
 | 
			
		||||
        try {
 | 
			
		||||
            engine = engineManager.getEngineByName(engineType);
 | 
			
		||||
        } catch (final NullPointerException ignored) {
 | 
			
		||||
        }
 | 
			
		||||
        if (engine == null) {
 | 
			
		||||
            val dirs = System.getProperty("java.ext.dirs").split(File.pathSeparator);
 | 
			
		||||
            for (String dir : dirs) {
 | 
			
		||||
                File nashorn = new File(dir, "nashorn.jar");
 | 
			
		||||
                if (nashorn.exists()) {
 | 
			
		||||
                    try {
 | 
			
		||||
                        Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
 | 
			
		||||
                        // 设置方法的访问权限
 | 
			
		||||
                        method.setAccessible(true);
 | 
			
		||||
                        // 获取系统类加载器
 | 
			
		||||
                        URL url = nashorn.toURI().toURL();
 | 
			
		||||
                        method.invoke(Thread.currentThread().getContextClassLoader(), url);
 | 
			
		||||
                        engineManager = new ScriptEngineManager();
 | 
			
		||||
                        engine = engineManager.getEngineByName(engineType);
 | 
			
		||||
                    } catch (NoSuchMethodException | MalformedURLException | IllegalAccessException | InvocationTargetException | NullPointerException ignored) {
 | 
			
		||||
                    }
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            throw new UnsupportedOperationException("当前环境不支持 " + engineType + " 脚本类型!");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static MiaoScriptEngine getDefault() {
 | 
			
		||||
        if (DEFAULT == null) {
 | 
			
		||||
            DEFAULT = new MiaoScriptEngine();
 | 
			
		||||
        }
 | 
			
		||||
        return DEFAULT;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Bindings createBindings() {
 | 
			
		||||
        return new SimpleBindings(new HashMap<>(engine.getBindings(ScriptContext.GLOBAL_SCOPE)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Object eval(final Reader reader) throws ScriptException {
 | 
			
		||||
        return engine.eval(reader);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Object eval(final Reader reader, final Bindings n) throws ScriptException {
 | 
			
		||||
        return engine.eval(reader, n);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Object eval(final Reader reader, final ScriptContext context) throws ScriptException {
 | 
			
		||||
        return engine.eval(reader, context);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Object eval(final String script) throws ScriptException {
 | 
			
		||||
        return engine.eval(script);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Object eval(final String script, final Bindings n) throws ScriptException {
 | 
			
		||||
        return engine.eval(script, n);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Object eval(final String script, final ScriptContext context) throws ScriptException {
 | 
			
		||||
        return engine.eval(script, context);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Object get(final String key) {
 | 
			
		||||
        return engine.get(key);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Bindings getBindings(final int scope) {
 | 
			
		||||
        return engine.getBindings(scope);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ScriptContext getContext() {
 | 
			
		||||
        return engine.getContext();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ScriptEngineFactory getFactory() {
 | 
			
		||||
        return engine.getFactory();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public <T> T getInterface(final Class<T> clasz) {
 | 
			
		||||
        return ((Invocable) engine).getInterface(clasz);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public <T> T getInterface(final Object thiz, final Class<T> clasz) {
 | 
			
		||||
        return ((Invocable) engine).getInterface(thiz, clasz);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Object invokeFunction(final String name, final Object... args) throws ScriptException, NoSuchMethodException {
 | 
			
		||||
        return ((Invocable) engine).invokeFunction(name, args);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Object invokeMethod(final Object thiz, final String name, final Object... args) throws ScriptException, NoSuchMethodException {
 | 
			
		||||
        return ((Invocable) engine).invokeMethod(thiz, name, args);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void put(final String key, final Object value) {
 | 
			
		||||
        engine.put(key, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setBindings(final Bindings bindings, final int scope) {
 | 
			
		||||
        engine.setBindings(bindings, scope);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setContext(final ScriptContext context) {
 | 
			
		||||
        engine.setContext(context);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -8,15 +8,12 @@ import java.nio.file.Paths;
 | 
			
		||||
import javax.script.ScriptEngineManager;
 | 
			
		||||
 | 
			
		||||
import lombok.SneakyThrows;
 | 
			
		||||
import pw.yumc.YumCore.annotation.NotProguard;
 | 
			
		||||
import pw.yumc.YumCore.engine.MiaoScriptEngine;
 | 
			
		||||
/**
 | 
			
		||||
 * Created with IntelliJ IDEA
 | 
			
		||||
 *
 | 
			
		||||
 * @author 喵♂呜
 | 
			
		||||
 * Created on 2017/10/25 21:01.
 | 
			
		||||
 */
 | 
			
		||||
@NotProguard
 | 
			
		||||
public class ScriptEngine {
 | 
			
		||||
    private String root;
 | 
			
		||||
    private Object logger;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user