Update player death handling, add aggressive chicken behavior, minor changes and refactoring.

This commit is contained in:
Thanos paravantis 2016-02-26 18:17:03 +02:00
parent 0e697e279b
commit 1e08e1a5db
50 changed files with 1151 additions and 944 deletions

View File

@ -46,7 +46,7 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
protected void buildPage() protected void buildPage()
{ {
ArrayList<Integer> pageLayout = new ItemLayout( ArrayList<Integer> pageLayout = new ItemLayout(
"OXOXOXOXO", "XXXXOXXXO",
"OXOXOXOXO", "OXOXOXOXO",
"OXOXOXOXO", "OXOXOXOXO",
"OXOXOXOXO").getItemSlots(); "OXOXOXOXO").getItemSlots();

View File

@ -18,6 +18,7 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Chicken; import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -25,29 +26,35 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClient;
import mineplex.core.blood.BloodEvent;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTextTop; import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
@ -93,6 +100,7 @@ import nautilus.game.arcade.game.games.mineware.challenges.ChallengePickASide;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengePunchThePig; import nautilus.game.arcade.game.games.mineware.challenges.ChallengePunchThePig;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeRedLightGreenLight; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeRedLightGreenLight;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeReverseTag; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeReverseTag;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeRunner;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeRushPush; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeRushPush;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeShootChickens; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeShootChickens;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeSmashOff; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeSmashOff;
@ -222,6 +230,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_challenges.add(ChallengePunchThePig.class); _challenges.add(ChallengePunchThePig.class);
_challenges.add(ChallengeRedLightGreenLight.class); _challenges.add(ChallengeRedLightGreenLight.class);
_challenges.add(ChallengeReverseTag.class); _challenges.add(ChallengeReverseTag.class);
_challenges.add(ChallengeRunner.class); // TODO: To be tested.
_challenges.add(ChallengeRushPush.class); _challenges.add(ChallengeRushPush.class);
_challenges.add(ChallengeShootChickens.class); _challenges.add(ChallengeShootChickens.class);
_challenges.add(ChallengeSmashOff.class); _challenges.add(ChallengeSmashOff.class);
@ -657,7 +666,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
Scoreboard.Reset(); Scoreboard.Reset();
if (GetPlayers(true).size() > 14) if (super.GetPlayers(true).size() > 14)
{ {
int alive = 0; int alive = 0;
@ -761,19 +770,20 @@ public class BawkBawkBattles extends TeamGame implements IThrown
List<String> messages = Arrays.asList(challenge.getGameMessages()); List<String> messages = Arrays.asList(challenge.getGameMessages());
for (Player player : UtilServer.getPlayers()) for (Player player : GetPlayers(true))
{ {
UtilPlayer.message(player, F.count(ArcadeFormat.Line)); UtilPlayer.message(player, "");
// UtilPlayer.message(player, F.count(ArcadeFormat.Line));
UtilPlayer.message(player, " " + C.cYellow + challenge.getName()); UtilPlayer.message(player, " " + C.cYellow + challenge.getName() + C.Reset + " " + C.cGray + challenge.getType().toString());
UtilPlayer.message(player, ""); UtilPlayer.message(player, "");
for (String currentMessage : messages) for (String currentMessage : messages)
if (messages.get(messages.size() - 1) != currentMessage) if (messages.get(messages.size() - 1) != currentMessage)
UtilPlayer.message(player, C.cGray + " - " + C.cWhite + currentMessage); UtilPlayer.message(player, C.cGray + " - " + C.cWhite + currentMessage);
UtilPlayer.message(player, ""); // UtilPlayer.message(player, "");
UtilPlayer.message(player, F.count(ArcadeFormat.Line)); // UtilPlayer.message(player, F.count(ArcadeFormat.Line));
} }
while (true) while (true)
@ -781,7 +791,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
if (!IsLive()) if (!IsLive())
break; break;
for (Player player : UtilServer.getPlayers()) for (Player player : GetPlayers(true))
{ {
String message = C.cYellow + messages.get(looped); String message = C.cYellow + messages.get(looped);
UtilTextMiddle.display(challenge.getName(), message, 0, 60, 20); UtilTextMiddle.display(challenge.getName(), message, 0, 60, 20);
@ -870,7 +880,12 @@ public class BawkBawkBattles extends TeamGame implements IThrown
if (!IsLive()) if (!IsLive())
return; return;
if (!IsAlive(event.getPlayer())) Player player = event.getPlayer();
if (!IsAlive(player))
return;
if (!getChallengers().contains(player))
return; return;
if (!PrepareFreeze) if (!PrepareFreeze)
@ -897,6 +912,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
return; return;
Player player = event.getEntity(); Player player = event.getEntity();
if (_chickenTeam.HasPlayer(player))
return;
Location death = player.getLocation().clone(); Location death = player.getLocation().clone();
_challenge.getLost().add(player); _challenge.getLost().add(player);
@ -959,7 +978,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
return lives; return lives;
} }
public void handleFailure(Player player, boolean looseLife) public void handleFailure(Player player, boolean looseLife)
{ {
handleFailure(player, looseLife, false); handleFailure(player, looseLife, false);
@ -973,7 +992,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
taskFailedMessage(player, lives(player)); taskFailedMessage(player, lives(player));
// SetPlayerState(player, PlayerState.OUT); // SetPlayerState(player, PlayerState.OUT);
Manager.addSpectator(player, true); Manager.addSpectator(player, true);
if (cloak) if (cloak)
Manager.GetCondition().Factory().Cloak("Challenge Death", player, player, 7777, true, true); Manager.GetCondition().Factory().Cloak("Challenge Death", player, player, 7777, true, true);
} }
@ -994,7 +1013,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
if (player.equals(other)) if (player.equals(other))
continue; continue;
if (UtilMath.offset(other, player) > 5) if (UtilMath.offset(other, player) > 7)
continue; continue;
if (Recharge.Instance.use(player, "Approach Alive Player", 500, false, false)) if (Recharge.Instance.use(player, "Approach Alive Player", 500, false, false))
@ -1010,6 +1029,82 @@ public class BawkBawkBattles extends TeamGame implements IThrown
} }
} }
@EventHandler
public void onChickenAttack(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.SEC)
return;
if (_chickenTeam == null)
return;
if (_chickenTeam.GetSize() == 0)
return;
for (Player player : _chickenTeam.GetPlayers(true))
{
Chicken chicken = UtilMath.randomElement(_chickenAttack.getChickens());
// Chickens attacking too many players.
if (!chicken.isOnGround())
return;
UtilEnt.CreatureLook(chicken, player);
//UtilAction.velocity(chicken, UtilAlg.calculateVelocity(player.getVelocity(), chicken.getVelocity(), 1.0D));
UtilAction.velocity(chicken, UtilAlg.getTrajectory(chicken, player).setY(0.3D));
Manager.GetProjectile().AddThrow(
chicken,
null,
this,
-1,
true,
false,
false,
true,
0.8F);
}
}
@EventHandler
public void onChickenAttackParticle(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.TICK)
return;
for (Chicken chicken : _chickenAttack.getChickens())
{
if (!chicken.isOnGround())
{
UtilParticle.PlayParticle(ParticleType.FLAME, chicken.getLocation(), 0.1F, 0.1F, 0.1F, 0.02F, 1, ViewDist.NORMAL);
}
}
}
@EventHandler
public void onChickenAttackPlayerDeath(PlayerDeathEvent event)
{
if (!IsLive())
return;
if (_challenge == null)
return;
Player player = event.getEntity();
if (!_chickenTeam.HasPlayer(player))
return;
_chickenAttack.kill(player);
}
private void gameLostMessage(Player player) private void gameLostMessage(Player player)
{ {
UtilPlayer.message(player, ""); UtilPlayer.message(player, "");
@ -1236,8 +1331,8 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_chickenAttack = new ChickenAttack( _chickenAttack = new ChickenAttack(
this, this,
new Location(WorldData.World, 50, 0, 0), new Location(WorldData.World, 50, 0, 0),
new Location(WorldData.World, 47, 0, -3), new Location(WorldData.World, 45, 0, -5),
new Location(WorldData.World, 53, 0, 3)); new Location(WorldData.World, 55, 0, 5));
} }
@EventHandler @EventHandler
@ -1260,11 +1355,26 @@ public class BawkBawkBattles extends TeamGame implements IThrown
UtilTextMiddle.display(null, null, player); UtilTextMiddle.display(null, null, player);
} }
} }
@EventHandler @EventHandler
public void onBlood(BloodEvent event) public void onItemSpawn(ItemSpawnEvent event)
{ {
event.setCancelled(true); if (!IsLive())
return;
Item blood = event.getEntity();
ItemStack bloodItem = blood.getItemStack();
if (bloodItem.getType() == Material.INK_SACK && bloodItem.getData().getData() == 1)
{
if (bloodItem.hasItemMeta())
{
if (bloodItem.getItemMeta().hasDisplayName())
{
event.setCancelled(true);
}
}
}
} }
@EventHandler @EventHandler
@ -1458,6 +1568,23 @@ public class BawkBawkBattles extends TeamGame implements IThrown
public void Collide(LivingEntity target, Block block, ProjectileUser data) public void Collide(LivingEntity target, Block block, ProjectileUser data)
{ {
getCurrentChallenge().onCollide(target, block, data); getCurrentChallenge().onCollide(target, block, data);
if (data.GetThrown() instanceof Chicken)
{
if (target instanceof Player)
{
Player player = (Player) target;
if (_chickenTeam.HasPlayer(player) && IsAlive(player))
{
player.playSound(player.getLocation(), Sound.CHICKEN_HURT, 2.0F, 1.0F);
player.damage(4.0D);
if (UtilMath.random.nextBoolean())
UtilTextBottom.display(C.cRed + C.Bold + "bawk bawk!", player);
}
}
}
} }
@Override @Override

View File

@ -32,11 +32,6 @@ import nautilus.game.arcade.world.WorldData;
public abstract class Challenge implements Listener public abstract class Challenge implements Listener
{ {
public enum ChallengeType
{
LastStanding, FirstComplete
}
public BawkBawkBattles Host; public BawkBawkBattles Host;
private String _name; private String _name;

View File

@ -4,11 +4,11 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilPlayer;
public abstract class ChallengeSeperateRooms extends Challenge public abstract class ChallengeSeperateRooms extends Challenge
{ {
private HashMap<String, Integer[]> _borders = new HashMap<String, Integer[]>(); private HashMap<String, Integer[]> _borders = new HashMap<String, Integer[]>();

View File

@ -28,6 +28,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilShapes;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeAnvilDance extends Challenge public class ChallengeAnvilDance extends Challenge
{ {
@ -56,7 +57,12 @@ public class ChallengeAnvilDance extends Challenge
public ChallengeAnvilDance(BawkBawkBattles host) public ChallengeAnvilDance(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Anvil Dance", "It's raining anvils!", "Dodge them to stay alive."); super(
host,
ChallengeType.LastStanding,
"Anvil Dance",
"It's raining anvils!",
"Dodge them to stay alive.");
} }
@Override @Override
@ -321,7 +327,7 @@ public class ChallengeAnvilDance extends Challenge
if (times <= 10) if (times <= 10)
{ {
UtilFirework.playFirework(new Location(Host.WorldData.World, 0, height, 0), Type.BALL_LARGE, UtilFirework.playFirework(new Location(Host.WorldData.World, 0, height, 0), Type.BALL_LARGE,
Color.fromBGR(UtilMath.r(255), UtilMath.r(255), UtilMath.r(255)), false, true); Color.fromBGR(UtilMath.r(255), UtilMath.r(255), UtilMath.r(255)), false, true);
} }
height += _fireworkHeightIncrement; height += _fireworkHeightIncrement;

View File

@ -29,6 +29,7 @@ import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.game.games.mineware.AntiHackFix; import nautilus.game.arcade.game.games.mineware.AntiHackFix;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
import nautilus.game.arcade.game.games.mineware.events.ChallengeEndEvent; import nautilus.game.arcade.game.games.mineware.events.ChallengeEndEvent;
public class ChallengeArrowRampage extends Challenge public class ChallengeArrowRampage extends Challenge
@ -45,8 +46,7 @@ public class ChallengeArrowRampage extends Challenge
false, false,
true, true,
"You are equipped with explosive arrows.", "You are equipped with explosive arrows.",
"Force your enemy into the void!" "Force your enemy into the void!");
);
_antiHackFix = new AntiHackFix(this); _antiHackFix = new AntiHackFix(this);
} }
@ -88,7 +88,7 @@ public class ChallengeArrowRampage extends Challenge
for (Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
player.getInventory() player.getInventory()
.addItem(new ItemBuilder(Material.BOW).addEnchantment(Enchantment.ARROW_INFINITE, 1).build()); .addItem(new ItemBuilder(Material.BOW).addEnchantment(Enchantment.ARROW_INFINITE, 1).build());
player.getInventory().addItem(new ItemStack(Material.ARROW)); player.getInventory().addItem(new ItemStack(Material.ARROW));
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 2)); player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 2));
@ -209,7 +209,7 @@ public class ChallengeArrowRampage extends Challenge
{ {
Block hit = null; Block hit = null;
BlockIterator iterator = new BlockIterator(arrow.getLocation().getWorld(), arrow.getLocation().toVector(), BlockIterator iterator = new BlockIterator(arrow.getLocation().getWorld(), arrow.getLocation().toVector(),
arrow.getVelocity().normalize(), 0.0D, 4); arrow.getVelocity().normalize(), 0.0D, 4);
while (iterator.hasNext()) while (iterator.hasNext())
{ {
hit = iterator.next(); hit = iterator.next();

View File

@ -27,11 +27,12 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeBlockLobbers extends Challenge public class ChallengeBlockLobbers extends Challenge
{ {
private ArrayList<Material> _tBlocks = new ArrayList<Material>( private ArrayList<Material> _tBlocks = new ArrayList<Material>(
Arrays.asList(Material.GRASS, Material.DIRT, Material.SPONGE, Material.WOOD)); Arrays.asList(Material.GRASS, Material.DIRT, Material.SPONGE, Material.WOOD));
public ChallengeBlockLobbers(BawkBawkBattles host) public ChallengeBlockLobbers(BawkBawkBattles host)
{ {
@ -39,8 +40,7 @@ public class ChallengeBlockLobbers extends Challenge
host, ChallengeType.LastStanding, host, ChallengeType.LastStanding,
"Block Lobbers", "Block Lobbers",
"Throw blocks to other players.", "Throw blocks to other players.",
"Try to knock them off the platform!" "Try to knock them off the platform!");
);
} }
@Override @Override
@ -150,8 +150,8 @@ public class ChallengeBlockLobbers extends Challenge
return; return;
} }
FallingBlock fBlock = event.getPlayer().getWorld() FallingBlock fBlock = event.getPlayer().getWorld()
.spawnFallingBlock(event.getPlayer().getLocation().clone().add(0, .4, 0), .spawnFallingBlock(event.getPlayer().getLocation().clone().add(0, .4, 0),
event.getPlayer().getItemInHand().getType(), (byte) 0); event.getPlayer().getItemInHand().getType(), (byte) 0);
UtilInv.remove(event.getPlayer(), event.getPlayer().getItemInHand().getType(), (byte) 0, 1); UtilInv.remove(event.getPlayer(), event.getPlayer().getItemInHand().getType(), (byte) 0, 1);
UtilAction.velocity(fBlock, event.getPlayer().getLocation().getDirection(), 1.5, false, 0.0, 0.3, 10.0, true); UtilAction.velocity(fBlock, event.getPlayer().getLocation().getDirection(), 1.5, false, 0.0, 0.3, 10.0, true);
@ -204,7 +204,7 @@ public class ChallengeBlockLobbers extends Challenge
return; return;
} }
UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.GetThrown().getLocation(), target.getLocation()), 0.8, UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.GetThrown().getLocation(), target.getLocation()), 0.8,
false, 0, 0.3, 0.5, true); false, 0, 0.3, 0.5, true);
data.GetThrown().remove(); data.GetThrown().remove();
} }

View File

@ -30,6 +30,7 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.AntiHackFix; import nautilus.game.arcade.game.games.mineware.AntiHackFix;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeBouncingBlock extends Challenge public class ChallengeBouncingBlock extends Challenge
{ {
@ -39,8 +40,13 @@ public class ChallengeBouncingBlock extends Challenge
public ChallengeBouncingBlock(BawkBawkBattles host) public ChallengeBouncingBlock(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Bouncing Block", "Jump and punch floating wool blocks.", super(
"Avoid landing on red wool.", "First to 10 wins!"); host,
ChallengeType.FirstComplete,
"Bouncing Block",
"Jump and punch floating wool blocks.",
"Avoid landing on red wool.",
"First to 10 wins!");
_antiHackFix = new AntiHackFix(this); _antiHackFix = new AntiHackFix(this);
} }
@ -51,7 +57,7 @@ public class ChallengeBouncingBlock extends Challenge
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
for (Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 0, 0), true, for (Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 0, 0), true,
getArenaSize(9) - 2)) getArenaSize(9) - 2))
{ {
spawns.add(getCenter().clone().add(locs.getX() + 0.5, 1.1, locs.getZ() + 0.5)); spawns.add(getCenter().clone().add(locs.getX() + 0.5, 1.1, locs.getZ() + 0.5));
} }
@ -92,7 +98,7 @@ public class ChallengeBouncingBlock extends Challenge
public void generateRoom() public void generateRoom()
{ {
for (Location location : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 0, 0), false, for (Location location : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 0, 0), false,
getArenaSize(9))) getArenaSize(9)))
{ {
Block block = location.getBlock(); Block block = location.getBlock();
block.setType(Material.WOOL); block.setType(Material.WOOL);
@ -160,7 +166,7 @@ public class ChallengeBouncingBlock extends Challenge
continue; continue;
UtilTextBottom.display(C.Bold + "Score: " + C.Reset + C.cYellow + C.Bold + _playerScore.get(player), UtilTextBottom.display(C.Bold + "Score: " + C.Reset + C.cYellow + C.Bold + _playerScore.get(player),
player); player);
} }
} }
@ -197,7 +203,7 @@ public class ChallengeBouncingBlock extends Challenge
subtract(player, subtract); subtract(player, subtract);
UtilTextMiddle.display("", "Score decreased by " + C.cRed + subtract + C.Reset + "!", 5, 40, 5, UtilTextMiddle.display("", "Score decreased by " + C.cRed + subtract + C.Reset + "!", 5, 40, 5,
player); player);
player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0F, 1.0F); player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0F, 1.0F);
} }
} }
@ -266,7 +272,7 @@ public class ChallengeBouncingBlock extends Challenge
b.setData(color); b.setData(color);
UtilFirework.playFirework(b.getLocation().add(0.5, 0.5, 0.5), Type.BALL, UtilFirework.playFirework(b.getLocation().add(0.5, 0.5, 0.5), Type.BALL,
DyeColor.getByWoolData(b.getData()).getColor(), false, false); DyeColor.getByWoolData(b.getData()).getColor(), false, false);
_scoreBlocks.add(b); _scoreBlocks.add(b);
} }

View File

@ -1,88 +0,0 @@
package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.ChallengeSeperateRooms;
public class ChallengeBuildBuilding extends ChallengeSeperateRooms
{
private ArrayList<Material> _materials = new ArrayList<Material>();
private HashMap<Location, Material> _build = new HashMap<Location, Material>();
public ChallengeBuildBuilding(BawkBawkBattles host, String challengeName)
{
super(host, ChallengeType.FirstComplete, "Replicate the building!");
for (int x = 0; x < 3; x++)
{
for (int y = 0; y < 5; y++)
{
for (int z = 0; z < 3; z++)
{
}
}
}
}
@Override
public void generateRoom(Location loc)
{
// TODO Auto-generated method stub
}
@Override
public int getBorderX()
{
return 10;
}
@Override
public int getBorderY()
{
return 20;
}
@Override
public int getBorderZ()
{
return 10;
}
@Override
public int getDividersX()
{
return 5;
}
@Override
public int getDividersZ()
{
return 5;
}
@Override
public void cleanupRoom()
{
// TODO Auto-generated method stub
}
@Override
public void setupPlayers()
{
for (Player player : getChallengers())
{
player.setGameMode(GameMode.CREATIVE);
}
}
}

View File

@ -4,17 +4,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilTextMiddle;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -25,6 +14,18 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilTextMiddle;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeBuildRace extends Challenge public class ChallengeBuildRace extends Challenge
{ {
// The amount of blocks for every hotbar slot. // The amount of blocks for every hotbar slot.
@ -44,8 +45,12 @@ public class ChallengeBuildRace extends Challenge
public ChallengeBuildRace(BawkBawkBattles host) public ChallengeBuildRace(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Build Race", "Your inventory is filled with blocks.", super(
"Be the first to place them all in the ground!"); host,
ChallengeType.FirstComplete,
"Build Race",
"Your inventory is filled with blocks.",
"Place them all in the ground!");
} }
@Override @Override

View File

