From 569e2e282a804ff66f32688ab38ecf9f6bd27c89 Mon Sep 17 00:00:00 2001 From: xGinko Date: Wed, 7 Aug 2024 00:59:28 +0200 Subject: [PATCH] annotate method --- .../aef/modules/illegals/items/BannedItemNames.java | 4 +++- .../aef/modules/illegals/items/BannedMaterials.java | 4 +++- .../modules/illegals/items/IllegalItemModule.java | 12 ++++++++---- .../aef/modules/illegals/items/IllegalPotions.java | 4 +++- .../aef/modules/illegals/items/InvalidStackSize.java | 4 +++- .../aef/modules/illegals/items/ItemAttributes.java | 4 +++- .../aef/modules/illegals/items/PlayerHeads.java | 4 +++- .../xginko/aef/modules/illegals/items/SpawnEggs.java | 4 +++- .../aef/modules/illegals/items/Unbreakables.java | 4 +++- .../illegals/items/enchantments/HigherEnchants.java | 4 +++- .../items/enchantments/InapplicableEnchants.java | 4 +++- .../items/enchantments/IncompatibleEnchants.java | 4 +++- .../aef/modules/illegals/items/nbt/CommandItems.java | 4 +++- .../modules/illegals/items/nbt/CustomNBTFilter.java | 4 +++- .../illegals/items/nbt/NBTFilledStorageItem.java | 4 +++- .../aef/modules/illegals/items/BannedItemNames.java | 4 +++- .../aef/modules/illegals/items/BannedMaterials.java | 4 +++- .../modules/illegals/items/IllegalItemModule.java | 10 ++++++---- .../aef/modules/illegals/items/IllegalPotions.java | 4 +++- .../aef/modules/illegals/items/InvalidStackSize.java | 4 +++- .../aef/modules/illegals/items/PlayerHeads.java | 4 +++- .../xginko/aef/modules/illegals/items/SpawnEggs.java | 4 +++- .../aef/modules/illegals/items/Unbreakables.java | 4 +++- .../illegals/items/datavalues/CustomDataValues.java | 4 +++- .../items/datavalues/IllegalGoldenApples.java | 4 +++- .../illegals/items/enchantments/HigherEnchants.java | 4 +++- .../items/enchantments/InapplicableEnchants.java | 4 +++- .../items/enchantments/IncompatibleEnchants.java | 4 +++- .../aef/modules/illegals/items/nbt/CommandItems.java | 4 +++- .../modules/illegals/items/nbt/CustomNBTFilter.java | 4 +++- .../illegals/items/nbt/NBTFilledStorageItem.java | 4 +++- 31 files changed, 101 insertions(+), 37 deletions(-) diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/BannedItemNames.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/BannedItemNames.java index 62d134742..085b417f0 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/BannedItemNames.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/BannedItemNames.java @@ -12,6 +12,8 @@ import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.EnumSet; @@ -78,7 +80,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if ( itemStack == null || whitelistedTypes.contains(itemStack.getType()) diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/BannedMaterials.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/BannedMaterials.java index df1627637..838dfd9d0 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/BannedMaterials.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/BannedMaterials.java @@ -7,6 +7,8 @@ import me.xginko.aef.utils.ItemUtil; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.EnumSet; import java.util.List; @@ -65,7 +67,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/IllegalItemModule.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/IllegalItemModule.java index f99de6bc6..b0edc56e1 100644 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/IllegalItemModule.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/IllegalItemModule.java @@ -38,7 +38,9 @@ import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.PolyNull; +import org.jetbrains.annotations.NotNull; import java.time.Duration; import java.util.Arrays; @@ -49,9 +51,6 @@ public abstract class IllegalItemModule extends AEFModule implements Listener { - public abstract ItemLegality legalityOf(ItemStack itemStack); - public abstract void handleItem(ItemStack itemStack, ItemLegality legality); - protected final AEFPermission bypassPermission; protected final IllegalHandling handling; protected final Set optionalListeners; @@ -62,6 +61,7 @@ public IllegalItemModule(String configPath, AEFPermission bypassPermission) { super(configPath); this.bypassPermission = bypassPermission; this.optionalListeners = new HashSet<>(); + String configuredHandling = config.getString(configPath + ".handling", IllegalHandling.PREVENT_USE_ONLY.name(), "Available options:\n" + Arrays.stream(IllegalHandling.values()) .map(option -> option.name() + " - " + option.description()) @@ -157,6 +157,10 @@ private void onChunkLoad(ChunkLoadEvent event) { this.createIfAbsent = eventClass -> new ExpiringSet<>(delay); } + public abstract @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack); + + public abstract void handleItem(ItemStack itemStack, ItemLegality legality); + @Override public void enable() { plugin.getServer().getPluginManager().registerEvents(this, plugin); @@ -170,7 +174,7 @@ public void disable() { optionalListeners.clear(); } - public ItemLegality legalityOf(Iterable itemStacks) { + public ItemLegality legalityOf(@Nullable Iterable itemStacks) { if (itemStacks == null) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/IllegalPotions.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/IllegalPotions.java index 640abe984..2383479cf 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/IllegalPotions.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/IllegalPotions.java @@ -7,6 +7,8 @@ import me.xginko.aef.utils.MaterialUtil; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; public class IllegalPotions extends IllegalItemModule { @@ -27,7 +29,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || !MaterialUtil.POTIONS.contains(itemStack.getType()) || !itemStack.hasItemMeta()) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/InvalidStackSize.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/InvalidStackSize.java index c12fb63cd..9e8694eb0 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/InvalidStackSize.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/InvalidStackSize.java @@ -6,6 +6,8 @@ import me.xginko.aef.utils.ItemUtil; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.EnumSet; import java.util.List; @@ -47,7 +49,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType().isAir()) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/ItemAttributes.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/ItemAttributes.java index dba2cbfc9..df8637b82 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/ItemAttributes.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/ItemAttributes.java @@ -8,6 +8,8 @@ import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.EnumSet; import java.util.List; @@ -49,7 +51,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType().isAir() || !itemStack.hasItemMeta()) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/PlayerHeads.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/PlayerHeads.java index 86e85d57d..4fe7f19e7 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/PlayerHeads.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/PlayerHeads.java @@ -6,6 +6,8 @@ import me.xginko.aef.utils.ItemUtil; import me.xginko.aef.utils.MaterialUtil; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; public class PlayerHeads extends IllegalItemModule { @@ -26,7 +28,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/SpawnEggs.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/SpawnEggs.java index 9ca06e555..2ffeb7c01 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/SpawnEggs.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/SpawnEggs.java @@ -8,6 +8,8 @@ import me.xginko.aef.utils.ItemUtil; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.EnumSet; @@ -49,7 +51,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || whitelistedTypes.contains(itemStack.getType())) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/Unbreakables.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/Unbreakables.java index 46b38f423..895d40224 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/Unbreakables.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/Unbreakables.java @@ -8,6 +8,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.EnumSet; import java.util.List; @@ -53,7 +55,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType().isAir() || !itemStack.hasItemMeta()) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/HigherEnchants.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/HigherEnchants.java index 204f436cf..d1bab08d6 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/HigherEnchants.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/HigherEnchants.java @@ -8,6 +8,8 @@ import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.EnumSet; import java.util.HashSet; @@ -63,7 +65,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType().isAir()) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/InapplicableEnchants.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/InapplicableEnchants.java index e298cde1d..dde4d37d1 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/InapplicableEnchants.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/InapplicableEnchants.java @@ -8,6 +8,8 @@ import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.EnumSet; import java.util.List; @@ -51,7 +53,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType().isAir()) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/IncompatibleEnchants.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/IncompatibleEnchants.java index cb700dc8a..4a2f981e6 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/IncompatibleEnchants.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/IncompatibleEnchants.java @@ -8,6 +8,8 @@ import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.EnumSet; @@ -76,7 +78,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType() == Material.AIR) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CommandItems.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CommandItems.java index 7c6911485..9a806a4d9 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CommandItems.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CommandItems.java @@ -6,6 +6,8 @@ import me.xginko.aef.modules.illegals.items.IllegalItemModule; import me.xginko.aef.utils.MaterialUtil; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; public class CommandItems extends IllegalItemModule { @@ -27,7 +29,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType().isAir()) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CustomNBTFilter.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CustomNBTFilter.java index 7e7b1dfe5..d0a835ba9 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CustomNBTFilter.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CustomNBTFilter.java @@ -8,6 +8,8 @@ import me.xginko.aef.utils.ItemUtil; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.EnumSet; import java.util.HashSet; @@ -52,7 +54,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType().isAir()) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/nbt/NBTFilledStorageItem.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/nbt/NBTFilledStorageItem.java index 766344ebd..ef941ca7a 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/nbt/NBTFilledStorageItem.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/nbt/NBTFilledStorageItem.java @@ -10,6 +10,8 @@ import me.xginko.aef.utils.MaterialUtil; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.EnumSet; import java.util.Objects; @@ -55,7 +57,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType().isAir()) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/BannedItemNames.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/BannedItemNames.java index 0e929b2fb..89817925e 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/BannedItemNames.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/BannedItemNames.java @@ -6,6 +6,8 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.EnumSet; @@ -56,7 +58,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if ( itemStack == null || whitelistedTypes.contains(itemStack.getType()) diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/BannedMaterials.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/BannedMaterials.java index df1627637..838dfd9d0 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/BannedMaterials.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/BannedMaterials.java @@ -7,6 +7,8 @@ import me.xginko.aef.utils.ItemUtil; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.EnumSet; import java.util.List; @@ -65,7 +67,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/IllegalItemModule.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/IllegalItemModule.java index 913c65ed8..19549a31f 100644 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/IllegalItemModule.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/IllegalItemModule.java @@ -38,7 +38,9 @@ import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.PolyNull; +import org.jetbrains.annotations.NotNull; import java.time.Duration; import java.util.Arrays; @@ -49,13 +51,9 @@ public abstract class IllegalItemModule extends AEFModule implements Listener { - public abstract ItemLegality legalityOf(ItemStack itemStack); - public abstract void handleItem(ItemStack itemStack, ItemLegality legality); - protected final AEFPermission bypassPermission; protected final IllegalHandling handling; protected final Set optionalListeners; - private final Cache, ExpiringSet> listenerCooldowns; private final Function, @PolyNull ExpiringSet> createIfAbsent; @@ -159,6 +157,10 @@ private void onChunkLoad(ChunkLoadEvent event) { this.createIfAbsent = eventClass -> new ExpiringSet<>(delay); } + public abstract @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack); + + public abstract void handleItem(ItemStack itemStack, ItemLegality legality); + @Override public void enable() { plugin.getServer().getPluginManager().registerEvents(this, plugin); diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/IllegalPotions.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/IllegalPotions.java index 98b6a86c8..8ebebaad4 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/IllegalPotions.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/IllegalPotions.java @@ -7,6 +7,8 @@ import me.xginko.aef.utils.MaterialUtil; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; public class IllegalPotions extends IllegalItemModule { @@ -27,7 +29,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || !MaterialUtil.POTIONS.contains(itemStack.getType()) || !itemStack.hasItemMeta()) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/InvalidStackSize.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/InvalidStackSize.java index 86056fba1..ca5fe7503 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/InvalidStackSize.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/InvalidStackSize.java @@ -7,6 +7,8 @@ import me.xginko.aef.utils.ItemUtil; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.EnumSet; @@ -49,7 +51,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType() == Material.AIR) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/PlayerHeads.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/PlayerHeads.java index 364b1b1df..1fd8040af 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/PlayerHeads.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/PlayerHeads.java @@ -6,6 +6,8 @@ import me.xginko.aef.utils.ItemUtil; import me.xginko.aef.utils.MaterialUtil; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; public class PlayerHeads extends IllegalItemModule { @@ -26,7 +28,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/SpawnEggs.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/SpawnEggs.java index fdc6b846e..ed2d6b419 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/SpawnEggs.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/SpawnEggs.java @@ -8,6 +8,8 @@ import me.xginko.aef.utils.MaterialUtil; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.EnumSet; @@ -49,7 +51,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || whitelistedTypes.contains(itemStack.getType())) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/Unbreakables.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/Unbreakables.java index 625595fd8..787e53276 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/Unbreakables.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/Unbreakables.java @@ -9,6 +9,8 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.EnumSet; @@ -58,7 +60,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType() == Material.AIR) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/datavalues/CustomDataValues.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/datavalues/CustomDataValues.java index 749d33494..66513f506 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/datavalues/CustomDataValues.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/datavalues/CustomDataValues.java @@ -8,6 +8,8 @@ import me.xginko.aef.utils.PlatformUtil; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.EnumSet; @@ -55,7 +57,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType() == Material.AIR) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/datavalues/IllegalGoldenApples.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/datavalues/IllegalGoldenApples.java index 313105a37..7c163c1ff 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/datavalues/IllegalGoldenApples.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/datavalues/IllegalGoldenApples.java @@ -10,6 +10,8 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.EnumMap; import java.util.Map; @@ -44,7 +46,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/HigherEnchants.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/HigherEnchants.java index c2a8002bc..572bc019f 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/HigherEnchants.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/HigherEnchants.java @@ -8,6 +8,8 @@ import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.EnumSet; @@ -62,7 +64,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType() == Material.AIR) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/InapplicableEnchants.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/InapplicableEnchants.java index 268cd7eb9..8509d6bde 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/InapplicableEnchants.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/InapplicableEnchants.java @@ -9,6 +9,8 @@ import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.EnumSet; @@ -53,7 +55,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType() == Material.AIR) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/IncompatibleEnchants.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/IncompatibleEnchants.java index c8b64ce63..947aa3501 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/IncompatibleEnchants.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/enchantments/IncompatibleEnchants.java @@ -8,6 +8,8 @@ import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.EnumSet; @@ -76,7 +78,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType() == Material.AIR) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CommandItems.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CommandItems.java index ef548a4c9..2b877cbd4 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CommandItems.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CommandItems.java @@ -7,6 +7,8 @@ import me.xginko.aef.utils.MaterialUtil; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; public class CommandItems extends IllegalItemModule { @@ -28,7 +30,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType() == Material.AIR) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CustomNBTFilter.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CustomNBTFilter.java index abfe838db..3b42cb5fe 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CustomNBTFilter.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/nbt/CustomNBTFilter.java @@ -8,6 +8,8 @@ import me.xginko.aef.utils.ItemUtil; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.EnumSet; @@ -52,7 +54,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType() == Material.AIR) { return ItemLegality.LEGAL; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/nbt/NBTFilledStorageItem.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/nbt/NBTFilledStorageItem.java index 8f6060c83..d80c75773 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/nbt/NBTFilledStorageItem.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/nbt/NBTFilledStorageItem.java @@ -9,6 +9,8 @@ import me.xginko.aef.utils.MaterialUtil; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.EnumSet; import java.util.Objects; @@ -54,7 +56,7 @@ public boolean shouldEnable() { } @Override - public ItemLegality legalityOf(ItemStack itemStack) { + public @NotNull ItemLegality legalityOf(@Nullable ItemStack itemStack) { if (itemStack == null || itemStack.getType() == Material.AIR) { return ItemLegality.LEGAL; }