重载所有插件时忽略部分已注册服务插件...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2016-03-02 20:22:13 +08:00
parent 4480b0fb3d
commit 88e655e6fc
5 changed files with 59 additions and 8 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cn.citycraft</groupId>
<artifactId>Yum</artifactId>
<version>2.0.2</version>
<version>2.0.3</version>
<name>Yum</name>
<description>Minecraft 服务器插件管理系统</description>
<build>
@ -57,9 +57,9 @@
<jenkins.url>http://hs.yumc.pw:8080</jenkins.url>
<update.description>&amp;a全新 2.0 版本 震撼发布...</update.description>
<update.changes>
&amp;b2.0.3 &amp;6- &amp;a重载所有插件时忽略部分已注册服务插件...;
&amp;b2.0.2 &amp;6- &amp;c修复检查可更新插件功能导致全局更新失效问题...;
&amp;b &amp;6- &amp;d新增全局更新限制 无法同时进行 防止错误...;
&amp;b2.0.1 &amp;6- &amp;c插件在upgrade时自动重命名为原有名称...;
</update.changes>
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -40,6 +40,7 @@ public class YumAPI {
plugman = new PluginsManager(main);
download = new DownloadManager(main);
repo = new RepositoryManager(main);
plugman.addIgnore(main.getConfig().getStringList("ignorelist"));
}
/**

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
@ -100,7 +101,12 @@ public class YumCommand implements HandlerCommands, Listener {
final Map<String, Map<String, Object>> clist = desc.getCommands();
if (clist != null) {
sender.sendMessage("§6插件注册命令: §3" + (clist.isEmpty() ? "" : ""));
StringUtil.sendStringArray(sender, clist.keySet(), "§6 - §a");
for (final Entry<String, Map<String, Object>> entry : clist.entrySet()) {
sender.sendMessage("§6 - §a" + entry.getKey());
sendEntry(sender, "§6 描述: §a", entry.getValue(), "description");
sendEntry(sender, "§6 权限: §a", entry.getValue(), "permission");
sendEntry(sender, "§6 用法: §a", entry.getValue(), "usage");
}
}
final List<Permission> plist = desc.getPermissions();
if (plist != null) {
@ -260,6 +266,25 @@ public class YumCommand implements HandlerCommands, Listener {
});
}
/**
* 发生实体消息
*
* @param sender
* 命令发送者
* @param prefix
* 实体前缀
* @param map
* 实体
* @param key
* 实体Key
*/
public void sendEntry(final CommandSender sender, final String prefix, final Map<String, Object> map, final String key) {
final Object value = map.get(key);
if (value != null) {
sender.sendMessage(prefix + (String) value);
}
}
@HandlerCommand(name = "unload", minimumArguments = 1, description = "卸载插件", possibleArguments = "<插件名称>")
public void unload(final InvokeCommandEvent e) {
final String pluginname = e.getArgs()[0];

View File

@ -8,6 +8,7 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -53,6 +54,17 @@ public class PluginsManager {
return StringUtils.substring(plugin.getDescription().getVersion(), 0, 15);
}
/**
* 添加到忽略列表
*
* @param name
* - 插件名称
* @return 是否成功
*/
public boolean addIgnore(final Collection<? extends String> name) {
return ignoreList.addAll(name);
}
/**
* 添加到忽略列表
*
@ -458,18 +470,25 @@ public class PluginsManager {
public void reloadAll() {
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
if (!isIgnored(plugin)) {
reload(plugin);
unload(plugin);
}
}
Bukkit.getPluginManager().loadPlugins(Bukkit.getUpdateFolderFile().getParentFile());
}
/**
* 重载所有插件
*/
public void reloadAll(final CommandSender sender) {
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
final Plugin[] plist = Bukkit.getPluginManager().getPlugins();
for (final Plugin plugin : plist) {
if (!isIgnored(plugin)) {
reload(sender, plugin);
unload(sender, plugin);
}
}
for (final Plugin plugin : plist) {
if (!isIgnored(plugin)) {
load(sender, plugin.getName());
}
}
}

View File

@ -1,4 +1,4 @@
Version: 1.2
Version: 2.0
#是否只允许控制台执行插件命令
onlyCommandConsole: false
#是否只允许控制台执行插件文件命令
@ -6,4 +6,10 @@ onlyFileCommandConsole: true
#禁止rm -rf的文件夹列表
blacklist:
- 'plugins'
- 'worlds'
- 'worlds'
#全体重载忽略列表(##请不要删除原有插件##)
ignorelist:
- 'Yum'
- 'Vault'
- 'iConomy'
- 'GroupManager'