mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-10-31 20:28:47 +00:00
feat: 暂时取消部分线程安全检测
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
5491119c73
commit
60c08f0aca
5
pom.xml
5
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>Yum</artifactId>
|
||||
<version>2.7.5</version>
|
||||
<version>2.7.6</version>
|
||||
<name>Yum</name>
|
||||
<description>Minecraft 服务器插件管理系统</description>
|
||||
<build>
|
||||
@ -66,10 +66,9 @@
|
||||
<update.description>§a全新 2.X 版本 更多守护与优化</update.description>
|
||||
<update.changes>
|
||||
§c注意 §6- §aYum更新需要§d重启服务器!§c重启服务器!§4重启服务器!;
|
||||
§b2.7.6 §6- §c暂时取消部分线程安全检测§4(不稳定)...;
|
||||
§b2.7.5 §6- §c修复§eBukkitDev§e下载为空时的异常...;
|
||||
§b2.7.4 §6- §e异步记录服务器报错与耗时操作 §a性能优化...;
|
||||
§b2.7.3 §6- §a调整lag判断条件 减少高峰期误报...;
|
||||
§b2.7.2 §6- §c修复mi lag命令参数错误报错 §d百分比显示能耗...;
|
||||
</update.changes>
|
||||
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -1,98 +1,96 @@
|
||||
package pw.yumc.Yum.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Fork From LagMonitor: https://github.com/games647/LagMonitor.git
|
||||
* We can listen to events which are intended to run sync to the main thread.
|
||||
* If those events are fired on a async task the operation was likely not thread-safe.
|
||||
*/
|
||||
public class ThreadSafetyListener implements Listener {
|
||||
|
||||
public ThreadSafetyListener(final Yum yum) {
|
||||
Bukkit.getPluginManager().registerEvents(this, yum);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkLoad(final ChunkLoadEvent chunkLoadEvent) {
|
||||
checkSafety(chunkLoadEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkUnload(final ChunkUnloadEvent chunkUnloadEvent) {
|
||||
checkSafety(chunkUnloadEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCreatureSpawn(final CreatureSpawnEvent creatureSpawnEvent) {
|
||||
checkSafety(creatureSpawnEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryOpen(final InventoryOpenEvent inventoryOpenEvent) {
|
||||
checkSafety(inventoryOpenEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemSpawn(final ItemSpawnEvent itemSpawnEvent) {
|
||||
checkSafety(itemSpawnEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(final PlayerMoveEvent moveEvent) {
|
||||
checkSafety(moveEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(final PlayerQuitEvent quitEvent) {
|
||||
checkSafety(quitEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent teleportEvent) {
|
||||
checkSafety(teleportEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(final WorldLoadEvent worldLoadEvent) {
|
||||
checkSafety(worldLoadEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldSave(final WorldSaveEvent worldSaveEvent) {
|
||||
checkSafety(worldSaveEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldUnload(final WorldUnloadEvent worldUnloadEvent) {
|
||||
checkSafety(worldUnloadEvent);
|
||||
}
|
||||
|
||||
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();
|
||||
if (plugin != null) {
|
||||
throw new IllegalAccessError("[Yum 线程安全]: 请勿异步调用一个同步事件 " + eventName + " 操作插件: " + plugin.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package pw.yumc.Yum.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Fork From LagMonitor: https://github.com/games647/LagMonitor.git
|
||||
* We can listen to events which are intended to run sync to the main thread.
|
||||
* If those events are fired on a async task the operation was likely not thread-safe.
|
||||
*/
|
||||
public class ThreadSafetyListener implements Listener {
|
||||
|
||||
public ThreadSafetyListener(final Yum yum) {
|
||||
Bukkit.getPluginManager().registerEvents(this, yum);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkLoad(final ChunkLoadEvent chunkLoadEvent) {
|
||||
checkSafety(chunkLoadEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkUnload(final ChunkUnloadEvent chunkUnloadEvent) {
|
||||
checkSafety(chunkUnloadEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCreatureSpawn(final CreatureSpawnEvent creatureSpawnEvent) {
|
||||
checkSafety(creatureSpawnEvent);
|
||||
}
|
||||
|
||||
public void onInventoryOpen(final InventoryOpenEvent inventoryOpenEvent) {
|
||||
checkSafety(inventoryOpenEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemSpawn(final ItemSpawnEvent itemSpawnEvent) {
|
||||
checkSafety(itemSpawnEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(final PlayerMoveEvent moveEvent) {
|
||||
checkSafety(moveEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(final PlayerQuitEvent quitEvent) {
|
||||
checkSafety(quitEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent teleportEvent) {
|
||||
checkSafety(teleportEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(final WorldLoadEvent worldLoadEvent) {
|
||||
checkSafety(worldLoadEvent);
|
||||
}
|
||||
|
||||
public void onWorldSave(final WorldSaveEvent worldSaveEvent) {
|
||||
checkSafety(worldSaveEvent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldUnload(final WorldUnloadEvent worldUnloadEvent) {
|
||||
checkSafety(worldUnloadEvent);
|
||||
}
|
||||
|
||||
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();
|
||||
if (plugin != null) {
|
||||
throw new IllegalAccessError("[Yum 线程安全]: 请勿异步调用一个同步事件 " + eventName + " 操作插件: " + plugin.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user