修复版本精简错误的问题...

Signed-off-by: 502647092 <jtb1@163.com>
dev
502647092 2016-02-19 00:23:52 +08:00
parent 43799a0b24
commit 7278db3bb0
5 changed files with 17 additions and 8 deletions

View File

@ -12,6 +12,7 @@ import org.bukkit.plugin.Plugin;
import cn.citycraft.PluginHelper.commands.BaseCommand;
import cn.citycraft.Yum.Yum;
import cn.citycraft.Yum.api.YumAPI;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
/**
*
@ -35,7 +36,7 @@ public class CommandDelete extends BaseCommand {
final String pluginname = args[0];
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginname);
if (plugin != null) {
final String version = plugin.getDescription().getVersion().substring(0, 15);
final String version = StringUtils.substring(plugin.getDescription().getVersion(), 0, 15);
if (YumAPI.getPlugman().deletePlugin(sender, plugin)) {
sender.sendMessage("§c删除: §a插件 §6" + pluginname + " §a版本 §d" + version + " §a已从服务器卸载并删除!");
} else {

View File

@ -12,6 +12,7 @@ import org.bukkit.plugin.Plugin;
import cn.citycraft.PluginHelper.commands.BaseCommand;
import cn.citycraft.Yum.Yum;
import cn.citycraft.Yum.api.YumAPI;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
/**
*
@ -35,7 +36,7 @@ public class CommandFullDelete extends BaseCommand {
final String pluginname = args[0];
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginname);
if (plugin != null) {
final String version = plugin.getDescription().getVersion().substring(0, 15);
final String version = StringUtils.substring(plugin.getDescription().getVersion(), 0, 15);
if (YumAPI.getPlugman().fullDeletePlugin(sender, plugin)) {
sender.sendMessage("§c删除: §a插件 §6" + pluginname + " §a版本 §d" + version + " §a已从服务器卸载并删除!");
} else {

View File

@ -47,7 +47,7 @@ public class CommandInfo extends BaseCommand {
if (plugin != null) {
final PluginDescriptionFile desc = plugin.getDescription();
sender.sendMessage("§6插件名称: §3" + plugin.getName());
sender.sendMessage("§6插件版本: §3" + desc.getVersion().substring(0, 15));
sender.sendMessage("§6插件版本: §3" + StringUtils.substring(plugin.getDescription().getVersion(), 0, 15));
sender.sendMessage("§6插件作者: §3" + StringUtils.join(desc.getAuthors(), " "));
sender.sendMessage("§6插件描述: §3" + (desc.getDescription() == null ? "无" : desc.getDescription()));
sender.sendMessage("§6插件依赖: §3" + (desc.getDepend().isEmpty() ? "无" : ""));

View File

@ -11,6 +11,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
/**
*
*
@ -138,7 +140,7 @@ public class DownloadManager {
String pVer = null;
try {
final PluginDescriptionFile desc = plugin.getPluginLoader().getPluginDescription(file);
pVer = desc.getVersion().substring(0, 15);
pVer = StringUtils.substring(desc.getVersion(), 0, 15);
} catch (final Exception e) {
pVer = "";
}

View File

@ -15,6 +15,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -44,6 +45,10 @@ public class PluginsManager {
private final Set<String> ignoreList = new HashSet<>();
private final Plugin main;
public static String getVersion(final Plugin plugin) {
return StringUtils.substring(plugin.getDescription().getVersion(), 0, 15);
}
public PluginsManager(final Plugin plugin) {
this.main = plugin;
}
@ -166,7 +171,7 @@ public class PluginsManager {
final ChatColor color = plugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED;
String pluginName = color + plugin.getName();
if (includeVersions) {
pluginName = pluginName + " (" + plugin.getDescription().getVersion().substring(0, 15) + ")";
pluginName = pluginName + " (" + getVersion(plugin) + ")";
}
return pluginName;
}
@ -233,7 +238,7 @@ public class PluginsManager {
public String getPluginVersion(final String name) {
final Plugin plugin = getPluginByName(name);
if ((plugin != null) && (plugin.getDescription() != null)) {
return plugin.getDescription().getVersion().substring(0, 15);
return getVersion(plugin);
}
return null;
}
@ -330,7 +335,7 @@ public class PluginsManager {
}
target.onLoad();
Bukkit.getPluginManager().enablePlugin(target);
sender.sendMessage("§6载入: §a插件 §b" + target.getName() + " §a版本 §d" + target.getDescription().getVersion().substring(0, 15) + " §a已成功载入到服务器!");
sender.sendMessage("§6载入: §a插件 §b" + target.getName() + " §a版本 §d" + getVersion(target) + " §a已成功载入到服务器!");
return true;
}
@ -548,7 +553,7 @@ public class PluginsManager {
if (next.getName().equals(name)) {
pluginManager.disablePlugin(next);
if ((plugins != null) && (plugins.contains(next))) {
pluginVersion = next.getDescription().getVersion().substring(0, 15);
pluginVersion = getVersion(next);
plugins.remove(next);
sender.sendMessage("§6卸载: §a从服务器插件列表删除 §b" + name + " §a的实例!");
}