Super Spleef

This commit is contained in:
Sam 2018-04-30 15:18:51 +01:00 committed by Alexander Meech
parent 24ed1f0dd5
commit ef92d7ab62
5 changed files with 120 additions and 558 deletions

View File

@ -93,8 +93,6 @@ import nautilus.game.arcade.game.games.sneakyassassins.SneakyAssassins;
import nautilus.game.arcade.game.games.snowfight.SnowFight;
import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders;
import nautilus.game.arcade.game.games.spleef.Spleef;
import nautilus.game.arcade.game.games.spleef.SpleefTeams;
import nautilus.game.arcade.game.games.spleef.modes.UltraSpleef;
import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesNewSolo;
import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesNewTeams;
import nautilus.game.arcade.game.games.turfforts.TurfForts;
@ -180,7 +178,6 @@ public enum GameType
SnowFight(SnowFight.class, GameDisplay.SnowFight),
SpeedBuilders(SpeedBuilders.class, GameDisplay.SpeedBuilders),
Spleef(Spleef.class, GameDisplay.Spleef),
SpleefTeams(SpleefTeams.class, GameDisplay.SpleefTeams),
SurvivalGames(SurvivalGamesNewSolo.class, GameDisplay.SurvivalGames),
SurvivalGamesTeams(SurvivalGamesNewTeams.class, GameDisplay.SurvivalGamesTeams, new GameType[]{GameType.SurvivalGames}, false),
TurfWars(TurfForts.class, GameDisplay.TurfWars),
@ -227,7 +224,7 @@ public enum GameType
GameType.Micro, GameType.MilkCow, GameType.MineStrike, GameType.BawkBawkBattles,
GameType.OldMineWare, GameType.Paintball, GameType.Quiver, GameType.QuiverTeams, GameType.Runner,
GameType.Sheep, GameType.Skywars, GameType.SkywarsTeams, GameType.Smash, GameType.SmashDomination, GameType.SmashTeams,
GameType.Snake, GameType.SneakyAssassins, GameType.SnowFight, GameType.Spleef, GameType.SpleefTeams,
GameType.Snake, GameType.SneakyAssassins, GameType.SnowFight, GameType.Spleef,
GameType.SurvivalGames, GameType.SurvivalGamesTeams, GameType.TurfWars, GameType.UHC,
GameType.WitherAssault, GameType.Wizards, GameType.ZombieSurvival}, true),
@ -248,7 +245,6 @@ public enum GameType
new GameMode(GodBattles.class, GameType.UHC, "God Battles"),
new GameMode(BloodDiamonds.class, GameType.UHC, "Blood Diamonds"),
new GameMode(Assassins.class, GameType.UHC, "Assassins"),
new GameMode(UltraSpleef.class, GameType.Spleef, "Ultra Spleef"),
new GameMode(RandomKitSSM.class, GameType.Smash, "Random Kit SSM"),
new GameMode(EweHeroes.class, GameType.Sheep, "Heroes Of The Ewe"),
new GameMode(SheepMania.class, GameType.Sheep, "Sheep Mania"),

View File

