Challenge refactoring, bug fixes, add additional helper methods.
This commit is contained in:
parent
0f58c1378c
commit
c2d5699aa8
@ -40,6 +40,8 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -131,25 +133,22 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
private BawkBawkBattlesSettings _settings = new BawkBawkBattlesSettings();
|
||||
private ChallengeList _list = new ChallengeList();
|
||||
private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>();
|
||||
|
||||
private int _livesAmount = 2;
|
||||
|
||||
private String _restrictCommand = "restrict";
|
||||
private String _skipCommand = "skip";
|
||||
private ArrayList<Player> _winners = new ArrayList<Player>();
|
||||
|
||||
private GameTeam _playersTeam;
|
||||
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 ChickenAttack _chickenAttack;
|
||||
private Location _chickenAttackCenter;
|
||||
|
||||
private Challenge _challenge;
|
||||
private ArrayList<Block> _lastChallengeBlocks;
|
||||
private long _challengeTime;
|
||||
|
||||
private String _restrictCommand = "restrict";
|
||||
private String _skipCommand = "skip";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public BawkBawkBattles(ArcadeManager manager)
|
||||
{
|
||||
@ -163,6 +162,8 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
"Last player with lives wins!"
|
||||
});
|
||||
|
||||
_settings.setMaxLives(2);
|
||||
|
||||
DamageSelf = false;
|
||||
DamageTeamSelf = true;
|
||||
DamageTeamOther = false;
|
||||
@ -212,10 +213,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
ChallengeDogsVersusCats.class, // Playable - Refactored
|
||||
ChallengeDragonEgg.class, // Playable - Refactored
|
||||
ChallengeFallingBlocks.class, // Playable - Refactored
|
||||
ChallengeFastFood.class, // Playable
|
||||
ChallengeFishingDay.class, // Playable
|
||||
ChallengeWaterHorror.class, // Playable
|
||||
ChallengeInfestation.class, // Playable
|
||||
ChallengeFastFood.class, // Playable - Refactored
|
||||
ChallengeFishingDay.class, // Playable - Refactored
|
||||
ChallengeWaterHorror.class, // TNT not spawning - Refactored
|
||||
ChallengeInfestation.class, // Playable - Refactored
|
||||
ChallengeKangarooJump.class, // Playable
|
||||
ChallengeKingOfTheHill.class, // Playable- Improve map.
|
||||
ChallengeLavaRun.class, // Playable
|
||||
@ -448,7 +449,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
{
|
||||
_settings.setCrumbling(false);
|
||||
|
||||
for (Block block : _lastOrderBlocks)
|
||||
for (Block block : _lastChallengeBlocks)
|
||||
{
|
||||
if (block.getState() instanceof InventoryHolder)
|
||||
{
|
||||
@ -555,12 +556,12 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
|
||||
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()
|
||||
{
|
||||
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()
|
||||
@ -624,9 +625,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
|
||||
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
|
||||
public int compare(Block o1, Block o2)
|
||||
@ -765,7 +766,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
|
||||
int looped = 0;
|
||||
|
||||
List<String> messages = new ArrayList<>(Arrays.asList(challenge.getDescription()));
|
||||
List<String> messages = Lists.newArrayList(challenge.getDescription());
|
||||
|
||||
String type = challenge.getType().toString();
|
||||
|
||||
@ -780,8 +781,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
UtilPlayer.message(player, "");
|
||||
|
||||
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, "");
|
||||
}
|
||||
@ -796,12 +798,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
for (Player player : GetPlayers(true)) // Show to alive players only.
|
||||
UtilTextMiddle.display(challenge.getName(), message, 0, 60, 20, player);
|
||||
|
||||
if (looped == messages.size() - 1)
|
||||
{
|
||||
prepareCountdown();
|
||||
break;
|
||||
}
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
player.playSound(player.getLocation(), Sound.CHICKEN_IDLE, 1.5F, 1.0F);
|
||||
|
||||
@ -816,6 +812,12 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
}
|
||||
|
||||
looped++;
|
||||
|
||||
if (looped >= messages.size())
|
||||
{
|
||||
prepareCountdown();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -907,6 +909,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onChallengeDeath(PlayerDeathEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (_challenge == null)
|
||||
return;
|
||||
|
||||
@ -919,9 +924,30 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
|
||||
_challenge.getData().addLostPlayer(player);
|
||||
handleDeath(player);
|
||||
|
||||
_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
|
||||
public void onConditionApply(ConditionApplyEvent event)
|
||||
{
|
||||
@ -961,7 +987,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
if (lives <= 0)
|
||||
{
|
||||
if (alive <= 3)
|
||||
_places.add(player);
|
||||
_winners.add(player);
|
||||
}
|
||||
|
||||
if (lives <= 0 && alive > 2)
|
||||
@ -978,6 +1004,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
public int looseLife(Player player)
|
||||
{
|
||||
int lives = lives(player);
|
||||
|
||||
lives -= 1;
|
||||
|
||||
if (lives >= 0)
|
||||
@ -1152,11 +1179,12 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
if (_places.contains(player))
|
||||
_places.remove(player);
|
||||
|
||||
// TODO: Check if needed
|
||||
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();
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
_lives.put(player, _livesAmount);
|
||||
_lives.put(player, _settings.getMaxLives());
|
||||
|
||||
_challenge.createMap();
|
||||
|
||||
@ -1450,20 +1478,20 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
{
|
||||
Collections.reverse(_places);
|
||||
|
||||
if (!_places.contains(super.GetPlayers(true).get(0)))
|
||||
_places.add(0, super.GetPlayers(true).get(0));
|
||||
if (!_winners.contains(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)
|
||||
{
|
||||
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);
|
||||
|
||||
SetCustomWinLine("You have defeated Bawk Bawk!");
|
||||
AnnounceEnd(_places);
|
||||
AnnounceEnd(_winners);
|
||||
SetState(GameState.End);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxLives()
|
||||
{
|
||||
return _livesAmount;
|
||||
}
|
||||
|
||||
public GameTeam getPlayersTeam()
|
||||
{
|
||||
return _playersTeam;
|
||||
@ -1505,7 +1528,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
@Override
|
||||
public ArrayList<Player> getWinners()
|
||||
{
|
||||
return _places;
|
||||
return _winners;
|
||||
}
|
||||
|
||||
public HashMap<Player, Integer> getLives()
|
||||
|
@ -2,12 +2,23 @@ package nautilus.game.arcade.game.games.mineware;
|
||||
|
||||
public class BawkBawkBattlesSettings
|
||||
{
|
||||
private int _maxLives = 5;
|
||||
private boolean _crumbling = false;
|
||||
private boolean _waiting = true;
|
||||
private boolean _messagesSent = false;
|
||||
private boolean _sendingMessages = false;
|
||||
private boolean _challengeStarted = false;
|
||||
|
||||
public void setMaxLives(int maxLives)
|
||||
{
|
||||
_maxLives = maxLives;
|
||||
}
|
||||
|
||||
public int getMaxLives()
|
||||
{
|
||||
return _maxLives;
|
||||
}
|
||||
|
||||
public void setCrumbling(boolean flag)
|
||||
{
|
||||
_crumbling = flag;
|
||||
|
@ -1,20 +1,23 @@
|
||||
package nautilus.game.arcade.game.games.mineware.challenge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
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;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
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.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.Hologram.HologramTarget;
|
||||
@ -99,7 +103,7 @@ public abstract class Challenge implements Listener
|
||||
|
||||
protected void addItem(ItemStack... items)
|
||||
{
|
||||
for (Player player : Data.getCurrentPlaying())
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
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)
|
||||
{
|
||||
for (Player player : Data.getCurrentPlaying())
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
UtilInv.removeAll(player, type, data);
|
||||
}
|
||||
@ -118,11 +130,33 @@ public abstract class Challenge implements Listener
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
@ -153,7 +187,7 @@ public abstract class Challenge implements Listener
|
||||
|
||||
protected void removeEffect(PotionEffectType type)
|
||||
{
|
||||
for (Player player : Data.getCurrentPlaying())
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
player.removePotionEffect(type);
|
||||
}
|
||||
@ -171,11 +205,18 @@ public abstract class Challenge implements Listener
|
||||
|
||||
public void start()
|
||||
{
|
||||
Data.setCurrentPlaying(Host.getChallengers());
|
||||
Data.resetCompletedAndLost();
|
||||
|
||||
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();
|
||||
}
|
||||
@ -236,6 +277,7 @@ public abstract class Challenge implements Listener
|
||||
UtilPlayer.message(player, C.cGreen + C.Bold + "You completed the task!");
|
||||
UtilPlayer.message(player, "");
|
||||
|
||||
UtilInv.Clear(player);
|
||||
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());
|
||||
}
|
||||
|
||||
@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")
|
||||
@EventHandler
|
||||
public void onMapCrumble(UpdateEvent event)
|
||||
@ -400,7 +479,7 @@ public abstract class Challenge implements Listener
|
||||
{
|
||||
ArrayList<Player> currentlyAlive = new ArrayList<Player>();
|
||||
|
||||
for (Player player : Data.getCurrentPlaying())
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
if (Data.isLost(player))
|
||||
continue;
|
||||
|
@ -12,7 +12,6 @@ public class ChallengeData
|
||||
private HashSet<Block> _modifiedBlocks = new HashSet<Block>();
|
||||
private HashSet<Player> _completed = new HashSet<Player>();
|
||||
private HashSet<Player> _lost = new HashSet<Player>();
|
||||
private HashSet<Player> _playing = new HashSet<Player>();
|
||||
|
||||
public void resetCompletedAndLost()
|
||||
{
|
||||
@ -30,9 +29,6 @@ public class ChallengeData
|
||||
|
||||
if (_invisible.contains(player))
|
||||
_invisible.remove(player);
|
||||
|
||||
if (_playing.contains(player))
|
||||
_playing.remove(player);
|
||||
}
|
||||
|
||||
public boolean isCompleted(Player player)
|
||||
@ -99,24 +95,4 @@ public class ChallengeData
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ public class ChallengeList
|
||||
private ArrayList<Class<? extends Challenge>> _wrapper = 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)
|
||||
{
|
||||
for (Class<? extends Challenge> challenge : challenges)
|
||||
|
@ -14,6 +14,7 @@ public class ChallengeSettings
|
||||
|
||||
private boolean _useMapHeight;
|
||||
private boolean _lockInventory;
|
||||
private int _lockedSlot = 0;
|
||||
private boolean _teamBased;
|
||||
private boolean _canCrumble;
|
||||
|
||||
@ -103,16 +104,22 @@ public class ChallengeSettings
|
||||
return _useMapHeight;
|
||||
}
|
||||
|
||||
public void setLockInventory()
|
||||
public void setLockInventory(int lockedSlot)
|
||||
{
|
||||
_lockInventory = true;
|
||||
_lockedSlot = lockedSlot;
|
||||
}
|
||||
|
||||
|
||||
public boolean isInventoryLocked()
|
||||
{
|
||||
return _lockInventory;
|
||||
}
|
||||
|
||||
public int getLockedSlot()
|
||||
{
|
||||
return _lockedSlot;
|
||||
}
|
||||
|
||||
public void setTeamBased()
|
||||
{
|
||||
_teamBased = true;
|
||||
|
@ -47,7 +47,7 @@ public class InfestationZombie
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _wrapper.getLocation();
|
||||
return _wrapper.getLocation().clone();
|
||||
}
|
||||
|
||||
public ChallengeInfestation getChallenge()
|
||||
|
@ -59,7 +59,7 @@ public class ChallengeArrowRampage extends Challenge
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class ChallengeBlockLobbers extends Challenge
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
for (Player player : Data.getCurrentPlaying())
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
Material material = UtilMath.randomElement(_types);
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class ChallengeBouncingBlock extends Challenge
|
||||
{
|
||||
addEffect(PotionEffectType.JUMP, 6);
|
||||
|
||||
for (Player player : Data.getCurrentPlaying())
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
_score.put(player, 0);
|
||||
}
|
||||
@ -152,7 +152,7 @@ public class ChallengeBouncingBlock extends Challenge
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
for (Player player : Data.getCurrentPlaying())
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
if (Data.isDone(player))
|
||||
continue;
|
||||
@ -204,7 +204,7 @@ public class ChallengeBouncingBlock extends Challenge
|
||||
@SuppressWarnings("deprecation")
|
||||
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++)
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ public class ChallengeCloudFall extends Challenge
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class ChallengeDiamondSeeker extends Challenge
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ public class ChallengeDogsVersusCats extends Challenge
|
||||
Settings.setUseMapHeight();
|
||||
Settings.setTeamBased();
|
||||
Settings.setDuration(75000);
|
||||
Settings.setLockInventory(4);
|
||||
|
||||
_catTeam = new ChallengeTeam("Cats");
|
||||
_dogTeam = new ChallengeTeam("Dogs");
|
||||
@ -140,8 +141,7 @@ public class ChallengeDogsVersusCats extends Challenge
|
||||
DisguiseWolf Ddog = new DisguiseWolf(player);
|
||||
Host.getArcadeManager().GetDisguise().disguise(Ddog);
|
||||
|
||||
player.getInventory()
|
||||
.addItem(ItemStackFactory.Instance.CreateStack(Material.BONE, (byte) 0, 1, C.Reset + C.Bold + "Left-Click to bark!"));
|
||||
player.getInventory().setItem(Settings.getLockedSlot(), 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!"));
|
||||
}
|
||||
else
|
||||
@ -151,8 +151,7 @@ public class ChallengeDogsVersusCats extends Challenge
|
||||
DisguiseCat Dcat = new DisguiseCat(player);
|
||||
Host.getArcadeManager().GetDisguise().disguise(Dcat);
|
||||
|
||||
player.getInventory()
|
||||
.addItem(ItemStackFactory.Instance.CreateStack(Material.STRING, (byte) 0, 1, C.Reset + C.Bold + "Left-Click to meow!"));
|
||||
player.getInventory().setItem(Settings.getLockedSlot(), 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!"));
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ public class ChallengeDragonEgg extends Challenge
|
||||
"Whack a dragon egg 10 times.");
|
||||
|
||||
Settings.setUseMapHeight();
|
||||
Settings.setLockInventory(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,7 +91,7 @@ public class ChallengeDragonEgg extends Challenge
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
_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")
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
public void onDragonEggInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
@ -124,7 +125,8 @@ public class ChallengeDragonEgg extends Challenge
|
||||
|
||||
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;
|
||||
|
||||
@ -160,4 +162,26 @@ public class ChallengeDragonEgg extends Challenge
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -59,9 +59,8 @@ public class ChallengeFastFood extends Challenge
|
||||
ChallengeType.FirstComplete,
|
||||
"Fast Food",
|
||||
"Your inventory is full of food.",
|
||||
"Punch to throw it in the ground.",
|
||||
"First player to drop them all wins!");
|
||||
|
||||
"Punch to throw it in the ground.");
|
||||
|
||||
Settings.setUseMapHeight();
|
||||
}
|
||||
|
||||
@ -86,7 +85,7 @@ public class ChallengeFastFood extends Challenge
|
||||
Block block = location.getBlock();
|
||||
block.setType(Material.GRASS);
|
||||
|
||||
addBlock(location.getBlock());
|
||||
addBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +94,7 @@ public class ChallengeFastFood extends Challenge
|
||||
{
|
||||
itemParticleTask();
|
||||
|
||||
for (Player player : Host.GetPlayers(true))
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
@ -109,23 +108,20 @@ public class ChallengeFastFood extends Challenge
|
||||
{
|
||||
_itemSeperator = 0;
|
||||
|
||||
for (Entity entity : Host.WorldData.World.getEntities())
|
||||
{
|
||||
if (entity instanceof Item)
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
removeItemEntities();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!isPlayerValid(player))
|
||||
return;
|
||||
|
||||
if (UtilEvent.isAction(event, ActionType.L) && !Data.isDone(player))
|
||||
{
|
||||
if (event.getItem() != null)
|
||||
@ -147,7 +143,7 @@ public class ChallengeFastFood extends Challenge
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
{
|
||||
cancel();
|
||||
return;
|
||||
@ -234,7 +230,7 @@ public class ChallengeFastFood extends Challenge
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted() || !item.isValid() || item.isDead())
|
||||
if (!isChallengeValid() || !item.isValid() || item.isDead())
|
||||
{
|
||||
cancel();
|
||||
return;
|
||||
@ -298,8 +294,7 @@ public class ChallengeFastFood extends Challenge
|
||||
@SuppressWarnings("deprecation")
|
||||
private void blockBreakEffect(Block block)
|
||||
{
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(block.getType(), block.getData()), block.getLocation(), 0.0F, 0.0F, 0.0F, 0,
|
||||
10, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(block.getType(), block.getData()), block.getLocation(), 0.0F, 0.0F, 0.0F, 0, 10, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -44,7 +43,6 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ChallengeFishingDay extends Challenge
|
||||
{
|
||||
private int _fishingRodSlot = 0;
|
||||
private int _startingLureLevel = 8;
|
||||
private HashMap<Player, Boolean> _fishing = new HashMap<Player, Boolean>();
|
||||
private HashMap<TNTPrimed, Player> _explosives = new HashMap<TNTPrimed, Player>();
|
||||
@ -57,8 +55,9 @@ public class ChallengeFishingDay extends Challenge
|
||||
"Fishing Day",
|
||||
"Be the first to catch 5 fish.",
|
||||
"Watch out for TNT if you miss the fish!");
|
||||
|
||||
|
||||
Settings.setUseMapHeight();
|
||||
Settings.setLockInventory(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -77,7 +76,7 @@ public class ChallengeFishingDay extends Challenge
|
||||
|
||||
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);
|
||||
itemStack.setItemMeta(meta);
|
||||
|
||||
for (Player player : Host.GetPlayers(true))
|
||||
{
|
||||
if (Data.isDone(player))
|
||||
continue;
|
||||
|
||||
player.getInventory().setItem(_fishingRodSlot, itemStack);
|
||||
player.getInventory().setHeldItemSlot(_fishingRodSlot);
|
||||
}
|
||||
setItem(Settings.getLockedSlot(), itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -205,13 +197,7 @@ public class ChallengeFishingDay extends Challenge
|
||||
Host.InventoryClick = false;
|
||||
Host.WorldWaterDamage = 0;
|
||||
|
||||
for (Entity entity : Host.WorldData.World.getEntities())
|
||||
{
|
||||
if (entity instanceof TNTPrimed)
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
removePrimedTNTEntities();
|
||||
|
||||
_fishing.clear();
|
||||
_explosives.clear();
|
||||
@ -220,9 +206,12 @@ public class ChallengeFishingDay extends Challenge
|
||||
@EventHandler
|
||||
public void onPlayerFish(PlayerFishEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
Player fisher = event.getPlayer();
|
||||
|
||||
if (Data.isDone(fisher) || !Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isPlayerValid(fisher))
|
||||
return;
|
||||
|
||||
Fish hook = event.getHook();
|
||||
@ -247,7 +236,7 @@ public class ChallengeFishingDay extends Challenge
|
||||
fisher.getInventory().addItem(item);
|
||||
|
||||
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);
|
||||
|
||||
waterSplashEffect(fisher.getLocation().add(0, 0.5, 0), true, true);
|
||||
@ -271,48 +260,36 @@ public class ChallengeFishingDay extends Challenge
|
||||
@EventHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof Player && event.getDamager() instanceof FishHook)
|
||||
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
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
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();
|
||||
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);
|
||||
}
|
||||
waterSplashEffect(player.getLocation().add(0, 0.1, 0), false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -320,7 +297,7 @@ public class ChallengeFishingDay extends Challenge
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent event)
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
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.EXPLODE, 1.0F, 1.0F);
|
||||
UtilParticle.PlayParticle(ParticleType.CLOUD, dropsite, 0.6F, 0.6F, 0.6F, 0.0F, 50, ViewDist.NORMAL,
|
||||
UtilServer.getPlayers());
|
||||
UtilParticle.PlayParticle(ParticleType.SMOKE, dropsite, 0.3F, 0.3F, 0.3F, 0.5F, 50, ViewDist.NORMAL,
|
||||
UtilServer.getPlayers());
|
||||
UtilParticle.PlayParticle(ParticleType.CLOUD, dropsite, 0.6F, 0.6F, 0.6F, 0.0F, 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());
|
||||
|
||||
@ -390,8 +365,7 @@ public class ChallengeFishingDay extends Challenge
|
||||
Location droppedHook = hook.getLocation();
|
||||
Block below = droppedHook.getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
return _fishing.get(fisher) && hook.isValid() && !hook.isOnGround()
|
||||
&& below.getType() == Material.STATIONARY_WATER;
|
||||
return _fishing.get(fisher) && hook.isValid() && !hook.isOnGround() && below.getType() == Material.STATIONARY_WATER;
|
||||
}
|
||||
|
||||
private void createExplosion(Player target, Location dropsite)
|
||||
@ -407,7 +381,7 @@ public class ChallengeFishingDay extends Challenge
|
||||
explosive.setYield(0.0F);
|
||||
|
||||
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);
|
||||
}
|
||||
@ -420,8 +394,7 @@ public class ChallengeFishingDay extends Challenge
|
||||
if (randomAmount)
|
||||
amount += UtilMath.r(10);
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.WATER_WAKE, location, 0.2F, 0.1F, 0.2F, 0.0F, amount, ViewDist.NORMAL,
|
||||
UtilServer.getPlayers());
|
||||
UtilParticle.PlayParticle(ParticleType.WATER_WAKE, location, 0.2F, 0.1F, 0.2F, 0.0F, amount, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
|
||||
if (sound)
|
||||
location.getWorld().playSound(location, Sound.WATER, 0.3F, 1.0F);
|
||||
|
@ -11,13 +11,16 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
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.updater.UpdateType;
|
||||
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
|
||||
{
|
||||
private InfestationZombie _zombie = new InfestationZombie(this);
|
||||
private long _gameStart;
|
||||
private HashSet<String> _infected = new HashSet<String>();
|
||||
|
||||
public ChallengeInfestation(BawkBawkBattles host)
|
||||
@ -78,16 +80,10 @@ public class ChallengeInfestation extends Challenge
|
||||
Host.CreatureAllowOverride = true;
|
||||
_zombie.spawn();
|
||||
Host.CreatureAllowOverride = false;
|
||||
|
||||
_gameStart = System.currentTimeMillis();
|
||||
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
|
||||
}
|
||||
|
||||
_zombie.getEntity().setFireTicks(0);
|
||||
|
||||
addEffect(PotionEffectType.SPEED, 1);
|
||||
|
||||
Host.DamageEvP = true;
|
||||
Host.DamagePvP = true;
|
||||
}
|
||||
@ -95,16 +91,7 @@ public class ChallengeInfestation extends Challenge
|
||||
@Override
|
||||
public void onEnd()
|
||||
{
|
||||
for (Player player : Host.GetPlayers(false))
|
||||
{
|
||||
if (player.hasPotionEffect(PotionEffectType.SPEED))
|
||||
{
|
||||
player.removePotionEffect(PotionEffectType.SPEED);
|
||||
}
|
||||
}
|
||||
|
||||
_zombie.remove();
|
||||
Host.getArcadeManager().GetDisguise().clearDisguises();
|
||||
|
||||
Host.DamageEvP = false;
|
||||
Host.DamagePvP = false;
|
||||
@ -113,7 +100,7 @@ public class ChallengeInfestation extends Challenge
|
||||
@EventHandler
|
||||
public void onUpdateZombie(UpdateEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
@ -144,13 +131,25 @@ public class ChallengeInfestation extends Challenge
|
||||
if (_zombie.getLocation().distance(target.getLocation()) <= 2)
|
||||
if (!_infected.contains(target.getName()))
|
||||
{
|
||||
if (_gameStart + 5000 > System.currentTimeMillis())
|
||||
if (Settings.getStartTime() + 5000 > System.currentTimeMillis())
|
||||
return;
|
||||
|
||||
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
|
||||
public void onCustomDamage(CustomDamageEvent event)
|
||||
{
|
||||
@ -191,14 +190,14 @@ public class ChallengeInfestation extends Challenge
|
||||
@EventHandler
|
||||
public void onUpdateEndCheck(UpdateEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
return;
|
||||
|
||||
if (_infected.size() >= Math.floor(Host.GetPlayers(true).size() / 2))
|
||||
for (Player player : Host.GetPlayers(true))
|
||||
if (_infected.size() >= Math.floor(getChallengers().size() / 2))
|
||||
for (Player player : getChallengers())
|
||||
if (_infected.contains(player.getName()))
|
||||
setLost(player);
|
||||
else
|
||||
@ -208,7 +207,7 @@ public class ChallengeInfestation extends Challenge
|
||||
@EventHandler
|
||||
public void onEntityCombust(EntityCombustEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof Zombie)
|
||||
@ -235,6 +234,7 @@ public class ChallengeInfestation extends Challenge
|
||||
Host.WorldData.World.strikeLightningEffect(player.getLocation());
|
||||
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!"));
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ public class ChallengeWaterHorror extends Challenge
|
||||
private int _tntExplodeAfter = 2; // Seconds
|
||||
|
||||
private HashMap<Player, Boat> _boats = new HashMap<Player, Boat>();
|
||||
private Location dropsite = getCenter().clone().add(0, 7.0, 0);
|
||||
private Location base = dropsite.clone().subtract(0, 0.5, 0);
|
||||
private Location _dropsite = getCenter().add(0, 7.0, 0);
|
||||
private Location _base = _dropsite.clone().subtract(0, 0.5, 0);
|
||||
|
||||
public ChallengeWaterHorror(BawkBawkBattles host)
|
||||
{
|
||||
@ -70,7 +70,7 @@ public class ChallengeWaterHorror extends Challenge
|
||||
|
||||
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);
|
||||
|
||||
for (Player player : Host.GetPlayers(true))
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
Boat boat = player.getWorld().spawn(player.getLocation(), Boat.class);
|
||||
boat.setPassenger(player);
|
||||
@ -178,13 +178,7 @@ public class ChallengeWaterHorror extends Challenge
|
||||
{
|
||||
Host.getArcadeManager().GetExplosion().SetLiquidDamage(true);
|
||||
|
||||
for (Entity entity : Host.WorldData.World.getEntities())
|
||||
{
|
||||
if (entity instanceof Boat || entity instanceof TNTPrimed)
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
removeBoatEntities();
|
||||
|
||||
_boats.clear();
|
||||
}
|
||||
@ -192,7 +186,7 @@ public class ChallengeWaterHorror extends Challenge
|
||||
@EventHandler
|
||||
public void onUpdateEntityTrail(UpdateEvent event)
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
@ -204,9 +198,7 @@ public class ChallengeWaterHorror extends Challenge
|
||||
{
|
||||
if (entity.isValid() && !entity.isOnGround())
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FLAME, entity.getLocation(), 0.2F, 0.2F, 0.2F,
|
||||
0.0F, 2,
|
||||
ViewDist.LONG);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FLAME, entity.getLocation(), 0.2F, 0.2F, 0.2F, 0.0F, 2, ViewDist.LONG);
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@ -225,21 +217,20 @@ public class ChallengeWaterHorror extends Challenge
|
||||
@EventHandler
|
||||
public void onUpdateSpawnerParticle(UpdateEvent event)
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
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,
|
||||
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, ViewDist.LONG);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDismount(EntityDismountEvent event)
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof Boat)
|
||||
@ -251,7 +242,7 @@ public class ChallengeWaterHorror extends Challenge
|
||||
@EventHandler
|
||||
public void onVehicleDestroy(VehicleDestroyEvent event)
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (event.getVehicle() instanceof Boat)
|
||||
@ -261,7 +252,7 @@ public class ChallengeWaterHorror extends Challenge
|
||||
@EventHandler
|
||||
public void onExplosion(ExplosionEvent event)
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
event.GetBlocks().clear();
|
||||
@ -270,7 +261,7 @@ public class ChallengeWaterHorror extends Challenge
|
||||
@EventHandler
|
||||
public void onBlockFromTo(BlockFromToEvent event)
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (event.getBlock().getType() == Material.ICE)
|
||||
@ -280,12 +271,12 @@ public class ChallengeWaterHorror extends Challenge
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event)
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
Player player = event.getEntity();
|
||||
|
||||
if (Data.isDone(player))
|
||||
if (!isPlayerValid(player))
|
||||
return;
|
||||
|
||||
player.eject();
|
||||
@ -299,12 +290,12 @@ public class ChallengeWaterHorror extends Challenge
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Data.isDone(player))
|
||||
if (!isPlayerValid(player))
|
||||
return;
|
||||
|
||||
player.eject();
|
||||
@ -322,27 +313,25 @@ public class ChallengeWaterHorror extends Challenge
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!Host.IsLive() || !Host.getSettings().isChallengeStarted())
|
||||
if (!isChallengeValid())
|
||||
{
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Player> players = Host.GetPlayers(true);
|
||||
ArrayList<Player> players = getChallengers();
|
||||
int times = UtilMath.r(_tntSpawnMax) + _tntSpawnMin;
|
||||
|
||||
if (times > players.size())
|
||||
times = players.size();
|
||||
|
||||
System.out.println("Times: " + times);
|
||||
|
||||
for (int i = 0; i < times; i++)
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -351,8 +340,10 @@ public class ChallengeWaterHorror extends Challenge
|
||||
{
|
||||
Location target = player.getLocation();
|
||||
|
||||
Host.CreatureAllowOverride = true;
|
||||
TNTPrimed explosive = dropsite.getWorld().spawn(dropsite, TNTPrimed.class);
|
||||
explosive.setFuseTicks(_tntExplodeAfter * 20);
|
||||
Host.CreatureAllowOverride = false;
|
||||
|
||||
UtilAction.velocity(explosive, UtilAlg.getTrajectory(dropsite, target), 0.6D, true, 1.3D, 0.0D, 1.0D, false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user