Add FIXME tag

Former-commit-id: 17960954098dfc8767352d41629b60cef94ac3d4
This commit is contained in:
Ghost_chu committed 2020-04-10 09:19:14 +08:00
1 parent e663566c4d
commit ae99b32849
2 files changed
+11 -7

No files matched your search

@@ -41,6 +41,7 @@ public class ChunkListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent e) {
// FIXME: Need thread-safe impl, because paper using async chunk loading.
if (e.isNewChunk()) {
return;
}
@@ -57,13 +58,15 @@ public class ChunkListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent e) {
// FIXME: Need thread-safe impl, because paper using async chunk unloading.
final HashMap<Location, Shop> inChunk = plugin.getShopManager().getShops(e.getChunk());
if (inChunk == null || inChunk.isEmpty()) {
return;
}
for (Shop shop : new HashMap<>(inChunk).values()) {
shop.onUnload();
if(shop.isLoaded()) {
shop.onUnload();
}
}
}
@@ -19,8 +19,6 @@
package org.maxgamer.quickshop.listener;
import java.util.HashMap;
import java.util.Map.Entry;
import lombok.AllArgsConstructor;
import org.bukkit.Chunk;
import org.bukkit.Location;
@@ -35,6 +33,9 @@ import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.shop.Shop;
import org.maxgamer.quickshop.shop.ShopChunk;
import java.util.HashMap;
import java.util.Map.Entry;
@AllArgsConstructor
public class WorldListener implements Listener {
@@ -102,13 +103,13 @@ public class WorldListener implements Listener {
// So manually tell all of these shops they're unloaded.
for (Chunk chunk : e.getWorld().getLoadedChunks()) {
final HashMap<Location, Shop> inChunk = plugin.getShopManager().getShops(chunk);
if (inChunk == null || inChunk.isEmpty()) {
continue;
}
for (Shop shop : inChunk.values()) {
shop.onUnload();
if(shop.isLoaded()) { //Don't unload already unloaded shops.
shop.onUnload();
}
}
}
}