From 61782bcb01edf8ffdbe7be374a938095be394171 Mon Sep 17 00:00:00 2001 From: HaHaWTH Date: Sun, 17 Mar 2024 12:49:40 +0800 Subject: [PATCH] Remove item caching --- .../java/io/wdsj/asw/listener/PlayerItemListener.java | 8 -------- src/main/java/io/wdsj/asw/util/cache/BookCache.java | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/wdsj/asw/listener/PlayerItemListener.java b/src/main/java/io/wdsj/asw/listener/PlayerItemListener.java index 51964ea..8f7e5bd 100644 --- a/src/main/java/io/wdsj/asw/listener/PlayerItemListener.java +++ b/src/main/java/io/wdsj/asw/listener/PlayerItemListener.java @@ -19,14 +19,12 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.HashSet; import java.util.List; import static io.wdsj.asw.AdvancedSensitiveWords.*; import static io.wdsj.asw.util.Utils.messagesFilteredNum; public class PlayerItemListener implements Listener { - private static final HashSet NORMAL_ITEM_META = new HashSet<>(); @EventHandler(priority = EventPriority.LOW) public void onPlayerHeldItem(PlayerItemHeldEvent event) { @@ -37,7 +35,6 @@ public void onPlayerHeldItem(PlayerItemHeldEvent event) { if (item != null && item.hasItemMeta()) { ItemMeta meta = item.getItemMeta(); if (meta != null && meta.hasDisplayName()) { - if (NORMAL_ITEM_META.contains(meta)) return; String originalName = meta.getDisplayName(); long startTime = System.currentTimeMillis(); if (settingsManager.getProperty(PluginSettings.IGNORE_FORMAT_CODE)) originalName = originalName.replaceAll(Utils.getIgnoreFormatCodeRegex(), ""); @@ -64,8 +61,6 @@ public void onPlayerHeldItem(PlayerItemHeldEvent event) { TimingUtils.addProcessStatistic(endTime, startTime); if (settingsManager.getProperty(PluginSettings.NOTICE_OPERATOR)) Notifier.notice(player, EventType.ITEM, originalName); if (settingsManager.getProperty(PluginSettings.ITEM_PUNISH)) Punishment.punish(player); - } else { - NORMAL_ITEM_META.add(meta); } } } @@ -80,7 +75,6 @@ public void onDrop(PlayerDropItemEvent event) { if (item.hasItemMeta()) { ItemMeta meta = item.getItemMeta(); if (meta != null && meta.hasDisplayName()) { - if (NORMAL_ITEM_META.contains(meta)) return; String originalName = meta.getDisplayName(); long startTime = System.currentTimeMillis(); if (settingsManager.getProperty(PluginSettings.IGNORE_FORMAT_CODE)) originalName = originalName.replaceAll(Utils.getIgnoreFormatCodeRegex(), ""); @@ -107,8 +101,6 @@ public void onDrop(PlayerDropItemEvent event) { TimingUtils.addProcessStatistic(endTime, startTime); if (settingsManager.getProperty(PluginSettings.NOTICE_OPERATOR)) Notifier.notice(player, EventType.ITEM, originalName); if (settingsManager.getProperty(PluginSettings.ITEM_PUNISH)) Punishment.punish(player); - } else { - NORMAL_ITEM_META.add(meta); } } } diff --git a/src/main/java/io/wdsj/asw/util/cache/BookCache.java b/src/main/java/io/wdsj/asw/util/cache/BookCache.java index 7538359..952e086 100644 --- a/src/main/java/io/wdsj/asw/util/cache/BookCache.java +++ b/src/main/java/io/wdsj/asw/util/cache/BookCache.java @@ -2,7 +2,7 @@ import io.wdsj.asw.setting.PluginSettings; -import java.util.LinkedHashMap; +import java.util.HashMap; import java.util.List; import static io.wdsj.asw.AdvancedSensitiveWords.settingsManager; @@ -12,7 +12,7 @@ * @author HaHaWTH & HeyWTF_IS_That and 0D00_0721 */ public class BookCache { - private static final LinkedHashMap bookCache = new LinkedHashMap<>(); + private static final HashMap bookCache = new HashMap<>(); public static boolean isBookCached(String content) { return bookCache.containsKey(content);