Don't allow players to drop special items in safezones (GH)
This commit is contained in:
parent
ba07d373ba
commit
af443dafdf
@ -9,6 +9,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
@ -24,6 +25,7 @@ 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.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@ -527,6 +529,29 @@ public class LootModule extends MiniPlugin
|
||||
handleRewardItem(event.getPlayer(), event.getItem().getItemStack());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void dropItem(PlayerDropItemEvent event)
|
||||
{
|
||||
if (event.getItemDrop() == null || event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_safezone.isInSafeZone(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack dropped = event.getItemDrop().getItemStack();
|
||||
|
||||
for (LootItemReward storedReward : _itemRewards) {
|
||||
if (storedReward.getItemStack().isSimilar(dropped)) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(F.main(_moduleName, "You can't drop special items in Safezones."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleRewardItem(Player player, ItemStack itemStack)
|
||||
{
|
||||
LootItem lootItem = fromItemStack(itemStack);
|
||||
|
Loading…
Reference in New Issue
Block a user