Challenge refactoring, bug fixes, add additional helper methods.

This commit is contained in:
Thanos paravantis 2016-03-06 00:59:13 +02:00
parent 0f58c1378c
commit c2d5699aa8
18 changed files with 311 additions and 232 deletions

View File

@ -40,6 +40,8 @@ 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 com.google.common.collect.Lists;
import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClient;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
@ -131,25 +133,22 @@ public class BawkBawkBattles extends TeamGame implements IThrown
private BawkBawkBattlesSettings _settings = new BawkBawkBattlesSettings(); private BawkBawkBattlesSettings _settings = new BawkBawkBattlesSettings();
private ChallengeList _list = new ChallengeList(); private ChallengeList _list = new ChallengeList();
private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>(); private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>();
private ArrayList<Player> _winners = new ArrayList<Player>();
private int _livesAmount = 2;
private String _restrictCommand = "restrict";
private String _skipCommand = "skip";
private GameTeam _playersTeam; private GameTeam _playersTeam;
private GameTeam _chickenTeam; private GameTeam _chickenTeam;
private Challenge _challenge;
private long _challengeTime;
private ArrayList<Block> _lastOrderBlocks;
private ArrayList<Player> _places = new ArrayList<Player>();
private DeathEffect _deathEffect = new DeathEffect(this); private DeathEffect _deathEffect = new DeathEffect(this);
private ChickenAttack _chickenAttack; private ChickenAttack _chickenAttack;
private Location _chickenAttackCenter; private Location _chickenAttackCenter;
private Challenge _challenge;
private ArrayList<Block> _lastChallengeBlocks;
private long _challengeTime;
private String _restrictCommand = "restrict";
private String _skipCommand = "skip";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public BawkBawkBattles(ArcadeManager manager) public BawkBawkBattles(ArcadeManager manager)
{ {
@ -163,6 +162,8 @@ public class BawkBawkBattles extends TeamGame implements IThrown
"Last player with lives wins!" "Last player with lives wins!"
}); });
_settings.setMaxLives(2);
DamageSelf = false; DamageSelf = false;
DamageTeamSelf = true; DamageTeamSelf = true;
DamageTeamOther = false; DamageTeamOther = false;
@ -212,10 +213,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
ChallengeDogsVersusCats.class, // Playable - Refactored ChallengeDogsVersusCats.class, // Playable - Refactored
ChallengeDragonEgg.class, // Playable - Refactored ChallengeDragonEgg.class, // Playable - Refactored
ChallengeFallingBlocks.class, // Playable - Refactored ChallengeFallingBlocks.class, // Playable - Refactored
ChallengeFastFood.class, // Playable ChallengeFastFood.class, // Playable - Refactored
ChallengeFishingDay.class, // Playable ChallengeFishingDay.class, // Playable - Refactored
ChallengeWaterHorror.class, // Playable ChallengeWaterHorror.class, // TNT not spawning - Refactored
ChallengeInfestation.class, // Playable ChallengeInfestation.class, // Playable - Refactored
ChallengeKangarooJump.class, // Playable ChallengeKangarooJump.class, // Playable
ChallengeKingOfTheHill.class, // Playable- Improve map. ChallengeKingOfTheHill.class, // Playable- Improve map.
ChallengeLavaRun.class, // Playable ChallengeLavaRun.class, // Playable
@ -448,7 +449,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
{ {
_settings.setCrumbling(false); _settings.setCrumbling(false);
for (Block block : _lastOrderBlocks) for (Block block : _lastChallengeBlocks)
{ {
if (block.getState() instanceof InventoryHolder) if (block.getState() instanceof InventoryHolder)
{ {
@ -555,12 +556,12 @@ public class BawkBawkBattles extends TeamGame implements IThrown
private boolean justStartedCrumbling() private boolean justStartedCrumbling()
{ {
return !_settings.isCrumbling() && _challenge.getData().getLostPlayers().size() >= _challenge.getData().getCurrentPlaying().size() / 2; return !_settings.isCrumbling() && _challenge.getData().getLostPlayers().size() >= getChallengers().size() / 2;
} }
private boolean canEndChallengeFromCrumble() private boolean canEndChallengeFromCrumble()
{ {
return (_challenge.getData().getCurrentPlaying().size() - _challenge.getData().getLostPlayers().size()) <= 1 && _settings.isCrumbling(); return (getChallengers().size() - _challenge.getData().getLostPlayers().size()) <= 1 && _settings.isCrumbling();
} }
private void updateChallengeTimer() private void updateChallengeTimer()
@ -624,9 +625,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
private void sortLastChallengeBlocks() private void sortLastChallengeBlocks()
{ {
_lastOrderBlocks = new ArrayList<Block>(_challenge.getData().getModifiedBlocks()); _lastChallengeBlocks = new ArrayList<Block>(_challenge.getData().getModifiedBlocks());
Collections.sort(_lastOrderBlocks, new Comparator<Block>() Collections.sort(_lastChallengeBlocks, new Comparator<Block>()
{ {
@Override @Override
public int compare(Block o1, Block o2) public int compare(Block o1, Block o2)
@ -765,7 +766,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
int looped = 0; int looped = 0;
List<String> messages = new ArrayList<>(Arrays.asList(challenge.getDescription())); List<String> messages = Lists.newArrayList(challenge.getDescription());
String type = challenge.getType().toString(); String type = challenge.getType().toString();
@ -780,8 +781,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
UtilPlayer.message(player, ""); UtilPlayer.message(player, "");
for (String currentMessage : messages) for (String currentMessage : messages)
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, "");
} }
@ -796,12 +798,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
for (Player player : GetPlayers(true)) // Show to alive players only. for (Player player : GetPlayers(true)) // Show to alive players only.
UtilTextMiddle.display(challenge.getName(), message, 0, 60, 20, player); UtilTextMiddle.display(challenge.getName(), message, 0, 60, 20, player);
if (looped == messages.size() - 1)
{
prepareCountdown();
break;
}
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
player.playSound(player.getLocation(), Sound.CHICKEN_IDLE, 1.5F, 1.0F); player.playSound(player.getLocation(), Sound.CHICKEN_IDLE, 1.5F, 1.0F);
@ -816,6 +812,12 @@ public class BawkBawkBattles extends TeamGame implements IThrown
} }
looped++; looped++;
if (looped >= messages.size())
{
prepareCountdown();
break;
}
} }
} }
@ -907,6 +909,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onChallengeDeath(PlayerDeathEvent event) public void onChallengeDeath(PlayerDeathEvent event)
{ {
if (!IsLive())
return;
if (_challenge == null) if (_challenge == null)
return; return;
@ -919,9 +924,30 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_challenge.getData().addLostPlayer(player); _challenge.getData().addLostPlayer(player);
handleDeath(player); handleDeath(player);
_deathEffect.playDeath(player, death); _deathEffect.playDeath(player, death);
} }
@EventHandler
public void onPlayerApproachVoid(PlayerMoveEvent event)
{
if (!IsLive())
return;
if (_challenge == null)
return;
Player player = event.getPlayer();
if (_challenge.getData().isDone(player))
{
if (event.getTo().getY() <= 0)
{
player.teleport(_challenge.getCenter().add(0, 1, 0));
}
}
}
@EventHandler @EventHandler
public void onConditionApply(ConditionApplyEvent event) public void onConditionApply(ConditionApplyEvent event)
{ {
@ -961,7 +987,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
if (lives <= 0) if (lives <= 0)
{ {
if (alive <= 3) if (alive <= 3)
_places.add(player); _winners.add(player);
} }
if (lives <= 0 && alive > 2) if (lives <= 0 && alive > 2)
@ -978,6 +1004,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
public int looseLife(Player player) public int looseLife(Player player)
{ {
int lives = lives(player); int lives = lives(player);
lives -= 1; lives -= 1;
if (lives >= 0) if (lives >= 0)
@ -1152,11 +1179,12 @@ public class BawkBawkBattles extends TeamGame implements IThrown
if (_places.contains(player)) if (_places.contains(player))
_places.remove(player); _places.remove(player);
// TODO: Check if needed
if (_challenge != null) if (_challenge != null)
{ {
if (_challenge.getData().getCurrentPlaying() != null) if (getChallengers() != null)
{ {
_challenge.getData().removeCurrentPlaying(player); getChallengers().remove(player);
} }
} }
} }
@ -1318,7 +1346,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_challenge = selectChallenge(); _challenge = selectChallenge();
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
_lives.put(player, _livesAmount); _lives.put(player, _settings.getMaxLives());
_challenge.createMap(); _challenge.createMap();
@ -1450,20 +1478,20 @@ public class BawkBawkBattles extends TeamGame implements IThrown
{ {
Collections.reverse(_places); Collections.reverse(_places);
if (!_places.contains(super.GetPlayers(true).get(0))) if (!_winners.contains(super.GetPlayers(true).get(0)))
_places.add(0, super.GetPlayers(true).get(0)); _winners.add(0, super.GetPlayers(true).get(0));
if (_places.size() >= 1) if (_winners.size() >= 1)
{ {
AddGems(_places.get(0), 40, "First Place", false, false); AddGems(_winners.get(0), 40, "First Place", false, false);
if (_places.size() >= 2) if (_winners.size() >= 2)
{ {
AddGems(_places.get(1), 30, "Second Place", false, false); AddGems(_winners.get(1), 30, "Second Place", false, false);
if (_places.size() >= 3) if (_places.size() >= 3)
{ {
AddGems(_places.get(2), 20, "Third Place", false, false); AddGems(_winners.get(2), 20, "Third Place", false, false);
} }
} }
} }
@ -1472,16 +1500,11 @@ public class BawkBawkBattles extends TeamGame implements IThrown
AddGems(player, 10, "Participation", false, false); AddGems(player, 10, "Participation", false, false);
SetCustomWinLine("You have defeated Bawk Bawk!"); SetCustomWinLine("You have defeated Bawk Bawk!");
AnnounceEnd(_places); AnnounceEnd(_winners);
SetState(GameState.End); SetState(GameState.End);
} }
} }
public int getMaxLives()
{
return _livesAmount;
}
public GameTeam getPlayersTeam() public GameTeam getPlayersTeam()
{ {
return _playersTeam; return _playersTeam;
@ -1505,7 +1528,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
@Override @Override
public ArrayList<Player> getWinners() public ArrayList<Player> getWinners()
{ {
return _places; return _winners;
} }
public HashMap<Player, Integer> getLives() public HashMap<Player, Integer> getLives()

View File

@ -2,12 +2,23 @@ package nautilus.game.arcade.game.games.mineware;
public class BawkBawkBattlesSettings public class BawkBawkBattlesSettings
{ {
private int _maxLives = 5;
private boolean _crumbling = false; private boolean _crumbling = false;
private boolean _waiting = true; private boolean _waiting = true;
private boolean _messagesSent = false; private boolean _messagesSent = false;
private boolean _sendingMessages = false; private boolean _sendingMessages = false;
private boolean _challengeStarted = false; private boolean _challengeStarted = false;
public void setMaxLives(int maxLives)
{
_maxLives = maxLives;
}
public int getMaxLives()
{
return _maxLives;
}
public void setCrumbling(boolean flag) public void setCrumbling(boolean flag)
{ {
_crumbling = flag; _crumbling = flag;

View File

@ -1,20 +1,23 @@
package nautilus.game.arcade.game.games.mineware.challenge; package nautilus.game.arcade.game.games.mineware.challenge;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.HashSet;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock; import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Item; 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.entity.TNTPrimed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -26,6 +29,7 @@ import mineplex.core.common.util.MapUtil;
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.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.hologram.Hologram; import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.Hologram.HologramTarget; import mineplex.core.hologram.Hologram.HologramTarget;
@ -99,7 +103,7 @@ public abstract class Challenge implements Listener
protected void addItem(ItemStack... items) protected void addItem(ItemStack... items)
{ {
for (Player player : Data.getCurrentPlaying()) for (Player player : getChallengers())
{ {
for (ItemStack item : items) for (ItemStack item : items)
{ {
@ -108,9 +112,17 @@ public abstract class Challenge implements Listener
} }
} }
protected void setItem(int slot, ItemStack item)
{
for (Player player : getChallengers())
{
player.getInventory().setItem(slot, item);
}
}
protected void removeItem(Material type, byte data) protected void removeItem(Material type, byte data)
{ {
for (Player player : Data.getCurrentPlaying()) for (Player player : getChallengers())
{ {
UtilInv.removeAll(player, type, data); UtilInv.removeAll(player, type, data);
} }
@ -118,12 +130,34 @@ public abstract class Challenge implements Listener
protected void addEffect(PotionEffectType type, int duration, int amplifier) protected void addEffect(PotionEffectType type, int duration, int amplifier)
{ {
for (Player player : Data.getCurrentPlaying()) for (Player player : getChallengers())
{ {
player.addPotionEffect(new PotionEffect(type, duration, amplifier)); player.addPotionEffect(new PotionEffect(type, duration, amplifier));
} }
} }
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() protected void removeFallingBlockEntities()
{ {
for (Entity entity : Host.WorldData.World.getEntities()) for (Entity entity : Host.WorldData.World.getEntities())
@ -153,7 +187,7 @@ public abstract class Challenge implements Listener
protected void removeEffect(PotionEffectType type) protected void removeEffect(PotionEffectType type)
{ {
for (Player player : Data.getCurrentPlaying()) for (Player player : getChallengers())
{ {
player.removePotionEffect(type); player.removePotionEffect(type);
} }
@ -171,11 +205,18 @@ public abstract class Challenge implements Listener
public void start() public void start()
{ {
Data.setCurrentPlaying(Host.getChallengers());
Data.resetCompletedAndLost(); Data.resetCompletedAndLost();
Settings.setStartTime(System.currentTimeMillis()); Settings.setStartTime(System.currentTimeMillis());
Settings.setMaxCompletedCount((int) Math.ceil(Data.getCurrentPlaying().size() / 2D)); Settings.setMaxCompletedCount((int) Math.ceil(getChallengers().size() / 2D));
if (Settings.isInventoryLocked())
{
for (Player player : getChallengers())
{
player.getInventory().setHeldItemSlot(Settings.getLockedSlot());
}
}
onStart(); onStart();
} }
@ -236,6 +277,7 @@ public abstract class Challenge implements Listener
UtilPlayer.message(player, C.cGreen + C.Bold + "You completed the task!"); UtilPlayer.message(player, C.cGreen + C.Bold + "You completed the task!");
UtilPlayer.message(player, ""); UtilPlayer.message(player, "");
UtilInv.Clear(player);
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2.0F, 1.0F); player.playSound(player.getLocation(), Sound.LEVEL_UP, 2.0F, 1.0F);
} }
@ -320,6 +362,43 @@ public abstract class Challenge implements Listener
return Host.isInsideMap(player.getLocation()); return Host.isInsideMap(player.getLocation());
} }
@EventHandler
public void onChallengeStartingSoonUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
if (!Host.IsLive())
return;
if (Host.GetPlayers(true).size() <= 2)
return;
HashSet<Player> players = new HashSet<Player>();
players.addAll(Data.getCompletedPlayers());
players.addAll(Data.getLostPlayers());
for (Player player : players)
{
UtilTextBottom.display(C.Bold + "Next challenge will begin shortly.", player);
}
}
@EventHandler
public void onPlayerItemHeld(PlayerItemHeldEvent event)
{
if (!isChallengeValid())
return;
Player player = event.getPlayer();
if (!isPlayerValid(player))
return;
if (Settings.isInventoryLocked())
event.setCancelled(true);
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@EventHandler @EventHandler
public void onMapCrumble(UpdateEvent event) public void onMapCrumble(UpdateEvent event)
@ -400,7 +479,7 @@ public abstract class Challenge implements Listener
{ {
ArrayList<Player> currentlyAlive = new ArrayList<Player>(); ArrayList<Player> currentlyAlive = new ArrayList<Player>();
for (Player player : Data.getCurrentPlaying()) for (Player player : getChallengers())
{ {
if (Data.isLost(player)) if (Data.isLost(player))
continue; continue;

View File

@ -12,7 +12,6 @@ public class ChallengeData
private HashSet<Block> _modifiedBlocks = new HashSet<Block>(); private HashSet<Block> _modifiedBlocks = new HashSet<Block>();
private HashSet<Player> _completed = new HashSet<Player>(); private HashSet<Player> _completed = new HashSet<Player>();
private HashSet<Player> _lost = new HashSet<Player>(); private HashSet<Player> _lost = new HashSet<Player>();
private HashSet<Player> _playing = new HashSet<Player>();
public void resetCompletedAndLost() public void resetCompletedAndLost()
{ {
@ -30,9 +29,6 @@ public class ChallengeData
if (_invisible.contains(player)) if (_invisible.contains(player))
_invisible.remove(player); _invisible.remove(player);
if (_playing.contains(player))
_playing.remove(player);
} }
public boolean isCompleted(Player player) public boolean isCompleted(Player player)
@ -99,24 +95,4 @@ public class ChallengeData
{ {
return _lost; return _lost;
} }
public void setCurrentPlaying(Collection<Player> players)
{
_playing.addAll(players);
}
public void addCurrentPlaying(Player player)
{
_playing.add(player);
}
public void removeCurrentPlaying(Player player)
{
_playing.remove(player);
}
public HashSet<Player> getCurrentPlaying()
{
return _playing;
}
} }

View File

@ -9,6 +9,7 @@ public class ChallengeList
private ArrayList<Class<? extends Challenge>> _wrapper = new ArrayList<Class<? extends Challenge>>(); private ArrayList<Class<? extends Challenge>> _wrapper = new ArrayList<Class<? extends Challenge>>();
private ArrayList<Class<? extends Challenge>> _wrapperCopy = new ArrayList<Class<? extends Challenge>>(); private ArrayList<Class<? extends Challenge>> _wrapperCopy = new ArrayList<Class<? extends Challenge>>();
@SuppressWarnings("unchecked")
public void add(Class<? extends Challenge>... challenges) public void add(Class<? extends Challenge>... challenges)
{ {
for (Class<? extends Challenge> challenge : challenges) for (Class<? extends Challenge> challenge : challenges)

View File

@ -14,6 +14,7 @@ public class ChallengeSettings
private boolean _useMapHeight; private boolean _useMapHeight;
private boolean _lockInventory; private boolean _lockInventory;
private int _lockedSlot = 0;
private boolean _teamBased; private boolean _teamBased;
private boolean _canCrumble; private boolean _canCrumble;
@ -103,9 +104,10 @@ public class ChallengeSettings
return _useMapHeight; return _useMapHeight;
} }
public void setLockInventory() public void setLockInventory(int lockedSlot)
{ {
_lockInventory = true; _lockInventory = true;
_lockedSlot = lockedSlot;
} }
public boolean isInventoryLocked() public boolean isInventoryLocked()
@ -113,6 +115,11 @@ public class ChallengeSettings
return _lockInventory; return _lockInventory;
} }
public int getLockedSlot()
{
return _lockedSlot;
}
public void setTeamBased() public void setTeamBased()
{ {
_teamBased = true; _teamBased = true;

View File

@ -47,7 +47,7 @@ public class InfestationZombie
public Location getLocation() public Location getLocation()
{ {
return _wrapper.getLocation(); return _wrapper.getLocation().clone();
} }
public ChallengeInfestation getChallenge() public ChallengeInfestation getChallenge()

View File

@ -59,7 +59,7 @@ public class ChallengeArrowRampage extends Challenge
{ {
if (x % 2 == 0 && z % 2 == 0) if (x % 2 == 0 && z % 2 == 0)
{ {
spawns.add(getCenter().clone().add(x + 0.5, 4.1, z + 0.5)); spawns.add(getCenter().add(x + 0.5, 4.1, z + 0.5));
} }
} }
} }

View File

@ -91,7 +91,7 @@ public class ChallengeBlockLobbers extends Challenge
if (event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.FAST)
return; return;
for (Player player : Data.getCurrentPlaying()) for (Player player : getChallengers())
{ {
Material material = UtilMath.randomElement(_types); Material material = UtilMath.randomElement(_types);

View File

@ -90,7 +90,7 @@ public class ChallengeBouncingBlock extends Challenge
{ {
addEffect(PotionEffectType.JUMP, 6); addEffect(PotionEffectType.JUMP, 6);
for (Player player : Data.getCurrentPlaying()) for (Player player : getChallengers())
{ {
_score.put(player, 0); _score.put(player, 0);
} }
@ -152,7 +152,7 @@ public class ChallengeBouncingBlock extends Challenge
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
return; return;
for (Player player : Data.getCurrentPlaying()) for (Player player : getChallengers())
{ {
if (Data.isDone(player)) if (Data.isDone(player))
continue; continue;
@ -204,7 +204,7 @@ public class ChallengeBouncingBlock extends Challenge
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void spawnStartingWool() private void spawnStartingWool()
{ {
whileLoop: while (_blocks.size() <= Math.ceil(Data.getCurrentPlaying().size() / 2) + 1) whileLoop: while (_blocks.size() <= Math.ceil(getChallengers().size() / 2) + 1)
{ {
for (int x = -getArenaSize(); x <= getArenaSize(); x++) for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{ {

View File

@ -61,7 +61,7 @@ public class ChallengeCloudFall extends Challenge
if (goodSpawn) if (goodSpawn)
{ {
spawns.add(getCenter().clone().add(x + 0.5, y + 1.1, z + 0.5)); spawns.add(getCenter().add(x + 0.5, y + 1.1, z + 0.5));
} }
} }
} }

View File

@ -45,7 +45,7 @@ public class ChallengeDiamondSeeker extends Challenge
{ {
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().add(x + 0.5, 2.1, z + 0.5));
} }
} }
} }

View File

@ -57,6 +57,7 @@ public class ChallengeDogsVersusCats extends Challenge
Settings.setUseMapHeight(); Settings.setUseMapHeight();
Settings.setTeamBased(); Settings.setTeamBased();
Settings.setDuration(75000); Settings.setDuration(75000);
Settings.setLockInventory(4);
_catTeam = new ChallengeTeam("Cats"); _catTeam = new ChallengeTeam("Cats");
_dogTeam = new ChallengeTeam("Dogs"); _dogTeam = new ChallengeTeam("Dogs");
@ -140,8 +141,7 @@ public class ChallengeDogsVersusCats extends Challenge
DisguiseWolf Ddog = new DisguiseWolf(player); DisguiseWolf Ddog = new DisguiseWolf(player);
Host.getArcadeManager().GetDisguise().disguise(Ddog); Host.getArcadeManager().GetDisguise().disguise(Ddog);
player.getInventory() player.getInventory().setItem(Settings.getLockedSlot(), ItemStackFactory.Instance.CreateStack(Material.BONE, (byte) 0, 1, C.Reset + C.Bold + "Left-Click to bark!"));
.addItem(ItemStackFactory.Instance.CreateStack(Material.BONE, (byte) 0, 1, C.Reset + C.Bold + "Left-Click to bark!"));
UtilPlayer.message(player, F.main("Game", "You are a " + C.cGreen + "Dog" + C.mBody + ", bark!")); UtilPlayer.message(player, F.main("Game", "You are a " + C.cGreen + "Dog" + C.mBody + ", bark!"));
} }
else else
@ -151,8 +151,7 @@ public class ChallengeDogsVersusCats extends Challenge
DisguiseCat Dcat = new DisguiseCat(player); DisguiseCat Dcat = new DisguiseCat(player);
Host.getArcadeManager().GetDisguise().disguise(Dcat); Host.getArcadeManager().GetDisguise().disguise(Dcat);
player.getInventory() player.getInventory().setItem(Settings.getLockedSlot(), ItemStackFactory.Instance.CreateStack(Material.STRING, (byte) 0, 1, C.Reset + C.Bold + "Left-Click to meow!"));
.addItem(ItemStackFactory.Instance.CreateStack(Material.STRING, (byte) 0, 1, C.Reset + C.Bold + "Left-Click to meow!"));
UtilPlayer.message(player, F.main("Game", "You are a " + C.cGreen + "Cat" + C.mBody + ", meow!")); UtilPlayer.message(player, F.main("Game", "You are a " + C.cGreen + "Cat" + C.mBody + ", meow!"));
} }

View File

@ -37,6 +37,7 @@ public class ChallengeDragonEgg extends Challenge
"Whack a dragon egg 10 times."); "Whack a dragon egg 10 times.");
Settings.setUseMapHeight(); Settings.setUseMapHeight();
Settings.setLockInventory(4);
} }
@Override @Override
@ -90,7 +91,7 @@ public class ChallengeDragonEgg extends Challenge
for (Player player : getChallengers()) for (Player player : getChallengers())
{ {
_smashedEggs.put(player.getName(), 0); _smashedEggs.put(player.getName(), 0);
player.getInventory().setItem(0, new ItemBuilder(Material.IRON_AXE).setTitle(C.cWhite + "Egg Smasher").build()); player.getInventory().setItem(Settings.getLockedSlot(), new ItemBuilder(Material.IRON_AXE).setTitle(C.cWhite + "Egg Smasher").build());
} }
} }
@ -105,7 +106,7 @@ public class ChallengeDragonEgg extends Challenge
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) public void onDragonEggInteract(PlayerInteractEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -124,7 +125,8 @@ 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, ViewDist.MAX, UtilServer.getPlayers()); Location particleLocation = block.getLocation().add(0.5, 0.5, 0.5);
UtilParticle.PlayParticle(ParticleType.PORTAL, particleLocation, 0.3F, 0.3F, 0.3F, 0, 11, ViewDist.MAX, UtilServer.getPlayers());
Host.CreatureAllowOverride = true; Host.CreatureAllowOverride = true;
@ -160,4 +162,26 @@ public class ChallengeDragonEgg extends Challenge
setCompleted(player); setCompleted(player);
} }
} }
@EventHandler
public void onDragonEggInteractBlock(PlayerInteractEvent event)
{
if (!isChallengeValid())
return;
Player player = event.getPlayer();
if (event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (!Data.isDone(player) && !Data.isLost(player))
return;
Block block = event.getClickedBlock();
if (block.getType() != Material.DRAGON_EGG)
return;
event.setCancelled(true);
}
} }

