1.13.2 fix round 3.. or 4

This commit is contained in:
nossr50 2020-08-18 20:38:56 -07:00
parent 7ea9ec5c2f
commit 1feee7f312
3 changed files with 19 additions and 8 deletions

View File

@ -383,6 +383,10 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClickEvent(InventoryClickEvent event) {
if(event.getCurrentItem() == null) {
return;
}
SkillUtils.removeAbilityBuff(event.getCurrentItem());
if (event.getAction() == InventoryAction.HOTBAR_SWAP) {
if(isOutsideWindowClick(event))
@ -391,7 +395,7 @@ public class InventoryListener implements Listener {
PlayerInventory playerInventory = event.getWhoClicked().getInventory();
if(playerInventory.getItem(event.getHotbarButton()) != null)
SkillUtils.removeAbilityBuff(event.getWhoClicked().getInventory().getItem(event.getHotbarButton()));
SkillUtils.removeAbilityBuff(playerInventory.getItem(event.getHotbarButton()));
}
}

View File

@ -31,7 +31,7 @@ public final class ItemUtils {
return mcMMO.getMaterialMapStore().isBow(item.getType().getKey().getKey());
}
public static boolean hasItemInEitherHand(Player player, Material material) {
public static boolean hasItemInEitherHand(@NotNull Player player, Material material) {
return player.getInventory().getItemInMainHand().getType() == material || player.getInventory().getItemInOffHand().getType() == material;
}
@ -41,7 +41,7 @@ public final class ItemUtils {
* @param item Item to check
* @return true if the item is a sword, false otherwise
*/
public static boolean isSword(ItemStack item) {
public static boolean isSword(@NotNull ItemStack item) {
return mcMMO.getMaterialMapStore().isSword(item.getType().getKey().getKey());
}
@ -51,7 +51,7 @@ public final class ItemUtils {
* @param item Item to check
* @return true if the item is a hoe, false otherwise
*/
public static boolean isHoe(ItemStack item) {
public static boolean isHoe(@NotNull ItemStack item) {
return mcMMO.getMaterialMapStore().isHoe(item.getType().getKey().getKey());
}
@ -61,7 +61,7 @@ public final class ItemUtils {
* @param item Item to check
* @return true if the item is a shovel, false otherwise
*/
public static boolean isShovel(ItemStack item) {
public static boolean isShovel(@NotNull ItemStack item) {
return mcMMO.getMaterialMapStore().isShovel(item.getType().getKey().getKey());
}
@ -71,7 +71,7 @@ public final class ItemUtils {
* @param item Item to check
* @return true if the item is an axe, false otherwise
*/
public static boolean isAxe(ItemStack item) {
public static boolean isAxe(@NotNull ItemStack item) {
return mcMMO.getMaterialMapStore().isAxe(item.getType().getKey().getKey());
}
@ -81,7 +81,7 @@ public final class ItemUtils {
* @param item Item to check
* @return true if the item is a pickaxe, false otherwise
*/
public static boolean isPickaxe(ItemStack item) {
public static boolean isPickaxe(@NotNull ItemStack item) {
return mcMMO.getMaterialMapStore().isPickAxe(item.getType().getKey().getKey());
}

View File

@ -30,6 +30,7 @@ import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Iterator;
@ -135,6 +136,9 @@ public class SkillUtils {
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
ItemStack heldItem = player.getInventory().getItemInMainHand();
if(heldItem == null)
return;
if (!ItemUtils.canBeSuperAbilityDigBoosted(heldItem)) {
return;
}
@ -200,7 +204,10 @@ public class SkillUtils {
}
}
public static void removeAbilityBuff(@NotNull ItemStack itemStack) {
public static void removeAbilityBuff(@Nullable ItemStack itemStack) {
if(itemStack == null)
return;
if(!ItemUtils.canBeSuperAbilityDigBoosted(itemStack))
return;