mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 14:28:46 +00:00
update(NetworkManager.java): 调整拦截提示...
This commit is contained in:
parent
d46dfdf13d
commit
934c4c4be3
@ -74,14 +74,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 ? "[NetDebug] 插件 %s 尝试访问 %s 请注意服务器网络安全!" : "[NetManager] 插件 %s 尝试在主线程访问 %s 可能会导致服务器卡顿或无响应!";
|
||||
final String str = debug ? "§6[§bNetDebug§6] §c插件 §6%s §c尝试访问 §e%s §c请注意服务器网络安全!" : "§6[§bNetManager§6] §c插件 §6%s §c尝试在主线程访问 §e%s §4可能会导致服务器卡顿或无响应!";
|
||||
if (plugin == null) {
|
||||
main.getLogger().warning(String.format(str, "未知(请查看堆栈)", urlinfo));
|
||||
Bukkit.getConsoleSender().sendMessage(String.format(str, "未知(请查看堆栈)", urlinfo));
|
||||
Thread.dumpStack();
|
||||
} else if (!plugin.getName().equalsIgnoreCase("Yum")) {
|
||||
main.getLogger().warning(String.format(str, plugin.getName(), urlinfo));
|
||||
Bukkit.getConsoleSender().sendMessage(String.format(str, plugin.getName(), urlinfo));
|
||||
if (!allowPrimaryThread) {
|
||||
throwException(new IOException("[NetManager] 已阻止插件 " + plugin.getName() + " 在主线程访问网络!"));
|
||||
Bukkit.getConsoleSender().sendMessage("§6[§bNetManager§6] §4已阻止插件 §b" + plugin.getName() + " §4在主线程访问网络!");
|
||||
throwException(new IOException("Yum 已开启网络防护 不允许在主线程访问网络!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,14 +46,14 @@ public class PluginsManager {
|
||||
private final Set<String> ignoreList = new HashSet<>();
|
||||
private final Plugin main;
|
||||
|
||||
public PluginsManager(final Plugin plugin) {
|
||||
this.main = plugin;
|
||||
}
|
||||
|
||||
public static String getVersion(final Plugin plugin) {
|
||||
return StringUtils.substring(plugin.getDescription().getVersion(), 0, 15);
|
||||
}
|
||||
|
||||
public PluginsManager(final Plugin plugin) {
|
||||
this.main = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加到忽略列表
|
||||
*
|
||||
@ -582,7 +582,6 @@ public class PluginsManager {
|
||||
sender.sendMessage("§6卸载: §a从插件查找列表删除 §b" + name + " §a的实例!");
|
||||
}
|
||||
|
||||
if (commandMap != null) {
|
||||
for (final Iterator<Map.Entry<String, Command>> it = knownCommands.entrySet().iterator(); it.hasNext();) {
|
||||
final Map.Entry<String, Command> entry = it.next();
|
||||
if ((entry.getValue() instanceof PluginCommand)) {
|
||||
@ -594,23 +593,11 @@ public class PluginsManager {
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§6卸载: §a注销插件 §b" + name + " §a的所有命令!");
|
||||
}
|
||||
final ClassLoader cl = next.getClass().getClassLoader();
|
||||
try {
|
||||
((URLClassLoader) cl).close();
|
||||
} catch (final IOException ex) {
|
||||
}
|
||||
// ###移除类加载器后会导致插件无法载入###
|
||||
// if (fileAssociations != null) {
|
||||
// for (final Iterator<Entry<Pattern, PluginLoader>> filter = fileAssociations.entrySet().iterator(); filter.hasNext();) {
|
||||
// final Entry<Pattern, PluginLoader> entry = filter.next();
|
||||
// final Matcher match = entry.getKey().matcher(getPluginFile(next).getName());
|
||||
// if (match.find()) {
|
||||
// filter.remove();
|
||||
// sender.sendMessage("§6卸载: §a移除插件 §b" + name + " §a的类加载器!");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
System.gc();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user