mirror of
				https://e.coding.net/circlecloud/Yum.git
				synced 2025-11-04 05:06:02 +00:00 
			
		
		
		
	@@ -26,6 +26,7 @@ import cn.citycraft.PluginHelper.commands.InvokeSubCommand;
 | 
			
		||||
import cn.citycraft.PluginHelper.utils.StrKit;
 | 
			
		||||
import pw.yumc.Yum.Yum;
 | 
			
		||||
import pw.yumc.Yum.api.YumAPI;
 | 
			
		||||
import pw.yumc.Yum.managers.ConfigManager;
 | 
			
		||||
import pw.yumc.Yum.managers.PluginsManager;
 | 
			
		||||
import pw.yumc.Yum.managers.RepositoryManager;
 | 
			
		||||
import pw.yumc.Yum.models.RepoSerialization.Repositories;
 | 
			
		||||
@@ -207,9 +208,13 @@ public class YumCommand implements HandlerCommands, Listener {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @HandlerCommand(name = "reload", aliases = { "re" }, minimumArguments = 1, description = "重载插件", possibleArguments = "<插件名称|all|*>")
 | 
			
		||||
    @HandlerCommand(name = "reload", aliases = { "re" }, description = "重载插件", possibleArguments = "<插件名称|all|*>")
 | 
			
		||||
    public void reload(final InvokeCommandEvent e) {
 | 
			
		||||
        final CommandSender sender = e.getSender();
 | 
			
		||||
        if (e.getArgs().length == 0) {
 | 
			
		||||
            ConfigManager.i().reload();
 | 
			
		||||
            sender.sendMessage("§6重载: §a配置文件已重载!");
 | 
			
		||||
        }
 | 
			
		||||
        final String pluginname = e.getArgs()[0];
 | 
			
		||||
        if (pluginname.equalsIgnoreCase("all") || pluginname.equalsIgnoreCase("*")) {
 | 
			
		||||
            plugman.reloadAll(sender);
 | 
			
		||||
 
 | 
			
		||||
@@ -12,27 +12,45 @@ import pw.yumc.Yum.managers.ConfigManager;
 | 
			
		||||
 | 
			
		||||
public class PluginNetworkListener implements Listener {
 | 
			
		||||
    public String prefix = "§6[§bYum §a网络管理§6] ";
 | 
			
		||||
    public String warnMain = "§c插件 §6%s §c尝试在主线程访问网络 §4可能会导致服务器卡顿或无响应!";
 | 
			
		||||
    public String warn = "§c插件 §6%s §c尝试访问网络 §4请注意服务器网络安全!";
 | 
			
		||||
    public String breaked = "§4已阻止黑名单插件 §b%s §4访问网络!";
 | 
			
		||||
    public String url = "§4地址: %s";
 | 
			
		||||
 | 
			
		||||
    public PluginNetworkListener(final Yum yum) {
 | 
			
		||||
        Bukkit.getPluginManager().registerEvents(this, yum);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void breakNetwork(final PluginNetworkEvent e) {
 | 
			
		||||
        PluginKit.sc(String.format(prefix + breaked, e.getPlugin().getName()));
 | 
			
		||||
        PluginKit.sc(String.format(url, e.getUrl().toString()));
 | 
			
		||||
        e.setCancelled(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onPluginNetworkConect(final PluginNetworkEvent e) {
 | 
			
		||||
        final Plugin plugin = e.getPlugin();
 | 
			
		||||
        final String urlinfo = e.getUrl().toString();
 | 
			
		||||
        if (urlinfo.startsWith("socket")) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (urlinfo.contains("yumc")) {
 | 
			
		||||
            final String 大神你好 = "反编译的大神们我知道你们又要说了这货有后门";
 | 
			
		||||
            大神你好.isEmpty();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        final boolean isPrimaryThread = e.isPrimaryThread();
 | 
			
		||||
        final String str = prefix + (isPrimaryThread ? "§c插件 §6%s §c尝试在主线程访问 §e%s §4可能会导致服务器卡顿或无响应!" : "§c插件 §6%s §c尝试访问 §e%s §c请注意服务器网络安全!");
 | 
			
		||||
        if (plugin != null) {
 | 
			
		||||
            if (ConfigManager.i().getNetworkBlackList().contains(plugin.getName())) {
 | 
			
		||||
                PluginKit.sc(prefix + "§4已阻止黑名单插件 §b" + plugin.getName() + " §4访问网络!");
 | 
			
		||||
                PluginKit.sc(prefix + "§4地址: " + urlinfo);
 | 
			
		||||
                breakNetwork(e);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            PluginKit.sc(String.format(str, plugin.getName(), urlinfo));
 | 
			
		||||
            if (ConfigManager.i().getNetworkIgnoreList().contains(plugin.getName())) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            PluginKit.sc(String.format(prefix + (isPrimaryThread ? warnMain : warn), plugin.getName(), urlinfo));
 | 
			
		||||
            if (!ConfigManager.i().isAllowPrimaryThread() && isPrimaryThread) {
 | 
			
		||||
                PluginKit.sc(prefix + "§4已阻止插件 §b" + plugin.getName() + " §4在主线程访问网络!");
 | 
			
		||||
                e.setCancelled(true);
 | 
			
		||||
                breakNetwork(e);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@ 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.injected.event.SetOpEvent;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -15,22 +16,27 @@ import pw.yumc.injected.event.SetOpEvent;
 | 
			
		||||
 * @author 喵♂呜
 | 
			
		||||
 */
 | 
			
		||||
public class SecurityListener implements Listener {
 | 
			
		||||
    public String warn = "§6[§bYum §a安全系统§6] §c插件 §e%s §c已设置玩家 §a%s §c为OP §4请注意服务器安全!";
 | 
			
		||||
    public String prevent = "§6[§bYum §a安全系统§6] §c黑名单插件 §e%s §c尝试设置玩家 §a%s §c为OP §a安全系统已成功拦截!";
 | 
			
		||||
    private final String prefix = "§6[§bYum §a安全系统§6] ";
 | 
			
		||||
    private final String warn = "§c插件 §e%s §c已设置玩家 §a%s §c为OP §4请注意服务器安全!";
 | 
			
		||||
    private final String prevent = "§c黑名单插件 §e%s §c尝试设置玩家 §a%s §c为OP §a安全系统已成功拦截!";
 | 
			
		||||
 | 
			
		||||
    public SecurityListener(final Yum yum) {
 | 
			
		||||
        Bukkit.getPluginManager().registerEvents(this, yum);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void setop(final SetOpEvent event) {
 | 
			
		||||
    public void setop(final SetOpEvent e) {
 | 
			
		||||
        final Plugin plugin = PluginKit.getOperatePlugin();
 | 
			
		||||
        if (plugin != null) {
 | 
			
		||||
            if (plugin.getName().equalsIgnoreCase("BukkitInjectedTools")) {
 | 
			
		||||
                Bukkit.getConsoleSender().sendMessage(String.format(prevent, plugin, event.getOfflinePlayer().getName()));
 | 
			
		||||
            } else {
 | 
			
		||||
                Bukkit.getConsoleSender().sendMessage(String.format(warn, plugin, event.getOfflinePlayer().getName()));
 | 
			
		||||
            if (ConfigManager.i().getSetOpBlackList().contains(plugin.getName())) {
 | 
			
		||||
                PluginKit.sc(String.format(prefix + prevent, plugin, e.getOfflinePlayer().getName()));
 | 
			
		||||
                e.setCancelled(true);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (ConfigManager.i().getSetOpIgnoreList().contains(plugin.getName())) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            Bukkit.getConsoleSender().sendMessage(String.format(prefix + warn, plugin, e.getOfflinePlayer().getName()));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -53,11 +53,11 @@ public class ConfigManager {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isAllowPrimaryThread() {
 | 
			
		||||
        return config.getBoolean("AllowPrimaryThread", false);
 | 
			
		||||
        return network.getBoolean("AllowPrimaryThread", false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isNetworkDebug() {
 | 
			
		||||
        return config.getBoolean("NetworkDebug", false);
 | 
			
		||||
        return network.getBoolean("NetworkDebug", false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isNetworkEnable() {
 | 
			
		||||
 
 | 
			
		||||
@@ -55,7 +55,7 @@ public class NetworkManager {
 | 
			
		||||
            final PluginNetworkEvent pne = new PluginNetworkEvent(PluginKit.getOperatePlugin(), uri, Bukkit.isPrimaryThread());
 | 
			
		||||
            Bukkit.getPluginManager().callEvent(pne);
 | 
			
		||||
            if (pne.isCancelled()) {
 | 
			
		||||
                ExceptionKit.throwException(new IOException("[Yum 网络防护] 已开启网络防护 不允许在主线程访问网络!"));
 | 
			
		||||
                ExceptionKit.throwException(new IOException("[Yum 网络防护] 已开启网络防护 并被联网规则拦截!"));
 | 
			
		||||
            }
 | 
			
		||||
            return defaultSelector.select(uri);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,12 @@
 | 
			
		||||
Version: 2.1
 | 
			
		||||
#配置版本号 请勿修改!!!
 | 
			
		||||
Version: 2.2
 | 
			
		||||
 | 
			
		||||
#是否只允许控制台执行插件仓库命令
 | 
			
		||||
onlyCommandConsole: false
 | 
			
		||||
#是否只允许控制台执行插件网络管理命令
 | 
			
		||||
onlyNetCommandConsole: false
 | 
			
		||||
#是否只允许控制台执行插件文件管理命令
 | 
			
		||||
onlyFileCommandConsole: true
 | 
			
		||||
#网络调试模式
 | 
			
		||||
NetworkDebug: false
 | 
			
		||||
#是否允许插件主线程访问网络
 | 
			
		||||
AllowPrimaryThread: false
 | 
			
		||||
#禁止rm -rf的文件夹列表
 | 
			
		||||
blacklist:
 | 
			
		||||
- 'plugins'
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,6 @@
 | 
			
		||||
#配置版本号 请勿修改!!!
 | 
			
		||||
Version: 1.0
 | 
			
		||||
 | 
			
		||||
#是否开启
 | 
			
		||||
Enable: true
 | 
			
		||||
#黑名单列表
 | 
			
		||||
@@ -6,4 +9,7 @@ Black:
 | 
			
		||||
- FeatherBoard
 | 
			
		||||
#忽略检测列表
 | 
			
		||||
Ignore:
 | 
			
		||||
- Essentials
 | 
			
		||||
- Essentials
 | 
			
		||||
#URL白名单网址
 | 
			
		||||
WhiteKeyList: 
 | 
			
		||||
- yum
 | 
			
		||||
@@ -1,3 +1,6 @@
 | 
			
		||||
#配置版本号 请勿修改!!!
 | 
			
		||||
Version: 1.0
 | 
			
		||||
 | 
			
		||||
#是否开启
 | 
			
		||||
Enable: true
 | 
			
		||||
#黑名单列表
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user