@ -17,6 +17,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.mineplex.anticheat.checks.move.Glide;
import com.mineplex.anticheat.checks.move.HeadRoll;
@ -38,6 +40,7 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.runner.kits.KitArcher;
import nautilus.game.arcade.game.games.runner.kits.KitFrosty;
@ -84,7 +87,9 @@ public class Runner extends SoloGame implements IThrown
);
registerChatStats(
new ChatStatData("MarathonRunner", "Distance ran", true)
new ChatStatData("MarathonRunner", "Distance ran", true),
BlankLine,
new ChatStatData("kit", "Kit", true)
);
GlideCheckEnabled = false;
@ -94,6 +99,12 @@ public class Runner extends SoloGame implements IThrown
antiHack.addIgnoredCheck(HeadRoll.class);
}
@EventHandler
public void teleportIn(PlayerPrepareTeleportEvent event)
{
event.GetPlayer().addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false));
}
@EventHandler
public void arrowDamage(ProjectileHitEvent event)
{

View File

@ -1,6 +1,5 @@
package nautilus.game.arcade.game.games.spleef;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
@ -13,13 +12,18 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
@ -27,6 +31,7 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.spleef.kits.KitArcher;
import nautilus.game.arcade.game.games.spleef.kits.KitBrawler;
@ -38,30 +43,30 @@ import nautilus.game.arcade.stats.SpleefBlockDestroyStatTracker;
public class Spleef extends SoloGame
{
private static final String[] DESCRIPTION =
{
C.cGreen + "Punch Blocks" + C.Reset + " to break them!",
"You gain " + C.cRed + "Hunger" + C.Reset + " when breaking blocks.",
C.cYellow + "Last Player" + C.Reset + " alive wins!"
};
public Spleef(ArcadeManager manager)
{
super(manager, GameType.Spleef,
new Kit[]
super(manager, GameType.Spleef, new Kit[]
{
new KitSnowballer(manager),
new KitBrawler(manager),
new KitArcher(manager)
},
}, DESCRIPTION);
new String[]
{
"Punch blocks to break them!",
"1 Hunger per block smashed!",
"Last player alive wins!"
});
DamagePvP = false;
WorldWaterDamage = 4;
PrepareFreeze = false;
this.DamagePvP = false;
this.WorldWaterDamage = 4;
this.PrepareFreeze = false;
registerStatTrackers(new SpleefBlockDestroyStatTracker(this));
registerStatTrackers(
new SpleefBlockDestroyStatTracker(this)
);
registerChatStats(
DamageTaken,
@ -73,14 +78,17 @@ public class Spleef extends SoloGame
);
new CompassModule()
.setGiveCompass(true)
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
}
@EventHandler
public void SnowballDamage(ProjectileHitEvent event)
public void teleportIn(PlayerPrepareTeleportEvent event)
{
event.GetPlayer().addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false));
}
@EventHandler
public void snowballHit(ProjectileHitEvent event)
{
if (!IsLive() || !(event.getEntity() instanceof Snowball))
{
@ -90,24 +98,26 @@ public class Spleef extends SoloGame
Snowball ball = (Snowball) event.getEntity();
if (ball.getShooter() == null || !(ball.getShooter() instanceof Player))
{
return;
}
Location loc = ball.getLocation().add(ball.getVelocity().multiply(0.8));
Location location = ball.getLocation().add(ball.getVelocity().multiply(0.8));
Block block = location.getBlock();
Block block = loc.getBlock();
//Find Nearest if hit nothing :O
if (block.getType() == Material.AIR)
{
Block closest = null;
double closestDist = 0;
double closestDist = Double.MAX_VALUE;
for (Block other : UtilBlock.getSurrounding(block, true))
{
if (other.getType() == Material.AIR)
{
continue;
}
double dist = UtilMath.offset(loc, other.getLocation().add(0.5, 0.5, 0.5));
double dist = UtilMath.offsetSquared(location, other.getLocation().add(0.5, 0.5, 0.5));
if (closest == null || dist < closestDist)
{
@ -117,27 +127,31 @@ public class Spleef extends SoloGame
}
if (closest != null)
{
block = closest;
}
}
BlockFade(block, (Player) ball.getShooter(), false);
blockFade(block, (Player) ball.getShooter(), false);
}
@EventHandler
public void ArrowDamage(ProjectileHitEvent event)
public void arrowHit(ProjectileHitEvent event)
{
if (!IsLive() || !(event.getEntity() instanceof Arrow))
{
return;
}
final Arrow arrow = (Arrow) event.getEntity();
final double velocity = arrow.getVelocity().length();
Arrow arrow = (Arrow) event.getEntity();
double velocity = arrow.getVelocity().length();
if (!(arrow.getShooter() instanceof Player))
{
return;
}
final Player player = (Player) arrow.getShooter();
Player player = (Player) arrow.getShooter();
Manager.runSyncLater(() ->
{
@ -145,11 +159,11 @@ public class Spleef extends SoloGame
double radius = 0.5 + velocity / 1.6d;
BlockFade(block, player, false);
blockFade(block, player, false);
for (Block other : UtilBlock.getInRadius(block.getLocation().add(0.5, 0.5, 0.5), radius).keySet())
{
BlockFade(other, player, true);
blockFade(other, player, true);
}
arrow.remove();
@ -157,125 +171,135 @@ public class Spleef extends SoloGame
}
@EventHandler(priority = EventPriority.LOW)
public void BlockDamage(BlockDamageEvent event)
public void blockHit(BlockDamageEvent event)
{
Player player = event.getPlayer();
if (!IsLive() || UtilPlayer.isSpectator(player))
{
if (!this.IsLive())
return;
if (!this.IsAlive(event.getPlayer()))
return;
event.setCancelled(true);
if (event.getBlock().getType() == Material.BEDROCK)
return;
BlockFade(event.getBlock(), event.getPlayer(), false);
//Snowball
if (GetKit(event.getPlayer()) instanceof KitSnowballer && event.getBlock().getType() != Material.BEDROCK)
if (!UtilInv.contains(event.getPlayer(), Material.SNOW_BALL, (byte) 0, 16))
event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL));
}
public void BlockFade(Block block, Player player, boolean slowDamage)
Block block = event.getBlock();
event.setCancelled(true);
if (block.getType() == Material.BEDROCK)
{
return;
}
blockFade(block, player, false);
//Snowball
if (GetKit(player) instanceof KitSnowballer && !UtilInv.contains(player, Material.SNOW_BALL, (byte) 0, 16))
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL));
}
}
private void blockFade(Block block, Player player, boolean slowDamage)
{
if (block.getType() == Material.BEDROCK || block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA)
{
return;
}
//Prevent Super Hunger from Bow
if (Recharge.Instance.use(player, GetName() + " Hunger", 50, false, false))
{
UtilPlayer.hunger(player, 1);
}
if (!slowDamage)
{
Break(block, player);
breakBlock(block, player);
return;
}
//Wool and Stained Clay
if (block.getTypeId() == 35 || block.getTypeId() == 159)
if (block.getType() == Material.WOOL || block.getType() == Material.STAINED_CLAY)
{
//Greens
if (block.getData() == 5 || block.getData() == 13)
{
block.setData((byte) 4);
}
//Yellow
else if (block.getData() == 4)
{
block.setData((byte) 14);
else
Break(block, player);
}
else
{
breakBlock(block, player);
}
}
//Stone
else if (block.getTypeId() == 1)
else if (block.getType() == Material.STONE)
{
block.setTypeId(4);
}
//Stone Brick
else if (block.getTypeId() == 98)
else if (block.getType() == Material.SMOOTH_BRICK)
{
if (block.getData() == 0 || block.getData() == 1)
{
block.setData((byte) 2);
else
Break(block, player);
}
else
{
breakBlock(block, player);
}
}
//Grass
else if (block.getTypeId() == 2)
else if (block.getType() == Material.GRASS)
{
block.setTypeId(3);
}
//Wood Planks
else if (block.getTypeId() == 5)
else if (block.getType() == Material.WOOD)
{
if (block.getData() == 1)
{
block.setData((byte) 0);
else if (block.getData() == 0)
block.setData((byte) 2);
else
Break(block, player);
}
else if (block.getData() == 0)
{
block.setData((byte) 2);
}
else
{
breakBlock(block, player);
}
}
//Other
else if (block.getTypeId() != 7)
{
Break(block, player);
breakBlock(block, player);
}
}
public void Break(Block block, Player player)
private void breakBlock(Block block, Player player)
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
block.setTypeId(0);
Bukkit.getPluginManager().callEvent(new SpleefDestroyBlockEvent(block, player));
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR);
UtilServer.CallEvent(new SpleefDestroyBlockEvent(block, player));
}
@EventHandler
public void Hunger(UpdateEvent event)
public void updateHunger(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW || !IsLive())
{
if (event.getType() != UpdateType.SLOW)
return;
if (!IsLive())
return;
}
for (Player player : GetPlayers(true))
{
if (player.getFoodLevel() <= 0)
{
Manager.GetDamage().NewDamageEvent(player, null, null,
DamageCause.STARVATION, 1, false, true, false,
"Starvation", GetName());
UtilPlayer.message(player, F.main("Game", "Break blocks to restore hunger!"));
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.STARVATION, 1, false, true, false, GetMode(), "Starvation");
player.sendMessage(F.main("Game", C.cRedB + "Break blocks to restore hunger!"));
}
UtilPlayer.hunger(player, -2);

