mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 14:28:46 +00:00
添加部分API...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
ab14c50c36
commit
0bf5cd6a8b
@ -24,12 +24,18 @@ import cn.citycraft.Yum.manager.RepositoryManager;
|
||||
public class YumAPI {
|
||||
private static DownloadManager download;
|
||||
|
||||
private static Plugin main;
|
||||
|
||||
private static PluginsManager plugman;
|
||||
|
||||
private static RepositoryManager repo;
|
||||
|
||||
protected static Plugin main;
|
||||
|
||||
/**
|
||||
* 初始化Yum管理中心
|
||||
*
|
||||
* @param plugin
|
||||
* - 插件实体
|
||||
*/
|
||||
public YumAPI(final Plugin plugin) {
|
||||
YumAPI.main = plugin;
|
||||
plugman = new PluginsManager(main);
|
||||
@ -86,8 +92,9 @@ public class YumAPI {
|
||||
* @return 是否安装成功
|
||||
*/
|
||||
public static boolean install(final CommandSender sender, final String pluginname, final String url) {
|
||||
if (download.run(sender, url, new File(Bukkit.getUpdateFolderFile().getParentFile(), pluginname + ".jar"))) {
|
||||
return plugman.load(sender, pluginname);
|
||||
final File pluginFile = new File(Bukkit.getUpdateFolderFile().getParentFile(), pluginname + ".jar");
|
||||
if (download.run(sender, url, pluginFile)) {
|
||||
return plugman.load(sender, pluginFile);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -143,18 +150,18 @@ public class YumAPI {
|
||||
* @param pluginname
|
||||
* - 插件名称
|
||||
*/
|
||||
public static void load(final String pluginname) {
|
||||
plugman.load(pluginname);
|
||||
public static void load(final File pluginFile) {
|
||||
plugman.load(pluginFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸载插件
|
||||
* 载入插件
|
||||
*
|
||||
* @param plugin
|
||||
* - 插件实体
|
||||
* @param pluginname
|
||||
* - 插件名称
|
||||
*/
|
||||
public static void reload(final Plugin plugin) {
|
||||
plugman.unload(plugin);
|
||||
public static void load(final String pluginname) {
|
||||
plugman.load(pluginname);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,10 +170,20 @@ public class YumAPI {
|
||||
* @param plugin
|
||||
* - 插件实体
|
||||
*/
|
||||
public static void unload(final Plugin plugin) {
|
||||
public static void reload(final Plugin plugin) {
|
||||
plugman.reload(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸载插件
|
||||
*
|
||||
* @param plugin
|
||||
* - 插件实体
|
||||
*/
|
||||
public static void unload(final Plugin plugin) {
|
||||
plugman.unload(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新插件
|
||||
*
|
||||
|
@ -258,6 +258,44 @@ public class PluginsManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 载入插件
|
||||
*
|
||||
* @param sender
|
||||
* - 命令发送者
|
||||
* @param pluginFile
|
||||
* - 插件文件
|
||||
* @return 是否成功
|
||||
*/
|
||||
public boolean load(final CommandSender sender, final File pluginFile) {
|
||||
Plugin target = null;
|
||||
final String name = pluginFile.getName();
|
||||
try {
|
||||
target = Bukkit.getPluginManager().loadPlugin(pluginFile);
|
||||
} catch (final InvalidDescriptionException e) {
|
||||
sender.sendMessage("§4异常: §c" + e.getMessage());
|
||||
sender.sendMessage("§c插件: " + name + " 的 plugin.yml 文件存在错误!");
|
||||
return false;
|
||||
} catch (final UnsupportedClassVersionError e) {
|
||||
sender.sendMessage("§4异常: §c" + e.getMessage());
|
||||
sender.sendMessage("§c服务器或JAVA的版本低于插件: " + name + " 所需要的版本!!");
|
||||
return false;
|
||||
} catch (final InvalidPluginException e) {
|
||||
sender.sendMessage("§4异常: §c" + e.getMessage());
|
||||
sender.sendMessage("§c文件: " + name + " 不是一个可载入的插件!");
|
||||
return false;
|
||||
} catch (final UnknownDependencyException e) {
|
||||
sender.sendMessage("§4异常: §c服务器未安装必须依赖: " + e.getMessage());
|
||||
sender.sendMessage("§c插件: " + name + " 载入失败 缺少部分依赖项目!");
|
||||
return false;
|
||||
}
|
||||
|
||||
target.onLoad();
|
||||
Bukkit.getPluginManager().enablePlugin(target);
|
||||
sender.sendMessage("§6载入: §a插件 " + name + " 已成功载入到服务器!");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 载入插件
|
||||
*
|
||||
@ -268,7 +306,6 @@ public class PluginsManager {
|
||||
* @return 是否成功
|
||||
*/
|
||||
public boolean load(CommandSender sender, final String name) {
|
||||
Plugin target = null;
|
||||
String filename = null;
|
||||
if (sender == null) {
|
||||
sender = Bukkit.getConsoleSender();
|
||||
@ -304,31 +341,18 @@ public class PluginsManager {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
target = Bukkit.getPluginManager().loadPlugin(pluginFile);
|
||||
} catch (final InvalidDescriptionException e) {
|
||||
sender.sendMessage("§4异常: §c" + e.getMessage());
|
||||
sender.sendMessage("§c插件: " + name + " 的 plugin.yml 文件存在错误!");
|
||||
return false;
|
||||
} catch (final UnsupportedClassVersionError e) {
|
||||
sender.sendMessage("§4异常: §c" + e.getMessage());
|
||||
sender.sendMessage("§c服务器或JAVA的版本低于插件: " + name + " 所需要的版本!!");
|
||||
return false;
|
||||
} catch (final InvalidPluginException e) {
|
||||
sender.sendMessage("§4异常: §c" + e.getMessage());
|
||||
sender.sendMessage("§c文件: " + name + " 不是一个可载入的插件!");
|
||||
return false;
|
||||
} catch (final UnknownDependencyException e) {
|
||||
sender.sendMessage("§4异常: §c服务器未安装必须依赖: " + e.getMessage());
|
||||
sender.sendMessage("§c插件: " + name + " 载入失败 缺少部分依赖项目!");
|
||||
return false;
|
||||
return load(sender, pluginFile);
|
||||
}
|
||||
|
||||
target.onLoad();
|
||||
Bukkit.getPluginManager().enablePlugin(target);
|
||||
sender.sendMessage("§6载入: §a插件 " + name + " 已成功载入到服务器!");
|
||||
return true;
|
||||
/**
|
||||
* 载入插件
|
||||
*
|
||||
* @param pluginFile
|
||||
* - 插件名称
|
||||
* @return 是否成功
|
||||
*/
|
||||
public boolean load(final File pluginFile) {
|
||||
return load(Bukkit.getConsoleSender(), pluginFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user