mirror of
https://e.coding.net/circlecloud/YumCore.git
synced 2024-11-24 02:08:48 +00:00
fix: 修复开发版本无法自动更新的问题 添加单元测试
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
e578f33608
commit
d767dba2e6
15
pom.xml
15
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>pw.yumc</groupId>
|
<groupId>pw.yumc</groupId>
|
||||||
<artifactId>YumCore</artifactId>
|
<artifactId>YumCore</artifactId>
|
||||||
<version>1.8.3</version>
|
<version>1.8.5</version>
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.artifactId}</finalName>
|
<finalName>${project.artifactId}</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -66,7 +66,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.11.2-R0.1-SNAPSHOT</version>
|
<version>[1.12.1-R0.1-SNAPSHOT,)</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
@ -81,7 +81,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-api</artifactId>
|
<artifactId>bungeecord-api</artifactId>
|
||||||
<version>1.11-SNAPSHOT</version>
|
<version>[1.12-SNAPSHOT,)</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
@ -92,7 +92,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.clip</groupId>
|
<groupId>me.clip</groupId>
|
||||||
<artifactId>placeholderapi</artifactId>
|
<artifactId>placeholderapi</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>[2.5.1,)</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
@ -108,7 +108,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
<artifactId>Vault</artifactId>
|
<artifactId>Vault</artifactId>
|
||||||
<version>1.5.6</version>
|
<version>[1.5.6,)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.mail</groupId>
|
<groupId>javax.mail</groupId>
|
||||||
@ -130,6 +130,11 @@
|
|||||||
<artifactId>worldedit-bukkit</artifactId>
|
<artifactId>worldedit-bukkit</artifactId>
|
||||||
<version>6.1.5</version>
|
<version>6.1.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.puharesource.mc</groupId>
|
||||||
|
<artifactId>TitleManager</artifactId>
|
||||||
|
<version>2.0.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
|
@ -2,7 +2,7 @@ package pw.yumc.YumCore.bukkit;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.Optional;
|
||||||
import java.util.logging.Handler;
|
import java.util.logging.Handler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -27,6 +27,7 @@ public class Log {
|
|||||||
private static Logger logger;
|
private static Logger logger;
|
||||||
private static CommandSender console;
|
private static CommandSender console;
|
||||||
private static String prefix;
|
private static String prefix;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
debug = globalDebug || P.getDescription().getVersion().contains("DEV");
|
debug = globalDebug || P.getDescription().getVersion().contains("DEV");
|
||||||
@ -36,7 +37,6 @@ public class Log {
|
|||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
logger = Logger.getLogger("YumCore");
|
logger = Logger.getLogger("YumCore");
|
||||||
debug = true;
|
debug = true;
|
||||||
d(ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,6 +375,13 @@ public class Log {
|
|||||||
w(String.format(string, objects));
|
w(String.format(string, objects));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 是否为调试模式
|
||||||
|
*/
|
||||||
|
public static boolean isDebug() {
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 是否为全局调试模式
|
* @return 是否为全局调试模式
|
||||||
*/
|
*/
|
||||||
@ -382,23 +389,20 @@ public class Log {
|
|||||||
return globalDebug;
|
return globalDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String osn(List<?> classes) {
|
/**
|
||||||
|
* 打印对象简易名称
|
||||||
|
*
|
||||||
|
* @param objects
|
||||||
|
* 对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getSimpleNames(Object... objects) {
|
||||||
StringBuilder str = new StringBuilder("[");
|
StringBuilder str = new StringBuilder("[");
|
||||||
classes.forEach(c -> str.append(c == null ? null : c.getClass().getSimpleName()).append(", "));
|
Arrays.stream(objects)
|
||||||
return classes.isEmpty() ? "[]" : str.substring(0, str.length() - 2) + "]";
|
.forEach(o -> str.append(Optional.ofNullable(o)
|
||||||
}
|
.map(obj -> obj instanceof Class ? (Class) obj : obj.getClass())
|
||||||
|
.map(Class::getSimpleName)
|
||||||
public static String osn(Object... classes) {
|
.orElse(null)).append(", "));
|
||||||
return osn(Arrays.asList(classes));
|
return objects.length == 0 ? "[]" : str.substring(0, str.length() - 2) + "]";
|
||||||
}
|
|
||||||
|
|
||||||
public static String csn(List<Class> classes) {
|
|
||||||
StringBuilder str = new StringBuilder("[");
|
|
||||||
classes.forEach(c -> str.append(c == null ? null : c.getSimpleName()).append(", "));
|
|
||||||
return classes.isEmpty() ? "[]" : str.substring(0, str.length() - 2) + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String csn(Class[] classes) {
|
|
||||||
return csn(Arrays.asList(classes));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,18 +7,21 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插件Instance获取类
|
* 插件Instance获取类
|
||||||
*
|
*
|
||||||
* @since 2016年7月23日 上午9:09:57
|
|
||||||
* @author 喵♂呜
|
* @author 喵♂呜
|
||||||
|
* @since 2016年7月23日 上午9:09:57
|
||||||
*/
|
*/
|
||||||
public class P {
|
public class P {
|
||||||
/**
|
/**
|
||||||
@ -49,7 +52,6 @@ public class P {
|
|||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
* 命令名称
|
* 命令名称
|
||||||
*
|
|
||||||
* @return 插件命令
|
* @return 插件命令
|
||||||
*/
|
*/
|
||||||
public static PluginCommand getCommand(String name) {
|
public static PluginCommand getCommand(String name) {
|
||||||
@ -122,6 +124,16 @@ public class P {
|
|||||||
return instance.isEnabled();
|
return instance.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量注册监听器
|
||||||
|
*
|
||||||
|
* @param listeners
|
||||||
|
* 监听器
|
||||||
|
*/
|
||||||
|
public static void registerEvents(Listener... listeners) {
|
||||||
|
Arrays.stream(listeners).forEach(listener -> Bukkit.getPluginManager().registerEvents(listener, instance));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存文件
|
* 保存文件
|
||||||
*
|
*
|
||||||
|
@ -61,7 +61,7 @@ public class CommandMain implements CommandExecutor {
|
|||||||
* 命令类
|
* 命令类
|
||||||
* @return {@link CommandMain}
|
* @return {@link CommandMain}
|
||||||
*/
|
*/
|
||||||
public CommandMain register(Executor... clazzs) {
|
public void register(Executor... clazzs) {
|
||||||
for (Executor clazz : clazzs) {
|
for (Executor clazz : clazzs) {
|
||||||
Method[] methods = clazz.getClass().getDeclaredMethods();
|
Method[] methods = clazz.getClass().getDeclaredMethods();
|
||||||
for (Method method : methods) {
|
for (Method method : methods) {
|
||||||
@ -70,30 +70,29 @@ public class CommandMain implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
help = new CommandHelp(cmds);
|
help = new CommandHelp(cmds);
|
||||||
help.setHelpGenerator(helpGenerator);
|
help.setHelpGenerator(helpGenerator);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean registerCommand(Method method, Executor clazz) {
|
private void registerCommand(Method method, Executor clazz) {
|
||||||
CommandInfo ci = CommandInfo.parse(method, clazz);
|
CommandInfo ci = CommandInfo.parse(method, clazz);
|
||||||
if (ci != null) {
|
if (ci != null) {
|
||||||
injectPluginCommand(ci);
|
injectPluginCommand(ci);
|
||||||
Class[] params = method.getParameterTypes();
|
Class[] params = method.getParameterTypes();
|
||||||
Log.d("注册主命令 %s 参数类型: %s", ci.getName(), Log.csn(params));
|
Log.d("注册主命令 %s 参数类型: %s", ci.getName(), Log.getSimpleNames((Object[]) params));
|
||||||
try {
|
try {
|
||||||
Class<? extends CommandSender> sender = params[0];
|
Class<? extends CommandSender> sender = params[0];
|
||||||
cmds.add(ci);
|
cmds.add(ci);
|
||||||
return true;
|
|
||||||
} catch (ArrayIndexOutOfBoundsException | ClassCastException ignored) {
|
} catch (ArrayIndexOutOfBoundsException | ClassCastException ignored) {
|
||||||
}
|
|
||||||
Log.w(argumentTypeError, method.getName(), clazz.getClass().getName());
|
Log.w(argumentTypeError, method.getName(), clazz.getClass().getName());
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectPluginCommand(CommandInfo ci) {
|
private void injectPluginCommand(CommandInfo ci) {
|
||||||
PluginCommand cmd = P.getCommand(ci.getName());
|
PluginCommand cmd = P.getCommand(ci.getName());
|
||||||
if (cmd == null) {
|
if (cmd == null) {
|
||||||
if ((cmd = CommandKit.create(ci.getName(), ci.getAliases().toArray(new String[] {}))) == null) { throw new IllegalStateException("未找到命令 必须在plugin.yml先注册 " + ci.getName() + " 命令!"); }
|
if ((cmd = CommandKit.create(ci.getName(), ci.getAliases().toArray(new String[]{}))) == null) {
|
||||||
|
throw new IllegalStateException("未找到命令 必须在plugin.yml先注册 " + ci.getName() + " 命令!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cmd.setExecutor(this);
|
cmd.setExecutor(this);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ public class CommandParse {
|
|||||||
private static Map<String, Class> primitiveMap = new HashMap<>();
|
private static Map<String, Class> primitiveMap = new HashMap<>();
|
||||||
private boolean isMain;
|
private boolean isMain;
|
||||||
private List<Parse> parses = new LinkedList<>();
|
private List<Parse> parses = new LinkedList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
register(File.class, FileParse.class);
|
register(File.class, FileParse.class);
|
||||||
register(Player.class, PlayerParse.class);
|
register(Player.class, PlayerParse.class);
|
||||||
@ -68,7 +69,7 @@ public class CommandParse {
|
|||||||
if (parse == null) { throw new ParseException(String.format("存在无法解析的参数类型 %s", clazz.getName())); }
|
if (parse == null) { throw new ParseException(String.format("存在无法解析的参数类型 %s", clazz.getName())); }
|
||||||
this.parses.add(parse.parseAnnotation(annotations).handleAttrs());
|
this.parses.add(parse.parseAnnotation(annotations).handleAttrs());
|
||||||
}
|
}
|
||||||
Log.d("命令解析器 %s", Log.osn(parses));
|
Log.d("命令解析器 %s", Log.getSimpleNames(parses));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommandParse get(Method method) {
|
public static CommandParse get(Method method) {
|
||||||
@ -114,7 +115,7 @@ public class CommandParse {
|
|||||||
throw new ParseException(String.format("第 %s 个参数 %s", isMain ? 1 : 2 + i, e.getMessage()));
|
throw new ParseException(String.format("第 %s 个参数 %s", isMain ? 1 : 2 + i, e.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.d("解析参数: %s => %s", Arrays.toString(args), Log.osn(pobjs));
|
Log.d("解析参数: %s => %s", Arrays.toString(args), Log.getSimpleNames(pobjs));
|
||||||
return pobjs.toArray();
|
return pobjs.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,11 @@ public class CommandSub implements TabExecutor {
|
|||||||
String lastWord = args[args.length - 1];
|
String lastWord = args[args.length - 1];
|
||||||
Player senderPlayer = sender instanceof Player ? (Player) sender : null;
|
Player senderPlayer = sender instanceof Player ? (Player) sender : null;
|
||||||
List<String> matchedPlayers = new ArrayList<>();
|
List<String> matchedPlayers = new ArrayList<>();
|
||||||
C.Player.getOnlinePlayers().stream().filter(player -> (senderPlayer == null || senderPlayer.canSee(player)) && StringUtil.startsWithIgnoreCase(player.getName(), lastWord)).forEach(
|
C.Player.getOnlinePlayers()
|
||||||
|
.stream()
|
||||||
|
.filter(player -> (senderPlayer == null || senderPlayer.canSee(player)) && StringUtil.startsWithIgnoreCase(player.getName(),
|
||||||
|
lastWord))
|
||||||
|
.forEach(
|
||||||
player -> matchedPlayers.add(player.getName()));
|
player -> matchedPlayers.add(player.getName()));
|
||||||
return matchedPlayers;
|
return matchedPlayers;
|
||||||
}
|
}
|
||||||
@ -206,7 +210,7 @@ public class CommandSub implements TabExecutor {
|
|||||||
* 子命令处理类
|
* 子命令处理类
|
||||||
* @return {@link CommandSub}
|
* @return {@link CommandSub}
|
||||||
*/
|
*/
|
||||||
public CommandSub register(Executor... clazzs) {
|
public void register(Executor... clazzs) {
|
||||||
for (Executor clazz : clazzs) {
|
for (Executor clazz : clazzs) {
|
||||||
Log.d("解析执行类: %s", clazz.getClass().getName());
|
Log.d("解析执行类: %s", clazz.getClass().getName());
|
||||||
Method[] methods = clazz.getClass().getDeclaredMethods();
|
Method[] methods = clazz.getClass().getDeclaredMethods();
|
||||||
@ -219,7 +223,6 @@ public class CommandSub implements TabExecutor {
|
|||||||
}
|
}
|
||||||
help = new CommandHelp(defCmd, cmds);
|
help = new CommandHelp(defCmd, cmds);
|
||||||
buildCmdNameCache();
|
buildCmdNameCache();
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -235,7 +238,7 @@ public class CommandSub implements TabExecutor {
|
|||||||
CommandInfo ci = CommandInfo.parse(method, clazz);
|
CommandInfo ci = CommandInfo.parse(method, clazz);
|
||||||
if (ci != null) {
|
if (ci != null) {
|
||||||
Class[] params = method.getParameterTypes();
|
Class[] params = method.getParameterTypes();
|
||||||
Log.d("注册子命令: %s 参数类型: %s", ci.getName(), Log.csn(params));
|
Log.d("注册子命令: %s 参数类型: %s", ci.getName(), Log.getSimpleNames((Object[]) params));
|
||||||
try {
|
try {
|
||||||
Class<? extends CommandSender> sender = params[0];
|
Class<? extends CommandSender> sender = params[0];
|
||||||
// 用于消除unuse警告
|
// 用于消除unuse警告
|
||||||
@ -262,17 +265,16 @@ public class CommandSub implements TabExecutor {
|
|||||||
* 调用对象
|
* 调用对象
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
private boolean registerTab(Method method, Executor clazz) {
|
private void registerTab(Method method, Executor clazz) {
|
||||||
CommandTabInfo ti = CommandTabInfo.parse(method, clazz);
|
CommandTabInfo ti = CommandTabInfo.parse(method, clazz);
|
||||||
if (ti != null) {
|
if (ti != null) {
|
||||||
if (method.getReturnType().equals(List.class)) {
|
if (method.getReturnType().equals(List.class)) {
|
||||||
Log.d("注册子命令补全: %s ", method.getName());
|
Log.d("注册子命令补全: %s ", method.getName());
|
||||||
tabs.add(ti);
|
tabs.add(ti);
|
||||||
return true;
|
} else {
|
||||||
}
|
|
||||||
Log.w(returnTypeError, method.getName(), clazz.getClass().getName());
|
Log.w(returnTypeError, method.getName(), clazz.getClass().getName());
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,6 @@ package pw.yumc.YumCore.update;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
@ -30,31 +29,21 @@ import org.w3c.dom.Document;
|
|||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import pw.yumc.YumCore.bukkit.Log;
|
import pw.yumc.YumCore.bukkit.Log;
|
||||||
|
import pw.yumc.YumCore.bukkit.P;
|
||||||
import pw.yumc.YumCore.tellraw.Tellraw;
|
import pw.yumc.YumCore.tellraw.Tellraw;
|
||||||
import pw.yumc.YumCore.text.Encrypt;
|
import pw.yumc.YumCore.text.Encrypt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自动更新程序
|
* 自动更新程序
|
||||||
*
|
*
|
||||||
* @since 2016年8月3日 上午11:20:21
|
|
||||||
* @author 喵♂呜
|
* @author 喵♂呜
|
||||||
|
* @since 2016年8月3日 上午11:20:21
|
||||||
*/
|
*/
|
||||||
public class SubscribeTask implements Runnable, Listener {
|
public class SubscribeTask implements Runnable, Listener {
|
||||||
/**
|
/**
|
||||||
* 插件实例
|
* 插件实例
|
||||||
*/
|
*/
|
||||||
private static JavaPlugin instance;
|
private static JavaPlugin instance = P.instance;
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
Object pluginClassLoader = SubscribeTask.class.getClassLoader();
|
|
||||||
Field field = pluginClassLoader.getClass().getDeclaredField("plugin");
|
|
||||||
field.setAccessible(true);
|
|
||||||
instance = (JavaPlugin) field.get(pluginClassLoader);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.d(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查间隔
|
* 检查间隔
|
||||||
@ -111,6 +100,7 @@ public class SubscribeTask implements Runnable, Listener {
|
|||||||
* 更新类型
|
* 更新类型
|
||||||
*/
|
*/
|
||||||
public SubscribeTask(String branch, boolean isSecret, UpdateType type) {
|
public SubscribeTask(String branch, boolean isSecret, UpdateType type) {
|
||||||
|
Log.d("订阅更新 分支 %s 是否加密 %s 更新类型 %s", branch, isSecret, type.name());
|
||||||
updateFile = new UpdateFile(instance);
|
updateFile = new UpdateFile(instance);
|
||||||
versionInfo = new VersionInfo(instance, branch, isSecret);
|
versionInfo = new VersionInfo(instance, branch, isSecret);
|
||||||
updateType = type;
|
updateType = type;
|
||||||
@ -390,12 +380,11 @@ public class SubscribeTask implements Runnable, Listener {
|
|||||||
public String getNewVersion() {
|
public String getNewVersion() {
|
||||||
try {
|
try {
|
||||||
String result = getLastestVersion();
|
String result = getLastestVersion();
|
||||||
if (version.contains("DEV") && !Log.isGlobalDebug()) {
|
if (Log.isDebug() && !Log.isGlobalDebug()) {
|
||||||
Log.console("§4注意: §c当前版本为开发版本 且未开启全局调试 已自动下载最新稳定版!");
|
Log.console("§4注意: §c当前版本为开发版本 且未开启全局调试 已自动下载最新稳定版!");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
String current = version.split("-")[0];
|
if (needUpdate(result, version)) { return result; }
|
||||||
if (needUpdate(result, current)) { return result; }
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(e);
|
Log.d(e);
|
||||||
}
|
}
|
||||||
|
17
src/test/java/pw/yumc/YumCore/bukkit/LogTest.java
Normal file
17
src/test/java/pw/yumc/YumCore/bukkit/LogTest.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package pw.yumc.YumCore.bukkit;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA
|
||||||
|
*
|
||||||
|
* @author 喵♂呜
|
||||||
|
* Created on 2017/8/22 15:16.
|
||||||
|
*/
|
||||||
|
public class LogTest {
|
||||||
|
@Test
|
||||||
|
public void testSimpleNames() {
|
||||||
|
Assert.assertTrue("[LogTest, LogTest, null]".equals(Log.getSimpleNames(this, this.getClass(), null)));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user