Refactor color change, reverse tag and treasure digger challenge.
This commit is contained in:
parent
115508cf72
commit
1a51f51f60
@ -306,7 +306,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
|
||||
| SecurityException e)
|
||||
{
|
||||
System.out.println("There was a problem loading a new challenge.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -496,18 +495,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
|
||||
private void teleportPlayersToSpawnpoints()
|
||||
{
|
||||
// int i = 0;
|
||||
//
|
||||
// for (Player player : getChallengers())
|
||||
// {
|
||||
// player.teleport(spawnpoints.get(i++));
|
||||
//
|
||||
// if (i >= spawnpoints.size())
|
||||
// {
|
||||
// i = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
_playersTeam.SpawnTeleport(player);
|
||||
|
@ -7,14 +7,9 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
@ -156,61 +151,6 @@ public abstract class Challenge implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
protected void removePrimedTNTEntities()
|
||||
{
|
||||
for (Entity entity : Host.WorldData.World.getEntities())
|
||||
{
|
||||
if (entity instanceof TNTPrimed)
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeBoatEntities()
|
||||
{
|
||||
for (Entity entity : Host.WorldData.World.getEntities())
|
||||
{
|
||||
if (entity instanceof Boat)
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeFallingBlockEntities()
|
||||
{
|
||||
for (Entity entity : Host.WorldData.World.getEntities())
|
||||
{
|
||||
if (entity instanceof FallingBlock)
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeItemEntities()
|
||||
{
|
||||
for (Entity entity : Host.WorldData.World.getEntities())
|
||||
{
|
||||
if (entity instanceof Item)
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeArrowEntities()
|
||||
{
|
||||
for (Entity entity : Host.WorldData.World.getEntities())
|
||||
{
|
||||
if (entity instanceof Arrow)
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addEffect(PotionEffectType type, int amplifier)
|
||||
{
|
||||
addEffect(type, Integer.MAX_VALUE, amplifier);
|
||||
@ -224,6 +164,17 @@ public abstract class Challenge implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
protected void remove(Class<? extends Entity> entityClass)
|
||||
{
|
||||
for (Entity entity : Host.WorldData.World.getEntities())
|
||||
{
|
||||
if (entity.getClass().equals(entityClass))
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected Block generateGrass(Block block)
|
||||
{
|
||||
|
@ -13,6 +13,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
@ -124,8 +125,8 @@ public class ChallengeAnvilDance extends Challenge
|
||||
_landedAnvils.clear();
|
||||
_fallingAnvils.clear();
|
||||
|
||||
removeFallingBlockEntities();
|
||||
removeItemEntities();
|
||||
remove(FallingBlock.class);
|
||||
remove(Item.class);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
@ -118,7 +119,7 @@ public class ChallengeArrowRampage extends Challenge
|
||||
public void onEnd()
|
||||
{
|
||||
_arrows.clear();
|
||||
removeFallingBlockEntities();
|
||||
remove(FallingBlock.class);
|
||||
|
||||
// _antiHackFix.clear();
|
||||
Host.StrictAntiHack = true;
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -78,8 +79,8 @@ public class ChallengeBlockLobbers extends Challenge
|
||||
@Override
|
||||
public void onEnd()
|
||||
{
|
||||
removeFallingBlockEntities();
|
||||
removeItemEntities();
|
||||
remove(FallingBlock.class);
|
||||
remove(Item.class);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -89,7 +89,7 @@ public class ChallengeDeadlyTnt extends Challenge
|
||||
@Override
|
||||
public void onEnd()
|
||||
{
|
||||
removePrimedTNTEntities();
|
||||
remove(TNTPrimed.class);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
|
@ -108,7 +108,7 @@ public class ChallengeFastFood extends Challenge
|
||||
{
|
||||
_itemSeperator = 0;
|
||||
|
||||
removeItemEntities();
|
||||
remove(Item.class);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -194,8 +194,7 @@ public class ChallengeFishingDay extends Challenge
|
||||
Host.InventoryClick = false;
|
||||
Host.WorldWaterDamage = 0;
|
||||
|
||||
removePrimedTNTEntities();
|
||||
|
||||
remove(TNTPrimed.class);
|
||||
_fishing.clear();
|
||||
_explosives.clear();
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
|
||||
Host.DamagePvP = false;
|
||||
Host.DamagePvE = false;
|
||||
|
||||
removeArrowEntities();
|
||||
remove(Arrow.class);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -13,11 +13,12 @@ import org.bukkit.entity.Chicken;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
@ -33,9 +34,7 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
public class ChallengeShootChickens extends Challenge
|
||||
{
|
||||
private ArrayList<Chicken> _chickens = new ArrayList<Chicken>();
|
||||
private HashMap<String, Integer> _killedChickens = new HashMap<String, Integer>();
|
||||
private ArrayList<Projectile> _arrows = new ArrayList<Projectile>();
|
||||
|
||||
private HashMap<Player, Integer> _score = new HashMap<Player, Integer>();
|
||||
private HashMap<Player, Integer> _arrowsShot = new HashMap<Player, Integer>();
|
||||
|
||||
public ChallengeShootChickens(BawkBawkBattles host)
|
||||
@ -44,163 +43,30 @@ public class ChallengeShootChickens extends Challenge
|
||||
host,
|
||||
ChallengeType.FirstComplete,
|
||||
"Chicken Shooting",
|
||||
"Shoot 6 chickens.",
|
||||
"When a chicken lands, it dissapears.");
|
||||
"Shoot 6 chickens.");
|
||||
|
||||
Settings.setUseMapHeight();
|
||||
Settings.setLockInventory(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnd()
|
||||
public ArrayList<Location> createSpawns()
|
||||
{
|
||||
for (Chicken chicken : _chickens)
|
||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
||||
int size = getArenaSize() - 1;
|
||||
|
||||
for (int x = -(size); x <= size; x++)
|
||||
{
|
||||
chicken.remove();
|
||||
}
|
||||
|
||||
for (Projectile arrow : _arrows)
|
||||
{
|
||||
arrow.remove();
|
||||
}
|
||||
|
||||
Host.DamagePvE = false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onShoot(ProjectileLaunchEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Arrow)
|
||||
{
|
||||
_arrows.add(event.getEntity());
|
||||
|
||||
Arrow arrow = (Arrow) event.getEntity();
|
||||
Player player = (Player) arrow.getShooter();
|
||||
if (!Data.isDone(player))
|
||||
for (int z = -(size); z <= size; z++)
|
||||
{
|
||||
_arrowsShot.put(player, _arrowsShot.get(player) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(EntityDeathEvent event)
|
||||
{
|
||||
event.getDrops().clear();
|
||||
event.setDroppedExp(0);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Damage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetProjectile() == null)
|
||||
{
|
||||
event.SetCancelled("Not projectile damage");
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.GetDamagerPlayer(true);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
LivingEntity ent = event.GetDamageeEntity();
|
||||
|
||||
if (!_chickens.remove(ent))
|
||||
{
|
||||
event.SetCancelled("Not a chicken");
|
||||
return;
|
||||
}
|
||||
|
||||
event.AddMod("Ensure Death", null, 10, false);
|
||||
|
||||
int score = _killedChickens.get(player.getName()) + 1;
|
||||
|
||||
Location sloc = player.getEyeLocation();
|
||||
sloc.add(UtilAlg.getTrajectory(sloc, ent.getEyeLocation()).multiply(Math.min(7, ent.getLocation().distance(sloc))));
|
||||
|
||||
displayCount(player, sloc, (score >= 6 ? C.cDGreen : score >= 4 ? C.cGreen : score >= 2 ? C.cRed : C.cDRed) + score);
|
||||
|
||||
_killedChickens.put(player.getName(), score);
|
||||
|
||||
if (score == 6)
|
||||
{
|
||||
setCompleted(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHalfSecond(UpdateEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
UpdateType speed;
|
||||
if (getCurrentyAlive(false).size() >= 40)
|
||||
{
|
||||
speed = UpdateType.FASTEST;
|
||||
}
|
||||
else if (getCurrentyAlive(false).size() >= 20)
|
||||
{
|
||||
speed = UpdateType.FASTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
speed = UpdateType.FAST;
|
||||
}
|
||||
|
||||
if (event.getType() != speed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<Chicken> itel = _chickens.iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Chicken chicken = itel.next();
|
||||
|
||||
if (chicken.isOnGround() || !chicken.isValid())
|
||||
{
|
||||
chicken.remove();
|
||||
itel.remove();
|
||||
if (x % 2 == 0 && z % 2 == 0)
|
||||
{
|
||||
spawns.add(getCenter().add(x + 0.5, 1.1, z + 0.5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_chickens.size() < 11 + (getChallengers().size() * 2))
|
||||
{
|
||||
Location loc = getCenter().clone().add(UtilMath.r(getArenaSize() * 2) - (getArenaSize()), 15,
|
||||
UtilMath.r(getArenaSize() * 2) - (getArenaSize()));
|
||||
|
||||
Host.CreatureAllowOverride = true;
|
||||
Chicken chicken = (Chicken) loc.getWorld().spawnEntity(loc, EntityType.CHICKEN);
|
||||
Host.CreatureAllowOverride = false;
|
||||
chicken.setMaxHealth(0.1);
|
||||
chicken.setHealth(0.1);
|
||||
|
||||
_chickens.add(chicken);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
setBorder(-10, 10, 0, 10, -10, 10);
|
||||
|
||||
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(9, new ItemStack(Material.ARROW));
|
||||
|
||||
_killedChickens.put(player.getName(), 0);
|
||||
_arrowsShot.put(player, 0);
|
||||
}
|
||||
|
||||
Host.DamagePvE = true;
|
||||
return spawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -212,62 +78,229 @@ public class ChallengeShootChickens extends Challenge
|
||||
{
|
||||
for (int y = 0; y <= 1; y++)
|
||||
{
|
||||
Block b = getCenter().getBlock().getRelative(x, y, z);
|
||||
Block block = getCenter().getBlock().getRelative(x, y, z);
|
||||
|
||||
if (y == 0)
|
||||
{
|
||||
b.setType(Material.GRASS);
|
||||
block.setType(Material.GRASS);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
|
||||
{
|
||||
b.setType(Material.FENCE);
|
||||
block.setType(Material.FENCE);
|
||||
}
|
||||
else if (UtilMath.r(4) == 0)
|
||||
else
|
||||
{
|
||||
if (UtilMath.r(8) == 0)
|
||||
{
|
||||
b.setType(UtilMath.random.nextBoolean() ? Material.YELLOW_FLOWER : Material.RED_ROSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
b.setType(Material.LONG_GRASS);
|
||||
b.setData((byte) 1);
|
||||
}
|
||||
generateGrass(block);
|
||||
}
|
||||
}
|
||||
|
||||
if (b.getType() != Material.AIR)
|
||||
{
|
||||
addBlock(b);
|
||||
}
|
||||
addBlock(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Location> createSpawns()
|
||||
public void onStart()
|
||||
{
|
||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
||||
setBorder(-10, 10, 0, 10, -10, 10);
|
||||
|
||||
for (int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++)
|
||||
Host.DamagePvE = true;
|
||||
|
||||
ItemStack bow = new ItemBuilder(Material.BOW).setUnbreakable(true).addEnchantment(Enchantment.ARROW_INFINITE, 1).build();
|
||||
ItemStack arrow = new ItemStack(Material.ARROW);
|
||||
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
for (int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
|
||||
{
|
||||
if (x % 2 == 0 && z % 2 == 0)
|
||||
{
|
||||
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
|
||||
}
|
||||
}
|
||||
// It's better to add the items without setItem() method, to minimize for-loops.
|
||||
|
||||
PlayerInventory inv = player.getInventory();
|
||||
inv.setItem(Settings.getLockedSlot(), bow);
|
||||
inv.setItem(31, arrow);
|
||||
|
||||
_score.put(player, 0);
|
||||
_arrowsShot.put(player, 0);
|
||||
}
|
||||
|
||||
return spawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnd()
|
||||
{
|
||||
Host.DamagePvE = false;
|
||||
|
||||
for (Chicken chicken : _chickens)
|
||||
{
|
||||
chicken.remove();
|
||||
}
|
||||
|
||||
remove(Arrow.class);
|
||||
|
||||
_chickens.clear();
|
||||
_score.clear();
|
||||
_arrowsShot.clear();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof Arrow))
|
||||
return;
|
||||
|
||||
Arrow arrow = (Arrow) event.getEntity();
|
||||
Player player = (Player) arrow.getShooter();
|
||||
|
||||
if (!isPlayerValid(player))
|
||||
return;
|
||||
|
||||
_arrowsShot.put(player, _arrowsShot.get(player) + 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
event.getDrops().clear();
|
||||
event.setDroppedExp(0);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCustomDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (event.GetProjectile() == null)
|
||||
{
|
||||
event.SetCancelled("Not projectile damage");
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.GetDamagerPlayer(true);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (!isPlayerValid(player))
|
||||
return;
|
||||
|
||||
LivingEntity entity = event.GetDamageeEntity();
|
||||
|
||||
if (!_chickens.remove(entity))
|
||||
{
|
||||
event.SetCancelled("Not a chicken");
|
||||
return;
|
||||
}
|
||||
|
||||
event.AddMod("Ensure Death", null, 10, false);
|
||||
|
||||
int score = showAndIncrementScore(player, entity);
|
||||
|
||||
if (score == 6)
|
||||
{
|
||||
setCompleted(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
UpdateType speed;
|
||||
int alive = getCurrentyAlive(false).size();
|
||||
|
||||
if (alive >= 40)
|
||||
speed = UpdateType.FASTEST;
|
||||
else if (alive >= 20)
|
||||
speed = UpdateType.FASTER;
|
||||
else
|
||||
speed = UpdateType.FAST;
|
||||
|
||||
if (event.getType() != speed)
|
||||
return;
|
||||
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
removeChickensOnGround();
|
||||
spawnChicken();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (_score.containsKey(player))
|
||||
{
|
||||
_score.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<Player, Integer> getArrowsShot()
|
||||
{
|
||||
return _arrowsShot;
|
||||
}
|
||||
|
||||
private int showAndIncrementScore(Player player, LivingEntity entity)
|
||||
{
|
||||
int score = _score.get(player) + 1;
|
||||
|
||||
Location location = player.getEyeLocation();
|
||||
location.add(UtilAlg.getTrajectory(location, entity.getEyeLocation()).multiply(Math.min(7, entity.getLocation().distance(location))));
|
||||
|
||||
displayCount(player, location, (score >= 6 ? C.cDGreen : score >= 4 ? C.cGreen : score >= 2 ? C.cRed : C.cDRed) + score);
|
||||
|
||||
_score.put(player, score);
|
||||
return score;
|
||||
}
|
||||
|
||||
private void removeChickensOnGround()
|
||||
{
|
||||
Iterator<Chicken> iterator = _chickens.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Chicken chicken = iterator.next();
|
||||
|
||||
if (chicken.isOnGround() || !chicken.isValid())
|
||||
{
|
||||
chicken.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnChicken()
|
||||
{
|
||||
if (_chickens.size() < 11 + (getChallengers().size() * 2))
|
||||
{
|
||||
Location spawn = getRandomLocation();
|
||||
|
||||
Host.CreatureAllow = true;
|
||||
Chicken chicken = (Chicken) spawn.getWorld().spawnEntity(spawn, EntityType.CHICKEN);
|
||||
Host.CreatureAllow = false;
|
||||
|
||||
chicken.setMaxHealth(0.1);
|
||||
chicken.setHealth(0.1);
|
||||
|
||||
_chickens.add(chicken);
|
||||
}
|
||||
}
|
||||
|
||||
private Location getRandomLocation()
|
||||
{
|
||||
int random = UtilMath.r(getArenaSize() * 2) - (getArenaSize());
|
||||
|
||||
return getCenter().add(random, 15, random);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import java.util.ArrayList;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
|
||||
@ -14,8 +13,6 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
|
||||
public class ChallengeSmashOff extends Challenge
|
||||
{
|
||||
private ArrayList<Location> _spawns = new ArrayList<Location>();
|
||||
|
||||
public ChallengeSmashOff(BawkBawkBattles host)
|
||||
{
|
||||
super(
|
||||
@ -31,26 +28,21 @@ public class ChallengeSmashOff extends Challenge
|
||||
@Override
|
||||
public ArrayList<Location> createSpawns()
|
||||
{
|
||||
return _spawns;
|
||||
}
|
||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
||||
int amount = (int) Math.ceil(Math.sqrt(getChallengers().size()));
|
||||
|
||||
@Override
|
||||
public void onEnd()
|
||||
{
|
||||
Host.DamagePvP = false;
|
||||
|
||||
for (Player player : getChallengers())
|
||||
for (int pX = 0; pX < amount; pX++)
|
||||
{
|
||||
player.setHealth(player.getMaxHealth());
|
||||
for (int pZ = 0; pZ < amount; pZ++)
|
||||
{
|
||||
spawns.add(getCenter().add((pX * 4) + 1.0, 1.1, (pZ * 4) + 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
return spawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
Host.DamagePvP = true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void createMap()
|
||||
{
|
||||
@ -61,17 +53,15 @@ public class ChallengeSmashOff extends Challenge
|
||||
{
|
||||
for (int pZ = 0; pZ < amount; pZ++)
|
||||
{
|
||||
_spawns.add(getCenter().add((pX * 4) + 1.5, 1.1, (pZ * 4) + 1.5));
|
||||
|
||||
for (int x = pX * 4; x < (pX * 4) + 2; x++)
|
||||
{
|
||||
for (int z = pZ * 4; z < (pZ * 4) + 2; z++)
|
||||
{
|
||||
Block b = getCenter().getBlock().getRelative(x, 0, z);
|
||||
b.setType(Material.STAINED_CLAY);
|
||||
b.setData((byte) a);
|
||||
Block block = getCenter().getBlock().getRelative(x, 0, z);
|
||||
block.setType(Material.STAINED_CLAY);
|
||||
block.setData((byte) a);
|
||||
|
||||
addBlock(b);
|
||||
addBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,4 +73,15 @@ public class ChallengeSmashOff extends Challenge
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
Host.DamagePvP = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnd()
|
||||
{
|
||||
Host.DamagePvP = false;
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public class ChallengeTreasureDigger extends Challenge
|
||||
Host.WorldBlockBurn = true;
|
||||
Host.WorldFireSpread = true;
|
||||
|
||||
for (Player players : Host.GetPlayers(true))
|
||||
for (Player players : getChallengers())
|
||||
{
|
||||
ItemStack shovel = new ItemStack(Material.STONE_SPADE);
|
||||
players.getInventory().setItem(4, shovel);
|
||||
@ -228,12 +228,18 @@ public class ChallengeTreasureDigger extends Challenge
|
||||
@EventHandler
|
||||
public void onItemSpawn(ItemSpawnEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof FallingBlock)
|
||||
{
|
||||
FallingBlock block = (FallingBlock) event.getEntity();
|
||||
@ -244,14 +250,20 @@ public class ChallengeTreasureDigger extends Challenge
|
||||
@EventHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof Player && event.getDamager() instanceof Player)
|
||||
{
|
||||
if (!isPlayerValid((Player) event.getEntity()))
|
||||
return;
|
||||
|
||||
if (!isPlayerValid((Player) event.getDamager()))
|
||||
return;
|
||||
|
||||
Player damager = (Player) event.getDamager();
|
||||
ItemStack item = damager.getItemInHand();
|
||||
|
||||
if (Data.isDone(damager))
|
||||
return;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
if (!item.getType().name().toLowerCase().contains("sword"))
|
||||
@ -284,8 +296,7 @@ public class ChallengeTreasureDigger extends Challenge
|
||||
Block east = block.getRelative(BlockFace.EAST);
|
||||
Block west = block.getRelative(BlockFace.WEST);
|
||||
|
||||
return north.getType() == Material.CHEST || south.getType() == Material.CHEST || east.getType() == Material.CHEST
|
||||
|| west.getType() == Material.CHEST;
|
||||
return north.getType() == Material.CHEST || south.getType() == Material.CHEST || east.getType() == Material.CHEST || west.getType() == Material.CHEST;
|
||||
}
|
||||
|
||||
private void fillChestWithLoot(Chest chest)
|
||||
|
@ -181,8 +181,8 @@ public class ChallengeWaterHorror extends Challenge
|
||||
{
|
||||
Host.getArcadeManager().GetExplosion().SetLiquidDamage(true);
|
||||
|
||||
removeBoatEntities();
|
||||
removePrimedTNTEntities();
|
||||
remove(Boat.class);
|
||||
remove(TNTPrimed.class);
|
||||
|
||||
_boats.clear();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user