Skip to content

Commit cf71d2e

Browse files
committed
Move material check into book filter
1 parent e38d8fd commit cf71d2e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/main/java/me/minoneer/bukkit/bookexploit/BookFilter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.md_5.bungee.api.chat.BaseComponent;
44
import net.md_5.bungee.api.chat.ClickEvent;
5+
import org.bukkit.Material;
56
import org.bukkit.inventory.ItemStack;
67
import org.bukkit.inventory.meta.BookMeta;
78
import org.bukkit.inventory.meta.ItemMeta;
@@ -30,6 +31,10 @@ public ItemStack filterBook(@Nullable final ItemStack originalItem) {
3031
return null;
3132
}
3233

34+
if (originalItem.getType() != Material.WRITTEN_BOOK && originalItem.getType() != Material.WRITABLE_BOOK) {
35+
return null;
36+
}
37+
3338
ItemStack newItem = originalItem.clone();
3439

3540
ItemMeta itemMeta = newItem.getItemMeta();

src/main/java/me/minoneer/bukkit/bookexploit/BookListener.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package me.minoneer.bukkit.bookexploit;
22

3-
import org.bukkit.Material;
43
import org.bukkit.entity.HumanEntity;
54
import org.bukkit.entity.Player;
65
import org.bukkit.event.EventHandler;
@@ -52,9 +51,6 @@ public void onBookRead(@NotNull final PlayerInteractEvent event) {
5251
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) {
5352
return;
5453
}
55-
if (event.getItem() == null || event.getItem().getType() != Material.WRITTEN_BOOK) {
56-
return;
57-
}
5854
if (player.hasPermission("bookfilter.overridefilter")) {
5955
return;
6056
}

0 commit comments

Comments
 (0)