添加短命令 修改前台提示...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-12-06 17:29:10 +08:00
parent 751e42ad94
commit ae52cbf22f
12 changed files with 22 additions and 23 deletions

View File

@ -21,7 +21,6 @@ public class Yum extends JavaPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
YumAPI.getRepo().cacheToJson(config); YumAPI.getRepo().cacheToJson(config);
config.save();
} }
@Override @Override

View File

@ -22,7 +22,7 @@ public class CommandDelete extends BaseCommand {
Yum main; Yum main;
public CommandDelete(final Yum main) { public CommandDelete(final Yum main) {
super("remove"); super("d");
this.main = main; this.main = main;
setMinimumArguments(1); setMinimumArguments(1);
setDescription("删除插件"); setDescription("删除插件");

View File

@ -29,7 +29,7 @@ public class CommandInstall extends BaseCommand {
* @param name * @param name
*/ */
public CommandInstall(final Yum main) { public CommandInstall(final Yum main) {
super(); super("i");
this.main = main; this.main = main;
setMinimumArguments(1); setMinimumArguments(1);
setDescription("安装插件"); setDescription("安装插件");

View File

@ -25,7 +25,7 @@ public class CommandList extends BaseCommand {
* @param name * @param name
*/ */
public CommandList(final Yum main) { public CommandList(final Yum main) {
super(); super("l");
this.main = main; this.main = main;
setDescription("列出已安装插件列表"); setDescription("列出已安装插件列表");
} }

View File

@ -29,7 +29,7 @@ public class CommandRepo extends BaseCommand {
* @param name * @param name
*/ */
public CommandRepo(final Yum main) { public CommandRepo(final Yum main) {
super(); super("r");
this.main = main; this.main = main;
setMinimumArguments(1); setMinimumArguments(1);
setDescription("插件源命令"); setDescription("插件源命令");

View File

@ -20,7 +20,7 @@ public class CommandUpdate extends BaseCommand {
Yum main; Yum main;
public CommandUpdate(final Yum main) { public CommandUpdate(final Yum main) {
super(); super("u");
this.main = main; this.main = main;
setMinimumArguments(1); setMinimumArguments(1);
setDescription("更新插件"); setDescription("更新插件");

View File

@ -19,7 +19,7 @@ public class CommandUpdateAll extends BaseCommand {
Yum main; Yum main;
public CommandUpdateAll(final Yum main) { public CommandUpdateAll(final Yum main) {
super(); super("ua");
this.main = main; this.main = main;
setDescription("更新所有可更新插件"); setDescription("更新所有可更新插件");
} }

View File

@ -23,7 +23,7 @@ public class CommandUpgrade extends BaseCommand {
* @param name * @param name
*/ */
public CommandUpgrade(final Yum main) { public CommandUpgrade(final Yum main) {
super(); super("ug");
this.main = main; this.main = main;
setDescription("升级插件"); setDescription("升级插件");
setPossibleArguments("[插件名称]"); setPossibleArguments("[插件名称]");

View File

@ -544,7 +544,7 @@ public class PluginsManager {
} }
} }
} }
sender.sendMessage("§6卸载: §a注销插件 " + name + " 的所有命令!"); sender.sendMessage("§6卸载: §a注销插件 §b" + name + " §a的所有命令!");
} }
final ClassLoader cl = next.getClass().getClassLoader(); final ClassLoader cl = next.getClass().getClassLoader();
try { try {
@ -602,9 +602,9 @@ public class PluginsManager {
updateDirectory = directory; updateDirectory = directory;
} }
try { try {
sender.sendMessage("§6升级: §b从 " + updateDirectory.getCanonicalPath() + " 文件夹检索插件插件!"); sender.sendMessage("§6升级: §b从 §d" + updateDirectory.getCanonicalPath() + " §b文件夹检索插件插件!");
} catch (SecurityException | IOException e1) { } catch (SecurityException | IOException e1) {
sender.sendMessage("§4异常: §c文件夹 " + updateDirectory.getName() + " 权限不足或IO错误!"); sender.sendMessage("§4异常: §c文件夹 §d" + updateDirectory.getName() + " §c权限不足或IO错误!");
return false; return false;
} }
for (final File file : updateDirectory.listFiles()) { for (final File file : updateDirectory.listFiles()) {
@ -650,7 +650,7 @@ public class PluginsManager {
* @return 是否成功 * @return 是否成功
*/ */
public boolean upgrade(final File directory) { public boolean upgrade(final File directory) {
Bukkit.getConsoleSender().sendMessage("§6升级: §a开始升级 " + directory.getName() + " 目录下的所有插件!"); Bukkit.getConsoleSender().sendMessage("§6升级: §a开始升级 §d" + directory.getName() + " §a目录下的所有插件!");
return upgrade(Bukkit.getConsoleSender(), directory, null); return upgrade(Bukkit.getConsoleSender(), directory, null);
} }
} }

View File

@ -6,17 +6,16 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import cn.citycraft.PluginHelper.jsonresult.JsonResult; import cn.citycraft.PluginHelper.jsonresult.JsonHandler;
import cn.citycraft.PluginHelper.utils.IOUtil; import cn.citycraft.PluginHelper.utils.IOUtil;
import cn.citycraft.Yum.manager.RepoSerialization.Repositories; import cn.citycraft.Yum.manager.RepoSerialization.Repositories;
public class RepoCache { public class RepoCache {
protected static JsonResult jr = JsonResult.newJsonResult();
Map<String, PluginInfo> plugins = new HashMap<String, PluginInfo>(); Map<String, PluginInfo> plugins = new HashMap<String, PluginInfo>();
Map<String, Repositories> repos = new HashMap<String, Repositories>(); Map<String, Repositories> repos = new HashMap<String, Repositories>();
public static RepoCache fromJson(final String json) { public static RepoCache fromJson(final String json) {
return jr.fromJson(json, RepoCache.class); return JsonHandler.fromJson(json, RepoCache.class);
} }
public void addPlugins(final String name, final PluginInfo info) { public void addPlugins(final String name, final PluginInfo info) {
@ -53,7 +52,7 @@ public class RepoCache {
if (json == null || json.isEmpty()) { if (json == null || json.isEmpty()) {
return null; return null;
} }
final Repositories reposes = jr.fromJson(json, Repositories.class); final Repositories reposes = JsonHandler.fromJson(json, Repositories.class);
if (reposes == null || reposes.repos.isEmpty()) { if (reposes == null || reposes.repos.isEmpty()) {
return null; return null;
} }
@ -74,6 +73,6 @@ public class RepoCache {
@Override @Override
public String toString() { public String toString() {
return jr.toJson(this); return JsonHandler.toJson(this);
} }
} }

View File

@ -15,7 +15,8 @@ import org.bukkit.configuration.file.FileConfiguration;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import cn.citycraft.PluginHelper.jsonresult.JsonResult; import cn.citycraft.PluginHelper.config.FileConfig;
import cn.citycraft.PluginHelper.jsonresult.JsonHandler;
import cn.citycraft.PluginHelper.utils.IOUtil; import cn.citycraft.PluginHelper.utils.IOUtil;
import cn.citycraft.PluginHelper.utils.StringUtil; import cn.citycraft.PluginHelper.utils.StringUtil;
import cn.citycraft.Yum.manager.RepoSerialization.PackageInfo; import cn.citycraft.Yum.manager.RepoSerialization.PackageInfo;
@ -29,7 +30,6 @@ import cn.citycraft.Yum.manager.RepoSerialization.Repository;
* @author 蒋天蓓 * @author 蒋天蓓
*/ */
public class RepositoryManager { public class RepositoryManager {
JsonResult jr = JsonResult.newJsonResult();
org.bukkit.plugin.Plugin main; org.bukkit.plugin.Plugin main;
RepoCache repocache; RepoCache repocache;
@ -60,8 +60,9 @@ public class RepositoryManager {
return updateRepositories(sender, repo); return updateRepositories(sender, repo);
} }
public void cacheToJson(final FileConfiguration config) { public void cacheToJson(final FileConfig config) {
config.set("reposcache", repocache.toString()); config.set("reposcache", repocache.toString());
config.save();
} }
public void clean() { public void clean() {
@ -161,14 +162,14 @@ public class RepositoryManager {
public PackageInfo jsonToPackage(final String json) { public PackageInfo jsonToPackage(final String json) {
try { try {
return jr.fromJson(json, PackageInfo.class); return JsonHandler.fromJson(json, PackageInfo.class);
} catch (final JsonSyntaxException e) { } catch (final JsonSyntaxException e) {
return null; return null;
} }
} }
public Repositories jsonToRepositories(final String json) { public Repositories jsonToRepositories(final String json) {
return jr.fromJson(json, Repositories.class); return JsonHandler.fromJson(json, Repositories.class);
} }
public void updatePackage(final CommandSender sender, final PackageInfo pkg) { public void updatePackage(final CommandSender sender, final PackageInfo pkg) {