@ -2,10 +2,6 @@ package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList; import java.util.ArrayList;
import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -18,11 +14,20 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeChestLoot extends Challenge public class ChallengeChestLoot extends Challenge
{ {
public ChallengeChestLoot(BawkBawkBattles host) public ChallengeChestLoot(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete,"Diamond Seeker", "Find a diamond in the chests."); super(
host,
ChallengeType.FirstComplete,
"Diamond Seeker",
"Find a diamond in the chests.");
} }
@Override @Override
@ -30,9 +35,9 @@ public class ChallengeChestLoot extends Challenge
{ {
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
for (int x = -(getArenaSize() - 1); x <= getArenaSize()-1; x++) for (int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++)
{ {
for (int z = -(getArenaSize() - 1); z <= getArenaSize()-1; z++) for (int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{ {
if (x % 2 == 0 && z % 2 == 0) if (x % 2 == 0 && z % 2 == 0)
{ {

View File

@ -1,125 +0,0 @@
package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList;
import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
public class ChallengeChickenFishing extends Challenge
{
private ArrayList<Entity> _chickens = new ArrayList<Entity>();
private ArrayList<Location> _spawns = new ArrayList<Location>();
private ArrayList<Location> _chickenSpawns = new ArrayList<Location>();
public ChallengeChickenFishing(BawkBawkBattles host)
{
super(host, ChallengeType.FirstComplete,"Chicken Fishing", "Fish all dem Chickens");
}
@Override
public ArrayList<Location> getSpawns()
{
return _spawns;
}
@EventHandler
public void onSecond(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
Iterator<Entity> itel = _chickens.iterator();
while (itel.hasNext())
{
Entity ent = itel.next();
// TODO Validate chicken is caught
if (!ent.isValid())
{
itel.remove();
}
}
for (Player player : getChallengers())
{
Block block = player.getLocation().getBlock();
if (block.isLiquid())
{
setLost(player);
}
}
}
@Override
public void cleanupRoom()
{
for (Entity chicken : _chickens)
{
chicken.remove();
}
}
@Override
public void setupPlayers()
{
for (Player player : getChallengers())
{
player.getInventory().addItem(new ItemStack(Material.FISHING_ROD));
}
}
@Override
public void generateRoom()
{
int size = (getChallengers().size() / 2) + 4;
for (Location location : UtilShapes.getCircle(getCenter(), true, size))
{
Block block = location.getBlock();
for (int y = 0; y <= 7; y++)
{
Block b = block.getRelative(0, y, 0);
if (y < 3 || (y < 5 && UtilMath.random.nextBoolean()))
{
b.setType(Material.STONE);
}
else if (y != 7)
{
b.setType(Material.DIRT);
}
else
{
b.setType(Material.GRASS);
}
}
_spawns.add(location.clone().add(0.5, 7.1, 0.5));
}
for (Location location : UtilShapes.getCircle(getCenter(), false,
size - 1))
{
_chickenSpawns.add(location.add(0.5, 0.5, 0.5));
}
}
}

View File

@ -15,12 +15,18 @@ import mineplex.core.common.util.UtilShapes;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeCloudFall extends Challenge public class ChallengeCloudFall extends Challenge
{ {
public ChallengeCloudFall(BawkBawkBattles host) public ChallengeCloudFall(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Cloud Fall", "Jump and land on the green wool.", "Make sure to avoid the clouds.", "First to the bottom wins!"); super(
host,
ChallengeType.FirstComplete,
"Cloud Fall",
"Jump and land on green wool.",
"Avoid the deadly clouds!");
} }
@Override @Override
@ -28,24 +34,24 @@ public class ChallengeCloudFall extends Challenge
{ {
{ {
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize() - 1); x <= getArenaSize(); x++) for (int x = -(getArenaSize() - 1); x <= getArenaSize(); x++)
{ {
for(int z = -(getArenaSize() - 1); z <= getArenaSize(); z++) for (int z = -(getArenaSize() - 1); z <= getArenaSize(); z++)
{ {
boolean goodSpawn = true; boolean goodSpawn = true;
int y = 73; int y = 73;
if(x % 2 == 0 && z % 2 == 0) if (x % 2 == 0 && z % 2 == 0)
{ {
while(Host.WorldData.World.getBlockAt(x, y, z).getType() == Material.AIR) while (Host.WorldData.World.getBlockAt(x, y, z).getType() == Material.AIR)
{ {
if(y > 76) if (y > 76)
{ {
goodSpawn = false; goodSpawn = false;
break; break;
} }
y++; y++;
} }
if(goodSpawn) if (goodSpawn)
{ {
spawns.add(getCenter().clone().add(x + 0.5, y + 1.1, z + 0.5)); spawns.add(getCenter().clone().add(x + 0.5, y + 1.1, z + 0.5));
} }
@ -73,33 +79,33 @@ public class ChallengeCloudFall extends Challenge
@Override @Override
public void generateRoom() public void generateRoom()
{ {
for(int x = -getArenaSize(); x <= getArenaSize(); x++) for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{ {
for(int z = -getArenaSize(); z <= getArenaSize(); z++) for (int z = -getArenaSize(); z <= getArenaSize(); z++)
{ {
for(int y = 0; y <= 75; y++) for (int y = 0; y <= 75; y++)
{ {
Block b = getCenter().getBlock().getRelative(x, y, z); Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0) if (y == 0)
{ {
b.setType(Material.WOOL); b.setType(Material.WOOL);
} }
if(y == 1 && Math.abs(x) < getArenaSize()-2 && Math.abs(z) < getArenaSize()-2) if (y == 1 && Math.abs(x) < getArenaSize() - 2 && Math.abs(z) < getArenaSize() - 2)
{ {
if(UtilMath.r(8) == 0) if (UtilMath.r(8) == 0)
{ {
b.setType(Material.WOOL); b.setType(Material.WOOL);
b.setData((byte) 5); b.setData((byte) 5);
b.getRelative(BlockFace.UP).setType(Material.WOOL); b.getRelative(BlockFace.UP).setType(Material.WOOL);
b.getRelative(BlockFace.UP).setData((byte)5); b.getRelative(BlockFace.UP).setData((byte) 5);
addBlock(b.getRelative(BlockFace.UP)); addBlock(b.getRelative(BlockFace.UP));
} }
} }
if(y > 10 && y < 70) if (y > 10 && y < 70)
{ {
if(UtilMath.r(200) == 1) if (UtilMath.r(200) == 1)
{ {
// RIP DRY rule ;-;. plz don't hurt me :( // RIP DRY rule ;-;. plz don't hurt me :(
b.getRelative(BlockFace.NORTH).setType(Material.STAINED_CLAY); b.getRelative(BlockFace.NORTH).setType(Material.STAINED_CLAY);
@ -113,7 +119,7 @@ public class ChallengeCloudFall extends Challenge
addBlock(b.getRelative(BlockFace.SOUTH)); addBlock(b.getRelative(BlockFace.SOUTH));
} }
} }
if(b.getType() != Material.AIR) if (b.getType() != Material.AIR)
{ {
addBlock(b); addBlock(b);
} }
@ -122,13 +128,13 @@ public class ChallengeCloudFall extends Challenge
} }
// The spawning platform // The spawning platform
int size = 8; int size = 8;
for(Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 75, 0), false, size)) for (Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 75, 0), false, size))
{ {
locs.getBlock().setType(Material.WOOL); locs.getBlock().setType(Material.WOOL);
locs.getBlock().setData((byte) UtilMath.r(16)); locs.getBlock().setData((byte) UtilMath.r(16));
addBlock(locs.getBlock()); addBlock(locs.getBlock());
} }
for(Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 75, 0), false, size/2)) for (Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 75, 0), false, size / 2))
{ {
locs.getBlock().setType(Material.AIR); locs.getBlock().setType(Material.AIR);
} }
@ -138,30 +144,30 @@ public class ChallengeCloudFall extends Challenge
@EventHandler @EventHandler
public void onfallDamage(CustomDamageEvent event) public void onfallDamage(CustomDamageEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(!(event.GetDamageeEntity() instanceof Player)) if (!(event.GetDamageeEntity() instanceof Player))
{ {
return; return;
} }
if(event.GetCause() != DamageCause.FALL) if (event.GetCause() != DamageCause.FALL)
{ {
return; return;
} }
if(isDone(event.GetDamageePlayer())) if (isDone(event.GetDamageePlayer()))
{ {
return; return;
} }
if(Math.round(event.GetDamageePlayer().getLocation().getY()) == 3) if (Math.round(event.GetDamageePlayer().getLocation().getY()) == 3)
{ {
event.SetCancelled("fell on wool"); event.SetCancelled("fell on wool");
SetCompleted(event.GetDamageePlayer()); SetCompleted(event.GetDamageePlayer());
} }
// else // else
// { // {
// event.AddMod("Increased Damage", "Missed jump", 2, false); // event.AddMod("Increased Damage", "Missed jump", 2, false);
// } // }
} }
} }

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -30,6 +29,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeDogsVersusCats extends Challenge public class ChallengeDogsVersusCats extends Challenge
{ {
@ -42,8 +42,14 @@ public class ChallengeDogsVersusCats extends Challenge
public ChallengeDogsVersusCats(BawkBawkBattles host) public ChallengeDogsVersusCats(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Dogs VS Cats", "If you are a dog, bark.", "If you are a cat, meow.", super(
"Look up and punch to bark or meow.", "First team to the end number wins!"); host,
ChallengeType.FirstComplete,
"Dogs Vs Cats",
"If you are a dog, bark.",
"If you are a cat, meow.",
"Look up and punch to bark or meow.",
"First team to the end number wins!");
} }
@Override @Override
@ -101,7 +107,7 @@ public class ChallengeDogsVersusCats extends Challenge
Host.getArcadeManager().GetDisguise().disguise(Ddog); Host.getArcadeManager().GetDisguise().disguise(Ddog);
player.getInventory().addItem( player.getInventory().addItem(
ItemStackFactory.Instance.CreateStack(Material.BONE, (byte) 0, 1, C.Reset + C.Bold + "Left-Click to bark!")); ItemStackFactory.Instance.CreateStack(Material.BONE, (byte) 0, 1, C.Reset + C.Bold + "Left-Click to bark!"));
UtilPlayer.message(player, C.cYellow + C.Bold + "You are a Dog, bark!"); UtilPlayer.message(player, C.cYellow + C.Bold + "You are a Dog, bark!");
} }
else else
@ -112,7 +118,7 @@ public class ChallengeDogsVersusCats extends Challenge
Host.getArcadeManager().GetDisguise().disguise(Dcat); Host.getArcadeManager().GetDisguise().disguise(Dcat);
player.getInventory().addItem( player.getInventory().addItem(
ItemStackFactory.Instance.CreateStack(Material.STRING, (byte) 0, 1, C.Reset + C.Bold + "Left-Click to meow!")); ItemStackFactory.Instance.CreateStack(Material.STRING, (byte) 0, 1, C.Reset + C.Bold + "Left-Click to meow!"));
UtilPlayer.message(player, C.cYellow + C.Bold + "You are a Cat, meow!"); UtilPlayer.message(player, C.cYellow + C.Bold + "You are a Cat, meow!");
} }
looped++; looped++;
@ -187,7 +193,7 @@ public class ChallengeDogsVersusCats extends Challenge
int dogScore = calculateScore("dog"); int dogScore = calculateScore("dog");
UtilTextMiddle.display("", C.cBlue + C.Bold + " Dogs: " + C.cGreen + _dogScore + "/" + dogScore + C.cGray + " - " + C.cRed + C.Bold UtilTextMiddle.display("", C.cBlue + C.Bold + " Dogs: " + C.cGreen + _dogScore + "/" + dogScore + C.cGray + " - " + C.cRed + C.Bold
+ "Cats: " + C.cGreen + _catScore + "/" + catScore); + "Cats: " + C.cGreen + _catScore + "/" + catScore);
if (_catScore >= catScore) if (_catScore >= catScore)
{ {
@ -251,7 +257,7 @@ public class ChallengeDogsVersusCats extends Challenge
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.WOLF_BARK, 1f, 1f); event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.WOLF_BARK, 1f, 1f);
} }
UtilParticle.PlayParticle(ParticleType.NOTE, event.getPlayer().getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0f, 2, ViewDist.MAX, UtilParticle.PlayParticle(ParticleType.NOTE, event.getPlayer().getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0f, 2, ViewDist.MAX,
UtilServer.getPlayers()); UtilServer.getPlayers());
} }
} }

View File

@ -22,6 +22,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeDragonEgg extends Challenge public class ChallengeDragonEgg extends Challenge
{ {
@ -30,7 +31,11 @@ public class ChallengeDragonEgg extends Challenge
public ChallengeDragonEgg(BawkBawkBattles host) public ChallengeDragonEgg(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Dragon egg", "Whack a dragon egg 10 times."); super(
host,
ChallengeType.FirstComplete,
"Dragon egg",
"Whack a dragon egg 10 times.");
} }
@Override @Override
@ -76,22 +81,22 @@ public class ChallengeDragonEgg extends Challenge
block.setType(Material.AIR); block.setType(Material.AIR);
UtilParticle.PlayParticle(ParticleType.PORTAL, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0, 11, UtilParticle.PlayParticle(ParticleType.PORTAL, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0, 11,
ViewDist.MAX, ViewDist.MAX,
UtilServer.getPlayers()); UtilServer.getPlayers());
Host.CreatureAllowOverride = true; Host.CreatureAllowOverride = true;
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
Block b = getCenter().clone() Block b = getCenter().clone()
.add(UtilMath.r((getArenaSize() * 2)) - (getArenaSize()), 1, .add(UtilMath.r((getArenaSize() * 2)) - (getArenaSize()), 1,
UtilMath.r((getArenaSize() * 2)) - (getArenaSize())) UtilMath.r((getArenaSize() * 2)) - (getArenaSize()))
.getBlock(); .getBlock();
if (b.getType() == Material.AIR) if (b.getType() == Material.AIR)
{ {
Entity entity = getCenter().getWorld().spawnFallingBlock(b.getLocation().add(0.5, 2, 0.5), Entity entity = getCenter().getWorld().spawnFallingBlock(b.getLocation().add(0.5, 2, 0.5),
Material.DRAGON_EGG, (byte) 0); Material.DRAGON_EGG, (byte) 0);
_dragonEggs.add(entity); _dragonEggs.add(entity);
@ -111,8 +116,8 @@ public class ChallengeDragonEgg extends Challenge
int score = _smashedEggs.get(player.getName()) + 1; int score = _smashedEggs.get(player.getName()) + 1;
displayCount(player, block.getLocation().add(0.5, 1, 0.5), displayCount(player, block.getLocation().add(0.5, 1, 0.5),
(score >= 10 ? C.cDGreen : score >= 7 ? C.cGreen : score >= 4 ? C.cRed : C.cDRed) (score >= 10 ? C.cDGreen : score >= 7 ? C.cGreen : score >= 4 ? C.cRed : C.cDRed)
+ score); + score);
_smashedEggs.put(player.getName(), score); _smashedEggs.put(player.getName(), score);
@ -140,7 +145,7 @@ public class ChallengeDragonEgg extends Challenge
{ {
_smashedEggs.put(player.getName(), 0); _smashedEggs.put(player.getName(), 0);
player.getInventory().setItem(0, player.getInventory().setItem(0,
new ItemBuilder(Material.IRON_AXE).setTitle(C.cWhite + "Egg Smasher").build()); new ItemBuilder(Material.IRON_AXE).setTitle(C.cWhite + "Egg Smasher").build());
} }
} }
@ -162,7 +167,7 @@ public class ChallengeDragonEgg extends Challenge
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
{ {
Block b = getCenter().getBlock().getRelative(UtilMath.r(getArenaSize() * 2) - (getArenaSize()), 1, Block b = getCenter().getBlock().getRelative(UtilMath.r(getArenaSize() * 2) - (getArenaSize()), 1,
UtilMath.r(getArenaSize() * 2) - (getArenaSize())); UtilMath.r(getArenaSize() * 2) - (getArenaSize()));
b.setType(Material.DRAGON_EGG); b.setType(Material.DRAGON_EGG);
addBlock(b); addBlock(b);
} }

View File

