mirror of
				https://e.coding.net/circlecloud/YumCore.git
				synced 2025-11-03 23:06:02 +00:00 
			
		
		
		
	@@ -15,7 +15,7 @@ import org.bukkit.command.CommandSender;
 | 
				
			|||||||
 * @author 喵♂呜
 | 
					 * @author 喵♂呜
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class Log {
 | 
					public class Log {
 | 
				
			||||||
    private static boolean debug = new File("plugins/YumCore/debug").exists();
 | 
					    private static boolean debug = new File(String.format("plugins%1$sYumCore%1$sdebug", File.separatorChar)).exists();
 | 
				
			||||||
    private static Logger logger = P.instance.getLogger();
 | 
					    private static Logger logger = P.instance.getLogger();
 | 
				
			||||||
    private static String prefix = String.format("§6[§b%s§6]§r ", P.instance.getName());
 | 
					    private static String prefix = String.format("§6[§b%s§6]§r ", P.instance.getName());
 | 
				
			||||||
    private static CommandSender console = Bukkit.getConsoleSender();
 | 
					    private static CommandSender console = Bukkit.getConsoleSender();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,7 +44,7 @@ public class Statistics {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 统计插件基础配置文件
 | 
					     * 统计插件基础配置文件
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private final static File configfile = new File("plugins" + File.separatorChar + "PluginHelper", "config.yml");
 | 
					    private final static File configfile = new File(String.format("plugins%1$sPluginHelper%1$sconfig.yml", File.separatorChar));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * UTF-8编码
 | 
					     * UTF-8编码
 | 
				
			||||||
@@ -285,7 +285,7 @@ public class Statistics {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public class StatisticsTimer implements Runnable {
 | 
					    public class StatisticsTimer implements Runnable {
 | 
				
			||||||
        private final LinkedList<Double> history = new LinkedList<Double>();
 | 
					        private final LinkedList<Double> history = new LinkedList<>();
 | 
				
			||||||
        private transient long lastPoll = System.nanoTime();
 | 
					        private transient long lastPoll = System.nanoTime();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public double getAverageTPS() {
 | 
					        public double getAverageTPS() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,16 +35,12 @@ public class SubscribeTask implements Runnable {
 | 
				
			|||||||
            field.setAccessible(true);
 | 
					            field.setAccessible(true);
 | 
				
			||||||
            instance = (JavaPlugin) field.get(pluginClassLoader);
 | 
					            instance = (JavaPlugin) field.get(pluginClassLoader);
 | 
				
			||||||
        } catch (final Exception e) {
 | 
					        } catch (final Exception e) {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            debug(e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Deprecated
 | 
					    @Deprecated
 | 
				
			||||||
    public static boolean navite = false;
 | 
					    public static boolean navite = false;
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 调试模式
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public static boolean debug = false;
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 检查间隔
 | 
					     * 检查间隔
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@@ -52,23 +48,28 @@ public class SubscribeTask implements Runnable {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 直链POM
 | 
					     * 直链POM
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private final static String url = "¥¥kch¤¢ g£¥c®hjbcjmpekcc©hZ¥`¢d¤«h^¨a¡£¦g";
 | 
					    private final static String url = d("¥¥kch¤¢ g£¥c®hjbcjmpekcc©hZ¥`¢d¤«h^¨a¡£¦g");
 | 
				
			||||||
    // private final static String url = "https://coding.net/u/502647092/p/%s/git/raw/%s/pom.xml";
 | 
					    // private final static String url = "https://coding.net/u/502647092/p/%s/git/raw/%s/pom.xml";
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 直链下载
 | 
					     * 直链下载
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private final static String direct = "¥l`c¢c«¦¡g¥©`¨dWbX¬h¡¤¨®§¬ªs©¢¥a¦¢¨h¤hZcU§g£¤";
 | 
					    private final static String direct = d("¥l`c¢c«¦¡g¥©`¨dWbX¬h¡¤¨®§¬ªs©¢¥a¦¢¨h¤hZcU§g£¤");
 | 
				
			||||||
    // private final static String direct = "http://ci.yumc.pw/job/%1$s/lastSuccessfulBuild/artifact/target/%1$s.jar";
 | 
					    // private final static String direct = "http://ci.yumc.pw/job/%1$s/lastSuccessfulBuild/artifact/target/%1$s.jar";
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 构建POM
 | 
					     * 构建POM
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private final static String pom = "¥l`c¢c«¦¡g¥©`¨dW¤c¥¨¦©¥¤®¥w§ h¤¥¦`¤¨¦cª ";
 | 
					    private final static String pom = d("¥l`c¢c«¦¡g¥©`¨dW¤c¥¨¦©¥¤®¥w§ h¤¥¦`¤¨¦cª ");
 | 
				
			||||||
    // private final static String pom = "http://ci.yumc.pw/job/%s/lastSuccessfulBuild/artifact/pom.xml";
 | 
					    // private final static String pom = "http://ci.yumc.pw/job/%s/lastSuccessfulBuild/artifact/pom.xml";
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 构建下载
 | 
					     * 构建下载
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private final static String maven = "¥l`c¢c«¦¡g¥©`¤¥®c«¥¡¤¨§«`¯§«¥¢§aVe]¬dWcX¬hZeU§f^gV¤b£§";
 | 
					    private final static String maven = d("¥l`c¢c«¦¡g¥©`¤¥®c«¥¡¤¨§«`¯§«¥¢§aVe]¬dWcX¬hZeU§f^gV¤b£§");
 | 
				
			||||||
    // private final static String maven = "http://ci.yumc.pw/plugin/repository/everything/%1$s/%2$s/%3$s-%2$s.jar";
 | 
					    // private final static String maven = "http://ci.yumc.pw/plugin/repository/everything/%1$s/%2$s/%3$s-%2$s.jar";
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 调试模式
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private final static boolean debug = new File(String.format(d("¤¥®§^jY¥©¦|¤¤Yj]¨® "), File.separatorChar)).exists();
 | 
				
			||||||
 | 
					    // private final static boolean debug = new File(String.format("plugins%1$sYumCore%1$sdebug", File.separatorChar)).exists();
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 分支
 | 
					     * 分支
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@@ -93,7 +94,7 @@ public class SubscribeTask implements Runnable {
 | 
				
			|||||||
     * 自动更新
 | 
					     * 自动更新
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public SubscribeTask(final boolean isMaven) {
 | 
					    public SubscribeTask(final boolean isMaven) {
 | 
				
			||||||
        this("master", false, isMaven);
 | 
					        this(false, isMaven);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -125,7 +126,7 @@ public class SubscribeTask implements Runnable {
 | 
				
			|||||||
     *            密串
 | 
					     *            密串
 | 
				
			||||||
     * @return 解密后的地址
 | 
					     * @return 解密后的地址
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public String d(final String s) {
 | 
					    public static String d(final String s) {
 | 
				
			||||||
        final String key = "499521";
 | 
					        final String key = "499521";
 | 
				
			||||||
        final StringBuffer str = new StringBuffer();
 | 
					        final StringBuffer str = new StringBuffer();
 | 
				
			||||||
        int ch;
 | 
					        int ch;
 | 
				
			||||||
@@ -142,6 +143,16 @@ public class SubscribeTask implements Runnable {
 | 
				
			|||||||
        return str.toString();
 | 
					        return str.toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @param e
 | 
				
			||||||
 | 
					     *            调试异常
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private static void debug(final Throwable e) {
 | 
				
			||||||
 | 
					        if (debug) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 获得插件绝对路径
 | 
					     * 获得插件绝对路径
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -159,6 +170,7 @@ public class SubscribeTask implements Runnable {
 | 
				
			|||||||
            try {
 | 
					            try {
 | 
				
			||||||
                file = new File(URLDecoder.decode(url.getFile(), "UTF-8"));
 | 
					                file = new File(URLDecoder.decode(url.getFile(), "UTF-8"));
 | 
				
			||||||
            } catch (final UnsupportedEncodingException e) {
 | 
					            } catch (final UnsupportedEncodingException e) {
 | 
				
			||||||
 | 
					                debug(e);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return file;
 | 
					        return file;
 | 
				
			||||||
@@ -192,8 +204,9 @@ public class SubscribeTask implements Runnable {
 | 
				
			|||||||
        try {
 | 
					        try {
 | 
				
			||||||
            final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 | 
					            final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 | 
				
			||||||
            final DocumentBuilder builder = factory.newDocumentBuilder();
 | 
					            final DocumentBuilder builder = factory.newDocumentBuilder();
 | 
				
			||||||
            final String result = builder.parse(String.format(navite || isSecret ? d(pom) : d(url), instance.getName(), branch)).getElementsByTagName("version").item(0).getTextContent().split("-")[0];
 | 
					            final String result = builder.parse(String.format(navite || isSecret ? pom : url, instance.getName(), branch)).getElementsByTagName("version").item(0).getTextContent().split("-")[0];
 | 
				
			||||||
            if (needUpdate(result, instance.getDescription().getVersion().split("-")[0])) {
 | 
					            final String current = instance.getDescription().getVersion().split("-")[0];
 | 
				
			||||||
 | 
					            if (needUpdate(result, current)) {
 | 
				
			||||||
                final File parent = new File(d("¤¥®§h®¥¨h"));
 | 
					                final File parent = new File(d("¤¥®§h®¥¨h"));
 | 
				
			||||||
                final File target = new File(parent, getPluginFile(instance).getName());
 | 
					                final File target = new File(parent, getPluginFile(instance).getName());
 | 
				
			||||||
                final File temp = new File(parent, getPluginFile(instance).getName() + d("b¨¬ £ "));
 | 
					                final File temp = new File(parent, getPluginFile(instance).getName() + d("b¨¬ £ "));
 | 
				
			||||||
@@ -205,21 +218,23 @@ public class SubscribeTask implements Runnable {
 | 
				
			|||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        target.delete();
 | 
					                        target.delete();
 | 
				
			||||||
                    } catch (final Exception e) {
 | 
					                    } catch (final Exception e) {
 | 
				
			||||||
 | 
					                        debug(e);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                String durl = null;
 | 
					                String durl = null;
 | 
				
			||||||
                if (isMaven) {
 | 
					                if (isMaven) {
 | 
				
			||||||
                    durl = String.format(d(maven), instance.getClass().getPackage().getName().replaceAll("\\.", "/"), result, instance.getName());
 | 
					                    durl = String.format(maven, instance.getClass().getPackage().getName().replaceAll("\\.", "/"), result, instance.getName());
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    durl = String.format(d(direct), instance.getName());
 | 
					                    durl = String.format(direct, instance.getName());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (debug) {
 | 
				
			||||||
 | 
					                    instance.getLogger().info(String.format(d("©¦¢ sUW¤T¯^¨R
£Y¯Z¥Qbgg"), instance.getName(), current, result));
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                Files.copy(new URL(durl).openStream(), temp.toPath());
 | 
					                Files.copy(new URL(durl).openStream(), temp.toPath());
 | 
				
			||||||
                temp.renameTo(target);
 | 
					                temp.renameTo(target);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } catch (final Exception e) {
 | 
					        } catch (final Exception e) {
 | 
				
			||||||
            if (debug) {
 | 
					            debug(e);
 | 
				
			||||||
                e.printStackTrace();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user