mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 06:18:46 +00:00
feat: 使用新版本API
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
340d457e41
commit
277f42bd2e
@ -12,7 +12,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.CommonData.UpdatePlugin;
|
||||
import cn.citycraft.PluginHelper.ext.kit.Reflect;
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import pw.yumc.Yum.api.YumAPI;
|
||||
import pw.yumc.Yum.commands.FileCommand;
|
||||
import pw.yumc.Yum.commands.MonitorCommand;
|
||||
@ -26,6 +25,7 @@ import pw.yumc.Yum.managers.ConfigManager;
|
||||
import pw.yumc.Yum.managers.MonitorManager;
|
||||
import pw.yumc.Yum.managers.NetworkManager;
|
||||
import pw.yumc.Yum.runnables.MainThreadCheckTask;
|
||||
import pw.yumc.YumCore.bukkit.Log;
|
||||
import pw.yumc.YumCore.statistic.Statistics;
|
||||
import pw.yumc.YumCore.update.SubscribeTask;
|
||||
|
||||
@ -108,19 +108,19 @@ public class Yum extends JavaPlugin {
|
||||
throw new ClassNotFoundException();
|
||||
} catch (final NoSuchFieldException | SecurityException e) {
|
||||
new SecurityListener(this);
|
||||
PluginKit.scp("§a安全管理系统已启用...");
|
||||
Log.console("§a安全管理系统已启用...");
|
||||
}
|
||||
} catch (final ClassNotFoundException e) {
|
||||
PluginKit.scp("§c服务端未注入安全拦截器 关闭功能...");
|
||||
Log.console("§c服务端未注入安全拦截器 关闭功能...");
|
||||
}
|
||||
}
|
||||
if (ConfigManager.i().isNetworkEnable()) {
|
||||
new PluginNetworkListener(this);
|
||||
PluginKit.scp("§a网络管理系统已启用...");
|
||||
Log.console("§a网络管理系统已启用...");
|
||||
}
|
||||
if (ConfigManager.i().isThreadSafe()) {
|
||||
new ThreadSafetyListener(this);
|
||||
PluginKit.scp("§a线程管理系统已启用...");
|
||||
Log.console("§a线程管理系统已启用...");
|
||||
}
|
||||
if (ConfigManager.i().isMonitorEnable()) {
|
||||
new PluginListener();
|
||||
@ -133,7 +133,7 @@ public class Yum extends JavaPlugin {
|
||||
private void initRunnable() {
|
||||
// 需要在主线程注册任务
|
||||
if (ConfigManager.i().isMainThreadCheck() && mainThread != null) {
|
||||
PluginKit.scp("§aI O 管理系统已启用...");
|
||||
Log.console("§aI O 管理系统已启用...");
|
||||
if (tt != null) {
|
||||
tt.cancel();
|
||||
}
|
||||
|
@ -11,8 +11,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cn.citycraft.CommonData.UpdatePlugin;
|
||||
import cn.citycraft.PluginHelper.kit.PKit;
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import pw.yumc.Yum.inject.CommandInjector;
|
||||
import pw.yumc.Yum.inject.ListenerInjector;
|
||||
import pw.yumc.Yum.inject.TaskInjector;
|
||||
@ -21,6 +19,8 @@ import pw.yumc.Yum.managers.DownloadManager;
|
||||
import pw.yumc.Yum.managers.PluginsManager;
|
||||
import pw.yumc.Yum.managers.RepositoryManager;
|
||||
import pw.yumc.Yum.models.PluginInfo;
|
||||
import pw.yumc.YumCore.bukkit.P;
|
||||
import pw.yumc.YumCore.kit.PKit;
|
||||
|
||||
/**
|
||||
* Yum管理中心
|
||||
@ -42,7 +42,7 @@ public class YumAPI {
|
||||
* 插件实体
|
||||
*/
|
||||
public YumAPI() {
|
||||
YumAPI.main = PKit.instance;
|
||||
YumAPI.main = P.instance;
|
||||
plugman = new PluginsManager(main);
|
||||
download = new DownloadManager(main);
|
||||
repo = new RepositoryManager(main);
|
||||
@ -321,7 +321,7 @@ public class YumAPI {
|
||||
* 命令发送者
|
||||
*/
|
||||
public static void updateCheck(final CommandSender sender) {
|
||||
PluginKit.runTaskLaterAsync(new Runnable() {
|
||||
PKit.runTaskLaterAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final List<Plugin> ulist = getUpdateList(sender);
|
||||
@ -395,7 +395,7 @@ public class YumAPI {
|
||||
* 更新注入
|
||||
*/
|
||||
public static void updateInject() {
|
||||
PluginKit.runTaskLater(new Runnable() {
|
||||
PKit.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
@ -409,7 +409,7 @@ public class YumAPI {
|
||||
* 更新Yum源数据
|
||||
*/
|
||||
public static void updateRepo(final CommandSender sender) {
|
||||
PluginKit.runTaskAsync(new Runnable() {
|
||||
PKit.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
repo.updateRepositories(sender);
|
||||
|
@ -2,7 +2,12 @@ package pw.yumc.Yum.commands;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -52,7 +57,7 @@ public class FileCommand implements CommandExecutor {
|
||||
@Cmd(aliases = "cp", minimumArguments = 2)
|
||||
@Help(value = "复制文件", possibleArguments = "<源文件> <目标目录>")
|
||||
@Async
|
||||
public void copy(final CommandArgument e) {
|
||||
public void copy(final CommandArgument e) throws FileNotFoundException, IOException {
|
||||
final String[] args = e.getArgs();
|
||||
final CommandSender sender = e.getSender();
|
||||
final File src = new File(args[0]);
|
||||
@ -65,7 +70,7 @@ public class FileCommand implements CommandExecutor {
|
||||
sender.sendMessage(String.format(file_is_dir, args[0]));
|
||||
return;
|
||||
}
|
||||
if (FileUtil.copyFile(src, des)) {
|
||||
if (Files.copy(new FileInputStream(src), des.toPath(), StandardCopyOption.REPLACE_EXISTING) != 0) {
|
||||
sender.sendMessage(String.format(copySuccess, args[0]));
|
||||
} else {
|
||||
sender.sendMessage(String.format(copyFailed, args[0]));
|
||||
|
@ -21,7 +21,6 @@ import org.bukkit.plugin.TimedRegisteredListener;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import cn.citycraft.PluginHelper.ext.kit.Reflect;
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import cn.citycraft.PluginHelper.kit.StrKit;
|
||||
import pw.yumc.Yum.Yum;
|
||||
import pw.yumc.Yum.api.YumAPI;
|
||||
@ -36,6 +35,7 @@ import pw.yumc.YumCore.commands.CommandManager;
|
||||
import pw.yumc.YumCore.commands.annotation.Async;
|
||||
import pw.yumc.YumCore.commands.annotation.Cmd;
|
||||
import pw.yumc.YumCore.commands.annotation.Help;
|
||||
import pw.yumc.YumCore.kit.PKit;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -218,7 +218,7 @@ public class MonitorCommand implements CommandExecutor {
|
||||
sender.sendMessage(no_error);
|
||||
return;
|
||||
}
|
||||
final Plugin plugin = PluginKit.getOperatePlugin(lastError.getStackTrace());
|
||||
final Plugin plugin = PKit.getOperatePlugin(lastError.getStackTrace());
|
||||
sender.sendMessage(String.format(last_error, plugin != null ? plugin.getName() : "未知"));
|
||||
lastError.printStackTrace();
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.callback.CallBack.One;
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import cn.citycraft.PluginHelper.kit.ZipKit;
|
||||
import cn.citycraft.PluginHelper.utils.FileUtil;
|
||||
import cn.citycraft.PluginHelper.utils.IOUtil;
|
||||
@ -38,6 +37,7 @@ import pw.yumc.YumCore.commands.annotation.Async;
|
||||
import pw.yumc.YumCore.commands.annotation.Cmd;
|
||||
import pw.yumc.YumCore.commands.annotation.Help;
|
||||
import pw.yumc.YumCore.commands.annotation.Sort;
|
||||
import pw.yumc.YumCore.kit.PKit;
|
||||
import pw.yumc.YumCore.tellraw.Tellraw;
|
||||
|
||||
/**
|
||||
@ -87,7 +87,7 @@ public class YumCommand implements Listener, CommandExecutor {
|
||||
public void bukkitrepo(final CommandArgument e) {
|
||||
final String[] args = e.getArgs();
|
||||
final CommandSender sender = e.getSender();
|
||||
PluginKit.runTaskAsync(new Runnable() {
|
||||
PKit.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String id = args[1];
|
||||
|
@ -16,7 +16,6 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import cn.citycraft.PluginHelper.ext.kit.Reflect;
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import cn.citycraft.PluginHelper.kit.StrKit;
|
||||
import pw.yumc.Yum.commands.MonitorCommand;
|
||||
import pw.yumc.Yum.managers.MonitorManager;
|
||||
@ -63,7 +62,7 @@ public class CommandInjector implements TabExecutor {
|
||||
}
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
PluginKit.sc(String.format(inject_error, plugin.getName()));
|
||||
MonitorManager.log(String.format(inject_error, plugin.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,12 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import pw.yumc.Yum.api.YumAPI;
|
||||
import pw.yumc.Yum.managers.ConfigManager;
|
||||
import pw.yumc.Yum.managers.MonitorManager;
|
||||
import pw.yumc.YumCore.bukkit.Log;
|
||||
import pw.yumc.YumCore.bukkit.P;
|
||||
import pw.yumc.YumCore.kit.PKit;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -21,7 +22,7 @@ public class PluginListener implements Listener {
|
||||
|
||||
public PluginListener() {
|
||||
Bukkit.getPluginManager().registerEvents(this, P.instance);
|
||||
PluginKit.scp("§a性能监控系统已启用...");
|
||||
Log.console("§a性能监控系统已启用...");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -35,7 +36,7 @@ public class PluginListener implements Listener {
|
||||
return;
|
||||
}
|
||||
MonitorManager.reset(e.getPlugin().getName());
|
||||
PluginKit.runTaskLater(new Runnable() {
|
||||
PKit.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
YumAPI.inject(e.getPlugin());
|
||||
|
@ -5,11 +5,11 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import pw.yumc.Yum.Yum;
|
||||
import pw.yumc.Yum.commands.NetCommand;
|
||||
import pw.yumc.Yum.events.PluginNetworkEvent;
|
||||
import pw.yumc.Yum.managers.ConfigManager;
|
||||
import pw.yumc.YumCore.bukkit.Log;
|
||||
|
||||
public class PluginNetworkListener implements Listener {
|
||||
public String prefix = "§6[§bYum §a网络管理§6] ";
|
||||
@ -24,8 +24,8 @@ public class PluginNetworkListener implements Listener {
|
||||
|
||||
public void breakNetwork(final PluginNetworkEvent e) {
|
||||
if (ConfigManager.i().isNetworkShowInfo()) {
|
||||
PluginKit.sc(String.format(prefix + breaked, e.getPlugin().getName()));
|
||||
PluginKit.sc(String.format(prefix + url, e.getUrl().toString()));
|
||||
Log.console(prefix + breaked, e.getPlugin().getName());
|
||||
Log.console(prefix + url, e.getUrl().toString());
|
||||
}
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@ -55,13 +55,13 @@ public class PluginNetworkListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (e.isPrimaryThread()) {
|
||||
PluginKit.sc(String.format(prefix + warnMain, plugin.getName()));
|
||||
Log.console(prefix + warnMain, plugin.getName());
|
||||
if (!ConfigManager.i().isAllowPrimaryThread()) {
|
||||
breakNetwork(e);
|
||||
}
|
||||
} else {
|
||||
PluginKit.sc(String.format(prefix + warn, plugin.getName()));
|
||||
PluginKit.sc(String.format(prefix + url, urlinfo));
|
||||
Log.console(prefix + warn, plugin.getName());
|
||||
Log.console(prefix + url, urlinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,10 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import pw.yumc.Yum.Yum;
|
||||
import pw.yumc.Yum.managers.ConfigManager;
|
||||
import pw.yumc.YumCore.bukkit.Log;
|
||||
import pw.yumc.YumCore.kit.PKit;
|
||||
import pw.yumc.injected.event.SetOpEvent;
|
||||
|
||||
/**
|
||||
@ -26,10 +27,10 @@ public class SecurityListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void setop(final SetOpEvent e) {
|
||||
final Plugin plugin = PluginKit.getOperatePlugin();
|
||||
final Plugin plugin = PKit.getOperatePlugin();
|
||||
if (plugin != null) {
|
||||
if (ConfigManager.i().getSetOpBlackList().contains(plugin.getName())) {
|
||||
PluginKit.sc(String.format(prefix + prevent, plugin, e.getOfflinePlayer().getName()));
|
||||
Log.console(prefix + prevent, plugin, e.getOfflinePlayer().getName());
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ import org.bukkit.event.world.WorldSaveEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import pw.yumc.Yum.Yum;
|
||||
import pw.yumc.YumCore.kit.PKit;
|
||||
|
||||
/**
|
||||
* Fork From LagMonitor: https://github.com/games647/LagMonitor.git
|
||||
@ -86,7 +86,7 @@ public class ThreadSafetyListener implements Listener {
|
||||
private void checkSafety(final Event eventType) {
|
||||
if (Yum.mainThread != null && Thread.currentThread() != Yum.mainThread && !eventType.isAsynchronous()) {
|
||||
final String eventName = eventType.getEventName();
|
||||
final Plugin plugin = PluginKit.getOperatePlugin();
|
||||
final Plugin plugin = PKit.getOperatePlugin();
|
||||
if (plugin != null) {
|
||||
throw new IllegalAccessError("[Yum 线程安全]: 请勿异步调用一个同步事件 " + eventName + " 操作插件: " + plugin.getName());
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||
import cn.citycraft.PluginHelper.sql.DataBase;
|
||||
import pw.yumc.YumCore.bukkit.P;
|
||||
import pw.yumc.YumCore.config.FileConfig;
|
||||
import pw.yumc.YumCore.sql.DataBase;
|
||||
|
||||
public class ConfigManager {
|
||||
public final static String ENABLE = "Enable";
|
||||
@ -22,11 +22,11 @@ public class ConfigManager {
|
||||
public final FileConfig monitor;
|
||||
|
||||
public ConfigManager(final JavaPlugin plugin) {
|
||||
config = new FileConfig(plugin);
|
||||
setop = new FileConfig(plugin, "setop.yml");
|
||||
network = new FileConfig(plugin, "network.yml");
|
||||
thread = new FileConfig(plugin, "thread.yml");
|
||||
monitor = new FileConfig(plugin, "monitor.yml");
|
||||
config = new FileConfig();
|
||||
setop = new FileConfig("setop.yml");
|
||||
network = new FileConfig("network.yml");
|
||||
thread = new FileConfig("thread.yml");
|
||||
monitor = new FileConfig("monitor.yml");
|
||||
}
|
||||
|
||||
public static ConfigManager i() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package pw.yumc.Yum.managers;
|
||||
|
||||
import cn.citycraft.PluginHelper.sql.DataBase;
|
||||
import cn.citycraft.PluginHelper.sql.KeyValue;
|
||||
import cn.citycraft.PluginHelper.sql.Type;
|
||||
import pw.yumc.YumCore.sql.DataBase;
|
||||
import pw.yumc.YumCore.sql.core.KeyValue;
|
||||
|
||||
public class DataManager {
|
||||
private static DataBase db = ConfigManager.i().getDataBase();
|
||||
|
@ -16,11 +16,11 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.LogKit;
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import pw.yumc.YumCore.bukkit.Log;
|
||||
|
||||
/**
|
||||
* 能耗监控管理
|
||||
*
|
||||
*
|
||||
* @since 2016年7月19日 下午3:55:54
|
||||
* @author 喵♂呜
|
||||
*/
|
||||
@ -65,7 +65,7 @@ public class MonitorManager {
|
||||
if (log_to_file) {
|
||||
elog.logSender(message);
|
||||
} else {
|
||||
PluginKit.sc(message);
|
||||
Log.console(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class MonitorManager {
|
||||
if (log_to_file) {
|
||||
mlog.logSender(message);
|
||||
} else {
|
||||
PluginKit.sc(message);
|
||||
Log.console(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ public class MonitorManager {
|
||||
elog(String.format(errStackTrace, ste.getClassName(), ste.getMethodName(), ste.getFileName(), ste.getLineNumber()));
|
||||
}
|
||||
if (debug) {
|
||||
PluginKit.sc(devInfo);
|
||||
Log.console(devInfo);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -140,8 +140,8 @@ public class MonitorManager {
|
||||
if (oriMap == null || oriMap.isEmpty()) {
|
||||
return oriMap;
|
||||
}
|
||||
final Map<String, Long> sortedMap = new LinkedHashMap<String, Long>();
|
||||
final List<Map.Entry<String, Long>> entryList = new ArrayList<Map.Entry<String, Long>>(oriMap.entrySet());
|
||||
final Map<String, Long> sortedMap = new LinkedHashMap<>();
|
||||
final List<Map.Entry<String, Long>> entryList = new ArrayList<>(oriMap.entrySet());
|
||||
Collections.sort(entryList, new MonitorComparator());
|
||||
final Iterator<Map.Entry<String, Long>> iter = entryList.iterator();
|
||||
Entry<String, Long> tmpEntry = null;
|
||||
|
@ -10,9 +10,9 @@ import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.ExceptionKit;
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import pw.yumc.Yum.Yum;
|
||||
import pw.yumc.Yum.events.PluginNetworkEvent;
|
||||
import pw.yumc.YumCore.kit.PKit;
|
||||
|
||||
/**
|
||||
* 网络代理处理类
|
||||
@ -52,7 +52,7 @@ public class NetworkManager {
|
||||
|
||||
@Override
|
||||
public List<Proxy> select(final URI uri) {
|
||||
final PluginNetworkEvent pne = new PluginNetworkEvent(PluginKit.getOperatePlugin(), uri, Bukkit.isPrimaryThread());
|
||||
final PluginNetworkEvent pne = new PluginNetworkEvent(PKit.getOperatePlugin(), uri, Bukkit.isPrimaryThread());
|
||||
Bukkit.getPluginManager().callEvent(pne);
|
||||
if (pne.isCancelled()) {
|
||||
ExceptionKit.throwException(new IOException("[Yum 网络防护] 已开启网络防护 并被联网规则拦截!"));
|
||||
|
@ -33,8 +33,8 @@ import org.bukkit.plugin.UnknownDependencyException;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.StrKit;
|
||||
import cn.citycraft.PluginHelper.utils.FileUtil;
|
||||
import cn.citycraft.PluginHelper.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* 插件管理类
|
||||
@ -207,7 +207,7 @@ public class PluginsManager {
|
||||
* @return 插件
|
||||
*/
|
||||
public Plugin getPluginByName(final String[] args, final int start) {
|
||||
return getPluginByName(StringUtil.consolidateStrings(args, start));
|
||||
return getPluginByName(StrKit.consolidateStrings(args, start));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -233,7 +233,7 @@ public class PluginsManager {
|
||||
}
|
||||
|
||||
public List<String> getPluginNames(final boolean fullName) {
|
||||
final List<String> plugins = new ArrayList<String>();
|
||||
final List<String> plugins = new ArrayList<>();
|
||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
plugins.add(fullName ? plugin.getDescription().getFullName() : plugin.getName());
|
||||
}
|
||||
@ -263,7 +263,7 @@ public class PluginsManager {
|
||||
* @return 插件命令
|
||||
*/
|
||||
public String getUsages(final Plugin plugin) {
|
||||
final List<String> parsedCommands = new ArrayList<String>();
|
||||
final List<String> parsedCommands = new ArrayList<>();
|
||||
|
||||
final Map<String, Map<String, Object>> commands = plugin.getDescription().getCommands();
|
||||
|
||||
|
@ -14,7 +14,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.HttpKit;
|
||||
import cn.citycraft.PluginHelper.kit.StrKit;
|
||||
import pw.yumc.Yum.models.PluginInfo;
|
||||
import pw.yumc.Yum.models.RepoCache;
|
||||
@ -24,6 +23,7 @@ import pw.yumc.Yum.models.RepoSerialization.Repositories;
|
||||
import pw.yumc.Yum.models.RepoSerialization.Repository;
|
||||
import pw.yumc.Yum.models.RepoSerialization.TagInfo;
|
||||
import pw.yumc.Yum.models.RepoSerialization.URLType;
|
||||
import pw.yumc.YumCore.kit.HttpKit;
|
||||
|
||||
/**
|
||||
* 仓库管理类
|
||||
@ -71,7 +71,7 @@ public class RepositoryManager {
|
||||
}
|
||||
|
||||
public List<PluginInfo> getAllPlugin() {
|
||||
final List<PluginInfo> li = new ArrayList<PluginInfo>();
|
||||
final List<PluginInfo> li = new ArrayList<>();
|
||||
for (final Entry<String, PluginInfo> plugin : repocache.getPlugins().entrySet()) {
|
||||
li.add(plugin.getValue());
|
||||
}
|
||||
@ -79,7 +79,7 @@ public class RepositoryManager {
|
||||
}
|
||||
|
||||
public List<String> getAllPluginName() {
|
||||
final List<String> li = new ArrayList<String>();
|
||||
final List<String> li = new ArrayList<>();
|
||||
for (final Entry<String, PluginInfo> plugin : repocache.getPlugins().entrySet()) {
|
||||
li.add(plugin.getValue().name);
|
||||
}
|
||||
@ -87,7 +87,7 @@ public class RepositoryManager {
|
||||
}
|
||||
|
||||
public List<String> getAllPluginsInfo() {
|
||||
final List<String> li = new ArrayList<String>();
|
||||
final List<String> li = new ArrayList<>();
|
||||
li.add("§d仓库名称 §a插件名称 §e插件描述");
|
||||
for (final Entry<String, PluginInfo> pi : repocache.getPlugins().entrySet()) {
|
||||
final Plugin plugin = pi.getValue().plugin;
|
||||
@ -114,7 +114,7 @@ public class RepositoryManager {
|
||||
}
|
||||
|
||||
public List<PluginInfo> getPluginInfo(final String name) {
|
||||
final List<PluginInfo> li = new ArrayList<PluginInfo>();
|
||||
final List<PluginInfo> li = new ArrayList<>();
|
||||
for (final Entry<String, PluginInfo> plugin : repocache.getPlugins().entrySet()) {
|
||||
if (plugin.getValue().name.equalsIgnoreCase(name)) {
|
||||
li.add(plugin.getValue());
|
||||
|
@ -9,7 +9,7 @@ import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.StrKit;
|
||||
import pw.yumc.YumCore.kit.StrKit;
|
||||
|
||||
public class BukkitDev implements Serializable {
|
||||
public static String HOST = "https://api.curseforge.com";
|
||||
|
@ -5,7 +5,6 @@ import java.io.Serializable;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import cn.citycraft.PluginHelper.PluginHelperLogger;
|
||||
import cn.citycraft.PluginHelper.utils.IOUtil;
|
||||
import pw.yumc.Yum.models.RepoSerialization.Plugin;
|
||||
import pw.yumc.Yum.models.RepoSerialization.TagInfo;
|
||||
@ -95,7 +94,7 @@ public class PluginInfo implements Serializable {
|
||||
String ver = version;
|
||||
if (ver == null) {
|
||||
if (plugin.tags != null) {
|
||||
PluginHelperLogger.getLogger().debug("发现存在TAG标签 开始检索: " + NMSVersion);
|
||||
Log.debug("发现存在TAG标签 开始检索: " + NMSVersion);
|
||||
for (final TagInfo tagInfo : plugin.tags) {
|
||||
if (tagInfo.tag.equalsIgnoreCase(NMSVersion)) {
|
||||
sender.sendMessage("§6版本: §b从Tag标签中获取 §e" + NMSVersion + " §b的最新版本...");
|
||||
|
@ -10,13 +10,13 @@ import java.util.Map.Entry;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import cn.citycraft.PluginHelper.utils.IOUtil;
|
||||
import pw.yumc.Yum.models.RepoSerialization.Repositories;
|
||||
import pw.yumc.YumCore.bukkit.Log;
|
||||
|
||||
public class RepoCache implements Serializable {
|
||||
Map<String, PluginInfo> plugins = new HashMap<String, PluginInfo>();
|
||||
Map<String, Repositories> repos = new HashMap<String, Repositories>();
|
||||
Map<String, PluginInfo> plugins = new HashMap<>();
|
||||
Map<String, Repositories> repos = new HashMap<>();
|
||||
|
||||
public void addPlugins(final String name, final PluginInfo info) {
|
||||
plugins.put(name, info);
|
||||
@ -35,7 +35,7 @@ public class RepoCache implements Serializable {
|
||||
}
|
||||
|
||||
public List<String> getAllRepoInfo() {
|
||||
final List<String> repoinfo = new ArrayList<String>();
|
||||
final List<String> repoinfo = new ArrayList<>();
|
||||
for (final Entry<String, Repositories> repo : repos.entrySet()) {
|
||||
repoinfo.add(String.format("§d仓库: §e%s §6- §3%s", repo.getValue().name, repo.getKey()));
|
||||
}
|
||||
@ -49,12 +49,12 @@ public class RepoCache implements Serializable {
|
||||
public Repositories getRepo(final String repo) {
|
||||
final String json = IOUtil.getData(repo);
|
||||
if (json == null || json.isEmpty()) {
|
||||
PluginKit.sc("§6[§bYum§6] §c源地址获取数据为空 §b" + repo);
|
||||
Log.console("§c源地址获取数据为空 §b" + repo);
|
||||
return null;
|
||||
}
|
||||
final Repositories reposes = new Repositories((JSONObject) JSONValue.parse(json));
|
||||
if (reposes.repos.isEmpty()) {
|
||||
PluginKit.sc("§6[§bYum§6] §c源地址解析Json为空 §b" + repo);
|
||||
Log.console("§c源地址解析Json为空 §b" + repo);
|
||||
return null;
|
||||
}
|
||||
return reposes;
|
||||
|
@ -5,8 +5,9 @@ import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import cn.citycraft.PluginHelper.kit.ServerKit;
|
||||
import pw.yumc.YumCore.bukkit.Log;
|
||||
import pw.yumc.YumCore.kit.PKit;
|
||||
|
||||
/**
|
||||
* 线程安全检查任务
|
||||
@ -45,22 +46,22 @@ public class MainThreadCheckTask extends TimerTask {
|
||||
if (isElementEqual(topElement, "java.net.DualStackPlainSocketImpl", "connect0")
|
||||
|| isElementEqual(topElement, "java.net.SocketInputStream", "socketRead0")
|
||||
|| isElementEqual(topElement, "java.net.SocketOutputStream", "socketWrite0")) {
|
||||
final Plugin plugin = PluginKit.getOperatePlugin(stackTrace);
|
||||
final Plugin plugin = PKit.getOperatePlugin(stackTrace);
|
||||
if (plugin != null) {
|
||||
PluginKit.sc(String.format(prefix + warnPNet, plugin.getName()));
|
||||
Log.console(prefix + warnPNet, plugin.getName());
|
||||
} else {
|
||||
PluginKit.sc(prefix + warnNet);
|
||||
Log.console(prefix + warnNet);
|
||||
}
|
||||
tick();
|
||||
}
|
||||
// File (in) - java.io.FileInputStream.readBytes
|
||||
// File (out) - java.io.FileOutputStream.writeBytes
|
||||
else if (isElementEqual(topElement, "java.io.FileInputStream", "readBytes") || isElementEqual(topElement, "java.io.FileOutputStream", "writeBytes")) {
|
||||
final Plugin plugin = PluginKit.getOperatePlugin(stackTrace);
|
||||
final Plugin plugin = PKit.getOperatePlugin(stackTrace);
|
||||
if (plugin != null) {
|
||||
PluginKit.sc(String.format(prefix + warnPIO, plugin.getName()));
|
||||
Log.console(prefix + warnPIO, plugin.getName());
|
||||
} else {
|
||||
PluginKit.sc(prefix + warnIO);
|
||||
Log.console(prefix + warnIO);
|
||||
}
|
||||
tick();
|
||||
} else {
|
||||
@ -79,7 +80,7 @@ public class MainThreadCheckTask extends TimerTask {
|
||||
private void tick() {
|
||||
stopTime += 5;
|
||||
if (stopTime >= 45) {
|
||||
PluginKit.sc(String.format(prefix + deliver, stopTime));
|
||||
Log.console(prefix + deliver, stopTime);
|
||||
ServerKit.tick();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user