Prevent players placing barrier blocks (caused by a bug in ShopPage)

This commit is contained in:
Sam 2017-11-09 14:35:39 +00:00 committed by Alexander Meech
parent 9a3765ee2f
commit 5f156f771e

View File

@ -88,7 +88,7 @@ public class CakePlayerModule extends CakeModule
}
@EventHandler(priority = EventPriority.MONITOR)
public void blockBreak(BlockPlaceEvent event)
public void blockPlaceRecord(BlockPlaceEvent event)
{
if (event.isCancelled())
{
@ -121,12 +121,26 @@ public class CakePlayerModule extends CakeModule
}
@EventHandler
public void holdingRunePlace(BlockPlaceEvent event)
public void blockPlacePrevent(BlockPlaceEvent event)
{
if (event.getItemInHand().getType() == RUNE_OF_HOLDING.getType())
Player player = event.getPlayer();
ItemStack itemStack = player.getItemInHand();
if (itemStack == null)
{
return;
}
if (itemStack.getType() == RUNE_OF_HOLDING.getType())
{
event.setCancelled(true);
event.getPlayer().sendMessage(F.main("Game", "You cannot place a " + F.name(RUNE_OF_HOLDING.getItemMeta().getDisplayName()) + "."));
player.sendMessage(F.main("Game", "You cannot place a " + F.name(RUNE_OF_HOLDING.getItemMeta().getDisplayName()) + "."));
}
else if (itemStack.getType() == Material.BARRIER)
{
event.setCancelled(true);
player.setItemInHand(null);
player.sendMessage(F.main("Game", "You cannot place " + F.name("Barriers") + "."));
}
}