refactor(NetworkManager.java): 调整异常抛出方式

This commit is contained in:
502647092 2016-03-30 11:27:19 +08:00
parent bff61aea3f
commit 776820e4b7
2 changed files with 4 additions and 11 deletions

View File

@ -25,8 +25,8 @@ import cn.citycraft.PluginHelper.utils.StringUtil;
import pw.yumc.Yum.Yum; import pw.yumc.Yum.Yum;
import pw.yumc.Yum.api.YumAPI; import pw.yumc.Yum.api.YumAPI;
import pw.yumc.Yum.manager.PluginsManager; import pw.yumc.Yum.manager.PluginsManager;
import pw.yumc.Yum.manager.RepositoryManager;
import pw.yumc.Yum.manager.RepoSerialization.Repositories; import pw.yumc.Yum.manager.RepoSerialization.Repositories;
import pw.yumc.Yum.manager.RepositoryManager;
/** /**
* Yum命令基类 * Yum命令基类
@ -180,7 +180,7 @@ public class YumCommand implements HandlerCommands, Listener {
if (plugin == null) { if (plugin == null) {
plugman.load(sender, pluginname); plugman.load(sender, pluginname);
} else { } else {
sender.sendMessage("§c错误: §b插件 " + pluginname + " §c已加载到服务器!"); sender.sendMessage("§c错误: §a插件 §b" + pluginname + " §c已加载到服务器!");
} }
} }

View File

@ -12,6 +12,7 @@ import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import cn.citycraft.PluginHelper.config.FileConfig; import cn.citycraft.PluginHelper.config.FileConfig;
import cn.citycraft.PluginHelper.kit.ExceptionKit;
import pw.yumc.Yum.Yum; import pw.yumc.Yum.Yum;
/** /**
@ -21,14 +22,6 @@ import pw.yumc.Yum.Yum;
* @author * @author
*/ */
public class NetworkManager { public class NetworkManager {
public static void throwException(final Throwable exception) {
NetworkManager.<RuntimeException> throwException0(exception);
}
@SuppressWarnings("unchecked")
private static <T extends Throwable> void throwException0(final Throwable exception) throws T {
throw (T) exception;
}
public NetworkManager register(final Yum plugin) { public NetworkManager register(final Yum plugin) {
Bukkit.getConsoleSender().sendMessage("§6[§bYum-网络管理§6] §a注入网络管理系统 将托管服务器网络!"); Bukkit.getConsoleSender().sendMessage("§6[§bYum-网络管理§6] §a注入网络管理系统 将托管服务器网络!");
@ -80,7 +73,7 @@ public class NetworkManager {
Bukkit.getConsoleSender().sendMessage(String.format(str, plugin.getName(), urlinfo)); Bukkit.getConsoleSender().sendMessage(String.format(str, plugin.getName(), urlinfo));
if (!allowPrimaryThread) { if (!allowPrimaryThread) {
Bukkit.getConsoleSender().sendMessage("§6[§bYum-网络管理§6] §4已阻止插件 §b" + plugin.getName() + " §4在主线程访问网络!"); Bukkit.getConsoleSender().sendMessage("§6[§bYum-网络管理§6] §4已阻止插件 §b" + plugin.getName() + " §4在主线程访问网络!");
throwException(new IOException("[Yum-网络管理] 已开启网络防护 不允许在主线程访问网络!")); ExceptionKit.throwException(new IOException("[Yum-网络管理] 已开启网络防护 不允许在主线程访问网络!"));
} }
} }
} }