add update force version...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-09-01 15:42:53 +08:00
parent add505cc69
commit 8f8e3b3465
2 changed files with 17 additions and 4 deletions

View File

@ -26,7 +26,7 @@ public class CommandUpdate extends BaseCommand {
} }
@Override @Override
public void execute(final CommandSender sender, String label, String[] args) throws CommandException { public void execute(final CommandSender sender, String label, final String[] args) throws CommandException {
final String pluginname = args[0]; final String pluginname = args[0];
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginname); final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginname);
sender.sendMessage("§a开始更新插件: " + pluginname); sender.sendMessage("§a开始更新插件: " + pluginname);
@ -35,13 +35,21 @@ public class CommandUpdate extends BaseCommand {
@Override @Override
public void run() { public void run() {
PluginInfo pi = main.repo.getPlugin(pluginname); PluginInfo pi = main.repo.getPlugin(pluginname);
if (pi != null) if (pi != null) {
if (main.download.run(sender, pi.getMavenUrl(), main.plugman.getPluginFile(plugin))) { String fileurl;
if (args.length < 2) {
fileurl = pi.getMavenUrl();
} else {
fileurl = pi.getMavenUrl(args[1]);
}
if (main.download.run(sender, fileurl, main.plugman.getPluginFile(plugin))) {
if (main.plugman.unload(sender, plugin)) { if (main.plugman.unload(sender, plugin)) {
main.plugman.load(sender, pluginname); main.plugman.load(sender, pluginname);
} }
} }
} }
}
}); });
} else { } else {
sender.sendMessage("§c插件未安装或已卸载 需要安装请使用yum install " + pluginname + "!"); sender.sendMessage("§c插件未安装或已卸载 需要安装请使用yum install " + pluginname + "!");
@ -55,7 +63,7 @@ public class CommandUpdate extends BaseCommand {
@Override @Override
public String getPossibleArguments() { public String getPossibleArguments() {
return "<插件名称>"; return "<插件名称> <插件版本>";
} }
@Override @Override

View File

@ -16,6 +16,11 @@ public class PluginInfo {
plugin.artifactId, plugin.version); plugin.artifactId, plugin.version);
} }
public String getMavenUrl(String version) {
return String.format(url + (url.endsWith("/") ? "" : "/") + "%1$s/%2$s/%3$s/%2$s-%3$s.jar", plugin.groupId.replace(".", "/"),
plugin.artifactId, version);
}
public String getFileName() { public String getFileName() {
return String.format("%1$s-%2$s.jar", plugin.artifactId, plugin.version); return String.format("%1$s-%2$s.jar", plugin.artifactId, plugin.version);
} }