mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-12-23 05:08:47 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2d9f428ca1
@ -21,7 +21,6 @@ public class Yum extends JavaPlugin {
|
||||
@Override
|
||||
public void onDisable() {
|
||||
YumAPI.getRepo().cacheToJson(config);
|
||||
config.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,7 +22,7 @@ public class CommandDelete extends BaseCommand {
|
||||
Yum main;
|
||||
|
||||
public CommandDelete(final Yum main) {
|
||||
super("remove");
|
||||
super("d");
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("删除插件");
|
||||
|
@ -29,7 +29,7 @@ public class CommandInstall extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandInstall(final Yum main) {
|
||||
super();
|
||||
super("i");
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("安装插件");
|
||||
|
@ -25,7 +25,7 @@ public class CommandList extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandList(final Yum main) {
|
||||
super();
|
||||
super("l");
|
||||
this.main = main;
|
||||
setDescription("列出已安装插件列表");
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class CommandRepo extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandRepo(final Yum main) {
|
||||
super();
|
||||
super("r");
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("插件源命令");
|
||||
|
@ -20,7 +20,7 @@ public class CommandUpdate extends BaseCommand {
|
||||
Yum main;
|
||||
|
||||
public CommandUpdate(final Yum main) {
|
||||
super();
|
||||
super("u");
|
||||
this.main = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("更新插件");
|
||||
|
@ -19,7 +19,7 @@ public class CommandUpdateAll extends BaseCommand {
|
||||
Yum main;
|
||||
|
||||
public CommandUpdateAll(final Yum main) {
|
||||
super();
|
||||
super("ua");
|
||||
this.main = main;
|
||||
setDescription("更新所有可更新插件");
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class CommandUpgrade extends BaseCommand {
|
||||
* @param name
|
||||
*/
|
||||
public CommandUpgrade(final Yum main) {
|
||||
super();
|
||||
super("ug");
|
||||
this.main = main;
|
||||
setDescription("升级插件");
|
||||
setPossibleArguments("[插件名称]");
|
||||
|
@ -104,7 +104,7 @@ public class DownloadManager {
|
||||
final int fileLength = url.openConnection().getContentLength();
|
||||
if (fileLength < 0) {
|
||||
sender.sendMessage("§6下载: §c文件 " + file.getName() + " 获取长度错误(可能是网络问题)!");
|
||||
sender.sendMessage("§6文件: §c " + file.getName() + " 下载失败!");
|
||||
sender.sendMessage("§6文件: §c" + file.getName() + " 下载失败!");
|
||||
return false;
|
||||
}
|
||||
sender.sendMessage("§6文件长度: §3" + fileLength);
|
||||
|
@ -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();
|
||||
try {
|
||||
@ -602,9 +602,9 @@ public class PluginsManager {
|
||||
updateDirectory = directory;
|
||||
}
|
||||
try {
|
||||
sender.sendMessage("§6升级: §b从 " + updateDirectory.getCanonicalPath() + " 文件夹检索插件插件!");
|
||||
sender.sendMessage("§6升级: §b从 §d" + updateDirectory.getCanonicalPath() + " §b文件夹检索插件插件!");
|
||||
} catch (SecurityException | IOException e1) {
|
||||
sender.sendMessage("§4异常: §c文件夹 " + updateDirectory.getName() + " 权限不足或IO错误!");
|
||||
sender.sendMessage("§4异常: §c文件夹 §d" + updateDirectory.getName() + " §c权限不足或IO错误!");
|
||||
return false;
|
||||
}
|
||||
for (final File file : updateDirectory.listFiles()) {
|
||||
@ -616,9 +616,11 @@ public class PluginsManager {
|
||||
continue;
|
||||
}
|
||||
result = true;
|
||||
sender.sendMessage("§6升级: §a开始升级 " + name + " 插件!");
|
||||
if (!unload(sender, name)) {
|
||||
sender.sendMessage("§6升级: §d开始安装 §b" + name + " §d插件!");
|
||||
FileUtil.copy(file, new File(Bukkit.getUpdateFolderFile().getParentFile(), File.separatorChar + file.getName()));
|
||||
} else {
|
||||
sender.sendMessage("§6升级: §a开始升级 §b" + name + " §a插件!");
|
||||
}
|
||||
load(sender, name);
|
||||
} catch (final InvalidDescriptionException e) {
|
||||
@ -648,7 +650,7 @@ public class PluginsManager {
|
||||
* @return 是否成功
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -6,17 +6,16 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
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.Yum.manager.RepoSerialization.Repositories;
|
||||
|
||||
public class RepoCache {
|
||||
protected static JsonResult jr = JsonResult.newJsonResult();
|
||||
Map<String, PluginInfo> plugins = new HashMap<String, PluginInfo>();
|
||||
Map<String, Repositories> repos = new HashMap<String, Repositories>();
|
||||
|
||||
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) {
|
||||
@ -53,7 +52,7 @@ public class RepoCache {
|
||||
if (json == null || json.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
final Repositories reposes = jr.fromJson(json, Repositories.class);
|
||||
final Repositories reposes = JsonHandler.fromJson(json, Repositories.class);
|
||||
if (reposes == null || reposes.repos.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@ -74,6 +73,6 @@ public class RepoCache {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return jr.toJson(this);
|
||||
return JsonHandler.toJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
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.StringUtil;
|
||||
import cn.citycraft.Yum.manager.RepoSerialization.PackageInfo;
|
||||
@ -29,7 +30,6 @@ import cn.citycraft.Yum.manager.RepoSerialization.Repository;
|
||||
* @author 蒋天蓓
|
||||
*/
|
||||
public class RepositoryManager {
|
||||
JsonResult jr = JsonResult.newJsonResult();
|
||||
org.bukkit.plugin.Plugin main;
|
||||
RepoCache repocache;
|
||||
|
||||
@ -60,8 +60,9 @@ public class RepositoryManager {
|
||||
return updateRepositories(sender, repo);
|
||||
}
|
||||
|
||||
public void cacheToJson(final FileConfiguration config) {
|
||||
public void cacheToJson(final FileConfig config) {
|
||||
config.set("reposcache", repocache.toString());
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void clean() {
|
||||
@ -161,14 +162,14 @@ public class RepositoryManager {
|
||||
|
||||
public PackageInfo jsonToPackage(final String json) {
|
||||
try {
|
||||
return jr.fromJson(json, PackageInfo.class);
|
||||
return JsonHandler.fromJson(json, PackageInfo.class);
|
||||
} catch (final JsonSyntaxException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user