Add spawn protection
This commit is contained in:
parent
76b43bcb3c
commit
4bb5c25622
@ -21,6 +21,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -52,6 +54,7 @@ public class CakePlayerModule extends CakeModule
|
||||
.setUnbreakable(true)
|
||||
.build();
|
||||
private static final int PLATFORM_DELTA = 1;
|
||||
private static final PotionEffect SPAWN_PROTECTION = new PotionEffect(PotionEffectType.REGENERATION, 60, 4);
|
||||
|
||||
private final Set<Block> _placedBlocks;
|
||||
// Used to store the inventory of a player when using the rune of holding
|
||||
@ -123,24 +126,10 @@ public class CakePlayerModule extends CakeModule
|
||||
@EventHandler
|
||||
public void blockPlacePrevent(BlockPlaceEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
ItemStack itemStack = player.getItemInHand();
|
||||
|
||||
if (itemStack == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemStack.getType() == RUNE_OF_HOLDING.getType())
|
||||
if (event.getItemInHand().getType() == RUNE_OF_HOLDING.getType())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
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") + "."));
|
||||
event.getPlayer().sendMessage(F.main("Game", "You cannot place a " + F.name(RUNE_OF_HOLDING.getItemMeta().getDisplayName()) + "."));
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,8 +152,8 @@ public class CakePlayerModule extends CakeModule
|
||||
|
||||
_storedInventory.put(player, new ItemStack[][]
|
||||
{
|
||||
inventory.getContents(),
|
||||
inventory.getArmorContents()
|
||||
inventory.getContents().clone(),
|
||||
inventory.getArmorContents().clone()
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -217,6 +206,8 @@ public class CakePlayerModule extends CakeModule
|
||||
UtilInv.remove(player, RUNE_OF_HOLDING.getType(), RUNE_OF_HOLDING.getData().getData(), 1);
|
||||
}, 20);
|
||||
}
|
||||
|
||||
player.addPotionEffect(SPAWN_PROTECTION);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
Loading…
Reference in New Issue
Block a user