Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSmasher.java

78 lines
2.0 KiB
Java
Raw Normal View History

2013-08-27 17:14:08 +02:00
package nautilus.game.arcade.kit.perks;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.kit.Perk;
public class PerkSmasher extends Perk
{
public PerkSmasher()
{
super("Smasher", new String[]
{
C.cGray + "Hitting blocks damages all surrounding blocks",
});
}
@EventHandler
public void BlockSmash(BlockDamageEvent event)
{
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (this.Manager.GetGame() == null)
return;
if (!this.Manager.GetGame().IsAlive(player))
return;
2014-04-03 06:48:58 +02:00
if (!Recharge.Instance.use(player, GetName(), 250, false, false))
2013-08-27 17:14:08 +02:00
return;
for (Block block : UtilBlock.getSurrounding(event.getBlock(), false))
2013-08-27 17:14:08 +02:00
{
BlockDamageEvent blockDamage = new BlockDamageEvent(event.getPlayer(), block, event.getPlayer().getItemInHand(), false);
Manager.getPlugin().getServer().getPluginManager().callEvent(blockDamage);
2013-08-27 17:14:08 +02:00
}
BlockDamageEvent blockDamage = new BlockDamageEvent(event.getPlayer(), event.getBlock(), event.getPlayer().getItemInHand(), false);
Manager.getPlugin().getServer().getPluginManager().callEvent(blockDamage);
2013-08-27 17:14:08 +02:00
}
@EventHandler
public void BlockSmash(BlockBreakEvent event)
{
if (event.isCancelled())
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (this.Manager.GetGame() == null)
return;
if (!this.Manager.GetGame().IsAlive(player))
return;
2014-04-03 06:48:58 +02:00
if (!Recharge.Instance.use(player, GetName(), 50, false, false))
2013-08-27 17:14:08 +02:00
return;
for (Block block : UtilBlock.getSurrounding(event.getBlock(), false))
2013-08-27 17:14:08 +02:00
{
BlockBreakEvent blockDamage = new BlockBreakEvent(block, player);
Manager.getPlugin().getServer().getPluginManager().callEvent(blockDamage);
2013-08-27 17:14:08 +02:00
}
}
}