9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-23 17:09:25 +00:00

Fix thread safety issue

This commit is contained in:
XiaoMoMi
2024-12-09 03:29:06 +08:00
parent 56c77bd294
commit 2e702d8945
4 changed files with 8 additions and 4 deletions

View File

@@ -80,7 +80,7 @@ public class ActionBarSender implements Feature {
this.onConditionTimerCheck(); this.onConditionTimerCheck();
} }
public void onConditionTimerCheck() { public synchronized void onConditionTimerCheck() {
ActionBarConfig[] configs = manager.actionBarConfigs(); ActionBarConfig[] configs = manager.actionBarConfigs();
outer: { outer: {
for (ActionBarConfig config : configs) { for (ActionBarConfig config : configs) {

View File

@@ -98,7 +98,7 @@ public class BossBarSender implements Feature, BossBar {
timeLeft = 0; timeLeft = 0;
} }
public void tick() { public synchronized void tick() {
if (timeLeft > 0) if (timeLeft > 0)
timeLeft--; timeLeft--;

View File

@@ -76,7 +76,7 @@ public class TagRendererImpl implements TagRenderer {
} }
@Override @Override
public void onTick() { public synchronized void onTick() {
if (!isValid()) return; if (!isValid()) return;
Set<CNPlayer> playersToUpdatePassengers = new ObjectOpenHashSet<>(); Set<CNPlayer> playersToUpdatePassengers = new ObjectOpenHashSet<>();

View File

@@ -255,7 +255,11 @@ public class BukkitCustomNameplates extends CustomNameplates implements Listener
if (nameplateManager != null) this.nameplateManager.disable(); if (nameplateManager != null) this.nameplateManager.disable();
if (imageManager != null) this.imageManager.disable(); if (imageManager != null) this.imageManager.disable();
if (chatManager != null) this.chatManager.disable(); if (chatManager != null) this.chatManager.disable();
if (commandManager != null) this.commandManager.unregisterFeatures(); if (commandManager != null) {
if (!Bukkit.getServer().isStopping()) {
this.commandManager.unregisterFeatures();
}
}
this.joinQuitListeners.clear(); this.joinQuitListeners.clear();
this.playerListeners.clear(); this.playerListeners.clear();
this.networkManager.shutdown(); this.networkManager.shutdown();