From 4075de4e598f8dec24627c6dfba939ec9e5a98b6 Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Fri, 22 Nov 2019 17:03:20 +0100 Subject: [PATCH] Add new methods for not allowed message --- .../Minepacks/Bukkit/API/ItemFilter.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/API/ItemFilter.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/API/ItemFilter.java index 12b37bd..fb0651c 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/API/ItemFilter.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/API/ItemFilter.java @@ -17,9 +17,36 @@ package at.pcgamingfreaks.Minepacks.Bukkit.API; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; public interface ItemFilter { - boolean isItemBlocked(ItemStack item); + /** + * @param item The item that should be checked. + * @return True if the item is not allowed. False if the item is allowed. + */ + boolean isItemBlocked(@NotNull ItemStack item); + + /** + * @param player The player that should receive the message that the item is not allowed. + * @param itemStack The item that is not allowed. Will be used for the name. + */ + void sendNotAllowedMessage(@NotNull Player player, @NotNull ItemStack itemStack); + + /** + * @param player The player that should receive the message if the item is not allowed. + * @param itemStack The item that should be checked. + * @return True if the item is not allowed. False if the item is allowed. + */ + default boolean checkIsBlockedAndShowMessage(@NotNull Player player, @NotNull ItemStack itemStack) + { + if(isItemBlocked(itemStack)) + { + sendNotAllowedMessage(player, itemStack); + return true; + } + return false; + } } \ No newline at end of file