mirror of
				https://e.coding.net/circlecloud/Yum.git
				synced 2025-11-04 13:16:02 +00:00 
			
		
		
		
	@@ -62,14 +62,14 @@ public class PluginsManager {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static boolean deletePlugin(Plugin plugin) {
 | 
					 | 
				
			||||||
		return deletePlugin(Bukkit.getConsoleSender(), plugin);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public static boolean deletePlugin(CommandSender sender, Plugin plugin) {
 | 
						public static boolean deletePlugin(CommandSender sender, Plugin plugin) {
 | 
				
			||||||
		return unload(sender, plugin) && getPluginFile(plugin).delete();
 | 
							return unload(sender, plugin) && getPluginFile(plugin).delete();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static boolean deletePlugin(Plugin plugin) {
 | 
				
			||||||
 | 
							return deletePlugin(Bukkit.getConsoleSender(), plugin);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static void disable(Plugin plugin) {
 | 
						public static void disable(Plugin plugin) {
 | 
				
			||||||
		if ((plugin.isEnabled()) && (plugin != null)) {
 | 
							if ((plugin.isEnabled()) && (plugin != null)) {
 | 
				
			||||||
			Bukkit.getPluginManager().disablePlugin(plugin);
 | 
								Bukkit.getPluginManager().disablePlugin(plugin);
 | 
				
			||||||
@@ -106,8 +106,7 @@ public class PluginsManager {
 | 
				
			|||||||
		ChatColor color = plugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED;
 | 
							ChatColor color = plugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED;
 | 
				
			||||||
		String pluginName = color + plugin.getName();
 | 
							String pluginName = color + plugin.getName();
 | 
				
			||||||
		if (includeVersions) {
 | 
							if (includeVersions) {
 | 
				
			||||||
			pluginName = pluginName + " ("
 | 
								pluginName = pluginName + " (" + plugin.getDescription().getVersion() + ")";
 | 
				
			||||||
					+ plugin.getDescription().getVersion() + ")";
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return pluginName;
 | 
							return pluginName;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -135,8 +134,7 @@ public class PluginsManager {
 | 
				
			|||||||
	public static List<String> getPluginNames(boolean fullName) {
 | 
						public static List<String> getPluginNames(boolean fullName) {
 | 
				
			||||||
		List<String> plugins = new ArrayList<String>();
 | 
							List<String> plugins = new ArrayList<String>();
 | 
				
			||||||
		for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
 | 
							for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
 | 
				
			||||||
			plugins.add(fullName ? plugin.getDescription().getFullName()
 | 
								plugins.add(fullName ? plugin.getDescription().getFullName() : plugin.getName());
 | 
				
			||||||
					: plugin.getName());
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return plugins;
 | 
							return plugins;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -151,15 +149,12 @@ public class PluginsManager {
 | 
				
			|||||||
	public static String getUsages(Plugin plugin) {
 | 
						public static String getUsages(Plugin plugin) {
 | 
				
			||||||
		List<String> parsedCommands = new ArrayList<String>();
 | 
							List<String> parsedCommands = new ArrayList<String>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Map<String, Map<String, Object>> commands = plugin.getDescription()
 | 
							Map<String, Map<String, Object>> commands = plugin.getDescription().getCommands();
 | 
				
			||||||
				.getCommands();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (commands != null) {
 | 
							if (commands != null) {
 | 
				
			||||||
			Iterator<Entry<String, Map<String, Object>>> commandsIt = commands
 | 
								Iterator<Entry<String, Map<String, Object>>> commandsIt = commands.entrySet().iterator();
 | 
				
			||||||
					.entrySet().iterator();
 | 
					 | 
				
			||||||
			while (commandsIt.hasNext()) {
 | 
								while (commandsIt.hasNext()) {
 | 
				
			||||||
				Entry<String, Map<String, Object>> thisEntry = commandsIt
 | 
									Entry<String, Map<String, Object>> thisEntry = commandsIt.next();
 | 
				
			||||||
						.next();
 | 
					 | 
				
			||||||
				if (thisEntry != null) {
 | 
									if (thisEntry != null) {
 | 
				
			||||||
					parsedCommands.add(thisEntry.getKey());
 | 
										parsedCommands.add(thisEntry.getKey());
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
@@ -233,16 +228,13 @@ public class PluginsManager {
 | 
				
			|||||||
		try {
 | 
							try {
 | 
				
			||||||
			target = Bukkit.getPluginManager().loadPlugin(pluginFile);
 | 
								target = Bukkit.getPluginManager().loadPlugin(pluginFile);
 | 
				
			||||||
		} catch (InvalidDescriptionException e) {
 | 
							} catch (InvalidDescriptionException e) {
 | 
				
			||||||
			sender.sendMessage("§c异常: " + e.getMessage() + " 插件: " + name
 | 
								sender.sendMessage("§c异常: " + e.getMessage() + " 插件: " + name + " 的plugin.yml文件存在错误!");
 | 
				
			||||||
					+ " 的plugin.yml文件存在错误!");
 | 
					 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		} catch (InvalidPluginException e) {
 | 
							} catch (InvalidPluginException e) {
 | 
				
			||||||
			sender.sendMessage("§c异常: " + e.getMessage() + " 文件: " + name
 | 
								sender.sendMessage("§c异常: " + e.getMessage() + " 文件: " + name + " 不是一个可载入的插件!");
 | 
				
			||||||
					+ " 不是一个可载入的插件!");
 | 
					 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		} catch (UnknownDependencyException e) {
 | 
							} catch (UnknownDependencyException e) {
 | 
				
			||||||
			sender.sendMessage("§c异常: " + e.getMessage() + " 插件: " + name
 | 
								sender.sendMessage("§c异常: " + e.getMessage() + " 插件: " + name + " 缺少部分依赖项目!");
 | 
				
			||||||
					+ " 缺少部分依赖项目!");
 | 
					 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -260,15 +252,14 @@ public class PluginsManager {
 | 
				
			|||||||
		return load(Bukkit.getConsoleSender(), name);
 | 
							return load(Bukkit.getConsoleSender(), name);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static boolean reload(Plugin plugin) {
 | 
						public static boolean reload(CommandSender sender, Plugin plugin) {
 | 
				
			||||||
		return reload(Bukkit.getConsoleSender(), plugin);
 | 
							if (plugin != null)
 | 
				
			||||||
 | 
								return unload(sender, plugin) && load(sender, plugin);
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static boolean reload(CommandSender sender, Plugin plugin) {
 | 
						public static boolean reload(Plugin plugin) {
 | 
				
			||||||
		if (plugin != null) {
 | 
							return reload(Bukkit.getConsoleSender(), plugin);
 | 
				
			||||||
			return unload(sender, plugin) && load(sender, plugin);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		return false;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static void reloadAll() {
 | 
						public static void reloadAll() {
 | 
				
			||||||
@@ -294,41 +285,31 @@ public class PluginsManager {
 | 
				
			|||||||
		boolean reloadlisteners = true;
 | 
							boolean reloadlisteners = true;
 | 
				
			||||||
		if (pluginManager != null) {
 | 
							if (pluginManager != null) {
 | 
				
			||||||
			try {
 | 
								try {
 | 
				
			||||||
				Field pluginsField = Bukkit.getPluginManager().getClass()
 | 
									Field pluginsField = Bukkit.getPluginManager().getClass().getDeclaredField("plugins");
 | 
				
			||||||
						.getDeclaredField("plugins");
 | 
					 | 
				
			||||||
				pluginsField.setAccessible(true);
 | 
									pluginsField.setAccessible(true);
 | 
				
			||||||
				plugins = (List<Plugin>) pluginsField.get(pluginManager);
 | 
									plugins = (List<Plugin>) pluginsField.get(pluginManager);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				Field lookupNamesField = Bukkit.getPluginManager().getClass()
 | 
									Field lookupNamesField = Bukkit.getPluginManager().getClass().getDeclaredField("lookupNames");
 | 
				
			||||||
						.getDeclaredField("lookupNames");
 | 
					 | 
				
			||||||
				lookupNamesField.setAccessible(true);
 | 
									lookupNamesField.setAccessible(true);
 | 
				
			||||||
				lookupNames = (Map<String, Plugin>) lookupNamesField
 | 
									lookupNames = (Map<String, Plugin>) lookupNamesField.get(pluginManager);
 | 
				
			||||||
						.get(pluginManager);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				try {
 | 
									try {
 | 
				
			||||||
					Field listenersField = Bukkit.getPluginManager().getClass()
 | 
										Field listenersField = Bukkit.getPluginManager().getClass().getDeclaredField("listeners");
 | 
				
			||||||
							.getDeclaredField("listeners");
 | 
					 | 
				
			||||||
					listenersField.setAccessible(true);
 | 
										listenersField.setAccessible(true);
 | 
				
			||||||
					listeners = (Map<Event, SortedSet<RegisteredListener>>) listenersField
 | 
										listeners = (Map<Event, SortedSet<RegisteredListener>>) listenersField.get(pluginManager);
 | 
				
			||||||
							.get(pluginManager);
 | 
					 | 
				
			||||||
				} catch (Exception e) {
 | 
									} catch (Exception e) {
 | 
				
			||||||
					reloadlisteners = false;
 | 
										reloadlisteners = false;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				Field commandMapField = Bukkit.getPluginManager().getClass()
 | 
									Field commandMapField = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
 | 
				
			||||||
						.getDeclaredField("commandMap");
 | 
					 | 
				
			||||||
				commandMapField.setAccessible(true);
 | 
									commandMapField.setAccessible(true);
 | 
				
			||||||
				commandMap = (SimpleCommandMap) commandMapField
 | 
									commandMap = (SimpleCommandMap) commandMapField.get(pluginManager);
 | 
				
			||||||
						.get(pluginManager);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				Field knownCommandsField = SimpleCommandMap.class
 | 
									Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
 | 
				
			||||||
						.getDeclaredField("knownCommands");
 | 
					 | 
				
			||||||
				knownCommandsField.setAccessible(true);
 | 
									knownCommandsField.setAccessible(true);
 | 
				
			||||||
				knownCommands = (Map<String, Command>) knownCommandsField
 | 
									knownCommands = (Map<String, Command>) knownCommandsField.get(commandMap);
 | 
				
			||||||
						.get(commandMap);
 | 
					 | 
				
			||||||
			} catch (Exception e) {
 | 
								} catch (Exception e) {
 | 
				
			||||||
				sender.sendMessage("§c异常: " + e.getMessage() + " 插件 " + name
 | 
									sender.sendMessage("§c异常: " + e.getMessage() + " 插件 " + name + " 卸载失败!");
 | 
				
			||||||
						+ " 卸载失败!");
 | 
					 | 
				
			||||||
				return false;
 | 
									return false;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -343,21 +324,19 @@ public class PluginsManager {
 | 
				
			|||||||
					lookupNames.remove(name);
 | 
										lookupNames.remove(name);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (commandMap != null)
 | 
									if (commandMap != null) {
 | 
				
			||||||
					for (Iterator<Map.Entry<String, Command>> it = knownCommands
 | 
										for (Iterator<Map.Entry<String, Command>> it = knownCommands.entrySet().iterator(); it.hasNext();) {
 | 
				
			||||||
							.entrySet().iterator(); it.hasNext();) {
 | 
					 | 
				
			||||||
						Map.Entry<String, Command> entry = it.next();
 | 
											Map.Entry<String, Command> entry = it.next();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						if ((entry.getValue() instanceof PluginCommand)) {
 | 
											if ((entry.getValue() instanceof PluginCommand)) {
 | 
				
			||||||
							PluginCommand command = (PluginCommand) entry
 | 
												PluginCommand command = (PluginCommand) entry.getValue();
 | 
				
			||||||
									.getValue();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
							if (command.getPlugin() == next) {
 | 
												if (command.getPlugin() == next) {
 | 
				
			||||||
								command.unregister(commandMap);
 | 
													command.unregister(commandMap);
 | 
				
			||||||
								it.remove();
 | 
													it.remove();
 | 
				
			||||||
							}
 | 
												}
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (listeners != null && reloadlisteners) {
 | 
							if (listeners != null && reloadlisteners) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,9 @@
 | 
				
			|||||||
name: ${project.artifactId}
 | 
					name: ${project.artifactId}
 | 
				
			||||||
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
 | 
					main: ${project.groupId}.${project.artifactId}.${project.artifactId}
 | 
				
			||||||
version: ${project.version}
 | 
					version: ${project.version}
 | 
				
			||||||
auther: 喵♂呜
 | 
					auther: 喵♂呜
 | 
				
			||||||
website: http://ci.citycraft.cn:8800/jenkins/job/${project.artifactId}/
 | 
					website: http://ci.citycraft.cn:8800/jenkins/job/${project.artifactId}/
 | 
				
			||||||
commands:
 | 
					commands:
 | 
				
			||||||
  yum:
 | 
					  yum:
 | 
				
			||||||
    description: MC插件仓库
 | 
					    description: MC插件仓库
 | 
				
			||||||
    usage: §6使用§a/yum help§6查看帮助!
 | 
					    usage: §6使用§a/yum help§6查看帮助!
 | 
				
			||||||
		Reference in New Issue
	
	Block a user