Skip to content

Commit

Permalink
Remove item caching
Browse files Browse the repository at this point in the history
  • Loading branch information
HaHaWTH committed Mar 17, 2024
1 parent 7c2319f commit 61782bc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
8 changes: 0 additions & 8 deletions src/main/java/io/wdsj/asw/listener/PlayerItemListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemMeta> NORMAL_ITEM_META = new HashSet<>();

@EventHandler(priority = EventPriority.LOW)
public void onPlayerHeldItem(PlayerItemHeldEvent event) {
Expand All @@ -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(), "");
Expand All @@ -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);
}
}
}
Expand All @@ -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(), "");
Expand All @@ -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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/wdsj/asw/util/cache/BookCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,7 +12,7 @@
* @author HaHaWTH & HeyWTF_IS_That and 0D00_0721
*/
public class BookCache {
private static final LinkedHashMap<String, BookCacheEntry> bookCache = new LinkedHashMap<>();
private static final HashMap<String, BookCacheEntry> bookCache = new HashMap<>();

public static boolean isBookCached(String content) {
return bookCache.containsKey(content);
Expand Down

0 comments on commit 61782bc

Please sign in to comment.