From b59e57dfb61cca09a568b40692abb9e854482a5c Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 02:10:24 +0100 Subject: [PATCH] Fixed Players not being given their Gem Hunters rewards for the final time! --- .../mineplex/gemhunters/loot/LootModule.java | 20 ++++++++++++++++--- .../loot/rewards/LootItemReward.java | 3 ++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java index b759af50b..3b7a7c822 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -29,6 +29,8 @@ import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; @@ -479,10 +481,10 @@ public class LootModule extends MiniPlugin handleRewardItem((Player) event.getWhoClicked(), itemStack); } - @EventHandler + @EventHandler(priority = EventPriority.HIGH) public void pickupItem(PlayerPickupItemEvent event) { - if (event.getItem() == null) + if (event.getItem() == null || event.isCancelled()) { return; } @@ -626,7 +628,7 @@ public class LootModule extends MiniPlugin { LootItemReward reward = iterator.next(); - if (player.equals(reward.getPlayer()) && player.getInventory().contains(reward.getItemStack())) + if (reward.getPlayer() != null && player.equals(reward.getPlayer())) { reward.success(); iterator.remove(); @@ -634,6 +636,18 @@ public class LootModule extends MiniPlugin } } + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + for (LootItemReward reward : _itemRewards) + { + if (reward.getPlayer().equals(event.getEntity())) + { + reward.death(event); + } + } + } + public final Set getShownPlayers() { return _shownPlayers; diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootItemReward.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootItemReward.java index f0ec11991..49acb3858 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootItemReward.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootItemReward.java @@ -38,7 +38,7 @@ public abstract class LootItemReward public final void collectItem(Player player) { - if (player.equals(_player)) + if (_player != null && player.equals(_player)) { return; } @@ -73,6 +73,7 @@ public abstract class LootItemReward public final void death(PlayerDeathEvent event) { + _player = null; } public boolean isFirstPickup()