unblock shulkers

This commit is contained in:
ZeroEpoch1969 2019-03-24 21:47:40 -07:00
parent ea6d0aba60
commit 481983aeaf
No known key found for this signature in database
GPG Key ID: A7BAB4E14F089CF3

View File

@ -9,8 +9,6 @@ import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Dispenser;
import org.bukkit.block.ShulkerBox;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -103,52 +101,4 @@ public class BlockBlocker extends FreedomService
} }
} }
@EventHandler(priority = EventPriority.HIGH)
public void onShulkerBoxPlace(BlockPlaceEvent event)
{
Block block = event.getBlock();
if (Groups.SHULKER_BOXES.contains(event.getBlock().getType()))
{
ShulkerBox shulkerBox = (ShulkerBox)block.getState();
boolean empty = true;
for (ItemStack itemStack : shulkerBox.getInventory().getContents())
{
if (itemStack != null)
{
empty = false;
break;
}
}
if (!empty)
{
shulkerBox.getInventory().clear();
event.getPlayer().sendMessage(ChatColor.RED + "For security reasons, your shulker box has been emptied.");
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onDispenserPlace(BlockPlaceEvent event)
{
Block block = event.getBlock();
if (block.getType().equals(Material.DISPENSER))
{
Dispenser dispenser = (Dispenser)block.getState();
boolean empty = true;
for (ItemStack itemStack : dispenser.getInventory().getContents())
{
if (itemStack != null)
{
empty = false;
break;
}
}
if (!empty)
{
dispenser.getInventory().clear();
event.getPlayer().sendMessage(ChatColor.RED + "For security reasons, dispenser has been emptied.");
}
}
}
} }