View File

@ -59,8 +59,7 @@ public class ChallengeFastFood extends Challenge
ChallengeType.FirstComplete, ChallengeType.FirstComplete,
"Fast Food", "Fast Food",
"Your inventory is full of food.", "Your inventory is full of food.",
"Punch to throw it in the ground.", "Punch to throw it in the ground.");
"First player to drop them all wins!");
Settings.setUseMapHeight(); Settings.setUseMapHeight();
} }
@ -86,7 +85,7 @@ public class ChallengeFastFood extends Challenge
Block block = location.getBlock(); Block block = location.getBlock();
block.setType(Material.GRASS); block.setType(Material.GRASS);
addBlock(location.getBlock()); addBlock(block);
} }
} }
@ -95,7 +94,7 @@ public class ChallengeFastFood extends Challenge
{ {
itemParticleTask(); itemParticleTask();
for (Player player : Host.GetPlayers(true)) for (Player player : getChallengers())
{ {
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
{ {
@ -109,23 +108,20 @@ public class ChallengeFastFood extends Challenge
{ {
_itemSeperator = 0; _itemSeperator = 0;
for (Entity entity : Host.WorldData.World.getEntities()) removeItemEntities();
{
if (entity instanceof Item)
{
entity.remove();
}
}
} }
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) public void onPlayerInteract(PlayerInteractEvent event)
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!isPlayerValid(player))
return;
if (UtilEvent.isAction(event, ActionType.L) && !Data.isDone(player)) if (UtilEvent.isAction(event, ActionType.L) && !Data.isDone(player))
{ {
if (event.getItem() != null) if (event.getItem() != null)
@ -147,7 +143,7 @@ public class ChallengeFastFood extends Challenge
@Override @Override
public void run() public void run()
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
{ {
cancel(); cancel();
return; return;
@ -234,7 +230,7 @@ public class ChallengeFastFood extends Challenge
@Override @Override
public void run() public void run()
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted() || !item.isValid() || item.isDead()) if (!isChallengeValid() || !item.isValid() || item.isDead())
{ {
cancel(); cancel();
return; return;
@ -298,8 +294,7 @@ public class ChallengeFastFood extends Challenge
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
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

@ -19,7 +19,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -44,7 +43,6 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class ChallengeFishingDay extends Challenge public class ChallengeFishingDay extends Challenge
{ {
private int _fishingRodSlot = 0;
private int _startingLureLevel = 8; private int _startingLureLevel = 8;
private HashMap<Player, Boolean> _fishing = new HashMap<Player, Boolean>(); private HashMap<Player, Boolean> _fishing = new HashMap<Player, Boolean>();
private HashMap<TNTPrimed, Player> _explosives = new HashMap<TNTPrimed, Player>(); private HashMap<TNTPrimed, Player> _explosives = new HashMap<TNTPrimed, Player>();
@ -59,6 +57,7 @@ public class ChallengeFishingDay extends Challenge
"Watch out for TNT if you miss the fish!"); "Watch out for TNT if you miss the fish!");
Settings.setUseMapHeight(); Settings.setUseMapHeight();
Settings.setLockInventory(0);
} }
@Override @Override
@ -77,7 +76,7 @@ public class ChallengeFishingDay extends Challenge
if ((absX == platform || absZ == platform) && !(absX > platform || absZ > platform)) if ((absX == platform || absZ == platform) && !(absX > platform || absZ > platform))
{ {
spawns.add(getCenter().clone().add(x + 0.5, 6.1, z + 0.5)); spawns.add(getCenter().add(x + 0.5, 6.1, z + 0.5));
} }
} }
} }
@ -187,14 +186,7 @@ public class ChallengeFishingDay extends Challenge
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemStack.setItemMeta(meta); itemStack.setItemMeta(meta);
for (Player player : Host.GetPlayers(true)) setItem(Settings.getLockedSlot(), itemStack);
{
if (Data.isDone(player))
continue;
player.getInventory().setItem(_fishingRodSlot, itemStack);
player.getInventory().setHeldItemSlot(_fishingRodSlot);
}
} }
@Override @Override
@ -205,13 +197,7 @@ public class ChallengeFishingDay extends Challenge
Host.InventoryClick = false; Host.InventoryClick = false;
Host.WorldWaterDamage = 0; Host.WorldWaterDamage = 0;
for (Entity entity : Host.WorldData.World.getEntities()) removePrimedTNTEntities();
{
if (entity instanceof TNTPrimed)
{
entity.remove();
}
}
_fishing.clear(); _fishing.clear();
_explosives.clear(); _explosives.clear();
@ -220,9 +206,12 @@ public class ChallengeFishingDay extends Challenge
@EventHandler @EventHandler
public void onPlayerFish(PlayerFishEvent event) public void onPlayerFish(PlayerFishEvent event)
{ {
if (!isChallengeValid())
return;
Player fisher = event.getPlayer(); Player fisher = event.getPlayer();
if (Data.isDone(fisher) || !Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isPlayerValid(fisher))
return; return;
Fish hook = event.getHook(); Fish hook = event.getHook();
@ -247,7 +236,7 @@ public class ChallengeFishingDay extends Challenge
fisher.getInventory().addItem(item); fisher.getInventory().addItem(item);
UtilTextBottom.display("You caught a " + C.cGreen + getFishType(item.getData().getData()) + C.cWhite + "!", UtilTextBottom.display("You caught a " + C.cGreen + getFishType(item.getData().getData()) + C.cWhite + "!",
fisher); fisher);
fisher.playSound(fisher.getLocation(), Sound.ORB_PICKUP, 1.0F, 1.0F); fisher.playSound(fisher.getLocation(), Sound.ORB_PICKUP, 1.0F, 1.0F);
waterSplashEffect(fisher.getLocation().add(0, 0.5, 0), true, true); waterSplashEffect(fisher.getLocation().add(0, 0.5, 0), true, true);
@ -271,48 +260,36 @@ public class ChallengeFishingDay extends Challenge
@EventHandler @EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
return; return;
if (event.getEntity() instanceof Player && event.getDamager() instanceof FishHook) if (event.getEntity() instanceof Player && event.getDamager() instanceof FishHook)
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler
public void onItemHeld(PlayerItemHeldEvent event)
{
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
return;
if (!Data.isDone(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler @EventHandler
public void onPlayerMove(PlayerMoveEvent event) public void onPlayerMove(PlayerMoveEvent event)
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
return; return;
if (!Data.isDone(event.getPlayer())) if (!isPlayerValid(event.getPlayer()))
return;
if (Math.random() * 100 < 20)
{ {
if (Math.random() * 100 < 20) Player player = event.getPlayer();
Location from = event.getFrom();
Location to = event.getTo();
double fromX = from.getX();
double fromZ = from.getZ();
double toX = to.getX();
double toZ = to.getZ();
if (fromX != toX || fromZ != toZ)
{ {
Player player = event.getPlayer(); waterSplashEffect(player.getLocation().add(0, 0.1, 0), false, false);
Location from = event.getFrom();
Location to = event.getTo();
double fromX = from.getX();
double fromZ = from.getZ();
double toX = to.getX();
double toZ = to.getZ();
if (fromX != toX || fromZ != toZ)
{
waterSplashEffect(player.getLocation().add(0, 0.1, 0), false, false);
}
} }
} }
} }
@ -320,7 +297,7 @@ public class ChallengeFishingDay extends Challenge
@EventHandler @EventHandler
public void onEntityExplode(EntityExplodeEvent event) public void onEntityExplode(EntityExplodeEvent event)
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
return; return;
Location dropsite = event.getLocation(); Location dropsite = event.getLocation();
@ -328,10 +305,8 @@ public class ChallengeFishingDay extends Challenge
world.playSound(dropsite, Sound.ZOMBIE_WOODBREAK, 0.5F, 1.0F); world.playSound(dropsite, Sound.ZOMBIE_WOODBREAK, 0.5F, 1.0F);
world.playSound(dropsite, Sound.EXPLODE, 1.0F, 1.0F); world.playSound(dropsite, Sound.EXPLODE, 1.0F, 1.0F);
UtilParticle.PlayParticle(ParticleType.CLOUD, dropsite, 0.6F, 0.6F, 0.6F, 0.0F, 50, ViewDist.NORMAL, UtilParticle.PlayParticle(ParticleType.CLOUD, dropsite, 0.6F, 0.6F, 0.6F, 0.0F, 50, ViewDist.NORMAL, UtilServer.getPlayers());
UtilServer.getPlayers()); UtilParticle.PlayParticle(ParticleType.SMOKE, dropsite, 0.3F, 0.3F, 0.3F, 0.5F, 50, ViewDist.NORMAL, UtilServer.getPlayers());
UtilParticle.PlayParticle(ParticleType.SMOKE, dropsite, 0.3F, 0.3F, 0.3F, 0.5F, 50, ViewDist.NORMAL,
UtilServer.getPlayers());
Player target = _explosives.get(event.getEntity()); Player target = _explosives.get(event.getEntity());
@ -390,8 +365,7 @@ public class ChallengeFishingDay extends Challenge
Location droppedHook = hook.getLocation(); Location droppedHook = hook.getLocation();
Block below = droppedHook.getBlock().getRelative(BlockFace.DOWN); Block below = droppedHook.getBlock().getRelative(BlockFace.DOWN);
return _fishing.get(fisher) && hook.isValid() && !hook.isOnGround() return _fishing.get(fisher) && hook.isValid() && !hook.isOnGround() && below.getType() == Material.STATIONARY_WATER;
&& below.getType() == Material.STATIONARY_WATER;
} }
private void createExplosion(Player target, Location dropsite) private void createExplosion(Player target, Location dropsite)
@ -407,7 +381,7 @@ public class ChallengeFishingDay extends Challenge
explosive.setYield(0.0F); explosive.setYield(0.0F);
UtilAction.velocity(explosive, UtilAlg.getTrajectory(dropsite, target.getLocation()), 1.2D, false, 0.0D, UtilAction.velocity(explosive, UtilAlg.getTrajectory(dropsite, target.getLocation()), 1.2D, false, 0.0D,
0.3D, 0.6D, false); 0.3D, 0.6D, false);
_explosives.put(explosive, target); _explosives.put(explosive, target);
} }
@ -420,8 +394,7 @@ public class ChallengeFishingDay extends Challenge
if (randomAmount) if (randomAmount)
amount += UtilMath.r(10); amount += UtilMath.r(10);
UtilParticle.PlayParticle(ParticleType.WATER_WAKE, location, 0.2F, 0.1F, 0.2F, 0.0F, amount, ViewDist.NORMAL, UtilParticle.PlayParticle(ParticleType.WATER_WAKE, location, 0.2F, 0.1F, 0.2F, 0.0F, amount, ViewDist.NORMAL, UtilServer.getPlayers());
UtilServer.getPlayers());
if (sound) if (sound)
location.getWorld().playSound(location, Sound.WATER, 0.3F, 1.0F); location.getWorld().playSound(location, Sound.WATER, 0.3F, 1.0F);