View File

@ -1,293 +0,0 @@
package nautilus.game.arcade.game.games.spleef;
import java.lang.reflect.Field;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.spleef.kits.*;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.chat.ChatStatData;
import net.minecraft.server.v1_8_R3.EntityArrow;
public class SpleefTeams extends TeamGame
{
public SpleefTeams(ArcadeManager manager)
{
super(manager, GameType.SpleefTeams,
new Kit[]
{
new KitSnowballer(manager),
new KitBrawler(manager),
new KitArcher(manager)
},
new String[]
{
"Punch blocks to break them!",
"Last team alive wins!"
});
this.DamagePvP = false;
this.WorldWaterDamage = 4;
this.PrepareFreeze = false;
registerChatStats(
Kills,
Assists,
BlankLine,
new ChatStatData("BlocksBroken", "Blocks Broken", true),
BlankLine,
new ChatStatData("kit", "Kit", true)
);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
@EventHandler
public void SnowballDamage(ProjectileHitEvent event)
{
if (!(event.getEntity() instanceof Snowball))
return;
Snowball ball = (Snowball)event.getEntity();
if (ball.getShooter() == null || !(ball.getShooter() instanceof Player))
return;
Location loc = ball.getLocation().add(ball.getVelocity().multiply(0.8));
Block block = loc.getBlock();
//Find Nearest if hit nothing :O
if (block.getType() == Material.AIR)
{
Block closest = null;
double closestDist = 0;
for (Block other : UtilBlock.getSurrounding(block, true))
{
if (other.getType() == Material.AIR)
continue;
double dist = UtilMath.offset(loc, other.getLocation().add(0.5, 0.5, 0.5));
if (closest == null || dist < closestDist)
{
closest = other;
closestDist = dist;
}
}
if (closest != null)
block = closest;
}
BlockFade(block, (Player)ball.getShooter(), false);
}
@EventHandler
public void ArrowDamage(ProjectileHitEvent event)
{
if (!(event.getEntity() instanceof Arrow))
return;
final Arrow arrow = (Arrow)event.getEntity();
final double velocity = arrow.getVelocity().length();
if (!(arrow.getShooter() instanceof Player))
return;
final Player player = (Player)arrow.getShooter();
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
{
public void run()
{
try
{
EntityArrow entityArrow = ((CraftArrow)arrow).getHandle();
Field fieldX = EntityArrow.class.getDeclaredField("d");
Field fieldY = EntityArrow.class.getDeclaredField("e");
Field fieldZ = EntityArrow.class.getDeclaredField("f");
fieldX.setAccessible(true);
fieldY.setAccessible(true);
fieldZ.setAccessible(true);
int x = fieldX.getInt(entityArrow);
int y = fieldY.getInt(entityArrow);
int z = fieldZ.getInt(entityArrow);
Block block = arrow.getWorld().getBlockAt(x, y, z);
double radius = 0.5 + velocity/1.6d;
BlockFade(block, player, false);
for (Block other : UtilBlock.getInRadius(block.getLocation().add(0.5, 0.5, 0.5), radius).keySet())
{
BlockFade(other, player, true);
}
arrow.remove();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}, 0);
}
@EventHandler(priority = EventPriority.LOW)
public void BlockDamage(BlockDamageEvent event)
{
if (!this.IsLive())
return;
if (!this.IsAlive(event.getPlayer()))
return;
event.setCancelled(true);
BlockFade(event.getBlock(), event.getPlayer(), false);
//Snowball
if (GetKit(event.getPlayer()) instanceof KitSnowballer)
if (!UtilInv.contains(event.getPlayer(), Material.SNOW_BALL, (byte)0, 16))
event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL));
}
public void BlockFade(Block block, Player player, boolean slowDamage)
{
AddStat(player, "BlocksBroken", 1, false, false);
//Prevent Super Hunger from Bow
if (Recharge.Instance.use(player, GetName() + " Hunger", 50, false, false))
if (block.getTypeId() != 7)
UtilPlayer.hunger(player, 1);
if (!slowDamage)
{
Break(block);
return;
}
//Wool and Stained Clay
if (block.getTypeId() == 35 || block.getTypeId() == 159)
{
//Greens
if (block.getData() == 5 || block.getData() == 13)
block.setData((byte)4);
//Yellow
else if (block.getData() == 4)
block.setData((byte)14);
else
Break(block);
}
//Stone
else if (block.getTypeId() == 1)
{
block.setTypeId(4);
}
//Stone Brick
else if (block.getTypeId() == 98)
{
if (block.getData() == 0 || block.getData() == 1)
block.setData((byte)2);
else
Break(block);
}
//Grass
else if (block.getTypeId() == 2)
{
block.setTypeId(3);
}
//Wood Planks
else if (block.getTypeId() == 5)
{
if (block.getData() == 1)
block.setData((byte)0);
else if (block.getData() == 0)
block.setData((byte)2);
else
Break(block);
}
//Other
else if (block.getTypeId() != 7)
{
Break(block);
}
}
public void Break(Block block)
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
block.setTypeId(0);
}
@EventHandler
public void Hunger(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)
return;
if (!IsLive())
return;
for (Player player : GetPlayers(true))
{
if (player.getFoodLevel() <= 0)
{
Manager.GetDamage().NewDamageEvent(player, null, null,
DamageCause.STARVATION, 1, false, true, false,
"Starvation", GetName());
UtilPlayer.message(player, F.main("Game", "Break blocks to restore hunger!"));
}
UtilPlayer.hunger(player, -2);
}
}
}

