mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 14:28:46 +00:00
Release Version...
This commit is contained in:
parent
383448d8d6
commit
2dfe5cedb6
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
<artifactId>Yum</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<version>1.4</version>
|
||||
<name>Yum</name>
|
||||
<description>Minecraft 服务器插件管理系统</description>
|
||||
<build>
|
||||
|
@ -32,7 +32,7 @@ public class CommandRepo extends BaseCommand {
|
||||
switch (cmd) {
|
||||
case "add":
|
||||
if (args.length == 2) {
|
||||
if (YumManager.repo.addRepositories(args[1]))
|
||||
if (YumManager.repo.addRepositories(sender, args[1]))
|
||||
sender.sendMessage("§6仓库: §a插件信息已缓存!");
|
||||
else
|
||||
sender.sendMessage("§6仓库: §c源地址未找到仓库信息或无法访问!");
|
||||
|
40
src/main/java/cn/citycraft/Yum/manager/Repositories.java
Normal file
40
src/main/java/cn/citycraft/Yum/manager/Repositories.java
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.Yum.manager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 源仓库序列化类
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月31日下午7:41:53
|
||||
*/
|
||||
public class Repositories {
|
||||
public class PackageInfo {
|
||||
public String name;
|
||||
public String url;
|
||||
public List<Plugin> plugins = new ArrayList<>();
|
||||
}
|
||||
|
||||
public class Plugin {
|
||||
public String groupId;
|
||||
public String artifactId;
|
||||
public String description;
|
||||
public String version;
|
||||
public List<TagInfo> tags;
|
||||
}
|
||||
|
||||
public class Repository {
|
||||
public String id;
|
||||
public String url;
|
||||
public String type;
|
||||
}
|
||||
|
||||
public class TagInfo {
|
||||
public String tag;
|
||||
public String version;
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
@ -20,10 +21,9 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import cn.citycraft.Yum.repository.Package;
|
||||
import cn.citycraft.Yum.repository.Plugin;
|
||||
import cn.citycraft.Yum.repository.PluginInfo;
|
||||
import cn.citycraft.Yum.repository.Repository;
|
||||
import cn.citycraft.Yum.manager.Repositories.PackageInfo;
|
||||
import cn.citycraft.Yum.manager.Repositories.Plugin;
|
||||
import cn.citycraft.Yum.manager.Repositories.Repository;;
|
||||
|
||||
/**
|
||||
* 仓库管理类
|
||||
@ -44,22 +44,22 @@ public class RepositoryManager {
|
||||
repos = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public boolean addPackage(String urlstring) {
|
||||
public boolean addPackage(CommandSender sender, String urlstring) {
|
||||
String json = getHtml(urlstring);
|
||||
if (json == "")
|
||||
return false;
|
||||
Package pkg = jsonToPackage(json);
|
||||
PackageInfo pkg = jsonToPackage(json);
|
||||
if (pkg == null)
|
||||
return false;
|
||||
updatePackage(pkg);
|
||||
updatePackage(sender, pkg);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addRepositories(String urlstring) {
|
||||
public boolean addRepositories(CommandSender sender, String urlstring) {
|
||||
if (urlstring == null || urlstring.isEmpty())
|
||||
return false;
|
||||
repos.add(urlstring);
|
||||
return updateRepositories(urlstring);
|
||||
return updateRepositories(sender, urlstring);
|
||||
}
|
||||
|
||||
public void cacheToJson(FileConfiguration config) {
|
||||
@ -143,9 +143,9 @@ public class RepositoryManager {
|
||||
}
|
||||
}
|
||||
|
||||
public Package jsonToPackage(String json) {
|
||||
public PackageInfo jsonToPackage(String json) {
|
||||
try {
|
||||
return gson.fromJson(json, Package.class);
|
||||
return gson.fromJson(json, PackageInfo.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
return null;
|
||||
}
|
||||
@ -160,7 +160,7 @@ public class RepositoryManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePackage(Package pkg) {
|
||||
public void updatePackage(CommandSender sender, PackageInfo pkg) {
|
||||
for (Plugin plugin : pkg.plugins) {
|
||||
PluginInfo pi = new PluginInfo();
|
||||
pi.plugin = plugin;
|
||||
@ -168,19 +168,22 @@ public class RepositoryManager {
|
||||
pi.repo = pkg.name;
|
||||
plugins.put(plugin.groupId + "." + plugin.artifactId, pi);
|
||||
}
|
||||
sender.sendMessage("仓库: §e" + pkg.name + " §a更新成功!");
|
||||
}
|
||||
|
||||
public boolean updateRepositories(CommandSender sender) {
|
||||
plugins.clear();
|
||||
for (String string : repos)
|
||||
if (updateRepositories(string))
|
||||
if (updateRepositories(sender, string))
|
||||
sender.sendMessage("§6源: §e" + string + " §a更新成功!");
|
||||
else
|
||||
sender.sendMessage("§6源: §e" + string + " §c更新失败!");
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean updateRepositories(String urlstring) {
|
||||
public boolean updateRepositories(CommandSender sender, String urlstring) {
|
||||
if (sender == null)
|
||||
sender = Bukkit.getConsoleSender();
|
||||
if (!urlstring.endsWith("repo.info"))
|
||||
urlstring = urlstring + "/repo.info";
|
||||
String json = getHtml(urlstring);
|
||||
@ -190,7 +193,7 @@ public class RepositoryManager {
|
||||
if (lrepo == null)
|
||||
return false;
|
||||
for (Repository repository : lrepo)
|
||||
addPackage(repository.url);
|
||||
addPackage(sender, repository.url);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cn.citycraft.Yum.repository.PluginInfo;
|
||||
|
||||
/**
|
||||
* 自动更新类
|
||||
*
|
||||
|
@ -1,19 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.Yum.repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月31日下午7:42:22
|
||||
*/
|
||||
public class Package {
|
||||
public String name;
|
||||
public String url;
|
||||
public List<Plugin> plugins = new ArrayList<>();
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.Yum.repository;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月31日下午7:42:54
|
||||
*/
|
||||
public class Plugin {
|
||||
public String groupId;
|
||||
public String artifactId;
|
||||
public String description;
|
||||
public String version;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package cn.citycraft.Yum.repository;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月31日下午7:43:19
|
||||
*/
|
||||
public class PluginInfo {
|
||||
public Plugin plugin;
|
||||
public String url;
|
||||
public String repo;
|
||||
|
||||
public String getMavenUrl() {
|
||||
return getMavenUrl(null);
|
||||
}
|
||||
|
||||
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 == null ? plugin.version : version);
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return String.format("%1$s-%2$s.jar", plugin.artifactId, plugin.version);
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.Yum.repository;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月31日下午7:41:53
|
||||
*/
|
||||
public class Repository {
|
||||
public String id;
|
||||
public String url;
|
||||
public String type;
|
||||
}
|
Loading…
Reference in New Issue
Block a user