Close plugins internally when reloading them instead of externally
This commit is contained in:
parent
a0e0072f12
commit
4b6008299b
6 changed files with 23 additions and 26 deletions
|
|
@ -195,9 +195,8 @@ public class CommandServerUtils extends BaseCommand {
|
|||
@CommandPermission("serverutils.reloadplugin")
|
||||
@Description("Reloads a specified plugin.")
|
||||
public void onReloadPlugin(CommandSender sender, String pluginName) {
|
||||
CloseableResult result = BukkitPluginManager.get().reloadPlugin(pluginName);
|
||||
result.getResult().sendTo(BukkitUtils.wrap(sender), "reload", pluginName);
|
||||
result.tryClose();
|
||||
Result result = BukkitPluginManager.get().reloadPlugin(pluginName);
|
||||
result.sendTo(BukkitUtils.wrap(sender), "reload", pluginName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -179,9 +179,9 @@ public class BukkitPluginManager extends AbstractPluginManager<Plugin> {
|
|||
* @return The result of the reload.
|
||||
*/
|
||||
@Override
|
||||
public CloseableResult reloadPlugin(String pluginName) {
|
||||
public Result reloadPlugin(String pluginName) {
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(pluginName);
|
||||
if (plugin == null) return new CloseableResult(Result.NOT_EXISTS);
|
||||
if (plugin == null) return Result.NOT_EXISTS;
|
||||
return reloadPlugin(plugin);
|
||||
}
|
||||
|
||||
|
|
@ -191,21 +191,22 @@ public class BukkitPluginManager extends AbstractPluginManager<Plugin> {
|
|||
* @return The result of the reload.
|
||||
*/
|
||||
@Override
|
||||
public CloseableResult reloadPlugin(Plugin plugin) {
|
||||
public Result reloadPlugin(Plugin plugin) {
|
||||
Result disableResult = disablePlugin(plugin);
|
||||
if (disableResult != Result.SUCCESS && disableResult != Result.ALREADY_DISABLED) {
|
||||
return new CloseableResult(disableResult);
|
||||
return disableResult;
|
||||
}
|
||||
|
||||
CloseableResult result = unloadPlugin(plugin);
|
||||
if (result.getResult() != Result.SUCCESS) return result;
|
||||
if (result.getResult() != Result.SUCCESS) return result.getResult();
|
||||
result.tryClose();
|
||||
|
||||
File pluginFile = getPluginFile(plugin.getName());
|
||||
if (pluginFile == null) return result.set(Result.FILE_DELETED);
|
||||
if (pluginFile == null) return Result.FILE_DELETED;
|
||||
|
||||
BukkitLoadResult loadResult = loadPlugin(pluginFile);
|
||||
if (!loadResult.isSuccess()) return result.set(loadResult.getResult());
|
||||
return result.set(enablePlugin(loadResult.get()));
|
||||
if (!loadResult.isSuccess()) return loadResult.getResult();
|
||||
return enablePlugin(loadResult.get());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue