mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 14:28:46 +00:00
feat: 添加主线程操作插件检测
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
b3d6a2e6ba
commit
ae621a855e
@ -2,18 +2,23 @@ package pw.yumc.Yum.runnables;
|
|||||||
|
|
||||||
import java.lang.Thread.State;
|
import java.lang.Thread.State;
|
||||||
import java.util.TimerTask;
|
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
|
* @since 2016年6月22日 下午4:57:32
|
||||||
* @author 喵♂呜
|
* @author 喵♂呜
|
||||||
*/
|
*/
|
||||||
public class MainThreadCheckTask extends TimerTask {
|
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;
|
private final Thread mainThread;
|
||||||
|
|
||||||
public MainThreadCheckTask(final Thread mainThread) {
|
public MainThreadCheckTask(final Thread mainThread) {
|
||||||
@ -37,12 +42,22 @@ public class MainThreadCheckTask extends TimerTask {
|
|||||||
if (isElementEqual(topElement, "java.net.DualStackPlainSocketImpl", "connect0")
|
if (isElementEqual(topElement, "java.net.DualStackPlainSocketImpl", "connect0")
|
||||||
|| isElementEqual(topElement, "java.net.SocketInputStream", "socketRead0")
|
|| isElementEqual(topElement, "java.net.SocketInputStream", "socketRead0")
|
||||||
|| isElementEqual(topElement, "java.net.SocketOutputStream", "socketWrite0")) {
|
|| 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 (in) - java.io.FileInputStream.readBytes
|
||||||
// File (out) - java.io.FileOutputStream.writeBytes
|
// File (out) - java.io.FileOutputStream.writeBytes
|
||||||
else if (isElementEqual(topElement, "java.io.FileInputStream", "readBytes") || isElementEqual(topElement, "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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user