mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-12-23 05:08:47 +00:00
add YumApi...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
f1b5551cf2
commit
88cec09019
@ -3,6 +3,13 @@
|
||||
*/
|
||||
package cn.citycraft.Yum.api;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cn.citycraft.Yum.manager.YumManager;
|
||||
|
||||
/**
|
||||
* Yum仓库插件API
|
||||
*
|
||||
@ -10,5 +17,7 @@ package cn.citycraft.Yum.api;
|
||||
* @since 2015年8月22日下午4:43:41
|
||||
*/
|
||||
public class YumApi {
|
||||
|
||||
public static boolean update(final CommandSender sender, final Plugin plugin, final URL url, final String version) {
|
||||
return YumManager.update(sender, plugin, url, version);
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class DownloadManager {
|
||||
fout.write(data, 0, count);
|
||||
final int percent = (int) (downloaded * 100L / fileLength);
|
||||
if (percent % 10 == 0) {
|
||||
if (fileLength < 102400 || System.currentTimeMillis() - time > 1000) {
|
||||
if (System.currentTimeMillis() - time > 500) {
|
||||
sender.sendMessage(String.format("§6已下载: §a" + getPer(percent / 10) + " %s%%", percent));
|
||||
time = System.currentTimeMillis();
|
||||
}
|
||||
|
@ -141,11 +141,11 @@ public class RepositoryManager {
|
||||
final String repocache = config.getString("repocache");
|
||||
final String plugincache = config.getString("plugincache");
|
||||
try {
|
||||
if (!repocache.isEmpty()) {
|
||||
if (repocache != null && !repocache.isEmpty()) {
|
||||
repos = gson.fromJson(repocache, new TypeToken<List<String>>() {
|
||||
}.getType());
|
||||
}
|
||||
if (!plugincache.isEmpty()) {
|
||||
if (plugincache != null && !plugincache.isEmpty()) {
|
||||
plugins = gson.fromJson(plugincache, new TypeToken<HashMap<String, PluginInfo>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.citycraft.Yum.manager;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -56,4 +57,12 @@ public class YumManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean update(final CommandSender sender, final Plugin plugin, final URL url, final String version) {
|
||||
if (download.run(sender, url, new File(Bukkit.getUpdateFolderFile(), plugman.getPluginFile(plugin).getName()))) {
|
||||
sender.sendMessage("§6更新: §a已下载插件 " + plugin.getName() + " 到update文件夹 重启后自动更新(或使用upgrade直接升级)!");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user