View File

@ -11,13 +11,16 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.disguise.disguises.DisguiseZombie; import mineplex.core.disguise.disguises.DisguiseZombie;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -30,7 +33,6 @@ import nautilus.game.arcade.game.games.mineware.challenge.other.InfestationZombi
public class ChallengeInfestation extends Challenge public class ChallengeInfestation extends Challenge
{ {
private InfestationZombie _zombie = new InfestationZombie(this); private InfestationZombie _zombie = new InfestationZombie(this);
private long _gameStart;
private HashSet<String> _infected = new HashSet<String>(); private HashSet<String> _infected = new HashSet<String>();
public ChallengeInfestation(BawkBawkBattles host) public ChallengeInfestation(BawkBawkBattles host)
@ -78,16 +80,10 @@ public class ChallengeInfestation extends Challenge
Host.CreatureAllowOverride = true; Host.CreatureAllowOverride = true;
_zombie.spawn(); _zombie.spawn();
Host.CreatureAllowOverride = false; Host.CreatureAllowOverride = false;
_gameStart = System.currentTimeMillis();
for (Player player : getChallengers())
{
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
}
_zombie.getEntity().setFireTicks(0); _zombie.getEntity().setFireTicks(0);
addEffect(PotionEffectType.SPEED, 1);
Host.DamageEvP = true; Host.DamageEvP = true;
Host.DamagePvP = true; Host.DamagePvP = true;
} }
@ -95,16 +91,7 @@ public class ChallengeInfestation extends Challenge
@Override @Override
public void onEnd() public void onEnd()
{ {
for (Player player : Host.GetPlayers(false))
{
if (player.hasPotionEffect(PotionEffectType.SPEED))
{
player.removePotionEffect(PotionEffectType.SPEED);
}
}
_zombie.remove(); _zombie.remove();
Host.getArcadeManager().GetDisguise().clearDisguises();
Host.DamageEvP = false; Host.DamageEvP = false;
Host.DamagePvP = false; Host.DamagePvP = false;
@ -113,7 +100,7 @@ public class ChallengeInfestation extends Challenge
@EventHandler @EventHandler
public void onUpdateZombie(UpdateEvent event) public void onUpdateZombie(UpdateEvent event)
{ {
if (!Host.IsLive()) if (!isChallengeValid())
return; return;
if (event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.FAST)
@ -144,13 +131,25 @@ public class ChallengeInfestation extends Challenge
if (_zombie.getLocation().distance(target.getLocation()) <= 2) if (_zombie.getLocation().distance(target.getLocation()) <= 2)
if (!_infected.contains(target.getName())) if (!_infected.contains(target.getName()))
{ {
if (_gameStart + 5000 > System.currentTimeMillis()) if (Settings.getStartTime() + 5000 > System.currentTimeMillis())
return; return;
infect(target); infect(target);
} }
} }
@EventHandler
public void onParticleUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!isChallengeValid())
return;
UtilParticle.PlayParticle(ParticleType.FLAME, _zombie.getLocation().add(0, 1.5, 0), 0.3F, 0.3F, 0.3F, 0.01F, 1, ViewDist.MAX, UtilServer.getPlayers());
}
@EventHandler @EventHandler
public void onCustomDamage(CustomDamageEvent event) public void onCustomDamage(CustomDamageEvent event)
{ {
@ -191,14 +190,14 @@ public class ChallengeInfestation extends Challenge
@EventHandler @EventHandler
public void onUpdateEndCheck(UpdateEvent event) public void onUpdateEndCheck(UpdateEvent event)
{ {
if (!Host.IsLive()) if (!isChallengeValid())
return; return;
if (event.getType() != UpdateType.FASTER) if (event.getType() != UpdateType.FASTER)
return; return;
if (_infected.size() >= Math.floor(Host.GetPlayers(true).size() / 2)) if (_infected.size() >= Math.floor(getChallengers().size() / 2))
for (Player player : Host.GetPlayers(true)) for (Player player : getChallengers())
if (_infected.contains(player.getName())) if (_infected.contains(player.getName()))
setLost(player); setLost(player);
else else
@ -208,7 +207,7 @@ public class ChallengeInfestation extends Challenge
@EventHandler @EventHandler
public void onEntityCombust(EntityCombustEvent event) public void onEntityCombust(EntityCombustEvent event)
{ {
if (!Host.IsLive()) if (!isChallengeValid())
return; return;
if (event.getEntity() instanceof Zombie) if (event.getEntity() instanceof Zombie)
@ -235,6 +234,7 @@ public class ChallengeInfestation extends Challenge
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!")); UtilPlayer.message(player, F.main("Game", "You have been infected, you now have to infect the rest."));
// player.sendMessage(F.main("Game", "You have been infected. It's over so infect the rest!"));
} }
} }

View File

@ -39,8 +39,8 @@ public class ChallengeWaterHorror extends Challenge
private int _tntExplodeAfter = 2; // Seconds private int _tntExplodeAfter = 2; // Seconds
private HashMap<Player, Boat> _boats = new HashMap<Player, Boat>(); private HashMap<Player, Boat> _boats = new HashMap<Player, Boat>();
private Location dropsite = getCenter().clone().add(0, 7.0, 0); private Location _dropsite = getCenter().add(0, 7.0, 0);
private Location base = dropsite.clone().subtract(0, 0.5, 0); private Location _base = _dropsite.clone().subtract(0, 0.5, 0);
public ChallengeWaterHorror(BawkBawkBattles host) public ChallengeWaterHorror(BawkBawkBattles host)
{ {
@ -70,7 +70,7 @@ public class ChallengeWaterHorror extends Challenge
if ((absX == platform || absZ == platform) && !(absX > platform || absZ > platform)) if ((absX == platform || absZ == platform) && !(absX > platform || absZ > platform))
{ {
spawns.add(getCenter().clone().add(x + 0.5, 6.1, z + 0.5)); spawns.add(getCenter().add(x + 0.5, 6.1, z + 0.5));
} }
} }
} }
@ -161,7 +161,7 @@ public class ChallengeWaterHorror extends Challenge
{ {
Host.getArcadeManager().GetExplosion().SetLiquidDamage(false); Host.getArcadeManager().GetExplosion().SetLiquidDamage(false);
for (Player player : Host.GetPlayers(true)) for (Player player : getChallengers())
{ {
Boat boat = player.getWorld().spawn(player.getLocation(), Boat.class); Boat boat = player.getWorld().spawn(player.getLocation(), Boat.class);
boat.setPassenger(player); boat.setPassenger(player);
@ -178,13 +178,7 @@ public class ChallengeWaterHorror extends Challenge
{ {
Host.getArcadeManager().GetExplosion().SetLiquidDamage(true); Host.getArcadeManager().GetExplosion().SetLiquidDamage(true);
for (Entity entity : Host.WorldData.World.getEntities()) removeBoatEntities();
{
if (entity instanceof Boat || entity instanceof TNTPrimed)
{
entity.remove();
}
}
_boats.clear(); _boats.clear();
} }
@ -192,7 +186,7 @@ public class ChallengeWaterHorror extends Challenge
@EventHandler @EventHandler
public void onUpdateEntityTrail(UpdateEvent event) public void onUpdateEntityTrail(UpdateEvent event)
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
return; return;
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
@ -204,9 +198,7 @@ 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, ViewDist.LONG);
0.0F, 2,
ViewDist.LONG);
new BukkitRunnable() new BukkitRunnable()
{ {
@ -225,21 +217,20 @@ public class ChallengeWaterHorror extends Challenge
@EventHandler @EventHandler
public void onUpdateSpawnerParticle(UpdateEvent event) public void onUpdateSpawnerParticle(UpdateEvent event)
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
return; return;
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
return; return;
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
public void onEntityDismount(EntityDismountEvent event) public void onEntityDismount(EntityDismountEvent event)
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
return; return;
if (event.getEntity() instanceof Boat) if (event.getEntity() instanceof Boat)
@ -251,7 +242,7 @@ public class ChallengeWaterHorror extends Challenge
@EventHandler @EventHandler
public void onVehicleDestroy(VehicleDestroyEvent event) public void onVehicleDestroy(VehicleDestroyEvent event)
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
return; return;
if (event.getVehicle() instanceof Boat) if (event.getVehicle() instanceof Boat)
@ -261,7 +252,7 @@ public class ChallengeWaterHorror extends Challenge
@EventHandler @EventHandler
public void onExplosion(ExplosionEvent event) public void onExplosion(ExplosionEvent event)
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
return; return;
event.GetBlocks().clear(); event.GetBlocks().clear();
@ -270,7 +261,7 @@ public class ChallengeWaterHorror extends Challenge
@EventHandler @EventHandler
public void onBlockFromTo(BlockFromToEvent event) public void onBlockFromTo(BlockFromToEvent event)
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
return; return;
if (event.getBlock().getType() == Material.ICE) if (event.getBlock().getType() == Material.ICE)
@ -280,12 +271,12 @@ public class ChallengeWaterHorror extends Challenge
@EventHandler @EventHandler
public void onPlayerDeath(PlayerDeathEvent event) public void onPlayerDeath(PlayerDeathEvent event)
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
return; return;
Player player = event.getEntity(); Player player = event.getEntity();
if (Data.isDone(player)) if (!isPlayerValid(player))
return; return;
player.eject(); player.eject();
@ -299,12 +290,12 @@ public class ChallengeWaterHorror extends Challenge
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) public void onPlayerQuit(PlayerQuitEvent event)
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (Data.isDone(player)) if (!isPlayerValid(player))
return; return;
player.eject(); player.eject();
@ -322,27 +313,25 @@ public class ChallengeWaterHorror extends Challenge
@Override @Override
public void run() public void run()
{ {
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted()) if (!isChallengeValid())
{ {
cancel(); cancel();
return; return;
} }
ArrayList<Player> players = Host.GetPlayers(true); ArrayList<Player> players = getChallengers();
int times = UtilMath.r(_tntSpawnMax) + _tntSpawnMin; int times = UtilMath.r(_tntSpawnMax) + _tntSpawnMin;
if (times > players.size()) if (times > players.size())
times = players.size(); times = players.size();
System.out.println("Times: " + times);
for (int i = 0; i < times; i++) for (int i = 0; i < times; i++)
{ {
Player target = UtilMath.randomElement(players); Player target = UtilMath.randomElement(players);
createExplosive(target, dropsite); createExplosive(target, _dropsite);
} }
dropsite.getWorld().playSound(dropsite, Sound.ZOMBIE_WOODBREAK, 0.5F, 1.3F); _dropsite.getWorld().playSound(_dropsite, Sound.ZOMBIE_WOODBREAK, 0.5F, 1.3F);
} }
}.runTaskTimer(Host.getArcadeManager().getPlugin(), 40L, 40L); }.runTaskTimer(Host.getArcadeManager().getPlugin(), 40L, 40L);
} }
@ -351,8 +340,10 @@ public class ChallengeWaterHorror extends Challenge
{ {
Location target = player.getLocation(); Location target = player.getLocation();
Host.CreatureAllowOverride = true;
TNTPrimed explosive = dropsite.getWorld().spawn(dropsite, TNTPrimed.class); TNTPrimed explosive = dropsite.getWorld().spawn(dropsite, TNTPrimed.class);
explosive.setFuseTicks(_tntExplodeAfter * 20); explosive.setFuseTicks(_tntExplodeAfter * 20);
Host.CreatureAllowOverride = false;
UtilAction.velocity(explosive, UtilAlg.getTrajectory(dropsite, target), 0.6D, true, 1.3D, 0.0D, 1.0D, false); UtilAction.velocity(explosive, UtilAlg.getTrajectory(dropsite, target), 0.6D, true, 1.3D, 0.0D, 1.0D, false);
} }