From 22f57e1e81fe9ea315a9f7edf2590a6723254874 Mon Sep 17 00:00:00 2001 From: 502647092 Date: Tue, 29 Mar 2016 20:37:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor(NetworkManager):=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- src/main/java/pw/yumc/Yum/manager/NetworkManager.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/pw/yumc/Yum/manager/NetworkManager.java b/src/main/java/pw/yumc/Yum/manager/NetworkManager.java index 21a1cd5..2c7ea01 100644 --- a/src/main/java/pw/yumc/Yum/manager/NetworkManager.java +++ b/src/main/java/pw/yumc/Yum/manager/NetworkManager.java @@ -31,7 +31,7 @@ public class NetworkManager { } public NetworkManager register(final Yum plugin) { - plugin.getLogger().info("注入网络代理 将托管服务器网络!"); + Bukkit.getConsoleSender().sendMessage("§6[§bYum-网络管理§6] §a注入网络管理系统 将托管服务器网络!"); ProxySelector.setDefault(new YumProxySelector(ProxySelector.getDefault(), plugin)); return this; } @@ -46,13 +46,11 @@ public class NetworkManager { class YumProxySelector extends ProxySelector { private final boolean debug; private final boolean allowPrimaryThread; - private final Yum main; private final FileConfig config; private final ProxySelector defaultSelector; private final HashMap pluginMap = new HashMap<>(); public YumProxySelector(final ProxySelector defaultSelector, final Yum plugin) { - this.main = plugin; this.config = plugin.getConfig(); this.defaultSelector = defaultSelector; this.debug = config.getBoolean("NetworkDebug"); @@ -74,15 +72,15 @@ public class NetworkManager { final Plugin plugin = this.getRequestingPlugin(); final String urlinfo = uri.toString(); if (!urlinfo.startsWith("socket") && !urlinfo.toLowerCase().contains("yumc") && !urlinfo.toLowerCase().contains("pom.xml")) { - final String str = debug ? "§6[§bNetDebug§6] §c插件 §6%s §c尝试访问 §e%s §c请注意服务器网络安全!" : "§6[§bNetManager§6] §c插件 §6%s §c尝试在主线程访问 §e%s §4可能会导致服务器卡顿或无响应!"; + final String str = debug ? "§6[§bYum-网络监控§6] §c插件 §6%s §c尝试访问 §e%s §c请注意服务器网络安全!" : "§6[§bYum-网络管理§6] §c插件 §6%s §c尝试在主线程访问 §e%s §4可能会导致服务器卡顿或无响应!"; if (plugin == null) { Bukkit.getConsoleSender().sendMessage(String.format(str, "未知(请查看堆栈)", urlinfo)); Thread.dumpStack(); } else if (!plugin.getName().equalsIgnoreCase("Yum")) { Bukkit.getConsoleSender().sendMessage(String.format(str, plugin.getName(), urlinfo)); if (!allowPrimaryThread) { - Bukkit.getConsoleSender().sendMessage("§6[§bNetManager§6] §4已阻止插件 §b" + plugin.getName() + " §4在主线程访问网络!"); - throwException(new IOException("Yum 已开启网络防护 不允许在主线程访问网络!")); + Bukkit.getConsoleSender().sendMessage("§6[§bYum-网络管理§6] §4已阻止插件 §b" + plugin.getName() + " §4在主线程访问网络!"); + throwException(new IOException("[Yum-网络管理] 已开启网络防护 不允许在主线程访问网络!")); } } }