mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-30 13:27:37 +00:00
unblock shulkers
This commit is contained in:
parent
ea6d0aba60
commit
481983aeaf
@ -9,8 +9,6 @@ import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Dispenser;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user