View File

@ -1,176 +0,0 @@
package nautilus.game.arcade.game.games.spleef.modes;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.spleef.Spleef;
import nautilus.game.arcade.game.games.spleef.kits.KitSnowballer;
/**
* UltraSpleef gamemode for Super Spleef
*
* @author xXVevzZXx
*/
public class UltraSpleef extends Spleef
{
public UltraSpleef(ArcadeManager manager)
{
super(manager);
}
@Override
@EventHandler(priority = EventPriority.LOW)
public void BlockDamage(BlockDamageEvent event)
{
if (!this.IsLive())
return;
if (!this.IsAlive(event.getPlayer()))
return;
event.setCancelled(true);
if (event.getBlock().getType() == Material.BEDROCK)
return;
BlockFade(event.getBlock(), event.getPlayer(), false);
for (Block block : UtilBlock.getSurrounding(event.getBlock(), false))
{
BlockFade(block, event.getPlayer(), false);
}
//Snowball
if (GetKit(event.getPlayer()) instanceof KitSnowballer && event.getBlock().getType() != Material.BEDROCK)
if (!UtilInv.contains(event.getPlayer(), Material.SNOW_BALL, (byte)0, 16))
event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL, 2));
}
@Override
@EventHandler
public void SnowballDamage(ProjectileHitEvent event)
{
if (!IsLive())
return;
if (!(event.getEntity() instanceof Snowball))
return;
Snowball ball = (Snowball)event.getEntity();
if (ball.getShooter() == null || !(ball.getShooter() instanceof Player))
return;
Location loc = ball.getLocation().add(ball.getVelocity().multiply(0.8));
Block block = loc.getBlock();
//Find Nearest if hit nothing :O
if (block.getType() == Material.AIR)
{
Block closest = null;
double closestDist = 0;
for (Block other : UtilBlock.getSurrounding(block, true))
{
if (other.getType() == Material.AIR)
continue;
double dist = UtilMath.offset(loc, other.getLocation().add(0.5, 0.5, 0.5));
if (closest == null || dist < closestDist)
{
closest = other;
closestDist = dist;
}
}
if (closest != null)
block = closest;
}
for (Block other : UtilBlock.getSurrounding(block, true))
{
BlockFade(other, (Player)ball.getShooter(), false);
}
}
@Override
public void BlockFade(Block block, Player player, boolean slowDamage)
{
if (block.getType() == Material.BEDROCK || block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA)
return;
//Prevent Super Hunger from Bow
if (Recharge.Instance.use(player, GetName() + " Hunger", 50, false, false))
UtilPlayer.hunger(player, 1);
if (!slowDamage)
{
Break(block, player);
return;
}
//Wool and Stained Clay
if (block.getTypeId() == 35 || block.getTypeId() == 159)
{
//Greens
if (block.getData() == 5 || block.getData() == 13)
block.setData((byte)14);
else
Break(block, player);
}
//Stone Brick
else if (block.getTypeId() == 98)
{
Break(block, player);
}
//Grass
else if (block.getTypeId() == 2)
{
Break(block, player);
}
//Wood Planks
else if (block.getTypeId() == 5)
{
if (block.getData() == 1)
block.setData((byte)0);
else
Break(block, player);
}
//Other
else if (block.getTypeId() != 7)
{
Break(block, player);
}
}
@Override
public String GetMode()
{
return "Ultra Spleef";
}
}