Implement challenge settings and data.

This commit is contained in:
Thanos paravantis 2016-03-01 17:09:43 +02:00
parent 6570adc4af
commit 77871e3195
55 changed files with 788 additions and 707 deletions

View File

@ -11,14 +11,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.ClassCombat"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>

View File

@ -41,7 +41,7 @@ public class AntiHackFix implements Listener
Player player = event.getPlayer();
if (_challenge.isDone(player))
if (_challenge.getData().isDone(player))
return;
if (!player.hasPotionEffect(PotionEffectType.JUMP))

View File

@ -99,7 +99,6 @@ import nautilus.game.arcade.game.games.mineware.challenges.ChallengePickASide;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengePunchThePig;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeRedLightGreenLight;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeReverseTag;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeRunner;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeRushPush;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeShootChickens;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeSmashOff;
@ -282,12 +281,12 @@ public class BawkBawkBattles extends TeamGame implements IThrown
Challenge challenge = getChallengeInstance();
if (getChallengers().size() >= challenge.getMinPlayers())
if (getChallengers().size() >= challenge.getSettings().getMinPlayers())
{
if (getChallengers().size() >= challenge.getMaxPlayers())
if (getChallengers().size() >= challenge.getSettings().getMaxPlayers())
continue;
if (challenge.isTeamBased())
if (challenge.getSettings().isTeamBased())
if (!(getChallengers().size() % 2 == 0))
continue;
@ -312,8 +311,8 @@ public class BawkBawkBattles extends TeamGame implements IThrown
catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
| SecurityException e)
{
System.out.println("There was a problem loading a new challenge.");
System.out.println("Error: " + e.getMessage());
System.out.println("There was a problem loading a new challenge.");
e.printStackTrace();
}
return null;
@ -331,7 +330,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
if (_challenge != null)
{
for (Player player : GetPlayers(true))
if (!_challenge.isDone(player) && ((CraftPlayer) player).getHandle().spectating)
if (!_challenge.getData().isDone(player) && ((CraftPlayer) player).getHandle().spectating)
return;
}
@ -350,7 +349,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_crumbling = false;
_deathEffect.removeSpawnedEntities();
_challenge.generateRoom();
_challenge.createMap();
ArrayList<Location> spawns = setupChallengeSpawnLocations();
ArrayList<Location> selectedSpawnpoints = new ArrayList<Location>();
@ -478,7 +477,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
private ArrayList<Location> setupChallengeSpawnLocations()
{
ArrayList<Location> spawns = _challenge.getSpawns();
ArrayList<Location> spawns = _challenge.createSpawns();
_playersTeam.SetSpawns(spawns);
SpectatorSpawn = UtilWorld.averageLocation(spawns).add(0, 7.0D, 0);
return spawns;
@ -567,17 +566,17 @@ public class BawkBawkBattles extends TeamGame implements IThrown
private boolean canStartCrumbling()
{
return _challenge.canCrumble() && !_challenge.getModifiedBlocks().isEmpty();
return _challenge.getSettings().canCrumble() && !_challenge.getData().getModifiedBlocks().isEmpty();
}
private boolean justStartedCrumbling()
{
return !_crumbling && _challenge.getLost().size() >= _challenge.getCurrentPlaying().size() / 2;
return !_crumbling && _challenge.getData().getLostPlayers().size() >= _challenge.getData().getCurrentPlaying().size() / 2;
}
private boolean canEndChallengeFromCrumble()
{
return (_challenge.getCurrentPlaying().size() - _challenge.getLost().size()) <= 1 && _crumbling;
return (_challenge.getData().getCurrentPlaying().size() - _challenge.getData().getLostPlayers().size()) <= 1 && _crumbling;
}
private void updateChallengeTimer()
@ -625,18 +624,18 @@ public class BawkBawkBattles extends TeamGame implements IThrown
Manager.GetDisguise().undisguise(player);
UtilInv.Clear(player);
if (_challenge.hasAnyoneCompleted() && !_challenge.isCompleted(player))
if (_challenge.getData().hasAnyoneCompleted() && !_challenge.getData().isCompleted(player))
//looseLife(player, true);
handleDeath(player);
if (_challenge.isCompleted(player))
if (_challenge.getData().isCompleted(player))
AddGems(player, 3, "Completed Challenge", true, true);
}
}
private void sortLastChallengeBlocks()
{
_lastOrderBlocks = new ArrayList<Block>(_challenge.getModifiedBlocks());
_lastOrderBlocks = new ArrayList<Block>(_challenge.getData().getModifiedBlocks());
Collections.sort(_lastOrderBlocks, new Comparator<Block>()
{
@ -705,7 +704,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
Scoreboard.Write(C.cGold + C.Bold + "Completed");
if (check)
Scoreboard.Write("" + _challenge.getCompleted().size());
Scoreboard.Write("" + _challenge.getData().getCompletedPlayers().size());
else
Scoreboard.Write("-");
@ -714,7 +713,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
Scoreboard.Write(C.cGray + C.Bold + "Dead");
if (check)
Scoreboard.Write("" + _challenge.getLost().size());
Scoreboard.Write("" + _challenge.getData().getLostPlayers().size());
else
Scoreboard.Write("-");
@ -731,11 +730,11 @@ public class BawkBawkBattles extends TeamGame implements IThrown
if (_challenge != null)
{
if (_challenge.isLost(player))
if (_challenge.getData().isLost(player))
{
currentlyOut = C.cDRed + "X ";
}
else if (_challenge.isCompleted(player))
else if (_challenge.getData().isCompleted(player))
{
currentlyOut = C.cGreen + "";
}
@ -926,7 +925,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
Location death = player.getLocation().clone();
_challenge.getLost().add(player);
_challenge.getData().addLostPlayer(player);
handleDeath(player);
_deathEffect.playDeath(player, death);
}
@ -1162,9 +1161,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
if (_challenge != null)
{
if (_challenge.getCurrentPlaying() != null)
if (_challenge.getData().getCurrentPlaying() != null)
{
_challenge.getCurrentPlaying().remove(player);
_challenge.getData().removeCurrentPlaying(player);
}
}
}
@ -1328,10 +1327,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_lives.put(player, _livesAmount);
_challenge = selectChallenge();
_challenge.generateRoom();
_challenge.createMap();
_playersTeam.SetSpawns(_challenge.getSpawns());
SpectatorSpawn = UtilWorld.averageLocation(_challenge.getSpawns()).add(0, 7, 0);
_playersTeam.SetSpawns(_challenge.createSpawns());
SpectatorSpawn = UtilWorld.averageLocation(_challenge.createSpawns()).add(0, 7, 0);
}
@EventHandler
@ -1366,6 +1365,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{

View File

@ -1,7 +1,6 @@
package nautilus.game.arcade.game.games.mineware;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.bukkit.Location;
@ -32,122 +31,126 @@ import nautilus.game.arcade.world.WorldData;
public abstract class Challenge implements Listener
{
public BawkBawkBattles Host;
protected BawkBawkBattles Host;
private ChallengeType _type;
private String _name;
private String[] _description;
private boolean _teamBased;
private boolean _crumble;
private ChallengeType _type;
protected ChallengeSettings Settings;
protected ChallengeData Data;
private Location _center;
private HashSet<Player> _invisPlayers = new HashSet<Player>();
private HashSet<Block> _modifiedBlocks = new HashSet<Block>();
private int _places;
private long _startTime;
private long _duration;
private HashSet<Player> _completed = new HashSet<Player>();
private HashSet<Player> _lost = new HashSet<Player>();
private HashSet<Player> _currentPlaying;
/**
* Default Constructor.
*
* @param host The game that this challenge is hosted on.
* @param type The type of the challenge.
* @param useMapHeight Whether or not the map center should be elevated to y = 62.
* @param name The display name of the challenge.
* @param teamBased Whether or not this challenge is based on teams.
* @param crumble Whether or not the map can crumble.
* @param description The description of the challenge.
*/
public Challenge(BawkBawkBattles host, ChallengeType type, boolean useMapHeight, String name, boolean teamBased,
boolean crumble, String... description)
public Challenge(BawkBawkBattles host, ChallengeType type, String name, String... description)
{
Host = host;
_type = type;
_name = name;
_teamBased = teamBased;
_crumble = crumble;
_description = description;
int y = 0;
if (useMapHeight)
y = 62;
_center = new Location(host.WorldData.World, -1, y, 10);
Settings = new ChallengeSettings(this);
Data = new ChallengeData();
setBorder(-100, 100, 0, 256, -100, 100);
}
/**
* Alternative Constructor.
*
* @param host The game that this challenge is hosted on.
* @param type The type of the challenge.
* @param name The display name of the challenge.
* @param description The description of the challenge.
*/
public Challenge(BawkBawkBattles host, ChallengeType type, String name, String... description)
{
this(host, type, false, name, false, false, description);
}
/**
* Alternative Constructor.
*
* @param host The game that this challenge is hosted on.
* @param type The type of the challenge.
* @param useMapHeight Whether or not the map center should be elevated to y = 62.
* @param name The display name of the challenge.
* @param description The description of the challenge.
*/
public Challenge(BawkBawkBattles host, ChallengeType type, boolean useMapHeight, String name, String... description)
{
this(host, type, useMapHeight, name, false, false, description);
}
/**
* Alternative Constructor.
*
* @param host The game that this challenge is hosted on.
* @param type The type of the challenge.
* @param name The display name of the challenge.
* @param teamBased Whether or not this challenge is based on teams.
* @param crumble Whether or not the map can crumble.
* @param description The description of the challenge.
*/
public Challenge(BawkBawkBattles host, ChallengeType type, String name, boolean teamBased,
boolean crumble, String... description)
{
this(host, type, false, name, teamBased, crumble, description);
}
// /**
// * Default Constructor.
// *
// * @param host The game that this challenge is hosted on.
// * @param type The type of the challenge.
// * @param useMapHeight Whether or not the map center should be elevated to y = 62.
// * @param name The display name of the challenge.
// * @param teamBased Whether or not this challenge is based on teams.
// * @param crumble Whether or not the map can crumble.
// * @param description The description of the challenge.
// */
// public Challenge(BawkBawkBattles host, ChallengeType type, boolean useMapHeight, String name, boolean teamBased,
// boolean crumble, String... description)
// {
// Host = host;
// _type = type;
// _name = name;
// _teamBased = teamBased;
// _crumble = crumble;
// _description = description;
//
// int y = 0;
//
// if (useMapHeight)
// y = 62;
//
// _center = new Location(host.WorldData.World, -1, y, 10);
//
// setBorder(-100, 100, 0, 256, -100, 100);
// }
//
// /**
// * Alternative Constructor.
// *
// * @param host The game that this challenge is hosted on.
// * @param type The type of the challenge.
// * @param name The display name of the challenge.
// * @param description The description of the challenge.
// */
// public Challenge(BawkBawkBattles host, ChallengeType type, String name, String... description)
// {
// this(host, type, false, name, false, false, description);
// }
//
// /**
// * Alternative Constructor.
// *
// * @param host The game that this challenge is hosted on.
// * @param type The type of the challenge.
// * @param useMapHeight Whether or not the map center should be elevated to y = 62.
// * @param name The display name of the challenge.
// * @param description The description of the challenge.
// */
// public Challenge(BawkBawkBattles host, ChallengeType type, boolean useMapHeight, String name, String... description)
// {
// this(host, type, useMapHeight, name, false, false, description);
// }
//
// /**
// * Alternative Constructor.
// *
// * @param host The game that this challenge is hosted on.
// * @param type The type of the challenge.
// * @param name The display name of the challenge.
// * @param teamBased Whether or not this challenge is based on teams.
// * @param crumble Whether or not the map can crumble.
// * @param description The description of the challenge.
// */
// public Challenge(BawkBawkBattles host, ChallengeType type, String name, boolean teamBased,
// boolean crumble, String... description)
// {
// this(host, type, false, name, teamBased, crumble, description);
// }
/**
* The list of spawn locations where players will be teleported.
*
* @return ArrayList<Location>
*/
public abstract ArrayList<Location> getSpawns();
public abstract ArrayList<Location> createSpawns();
/**
* The list of actions to perform in order for the map to be created.
*/
public abstract void generateRoom();
public abstract void createMap();
/**
* The list of actions to perform once the challenge is started.
*/
public abstract void setupPlayers();
public void onStart()
{
}
/**
* The list of actions to perform after the challenge has ended.
*/
public abstract void cleanupRoom();
public void onEnd()
{
}
/**
* This method is called when the challenge timer runs out. <br>
@ -159,27 +162,26 @@ public abstract class Challenge implements Listener
public void start()
{
_currentPlaying = new HashSet<Player>(getChallengers());
setupPlayers();
Data.setCurrentPlaying(Host.getChallengers());
Data.resetCompletedAndLost();
_completed.clear();
_lost.clear();
_startTime = System.currentTimeMillis();
_duration = getMaxTime();
_places = (int) Math.ceil(getChallengers().size() / 2D);
Settings.setStartTime(System.currentTimeMillis());
Settings.setMaxCompletedCount((int) Math.ceil(Data.getCurrentPlaying().size() / 2D));
onStart();
}
public boolean canFinish()
{
boolean maxTimeReached = UtilTime.elapsed(_startTime, _duration);
boolean maxTimeReached = UtilTime.elapsed(Settings.getStartTime(), Settings.getDuration());
ArrayList<Player> players = getChallengers();
if (players.size() <= _completed.size()) // 50% done
if (players.size() <= Data.getCompletedPlayers().size()) // 50% done
return true;
if (_type == ChallengeType.LastStanding)
{
if (players.size() <= _places)
if (players.size() <= Settings.getMaxCompletedCount())
{
for (Player player : players)
SetCompleted(player);
@ -189,7 +191,7 @@ public abstract class Challenge implements Listener
}
else if (_type == ChallengeType.FirstComplete)
{
if (_completed.size() >= _places)
if (Data.getCompletedPlayers().size() >= Settings.getMaxCompletedCount())
return true;
}
@ -201,25 +203,25 @@ public abstract class Challenge implements Listener
public void end()
{
if (!_invisPlayers.isEmpty())
for (Player player : _invisPlayers)
if (!Data.getInvisiblePlayers().isEmpty())
for (Player player : Data.getInvisiblePlayers())
Host.Manager.GetCondition().EndCondition(player, ConditionType.CLOAK, "Challenge Ended");
cleanupRoom();
onEnd();
}
public void setCompleted(Player player, boolean invis)
{
if (_completed.contains(player))
if (Data.getCompletedPlayers().contains(player))
return;
if (invis)
{
_invisPlayers.add(player);
Data.addInvisiblePlayer(player);
Host.Manager.GetCondition().Factory().Cloak("Completed", player, player, 7777, true, false);
}
_completed.add(player);
Data.addCompletedPlayer(player);
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cGreen + C.Bold + "You completed the task!");
@ -235,15 +237,15 @@ public abstract class Challenge implements Listener
public void setLost(Player player, boolean invis)
{
if (isDone(player))
if (Data.isDone(player))
return;
if (!Host.isCrumbling())
_lost.add(player);
Data.addLostPlayer(player);
if (invis)
{
_invisPlayers.add(player);
Data.addInvisiblePlayer(player);
Host.Manager.GetCondition().Factory().Cloak("Lost", player, player, 7777, true, false);
}
@ -259,7 +261,7 @@ public abstract class Challenge implements Listener
protected void addBlock(Block block)
{
if (!block.isEmpty())
_modifiedBlocks.add(block);
Data.addModifiedBlock(block);
}
public void setBorder(int minX, int maxX, int minY, int maxY, int minZ, int maxZ)
@ -267,11 +269,11 @@ public abstract class Challenge implements Listener
WorldData data = Host.WorldData;
data.MinX = minX;
data.MaxX = (int) (maxX + _center.getX());
data.MaxX = (int) (maxX + Settings.getMapCenter().getX());
data.MinY = minY;
data.MaxY = (int) (maxY + _center.getY());
data.MaxY = (int) (maxY + Settings.getMapCenter().getY());
data.MinZ = minZ;
data.MaxZ = (int) (maxZ + _center.getZ());
data.MaxZ = (int) (maxZ + Settings.getMapCenter().getZ());
}
protected void displayCount(Player player, Location loc, String string)
@ -315,7 +317,7 @@ public abstract class Challenge implements Listener
if (!Host.IsLive())
return;
if (!_crumble)
if (!Settings.canCrumble())
return;
if (!Host.isCrumbling())
@ -324,13 +326,13 @@ public abstract class Challenge implements Listener
Block qualifiedBlock = null;
double furthestDistance = 0;
if (_modifiedBlocks.isEmpty())
if (Data.getModifiedBlocks().isEmpty())
{
Host.setCrumbling(false);
return;
}
for (Block currentBlock : _modifiedBlocks)
for (Block currentBlock : Data.getModifiedBlocks())
{
double theBlocksDistance = UtilMath.offset2d(Host.GetSpectatorLocation(),
currentBlock.getLocation().add(0.5, 0.5, 0.5));
@ -347,7 +349,7 @@ public abstract class Challenge implements Listener
qualifiedBlock = qualifiedBlock.getRelative(BlockFace.DOWN);
}
_modifiedBlocks.remove(qualifiedBlock);
Data.removeModifiedBlock(qualifiedBlock);
if (UtilMath.r(4) == 0)
{
@ -364,27 +366,12 @@ public abstract class Challenge implements Listener
if (!Host.IsLive())
return;
removeFromLists(event.getPlayer());
}
public void removeFromLists(Player player)
{
if (_lost.contains(player))
_lost.remove(player);
if (_completed.contains(player))
_completed.remove(player);
if (_invisPlayers.contains(player))
_invisPlayers.remove(player);
if (_currentPlaying.contains(player))
_currentPlaying.remove(player);
Data.removePlayer(event.getPlayer());
}
public int getTimeLeft()
{
return (int) ((_duration - (System.currentTimeMillis() - _startTime)) / 1000);
return (int) ((Settings.getDuration() - (System.currentTimeMillis() - Settings.getStartTime())) / 1000);
}
/**
@ -401,13 +388,13 @@ public abstract class Challenge implements Listener
{
ArrayList<Player> currentlyAlive = new ArrayList<Player>();
for (Player player : _currentPlaying)
for (Player player : Data.getCurrentPlaying())
{
if (isLost(player))
if (Data.isLost(player))
continue;
if (ignoreAlreadyWon)
if (isCompleted(player))
if (Data.isCompleted(player))
continue;
currentlyAlive.add(player);
@ -416,34 +403,19 @@ public abstract class Challenge implements Listener
return currentlyAlive;
}
public boolean isCompleted(Player player)
{
return _completed.contains(player);
}
public boolean isDone(Player player)
{
return _completed.contains(player) || _lost.contains(player);
}
public boolean isLost(Player player)
{
return _lost.contains(player);
}
public float getTimeLeftPercent()
{
float a = (float) (_duration - (System.currentTimeMillis() - _startTime));
float b = (float) (_duration);
float a = (float) (Settings.getDuration() - (System.currentTimeMillis() - Settings.getStartTime()));
float b = (float) (Settings.getDuration());
return a / b;
}
public final int getRemainingPlaces()
{
if (_type == ChallengeType.FirstComplete)
return _places - _completed.size();
return Settings.getMaxCompletedCount() - Data.getCompletedPlayers().size();
else if (_type == ChallengeType.LastStanding)
return getChallengers().size() - _places;
return getChallengers().size() - Settings.getMaxCompletedCount();
return 0;
}
@ -452,16 +424,6 @@ public abstract class Challenge implements Listener
{
}
public int getMinPlayers()
{
return 2;
}
public int getMaxPlayers()
{
return 250;
}
public int getArenaSize()
{
return getArenaSize(8);
@ -473,6 +435,16 @@ public abstract class Challenge implements Listener
return size > 40 ? 40 : size;
}
public BawkBawkBattles getHost()
{
return Host;
}
public ChallengeType getType()
{
return _type;
}
public String getName()
{
return _name;
@ -483,6 +455,24 @@ public abstract class Challenge implements Listener
return _description;
}
public Location getCenter()
{
return Settings.getMapCenter();
}
public ChallengeSettings getSettings()
{
return Settings;
}
public ChallengeData getData()
{
return Data;
}
/**
* @deprecated
*/
public String[] getGameMessages()
{
List<String> description = new ArrayList<String>();
@ -496,79 +486,4 @@ public abstract class Challenge implements Listener
return description.toArray(new String[description.size()]);
}
public boolean isTeamBased()
{
return _teamBased;
}
public boolean canCrumble()
{
return _crumble;
}
public ChallengeType getType()
{
return _type;
}
public Location getCenter()
{
return _center.clone();
}
public HashSet<Block> getModifiedBlocks()
{
return _modifiedBlocks;
}
public int getAvailablePlaces()
{
return _places;
}
public long getStartTime()
{
return _startTime;
}
public long getDuration()
{
return _duration;
}
public void setDuration(long duration)
{
_duration = duration;
}
public HashSet<Player> getCompleted()
{
return _completed;
}
public boolean hasAnyoneCompleted()
{
return !_completed.isEmpty();
}
public HashSet<Player> getLost()
{
return _lost;
}
public HashSet<Player> getCurrentPlaying()
{
return _currentPlaying;
}
public boolean shouldCrumble()
{
return _crumble;
}
public long getMaxTime()
{
return 60000;
}
}

View File

@ -0,0 +1,122 @@
package nautilus.game.arcade.game.games.mineware;
import java.util.Collection;
import java.util.HashSet;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
public class ChallengeData
{
private HashSet<Player> _invisible = new HashSet<Player>();
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()
{
_completed.clear();
_lost.clear();
}
public void removePlayer(Player player)
{
if (_lost.contains(player))
_lost.remove(player);
if (_completed.contains(player))
_completed.remove(player);
if (_invisible.contains(player))
_invisible.remove(player);
if (_playing.contains(player))
_playing.remove(player);
}
public boolean isCompleted(Player player)
{
return _completed.contains(player);
}
public boolean isDone(Player player)
{
return _completed.contains(player) || _lost.contains(player);
}
public boolean isLost(Player player)
{
return _lost.contains(player);
}
public void addInvisiblePlayer(Player player)
{
_invisible.add(player);
}
public HashSet<Player> getInvisiblePlayers()
{
return _invisible;
}
public void addModifiedBlock(Block block)
{
_modifiedBlocks.add(block);
}
public void removeModifiedBlock(Block block)
{
_modifiedBlocks.remove(block);
}
public HashSet<Block> getModifiedBlocks()
{
return _modifiedBlocks;
}
public void addCompletedPlayer(Player player)
{
_completed.add(player);
}
public HashSet<Player> getCompletedPlayers()
{
return _completed;
}
public boolean hasAnyoneCompleted()
{
return !_completed.isEmpty();
}
public void addLostPlayer(Player player)
{
_lost.add(player);
}
public HashSet<Player> getLostPlayers()
{
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

@ -128,7 +128,7 @@ public abstract class ChallengeSeperateRooms extends Challenge
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
return new ArrayList<Location>(_spawns.keySet());
}

View File

@ -1,60 +1,135 @@
package nautilus.game.arcade.game.games.mineware;
import org.bukkit.Location;
public class ChallengeSettings
{
private Challenge _challenge;
private int _minPlayers = 2;
private int _maxPlayers = 250;
private Location _mapCenter;
private int _maxCompletedCount;
private long _startTime;
private long _duration = 60000;
private boolean _useMapHeight;
private boolean _lockInventory;
private boolean _teamBased;
private boolean _canCrumble;
private long _duration;
public void setUseMapHeight()
public ChallengeSettings(Challenge challenge)
{
_useMapHeight = true;
_challenge = challenge;
_mapCenter = new Location(_challenge.getHost().WorldData.World, 0, 0, 0);
}
public boolean canUseMapHeight()
public Challenge getChallenge()
{
return _useMapHeight;
return _challenge;
}
public void setLockInventory()
public void setMinPlayers(int minPlayers)
{
_lockInventory = true;
_minPlayers = minPlayers;
}
public boolean isInventoryLocked()
public int getMinPlayers()
{
return _lockInventory;
return _minPlayers;
}
public void setTeamBased()
public void setMaxPlayers(int maxPlayers)
{
_teamBased = true;
_maxPlayers = maxPlayers;
}
public boolean isTeamBased()
public int getMaxPlayers()
{
return _teamBased;
return _maxPlayers;
}
public void setCanCruble()
public void setMapCenter(Location mapCenter)
{
_canCrumble = true;
_mapCenter = mapCenter;
}
public boolean canCrumble()
public Location getMapCenter()
{
return _canCrumble;
return _mapCenter.clone();
}
public void setMaxCompletedCount(int maxCompletedCount)
{
_maxCompletedCount = maxCompletedCount;
}
public int getMaxCompletedCount()
{
return _maxCompletedCount;
}
public void setStartTime(long startTime)
{
_startTime = startTime;
}
public long getStartTime()
{
return _startTime;
}
public void setDuration(long duration)
{
_duration = duration;
}
public long getDuration()
{
return _duration;
}
public void setUseMapHeight()
{
_useMapHeight = true;
// Use map center.
_mapCenter.setX(-1);
_mapCenter.setY(62);
_mapCenter.setZ(10);
}
public boolean canUseMapHeight()
{
return _useMapHeight;
}
public void setLockInventory()
{
_lockInventory = true;
}
public boolean isInventoryLocked()
{
return _lockInventory;
}
public void setTeamBased()
{
_teamBased = true;
}
public boolean isTeamBased()
{
return _teamBased;
}
public void setCanCruble()
{
_canCrumble = true;
}
public boolean canCrumble()
{
return _canCrumble;
}
}

View File

@ -60,14 +60,15 @@ public class ChallengeAnvilDance extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Anvil Dance",
"It's raining anvils!",
"Dodge them to stay alive.");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -81,7 +82,7 @@ public class ChallengeAnvilDance extends Challenge
@SuppressWarnings("deprecation")
@Override
public void generateRoom()
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false, getArenaSize()))
{
@ -98,7 +99,7 @@ public class ChallengeAnvilDance extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
checkInvalidFallingBlocksTask();
startFallingTask();
@ -106,7 +107,7 @@ public class ChallengeAnvilDance extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
if (_fireworkTask != null)
_fireworkTask.cancel();
@ -353,7 +354,7 @@ public class ChallengeAnvilDance extends Challenge
{
Player player = (Player) entity;
if (isDone(player))
if (Data.isDone(player))
return;
if (!Host.IsAlive(player))
return;

View File

@ -42,18 +42,18 @@ public class ChallengeArrowRampage extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Arrow Rampage",
false,
true,
"You are equipped with explosive arrows.",
"Force your enemy into the void!");
Settings.setUseMapHeight();
Settings.setCanCruble();
_antiHackFix = new AntiHackFix(this);
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -71,34 +71,7 @@ public class ChallengeArrowRampage extends Challenge
}
@Override
public void cleanupRoom()
{
for (Player player : Host.GetPlayers(true))
{
player.getInventory().clear();
player.removePotionEffect(PotionEffectType.JUMP);
}
_antiHackFix.clear();
Host.StrictAntiHack = true;
}
@Override
public void setupPlayers()
{
for (Player player : Host.GetPlayers(true))
{
player.getInventory()
.addItem(new ItemBuilder(Material.BOW).addEnchantment(Enchantment.ARROW_INFINITE, 1).build());
player.getInventory().addItem(new ItemStack(Material.ARROW));
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 2));
}
Host.StrictAntiHack = false;
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(9); x <= getArenaSize(9); x++)
{
@ -139,6 +112,33 @@ public class ChallengeArrowRampage extends Challenge
}
}
@Override
public void onStart()
{
for (Player player : Host.GetPlayers(true))
{
player.getInventory()
.addItem(new ItemBuilder(Material.BOW).addEnchantment(Enchantment.ARROW_INFINITE, 1).build());
player.getInventory().addItem(new ItemStack(Material.ARROW));
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 2));
}
Host.StrictAntiHack = false;
}
@Override
public void onEnd()
{
for (Player player : Host.GetPlayers(true))
{
player.getInventory().clear();
player.removePotionEffect(PotionEffectType.JUMP);
}
_antiHackFix.clear();
Host.StrictAntiHack = true;
}
@EventHandler
public void onChallengeEnd(ChallengeEndEvent event)
{

View File

@ -38,14 +38,15 @@ public class ChallengeBlockLobbers extends Challenge
{
super(
host, ChallengeType.LastStanding,
true,
"Block Lobbers",
"Throw blocks to other players.",
"Try to knock them off the platform!");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -58,7 +59,7 @@ public class ChallengeBlockLobbers extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Entity fallingBlocks : Host.WorldData.World.getEntities())
{
@ -70,13 +71,7 @@ public class ChallengeBlockLobbers extends Challenge
}
@Override
public void setupPlayers()
{
}
@Override
public void generateRoom()
public void createMap()
{
for (Location locs : UtilShapes.getCircle(getCenter(), false, 11))
{
@ -102,7 +97,7 @@ public class ChallengeBlockLobbers extends Challenge
{
Material pickedMat = _tBlocks.get(UtilMath.r(_tBlocks.size()));
if (isDone(players))
if (Data.isDone(players))
{
continue;
}
@ -141,7 +136,7 @@ public class ChallengeBlockLobbers extends Challenge
{
return;
}
if (isDone(event.getPlayer()))
if (Data.isDone(event.getPlayer()))
{
return;
}
@ -198,7 +193,7 @@ public class ChallengeBlockLobbers extends Challenge
// block.setType(Material.AIR);
return;
}
if (isCompleted((Player) target))
if (Data.isCompleted((Player) target))
{
return;
}

View File

@ -43,17 +43,17 @@ public class ChallengeBouncingBlock extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Bouncing Block",
"Jump and punch floating wool blocks.",
"Avoid landing on red wool.",
"First to 10 wins!");
Settings.setUseMapHeight();
_antiHackFix = new AntiHackFix(this);
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -66,7 +66,7 @@ public class ChallengeBouncingBlock extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Player player : Host.GetPlayers(true))
player.removePotionEffect(PotionEffectType.JUMP);
@ -82,7 +82,7 @@ public class ChallengeBouncingBlock extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player player : Host.GetPlayers(true))
{
@ -95,7 +95,7 @@ public class ChallengeBouncingBlock extends Challenge
@SuppressWarnings("deprecation")
@Override
public void generateRoom()
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false,
getArenaSize(9)))
@ -127,7 +127,7 @@ public class ChallengeBouncingBlock extends Challenge
if (!Host.IsAlive(event.getPlayer()))
return;
if (isDone(event.getPlayer()))
if (Data.isDone(event.getPlayer()))
return;
if (event.getClickedBlock() == null || event.getClickedBlock().getType() == Material.AIR)
@ -162,7 +162,7 @@ public class ChallengeBouncingBlock extends Challenge
for (Player player : Host.GetPlayers(true))
{
if (isDone(player))
if (Data.isDone(player))
continue;
UtilTextBottom.display(C.Bold + "Score: " + C.Reset + C.cYellow + C.Bold + _playerScore.get(player),
@ -178,7 +178,7 @@ public class ChallengeBouncingBlock extends Challenge
Player player = event.getPlayer();
if (isDone(player))
if (Data.isDone(player))
return;
if (event.getFrom().getX() == event.getTo().getX() && event.getFrom().getZ() == event.getTo().getZ())

View File

@ -48,14 +48,15 @@ public class ChallengeBuildRace extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Build Race",
"Your inventory is filled with blocks.",
"Place them all in the ground!");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -68,7 +69,7 @@ public class ChallengeBuildRace extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false, getArenaSize()))
{
@ -81,7 +82,7 @@ public class ChallengeBuildRace extends Challenge
@SuppressWarnings("deprecation")
@Override
public void setupPlayers()
public void onStart()
{
for (Material allowed : _materials)
{
@ -96,7 +97,7 @@ public class ChallengeBuildRace extends Challenge
@SuppressWarnings("deprecation")
@Override
public void cleanupRoom()
public void onEnd()
{
for (Material allowed : _materials)
{
@ -112,10 +113,10 @@ public class ChallengeBuildRace extends Challenge
Player player = event.getPlayer();
if (isDone(player))
if (Data.isDone(player))
return;
if (isCompleted(player))
if (Data.isCompleted(player))
{
event.setCancelled(true);
return;

View File

@ -26,13 +26,14 @@ public class ChallengeChestLoot extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Diamond Seeker",
"Find a diamond in the chests.");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -51,14 +52,14 @@ public class ChallengeChestLoot extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.InventoryOpenChest = false;
Host.InventoryOpenBlock = false;
}
@Override
public void setupPlayers()
public void onStart()
{
Host.InventoryOpenChest = true;
Host.InventoryOpenBlock = true;
@ -83,7 +84,7 @@ public class ChallengeChestLoot extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
ArrayList<Inventory> invs = new ArrayList<Inventory>();

View File

@ -30,7 +30,7 @@ public class ChallengeCloudFall extends Challenge
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -64,20 +64,20 @@ public class ChallengeCloudFall extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.DamageFall = false;
}
@Override
public void setupPlayers()
public void onStart()
{
Host.DamageFall = true;
}
@SuppressWarnings("deprecation")
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
@ -154,7 +154,7 @@ public class ChallengeCloudFall extends Challenge
{
return;
}
if (isDone(event.GetDamageePlayer()))
if (Data.isDone(event.GetDamageePlayer()))
{
return;
}

View File

@ -45,16 +45,19 @@ public class ChallengeDogsVersusCats extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Dogs Vs Cats",
"If you are a dog, bark.",
"If you are a cat, meow.",
"Look up and punch to bark or meow.",
"First team to the end number wins!");
Settings.setUseMapHeight();
Settings.setTeamBased();
Settings.setDuration(75000);
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -72,7 +75,7 @@ public class ChallengeDogsVersusCats extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Player player : UtilServer.getPlayers())
{
@ -84,13 +87,7 @@ public class ChallengeDogsVersusCats extends Challenge
}
@Override
public long getMaxTime()
{
return 75000;
};
@Override
public void setupPlayers()
public void onStart()
{
int looped = 0;
@ -126,15 +123,9 @@ public class ChallengeDogsVersusCats extends Challenge
}
}
@Override
public int getMinPlayers()
{
return 2;
};
@SuppressWarnings("deprecation")
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
@ -237,7 +228,7 @@ public class ChallengeDogsVersusCats extends Challenge
{
return;
}
if (isCompleted(event.getPlayer()))
if (Data.isCompleted(event.getPlayer()))
{
return;
}

View File

@ -34,13 +34,14 @@ public class ChallengeDragonEgg extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Dragon Egg",
"Whack a dragon egg 10 times.");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -129,7 +130,7 @@ public class ChallengeDragonEgg extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Entity ent : _dragonEggs)
{
@ -138,7 +139,7 @@ public class ChallengeDragonEgg extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
setBorder(-18, 18, 0, 20, -18, 18);
@ -151,7 +152,7 @@ public class ChallengeDragonEgg extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{

View File

@ -83,17 +83,18 @@ public class ChallengeFallingBlocks extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Falling Blocks",
"Blocks are falling from the sky!",
"Try to avoid getting hit.");
Settings.setUseMapHeight();
_time = (int) _nextWave;
_modifiedSpawnChance = _spawnChance;
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -107,7 +108,7 @@ public class ChallengeFallingBlocks extends Challenge
@SuppressWarnings("deprecation")
@Override
public void generateRoom()
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false, getArenaSize()))
{
@ -128,14 +129,14 @@ public class ChallengeFallingBlocks extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
startWavesTask();
startWaveTimerTask();
}
@Override
public void cleanupRoom()
public void onEnd()
{
_time = 0;
_wavesCompleted = 0;
@ -329,7 +330,7 @@ public class ChallengeFallingBlocks extends Challenge
{
Player player = (Player) entity;
if (isDone(player))
if (Data.isDone(player))
return;
if (!Host.IsAlive(player))
return;

View File

@ -57,15 +57,16 @@ public class ChallengeFastFood extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Fast Food",
"Your inventory is full of food.",
"Punch to throw it in the ground.",
"First player to drop them all wins!");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -78,7 +79,7 @@ public class ChallengeFastFood extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false, getArenaSize()))
{
@ -90,7 +91,7 @@ public class ChallengeFastFood extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
itemParticleTask();
@ -104,7 +105,7 @@ public class ChallengeFastFood extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
_itemSeperator = 0;
@ -125,7 +126,7 @@ public class ChallengeFastFood extends Challenge
Player player = event.getPlayer();
if (UtilEvent.isAction(event, ActionType.L) && !isDone(player))
if (UtilEvent.isAction(event, ActionType.L) && !Data.isDone(player))
{
if (event.getItem() != null)
{

View File

@ -54,14 +54,15 @@ public class ChallengeFishingDay extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Fishing Day",
"Be the first to catch 5 fish.",
"Watch out for TNT if you miss the fish!");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
int size = getArenaSize();
ArrayList<Location> spawns = new ArrayList<Location>();
@ -85,7 +86,7 @@ public class ChallengeFishingDay extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
int size = getArenaSize();
@ -129,7 +130,7 @@ public class ChallengeFishingDay extends Challenge
}
else
{
if (y == 5 && !getSpawns().contains(block.getLocation()))
if (y == 5 && !createSpawns().contains(block.getLocation()))
{
block.setType(Material.GRASS);
@ -171,7 +172,7 @@ public class ChallengeFishingDay extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
Host.DamageEvP = false;
Host.ItemPickup = true;
@ -188,7 +189,7 @@ public class ChallengeFishingDay extends Challenge
for (Player player : Host.GetPlayers(true))
{
if (isDone(player))
if (Data.isDone(player))
continue;
player.getInventory().setItem(_fishingRodSlot, itemStack);
@ -197,7 +198,7 @@ public class ChallengeFishingDay extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.DamageEvP = false;
Host.ItemPickup = false;
@ -221,7 +222,7 @@ public class ChallengeFishingDay extends Challenge
{
Player fisher = event.getPlayer();
if (isDone(fisher) || !Host.IsLive() || !Host.isChallengeStarted())
if (Data.isDone(fisher) || !Host.IsLive() || !Host.isChallengeStarted())
return;
Fish hook = event.getHook();
@ -283,7 +284,7 @@ public class ChallengeFishingDay extends Challenge
if (!Host.IsLive() || !Host.isChallengeStarted())
return;
if (!isDone(event.getPlayer()))
if (!Data.isDone(event.getPlayer()))
{
event.setCancelled(true);
}
@ -295,7 +296,7 @@ public class ChallengeFishingDay extends Challenge
if (!Host.IsLive() || !Host.isChallengeStarted())
return;
if (!isDone(event.getPlayer()))
if (!Data.isDone(event.getPlayer()))
{
if (Math.random() * 100 < 20)
{

View File

@ -38,16 +38,16 @@ public class ChallengeInfestation extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Infestation",
"Avoid the deadly zombie.",
"The infected can kill humans!");
Settings.setUseMapHeight();
_zombie.setSpeed(1.5F);
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -61,7 +61,7 @@ public class ChallengeInfestation extends Challenge
@SuppressWarnings("deprecation")
@Override
public void generateRoom()
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false, getArenaSize(15)))
{
@ -73,7 +73,7 @@ public class ChallengeInfestation extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
Host.CreatureAllowOverride = true;
_zombie.spawn();
@ -93,7 +93,7 @@ public class ChallengeInfestation extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Player player : Host.GetPlayers(false))
{
@ -163,7 +163,7 @@ public class ChallengeInfestation extends Challenge
if ((!(event.GetDamagerEntity(false) instanceof Player)))
return;
if (isCompleted(event.GetDamageePlayer()))
if (Data.isCompleted(event.GetDamageePlayer()))
{
event.SetCancelled("Player already finished");
return;

View File

@ -33,14 +33,15 @@ public class ChallengeKangarooJump extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Kangaroo Jump",
"Jump from block to block.",
"Player with the highest height wins!");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -58,13 +59,13 @@ public class ChallengeKangarooJump extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.StrictAntiHack = true;
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player player : Host.GetPlayers(true))
{
@ -75,7 +76,7 @@ public class ChallengeKangarooJump extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
@ -163,7 +164,7 @@ public class ChallengeKangarooJump extends Challenge
{
return;
}
if (isLost(player))
if (Data.isLost(player))
{
_playerJumpHeight.remove(player);
}
@ -204,7 +205,7 @@ public class ChallengeKangarooJump extends Challenge
for (int i = 0; i < (sortedList.size()); i++)
{
System.out.println(sortedList.get(i));
if (!isDone(Bukkit.getPlayer(sortedList.get(i))))
if (!Data.isDone(Bukkit.getPlayer(sortedList.get(i))))
{
if (i < (sortedList.size() / 2))
{

View File

@ -35,21 +35,23 @@ public class ChallengeKingOfTheHill extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"King Of The Ladder",
"Reach the top of the ladder.");
Settings.setUseMapHeight();
Settings.setMaxPlayers(15);
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++)
for (int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++)
{
for(int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
for (int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{
if(x % 2 == 0 && z % 2 == 0)
if (x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
}
@ -60,17 +62,11 @@ public class ChallengeKingOfTheHill extends Challenge
}
@Override
public int getMaxPlayers()
{
return 15;
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.DamagePvP = false;
for(int h = 0; h < 30; h++)
for (int h = 0; h < 30; h++)
{
getCenter().getBlock().getRelative(0, h, 0).setType(Material.AIR);
}
@ -83,9 +79,9 @@ public class ChallengeKingOfTheHill extends Challenge
{
List<Entity> drops = Host.WorldData.World.getEntities();
for(Entity ent : drops)
for (Entity ent : drops)
{
if(ent instanceof Item)
if (ent instanceof Item)
{
ent.remove();
}
@ -96,9 +92,9 @@ public class ChallengeKingOfTheHill extends Challenge
List<Entity> drops = Host.WorldData.World.getEntities();
for(Entity ent : drops)
for (Entity ent : drops)
{
if(ent instanceof Item)
if (ent instanceof Item)
{
ent.remove();
}
@ -106,35 +102,35 @@ public class ChallengeKingOfTheHill extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
for(Player player : getChallengers())
for (Player player : getChallengers())
{
player.getInventory().setItem(0,
new ItemBuilder(Material.STICK).addEnchantment(Enchantment.KNOCKBACK, 5).addLore(C.cPurple + "One strong stick!").build());
new ItemBuilder(Material.STICK).addEnchantment(Enchantment.KNOCKBACK, 5).addLore(C.cPurple + "One strong stick!").build());
}
Host.DamagePvP = true;
}
@SuppressWarnings("deprecation")
@Override
public void generateRoom()
public void createMap()
{
for(int x = -getArenaSize(); x <= getArenaSize(); x++)
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
for (int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 1; y++)
for (int y = 0; y <= 1; y++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
if (y == 0)
{
b.setType(Material.GRASS);
}
if(x == 0 && z == 0 && y == 0)
if (x == 0 && z == 0 && y == 0)
{
for(int h = 1; h <= 20; h++)
for (int h = 1; h <= 20; h++)
{
Block ladder = getCenter().getBlock().getRelative(x, h, z);
ladder.setType(Material.STONE);
@ -147,12 +143,12 @@ public class ChallengeKingOfTheHill extends Challenge
}
else
{
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
if (Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
{
b.setType(Material.FENCE);
}
}
if(b.getType() != Material.AIR)
if (b.getType() != Material.AIR)
{
addBlock(b);
}
@ -164,23 +160,23 @@ public class ChallengeKingOfTheHill extends Challenge
@EventHandler
public void checkWinners(UpdateEvent event)
{
if(event.getType() != UpdateType.TICK)
if (event.getType() != UpdateType.TICK)
{
return;
}
if(!Host.IsLive())
if (!Host.IsLive())
{
return;
}
for(Player player : Host.GetPlayers(true))
for (Player player : Host.GetPlayers(true))
{
if(isCompleted(player))
if (Data.isCompleted(player))
{
continue;
}
if(UtilAlg.inBoundingBox(player.getLocation(), _winCornerA, _winCornerB))
if (UtilAlg.inBoundingBox(player.getLocation(), _winCornerA, _winCornerB))
{
setCompleted(player, true);
}
@ -190,34 +186,34 @@ public class ChallengeKingOfTheHill extends Challenge
@EventHandler
public void onPvp(CustomDamageEvent event)
{
if(!Host.IsLive())
if (!Host.IsLive())
{
return;
}
if(event.GetDamageePlayer() == null)
if (event.GetDamageePlayer() == null)
{
return;
}
if(isCompleted(event.GetDamagerPlayer(false)))
if (Data.isCompleted(event.GetDamagerPlayer(false)))
{
event.SetCancelled("Player already completed");
return;
}
if(event.GetCause() == DamageCause.FALL)
if (event.GetCause() == DamageCause.FALL)
{
event.SetCancelled("Fall damage");
}
}
@EventHandler
public void resetPlayerHealth(UpdateEvent event)
{
if(event.getType() != UpdateType.SEC)
if (event.getType() != UpdateType.SEC)
{
for(Player player : Host.GetPlayers(true))
for (Player player : Host.GetPlayers(true))
{
player.setHealth(20);
}

View File

@ -37,15 +37,17 @@ public class ChallengeLavaRun extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Lava Run",
"The lava is coming!",
"Stand on the obsidian.",
"Run! Run! Run!");
Settings.setUseMapHeight();
Settings.setMaxPlayers(30);
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
int size = getArenaSize() - 3;
@ -62,7 +64,7 @@ public class ChallengeLavaRun extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
@ -98,12 +100,6 @@ public class ChallengeLavaRun extends Challenge
return block;
}
@Override
public int getMaxPlayers()
{
return 30;
}
@EventHandler
public void onDamage(CustomDamageEvent event)
{
@ -199,12 +195,7 @@ public class ChallengeLavaRun extends Challenge
}
@Override
public void cleanupRoom()
{
}
@Override
public void setupPlayers()
public void onStart()
{
_delay = System.currentTimeMillis() + 2000;
int size = getArenaSize() + 3;

View File

@ -45,14 +45,15 @@ public class ChallengeMilkACow extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Milk a Cow",
"Milk 5 different cows.",
"Deliver the milk to the villager!");
Settings.setUseMapHeight();
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Entity cow : _milked.keySet())
{
@ -84,7 +85,7 @@ public class ChallengeMilkACow extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player player : Host.GetPlayers(true))
{
@ -97,7 +98,7 @@ public class ChallengeMilkACow extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
@ -288,7 +289,7 @@ public class ChallengeMilkACow extends Challenge
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();

View File

@ -29,13 +29,14 @@ public class ChallengeMineADiamond extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Mine a Diamond",
"Find a diamond around the map.");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -53,13 +54,13 @@ public class ChallengeMineADiamond extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.BlockBreak = false;
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player player : Host.GetPlayers(true))
{
@ -74,7 +75,7 @@ public class ChallengeMineADiamond extends Challenge
@SuppressWarnings("deprecation")
@Override
public void generateRoom()
public void createMap()
{
int amountOfDiamonds = 0;
@ -157,7 +158,7 @@ public class ChallengeMineADiamond extends Challenge
{
return;
}
if (isCompleted(event.getPlayer()))
if (Data.isCompleted(event.getPlayer()))
{
event.setCancelled(true);
return;

View File

@ -47,14 +47,15 @@ public class ChallengeMinecartDance extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Musical Minecart",
"Get ready when the fireworks change color.",
"Once they're green, get inside a minecart!");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -72,7 +73,7 @@ public class ChallengeMinecartDance extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
if (_isPlayingMusic)
{
@ -92,13 +93,13 @@ public class ChallengeMinecartDance extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
_timeSinceLastState = System.currentTimeMillis();
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
@ -322,7 +323,7 @@ public class ChallengeMinecartDance extends Challenge
return;
}
Player player = (Player) event.getEntered();
if (isLost(player) || !Host.IsPlaying(player))
if (Data.isLost(player) || !Host.IsPlaying(player))
{
event.setCancelled(true);
}

View File

@ -31,17 +31,17 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Mini OITQ",
false,
true,
"Shoot arrows to instant kill others.",
"Avoid getting hit by them.",
"Arrow supply every 4 seconds.");
Settings.setUseMapHeight();
Settings.setCanCruble();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -59,7 +59,7 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.DamagePvP = false;
Host.DamagePvE = false;
@ -74,7 +74,7 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player player : Host.GetPlayers(true))
{
@ -86,7 +86,7 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
@ -112,7 +112,7 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
{
if (UtilMath.r(8) == 0)
{
for (Location spawns : getSpawns())
for (Location spawns : createSpawns())
{
if (spawns.getBlockX() == b.getLocation().getBlockX() && spawns.getBlockZ() == b.getLocation().getBlockZ())
{
@ -152,7 +152,7 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
}
for (Player player : Host.GetPlayers(true))
{
if (isLost(player))
if (Data.isLost(player))
{
continue;
}
@ -183,7 +183,7 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
Arrow arrow = (Arrow) event.getDamager();
Player shooter = (Player) arrow.getShooter();
Player damaged = (Player) event.getEntity();
if (isLost(shooter) || !Host.IsPlaying(shooter) || shooter.equals(damaged))
if (Data.isLost(shooter) || !Host.IsPlaying(shooter) || shooter.equals(damaged))
{
event.setCancelled(true);
return;

View File

@ -25,13 +25,14 @@ public class ChallengeNavigateMaze extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Nagivation Maze",
"Go to the other side of the maze.");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -51,7 +52,7 @@ public class ChallengeNavigateMaze extends Challenge
{
return;
}
if (isDone(event.getPlayer()))
if (Data.isDone(event.getPlayer()))
{
return;
}
@ -64,18 +65,13 @@ public class ChallengeNavigateMaze extends Challenge
}
@Override
public void cleanupRoom()
{
}
@Override
public void setupPlayers()
public void onStart()
{
setBorder(-20, 22, 0, 10, -20, 22);
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -18; x <= 21; x++)
{

View File

@ -32,10 +32,11 @@ public class ChallengePickASide extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Pick a Side",
"The side with the smallest amount of players wins.",
"Standing in the middle does not work.");
Settings.setUseMapHeight();
}
public int getMinPlayers()
@ -44,7 +45,7 @@ public class ChallengePickASide extends Challenge
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -62,13 +63,9 @@ public class ChallengePickASide extends Challenge
return spawns;
}
@Override
public void cleanupRoom()
{
}
@Override
public void setupPlayers()
public void onStart()
{
setBorder(-10, 10, 0, 10, -10, 10);
}
@ -112,7 +109,7 @@ public class ChallengePickASide extends Challenge
{
for (Player player : Host.GetPlayers(true))
{
if (isCompleted(player))
if (Data.isCompleted(player))
{
continue;
}
@ -200,7 +197,7 @@ public class ChallengePickASide extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -10; x <= 10; x++)
{

View File

@ -34,13 +34,14 @@ public class ChallengePunchThePig extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Punch the Pig",
"Kill 5 pigs.");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -58,7 +59,7 @@ public class ChallengePunchThePig extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Pig pigs : _pigs)
{
@ -73,7 +74,7 @@ public class ChallengePunchThePig extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
for (int i = 0; i <= Math.round((Host.GetPlayers(true).size()) * 5); i++)
{
@ -98,7 +99,7 @@ public class ChallengePunchThePig extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
@ -146,7 +147,7 @@ public class ChallengePunchThePig extends Challenge
if (event.GetDamageeEntity() instanceof Pig)
{
if (isCompleted(event.GetDamagerPlayer(false)))
if (Data.isCompleted(event.GetDamagerPlayer(false)))
{
event.SetCancelled("Player already completed");
return;
@ -206,7 +207,7 @@ public class ChallengePunchThePig extends Challenge
for (Player player : Host.GetPlayers(true))
{
if (isCompleted(player))
if (Data.isCompleted(player))
{
return;
}

View File

@ -52,15 +52,16 @@ public class ChallengeRedLightGreenLight extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Red Light, Green Light",
"Be the first to reach the end.",
"You can move when the fireworks are green.",
"Stay still when the fireworks turn red.");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -78,7 +79,7 @@ public class ChallengeRedLightGreenLight extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
_host.remove();
@ -93,7 +94,7 @@ public class ChallengeRedLightGreenLight extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
changeMoveState(true);
@ -104,7 +105,7 @@ public class ChallengeRedLightGreenLight extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
int var = 1;
int colorPicker = 0;
@ -158,7 +159,7 @@ public class ChallengeRedLightGreenLight extends Challenge
{
return;
}
if (isDone(event.getPlayer()) || !Host.IsPlaying(event.getPlayer()))
if (Data.isDone(event.getPlayer()) || !Host.IsPlaying(event.getPlayer()))
{
return;
}

View File

@ -44,14 +44,15 @@ public class ChallengeReverseTag extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Reverse Tag",
"Punch a sparkling person to become one.",
"Stay sparkling until the end.");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -69,13 +70,13 @@ public class ChallengeReverseTag extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.DamagePvP = false;
}
@Override
public void setupPlayers()
public void onStart()
{
_endTime = System.currentTimeMillis() + ((UtilMath.r(5) + 20) * 1000);
_startTime = System.currentTimeMillis();
@ -97,7 +98,7 @@ public class ChallengeReverseTag extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
int random = UtilMath.r(16);

View File

@ -31,20 +31,21 @@ public class ChallengeRunner extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Runner",
"Blocks below your feet are falling.",
"Run as fast as you can!");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
return _spawns;
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Entity ent : _fallingBlocks)
{
@ -52,15 +53,10 @@ public class ChallengeRunner extends Challenge
}
}
@Override
public void setupPlayers()
{
}
private ArrayList<Location> _spawns = new ArrayList<Location>();
@Override
public void generateRoom()
public void createMap()
{
int amount = (int) Math.ceil(Math.sqrt(getChallengers().size()));
int a = UtilMath.r(16);

View File

@ -30,16 +30,17 @@ public class ChallengeRushPush extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Rush Push",
true,
true,
"Rush to your enemy.",
"Push them off the platform.");
Settings.setUseMapHeight();
Settings.setTeamBased();
Settings.setCanCruble();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> locations = new ArrayList<Location>();
@ -58,13 +59,13 @@ public class ChallengeRushPush extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.DamagePvP = false;
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player player : Host.GetPlayers(true))
{
@ -95,7 +96,7 @@ public class ChallengeRushPush extends Challenge
// z < 1 = blue z > 1 = red; z ~ 0 = misc;
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
@ -153,7 +154,7 @@ public class ChallengeRushPush extends Challenge
{
return;
}
if (isLost(event.GetDamagerPlayer(false)))
if (Data.isLost(event.GetDamagerPlayer(false)))
{
event.SetCancelled("Player out of the game");
return;

View File

@ -43,14 +43,15 @@ public class ChallengeShootChickens extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Chicken Shooting",
"Shoot 6 chickens.",
"When a chicken lands, it dissapears.");
Settings.setUseMapHeight();
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Chicken chicken : _chickens)
{
@ -74,7 +75,7 @@ public class ChallengeShootChickens extends Challenge
Arrow arrow = (Arrow) event.getEntity();
Player player = (Player) arrow.getShooter();
if (!isDone(player))
if (!Data.isDone(player))
{
_arrowsShot.put(player, _arrowsShot.get(player) + 1);
}
@ -185,7 +186,7 @@ public class ChallengeShootChickens extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
setBorder(-10, 10, 0, 10, -10, 10);
@ -203,7 +204,7 @@ public class ChallengeShootChickens extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
@ -247,7 +248,7 @@ public class ChallengeShootChickens extends Challenge
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();

View File

@ -21,21 +21,21 @@ public class ChallengeSmashOff extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Smash Off",
false,
true,
"Knock all others off the platform.");
Settings.setUseMapHeight();
Settings.setCanCruble();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
return _spawns;
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.DamagePvP = false;
@ -46,13 +46,13 @@ public class ChallengeSmashOff extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
Host.DamagePvP = true;
}
@Override
public void generateRoom()
public void createMap()
{
int amount = (int) Math.ceil(Math.sqrt(getChallengers().size()));
int a = UtilMath.r(16);

View File

@ -23,13 +23,14 @@ public class ChallengeSpleef extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Spleef",
"Destroy the blocks beneath other players!");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -45,12 +46,12 @@ public class ChallengeSpleef extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
}
@Override
public void setupPlayers()
public void onStart()
{
}
@ -74,7 +75,7 @@ public class ChallengeSpleef extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -15; x <= 15; x++)
{

View File

@ -37,9 +37,10 @@ public class ChallengeStandOnColor extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Color Change",
"Stand on the correct color.");
Settings.setUseMapHeight();
for (int i = 0; i <= 15; i++)
{
@ -54,7 +55,7 @@ public class ChallengeStandOnColor extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Player player : Host.GetPlayers(true))
{
@ -100,14 +101,14 @@ public class ChallengeStandOnColor extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
setBorder(-20, 20, 0, 10, -20, 20);
generateFloor();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -202,7 +203,7 @@ public class ChallengeStandOnColor extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
_stageExpires = System.currentTimeMillis() + _timeDelay;
_currentColor = _colors.get(UtilMath.r(_colors.size()));

View File

@ -38,22 +38,22 @@ public class ChallengeTntLauncher extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Deadly TNT",
false,
true,
"Throw TNT to other players.",
"Do not get knocked off.");
Settings.setUseMapHeight();
Settings.setCanCruble();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
return _spawns;
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.Damage = true;
@ -73,12 +73,12 @@ public class ChallengeTntLauncher extends Challenge
return;
HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getLocation(),
4 + ((System.currentTimeMillis() - getStartTime()) / 10000D));
4 + ((System.currentTimeMillis() - Settings.getStartTime()) / 10000D));
for (Player player : players.keySet())
{
double mult = players.get(player) / 2;
mult += (System.currentTimeMillis() - getStartTime()) / 20000D;
mult += (System.currentTimeMillis() - Settings.getStartTime()) / 20000D;
// Knockback
UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 3 * mult, false, 0,
@ -111,13 +111,13 @@ public class ChallengeTntLauncher extends Challenge
TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class);
UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.6, false, 0, 0.2, 1, false);
tnt.setFuseTicks((int) (60 * (1 - ((System.currentTimeMillis() - getStartTime()) / 70000))));
tnt.setFuseTicks((int) (60 * (1 - ((System.currentTimeMillis() - Settings.getStartTime()) / 70000))));
_tnt.add(tnt);
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player player : getChallengers())
{
@ -126,7 +126,7 @@ public class ChallengeTntLauncher extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
double radius = 6 + (getChallengers().size() / 2D);

View File

@ -38,11 +38,13 @@ public class ChallengeTreasureDigger extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Treasure Digger",
"Search for treasure below the sand.",
"Find weapons to kill the others!");
Settings.setUseMapHeight();
Settings.setMinPlayers(4);
_lootChance.put(Material.BONE, 20.0);
_lootChance.put(Material.STRING, 20.0);
@ -84,7 +86,7 @@ public class ChallengeTreasureDigger extends Challenge
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -103,7 +105,7 @@ public class ChallengeTreasureDigger extends Challenge
@SuppressWarnings("deprecation")
@Override
public void generateRoom()
public void createMap()
{
Location center = getCenter();
@ -172,7 +174,7 @@ public class ChallengeTreasureDigger extends Challenge
{
Block below = block.getRelative(BlockFace.DOWN);
if (chance < 1.5 && !getSpawns().contains(block.getLocation()) && below.getType() == Material.SAND)
if (chance < 1.5 && !createSpawns().contains(block.getLocation()) && below.getType() == Material.SAND)
{
block.setType(Material.DEAD_BUSH);
}
@ -184,7 +186,7 @@ public class ChallengeTreasureDigger extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
Host.DamagePvP = true;
Host.InventoryOpenChest = true;
@ -203,7 +205,7 @@ public class ChallengeTreasureDigger extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.DamagePvP = true;
Host.InventoryOpenChest = false;
@ -247,7 +249,7 @@ public class ChallengeTreasureDigger extends Challenge
Player damager = (Player) event.getDamager();
ItemStack item = damager.getItemInHand();
if (isDone(damager))
if (Data.isDone(damager))
return;
if (item != null)
@ -334,10 +336,4 @@ public class ChallengeTreasureDigger extends Challenge
{
return _lootChance.get(loot);
}
@Override
public int getMinPlayers()
{
return 4;
}
}

View File

@ -55,13 +55,15 @@ public class ChallengeVolleyPig extends Challenge
super(
host,
ChallengeType.FirstComplete,
true,
"Volley Pig",
"Punch the pig on the enemy side.");
Settings.setUseMapHeight();
Settings.setMaxPlayers(25);
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> locations = new ArrayList<Location>();
@ -80,14 +82,14 @@ public class ChallengeVolleyPig extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
_pig.remove();
Host.DamagePvE = false;
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player player : getChallengers())
{
@ -115,12 +117,6 @@ public class ChallengeVolleyPig extends Challenge
Host.DamagePvE = true;
}
@Override
public int getMaxPlayers()
{
return 25;
}
@EventHandler(priority = EventPriority.LOW)
public void onMove(PlayerMoveEvent event)
{
@ -200,9 +196,9 @@ public class ChallengeVolleyPig extends Challenge
displayProgress();
if (!_pig.isValid() || UtilTime.elapsed(getStartTime(), 30000) || _redSide > 10000 || _blueSide > 10000)
if (!_pig.isValid() || UtilTime.elapsed(Settings.getStartTime(), 30000) || _redSide > 10000 || _blueSide > 10000)
{
setDuration(0); // Instant game over
Settings.setDuration(0); // Instant game over.
for (Player player : getChallengers())
{
@ -254,7 +250,7 @@ public class ChallengeVolleyPig extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
Host.CreatureAllowOverride = true;

View File

@ -47,14 +47,15 @@ public class ChallengeWaterHorror extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Water Horror",
"TNT is spawning from the water!",
"Use your boat to dodge explosions.");
Settings.setCanCruble();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
int size = getArenaSize();
ArrayList<Location> spawns = new ArrayList<Location>();
@ -78,7 +79,7 @@ public class ChallengeWaterHorror extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
int size = getArenaSize();
@ -156,7 +157,7 @@ public class ChallengeWaterHorror extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
Host.getArcadeManager().GetExplosion().SetLiquidDamage(false);
@ -173,7 +174,7 @@ public class ChallengeWaterHorror extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.getArcadeManager().GetExplosion().SetLiquidDamage(true);
@ -284,7 +285,7 @@ public class ChallengeWaterHorror extends Challenge
Player player = event.getEntity();
if (isDone(player))
if (Data.isDone(player))
return;
player.eject();
@ -303,7 +304,7 @@ public class ChallengeWaterHorror extends Challenge
Player player = event.getPlayer();
if (isDone(player))
if (Data.isDone(player))
return;
player.eject();

View File

@ -37,13 +37,14 @@ public class ChallengeWaveCrush extends Challenge
super(
host,
ChallengeType.LastStanding,
true,
"Wave Crush",
"Avoid the crushing waves.");
Settings.setUseMapHeight();
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -61,7 +62,7 @@ public class ChallengeWaveCrush extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
_inProgress = false;
@ -75,7 +76,7 @@ public class ChallengeWaveCrush extends Challenge
{
if (b.getType() != Material.AIR)
{
if (!getModifiedBlocks().contains(b))
if (!Data.getModifiedBlocks().contains(b))
{
b.setType(Material.AIR);
}
@ -87,7 +88,7 @@ public class ChallengeWaveCrush extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player player : Host.GetPlayers(true))
{
@ -124,7 +125,7 @@ public class ChallengeWaveCrush extends Challenge
for (Player player : _survivedWaves.keySet())
{
if (!isDone(player))
if (!Data.isDone(player))
{
_survivedWaves.put(player, _survivedWaves.get(player) + 1);
}
@ -134,7 +135,7 @@ public class ChallengeWaveCrush extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
int var = 0;
int colorPicker = 0;
@ -186,7 +187,7 @@ public class ChallengeWaveCrush extends Challenge
return;
}
Player thePlayer = (Player) target;
if (isDone(thePlayer))
if (Data.isDone(thePlayer))
{
return;
}
@ -219,7 +220,7 @@ public class ChallengeWaveCrush extends Challenge
{
for (Player player : Host.GetPlayers(true))
{
if (!isDone(player))
if (!Data.isDone(player))
{
SetCompleted(player);
}

View File

@ -49,7 +49,7 @@ public class ChallengeBlockShot extends Challenge
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
return _spawns;
}
@ -61,7 +61,7 @@ public class ChallengeBlockShot extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Entity arrow : _arrows)
{
@ -152,7 +152,7 @@ public class ChallengeBlockShot extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
setBorder(-16, 16, 0, 20, -16, 16);
@ -167,7 +167,7 @@ public class ChallengeBlockShot extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (Location loc : UtilShapes.getPointsInCircle(getCenter(), getChallengers().size(), 10))
{

View File

@ -73,15 +73,9 @@ public class ChallengeBuildBuilding extends ChallengeSeperateRooms
return 5;
}
@Override
public void cleanupRoom()
{
// TODO Auto-generated method stub
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player player : getChallengers())
{
@ -89,4 +83,18 @@ public class ChallengeBuildBuilding extends ChallengeSeperateRooms
}
}
@Override
public ArrayList<Location> createSpawns()
{
// TODO Auto-generated method stub
return null;
}
@Override
public void createMap()
{
// TODO Auto-generated method stub
}
}

View File

@ -35,7 +35,7 @@ public class ChallengeChickenFishing extends Challenge
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
return _spawns;
}
@ -74,7 +74,7 @@ public class ChallengeChickenFishing extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Entity chicken : _chickens)
{
@ -83,7 +83,7 @@ public class ChallengeChickenFishing extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player player : getChallengers())
{
@ -92,7 +92,7 @@ public class ChallengeChickenFishing extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
int size = (getChallengers().size() / 2) + 4;

View File

@ -29,6 +29,8 @@ public class ChallengeDiamondFall extends Challenge
ChallengeType.LastStanding,
"Diamond Fall",
"Loot the most diamonds from chests!");
Settings.setDuration(30000);
}
@Override
@ -64,7 +66,7 @@ public class ChallengeDiamondFall extends Challenge
}
});
for (int places = 0; places < Math.min(players.size(), getAvailablePlaces()); places++)
for (int places = 0; places < Math.min(players.size(), Settings.getMaxCompletedCount()); places++)
{
SetCompleted(players.get(places));
}
@ -74,13 +76,7 @@ public class ChallengeDiamondFall extends Challenge
}
@Override
public long getMaxTime()
{
return 30000;
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> locations = new ArrayList<Location>();
@ -96,7 +92,7 @@ public class ChallengeDiamondFall extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -3; x <= 3; x++)
{
@ -159,15 +155,4 @@ public class ChallengeDiamondFall extends Challenge
}
}
}
@Override
public void cleanupRoom()
{
}
@Override
public void setupPlayers()
{
}
}

View File

@ -30,6 +30,8 @@ public class ChallengeHitTargets extends Challenge
ChallengeType.FirstComplete,
"Hit target",
"Hit the chosen players.");
Settings.setMinPlayers(4);
}
@EventHandler
@ -77,13 +79,7 @@ public class ChallengeHitTargets extends Challenge
// }
@Override
public int getMinPlayers()
{
return 4;
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -102,13 +98,13 @@ public class ChallengeHitTargets extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.DamagePvP = false;
}
@Override
public void setupPlayers()
public void onStart()
{
Host.DamagePvP = true;
ArrayList<Player> players = getChallengers();
@ -137,7 +133,7 @@ public class ChallengeHitTargets extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -12; x <= 12; x++)
{

View File

@ -372,7 +372,7 @@ public class ChallengeNameThatSound extends ChallengeSeperateRooms
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (ArrayList<Entity> entityList : _mobs.values())
{
@ -385,7 +385,7 @@ public class ChallengeNameThatSound extends ChallengeSeperateRooms
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player player : getChallengers())
{
@ -397,4 +397,18 @@ public class ChallengeNameThatSound extends ChallengeSeperateRooms
}
}
@Override
public ArrayList<Location> createSpawns()
{
// TODO Auto-generated method stub
return null;
}
@Override
public void createMap()
{
// TODO Auto-generated method stub
}
}