@ -3,17 +3,6 @@ package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilTextBottom;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -28,6 +17,18 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilTextBottom;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeFallingBlocks extends Challenge public class ChallengeFallingBlocks extends Challenge
{ {
// The chance of an anvil to spawn in a single block. // The chance of an anvil to spawn in a single block.
@ -55,21 +56,36 @@ public class ChallengeFallingBlocks extends Challenge
private HashSet<Block> _remaining = new HashSet<Block>(); private HashSet<Block> _remaining = new HashSet<Block>();
// The array of materials used to generate random falling blocks. // The array of materials used to generate random falling blocks.
private Material[] _materials = private Material[] _materials = {
{ Material.GRASS, Material.DIRT, Material.STONE, Material.LOG, Material.WOOD, Material.COBBLESTONE, Material.GRAVEL, Material.COAL_ORE, Material.GRASS,
Material.IRON_ORE, Material.HAY_BLOCK, Material.JUKEBOX, Material.SMOOTH_BRICK, Material.EMERALD_ORE, Material.FURNACE }; Material.DIRT,
Material.STONE,
Material.LOG,
Material.WOOD,
Material.COBBLESTONE,
Material.GRAVEL,
Material.COAL_ORE,
Material.IRON_ORE,
Material.HAY_BLOCK,
Material.JUKEBOX,
Material.SMOOTH_BRICK,
Material.EMERALD_ORE,
Material.FURNACE };
// The array of materials used to generate random floor. // The array of materials used to generate random floor.
private Material[] _floor = private Material[] _floor = { Material.GRASS, Material.DIRT, Material.STONE, Material.COBBLESTONE };
{ Material.GRASS, Material.DIRT, Material.STONE, Material.COBBLESTONE };
// The array of sounds used to play when a new wave is being deployed. // The array of sounds used to play when a new wave is being deployed.
private Sound[] _sounds = private Sound[] _sounds = { Sound.DIG_GRASS, Sound.DIG_GRAVEL, Sound.DIG_SAND, Sound.DIG_SNOW, Sound.DIG_STONE, Sound.DIG_WOOD, Sound.DIG_WOOL };
{ Sound.DIG_GRASS, Sound.DIG_GRAVEL, Sound.DIG_SAND, Sound.DIG_SNOW, Sound.DIG_STONE, Sound.DIG_WOOD, Sound.DIG_WOOL };
public ChallengeFallingBlocks(BawkBawkBattles host) public ChallengeFallingBlocks(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Falling Blocks", "Blocks are falling from the sky!", "Try to avoid getting hit."); super(
host,
ChallengeType.LastStanding,
"Falling Blocks",
"Blocks are falling from the sky!",
"Try to avoid getting hit.");
_time = (int) _nextWave; _time = (int) _nextWave;
_modifiedSpawnChance = _spawnChance; _modifiedSpawnChance = _spawnChance;
@ -81,7 +97,7 @@ public class ChallengeFallingBlocks extends Challenge
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
Location center = new Location(Host.WorldData.World, 0, 0, 0); Location center = new Location(Host.WorldData.World, 0, 0, 0);
for(Location location : UtilShapes.getCircle(center, true, getArenaSize() - 3)) for (Location location : UtilShapes.getCircle(center, true, getArenaSize() - 3))
{ {
double x = location.getX() + 0.5; double x = location.getX() + 0.5;
double y = 1.1; double y = 1.1;
@ -99,15 +115,15 @@ public class ChallengeFallingBlocks extends Challenge
{ {
Location center = new Location(Host.WorldData.World, 0, 0, 0); Location center = new Location(Host.WorldData.World, 0, 0, 0);
for(Location location : UtilShapes.getCircle(center, false, getArenaSize())) for (Location location : UtilShapes.getCircle(center, false, getArenaSize()))
{ {
Material material = _floor[UtilMath.r(_floor.length)]; Material material = _floor[UtilMath.r(_floor.length)];
Block block = location.getBlock(); Block block = location.getBlock();
block.setType(material); block.setType(material);
if(material == Material.STONE) if (material == Material.STONE)
{ {
if(UtilMath.random.nextBoolean()) if (UtilMath.random.nextBoolean())
{ {
block.setData((byte) 5); block.setData((byte) 5);
} }
@ -131,16 +147,16 @@ public class ChallengeFallingBlocks extends Challenge
_wavesCompleted = 0; _wavesCompleted = 0;
_modifiedSpawnChance = 0; _modifiedSpawnChance = 0;
for(Block block : _remaining) for (Block block : _remaining)
{ {
block.setType(Material.AIR); block.setType(Material.AIR);
} }
_remaining.clear(); _remaining.clear();
for(Entity entity : Host.WorldData.World.getEntities()) for (Entity entity : Host.WorldData.World.getEntities())
{ {
if(entity instanceof FallingBlock) if (entity instanceof FallingBlock)
{ {
entity.remove(); entity.remove();
} }
@ -156,10 +172,10 @@ public class ChallengeFallingBlocks extends Challenge
@EventHandler @EventHandler
public void onEntityChangeBlockEvent(final EntityChangeBlockEvent event) public void onEntityChangeBlockEvent(final EntityChangeBlockEvent event)
{ {
if(!Host.IsLive() || !Host.isChallengeStarted()) if (!Host.IsLive() || !Host.isChallengeStarted())
return; return;
if(event.getEntity() instanceof FallingBlock) if (event.getEntity() instanceof FallingBlock)
{ {
final Block block = event.getBlock(); final Block block = event.getBlock();
_remaining.add(block); _remaining.add(block);
@ -169,14 +185,14 @@ public class ChallengeFallingBlocks extends Challenge
@Override @Override
public void run() public void run()
{ {
if(!Host.IsLive() || !Host.isChallengeStarted()) if (!Host.IsLive() || !Host.isChallengeStarted())
{ {
cancel(); cancel();
return; return;
} }
UtilParticle.PlayParticle(ParticleType.BLOCK_CRACK.getParticle(block.getType(), 0), block.getLocation(), 0.3F, 0.3F, 0.3F, 0.0F, UtilParticle.PlayParticle(ParticleType.BLOCK_CRACK.getParticle(block.getType(), 0), block.getLocation(), 0.3F, 0.3F, 0.3F, 0.0F,
3, ViewDist.LONG, UtilServer.getPlayers()); 3, ViewDist.LONG, UtilServer.getPlayers());
block.setType(Material.AIR); block.setType(Material.AIR);
_remaining.remove(block); _remaining.remove(block);
@ -188,10 +204,10 @@ public class ChallengeFallingBlocks extends Challenge
@EventHandler @EventHandler
public void onBlockFade(BlockFadeEvent event) public void onBlockFade(BlockFadeEvent event)
{ {
if(!Host.IsLive() || !Host.isChallengeStarted()) if (!Host.IsLive() || !Host.isChallengeStarted())
return; return;
if(event.getNewState().getType() == Material.DIRT || event.getNewState().getType() == Material.GRASS) if (event.getNewState().getType() == Material.DIRT || event.getNewState().getType() == Material.GRASS)
event.setCancelled(true); event.setCancelled(true);
} }
@ -202,7 +218,7 @@ public class ChallengeFallingBlocks extends Challenge
@Override @Override
public void run() public void run()
{ {
if(!Host.IsLive() || !Host.isChallengeStarted()) if (!Host.IsLive() || !Host.isChallengeStarted())
{ {
cancel(); cancel();
return; return;
@ -220,13 +236,13 @@ public class ChallengeFallingBlocks extends Challenge
@Override @Override
public void run() public void run()
{ {
if(!Host.IsLive() || !Host.isChallengeStarted()) if (!Host.IsLive() || !Host.isChallengeStarted())
{ {
cancel(); cancel();
return; return;
} }
if(_time <= 0) if (_time <= 0)
{ {
_time = (int) _nextWave; _time = (int) _nextWave;
} }
@ -234,7 +250,7 @@ public class ChallengeFallingBlocks extends Challenge
int wave = _wavesCompleted + 1; int wave = _wavesCompleted + 1;
String time = C.cWhite + C.Bold + _time; String time = C.cWhite + C.Bold + _time;
if(wave > 1) if (wave > 1)
{ {
UtilTextBottom.display(C.cYellow + C.Bold + "Next Wave: " + time, UtilServer.getPlayers()); UtilTextBottom.display(C.cYellow + C.Bold + "Next Wave: " + time, UtilServer.getPlayers());
} }
@ -250,34 +266,34 @@ public class ChallengeFallingBlocks extends Challenge
private void createWave() private void createWave()
{ {
if(_modifiedSpawnChance < 100.0) if (_modifiedSpawnChance < 100.0)
_modifiedSpawnChance += _incrementRate; _modifiedSpawnChance += _incrementRate;
_wavesCompleted++; _wavesCompleted++;
Sound nextSound = _sounds[UtilMath.r(_sounds.length)]; Sound nextSound = _sounds[UtilMath.r(_sounds.length)];
for(Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
player.playSound(player.getLocation(), nextSound, 1.0F, 1.5F); player.playSound(player.getLocation(), nextSound, 1.0F, 1.5F);
} }
Location center = new Location(Host.WorldData.World, 0, _waveHeight, 0); Location center = new Location(Host.WorldData.World, 0, _waveHeight, 0);
for(Location location : UtilShapes.getCircle(center, false, getArenaSize())) for (Location location : UtilShapes.getCircle(center, false, getArenaSize()))
{ {
if(Math.random() * 100 <= _modifiedSpawnChance) if (Math.random() * 100 <= _modifiedSpawnChance)
{ {
createFallingBlock(location); createFallingBlock(location);
} }
} }
// Prevent camping // Prevent camping
for(Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
Location camp = player.getLocation(); Location camp = player.getLocation();
if(camp.getY() >= 1 && camp.getY() <= 3) if (camp.getY() >= 1 && camp.getY() <= 3)
{ {
createFallingBlock(new Location(Host.WorldData.World, camp.getX(), _waveHeight, camp.getZ())); createFallingBlock(new Location(Host.WorldData.World, camp.getX(), _waveHeight, camp.getZ()));
} }
@ -293,8 +309,8 @@ public class ChallengeFallingBlocks extends Challenge
FallingBlock block = world.spawnFallingBlock(location, material, (byte) 0); FallingBlock block = world.spawnFallingBlock(location, material, (byte) 0);
block.setDropItem(false); block.setDropItem(false);
if(material == Material.SMOOTH_BRICK || material == Material.DIRT) if (material == Material.SMOOTH_BRICK || material == Material.DIRT)
if(UtilMath.random.nextBoolean()) if (UtilMath.random.nextBoolean())
block = world.spawnFallingBlock(location, material, (byte) 2); block = world.spawnFallingBlock(location, material, (byte) 2);
damageNearby(block); damageNearby(block);
@ -307,21 +323,21 @@ public class ChallengeFallingBlocks extends Challenge
@Override @Override
public void run() public void run()
{ {
if(!Host.IsLive() || !block.isValid() || block.isOnGround() || !Host.isChallengeStarted()) if (!Host.IsLive() || !block.isValid() || block.isOnGround() || !Host.isChallengeStarted())
{ {
cancel(); cancel();
return; return;
} }
for(Entity entity : block.getNearbyEntities(0.05, 0.05, 0.05)) for (Entity entity : block.getNearbyEntities(0.05, 0.05, 0.05))
{ {
if(entity instanceof Player) if (entity instanceof Player)
{ {
Player player = (Player) entity; Player player = (Player) entity;
if(isDone(player)) if (isDone(player))
return; return;
if(!Host.IsAlive(player)) if (!Host.IsAlive(player))
return; return;
player.damage(player.getHealth()); player.damage(player.getHealth());

View File

@ -2,20 +2,6 @@ package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList; import java.util.ArrayList;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -30,21 +16,51 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeFastFood extends Challenge public class ChallengeFastFood extends Challenge
{ {
private Material[] _food = private Material[] _food = {
{ Material.APPLE, Material.BREAD, Material.GRILLED_PORK, Material.COOKED_BEEF, Material.RAW_FISH, Material.COOKED_FISH, Material.CAKE, Material.APPLE,
Material.COOKIE, Material.MELON, Material.COOKED_CHICKEN, Material.CARROT_ITEM, Material.BAKED_POTATO, Material.PUMPKIN_PIE }; Material.BREAD,
Material.GRILLED_PORK,
Material.COOKED_BEEF,
Material.RAW_FISH,
Material.COOKED_FISH,
Material.CAKE,
Material.COOKIE,
Material.MELON,
Material.COOKED_CHICKEN,
Material.CARROT_ITEM,
Material.BAKED_POTATO,
Material.PUMPKIN_PIE };
private Material[] _flowers = private Material[] _flowers = { Material.LONG_GRASS, Material.YELLOW_FLOWER, Material.RED_ROSE };
{ Material.LONG_GRASS, Material.YELLOW_FLOWER, Material.RED_ROSE };
private int _itemSeperator = 0; private int _itemSeperator = 0;
public ChallengeFastFood(BawkBawkBattles host) public ChallengeFastFood(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Fast Food", "Your inventory is full of food!", "Punch to throw it in the ground.", super(
"First player to drop them all wins."); host,
ChallengeType.FirstComplete,
"Fast Food",
"Your inventory is full of food.",
"Punch to throw it in the ground.",
"First player to drop them all wins!");
} }
@Override @Override
@ -53,7 +69,7 @@ public class ChallengeFastFood extends Challenge
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
Location center = new Location(Host.WorldData.World, 0, 0, 0); Location center = new Location(Host.WorldData.World, 0, 0, 0);
for(Location location : UtilShapes.getCircle(center, true, getArenaSize() - 3)) for (Location location : UtilShapes.getCircle(center, true, getArenaSize() - 3))
{ {
double x = location.getX() + 0.5; double x = location.getX() + 0.5;
double y = 1.1; double y = 1.1;
@ -70,7 +86,7 @@ public class ChallengeFastFood extends Challenge
{ {
Location center = new Location(Host.WorldData.World, 0, 0, 0); Location center = new Location(Host.WorldData.World, 0, 0, 0);
for(Location location : UtilShapes.getCircle(center, false, getArenaSize())) for (Location location : UtilShapes.getCircle(center, false, getArenaSize()))
{ {
Block block = location.getBlock(); Block block = location.getBlock();
block.setType(Material.GRASS); block.setType(Material.GRASS);
@ -84,9 +100,9 @@ public class ChallengeFastFood extends Challenge
{ {
itemParticleTask(); itemParticleTask();
for(Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
for(int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
{ {
player.getInventory().setItem(i, getRandomFood()); player.getInventory().setItem(i, getRandomFood());
} }
@ -98,9 +114,9 @@ public class ChallengeFastFood extends Challenge
{ {
_itemSeperator = 0; _itemSeperator = 0;
for(Entity entity : Host.WorldData.World.getEntities()) for (Entity entity : Host.WorldData.World.getEntities())
{ {
if(entity instanceof Item) if (entity instanceof Item)
{ {
entity.remove(); entity.remove();
} }
@ -110,14 +126,14 @@ public class ChallengeFastFood extends Challenge
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) public void onPlayerInteract(PlayerInteractEvent event)
{ {
if(!Host.IsLive() || !Host.isChallengeStarted()) if (!Host.IsLive() || !Host.isChallengeStarted())
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if(UtilEvent.isAction(event, ActionType.L) && !isDone(player)) if (UtilEvent.isAction(event, ActionType.L) && !isDone(player))
{ {
if(event.getItem() != null) if (event.getItem() != null)
{ {
ItemStack item = event.getItem(); ItemStack item = event.getItem();
throwItemInGround(player, item); throwItemInGround(player, item);
@ -136,23 +152,23 @@ public class ChallengeFastFood extends Challenge
@Override @Override
public void run() public void run()
{ {
if(!Host.IsLive() || !Host.isChallengeStarted()) if (!Host.IsLive() || !Host.isChallengeStarted())
{ {
cancel(); cancel();
return; return;
} }
for(Entity entity : Host.WorldData.World.getEntities()) for (Entity entity : Host.WorldData.World.getEntities())
{ {
if(entity instanceof Item) if (entity instanceof Item)
{ {
Item item = (Item) entity; Item item = (Item) entity;
if(!item.isValid() || item.isDead() || item.isOnGround() || item.getItemStack().getType() == Material.INK_SACK) if (!item.isValid() || item.isDead() || item.isOnGround() || item.getItemStack().getType() == Material.INK_SACK)
continue; continue;
UtilParticle.PlayParticle(ParticleType.INSTANT_SPELL, item.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilParticle.PlayParticle(ParticleType.INSTANT_SPELL, item.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL,
UtilServer.getPlayers()); UtilServer.getPlayers());
} }
} }
} }
@ -164,11 +180,11 @@ public class ChallengeFastFood extends Challenge
Material foodMaterial = UtilMath.randomElement(_food); Material foodMaterial = UtilMath.randomElement(_food);
byte data = 0; byte data = 0;
if(foodMaterial == Material.RAW_FISH) if (foodMaterial == Material.RAW_FISH)
{ {
data = (byte) (UtilMath.r(3) + 1); data = (byte) (UtilMath.r(3) + 1);
} }
else if(foodMaterial == Material.COOKED_FISH) else if (foodMaterial == Material.COOKED_FISH)
{ {
data = (byte) UtilMath.r(1); data = (byte) UtilMath.r(1);
} }
@ -179,13 +195,13 @@ public class ChallengeFastFood extends Challenge
private void changeItemSlot(Player player) private void changeItemSlot(Player player)
{ {
for(int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
{ {
if(player.getInventory().getItem(i) != null) if (player.getInventory().getItem(i) != null)
{ {
ItemStack newItemSelection = player.getInventory().getItem(i); ItemStack newItemSelection = player.getInventory().getItem(i);
if(newItemSelection.getType() != Material.AIR) if (newItemSelection.getType() != Material.AIR)
{ {
player.getInventory().setHeldItemSlot(i); player.getInventory().setHeldItemSlot(i);
return; return;
@ -197,7 +213,7 @@ public class ChallengeFastFood extends Challenge
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void throwItemInGround(Player player, ItemStack item) private void throwItemInGround(Player player, ItemStack item)
{ {
if(!Recharge.Instance.use(player, "Food Throw", 100, false, false)) if (!Recharge.Instance.use(player, "Food Throw", 100, false, false))
return; return;
player.getWorld().playSound(player.getLocation(), Sound.EAT, 0.5F, 1.1F); player.getWorld().playSound(player.getLocation(), Sound.EAT, 0.5F, 1.1F);
@ -223,43 +239,43 @@ public class ChallengeFastFood extends Challenge
@Override @Override
public void run() public void run()
{ {
if(!Host.IsLive() || !Host.isChallengeStarted() || !item.isValid() || item.isDead()) if (!Host.IsLive() || !Host.isChallengeStarted() || !item.isValid() || item.isDead())
{ {
cancel(); cancel();
return; return;
} }
if(item.isOnGround()) if (item.isOnGround())
{ {
double random = Math.random() * 100; double random = Math.random() * 100;
if(random < 30.0) if (random < 30.0)
{ {
Location drop = item.getLocation(); Location drop = item.getLocation();
Block block = drop.getBlock(); Block block = drop.getBlock();
Block below = block.getRelative(BlockFace.DOWN); Block below = block.getRelative(BlockFace.DOWN);
if(UtilMath.random.nextBoolean()) if (UtilMath.random.nextBoolean())
{ {
if(below.getType() != Material.AIR) if (below.getType() != Material.AIR)
{ {
below.setType(Material.DIRT); below.setType(Material.DIRT);
if(UtilMath.random.nextBoolean()) if (UtilMath.random.nextBoolean())
below.setData((byte) 1); below.setData((byte) 1);
} }
} }
if(block.getType() == Material.AIR && below.getType() != Material.AIR) if (block.getType() == Material.AIR && below.getType() != Material.AIR)
{ {
Material flower = UtilMath.randomElement(_flowers); Material flower = UtilMath.randomElement(_flowers);
block.setType(flower); block.setType(flower);
if(flower == Material.LONG_GRASS) if (flower == Material.LONG_GRASS)
{ {
block.setData((byte) (UtilMath.r(2) + 1)); block.setData((byte) (UtilMath.r(2) + 1));
} }
else if(flower == Material.RED_ROSE) else if (flower == Material.RED_ROSE)
{ {
block.setData((byte) UtilMath.r(8)); block.setData((byte) UtilMath.r(8));
} }
@ -280,7 +296,7 @@ public class ChallengeFastFood extends Challenge
{ {
ArrayList<ItemStack> items = UtilInv.getItems(player); ArrayList<ItemStack> items = UtilInv.getItems(player);
if(items.size() == 0) if (items.size() == 0)
SetCompleted(player); SetCompleted(player);
} }
@ -288,7 +304,7 @@ public class ChallengeFastFood extends Challenge
private void blockBreakEffect(Block block) private void blockBreakEffect(Block block)
{ {
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(block.getType(), block.getData()), block.getLocation(), 0.0F, 0.0F, 0.0F, 0, UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(block.getType(), block.getData()), block.getLocation(), 0.0F, 0.0F, 0.0F, 0,
10, ViewDist.NORMAL, UtilServer.getPlayers()); 10, ViewDist.NORMAL, UtilServer.getPlayers());
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
} }
} }

View File

@ -39,6 +39,7 @@ import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class ChallengeFishingDay extends Challenge public class ChallengeFishingDay extends Challenge
@ -50,8 +51,12 @@ public class ChallengeFishingDay extends Challenge
public ChallengeFishingDay(BawkBawkBattles host) public ChallengeFishingDay(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Fishing Day", "Be the first to catch 5 fish.", super(
"Watch out for TNT if you miss the fish!"); host,
ChallengeType.FirstComplete,
"Fishing Day",
"Be the first to catch 5 fish.",
"Watch out for TNT if you miss the fish!");
} }
@Override @Override

View File

@ -26,6 +26,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeInfestation extends Challenge public class ChallengeInfestation extends Challenge
{ {
@ -38,14 +39,19 @@ public class ChallengeInfestation extends Challenge
public ChallengeInfestation(BawkBawkBattles host) public ChallengeInfestation(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Infestation", "Avoid the deadly zombie!", "Watch out, the infected can kill humans."); super(
host,
ChallengeType.LastStanding,
"Infestation",
"Avoid the deadly zombie.",
"The infected can kill humans!");
} }
@Override @Override
public ArrayList<Location> getSpawns() public ArrayList<Location> getSpawns()
{ {
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
for(Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 0, 0), true, getArenaSize(10))) for (Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 0, 0), true, getArenaSize(10)))
{ {
spawns.add(getCenter().clone().add(locs.getX() + 0.5, locs.getY() + 1.1, locs.getZ() + 0.5)); spawns.add(getCenter().clone().add(locs.getX() + 0.5, locs.getY() + 1.1, locs.getZ() + 0.5));
} }
@ -55,9 +61,9 @@ public class ChallengeInfestation extends Challenge
@Override @Override
public void cleanupRoom() public void cleanupRoom()
{ {
for(Player player : Host.GetPlayers(false)) for (Player player : Host.GetPlayers(false))
{ {
if(player.hasPotionEffect(PotionEffectType.SPEED)) if (player.hasPotionEffect(PotionEffectType.SPEED))
{ {
player.removePotionEffect(PotionEffectType.SPEED); player.removePotionEffect(PotionEffectType.SPEED);
} }
@ -74,7 +80,7 @@ public class ChallengeInfestation extends Challenge
public void setupPlayers() public void setupPlayers()
{ {
_gameStart = System.currentTimeMillis(); _gameStart = System.currentTimeMillis();
for(Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1)); player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
} }
@ -86,7 +92,7 @@ public class ChallengeInfestation extends Challenge
@Override @Override
public void generateRoom() public void generateRoom()
{ {
for(Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 0, 0), false, getArenaSize(15))) for (Location locs : UtilShapes.getCircle(new Location(Host.WorldData.World, 0, 0, 0), false, getArenaSize(15)))
{ {
locs.getBlock().setType(Material.WOOL); locs.getBlock().setType(Material.WOOL);
locs.getBlock().setData((byte) UtilMath.r(16)); locs.getBlock().setData((byte) UtilMath.r(16));
@ -106,29 +112,29 @@ public class ChallengeInfestation extends Challenge
@EventHandler @EventHandler
public void onZombieInfection(CustomDamageEvent event) public void onZombieInfection(CustomDamageEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(!(event.GetDamageeEntity() instanceof Player)) if (!(event.GetDamageeEntity() instanceof Player))
{ {
return; return;
} }
if((!(event.GetDamagerEntity(false) instanceof Player))) if ((!(event.GetDamagerEntity(false) instanceof Player)))
{ {
return; return;
} }
if(isCompleted(event.GetDamageePlayer())) if (isCompleted(event.GetDamageePlayer()))
{ {
event.SetCancelled("Player already finished"); event.SetCancelled("Player already finished");
return; return;
} }
if(!_infectedPlayers.contains(event.GetDamagerPlayer(false).getName())) if (!_infectedPlayers.contains(event.GetDamagerPlayer(false).getName()))
{ {
event.SetCancelled("Not an infector"); event.SetCancelled("Not an infector");
return; return;
} }
if(_infectedPlayers.contains(event.GetDamageePlayer().getName())) if (_infectedPlayers.contains(event.GetDamageePlayer().getName()))
{ {
event.SetCancelled("Already infected"); event.SetCancelled("Already infected");
return; return;
@ -144,45 +150,45 @@ public class ChallengeInfestation extends Challenge
@EventHandler @EventHandler
public void zombieControl(UpdateEvent event) public void zombieControl(UpdateEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.FAST)
{ {
return; return;
} }
if(_zombieFrozen) if (_zombieFrozen)
{ {
if(System.currentTimeMillis() > _zombieFreezeEnd) if (System.currentTimeMillis() > _zombieFreezeEnd)
{ {
_zombieFrozen = false; _zombieFrozen = false;
} }
return; return;
} }
if(UtilMath.r(15) == 0) if (UtilMath.r(15) == 0)
{ {
freezeZombie((UtilMath.r(3)+3)*1000); freezeZombie((UtilMath.r(3) + 3) * 1000);
} }
if(_infectedZombie.getLocation().getY() < -1) if (_infectedZombie.getLocation().getY() < -1)
{ {
_infectedZombie.teleport(new Location(Host.WorldData.World, 0, 1, 0)); _infectedZombie.teleport(new Location(Host.WorldData.World, 0, 1, 0));
} }
Player closestPlayer = UtilPlayer.getClosest(_infectedZombie.getLocation(), (Entity) null); Player closestPlayer = UtilPlayer.getClosest(_infectedZombie.getLocation(), (Entity) null);
_infectedZombie.setTarget(closestPlayer); _infectedZombie.setTarget(closestPlayer);
if(_zombieSpeed <= 3.0f) if (_zombieSpeed <= 3.0f)
{ {
_zombieSpeed *= 1.03f; _zombieSpeed *= 1.03f;
} }
UtilEnt.CreatureLook(_infectedZombie, closestPlayer); UtilEnt.CreatureLook(_infectedZombie, closestPlayer);
UtilEnt.CreatureMove(_infectedZombie, closestPlayer.getLocation(), _zombieSpeed); UtilEnt.CreatureMove(_infectedZombie, closestPlayer.getLocation(), _zombieSpeed);
if(_infectedZombie.getLocation().distance(closestPlayer.getLocation()) <= 2) if (_infectedZombie.getLocation().distance(closestPlayer.getLocation()) <= 2)
{ {
if(!_infectedPlayers.contains(closestPlayer.getName())) if (!_infectedPlayers.contains(closestPlayer.getName()))
{ {
if(_gameStart+5000 > System.currentTimeMillis()) if (_gameStart + 5000 > System.currentTimeMillis())
{ {
return; return;
} }
@ -190,23 +196,23 @@ public class ChallengeInfestation extends Challenge
} }
} }
} }
@EventHandler @EventHandler
public void winCheck(UpdateEvent event) public void winCheck(UpdateEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(event.getType() != UpdateType.FASTER) if (event.getType() != UpdateType.FASTER)
{ {
return; return;
} }
if(_infectedPlayers.size() >= Math.floor(Host.GetPlayers(true).size()/2)) if (_infectedPlayers.size() >= Math.floor(Host.GetPlayers(true).size() / 2))
{ {
for(Player player: Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
if(_infectedPlayers.contains(player.getName())) if (_infectedPlayers.contains(player.getName()))
{ {
setLost(player); setLost(player);
} }
@ -221,17 +227,17 @@ public class ChallengeInfestation extends Challenge
@EventHandler @EventHandler
public void blockMobFire(EntityCombustEvent event) public void blockMobFire(EntityCombustEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(event.getEntity() instanceof Zombie) if (event.getEntity() instanceof Zombie)
{ {
event.getEntity().setFireTicks(0); event.getEntity().setFireTicks(0);
event.setCancelled(true); event.setCancelled(true);
} }
} }
private void freezeZombie(int millisec) private void freezeZombie(int millisec)
{ {
_zombieFreezeEnd = System.currentTimeMillis() + millisec; _zombieFreezeEnd = System.currentTimeMillis() + millisec;
@ -240,16 +246,16 @@ public class ChallengeInfestation extends Challenge
public void playerInfect(Player player) public void playerInfect(Player player)
{ {
if(_infectedPlayers.contains(player.getName())) if (_infectedPlayers.contains(player.getName()))
{ {
return; return;
} }
_infectedPlayers.add(player.getName()); _infectedPlayers.add(player.getName());
_zombieSpeed = 1.0f; _zombieSpeed = 1.0f;
Host.WorldData.World.strikeLightningEffect(player.getLocation()); Host.WorldData.World.strikeLightningEffect(player.getLocation());
Host.getArcadeManager().GetDisguise().disguise(new DisguiseZombie(player)); Host.getArcadeManager().GetDisguise().disguise(new DisguiseZombie(player));
player.sendMessage(F.main("Infection", "You have been infected! It's over so infect the rest!")); player.sendMessage(F.main("Infection", "You have been infected! It's over so infect the rest!"));
} }

View File

@ -5,13 +5,6 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -20,6 +13,14 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeKangarooJump extends Challenge public class ChallengeKangarooJump extends Challenge
{ {
private long _gameTime = System.currentTimeMillis() + ((UtilMath.r(5) + 20) * 1000); private long _gameTime = System.currentTimeMillis() + ((UtilMath.r(5) + 20) * 1000);
@ -29,7 +30,12 @@ public class ChallengeKangarooJump extends Challenge
public ChallengeKangarooJump(BawkBawkBattles host) public ChallengeKangarooJump(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Kangaroo Jump", "Jump from block to block.", "Player with the highest height wins!"); super(
host,
ChallengeType.FirstComplete,
"Kangaroo Jump",
"Jump from block to block.",
"Player with the highest height wins!");
} }
@Override @Override
@ -37,11 +43,11 @@ public class ChallengeKangarooJump extends Challenge
{ {
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++) for (int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++)
{ {
for(int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++) for (int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{ {
if(x % 2 == 0 && z % 2 == 0) if (x % 2 == 0 && z % 2 == 0)
{ {
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5)); spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
} }
@ -59,7 +65,7 @@ public class ChallengeKangarooJump extends Challenge
@Override @Override
public void setupPlayers() public void setupPlayers()
{ {
for(Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
_players.put(player.getName(), true); _players.put(player.getName(), true);
_playerJumpHeight.put(player, 0); _playerJumpHeight.put(player, 0);
@ -70,22 +76,22 @@ public class ChallengeKangarooJump extends Challenge
@Override @Override
public void generateRoom() public void generateRoom()
{ {
for(int x = -getArenaSize(); x <= getArenaSize(); x++) for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{ {
for(int z = -getArenaSize(); z <= getArenaSize(); z++) for (int z = -getArenaSize(); z <= getArenaSize(); z++)
{ {
for(int y = 0; y <= 150; y++) for (int y = 0; y <= 150; y++)
{ {
Block b = getCenter().getBlock().getRelative(x, y, z); Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0) if (y == 0)
{ {
b.setType(Material.DIRT); b.setType(Material.DIRT);
b.setData((byte) 2); b.setData((byte) 2);
} }
else if(y > 2) else if (y > 2)
{ {
if(UtilMath.r(33) == 15) if (UtilMath.r(33) == 15)
{ {
b.setType(Material.WOOL); b.setType(Material.WOOL);
b.setData((byte) UtilMath.r(16)); b.setData((byte) UtilMath.r(16));
@ -93,12 +99,12 @@ public class ChallengeKangarooJump extends Challenge
} }
else else
{ {
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize()) if (Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
{ {
b.setType(Material.FENCE); b.setType(Material.FENCE);
} }
} }
if(b.getType() != Material.AIR) if (b.getType() != Material.AIR)
{ {
addBlock(b); addBlock(b);
} }
@ -110,23 +116,23 @@ public class ChallengeKangarooJump extends Challenge
@EventHandler @EventHandler
public void onPlayerJump(PlayerMoveEvent event) public void onPlayerJump(PlayerMoveEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(!Host.isChallengeStarted()) if (!Host.isChallengeStarted())
{ {
return; return;
} }
if(event.getFrom().getY() >= event.getTo().getY()) if (event.getFrom().getY() >= event.getTo().getY())
{ {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
if(_players.get(player.getName()) == false) // TODO fix if (_players.get(player.getName()) == false) // TODO fix
{ {
if(player.isOnGround()) if (player.isOnGround())
{ {
_players.put(player.getName(), true); _players.put(player.getName(), true);
} }
@ -135,37 +141,37 @@ public class ChallengeKangarooJump extends Challenge
UtilAction.velocity(player, 2, 0.4, 4, true); UtilAction.velocity(player, 2, 0.4, 4, true);
_players.put(player.getName(), false); _players.put(player.getName(), false);
} }
@EventHandler @EventHandler
public void playerJumpTracker(PlayerMoveEvent event) public void playerJumpTracker(PlayerMoveEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
if(player.getLocation().getBlockY() < 4) if (player.getLocation().getBlockY() < 4)
{ {
return; // Return = Stop code return; // Return = Stop code
} }
if(!player.isOnGround()) if (!player.isOnGround())
{ {
return; return;
} }
if(!_playerJumpHeight.containsKey(player)) if (!_playerJumpHeight.containsKey(player))
{ {
return; return;
} }
if(isLost(player)) if (isLost(player))
{ {
_playerJumpHeight.remove(player); _playerJumpHeight.remove(player);
} }
if((player.getLocation().getBlockY() < _playerJumpHeight.get(player))) if ((player.getLocation().getBlockY() < _playerJumpHeight.get(player)))
{ {
_playerJumpHeight.remove(player); _playerJumpHeight.remove(player);
return; return;
} }
if(player.getLocation().getBlockY() > _playerJumpHeight.get(player)) if (player.getLocation().getBlockY() > _playerJumpHeight.get(player))
{ {
_playerJumpHeight.put(player, player.getLocation().getBlockY()); _playerJumpHeight.put(player, player.getLocation().getBlockY());
} }
@ -174,32 +180,32 @@ public class ChallengeKangarooJump extends Challenge
@EventHandler @EventHandler
public void gameEndChecker(UpdateEvent event) public void gameEndChecker(UpdateEvent event)
{ {
if(event.getType() != UpdateType.FASTER) if (event.getType() != UpdateType.FASTER)
{ {
return; return;
} }
if(System.currentTimeMillis() > _gameTime) if (System.currentTimeMillis() > _gameTime)
{ {
HashMap<String, Integer> playerHeights = new HashMap<String, Integer>(); HashMap<String, Integer> playerHeights = new HashMap<String, Integer>();
for(Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
if(!Host.IsAlive(player)) if (!Host.IsAlive(player))
{ {
return; return;
} }
if(!playerHeights.containsKey(player.getName())) if (!playerHeights.containsKey(player.getName()))
{ {
playerHeights.put(player.getName(), player.getLocation().getBlockY()); playerHeights.put(player.getName(), player.getLocation().getBlockY());
} }
} }
ArrayList<String> sortedList = sortHash(playerHeights); ArrayList<String> sortedList = sortHash(playerHeights);
for(int i = 0; i < (sortedList.size()); i++) for (int i = 0; i < (sortedList.size()); i++)
{ {
System.out.println(sortedList.get(i)); System.out.println(sortedList.get(i));
if(!isDone(Bukkit.getPlayer(sortedList.get(i)))) if (!isDone(Bukkit.getPlayer(sortedList.get(i))))
{ {
if(i < (sortedList.size() / 2)) if (i < (sortedList.size() / 2))
{ {
SetCompleted(Bukkit.getPlayer(sortedList.get(i))); SetCompleted(Bukkit.getPlayer(sortedList.get(i)));
} }
@ -227,7 +233,7 @@ public class ChallengeKangarooJump extends Challenge
}); });
return players; return players;
} }
public HashMap<Player, Integer> getPlayerHeight() public HashMap<Player, Integer> getPlayerHeight()
{ {
return _playerJumpHeight; return _playerJumpHeight;

View File

@ -23,6 +23,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeKingOfTheHill extends Challenge public class ChallengeKingOfTheHill extends Challenge
{ {
@ -31,7 +32,11 @@ public class ChallengeKingOfTheHill extends Challenge
public ChallengeKingOfTheHill(BawkBawkBattles host) public ChallengeKingOfTheHill(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "King Of The Ladder", "Reach the top of the ladder."); super(
host,
ChallengeType.FirstComplete,
"King Of The Ladder",
"Reach the top of the ladder.");
} }
@Override @Override

View File

@ -21,6 +21,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeLavaRun extends Challenge public class ChallengeLavaRun extends Challenge
{ {
@ -31,7 +32,13 @@ public class ChallengeLavaRun extends Challenge
public ChallengeLavaRun(BawkBawkBattles host) public ChallengeLavaRun(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Lava run", "The lava is coming!", "Stand on the obsidian.", "Run! Run! Run!"); super(
host,
ChallengeType.LastStanding,
"Lava Ρun",
"The lava is coming!",
"Stand on the obsidian.",
"Run! Run! Run!");
} }
@Override @Override
@ -49,11 +56,11 @@ public class ChallengeLavaRun extends Challenge
return spawns; return spawns;
} }
@Override @Override
public int getMaxPlayers() public int getMaxPlayers()
{ {
return 30; return 30;
} }
@EventHandler @EventHandler

View File

@ -3,19 +3,6 @@ package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseVillager;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.Hologram.HologramTarget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -32,6 +19,20 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseVillager;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.Hologram.HologramTarget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeMilkACow extends Challenge public class ChallengeMilkACow extends Challenge
{ {
private Villager _villager; private Villager _villager;
@ -41,7 +42,12 @@ public class ChallengeMilkACow extends Challenge
public ChallengeMilkACow(BawkBawkBattles host) public ChallengeMilkACow(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Milk the cows", "Milk 5 different cows.", "Deliver the milk to the villager!"); super(
host,
ChallengeType.FirstComplete,
"Milk a Cow",
"Milk 5 different cows.",
"Deliver the milk to the villager!");
} }
@Override @Override
@ -51,7 +57,7 @@ public class ChallengeMilkACow extends Challenge
{ {
Hologram holo = _cowIndicator.get(cow); Hologram holo = _cowIndicator.get(cow);
holo.stop(); holo.stop();
cow.remove(); cow.remove();
} }
_villager.remove(); _villager.remove();
@ -137,31 +143,45 @@ public class ChallengeMilkACow extends Challenge
_villager.setProfession(Profession.FARMER); _villager.setProfession(Profession.FARMER);
_villager.setCustomName(C.Bold + "Farmer Joe"); _villager.setCustomName(C.Bold + "Farmer Joe");
_villager.setCustomNameVisible(true); _villager.setCustomNameVisible(true);
String[] names = new String[] String[] names = new String[] {
{ "Tom",
"Tom", "Steve", "John", "Harry", "Andrew", "Daniel", "Bobbae", "Jim" "Steve",
}; "John",
"Harry",
"Andrew",
"Daniel",
"Bobbae",
"Jim"
};
if (UtilMath.r(5) == 0) if (UtilMath.r(5) == 0)
{ {
names = new String[] names = new String[] {
{ "Moorten",
"Moorten", "Mooington", "Mooley", "Moose", "Mooskee", "Chicken", "Mooffy", "Moozzle", "Mooington",
}; "Mooley",
"Moose",
"Mooskee",
"Chicken",
"Mooffy",
"Moozzle",
};
} }
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
Location loc = getCenter().clone().add(UtilMath.r(((getArenaSize()*2)-1) - (getArenaSize()-1)), 1, UtilMath.r((getArenaSize()*2)-1) - (getArenaSize()-1)); Location loc = getCenter().clone().add(UtilMath.r(((getArenaSize() * 2) - 1) - (getArenaSize() - 1)), 1,
UtilMath.r((getArenaSize() * 2) - 1) - (getArenaSize() - 1));
Cow cow = (Cow) loc.getWorld().spawnEntity(loc, EntityType.COW); Cow cow = (Cow) loc.getWorld().spawnEntity(loc, EntityType.COW);
cow.setCustomName(C.cWhite + names[i]); cow.setCustomName(C.cWhite + names[i]);
cow.setCustomNameVisible(true); cow.setCustomNameVisible(true);
_milked.put(cow, new ArrayList<String>()); _milked.put(cow, new ArrayList<String>());
_cowIndicator.put(cow, new Hologram(Host.Manager.getHologramManager(), cow.getLocation().clone().add(0, 2.5, 0), C.cRed + "Already Milked!")); _cowIndicator.put(cow,
new Hologram(Host.Manager.getHologramManager(), cow.getLocation().clone().add(0, 2.5, 0), C.cRed + "Already Milked!"));
Hologram holo = _cowIndicator.get(cow); Hologram holo = _cowIndicator.get(cow);
holo.setHologramTarget(HologramTarget.WHITELIST); holo.setHologramTarget(HologramTarget.WHITELIST);
holo.setFollowEntity(cow); holo.setFollowEntity(cow);
@ -174,28 +194,28 @@ public class ChallengeMilkACow extends Challenge
@EventHandler @EventHandler
public void cowIndicator(UpdateEvent event) public void cowIndicator(UpdateEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(event.getType() != UpdateType.SEC) if (event.getType() != UpdateType.SEC)
{ {
return; return;
} }
for(Entity entCow: _milked.keySet()) for (Entity entCow : _milked.keySet())
{ {
for(String playerName: _milked.get(entCow)) for (String playerName : _milked.get(entCow))
{ {
Hologram holo = _cowIndicator.get(entCow); Hologram holo = _cowIndicator.get(entCow);
if(!holo.containsPlayer(playerName)) if (!holo.containsPlayer(playerName))
{ {
holo.addPlayer(playerName); holo.addPlayer(playerName);
} }
} }
} }
} }
@EventHandler @EventHandler
public void onEntityInteract(PlayerInteractEntityEvent event) public void onEntityInteract(PlayerInteractEntityEvent event)
{ {
@ -246,7 +266,7 @@ public class ChallengeMilkACow extends Challenge
_score.put(p, score); _score.put(p, score);
displayCount(p, ((Villager) ent).getEyeLocation().add(0, 0.3, 0), (score >= 5 ? C.cDGreen : score >= 3 ? C.cGreen displayCount(p, ((Villager) ent).getEyeLocation().add(0, 0.3, 0), (score >= 5 ? C.cDGreen : score >= 3 ? C.cGreen
: score >= 2 ? C.cRed : C.cDRed) + score); : score >= 2 ? C.cRed : C.cDRed) + score);
if (score == 5) if (score == 5)
{ {
@ -271,9 +291,9 @@ public class ChallengeMilkACow extends Challenge
{ {
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
for (int x = -(getArenaSize() - 1); x <= getArenaSize()-1; x++) for (int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++)
{ {
for (int z = -(getArenaSize() - 1); z <= getArenaSize()-1; z++) for (int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{ {
if (x % 2 == 0 && z % 2 == 0) if (x % 2 == 0 && z % 2 == 0)
{ {
@ -284,7 +304,7 @@ public class ChallengeMilkACow extends Challenge
return spawns; return spawns;
} }
public HashMap<Player, Integer> getScore() public HashMap<Player, Integer> getScore()
{ {
return _score; return _score;

View File

@ -3,10 +3,6 @@ package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -17,16 +13,24 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeMineADiamond extends Challenge public class ChallengeMineADiamond extends Challenge
{ {
private ArrayList<Material> _ores = new ArrayList<Material>(Arrays.asList(Material.IRON_ORE, Material.GOLD_ORE, private ArrayList<Material> _ores = new ArrayList<Material>(Arrays.asList(Material.IRON_ORE, Material.GOLD_ORE,
Material.REDSTONE_ORE, Material.EMERALD_ORE, Material.COAL_ORE, Material.LAPIS_ORE)); Material.REDSTONE_ORE, Material.EMERALD_ORE, Material.COAL_ORE, Material.LAPIS_ORE));
private ArrayList<Block> _diamonds = new ArrayList<Block>(); private ArrayList<Block> _diamonds = new ArrayList<Block>();
public ChallengeMineADiamond(BawkBawkBattles host) public ChallengeMineADiamond(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Mine a Diamond", "Find a diamond around the map.", super(
"Be the first to mine one!"); host,
ChallengeType.FirstComplete,
"Mine a Diamond",
"Find a diamond around the map.");
} }
@Override @Override
@ -104,10 +108,11 @@ public class ChallengeMineADiamond extends Challenge
for (int i = 0; i < Math.ceil((Host.GetPlayers(true).size() + 1) / 2); i++) for (int i = 0; i < Math.ceil((Host.GetPlayers(true).size() + 1) / 2); i++)
{ {
Block copy = getCenter().getBlock().getRelative( Block copy = getCenter().getBlock().getRelative(
UtilMath.r(getArenaSize() * 2) - (getArenaSize()), 1, UtilMath.r(getArenaSize() * 2) - (getArenaSize()), 1,
UtilMath.r(getArenaSize() * 2) - (getArenaSize())); UtilMath.r(getArenaSize() * 2) - (getArenaSize()));
if (copy.getType() == Material.DIAMOND_ORE && Math.abs(copy.getX()) < getArenaSize() && Math.abs(copy.getY()) < getArenaSize()) if (copy.getType() == Material.DIAMOND_ORE && Math.abs(copy.getX()) < getArenaSize()
&& Math.abs(copy.getY()) < getArenaSize())
{ {
i--; i--;
continue; continue;

View File

@ -27,14 +27,14 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldEvent; import net.minecraft.server.v1_8_R3.PacketPlayOutWorldEvent;
public class ChallengeMinecartDance extends Challenge public class ChallengeMinecartDance extends Challenge
{ {
/* /*
* _state if 1 = waiting if 2 = stateSwitch if 3 = cartsSpawned and player * _state if 1 = waiting if 2 = stateSwitch if 3 = cartsSpawned and player battle
* battle
*/ */
private boolean _isPlayingMusic = false; private boolean _isPlayingMusic = false;
private int _availableMinecarts; private int _availableMinecarts;
@ -44,8 +44,12 @@ public class ChallengeMinecartDance extends Challenge
public ChallengeMinecartDance(BawkBawkBattles host) public ChallengeMinecartDance(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Musical Minecart", "Get ready when the fireworks change color.", super(
"Once they're green, get inside a minecart!"); host,
ChallengeType.LastStanding,
"Musical Minecart",
"Get ready when the fireworks change color.",
"Once they're green, get inside a minecart!");
} }
@Override @Override
@ -75,8 +79,8 @@ public class ChallengeMinecartDance extends Challenge
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
((CraftPlayer) player).getHandle().playerConnection ((CraftPlayer) player).getHandle().playerConnection
.sendPacket(new PacketPlayOutWorldEvent(1005, new BlockPosition(getCenter().getBlockX(), .sendPacket(new PacketPlayOutWorldEvent(1005, new BlockPosition(getCenter().getBlockX(),
getCenter().getBlockY() + 5, getCenter().getBlockZ()), 0, false)); getCenter().getBlockY() + 5, getCenter().getBlockZ()), 0, false));
} }
} }
for (Minecart minecarts : _minecarts) for (Minecart minecarts : _minecarts)
@ -201,8 +205,9 @@ public class ChallengeMinecartDance extends Challenge
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldEvent(1005, ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldEvent(1005,
new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY() + 5, getCenter() new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY() + 5, getCenter()
.getBlockZ()), 2259, false)); .getBlockZ()),
2259, false));
} }
} }
if (_timeSinceLastState + 5500 < System.currentTimeMillis()) if (_timeSinceLastState + 5500 < System.currentTimeMillis())
@ -243,23 +248,25 @@ public class ChallengeMinecartDance extends Challenge
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldEvent(1005, ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldEvent(1005,
new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY() + 5, getCenter() new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY() + 5, getCenter()
.getBlockZ()), 0, false)); .getBlockZ()),
0, false));
} }
} }
for (int i = 0; i < getCurrentyAlive(true).size() / 2; i++) for (int i = 0; i < getCurrentyAlive(true).size() / 2; i++)
{ {
Minecart minecart = Host.WorldData.World.spawn( Minecart minecart = Host.WorldData.World.spawn(
new Location(Host.WorldData.World, UtilMath.r(getArenaSize(7) * 2) - (getArenaSize(7)), 2, new Location(Host.WorldData.World, UtilMath.r(getArenaSize(7) * 2) - (getArenaSize(7)), 2,
UtilMath.r(getArenaSize(7) * 2) - (getArenaSize(7))), Minecart.class); UtilMath.r(getArenaSize(7) * 2) - (getArenaSize(7))),
Minecart.class);
UtilEnt.ghost(minecart, true, false); UtilEnt.ghost(minecart, true, false);
_minecarts.add(minecart); _minecarts.add(minecart);
} }
_state = 3; _state = 3;
if(getCurrentyAlive(false).size() >= 10) if (getCurrentyAlive(false).size() >= 10)
{ {
startTimer(Math.round(getCurrentyAlive(false).size()/2)); startTimer(Math.round(getCurrentyAlive(false).size() / 2));
} }
else else
{ {
@ -365,18 +372,18 @@ public class ChallengeMinecartDance extends Challenge
} }
} }
}.runTaskLater(Host.Manager.getPlugin(), ticks * 20); }.runTaskLater(Host.Manager.getPlugin(), ticks * 20);
} }
public void spawnFireworkAtCorners(Color color) public void spawnFireworkAtCorners(Color color)
{ {
UtilFirework.playFirework(new Location(Host.WorldData.World, getArenaSize() + 5, 10, getArenaSize() + 5), UtilFirework.playFirework(new Location(Host.WorldData.World, getArenaSize() + 5, 10, getArenaSize() + 5),
Type.BALL_LARGE, color, false, false); Type.BALL_LARGE, color, false, false);
UtilFirework.playFirework(new Location(Host.WorldData.World, -getArenaSize() - 5, 10, getArenaSize() + 5), UtilFirework.playFirework(new Location(Host.WorldData.World, -getArenaSize() - 5, 10, getArenaSize() + 5),
Type.BALL_LARGE, color, false, false); Type.BALL_LARGE, color, false, false);
UtilFirework.playFirework(new Location(Host.WorldData.World, getArenaSize() + 5, 10, -getArenaSize() - 5), UtilFirework.playFirework(new Location(Host.WorldData.World, getArenaSize() + 5, 10, -getArenaSize() - 5),
Type.BALL_LARGE, color, false, false); Type.BALL_LARGE, color, false, false);
UtilFirework.playFirework(new Location(Host.WorldData.World, -getArenaSize() - 5, 10, -getArenaSize() - 5), UtilFirework.playFirework(new Location(Host.WorldData.World, -getArenaSize() - 5, 10, -getArenaSize() - 5),
Type.BALL_LARGE, color, false, false); Type.BALL_LARGE, color, false, false);
} }
} }

View File

@ -22,13 +22,21 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeMiniOneInTheQuiver extends Challenge public class ChallengeMiniOneInTheQuiver extends Challenge
{ {
public ChallengeMiniOneInTheQuiver(BawkBawkBattles host) public ChallengeMiniOneInTheQuiver(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Mini OITQ", false, true, "Avoid getting hit by arrows.", "You receive an arrow every 4 seconds.", super(
"Last man standing wins!"); host,
ChallengeType.LastStanding,
"Mini OITQ",
false,
true,
"Shoot arrows to instant kill others.",
"Avoid getting hit by them.",
"Arrow supply every 4 seconds.");
} }
@Override @Override

View File

@ -3,10 +3,6 @@ package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -15,13 +11,22 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeNavigateMaze extends Challenge public class ChallengeNavigateMaze extends Challenge
{ {
private HashMap<Player, Long> _playerCompletionTime = new HashMap<Player, Long>(); private HashMap<Player, Long> _playerCompletionTime = new HashMap<Player, Long>();
public ChallengeNavigateMaze(BawkBawkBattles host) public ChallengeNavigateMaze(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Nagivation Maze", "Go to the other side of the maze."); super(
host,
ChallengeType.FirstComplete,
"Nagivation Maze",
"Go to the other side of the maze.");
} }
@Override @Override
@ -45,11 +50,11 @@ public class ChallengeNavigateMaze extends Challenge
{ {
return; return;
} }
if(isDone(event.getPlayer())) if (isDone(event.getPlayer()))
{ {
return; return;
} }
if (event.getTo().getY() >= 1 && event.getTo().getX() > 16) if (event.getTo().getY() >= 1 && event.getTo().getX() > 16)
{ {
SetCompleted(event.getPlayer()); SetCompleted(event.getPlayer());
@ -154,10 +159,12 @@ public class ChallengeNavigateMaze extends Challenge
{ {
Block block = nextLoop.remove(0); Block block = nextLoop.remove(0);
for (BlockFace face : new BlockFace[] for (BlockFace face : new BlockFace[] {
{ BlockFace.EAST,
BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH BlockFace.WEST,
}) BlockFace.SOUTH,
BlockFace.NORTH
})
{ {
Block b = block.getRelative(face); Block b = block.getRelative(face);
@ -253,7 +260,7 @@ public class ChallengeNavigateMaze extends Challenge
return blocks; return blocks;
} }
public HashMap<Player, Long> getPlayerTimes() public HashMap<Player, Long> getPlayerTimes()
{ {
return _playerCompletionTime; return _playerCompletionTime;

View File

@ -3,6 +3,13 @@ package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
@ -11,13 +18,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
public class ChallengePickASide extends Challenge public class ChallengePickASide extends Challenge
{ {
@ -28,8 +29,12 @@ public class ChallengePickASide extends Challenge
public ChallengePickASide(BawkBawkBattles host) public ChallengePickASide(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Pick a Side", "The side with the fewest players wins!", super(
"No... Standing in the middle won't work"); host,
ChallengeType.FirstComplete,
"Pick a Side",
"The side with the smallest amount of players wins.",
"Standing in the middle does not work.");
} }
public int getMinPlayers() public int getMinPlayers()

View File

@ -4,14 +4,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -21,6 +13,15 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengePunchThePig extends Challenge public class ChallengePunchThePig extends Challenge
{ {
private int _amountOfKills = 5; private int _amountOfKills = 5;
@ -30,7 +31,11 @@ public class ChallengePunchThePig extends Challenge
public ChallengePunchThePig(BawkBawkBattles host) public ChallengePunchThePig(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Punch the Pig", "Kill 5 pigs!"); super(
host,
ChallengeType.FirstComplete,
"Punch the Pig",
"Kill 5 pigs.");
} }
@Override @Override
@ -38,11 +43,11 @@ public class ChallengePunchThePig extends Challenge
{ {
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize() - 1); x < getArenaSize() - 1; x++) for (int x = -(getArenaSize() - 1); x < getArenaSize() - 1; x++)
{ {
for(int z = -(getArenaSize() - 1); z < getArenaSize() - 1; z++) for (int z = -(getArenaSize() - 1); z < getArenaSize() - 1; z++)
{ {
if(x % 2 == 0 && z % 2 == 0) if (x % 2 == 0 && z % 2 == 0)
{ {
spawns.add(getCenter().clone().add(x, 1.1, z)); spawns.add(getCenter().clone().add(x, 1.1, z));
} }
@ -54,9 +59,9 @@ public class ChallengePunchThePig extends Challenge
@Override @Override
public void cleanupRoom() public void cleanupRoom()
{ {
for(Pig pigs : _pigs) for (Pig pigs : _pigs)
{ {
if(!pigs.isDead()) if (!pigs.isDead())
{ {
pigs.remove(); pigs.remove();
} }
@ -69,10 +74,10 @@ public class ChallengePunchThePig extends Challenge
@Override @Override
public void setupPlayers() public void setupPlayers()
{ {
for(int i = 0; i <= Math.round((Host.GetPlayers(true).size()) * 5); i++) for (int i = 0; i <= Math.round((Host.GetPlayers(true).size()) * 5); i++)
{ {
Location loc = getCenter().clone().add(UtilMath.r((getArenaSize() * 2) - 1) - (getArenaSize() - 1), 1, Location loc = getCenter().clone().add(UtilMath.r((getArenaSize() * 2) - 1) - (getArenaSize() - 1), 1,
UtilMath.r((getArenaSize() * 2) - 1) - (getArenaSize() - 1)); UtilMath.r((getArenaSize() * 2) - 1) - (getArenaSize() - 1));
Host.CreatureAllowOverride = true; Host.CreatureAllowOverride = true;
Pig pig = (Pig) loc.getWorld().spawnEntity(loc, EntityType.PIG); Pig pig = (Pig) loc.getWorld().spawnEntity(loc, EntityType.PIG);
@ -83,7 +88,7 @@ public class ChallengePunchThePig extends Challenge
_pigs.add(pig); _pigs.add(pig);
} }
for(Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
_playerScore.put(player.getName(), 0); _playerScore.put(player.getName(), 0);
} }
@ -94,26 +99,26 @@ public class ChallengePunchThePig extends Challenge
@Override @Override
public void generateRoom() public void generateRoom()
{ {
for(int x = -getArenaSize(); x <= getArenaSize(); x++) for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{ {
for(int z = -getArenaSize(); z <= getArenaSize(); z++) for (int z = -getArenaSize(); z <= getArenaSize(); z++)
{ {
for(int y = 0; y <= 1; y++) for (int y = 0; y <= 1; y++)
{ {
Block b = getCenter().getBlock().getRelative(x, y, z); Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0) if (y == 0)
{ {
b.setType(Material.GRASS); b.setType(Material.GRASS);
} }
else else
{ {
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize()) if (Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
{ {
b.setType(Material.FENCE); b.setType(Material.FENCE);
} }
} }
if(b.getType() != Material.AIR) if (b.getType() != Material.AIR)
{ {
addBlock(b); addBlock(b);
} }
@ -125,33 +130,33 @@ public class ChallengePunchThePig extends Challenge
@EventHandler @EventHandler
public void onPigPunch(CustomDamageEvent event) public void onPigPunch(CustomDamageEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(event.GetDamageeEntity() == null) if (event.GetDamageeEntity() == null)
{ {
return; return;
} }
if(event.GetDamagerPlayer(false) == null) if (event.GetDamagerPlayer(false) == null)
{ {
return; return;
} }
if(event.GetDamageeEntity() instanceof Pig) if (event.GetDamageeEntity() instanceof Pig)
{ {
if(isCompleted(event.GetDamagerPlayer(false))) if (isCompleted(event.GetDamagerPlayer(false)))
{ {
event.SetCancelled("Player already completed"); event.SetCancelled("Player already completed");
return; return;
} }
if(_pigs.contains(event.GetDamageeEntity())) if (_pigs.contains(event.GetDamageeEntity()))
{ {
if(_playerScore.get(event.GetDamagerPlayer(false).getName()) != _amountOfKills - 1) if (_playerScore.get(event.GetDamagerPlayer(false).getName()) != _amountOfKills - 1)
{ {
_playerScore.put(event.GetDamagerPlayer(false).getName(), _playerScore.get(event.GetDamagerPlayer(false).getName()) + 1); _playerScore.put(event.GetDamagerPlayer(false).getName(), _playerScore.get(event.GetDamagerPlayer(false).getName()) + 1);
displayCount(event.GetDamagerPlayer(false), event.GetDamageeEntity().getLocation().add(0.5, 1, 0.5), displayCount(event.GetDamagerPlayer(false), event.GetDamageeEntity().getLocation().add(0.5, 1, 0.5),
C.cGreen + "" + _playerScore.get(event.GetDamagerPlayer(false).getName())); C.cGreen + "" + _playerScore.get(event.GetDamagerPlayer(false).getName()));
} }
else else
{ {
@ -168,11 +173,11 @@ public class ChallengePunchThePig extends Challenge
@EventHandler @EventHandler
public void onPigDeath(EntityDeathEvent event) public void onPigDeath(EntityDeathEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(event.getEntity() instanceof Pig) if (event.getEntity() instanceof Pig)
{ {
event.getDrops().clear(); event.getDrops().clear();
} }
@ -181,26 +186,26 @@ public class ChallengePunchThePig extends Challenge
@EventHandler @EventHandler
public void checkPigs(UpdateEvent event) public void checkPigs(UpdateEvent event)
{ {
if(event.getType() != UpdateType.FASTER) if (event.getType() != UpdateType.FASTER)
{ {
return; return;
} }
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(!Host.isChallengeStarted()) if (!Host.isChallengeStarted())
{ {
return; return;
} }
if(!_pigs.isEmpty()) if (!_pigs.isEmpty())
{ {
return; return;
} }
for(Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
if(isCompleted(player)) if (isCompleted(player))
{ {
return; return;
} }

View File

@ -31,9 +31,10 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
public class ChallengeRedLightGreenLight extends Challenge public class ChallengeRedLightGreenLight extends Challenge
{ {
private boolean _canMove; private boolean _canMove;
private int _minTimeBeforeGreen = 2500; private int _minTimeBeforeGreen = 2500;
@ -45,10 +46,16 @@ public class ChallengeRedLightGreenLight extends Challenge
private ArrayList<String> _cooldownedPlayers = new ArrayList<String>(); private ArrayList<String> _cooldownedPlayers = new ArrayList<String>();
private ArrayList<Integer> _colorList = new ArrayList<Integer>(Arrays.asList(14, 11, 9, 3, 1, 4, 13, 5)); private ArrayList<Integer> _colorList = new ArrayList<Integer>(Arrays.asList(14, 11, 9, 3, 1, 4, 13, 5));
private Villager _host; private Villager _host;
public ChallengeRedLightGreenLight(BawkBawkBattles host) public ChallengeRedLightGreenLight(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Red Light, Green Light", false, false, "Be the first to reach the end.", "Don't move while the fireworks are red!"); super(
host,
ChallengeType.FirstComplete,
"Red Light, Green Light",
"Be the first to reach the end.",
"You can move when the fireworks are green.",
"Stay still when the fireworks turn red.");
} }
@Override @Override
@ -56,11 +63,11 @@ public class ChallengeRedLightGreenLight extends Challenge
{ {
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -31; x <= -30; x++) for (int x = -31; x <= -30; x++)
{ {
for(int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++) for (int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{ {
if(x % 2 == 0 && z % 2 == 0) if (x % 2 == 0 && z % 2 == 0)
{ {
spawns.add(getCenter().clone().add(x + 0.5, 2.1, z + 0.5)); spawns.add(getCenter().clone().add(x + 0.5, 2.1, z + 0.5));
} }
@ -73,10 +80,10 @@ public class ChallengeRedLightGreenLight extends Challenge
public void cleanupRoom() public void cleanupRoom()
{ {
_host.remove(); _host.remove();
for(Player player: Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
if(player.hasPotionEffect(PotionEffectType.SLOW)) if (player.hasPotionEffect(PotionEffectType.SLOW))
{ {
player.removePotionEffect(PotionEffectType.SLOW); player.removePotionEffect(PotionEffectType.SLOW);
} }
@ -88,8 +95,8 @@ public class ChallengeRedLightGreenLight extends Challenge
public void setupPlayers() public void setupPlayers()
{ {
changeMoveState(true); changeMoveState(true);
for(Player player: Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 2)); player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 2));
} }
@ -102,74 +109,76 @@ public class ChallengeRedLightGreenLight extends Challenge
int colorPicker = 0; int colorPicker = 0;
Collections.reverse(_colorList); Collections.reverse(_colorList);
for(int x = -32; x <= 32; x++) //length people need to run for (int x = -32; x <= 32; x++) //length people need to run
{ {
for(int z = -getArenaSize(); z <= getArenaSize(); z++) for (int z = -getArenaSize(); z <= getArenaSize(); z++)
{ {
for(int y = 0; y <= 1; y++) for (int y = 0; y <= 1; y++)
{ {
Block b = getCenter().getBlock().getRelative(x, y, z); Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0) if (y == 0)
{ {
b.setType(Material.BEDROCK); b.setType(Material.BEDROCK);
} }
else if(y > 0) else if (y > 0)
{ {
b.setType(Material.WOOL); b.setType(Material.WOOL);
b.setData(_colorList.get(colorPicker).byteValue()); b.setData(_colorList.get(colorPicker).byteValue());
} }
if(x == _villagerLocationX) if (x == _villagerLocationX)
{ {
b.setType(Material.COAL_BLOCK); b.setType(Material.COAL_BLOCK);
} }
if(b.getType() != Material.AIR) if (b.getType() != Material.AIR)
{ {
addBlock(b); addBlock(b);
} }
} }
} }
if(var % 8 == 0 && (colorPicker != _colorList.size() - 1)) if (var % 8 == 0 && (colorPicker != _colorList.size() - 1))
{ {
colorPicker++; colorPicker++;
} }
var++; var++;
} }
Host.CreatureAllowOverride = true; Host.CreatureAllowOverride = true;
_host = (Villager)getCenter().getWorld().spawnEntity(new Location(getCenter().getWorld(), _villagerLocationX, 2, 0), EntityType.VILLAGER); _host = (Villager) getCenter().getWorld().spawnEntity(new Location(getCenter().getWorld(), _villagerLocationX, 2, 0), EntityType.VILLAGER);
UtilEnt.Vegetate(_host); UtilEnt.Vegetate(_host);
UtilEnt.ghost(_host, true, false); UtilEnt.ghost(_host, true, false);
Host.CreatureAllowOverride = false; Host.CreatureAllowOverride = false;
} }
@EventHandler @EventHandler
public void playerMoveHandler(final PlayerMoveEvent event) public void playerMoveHandler(final PlayerMoveEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(isDone(event.getPlayer()) || !Host.IsPlaying(event.getPlayer())) if (isDone(event.getPlayer()) || !Host.IsPlaying(event.getPlayer()))
{ {
return; return;
} }
if(event.getPlayer().getLocation().getX() > _villagerLocationX) // Wins the challenge if (event.getPlayer().getLocation().getX() > _villagerLocationX) // Wins the challenge
{ {
SetCompleted(event.getPlayer()); SetCompleted(event.getPlayer());
} }
if(!_canMove && !_cooldownedPlayers.contains(event.getPlayer().getName()) && _timeBeforeAction < System.currentTimeMillis()) if (!_canMove && !_cooldownedPlayers.contains(event.getPlayer().getName()) && _timeBeforeAction < System.currentTimeMillis())
{ {
if(event.getFrom().getBlockX() == event.getTo().getBlockX()) if (event.getFrom().getBlockX() == event.getTo().getBlockX())
{ {
return; return;
} }
UtilAction.velocity(event.getPlayer(), UtilAlg.getTrajectory2d(event.getPlayer().getLocation(), new Location(getCenter().getWorld(), -32, 5, 0)), 1.5, true, 0.4, 0, 10, true); UtilAction.velocity(event.getPlayer(),
UtilAlg.getTrajectory2d(event.getPlayer().getLocation(), new Location(getCenter().getWorld(), -32, 5, 0)), 1.5, true, 0.4, 0, 10,
true);
_cooldownedPlayers.add(event.getPlayer().getName()); _cooldownedPlayers.add(event.getPlayer().getName());
new BukkitRunnable() new BukkitRunnable()
{ {
@Override @Override
public void run() public void run()
{ {
@ -178,23 +187,23 @@ public class ChallengeRedLightGreenLight extends Challenge
}.runTaskLater(Host.Manager.getPlugin(), 35); }.runTaskLater(Host.Manager.getPlugin(), 35);
} }
} }
@EventHandler @EventHandler
public void stateChangeHandler(UpdateEvent event) public void stateChangeHandler(UpdateEvent event)
{ {
if(event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.FAST)
{ {
return; return;
} }
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(_canMove) if (_canMove)
{ {
if(_timeSinceLastRed+_minTimeBeforeRed < System.currentTimeMillis()) if (_timeSinceLastRed + _minTimeBeforeRed < System.currentTimeMillis())
{ {
if(UtilMath.r(2) == 0) if (UtilMath.r(2) == 0)
{ {
changeMoveState(false); changeMoveState(false);
} }
@ -202,32 +211,32 @@ public class ChallengeRedLightGreenLight extends Challenge
} }
else else
{ {
if(_timeSinceLastGreen+_minTimeBeforeGreen < System.currentTimeMillis()) if (_timeSinceLastGreen + _minTimeBeforeGreen < System.currentTimeMillis())
{ {
if(UtilMath.r(3) == 0) if (UtilMath.r(3) == 0)
{ {
changeMoveState(true); changeMoveState(true);
} }
} }
} }
} }
private void changeMoveState(boolean condition) private void changeMoveState(boolean condition)
{ {
if(condition != _canMove) if (condition != _canMove)
{ {
if(condition) if (condition)
{ {
_timeSinceLastRed = System.currentTimeMillis(); _timeSinceLastRed = System.currentTimeMillis();
_canMove = true; _canMove = true;
spawnFireWork(Color.GREEN); spawnFireWork(Color.GREEN);
for(Player player: UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
player.sendMessage(F.main("Green Light", "You can now move!")); player.sendMessage(F.main("Green Light", "You can now move!"));
player.getWorld().playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 2f, 1f);
player.getWorld().playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 2f, 1f); player.getWorld().playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 2f, 1f);
player.getWorld().playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 2f, 1f);
} }
} }
else else
@ -236,21 +245,21 @@ public class ChallengeRedLightGreenLight extends Challenge
_timeBeforeAction = System.currentTimeMillis() + 1500; //1.5 seconds before the player HAS to stand still _timeBeforeAction = System.currentTimeMillis() + 1500; //1.5 seconds before the player HAS to stand still
_canMove = false; _canMove = false;
spawnFireWork(Color.RED); spawnFireWork(Color.RED);
for(Player player: UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
player.sendMessage(F.main("Red Light", "Freeze!")); player.sendMessage(F.main("Red Light", "Freeze!"));
UtilTextMiddle.display(ChatColor.RED + "Freeze!", "", 0, 20*3, 20); UtilTextMiddle.display(ChatColor.RED + "Freeze!", "", 0, 20 * 3, 20);
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
} }
} }
} }
} }
private void spawnFireWork(Color color) private void spawnFireWork(Color color)
{ {
for(int i = -getArenaSize(); i < getArenaSize()*2; i += 4) for (int i = -getArenaSize(); i < getArenaSize() * 2; i += 4)
{ {
UtilFirework.playFirework(new Location(Host.WorldData.World, 30, 10, i), Type.BALL_LARGE, color, false, false); UtilFirework.playFirework(new Location(Host.WorldData.World, 30, 10, i), Type.BALL_LARGE, color, false, false);
} }

View File

@ -28,6 +28,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeReverseTag extends Challenge public class ChallengeReverseTag extends Challenge
{ {
@ -38,9 +39,14 @@ public class ChallengeReverseTag extends Challenge
private HashSet<String> _cooldowned = new HashSet<String>(); private HashSet<String> _cooldowned = new HashSet<String>();
private HashSet<Player> _nonTaggedPlayers = new HashSet<Player>(); private HashSet<Player> _nonTaggedPlayers = new HashSet<Player>();
public ChallengeReverseTag(BawkBawkBattles Host) public ChallengeReverseTag(BawkBawkBattles host)
{ {
super(Host, ChallengeType.FirstComplete, "Reverse Tag", "Be a sparkling person until the end.", "Punch the sparking people to become one!"); super(
host,
ChallengeType.FirstComplete,
"Reverse Tag",
"Punch a sparkling person to become one.",
"Stay sparkling until the end.");
} }
@Override @Override
@ -48,11 +54,11 @@ public class ChallengeReverseTag extends Challenge
{ {
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -14; x <= 14; x++) for (int x = -14; x <= 14; x++)
{ {
for(int z = -14; z <= 14; z++) for (int z = -14; z <= 14; z++)
{ {
if(x % 2 == 0 && z % 2 == 0) if (x % 2 == 0 && z % 2 == 0)
{ {
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5)); spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
} }
@ -77,10 +83,10 @@ public class ChallengeReverseTag extends Challenge
ArrayList<Player> players = new ArrayList<Player>(Host.GetPlayers(true)); ArrayList<Player> players = new ArrayList<Player>(Host.GetPlayers(true));
Collections.shuffle(players); Collections.shuffle(players);
for(Player player : players) for (Player player : players)
{ {
_nonTaggedPlayers.add(player); _nonTaggedPlayers.add(player);
if(looped % 2 == 0) if (looped % 2 == 0)
{ {
addTagged(player); addTagged(player);
} }
@ -94,18 +100,18 @@ public class ChallengeReverseTag extends Challenge
{ {
int random = UtilMath.r(16); int random = UtilMath.r(16);
for(int x = -16; x <= 16; x += 4) for (int x = -16; x <= 16; x += 4)
{ {
for(int z = -16; z <= 16; z += 4) for (int z = -16; z <= 16; z += 4)
{ {
for(int y = 0; y <= 0; y++) for (int y = 0; y <= 0; y++)
{ {
Block b = getCenter().getBlock().getRelative(x, y, z); Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0) if (y == 0)
{ {
for(int _x = x; _x <= x + 3; _x++) for (int _x = x; _x <= x + 3; _x++)
{ {
for(int _z = z; _z <= z + 3; _z++) for (int _z = z; _z <= z + 3; _z++)
{ {
b = getCenter().getBlock().getRelative(_x, y, _z); b = getCenter().getBlock().getRelative(_x, y, _z);
b.setType(Material.WOOL); b.setType(Material.WOOL);
@ -115,7 +121,7 @@ public class ChallengeReverseTag extends Challenge
} }
random = UtilMath.r(16); random = UtilMath.r(16);
} }
if(b.getType() != Material.AIR) if (b.getType() != Material.AIR)
{ {
addBlock(b); addBlock(b);
} }
@ -127,21 +133,21 @@ public class ChallengeReverseTag extends Challenge
@EventHandler @EventHandler
public void tntFirework(UpdateEvent event) public void tntFirework(UpdateEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(event.getType() != UpdateType.SEC) if (event.getType() != UpdateType.SEC)
{ {
return; return;
} }
checkGameEnd(); checkGameEnd();
if(UtilServer.getPlayers().length > 40) // Made to prevent lag issues if (UtilServer.getPlayers().length > 40) // Made to prevent lag issues
{ {
return; return;
} }
for(String nameofPlayer : _tagged) for (String nameofPlayer : _tagged)
{ {
UtilFirework.playFirework(Bukkit.getPlayer(nameofPlayer).getEyeLocation(), Type.BURST, Color.GREEN, false, false); UtilFirework.playFirework(Bukkit.getPlayer(nameofPlayer).getEyeLocation(), Type.BURST, Color.GREEN, false, false);
} }
@ -150,25 +156,25 @@ public class ChallengeReverseTag extends Challenge
@EventHandler @EventHandler
public void onPlayerPunch(CustomDamageEvent event) public void onPlayerPunch(CustomDamageEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(event.GetDamagerPlayer(false) == null || event.GetDamageePlayer() == null) if (event.GetDamagerPlayer(false) == null || event.GetDamageePlayer() == null)
{ {
return; return;
} }
if(_tagged.contains(event.GetDamagerPlayer(false).getName())) if (_tagged.contains(event.GetDamagerPlayer(false).getName()))
{ {
event.SetCancelled("Tagger can't tag another"); event.SetCancelled("Tagger can't tag another");
return; return;
} }
if(!(_tagged.contains(event.GetDamageePlayer().getName()))) if (!(_tagged.contains(event.GetDamageePlayer().getName())))
{ {
event.SetCancelled("Damaged a nontagged person"); event.SetCancelled("Damaged a nontagged person");
return; return;
} }
if(_cooldowned.contains(event.GetDamageePlayer().getName())) if (_cooldowned.contains(event.GetDamageePlayer().getName()))
{ {
event.SetCancelled("Damaged is on cooldown"); event.SetCancelled("Damaged is on cooldown");
return; return;
@ -176,15 +182,15 @@ public class ChallengeReverseTag extends Challenge
removeTagged(event.GetDamageePlayer()); removeTagged(event.GetDamageePlayer());
addTagged(event.GetDamagerPlayer(false)); addTagged(event.GetDamagerPlayer(false));
} }
@EventHandler @EventHandler
public void displayGameProgress(UpdateEvent event) public void displayGameProgress(UpdateEvent event)
{ {
if(event.getType() != UpdateType.FASTEST) if (event.getType() != UpdateType.FASTEST)
{ {
return; return;
} }
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
@ -194,11 +200,11 @@ public class ChallengeReverseTag extends Challenge
@EventHandler @EventHandler
public void onTaggedDeath(PlayerDeathEvent event) public void onTaggedDeath(PlayerDeathEvent event)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(_tagged.contains(event.getEntity().getName())) if (_tagged.contains(event.getEntity().getName()))
{ {
_tagged.remove(event.getEntity().getName()); _tagged.remove(event.getEntity().getName());
} }
@ -206,20 +212,20 @@ public class ChallengeReverseTag extends Challenge
private void removeTagged(Player player) private void removeTagged(Player player)
{ {
if(_tagged.contains(player.getName())) if (_tagged.contains(player.getName()))
{ {
//UtilPlayer.message(player, C.cYellow + C.Bold + "You are " + C.cRed + "NO LONGER" + C.cYellow + " tagged!"); //UtilPlayer.message(player, C.cYellow + C.Bold + "You are " + C.cRed + "NO LONGER" + C.cYellow + " tagged!");
UtilTextMiddle.display(null, C.cRed + "You are no longer tagged.", 5, 40, 5, player); UtilTextMiddle.display(null, C.cRed + "You are no longer tagged.", 5, 40, 5, player);
player.getInventory().setHelmet(new ItemStack(Material.AIR)); player.getInventory().setHelmet(new ItemStack(Material.AIR));
_tagged.remove(player.getName()); _tagged.remove(player.getName());
if(_nonTaggedPlayers.contains(player)) if (_nonTaggedPlayers.contains(player))
{ {
_nonTaggedPlayers.remove(player); _nonTaggedPlayers.remove(player);
} }
for(int i = 0; i <= 8; i++) for (int i = 0; i <= 8; i++)
{ {
player.getInventory().clear(i); player.getInventory().clear(i);
} }
@ -228,15 +234,15 @@ public class ChallengeReverseTag extends Challenge
private void addTagged(final Player player) private void addTagged(final Player player)
{ {
if(!_tagged.contains(player.getName())) if (!_tagged.contains(player.getName()))
{ {
// UtilPlayer.message(player, C.cYellow + C.Bold + "You are " + C.cGreen + "NOW" + C.cYellow + " tagged! Keep it up!"); // UtilPlayer.message(player, C.cYellow + C.Bold + "You are " + C.cGreen + "NOW" + C.cYellow + " tagged! Keep it up!");
UtilTextMiddle.display(null, C.cGreen + "You are now tagged, keep it up.", 5, 40, 5, player); UtilTextMiddle.display(null, C.cGreen + "You are now tagged, keep it up.", 5, 40, 5, player);
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(35, (byte) 5)); player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(35, (byte) 5));
_tagged.add(player.getName()); _tagged.add(player.getName());
_cooldowned.add(player.getName()); _cooldowned.add(player.getName());
new BukkitRunnable() new BukkitRunnable()
{ {
@Override @Override
@ -244,10 +250,9 @@ public class ChallengeReverseTag extends Challenge
{ {
_cooldowned.remove(player.getName()); _cooldowned.remove(player.getName());
} }
}.runTaskLater(Host.Manager.getPlugin(), 20*_cooldown); }.runTaskLater(Host.Manager.getPlugin(), 20 * _cooldown);
for (int i = 0; i <= 8; i++)
for(int i = 0; i <= 8; i++)
{ {
player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(35, (byte) 5)); player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(35, (byte) 5));
} }
@ -256,11 +261,11 @@ public class ChallengeReverseTag extends Challenge
public void checkGameEnd() public void checkGameEnd()
{ {
if(System.currentTimeMillis() > _endTime) if (System.currentTimeMillis() > _endTime)
{ {
for(Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
if(_tagged.contains(player.getName())) if (_tagged.contains(player.getName()))
{ {
SetCompleted(player); SetCompleted(player);
} }
@ -271,7 +276,7 @@ public class ChallengeReverseTag extends Challenge
} }
} }
} }
public HashSet<Player> getNonTaggedPlayers() public HashSet<Player> getNonTaggedPlayers()
{ {
return _nonTaggedPlayers; return _nonTaggedPlayers;

View File

@ -20,6 +20,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeRunner extends Challenge public class ChallengeRunner extends Challenge
{ {
@ -27,8 +28,12 @@ public class ChallengeRunner extends Challenge
public ChallengeRunner(BawkBawkBattles host) public ChallengeRunner(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Runner", super(
"Blocks are disappearing beneath you! Run away!"); host,
ChallengeType.LastStanding,
"Runner",
"Blocks below your feet are falling.",
"Run as fast as you can!");
} }
@Override @Override
@ -73,7 +78,7 @@ public class ChallengeRunner extends Challenge
} }
_spawns.add(getCenter() _spawns.add(getCenter()
.add((pX * 4) + 1.5, 1.1, (pZ * 4) + 1.5)); .add((pX * 4) + 1.5, 1.1, (pZ * 4) + 1.5));
for (int x = pX * 4; x < (pX * 4) + 2; x++) for (int x = pX * 4; x < (pX * 4) + 2; x++)
{ {
@ -146,7 +151,7 @@ public class ChallengeRunner extends Challenge
byte data = block.getData(); byte data = block.getData();
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR); MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR);
FallingBlock ent = block.getWorld().spawnFallingBlock( FallingBlock ent = block.getWorld().spawnFallingBlock(
block.getLocation(), id, data); block.getLocation(), id, data);
_fallingBlocks.add(ent); _fallingBlocks.add(ent);
blockIterator.remove(); blockIterator.remove();
@ -156,7 +161,7 @@ public class ChallengeRunner extends Challenge
public void AddBlock(Block block) public void AddBlock(Block block)
{ {
if (block == null || block.getTypeId() == 0 || block.getTypeId() == 7 if (block == null || block.getTypeId() == 0 || block.getTypeId() == 7
|| block.isLiquid()) || block.isLiquid())
return; return;
if (block.getRelative(BlockFace.UP).getTypeId() != 0) if (block.getRelative(BlockFace.UP).getTypeId() != 0)

View File

@ -19,16 +19,22 @@ import mineplex.core.common.util.UtilTextMiddle;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeRushPush extends Challenge public class ChallengeRushPush extends Challenge
{ {
private boolean _challengeEnded = false;
private HashMap<String, String> _teams = new HashMap<String, String>(); private HashMap<String, String> _teams = new HashMap<String, String>();
public ChallengeRushPush(BawkBawkBattles host) public ChallengeRushPush(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Rush push", true, true, "Rush to your enemy.", super(
"Push them off the platform."); host,
ChallengeType.LastStanding,
"Rush push",
true,
true,
"Rush to your enemy.",
"Push them off the platform.");
} }
@Override @Override
@ -108,19 +114,19 @@ public class ChallengeRushPush extends Challenge
} }
} }
} }
@EventHandler @EventHandler
public void onDeath(PlayerDeathEvent event) public void onDeath(PlayerDeathEvent event)
{ {
int onBlue = 0; int onBlue = 0;
int onRed = 0; int onRed = 0;
if(_teams.containsKey(event.getEntity().getName())) if (_teams.containsKey(event.getEntity().getName()))
{ {
_teams.remove(event.getEntity().getName()); _teams.remove(event.getEntity().getName());
} }
for(String playerName: _teams.keySet()) for (String playerName : _teams.keySet())
{ {
if(_teams.get(playerName) == "blue") if (_teams.get(playerName) == "blue")
{ {
onBlue++; onBlue++;
} }
@ -129,7 +135,7 @@ public class ChallengeRushPush extends Challenge
onRed++; onRed++;
} }
} }
if((onBlue == 0 || onRed == 0) && Host.isCrumbling() == false) if ((onBlue == 0 || onRed == 0) && Host.isCrumbling() == false)
{ {
UtilTextMiddle.display(onBlue == 0 ? C.cBlue + "Blue Team won!" : C.cRed + "Red Team won!", "Friendly fire enabled!", 20, 60, 20); UtilTextMiddle.display(onBlue == 0 ? C.cBlue + "Blue Team won!" : C.cRed + "Red Team won!", "Friendly fire enabled!", 20, 60, 20);
} }
@ -158,7 +164,7 @@ public class ChallengeRushPush extends Challenge
if (_teams.containsKey(event.GetDamageePlayer().getName())) if (_teams.containsKey(event.GetDamageePlayer().getName()))
{ {
if (_teams.get(event.GetDamagerPlayer(false).getName()) == _teams.get(event.GetDamageePlayer() if (_teams.get(event.GetDamagerPlayer(false).getName()) == _teams.get(event.GetDamageePlayer()
.getName())) .getName()))
{ {
event.SetCancelled("Friendly Fire"); event.SetCancelled("Friendly Fire");
return; return;

View File

@ -4,16 +4,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -29,17 +19,33 @@ import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeShootChickens extends Challenge public class ChallengeShootChickens extends Challenge
{ {
private ArrayList<Chicken> _chickens = new ArrayList<Chicken>(); private ArrayList<Chicken> _chickens = new ArrayList<Chicken>();
private HashMap<String, Integer> _killedChickens = new HashMap<String, Integer>(); private HashMap<String, Integer> _killedChickens = new HashMap<String, Integer>();
private ArrayList<Projectile> _arrows = new ArrayList<Projectile>(); private ArrayList<Projectile> _arrows = new ArrayList<Projectile>();
private HashMap<Player, Integer> _arrowsShot = new HashMap<Player, Integer>(); private HashMap<Player, Integer> _arrowsShot = new HashMap<Player, Integer>();
public ChallengeShootChickens(BawkBawkBattles host) public ChallengeShootChickens(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Chicken Shooting", "Shoot 6 chickens!"); super(
host,
ChallengeType.FirstComplete,
"Chicken Shooting",
"Shoot 6 chickens.",
"When a chicken lands, it dissapears.");
} }
@Override @Override
@ -60,16 +66,16 @@ public class ChallengeShootChickens extends Challenge
@EventHandler @EventHandler
public void onShoot(ProjectileLaunchEvent event) public void onShoot(ProjectileLaunchEvent event)
{ {
if(event.getEntity() instanceof Arrow) if (event.getEntity() instanceof Arrow)
{ {
_arrows.add(event.getEntity()); _arrows.add(event.getEntity());
Arrow arrow = (Arrow) event.getEntity(); Arrow arrow = (Arrow) event.getEntity();
Player player = (Player) arrow.getShooter(); Player player = (Player) arrow.getShooter();
if(!isDone(player)) if (!isDone(player))
{ {
_arrowsShot.put(player, _arrowsShot.get(player)+1); _arrowsShot.put(player, _arrowsShot.get(player) + 1);
} }
} }
} }
@ -131,11 +137,11 @@ public class ChallengeShootChickens extends Challenge
return; return;
} }
UpdateType speed; UpdateType speed;
if(getCurrentyAlive(false).size() >= 40) if (getCurrentyAlive(false).size() >= 40)
{ {
speed = UpdateType.FASTEST; speed = UpdateType.FASTEST;
} }
else if(getCurrentyAlive(false).size() >= 20) else if (getCurrentyAlive(false).size() >= 20)
{ {
speed = UpdateType.FASTER; speed = UpdateType.FASTER;
} }
@ -164,7 +170,8 @@ public class ChallengeShootChickens extends Challenge
if (_chickens.size() < 11 + (getChallengers().size() * 2)) if (_chickens.size() < 11 + (getChallengers().size() * 2))
{ {
Location loc = getCenter().clone().add(UtilMath.r(getArenaSize()*2) - (getArenaSize()), 15, UtilMath.r(getArenaSize()*2) - (getArenaSize())); Location loc = getCenter().clone().add(UtilMath.r(getArenaSize() * 2) - (getArenaSize()), 15,
UtilMath.r(getArenaSize() * 2) - (getArenaSize()));
Host.CreatureAllowOverride = true; Host.CreatureAllowOverride = true;
Chicken chicken = (Chicken) loc.getWorld().spawnEntity(loc, EntityType.CHICKEN); Chicken chicken = (Chicken) loc.getWorld().spawnEntity(loc, EntityType.CHICKEN);
@ -183,7 +190,8 @@ public class ChallengeShootChickens extends Challenge
for (Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
player.getInventory().setItem(0,new ItemBuilder(Material.BOW).addEnchantment(Enchantment.ARROW_INFINITE, 1).setUnbreakable(true).build()); player.getInventory().setItem(0,
new ItemBuilder(Material.BOW).addEnchantment(Enchantment.ARROW_INFINITE, 1).setUnbreakable(true).build());
player.getInventory().setItem(9, new ItemStack(Material.ARROW)); player.getInventory().setItem(9, new ItemStack(Material.ARROW));
_killedChickens.put(player.getName(), 0); _killedChickens.put(player.getName(), 0);
@ -242,9 +250,9 @@ public class ChallengeShootChickens extends Challenge
{ {
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
for (int x = -(getArenaSize()-1); x <= getArenaSize()-1; x++) for (int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++)
{ {
for (int z = -(getArenaSize()-1); z <= getArenaSize()-1; z++) for (int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{ {
if (x % 2 == 0 && z % 2 == 0) if (x % 2 == 0 && z % 2 == 0)
{ {
@ -255,7 +263,7 @@ public class ChallengeShootChickens extends Challenge
return spawns; return spawns;
} }
public HashMap<Player, Integer> getArrowsShot() public HashMap<Player, Integer> getArrowsShot()
{ {
return _arrowsShot; return _arrowsShot;

View File

@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeSmashOff extends Challenge public class ChallengeSmashOff extends Challenge
{ {
@ -17,7 +18,13 @@ public class ChallengeSmashOff extends Challenge
public ChallengeSmashOff(BawkBawkBattles host) public ChallengeSmashOff(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Smash off", false, true, "Knock other players off the platform!"); super(
host,
ChallengeType.LastStanding,
"Smash Off",
false,
true,
"Knock all others off the platform.");
} }
@Override @Override

View File

@ -14,13 +14,17 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeSpleef extends Challenge public class ChallengeSpleef extends Challenge
{ {
public ChallengeSpleef(BawkBawkBattles host) public ChallengeSpleef(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Spleef", super(
"Destroy the blocks beneath other players!"); host,
ChallengeType.LastStanding,
"Spleef",
"Destroy the blocks beneath other players!");
} }
@Override @Override
@ -64,7 +68,7 @@ public class ChallengeSpleef extends Challenge
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND,
block.getTypeId()); block.getTypeId());
block.setType(Material.AIR); block.setType(Material.AIR);
} }

View File

@ -5,6 +5,14 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
@ -13,14 +21,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
public class ChallengeStandOnColor extends Challenge public class ChallengeStandOnColor extends Challenge
{ {
@ -33,7 +34,11 @@ public class ChallengeStandOnColor extends Challenge
public ChallengeStandOnColor(BawkBawkBattles host) public ChallengeStandOnColor(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Color Change", "Stand on the correct color."); super(
host,
ChallengeType.LastStanding,
"Color Change",
"Stand on the correct color.");
for (int i = 0; i <= 15; i++) for (int i = 0; i <= 15; i++)
{ {

View File

@ -26,6 +26,7 @@ import mineplex.core.recharge.Recharge;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeTntLauncher extends Challenge public class ChallengeTntLauncher extends Challenge
{ {
@ -34,7 +35,14 @@ public class ChallengeTntLauncher extends Challenge
public ChallengeTntLauncher(BawkBawkBattles host) public ChallengeTntLauncher(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Deadly TNT", false, true, "Throw TNT to other players.", "Don't get knocked off!"); super(
host,
ChallengeType.LastStanding,
"Deadly TNT",
false,
true,
"Throw TNT to other players.",
"Do not get knocked off.");
} }
@Override @Override
@ -64,7 +72,7 @@ public class ChallengeTntLauncher extends Challenge
return; return;
HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getLocation(), HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getLocation(),
4 + ((System.currentTimeMillis() - getStartTime()) / 10000D)); 4 + ((System.currentTimeMillis() - getStartTime()) / 10000D));
for (Player player : players.keySet()) for (Player player : players.keySet())
{ {
@ -73,7 +81,7 @@ public class ChallengeTntLauncher extends Challenge
// Knockback // Knockback
UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 3 * mult, false, 0, UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 3 * mult, false, 0,
0.5 + 2 * mult, 10, true); 0.5 + 2 * mult, 10, true);
} }
event.blockList().clear(); event.blockList().clear();

View File

@ -3,13 +3,6 @@ package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilTextMiddle;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -27,6 +20,14 @@ import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilTextMiddle;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeTreasureDigger extends Challenge public class ChallengeTreasureDigger extends Challenge
{ {
private LinkedHashMap<Material, Double> _lootChance = new LinkedHashMap<Material, Double>(); private LinkedHashMap<Material, Double> _lootChance = new LinkedHashMap<Material, Double>();
@ -34,8 +35,12 @@ public class ChallengeTreasureDigger extends Challenge
public ChallengeTreasureDigger(BawkBawkBattles host) public ChallengeTreasureDigger(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Treasure Digger", "Search for treasure below the sand.", "Find weapons to kill the others!", super(
"Be the last person to stay alive."); host,
ChallengeType.LastStanding,
"Treasure Digger",
"Search for treasure below the sand.",
"Find weapons to kill the others!");
_lootChance.put(Material.BONE, 20.0); _lootChance.put(Material.BONE, 20.0);
_lootChance.put(Material.STRING, 20.0); _lootChance.put(Material.STRING, 20.0);
@ -83,7 +88,7 @@ public class ChallengeTreasureDigger extends Challenge
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
Location center = new Location(Host.WorldData.World, 0, 0, 0); Location center = new Location(Host.WorldData.World, 0, 0, 0);
for(Location location : UtilShapes.getCircle(center, true, getArenaSize() - 2)) for (Location location : UtilShapes.getCircle(center, true, getArenaSize() - 2))
{ {
double x = location.getX() + 0.5; double x = location.getX() + 0.5;
double y = 4.1; double y = 4.1;
@ -102,73 +107,73 @@ public class ChallengeTreasureDigger extends Challenge
{ {
Location center = new Location(Host.WorldData.World, 0, 0, 0); Location center = new Location(Host.WorldData.World, 0, 0, 0);
for(int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
if(i > 0) if (i > 0)
{ {
center = center.clone(); center = center.clone();
center.setY(0); center.setY(0);
center.add(0, i, 0); center.add(0, i, 0);
} }
for(Location location : UtilShapes.getCircle(center, false, getArenaSize())) for (Location location : UtilShapes.getCircle(center, false, getArenaSize()))
{ {
Block block = location.getBlock(); Block block = location.getBlock();
double chance = Math.random() * 100; double chance = Math.random() * 100;
if(i == 0) if (i == 0)
{ {
block.setType(Material.BEDROCK); block.setType(Material.BEDROCK);
} }
else if(i == 1) else if (i == 1)
{ {
block.setType(Material.SAND); block.setType(Material.SAND);
if(chance < 45.0) // 20% if (chance < 45.0) // 20%
{ {
block.setData((byte) 1); block.setData((byte) 1);
} }
if(chance < 25.0) // 10% if (chance < 25.0) // 10%
{ {
block.setType(Material.SANDSTONE); block.setType(Material.SANDSTONE);
block.setData((byte) 0); block.setData((byte) 0);
} }
if(chance < 15.0) // 15% if (chance < 15.0) // 15%
{ {
makeChestWithTreasure(block); makeChestWithTreasure(block);
} }
} }
else if(i == 2) else if (i == 2)
{ {
block.setType(Material.SAND); block.setType(Material.SAND);
if(chance < 30.0) // 20% if (chance < 30.0) // 20%
{ {
block.setData((byte) 1); block.setData((byte) 1);
} }
if(chance < 10.0) // 10% if (chance < 10.0) // 10%
{ {
block.setType(Material.SANDSTONE); block.setType(Material.SANDSTONE);
block.setData((byte) 0); block.setData((byte) 0);
} }
} }
else if(i == 3) else if (i == 3)
{ {
block.setType(Material.SAND); block.setType(Material.SAND);
if(chance < 10.0) // 10% if (chance < 10.0) // 10%
{ {
block.setType(Material.SANDSTONE); block.setType(Material.SANDSTONE);
} }
} }
else if(i == 4) else if (i == 4)
{ {
Block below = block.getRelative(BlockFace.DOWN); Block below = block.getRelative(BlockFace.DOWN);
if(chance < 1.5 && !getSpawns().contains(block.getLocation()) && below.getType() == Material.SAND) if (chance < 1.5 && !getSpawns().contains(block.getLocation()) && below.getType() == Material.SAND)
{ {
block.setType(Material.DEAD_BUSH); block.setType(Material.DEAD_BUSH);
} }
@ -190,7 +195,7 @@ public class ChallengeTreasureDigger extends Challenge
Host.WorldBlockBurn = true; Host.WorldBlockBurn = true;
Host.WorldFireSpread = true; Host.WorldFireSpread = true;
for(Player players : Host.GetPlayers(true)) for (Player players : Host.GetPlayers(true))
{ {
ItemStack shovel = new ItemStack(Material.STONE_SPADE); ItemStack shovel = new ItemStack(Material.STONE_SPADE);
players.getInventory().setItem(4, shovel); players.getInventory().setItem(4, shovel);
@ -210,9 +215,9 @@ public class ChallengeTreasureDigger extends Challenge
Host.WorldBlockBurn = false; Host.WorldBlockBurn = false;
Host.WorldFireSpread = false; Host.WorldFireSpread = false;
for(Entity entity : Host.WorldData.World.getEntities()) for (Entity entity : Host.WorldData.World.getEntities())
{ {
if(entity instanceof Item) if (entity instanceof Item)
{ {
entity.remove(); entity.remove();
} }
@ -228,7 +233,7 @@ public class ChallengeTreasureDigger extends Challenge
@EventHandler @EventHandler
public void onEntityChangeBlock(EntityChangeBlockEvent event) public void onEntityChangeBlock(EntityChangeBlockEvent event)
{ {
if(event.getEntity() instanceof FallingBlock) if (event.getEntity() instanceof FallingBlock)
{ {
FallingBlock block = (FallingBlock) event.getEntity(); FallingBlock block = (FallingBlock) event.getEntity();
block.setDropItem(false); block.setDropItem(false);
@ -238,17 +243,17 @@ public class ChallengeTreasureDigger extends Challenge
@EventHandler @EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
{ {
if(event.getEntity() instanceof Player && event.getDamager() instanceof Player) if (event.getEntity() instanceof Player && event.getDamager() instanceof Player)
{ {
Player damager = (Player) event.getDamager(); Player damager = (Player) event.getDamager();
ItemStack item = damager.getItemInHand(); ItemStack item = damager.getItemInHand();
if(isDone(damager)) if (isDone(damager))
return; return;
if(item != null) if (item != null)
{ {
if(!item.getType().name().toLowerCase().contains("sword")) if (!item.getType().name().toLowerCase().contains("sword"))
{ {
UtilTextMiddle.display("", C.cRed + "You cannot attack without a weapon.", 5, 40, 5, damager); UtilTextMiddle.display("", C.cRed + "You cannot attack without a weapon.", 5, 40, 5, damager);
damager.playSound(damager.getLocation(), Sound.NOTE_BASS_GUITAR, 1.0F, 0.5F); damager.playSound(damager.getLocation(), Sound.NOTE_BASS_GUITAR, 1.0F, 0.5F);
@ -261,7 +266,7 @@ public class ChallengeTreasureDigger extends Challenge
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void makeChestWithTreasure(Block block) private void makeChestWithTreasure(Block block)
{ {
if(!areChestsNearby(block)) if (!areChestsNearby(block))
{ {
block.setType(Material.CHEST); block.setType(Material.CHEST);
block.setData((byte) UtilMath.r(4)); block.setData((byte) UtilMath.r(4));
@ -279,38 +284,38 @@ public class ChallengeTreasureDigger extends Challenge
Block west = block.getRelative(BlockFace.WEST); Block west = block.getRelative(BlockFace.WEST);
return north.getType() == Material.CHEST || south.getType() == Material.CHEST || east.getType() == Material.CHEST return north.getType() == Material.CHEST || south.getType() == Material.CHEST || east.getType() == Material.CHEST
|| west.getType() == Material.CHEST; || west.getType() == Material.CHEST;
} }
private void fillChestWithLoot(Chest chest) private void fillChestWithLoot(Chest chest)
{ {
Inventory inv = chest.getInventory(); Inventory inv = chest.getInventory();
for(int i = 0; i <= UtilMath.r(2) + 1; i++) for (int i = 0; i <= UtilMath.r(2) + 1; i++)
{ {
double chance = Math.random() * 100; double chance = Math.random() * 100;
Material loot = getRandomLootMaterial(); Material loot = getRandomLootMaterial();
double lootChance = getLootChance(loot); double lootChance = getLootChance(loot);
while(chance >= lootChance) while (chance >= lootChance)
{ {
chance = Math.random() * 100; chance = Math.random() * 100;
loot = getRandomLootMaterial(); loot = getRandomLootMaterial();
lootChance = getLootChance(loot); lootChance = getLootChance(loot);
} }
if(chance < lootChance) if (chance < lootChance)
{ {
ItemStack item = new ItemStack(loot); ItemStack item = new ItemStack(loot);
if(item.getType() == Material.ARROW || item.getType() == Material.BONE || item.getType() == Material.STRING) if (item.getType() == Material.ARROW || item.getType() == Material.BONE || item.getType() == Material.STRING)
{ {
item.setAmount(UtilMath.r(3) + 1); item.setAmount(UtilMath.r(3) + 1);
} }
int slot = UtilMath.r(inv.getSize()); int slot = UtilMath.r(inv.getSize());
while(inv.getItem(slot) != null && inv.getContents().length != inv.getSize()) while (inv.getItem(slot) != null && inv.getContents().length != inv.getSize())
{ {
slot = UtilMath.r(inv.getSize()); slot = UtilMath.r(inv.getSize());
} }

View File

@ -38,6 +38,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeVolleyPig extends Challenge public class ChallengeVolleyPig extends Challenge
{ {
@ -51,7 +52,11 @@ public class ChallengeVolleyPig extends Challenge
public ChallengeVolleyPig(BawkBawkBattles host) public ChallengeVolleyPig(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Volley Pig", "Punch the pig on the enemy side.", "Do not cross the middle!"); super(
host,
ChallengeType.FirstComplete,
"Volley Pig",
"Punch the pig on the enemy side.");
} }
@Override @Override
@ -138,7 +143,7 @@ public class ChallengeVolleyPig extends Challenge
{ {
String pName = event.getPlayer().getName(); String pName = event.getPlayer().getName();
Vector bump = UtilAlg.getAverageBump(event.getPlayer().getLocation(), Vector bump = UtilAlg.getAverageBump(event.getPlayer().getLocation(),
new ArrayList<Location>(Arrays.asList(_playerTeams.get(pName) == "blue" ? _blueCenter : _redCenter))); new ArrayList<Location>(Arrays.asList(_playerTeams.get(pName) == "blue" ? _blueCenter : _redCenter)));
UtilAction.velocity(event.getPlayer(), bump, 0.8, false, 0, 0.4, 10, true); UtilAction.velocity(event.getPlayer(), bump, 0.8, false, 0, 0.4, 10, true);
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 3, 1)); event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 3, 1));

View File

@ -30,6 +30,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeWaterHorror extends Challenge public class ChallengeWaterHorror extends Challenge
{ {
@ -43,8 +44,12 @@ public class ChallengeWaterHorror extends Challenge
public ChallengeWaterHorror(BawkBawkBattles host) public ChallengeWaterHorror(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Water Horror", "Deadly TNT is spawning from the water!", super(
"Use your boat to dodge explosions."); host,
ChallengeType.LastStanding,
"Water Horror",
"TNT is spawning from the water!",
"Use your boat to dodge explosions.");
} }
@Override @Override
@ -198,8 +203,8 @@ public class ChallengeWaterHorror extends Challenge
if (entity.isValid() && !entity.isOnGround()) if (entity.isValid() && !entity.isOnGround())
{ {
UtilParticle.PlayParticleToAll(ParticleType.FLAME, entity.getLocation(), 0.2F, 0.2F, 0.2F, UtilParticle.PlayParticleToAll(ParticleType.FLAME, entity.getLocation(), 0.2F, 0.2F, 0.2F,
0.0F, 2, 0.0F, 2,
ViewDist.LONG); ViewDist.LONG);
new BukkitRunnable() new BukkitRunnable()
{ {
@ -226,7 +231,7 @@ public class ChallengeWaterHorror extends Challenge
UtilParticle.PlayParticleToAll(ParticleType.FLAME, dropsite, 0.3F, 0.3F, 0.3F, 0.03F, 2, ViewDist.LONG); UtilParticle.PlayParticleToAll(ParticleType.FLAME, dropsite, 0.3F, 0.3F, 0.3F, 0.03F, 2, ViewDist.LONG);
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, base, 0.1F, 0.1F, 0.1F, 0.0F, 2, UtilParticle.PlayParticleToAll(ParticleType.CLOUD, base, 0.1F, 0.1F, 0.1F, 0.0F, 2,
ViewDist.LONG); ViewDist.LONG);
} }
@EventHandler @EventHandler

View File

@ -20,6 +20,7 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.projectile.ProjectileUser; import mineplex.core.projectile.ProjectileUser;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
import nautilus.game.arcade.game.games.mineware.events.ChallengeEndEvent; import nautilus.game.arcade.game.games.mineware.events.ChallengeEndEvent;
public class ChallengeWaveCrush extends Challenge public class ChallengeWaveCrush extends Challenge
@ -28,12 +29,16 @@ public class ChallengeWaveCrush extends Challenge
private int _waveAmount = 0; private int _waveAmount = 0;
private int _waveSpeed = 30; // in ticks private int _waveSpeed = 30; // in ticks
private ArrayList<Integer> _colorList = new ArrayList<Integer>(Arrays.asList(14, 11, 9, 3, 1, 4, 13, 5)); private ArrayList<Integer> _colorList = new ArrayList<Integer>(Arrays.asList(14, 11, 9, 3, 1, 4, 13, 5));
private HashMap<Player, Integer> _survivedWaves = new HashMap<Player, Integer>(); private HashMap<Player, Integer> _survivedWaves = new HashMap<Player, Integer>();
public ChallengeWaveCrush(BawkBawkBattles host) public ChallengeWaveCrush(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Wave Crush", "Avoid the crushing waves!"); super(
host,
ChallengeType.LastStanding,
"Wave Crush",
"Avoid the crushing waves.");
} }
@Override @Override
@ -41,11 +46,11 @@ public class ChallengeWaveCrush extends Challenge
{ {
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -15; x <= -13; x++) for (int x = -15; x <= -13; x++)
{ {
for(int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++) for (int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{ {
if(x % 2 == 0 && z % 2 == 0) if (x % 2 == 0 && z % 2 == 0)
{ {
spawns.add(getCenter().clone().add(x + 0.5, 2.1, z + 0.5)); spawns.add(getCenter().clone().add(x + 0.5, 2.1, z + 0.5));
} }
@ -59,17 +64,17 @@ public class ChallengeWaveCrush extends Challenge
{ {
_inProgress = false; _inProgress = false;
for(int x = -16; x <= 15; x++) for (int x = -16; x <= 15; x++)
{ {
for(int z = -getArenaSize(); z <= getArenaSize(); z++) for (int z = -getArenaSize(); z <= getArenaSize(); z++)
{ {
for(int y = 0; y <= 10; y++) for (int y = 0; y <= 10; y++)
{ {
Block b = Host.WorldData.World.getBlockAt(x, y, z); Block b = Host.WorldData.World.getBlockAt(x, y, z);
{ {
if(b.getType() != Material.AIR) if (b.getType() != Material.AIR)
{ {
if(!getModifiedBlocks().contains(b)) if (!getModifiedBlocks().contains(b))
{ {
b.setType(Material.AIR); b.setType(Material.AIR);
} }
@ -83,11 +88,11 @@ public class ChallengeWaveCrush extends Challenge
@Override @Override
public void setupPlayers() public void setupPlayers()
{ {
for(Player player: Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
_survivedWaves.put(player, 0); _survivedWaves.put(player, 0);
} }
_inProgress = true; _inProgress = true;
new BukkitRunnable() new BukkitRunnable()
@ -99,28 +104,28 @@ public class ChallengeWaveCrush extends Challenge
_waveAmount++; _waveAmount++;
Block choosenBlock; Block choosenBlock;
if(!_inProgress || !Host.IsLive()) if (!_inProgress || !Host.IsLive())
{ {
this.cancel(); this.cancel();
} }
choosenBlock = Host.WorldData.World.getBlockAt(15, 1, UtilMath.r(getArenaSize() * 2) - getArenaSize()); choosenBlock = Host.WorldData.World.getBlockAt(15, 1, UtilMath.r(getArenaSize() * 2) - getArenaSize());
while(choosenBlock.getType() == Material.AIR) while (choosenBlock.getType() == Material.AIR)
{ {
choosenBlock = Host.WorldData.World.getBlockAt(15, 1, UtilMath.r(getArenaSize() * 2) - getArenaSize()); choosenBlock = Host.WorldData.World.getBlockAt(15, 1, UtilMath.r(getArenaSize() * 2) - getArenaSize());
} }
waveStartingPoint(choosenBlock, 2); waveStartingPoint(choosenBlock, 2);
if(_waveAmount % 3 == 0) if (_waveAmount % 3 == 0)
{ {
_waveSpeed--; _waveSpeed--;
} }
for(Player player: _survivedWaves.keySet()) for (Player player : _survivedWaves.keySet())
{ {
if(!isDone(player)) if (!isDone(player))
{ {
_survivedWaves.put(player, _survivedWaves.get(player)+1); _survivedWaves.put(player, _survivedWaves.get(player) + 1);
} }
} }
} }
@ -133,30 +138,30 @@ public class ChallengeWaveCrush extends Challenge
int var = 0; int var = 0;
int colorPicker = 0; int colorPicker = 0;
for(int x = -16; x <= 15; x++) for (int x = -16; x <= 15; x++)
{ {
for(int z = -getArenaSize(); z <= getArenaSize(); z++) for (int z = -getArenaSize(); z <= getArenaSize(); z++)
{ {
for(int y = 0; y <= 1; y++) for (int y = 0; y <= 1; y++)
{ {
Block b = getCenter().getBlock().getRelative(x, y, z); Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0) if (y == 0)
{ {
b.setType(Material.BEDROCK); b.setType(Material.BEDROCK);
} }
else if(y > 0) else if (y > 0)
{ {
b.setType(Material.WOOL); b.setType(Material.WOOL);
b.setData(_colorList.get(colorPicker).byteValue()); b.setData(_colorList.get(colorPicker).byteValue());
} }
if(b.getType() != Material.AIR) if (b.getType() != Material.AIR)
{ {
addBlock(b); addBlock(b);
} }
} }
} }
if(var % 4 == 0 && (colorPicker != _colorList.size() - 1)) if (var % 4 == 0 && (colorPicker != _colorList.size() - 1))
{ {
colorPicker++; colorPicker++;
} }
@ -167,37 +172,37 @@ public class ChallengeWaveCrush extends Challenge
@Override @Override
public void onCollide(LivingEntity target, Block block, ProjectileUser data) public void onCollide(LivingEntity target, Block block, ProjectileUser data)
{ {
if(!Host.IsLive()) if (!Host.IsLive())
{ {
return; return;
} }
if(!(data.GetThrown() instanceof FallingBlock)) if (!(data.GetThrown() instanceof FallingBlock))
{ {
return; return;
} }
if(!(target instanceof Player)) if (!(target instanceof Player))
{ {
return; return;
} }
Player thePlayer = (Player) target; Player thePlayer = (Player) target;
if(isDone(thePlayer)) if (isDone(thePlayer))
{ {
return; return;
} }
if(!Host.IsAlive(thePlayer)) if (!Host.IsAlive(thePlayer))
{ {
return; return;
} }
Host.Manager.GetDamage().NewDamageEvent(target, null, null, DamageCause.PROJECTILE, 9999.0, false, false, false, "Falling Block", Host.Manager.GetDamage().NewDamageEvent(target, null, null, DamageCause.PROJECTILE, 9999.0, false, false, false, "Falling Block",
"Wave crush"); "Wave crush");
} }
public void waveStartingPoint(Block block, int radius) public void waveStartingPoint(Block block, int radius)
{ {
Block pickedBlock = Host.WorldData.World.getBlockAt(block.getX(), block.getY(), block.getZ() - radius); Block pickedBlock = Host.WorldData.World.getBlockAt(block.getX(), block.getY(), block.getZ() - radius);
if(radius != 1) if (radius != 1)
{ {
for(int i = 0; i <= (radius * 2) + 1; i++) for (int i = 0; i <= (radius * 2) + 1; i++)
{ {
waveCreation(Host.WorldData.World.getBlockAt(pickedBlock.getX(), pickedBlock.getY(), pickedBlock.getZ() + i)); waveCreation(Host.WorldData.World.getBlockAt(pickedBlock.getX(), pickedBlock.getY(), pickedBlock.getZ() + i));
} }
@ -211,9 +216,9 @@ public class ChallengeWaveCrush extends Challenge
@EventHandler @EventHandler
public void OnChallengeEnd(ChallengeEndEvent event) public void OnChallengeEnd(ChallengeEndEvent event)
{ {
for(Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
if(!isDone(player)) if (!isDone(player))
{ {
SetCompleted(player); SetCompleted(player);
} }
@ -224,9 +229,9 @@ public class ChallengeWaveCrush extends Challenge
@Override @Override
public void run() public void run()
{ {
for(Entity fBlocks : Host.WorldData.World.getEntities()) for (Entity fBlocks : Host.WorldData.World.getEntities())
{ {
if(fBlocks instanceof FallingBlock) if (fBlocks instanceof FallingBlock)
{ {
fBlocks.remove(); fBlocks.remove();
} }
@ -245,16 +250,16 @@ public class ChallengeWaveCrush extends Challenge
@Override @Override
public void run() public void run()
{ {
if(!_inProgress) if (!_inProgress)
{ {
this.cancel(); this.cancel();
} }
if(theBlock.getType() == Material.AIR) if (theBlock.getType() == Material.AIR)
{ {
this.cancel(); this.cancel();
} }
FallingBlock fBlock = Host.WorldData.World.spawnFallingBlock(theBlock.getLocation().clone().add(0, 1, 0), theBlock.getType(), FallingBlock fBlock = Host.WorldData.World.spawnFallingBlock(theBlock.getLocation().clone().add(0, 1, 0), theBlock.getType(),
theBlock.getData()); theBlock.getData());
Host.Manager.GetProjectile().AddThrow(fBlock, null, Host, -1, true, false, true, true, 0.7f); Host.Manager.GetProjectile().AddThrow(fBlock, null, Host, -1, true, false, true, true, 0.7f);
fBlock.setVelocity(new Vector(0, 10, 0).normalize()); fBlock.setVelocity(new Vector(0, 10, 0).normalize());
@ -263,7 +268,7 @@ public class ChallengeWaveCrush extends Challenge
} }
}.runTaskTimer(Host.Manager.getPlugin(), 0, 2); }.runTaskTimer(Host.Manager.getPlugin(), 0, 2);
} }
public HashMap<Player, Integer> getsurvivedwaves() public HashMap<Player, Integer> getsurvivedwaves()
{ {
return _survivedWaves; return _survivedWaves;

View File

@ -3,19 +3,6 @@ package nautilus.game.arcade.game.games.mineware.challenges.removed;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import org.bukkit.FireworkEffect.Type; import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -32,6 +19,20 @@ import org.bukkit.material.Wool;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeBlockShot extends Challenge public class ChallengeBlockShot extends Challenge
{ {
private HashMap<String, Integer> _shotBlocks = new HashMap<String, Integer>(); private HashMap<String, Integer> _shotBlocks = new HashMap<String, Integer>();
@ -40,7 +41,11 @@ public class ChallengeBlockShot extends Challenge
public ChallengeBlockShot(BawkBawkBattles host) public ChallengeBlockShot(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Block Shot", "Shoot down 5 blocks"); super(
host,
ChallengeType.FirstComplete,
"Block Shot",
"Shoot down 5 blocks");
} }
@Override @Override
@ -95,10 +100,10 @@ public class ChallengeBlockShot extends Challenge
Location sloc = player.getEyeLocation(); Location sloc = player.getEyeLocation();
sloc.add(UtilAlg.getTrajectory(sloc, block.getLocation().add(0.5, 0.5, 0.5)).multiply( sloc.add(UtilAlg.getTrajectory(sloc, block.getLocation().add(0.5, 0.5, 0.5)).multiply(
Math.min(7, block.getLocation().distance(sloc)))); Math.min(7, block.getLocation().distance(sloc))));
displayCount(player, sloc, displayCount(player, sloc,
(score >= 5 ? C.cDGreen : score >= 3 ? C.cGreen : score >= 1 ? C.cRed : C.cDRed) + score); (score >= 5 ? C.cDGreen : score >= 3 ? C.cGreen : score >= 1 ? C.cRed : C.cDRed) + score);
if (score == 5) if (score == 5)
{ {
@ -107,7 +112,7 @@ public class ChallengeBlockShot extends Challenge
Location loc = block.getLocation().add(0.5, 0.5, 0.5); Location loc = block.getLocation().add(0.5, 0.5, 0.5);
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, loc, 0, 0, 0, 0, 1, ViewDist.MAX, UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, loc, 0, 0, 0, 0, 1, ViewDist.MAX,
UtilServer.getPlayers()); UtilServer.getPlayers());
spawnBlock(); spawnBlock();
@ -154,7 +159,7 @@ public class ChallengeBlockShot extends Challenge
for (Player player : Host.GetPlayers(true)) for (Player player : Host.GetPlayers(true))
{ {
player.getInventory().setItem(0, player.getInventory().setItem(0,
new ItemBuilder(Material.BOW).addEnchantment(Enchantment.ARROW_INFINITE, 1).setUnbreakable(true).build()); new ItemBuilder(Material.BOW).addEnchantment(Enchantment.ARROW_INFINITE, 1).setUnbreakable(true).build());
player.getInventory().setItem(9, new ItemStack(Material.ARROW)); player.getInventory().setItem(9, new ItemStack(Material.ARROW));
_shotBlocks.put(player.getName(), 0); _shotBlocks.put(player.getName(), 0);

View File

@ -18,12 +18,17 @@ import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeDiamondFall extends Challenge public class ChallengeDiamondFall extends Challenge
{ {
public ChallengeDiamondFall(BawkBawkBattles host) public ChallengeDiamondFall(BawkBawkBattles host)
{ {
super(host, ChallengeType.LastStanding, "Diamond Fall", "Loot the most diamonds from chests!"); super(
host,
ChallengeType.LastStanding,
"Diamond Fall",
"Loot the most diamonds from chests!");
} }
@Override @Override

View File

@ -16,6 +16,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeHitTargets extends Challenge public class ChallengeHitTargets extends Challenge
{ {
@ -24,7 +25,11 @@ public class ChallengeHitTargets extends Challenge
public ChallengeHitTargets(BawkBawkBattles host) public ChallengeHitTargets(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Hit target", "Hit the chosen players"); super(
host,
ChallengeType.FirstComplete,
"Hit target",
"Hit the chosen players.");
} }
@EventHandler @EventHandler
@ -56,7 +61,7 @@ public class ChallengeHitTargets extends Challenge
} }
displayCount(p, event.GetDamageeEntity().getEyeLocation().add(0, 0.3, 0), (targets.isEmpty() ? C.cDGreen displayCount(p, event.GetDamageeEntity().getEyeLocation().add(0, 0.3, 0), (targets.isEmpty() ? C.cDGreen
: targets.size() == 1 ? C.cRed : C.cDRed) + (_targetsEach - targets.size())); : targets.size() == 1 ? C.cRed : C.cDRed) + (_targetsEach - targets.size()));
if (targets.isEmpty()) if (targets.isEmpty())
{ {

View File

@ -27,6 +27,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.ChallengeSeperateRooms; import nautilus.game.arcade.game.games.mineware.ChallengeSeperateRooms;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeNameThatSound extends ChallengeSeperateRooms public class ChallengeNameThatSound extends ChallengeSeperateRooms
{ {
@ -38,7 +39,10 @@ public class ChallengeNameThatSound extends ChallengeSeperateRooms
public ChallengeNameThatSound(BawkBawkBattles host) public ChallengeNameThatSound(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Hit the creature that makes the noises"); super(
host,
ChallengeType.FirstComplete,
"Hit the creature that makes the noises.");
_sounds.put(EntityType.ZOMBIE, new Sound[] { _sounds.put(EntityType.ZOMBIE, new Sound[] {
Sound.ZOMBIE_DEATH, Sound.ZOMBIE_DEATH,
@ -245,11 +249,11 @@ public class ChallengeNameThatSound extends ChallengeSeperateRooms
if (_lastGuess.containsKey(player.getName()) && !UtilTime.elapsed(_lastGuess.get(player.getName()), 3000)) if (_lastGuess.containsKey(player.getName()) && !UtilTime.elapsed(_lastGuess.get(player.getName()), 3000))
{ {
player.sendMessage(F.main( player.sendMessage(F.main(
"Guess", "Guess",
"Wait " "Wait "
+ UtilTime.convertString((_lastGuess.get(player.getName()) + 3000) - System.currentTimeMillis(), 1, + UtilTime.convertString((_lastGuess.get(player.getName()) + 3000) - System.currentTimeMillis(), 1,
TimeUnit.SECONDS) TimeUnit.SECONDS)
+ " before next guess")); + " before next guess"));
return; return;
} }

View File

@ -5,17 +5,6 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Random; import java.util.Random;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.events.ChallengeEndEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect;
@ -37,6 +26,18 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
import nautilus.game.arcade.game.games.mineware.events.ChallengeEndEvent;
public class ChallengeSimonSays extends Challenge public class ChallengeSimonSays extends Challenge
{ {
private boolean _truthful = true; private boolean _truthful = true;
@ -56,8 +57,13 @@ public class ChallengeSimonSays extends Challenge
public ChallengeSimonSays(BawkBawkBattles host) public ChallengeSimonSays(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Simon Says", "Do everything Simon says", "Don't listen to anyone else!", super(
"first with 3 correct wins!"); host,
ChallengeType.FirstComplete,
"Simon Says",
"Do everything that Simon says.",
"Don't listen to anyone else!",
"First with 3 correct answers wins.");
} }
private enum simonTypes private enum simonTypes
@ -335,7 +341,7 @@ public class ChallengeSimonSays extends Challenge
_eventKey = true; _eventKey = true;
Bukkit.broadcastMessage( Bukkit.broadcastMessage(
C.cGreen + C.Bold + "Villager> " + C.cYellow + (_truthful == true ? "Simon says: " : "") + _currentType.getOrderName()); C.cGreen + C.Bold + "Villager> " + C.cYellow + (_truthful == true ? "Simon says: " : "") + _currentType.getOrderName());
startOrderTimer(); startOrderTimer();
} }
@ -436,7 +442,7 @@ public class ChallengeSimonSays extends Challenge
SetCompleted(player); SetCompleted(player);
} }
UtilFirework.launchFirework(player.getLocation(), FireworkEffect.builder().flicker(false).withColor(Color.GREEN).with(Type.STAR).trail(false) UtilFirework.launchFirework(player.getLocation(), FireworkEffect.builder().flicker(false).withColor(Color.GREEN).with(Type.STAR).trail(false)
.build(), null, 1); .build(), null, 1);
} }
private void playerScoreOnFail(Player player) private void playerScoreOnFail(Player player)

View File

@ -8,19 +8,24 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeSkyFall extends Challenge public class ChallengeSkyFall extends Challenge
{ {
public ChallengeSkyFall(BawkBawkBattles host) public ChallengeSkyFall(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Skyfall", "Land on the bottom pad, knock players around with snowballs!"); super(
host,
ChallengeType.FirstComplete,
"Skyfall",
"Land on the bottom pad, knock players around with snowballs!");
} }
@Override @Override

View File

@ -20,18 +20,23 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.ChallengeType;
public class ChallengeTameTheWolf extends Challenge public class ChallengeTameTheWolf extends Challenge
{ {
private ArrayList<Material> _bannedFood = new ArrayList<Material>( private ArrayList<Material> _bannedFood = new ArrayList<Material>(
Arrays.asList(Material.MUSHROOM_SOUP, Material.GOLDEN_APPLE)); Arrays.asList(Material.MUSHROOM_SOUP, Material.GOLDEN_APPLE));
private ArrayList<Material> currentFood = getAllFoods(); private ArrayList<Material> currentFood = getAllFoods();
private HashMap<String, Integer> _playerScore = new HashMap<String, Integer>(); private HashMap<String, Integer> _playerScore = new HashMap<String, Integer>();
private HashMap<Wolf, Material> _wolfs = new HashMap<Wolf, Material>(); private HashMap<Wolf, Material> _wolfs = new HashMap<Wolf, Material>();
public ChallengeTameTheWolf(BawkBawkBattles host) public ChallengeTameTheWolf(BawkBawkBattles host)
{ {
super(host, ChallengeType.FirstComplete, "Tame The Wolf", "Find the right item", "To tame the wolf!"); super(
host,
ChallengeType.FirstComplete,
"Tame The Wolf",
"Find the correct item to tame the wolf.");
} }
@Override @Override
@ -158,7 +163,7 @@ public class ChallengeTameTheWolf extends Challenge
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.SUCCESSFUL_HIT, 1f, 1f); event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.SUCCESSFUL_HIT, 1f, 1f);
increasePlayerScore(event.getPlayer()); increasePlayerScore(event.getPlayer());
displayCount(event.getPlayer(), wolf.getLocation().add(0, 1, 0), displayCount(event.getPlayer(), wolf.getLocation().add(0, 1, 0),
C.cGreen + _playerScore.get(event.getPlayer().getName())); C.cGreen + _playerScore.get(event.getPlayer().getName()));
wolf.setBreed(true); wolf.setBreed(true);
_wolfs.remove(wolf); _wolfs.remove(wolf);

View File

@ -11,11 +11,16 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Chicken; import org.bukkit.entity.Chicken;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv; 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.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.disguise.disguises.DisguiseChicken;
@ -70,52 +75,68 @@ public class ChickenAttack
public void start(Player player) public void start(Player player)
{ {
_host.getPlayersTeam().RemovePlayer(player); _host.getPlayersTeam().RemovePlayer(player);
_host.getChickenTeam().AddPlayer(player, true); _host.getChickenTeam().AddPlayer(player, true);
UtilInv.Clear(player); UtilInv.Clear(player);
_host.Manager.Clear(player); _host.Manager.Clear(player);
player.teleport(_center); player.teleport(_center);
UtilTextMiddle.display(C.cRed + "Chicken Attack", "You ran out of lives!", 5, 40, 5, player); UtilTextMiddle.display(C.cRed + "Chicken Attack!", "You ran out of lives.", 5, 40, 5, player);
player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1.0F, 1.0F); player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1.0F, 1.0F);
debugDeathTask(player); player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 1));
ensurePlayerKill(player);
System.out.println("Chicken attack triggered for " + player.getName() + "."); System.out.println("Chicken attack triggered for " + player.getName() + ".");
} }
private void debugDeathTask(Player player) private void ensurePlayerKill(Player player)
{ {
new BukkitRunnable() new BukkitRunnable()
{ {
@Override @Override
public void run() public void run()
{ {
if (_host.IsLive()) if (_host.IsLive() && _host.getChickenTeam().HasPlayer(player) && _host.IsAlive(player))
{
UtilPlayer.message(player, C.cWhite + C.Bold + "You have been moved to spectators.");
kill(player); kill(player);
}
else else
{
cancel(); cancel();
}
} }
}.runTaskLater(_plugin, 100L); }.runTaskLater(_plugin, 400L);
} }
private void kill(Player player) public void kill(Player player)
{ {
System.out.println("Killed: " + player.getName()); System.out.println("Killed: " + player.getName());
_host.SetPlayerState(player, PlayerState.OUT); _host.Manager.Clear(player);
DisguiseChicken disguise = new DisguiseChicken(player); new BukkitRunnable()
disguise.setBaby(); {
_host.Manager.GetDisguise().disguise(disguise, UtilServer.getPlayers()); @Override
public void run()
{
_host.SetPlayerState(player, PlayerState.OUT);
player.teleport(_host.GetSpectatorLocation()); DisguiseChicken disguise = new DisguiseChicken(player);
disguise.setBaby();
_host.Manager.GetDisguise().disguise(disguise, UtilServer.getPlayers());
player.setAllowFlight(true); player.teleport(_host.GetSpectatorLocation());
player.setFlying(true);
player.playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1.0F, 1.0F); player.setAllowFlight(true);
player.setFlying(true);
player.playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1.0F, 1.0F);
}
}.runTaskLater(_plugin, 1L);
} }
private void spawnChickens() private void spawnChickens()
@ -139,7 +160,10 @@ public class ChickenAttack
{ {
_chickens.add(chicken); _chickens.add(chicken);
// TODO: Make chickens attack player. UtilEnt.addLookAtPlayerAI(chicken, 2.0F);
if (UtilMath.random.nextDouble() * 100 < 10.0)
chicken.setBaby();
} }
public boolean isGroupMember(Chicken chicken) public boolean isGroupMember(Chicken chicken)
@ -156,7 +180,12 @@ public class ChickenAttack
_chickens.clear(); _chickens.clear();
} }
public ArrayList<Chicken> getChickens()
{
return _chickens;
}
public Location getPlatformCenter() public Location getPlatformCenter()
{ {
return _center; return _center;