mirror of
				https://e.coding.net/circlecloud/Yum.git
				synced 2025-11-04 05:06:02 +00:00 
			
		
		
		
	@@ -2,18 +2,23 @@ package pw.yumc.Yum.runnables;
 | 
			
		||||
 | 
			
		||||
import java.lang.Thread.State;
 | 
			
		||||
import java.util.TimerTask;
 | 
			
		||||
import java.util.logging.Level;
 | 
			
		||||
 | 
			
		||||
import cn.citycraft.PluginHelper.kit.PKit;
 | 
			
		||||
import org.bukkit.plugin.Plugin;
 | 
			
		||||
 | 
			
		||||
import cn.citycraft.PluginHelper.kit.PluginKit;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 线程安全检查任务
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * @since 2016年6月22日 下午4:57:32
 | 
			
		||||
 * @author 喵♂呜
 | 
			
		||||
 */
 | 
			
		||||
public class MainThreadCheckTask extends TimerTask {
 | 
			
		||||
 | 
			
		||||
    public String prefix = "§6[§bYum §a线程管理§6] ";
 | 
			
		||||
    public String warnPNet = "§6插件 §b%s §c在主线程进行网络操作 §4服务器处于停止状态...";
 | 
			
		||||
    public String warnPIO = "§6插件 §b%s §c在主线程进行IO操作 §4服务器处于停止状态...";
 | 
			
		||||
    public String warnNet = "§c主线程存在网络操作 §4服务器处于停止状态...";
 | 
			
		||||
    public String warnIO = "§c主线程存在IO操作 §4服务器处于停止状态...";
 | 
			
		||||
    private final Thread mainThread;
 | 
			
		||||
 | 
			
		||||
    public MainThreadCheckTask(final Thread mainThread) {
 | 
			
		||||
@@ -37,12 +42,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")) {
 | 
			
		||||
                    PKit.i().getLogger().log(Level.WARNING, "主线程存在网络操作 服务器处于停止状态...", stackTrace);
 | 
			
		||||
                    final Plugin plugin = PluginKit.getOperatePlugin(stackTrace);
 | 
			
		||||
                    if (plugin != null) {
 | 
			
		||||
                        PluginKit.sc(String.format(prefix + warnPNet, plugin.getName()));
 | 
			
		||||
                    } else {
 | 
			
		||||
                        PluginKit.sc(prefix + warnNet);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                // 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")) {
 | 
			
		||||
                    PKit.i().getLogger().log(Level.WARNING, "主线程存在IO操作 服务器处于停止状态...", stackTrace);
 | 
			
		||||
                    final Plugin plugin = PluginKit.getOperatePlugin(stackTrace);
 | 
			
		||||
                    if (plugin != null) {
 | 
			
		||||
                        PluginKit.sc(String.format(prefix + warnPIO, plugin.getName()));
 | 
			
		||||
                    } else {
 | 
			
		||||
                        PluginKit.sc(prefix + warnIO);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user