View File

@ -89,7 +89,7 @@ public class ChallengeSimonSays extends Challenge
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -107,13 +107,13 @@ public class ChallengeSimonSays extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
_villager.remove();
}
@Override
public void setupPlayers()
public void onStart()
{
for (Player players : Host.GetPlayers(true))
{
@ -123,7 +123,7 @@ public class ChallengeSimonSays extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
@ -428,7 +428,7 @@ public class ChallengeSimonSays extends Challenge
private void playerScoreIncrease(Player player)
{
String playerName = player.getName();
if (_playerRoundFinish.contains(playerName) || isDone(player))
if (_playerRoundFinish.contains(playerName) || Data.isDone(player))
{
return;
}
@ -448,7 +448,7 @@ public class ChallengeSimonSays extends Challenge
private void playerScoreOnFail(Player player)
{
String playerName = player.getName();
if (_playerRoundFinish.contains(playerName) || isDone(player))
if (_playerRoundFinish.contains(playerName) || Data.isDone(player))
{
return;
}

View File

@ -29,7 +29,7 @@ public class ChallengeSkyFall extends Challenge
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> locations = new ArrayList<Location>();
@ -45,7 +45,7 @@ public class ChallengeSkyFall extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
Host.DamageEvP = false;
}
@ -58,7 +58,7 @@ public class ChallengeSkyFall extends Challenge
return;
}
if (!isCompleted(event.GetDamageePlayer()))
if (!Data.isCompleted(event.GetDamageePlayer()))
{
return;
}
@ -67,7 +67,7 @@ public class ChallengeSkyFall extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
setBorder(-50, 50, 0, 254, -50, 50);
@ -89,7 +89,7 @@ public class ChallengeSkyFall extends Challenge
for (Player player : getChallengers())
{
if (isCompleted(player))
if (Data.isCompleted(player))
continue;
double y = player.getLocation().getY();
@ -102,7 +102,7 @@ public class ChallengeSkyFall extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -3; x <= 3; x++)
{

View File

@ -40,7 +40,7 @@ public class ChallengeTameTheWolf extends Challenge
}
@Override
public ArrayList<Location> getSpawns()
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
@ -58,7 +58,7 @@ public class ChallengeTameTheWolf extends Challenge
}
@Override
public void cleanupRoom()
public void onEnd()
{
for (Wolf wolf : _wolfs.keySet())
{
@ -71,7 +71,7 @@ public class ChallengeTameTheWolf extends Challenge
}
@Override
public void setupPlayers()
public void onStart()
{
for (int i = 0; i <= Math.round((Host.GetPlayers(true).size()) * 3); i++)
{
@ -96,7 +96,7 @@ public class ChallengeTameTheWolf extends Challenge
}
@Override
public void generateRoom()
public void createMap()
{
for (int x = -16; x <= 16; x++)
{

View File

@ -32,7 +32,7 @@ public class MinewareKangarooAtHeart extends StatTracker<Game>
ChallengeKangarooJump kJump = (ChallengeKangarooJump) challenge;
for (Player player : kJump.getPlayerHeight().keySet())
if (!kJump.isLost(player))
if (!kJump.getData().isLost(player))
addStat(player, "Kangaroo", 1, false, false);
}
}

View File

@ -32,7 +32,7 @@ public class MinewarePinataMasterTracker extends StatTracker<Game>
ChallengeShootChickens chickChallenge = (ChallengeShootChickens) challenge;
for (Player player : chickChallenge.getArrowsShot().keySet())
if (chickChallenge.getArrowsShot().get(player) == 6 && challenge.isCompleted(player))
if (chickChallenge.getArrowsShot().get(player) == 6 && challenge.getData().isCompleted(player))
addStat(player, "PinataMaster", 1, true, false);
}
}

View File

@ -33,7 +33,7 @@ public class MinewareTagMasterTracker extends StatTracker<Game>
for (Player player : tag.getNonTaggedPlayers())
{
if (tag.isLost(player))
if (tag.getData().isLost(player))
return;
addStat(player, "TagMaster", 1, true, false);