Implement challenge team spawning
Team based challenges are now handled differently from the normal ones. When the game or challenge starts, instead of spawning all players with the default team spawn method, they are teleported according to their team. For example, if a player is on the blue team, he will be teleported on the blue side of the map. Moreover, teams are now generated properly, by diving the total number of players by two. One drawback, that will be fixed in a next commit, is that team challenges require an even amount of players.
This commit is contained in:
parent
38769d9616
commit
ccebeb75f1
@ -230,6 +230,7 @@ public abstract class Game implements Listener
|
||||
public int HungerSet = -1;
|
||||
public int HealthSet = -1;
|
||||
|
||||
public boolean SpawnTeleport = true;
|
||||
public boolean PrepareFreeze = true;
|
||||
|
||||
private double _itemMergeRadius = 0;
|
||||
|
@ -114,7 +114,7 @@ public class GameTeam
|
||||
return _spawns;
|
||||
}
|
||||
|
||||
private Location fixFacing(Location loc)
|
||||
public Location fixFacing(Location loc)
|
||||
{
|
||||
if (Host.FixSpawnFacing)
|
||||
{
|
||||
|
@ -77,6 +77,7 @@ import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeList;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeSettings;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.TeamChallenge;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeAnvilDance;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeArrowRampage;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeBlockLobbers;
|
||||
@ -145,7 +146,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>();
|
||||
private ArrayList<Player> _winners = new ArrayList<Player>();
|
||||
|
||||
private GameTeam _playersTeam, _chickenTeam;
|
||||
private GameTeam _playerTeam, _chickenTeam;
|
||||
|
||||
private DeathEffect _deathEffect = new DeathEffect(this);
|
||||
private ChickenAttack _chickenAttack;
|
||||
@ -171,13 +172,17 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
* High Priority
|
||||
* - Define team spawns on correct side
|
||||
* - Fix item rendering exception (kangaroo jump http://i.imgur.com/CPYIogC.jpg)
|
||||
* - Pinata Master
|
||||
* - http://prnt.sc/ax86n8 typos
|
||||
* - Tag master only adds 1
|
||||
* - Bouncing block don't make completed players jump high
|
||||
*
|
||||
* Medium Priority
|
||||
* - Make spawn distance equal from a target
|
||||
* - Fix chicken attack triggering on game end (eg. 3 players killed at once)
|
||||
*
|
||||
* Low Priority
|
||||
* - Spawn more chickens on Chicken Shooting
|
||||
* - Fix chicken attack triggering on game end (ex. 3 players killed at once)
|
||||
* - Fix TNT knockback on Deadly TNT
|
||||
* - Fix double life loss on Minecart Dance
|
||||
* - Fix obsidian not spawning on Lava Run
|
||||
@ -200,7 +205,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
"Last player with lives wins.",
|
||||
});
|
||||
|
||||
_settings.setMaxLives(1);
|
||||
_settings.setMaxLives(5);
|
||||
|
||||
// Damage = false;
|
||||
DamagePvP = false;
|
||||
@ -211,6 +216,8 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
DamageTeamSelf = true;
|
||||
DamageTeamOther = false;
|
||||
|
||||
SpawnTeleport = false; // Disabled for custom spawn teleportation.
|
||||
|
||||
DeathOut = false;
|
||||
DeathTeleport = false;
|
||||
AutomaticRespawn = false;
|
||||
@ -368,23 +375,63 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onTeamCreation(GameStateChangeEvent event)
|
||||
public void createTeams(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() == GameState.Recruit)
|
||||
{
|
||||
_playersTeam = new GameTeam(this, "Players", ChatColor.YELLOW, new ArrayList<>());
|
||||
AddTeam(_playersTeam);
|
||||
createPlayerTeam();
|
||||
}
|
||||
else if (event.GetState() == GameState.Live)
|
||||
{
|
||||
_chickenTeam = new GameTeam(this, "Chickens", ChatColor.GRAY, _playersTeam.GetSpawns());
|
||||
_chickenTeam.SetVisible(false);
|
||||
AddTeam(_chickenTeam);
|
||||
createChickenTeam();
|
||||
}
|
||||
}
|
||||
|
||||
private void createPlayerTeam()
|
||||
{
|
||||
_playerTeam = new GameTeam(this, "Players", ChatColor.YELLOW, new ArrayList<>());
|
||||
AddTeam(_playerTeam);
|
||||
}
|
||||
|
||||
private void createChickenTeam()
|
||||
{
|
||||
_chickenTeam = new GameTeam(this, "Chickens", ChatColor.GRAY, _playerTeam.GetSpawns());
|
||||
_chickenTeam.SetVisible(false);
|
||||
AddTeam(_chickenTeam);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void start(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Prepare)
|
||||
return;
|
||||
|
||||
addPlayerLives();
|
||||
|
||||
_challenge = selectChallenge();
|
||||
|
||||
if (isChallengeNull())
|
||||
return;
|
||||
|
||||
setupChallengeSpawnLocations();
|
||||
_challenge.createMap();
|
||||
|
||||
if (_settings.canMarkSpawnLocations())
|
||||
_challenge.markSpawnLocations();
|
||||
|
||||
spawnAndResetPlayers(true);
|
||||
}
|
||||
|
||||
private void addPlayerLives()
|
||||
{
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
_lives.put(player, _settings.getMaxLives());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChallengeUpdate(UpdateEvent event)
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
return;
|
||||
@ -402,9 +449,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
_challenge = selectChallenge();
|
||||
|
||||
if (isChallengeNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resetLastChallengeMap();
|
||||
|
||||
@ -416,9 +461,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
if (_settings.canMarkSpawnLocations())
|
||||
_challenge.markSpawnLocations();
|
||||
|
||||
teleportPlayersToSpawnpoints();
|
||||
resetPlayers();
|
||||
teleportSpectatorsToSpawn();
|
||||
spawnAndResetPlayers(false);
|
||||
|
||||
_delay = System.currentTimeMillis();
|
||||
_settings.setWaiting(true);
|
||||
@ -490,6 +533,13 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnAndResetPlayers(boolean firstRun)
|
||||
{
|
||||
teleportPlayersToSpawnpoints(firstRun);
|
||||
resetPlayers();
|
||||
teleportSpectatorsToSpawn();
|
||||
}
|
||||
|
||||
private void resetPlayers()
|
||||
{
|
||||
for (Player player : GetPlayers(false))
|
||||
@ -523,7 +573,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
ArrayList<Location> selected = _challenge.createSpawns();
|
||||
|
||||
_challenge.getData().setSpawns(selected);
|
||||
_playersTeam.SetSpawns(selected);
|
||||
_playerTeam.SetSpawns(selected);
|
||||
SpectatorSpawn = UtilWorld.averageLocation(selected).add(0, 7, 0);
|
||||
|
||||
return selected;
|
||||
@ -540,11 +590,64 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
}
|
||||
}
|
||||
|
||||
private void teleportPlayersToSpawnpoints()
|
||||
private void teleportPlayersToSpawnpoints(boolean firstRun)
|
||||
{
|
||||
if (_challenge instanceof TeamChallenge)
|
||||
{
|
||||
teamTeleport(firstRun);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerTeleport(firstRun);
|
||||
}
|
||||
|
||||
removeSolidBlockForPlayers();
|
||||
}
|
||||
|
||||
private void teamTeleport(boolean firstRun)
|
||||
{
|
||||
TeamChallenge teamChallenge = (TeamChallenge) _challenge;
|
||||
|
||||
if (teamChallenge.shouldTeamSpawn())
|
||||
{
|
||||
teamChallenge.spawn(firstRun);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerTeleport(firstRun);
|
||||
}
|
||||
}
|
||||
|
||||
private void playerTeleport(boolean firstRun)
|
||||
{
|
||||
if (firstRun)
|
||||
{
|
||||
ArrayList<Player> players = GetPlayers(false);
|
||||
|
||||
for (int i = 0; i < players.size(); i++)
|
||||
{
|
||||
Player player = players.get(i);
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_playerTeam.SpawnTeleport(player);
|
||||
}
|
||||
}.runTaskLater(Manager.getPlugin(), i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerTeam.SpawnTeleport(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeSolidBlockForPlayers()
|
||||
{
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
_playersTeam.SpawnTeleport(player);
|
||||
removeSolidBlock(player.getLocation());
|
||||
}
|
||||
}
|
||||
@ -1401,29 +1504,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onGamePrepare(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Prepare)
|
||||
return;
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
_lives.put(player, _settings.getMaxLives());
|
||||
|
||||
_challenge = selectChallenge();
|
||||
|
||||
if (isChallengeNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setupChallengeSpawnLocations();
|
||||
_challenge.createMap();
|
||||
|
||||
if (_settings.canMarkSpawnLocations())
|
||||
_challenge.markSpawnLocations();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGamePrepareCountdownCommence(GamePrepareCountdownCommence event)
|
||||
{
|
||||
@ -1587,9 +1667,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
}
|
||||
}
|
||||
|
||||
public GameTeam getPlayersTeam()
|
||||
public GameTeam getPlayerTeam()
|
||||
{
|
||||
return _playersTeam;
|
||||
return _playerTeam;
|
||||
}
|
||||
|
||||
public GameTeam getChickenTeam()
|
||||
@ -1646,14 +1726,16 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
@Override
|
||||
public ArrayList<Player> GetPlayers(boolean aliveOnly)
|
||||
{
|
||||
if (_playersTeam != null)
|
||||
return _playersTeam.GetPlayers(aliveOnly);
|
||||
if (_playerTeam != null)
|
||||
return _playerTeam.GetPlayers(aliveOnly);
|
||||
else
|
||||
return super.GetPlayers(aliveOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of players that are alive.
|
||||
* <br>
|
||||
* Players are considered to be alive <b>after</b> they are teleported to challenge spawn locations.
|
||||
*/
|
||||
public ArrayList<Player> getPlayersAlive()
|
||||
{
|
||||
|
@ -25,8 +25,6 @@ public class ChallengeList
|
||||
{
|
||||
_index = 0;
|
||||
}
|
||||
|
||||
System.out.println("Index reset: " + _index);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package nautilus.game.arcade.game.games.mineware.challenge.other;
|
||||
package nautilus.game.arcade.game.games.mineware.challenge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -10,7 +11,7 @@ import org.bukkit.entity.Player;
|
||||
public class ChallengeTeam
|
||||
{
|
||||
private String _name;
|
||||
private ArrayList<Player> _players = new ArrayList<>();
|
||||
private LinkedHashSet<Player> _players = new LinkedHashSet<Player>();
|
||||
|
||||
public ChallengeTeam(String name)
|
||||
{
|
||||
@ -24,21 +25,19 @@ public class ChallengeTeam
|
||||
|
||||
public void add(Player player)
|
||||
{
|
||||
if (!_players.contains(player))
|
||||
_players.add(player);
|
||||
_players.add(player);
|
||||
}
|
||||
|
||||
public void remove(Player player)
|
||||
{
|
||||
if (_players.contains(player))
|
||||
_players.remove(player);
|
||||
_players.remove(player);
|
||||
}
|
||||
|
||||
|
||||
public boolean isMember(Player player)
|
||||
{
|
||||
return _players.contains(player);
|
||||
}
|
||||
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return _players.size();
|
||||
@ -46,6 +45,6 @@ public class ChallengeTeam
|
||||
|
||||
public ArrayList<Player> getPlayers()
|
||||
{
|
||||
return _players;
|
||||
return new ArrayList<Player>(_players);
|
||||
}
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
package nautilus.game.arcade.game.games.mineware.challenge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
|
||||
|
||||
public abstract class TeamChallenge extends Challenge
|
||||
{
|
||||
private ChallengeTeam _firstTeam;
|
||||
private ChallengeTeam _secondTeam;
|
||||
private boolean _teamSpawn;
|
||||
private byte _firstTeamSpawnBlockData;
|
||||
private byte _secondTeamSpawnBlockData;
|
||||
|
||||
public TeamChallenge(BawkBawkBattles host, ChallengeType type, String firstTeam, String secondTeam, boolean teamSpawn, byte firstTeamSpawnBlockData, byte secondTeamSpawnBlockData, String name, String... description)
|
||||
{
|
||||
super(host, type, name, description);
|
||||
|
||||
_firstTeam = new ChallengeTeam(firstTeam);
|
||||
_secondTeam = new ChallengeTeam(secondTeam);
|
||||
_teamSpawn = teamSpawn;
|
||||
_firstTeamSpawnBlockData = firstTeamSpawnBlockData;
|
||||
_secondTeamSpawnBlockData = secondTeamSpawnBlockData;
|
||||
}
|
||||
|
||||
public TeamChallenge(BawkBawkBattles host, ChallengeType type, String firstTeam, String secondTeam, String name, String... description)
|
||||
{
|
||||
this(host, type, firstTeam, secondTeam, false, (byte) 0, (byte) 0, name, description);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called automatically only when _teamSpawn is true.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void spawn(boolean firstRun)
|
||||
{
|
||||
autoSelectTeams();
|
||||
|
||||
ArrayList<Player> firstTeam = _firstTeam.getPlayers();
|
||||
ArrayList<Player> secondTeam = _secondTeam.getPlayers();
|
||||
|
||||
int firstTeamIndex = 0;
|
||||
int secondTeamIndex = 0;
|
||||
|
||||
int players = Host.getPlayersWithRemainingLives();
|
||||
int teleported = 0;
|
||||
|
||||
while (teleported < players)
|
||||
{
|
||||
for (Location spawn : Data.getDefinedSpawns())
|
||||
{
|
||||
spawn = Host.getPlayerTeam().fixFacing(spawn);
|
||||
Block block = spawn.getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
if (block.getData() == _firstTeamSpawnBlockData && firstTeamIndex < firstTeam.size())
|
||||
{
|
||||
Player player = firstTeam.get(firstTeamIndex);
|
||||
|
||||
if (firstRun)
|
||||
{
|
||||
teleportWithDelay(player, spawn, teleported);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.teleport(spawn);
|
||||
}
|
||||
|
||||
firstTeamIndex++;
|
||||
teleported++;
|
||||
}
|
||||
else if (block.getData() == _secondTeamSpawnBlockData && secondTeamIndex < secondTeam.size())
|
||||
{
|
||||
Player player = secondTeam.get(secondTeamIndex);
|
||||
|
||||
if (firstRun)
|
||||
{
|
||||
teleportWithDelay(player, spawn, teleported);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.teleport(spawn);
|
||||
}
|
||||
|
||||
secondTeamIndex++;
|
||||
teleported++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void teleportWithDelay(Player player, final Location spawn, int teleported)
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.teleport(spawn);
|
||||
}
|
||||
}.runTaskLater(Host.Manager.getPlugin(), teleported);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called automatically only when _teamSpawn is true.
|
||||
*/
|
||||
protected void autoSelectTeams()
|
||||
{
|
||||
ArrayList<Player> players = Host.GetPlayers(false);
|
||||
Collections.shuffle(players);
|
||||
int size = 0;
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
if (size < players.size() / 2)
|
||||
{
|
||||
_firstTeam.add(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
_secondTeam.add(player);
|
||||
}
|
||||
|
||||
size++;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
ChallengeTeam team = getTeam(player);
|
||||
|
||||
if (team != null)
|
||||
{
|
||||
team.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
public ChallengeTeam getTeam(Player player)
|
||||
{
|
||||
if (_firstTeam.isMember(player))
|
||||
{
|
||||
return _firstTeam;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _secondTeam;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean areOnSameTeam(Player player1, Player player2)
|
||||
{
|
||||
return (_firstTeam.isMember(player1) && _firstTeam.isMember(player2)) || (_secondTeam.isMember(player1) && _secondTeam.isMember(player2));
|
||||
}
|
||||
|
||||
public ChallengeTeam getFirstTeam()
|
||||
{
|
||||
return _firstTeam;
|
||||
}
|
||||
|
||||
public ChallengeTeam getSecondTeam()
|
||||
{
|
||||
return _secondTeam;
|
||||
}
|
||||
|
||||
public boolean shouldTeamSpawn()
|
||||
{
|
||||
return _teamSpawn;
|
||||
}
|
||||
}
|
@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
@ -29,15 +28,12 @@ import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeTeam;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.other.ChallengeTeam;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.TeamChallenge;
|
||||
|
||||
public class ChallengeDogsVersusCats extends Challenge
|
||||
public class ChallengeDogsVersusCats extends TeamChallenge
|
||||
{
|
||||
private ChallengeTeam _dogTeam;
|
||||
private ChallengeTeam _catTeam;
|
||||
|
||||
private int _catScore = 0;
|
||||
private int _dogScore = 0;
|
||||
|
||||
@ -48,6 +44,8 @@ public class ChallengeDogsVersusCats extends Challenge
|
||||
super(
|
||||
host,
|
||||
ChallengeType.FirstComplete,
|
||||
"Cats",
|
||||
"Dogs",
|
||||
"Dogs Vs Cats",
|
||||
"If you are a dog, bark.",
|
||||
"If you are a cat, meow.",
|
||||
@ -58,9 +56,6 @@ public class ChallengeDogsVersusCats extends Challenge
|
||||
Settings.setTeamBased();
|
||||
Settings.setDuration(75000);
|
||||
Settings.setLockInventory(4);
|
||||
|
||||
_catTeam = new ChallengeTeam("Cats");
|
||||
_dogTeam = new ChallengeTeam("Dogs");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -127,7 +122,7 @@ public class ChallengeDogsVersusCats extends Challenge
|
||||
|
||||
if (looped % 2 == 0)
|
||||
{
|
||||
_dogTeam.add(player);
|
||||
getSecondTeam().add(player);
|
||||
|
||||
DisguiseWolf Ddog = new DisguiseWolf(player);
|
||||
Host.getArcadeManager().GetDisguise().disguise(Ddog);
|
||||
@ -137,7 +132,7 @@ public class ChallengeDogsVersusCats extends Challenge
|
||||
}
|
||||
else
|
||||
{
|
||||
_catTeam.add(player);
|
||||
getFirstTeam().add(player);
|
||||
|
||||
DisguiseCat Dcat = new DisguiseCat(player);
|
||||
Host.getArcadeManager().GetDisguise().disguise(Dcat);
|
||||
@ -158,28 +153,28 @@ public class ChallengeDogsVersusCats extends Challenge
|
||||
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
int catScore = calculateScore(_catTeam);
|
||||
int dogScore = calculateScore(_dogTeam);
|
||||
|
||||
int catScore = calculateScore(getFirstTeam());
|
||||
int dogScore = calculateScore(getSecondTeam());
|
||||
|
||||
UtilTextMiddle.display("", C.cBlue + C.Bold + " Dogs: " + C.cGreen + _dogScore + "/" + dogScore + C.cGray + " - " + C.cRed + C.Bold + "Cats: " + C.cGreen + _catScore + "/" + catScore);
|
||||
|
||||
if (_catScore >= catScore)
|
||||
{
|
||||
for (Player player : _catTeam.getPlayers())
|
||||
for (Player player : getFirstTeam().getPlayers())
|
||||
{
|
||||
setCompleted(player);
|
||||
}
|
||||
}
|
||||
else if (_dogScore >= dogScore)
|
||||
{
|
||||
for (Player player : _dogTeam.getPlayers())
|
||||
for (Player player : getSecondTeam().getPlayers())
|
||||
{
|
||||
setCompleted(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onMiddleTextUpdate(UpdateEvent event)
|
||||
{
|
||||
@ -189,15 +184,15 @@ public class ChallengeDogsVersusCats extends Challenge
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
for (Player player : _catTeam.getPlayers())
|
||||
for (Player player : getFirstTeam().getPlayers())
|
||||
{
|
||||
if (isPlayerValid(player))
|
||||
{
|
||||
UtilTextBottom.display(C.Bold + "Left-Click to Meow!", player);
|
||||
}
|
||||
}
|
||||
|
||||
for (Player player : _dogTeam.getPlayers())
|
||||
|
||||
for (Player player : getSecondTeam().getPlayers())
|
||||
{
|
||||
if (isPlayerValid(player))
|
||||
{
|
||||
@ -223,7 +218,7 @@ public class ChallengeDogsVersusCats extends Challenge
|
||||
|
||||
if (item.getType() == Material.BONE || item.getType() == Material.STRING)
|
||||
{
|
||||
if (_catTeam.isMember(player))
|
||||
if (getFirstTeam().isMember(player))
|
||||
{
|
||||
incrementCatScore();
|
||||
player.playSound(event.getPlayer().getLocation(), Sound.CAT_MEOW, 1f, 1f);
|
||||
@ -240,21 +235,9 @@ public class ChallengeDogsVersusCats extends Challenge
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
_catTeam.remove(player);
|
||||
_dogTeam.remove(player);
|
||||
}
|
||||
|
||||
private void incrementCatScore()
|
||||
{
|
||||
int maxScore = calculateScore(_catTeam);
|
||||
int maxScore = calculateScore(getFirstTeam());
|
||||
|
||||
if (_catScore < maxScore)
|
||||
_catScore++;
|
||||
@ -262,7 +245,7 @@ public class ChallengeDogsVersusCats extends Challenge
|
||||
|
||||
private void incrementDogScore()
|
||||
{
|
||||
int maxScore = calculateScore(_dogTeam);
|
||||
int maxScore = calculateScore(getSecondTeam());
|
||||
|
||||
if (_dogScore < maxScore)
|
||||
_dogScore++;
|
||||
|
@ -15,15 +15,11 @@ import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.other.ChallengeTeam;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.TeamChallenge;
|
||||
|
||||
public class ChallengePickASide extends Challenge
|
||||
public class ChallengePickASide extends TeamChallenge
|
||||
{
|
||||
private ChallengeTeam _blueTeam;
|
||||
private ChallengeTeam _redTeam;
|
||||
|
||||
private int _counter = 8;
|
||||
|
||||
public ChallengePickASide(BawkBawkBattles host)
|
||||
@ -31,6 +27,8 @@ public class ChallengePickASide extends Challenge
|
||||
super(
|
||||
host,
|
||||
ChallengeType.FirstComplete,
|
||||
"Blue",
|
||||
"Red",
|
||||
"Pick a Side",
|
||||
"The side with the fewest players wins.",
|
||||
"Standing in the middle does not work.");
|
||||
@ -38,9 +36,6 @@ public class ChallengePickASide extends Challenge
|
||||
Settings.setUseMapHeight();
|
||||
Settings.setMinPlayers(3);
|
||||
Settings.setTeamBased();
|
||||
|
||||
_blueTeam = new ChallengeTeam("Blue");
|
||||
_redTeam = new ChallengeTeam("Red");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -140,13 +135,13 @@ public class ChallengePickASide extends Challenge
|
||||
|
||||
private void determineWinners()
|
||||
{
|
||||
addPlayersOnTeams();
|
||||
determineSideSize();
|
||||
|
||||
if (_blueTeam.getSize() < _redTeam.getSize())
|
||||
if (getFirstTeam().getSize() < getSecondTeam().getSize())
|
||||
{
|
||||
selectBlueAsWinners();
|
||||
}
|
||||
else if (_blueTeam.getSize() > _redTeam.getSize())
|
||||
else if (getFirstTeam().getSize() > getSecondTeam().getSize())
|
||||
{
|
||||
selectRedAsWinners();
|
||||
}
|
||||
@ -163,27 +158,27 @@ public class ChallengePickASide extends Challenge
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlayersOnTeams()
|
||||
private void determineSideSize()
|
||||
{
|
||||
for (Player player : getPlayersAlive())
|
||||
{
|
||||
if (player.getLocation().getZ() < 1)
|
||||
{
|
||||
_blueTeam.add(player);
|
||||
getFirstTeam().add(player);
|
||||
}
|
||||
else if (player.getLocation().getZ() > 1)
|
||||
{
|
||||
_redTeam.add(player);
|
||||
getSecondTeam().add(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UtilMath.random.nextBoolean())
|
||||
{
|
||||
_redTeam.add(player);
|
||||
getSecondTeam().add(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
_blueTeam.add(player);
|
||||
getFirstTeam().add(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -191,12 +186,12 @@ public class ChallengePickASide extends Challenge
|
||||
|
||||
private void selectBlueAsWinners()
|
||||
{
|
||||
for (Player bluePlayer : _blueTeam.getPlayers())
|
||||
for (Player bluePlayer : getFirstTeam().getPlayers())
|
||||
{
|
||||
setCompleted(bluePlayer);
|
||||
}
|
||||
|
||||
for (Player redPlayer : _redTeam.getPlayers())
|
||||
for (Player redPlayer : getSecondTeam().getPlayers())
|
||||
{
|
||||
setLost(redPlayer);
|
||||
}
|
||||
@ -204,15 +199,14 @@ public class ChallengePickASide extends Challenge
|
||||
|
||||
private void selectRedAsWinners()
|
||||
{
|
||||
for (Player redPlayer : _redTeam.getPlayers())
|
||||
for (Player redPlayer : getSecondTeam().getPlayers())
|
||||
{
|
||||
setCompleted(redPlayer);
|
||||
}
|
||||
|
||||
for (Player bluePlayer : _blueTeam.getPlayers())
|
||||
for (Player bluePlayer : getFirstTeam().getPlayers())
|
||||
{
|
||||
setLost(bluePlayer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package nautilus.game.arcade.game.games.mineware.challenge.type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Color;
|
||||
@ -25,15 +24,11 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.other.ChallengeTeam;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.TeamChallenge;
|
||||
|
||||
public class ChallengeReverseTag extends Challenge
|
||||
public class ChallengeReverseTag extends TeamChallenge
|
||||
{
|
||||
private ChallengeTeam _tagged;
|
||||
private ChallengeTeam _nonTagged;
|
||||
|
||||
private int _cooldown = 2; // Seconds
|
||||
private HashSet<Player> _cooldowns = new HashSet<Player>();
|
||||
|
||||
@ -42,6 +37,8 @@ public class ChallengeReverseTag extends Challenge
|
||||
super(
|
||||
host,
|
||||
ChallengeType.FirstComplete,
|
||||
"Tagged",
|
||||
"Non Tagged",
|
||||
"Reverse Tag",
|
||||
"Punch a sparkling person to become one.",
|
||||
"Stay sparkling until the end.");
|
||||
@ -49,9 +46,6 @@ public class ChallengeReverseTag extends Challenge
|
||||
Settings.setUseMapHeight();
|
||||
Settings.setTeamBased();
|
||||
Settings.setDuration(UtilMath.r(5) + 20 * 1000);
|
||||
|
||||
_tagged = new ChallengeTeam("Tagged");
|
||||
_nonTagged = new ChallengeTeam("Non Tagged");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -98,23 +92,11 @@ public class ChallengeReverseTag extends Challenge
|
||||
{
|
||||
Host.DamagePvP = true;
|
||||
|
||||
int i = 0;
|
||||
ArrayList<Player> players = getPlayersAlive();
|
||||
Collections.shuffle(players);
|
||||
autoSelectTeams();
|
||||
|
||||
for (Player player : players)
|
||||
for (Player tagged : getFirstTeam().getPlayers())
|
||||
{
|
||||
if (i < (int) players.size() / 2)
|
||||
{
|
||||
_tagged.add(player);
|
||||
tagEffect(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
_nonTagged.add(player);
|
||||
}
|
||||
|
||||
i++;
|
||||
tagEffect(tagged);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,15 +109,10 @@ public class ChallengeReverseTag extends Challenge
|
||||
@Override
|
||||
public void onTimerFinish()
|
||||
{
|
||||
for (Player tagged : _tagged.getPlayers())
|
||||
for (Player tagged : getFirstTeam().getPlayers())
|
||||
{
|
||||
setCompleted(tagged);
|
||||
}
|
||||
|
||||
// for (Player nonTagged : _nonTagged.getPlayers())
|
||||
// {
|
||||
// setLost(nonTagged);
|
||||
// }
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -150,8 +127,10 @@ public class ChallengeReverseTag extends Challenge
|
||||
if (getPlayersAlive().size() > 40)
|
||||
return;
|
||||
|
||||
for (Player player : _tagged.getPlayers())
|
||||
for (Player player : getFirstTeam().getPlayers())
|
||||
{
|
||||
UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.GREEN, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -178,7 +157,7 @@ public class ChallengeReverseTag extends Challenge
|
||||
return;
|
||||
}
|
||||
|
||||
if (_tagged.isMember(damagee) && _nonTagged.isMember(damager) && !_cooldowns.contains(damagee))
|
||||
if (getFirstTeam().isMember(damagee) && getSecondTeam().isMember(damager) && !_cooldowns.contains(damagee))
|
||||
{
|
||||
clear(damagee);
|
||||
tag(damager, true);
|
||||
@ -197,7 +176,7 @@ public class ChallengeReverseTag extends Challenge
|
||||
return;
|
||||
|
||||
Player player = event.getEntity();
|
||||
_tagged.remove(player);
|
||||
getFirstTeam().remove(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -211,20 +190,16 @@ public class ChallengeReverseTag extends Challenge
|
||||
if (!isPlayerValid(player))
|
||||
return;
|
||||
|
||||
if (_cooldowns.contains(player))
|
||||
_cooldowns.remove(player);
|
||||
|
||||
_tagged.remove(player);
|
||||
_nonTagged.remove(player);
|
||||
_cooldowns.remove(player);
|
||||
}
|
||||
|
||||
private void clear(Player player)
|
||||
{
|
||||
if (_tagged.isMember(player))
|
||||
if (getFirstTeam().isMember(player))
|
||||
{
|
||||
clearEffect(player);
|
||||
_tagged.remove(player);
|
||||
_nonTagged.add(player);
|
||||
getFirstTeam().remove(player);
|
||||
getSecondTeam().add(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,12 +216,12 @@ public class ChallengeReverseTag extends Challenge
|
||||
|
||||
private void tag(Player player, boolean cooldown)
|
||||
{
|
||||
if (_nonTagged.isMember(player))
|
||||
if (getSecondTeam().isMember(player))
|
||||
{
|
||||
tagEffect(player);
|
||||
|
||||
_nonTagged.remove(player);
|
||||
_tagged.add(player);
|
||||
getSecondTeam().remove(player);
|
||||
getFirstTeam().add(player);
|
||||
_cooldowns.add(player);
|
||||
|
||||
if (cooldown)
|
||||
@ -278,14 +253,4 @@ public class ChallengeReverseTag extends Challenge
|
||||
}
|
||||
}.runTaskLater(Host.Manager.getPlugin(), 20 * _cooldown);
|
||||
}
|
||||
|
||||
public ChallengeTeam getTagged()
|
||||
{
|
||||
return _tagged;
|
||||
}
|
||||
|
||||
public ChallengeTeam getNonTagged()
|
||||
{
|
||||
return _nonTagged;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
@ -17,31 +16,29 @@ import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.other.ChallengeTeam;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.TeamChallenge;
|
||||
|
||||
public class ChallengeRushPush extends Challenge
|
||||
public class ChallengeRushPush extends TeamChallenge
|
||||
{
|
||||
private ChallengeTeam _blueTeam;
|
||||
private ChallengeTeam _redTeam;
|
||||
|
||||
public ChallengeRushPush(BawkBawkBattles host)
|
||||
{
|
||||
super(
|
||||
host,
|
||||
ChallengeType.LastStanding,
|
||||
"Blue",
|
||||
"Red",
|
||||
true,
|
||||
(byte) 11,
|
||||
(byte) 14,
|
||||
"Rush Push",
|
||||
"Attack to the enemy team.",
|
||||
"Push them off the platform.");
|
||||
|
||||
Settings.setUseMapHeight();
|
||||
Settings.setCanCruble();
|
||||
Settings.setTeamBased();
|
||||
Settings.setLockInventory(4);
|
||||
|
||||
_blueTeam = new ChallengeTeam("Blue");
|
||||
_redTeam = new ChallengeTeam("Red");
|
||||
Settings.setTeamBased();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,7 +91,7 @@ public class ChallengeRushPush extends Challenge
|
||||
{
|
||||
Host.DamagePvP = true;
|
||||
|
||||
addPlayersOnTeam();
|
||||
addDiamondSword();
|
||||
equipTeamHelmets();
|
||||
}
|
||||
|
||||
@ -129,35 +126,14 @@ public class ChallengeRushPush extends Challenge
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
_blueTeam.remove(player);
|
||||
_redTeam.remove(player);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void addPlayersOnTeam()
|
||||
private void addDiamondSword()
|
||||
{
|
||||
ItemStack sword = new ItemBuilder(Material.DIAMOND_SWORD)
|
||||
.setUnbreakable(true)
|
||||
.setItemFlags(ItemFlag.HIDE_UNBREAKABLE)
|
||||
.build();
|
||||
|
||||
for (Player player : getPlayersAlive())
|
||||
{
|
||||
if (player.getLocation().add(0, -1, 0).getBlock().getData() == (byte) 11)
|
||||
_blueTeam.add(player);
|
||||
else
|
||||
_redTeam.add(player);
|
||||
|
||||
player.getInventory().setItem(Settings.getLockedSlot(), sword);
|
||||
}
|
||||
setItem(Settings.getLockedSlot(), sword);
|
||||
}
|
||||
|
||||
private void equipTeamHelmets()
|
||||
@ -168,7 +144,7 @@ public class ChallengeRushPush extends Challenge
|
||||
meta.setColor(Color.BLUE);
|
||||
helmet.setItemMeta(meta);
|
||||
|
||||
for (Player player : _blueTeam.getPlayers())
|
||||
for (Player player : getFirstTeam().getPlayers())
|
||||
{
|
||||
player.getInventory().setHelmet(helmet);
|
||||
}
|
||||
@ -176,14 +152,9 @@ public class ChallengeRushPush extends Challenge
|
||||
meta.setColor(Color.RED);
|
||||
helmet.setItemMeta(meta);
|
||||
|
||||
for (Player player : _redTeam.getPlayers())
|
||||
for (Player player : getSecondTeam().getPlayers())
|
||||
{
|
||||
player.getInventory().setHelmet(helmet);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean areOnSameTeam(Player player1, Player player2)
|
||||
{
|
||||
return (_blueTeam.isMember(player1) && _blueTeam.isMember(player2)) || (_redTeam.isMember(player1) && _redTeam.isMember(player2));
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
@ -35,13 +34,11 @@ import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.other.ChallengeTeam;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.TeamChallenge;
|
||||
|
||||
public class ChallengeVolleyPig extends Challenge
|
||||
public class ChallengeVolleyPig extends TeamChallenge
|
||||
{
|
||||
private ChallengeTeam _blueTeam, _redTeam;
|
||||
private Location _blueCenter, _redCenter;
|
||||
private Pig _pig;
|
||||
private long _blueSide, _redSide;
|
||||
@ -51,6 +48,11 @@ public class ChallengeVolleyPig extends Challenge
|
||||
super(
|
||||
host,
|
||||
ChallengeType.FirstComplete,
|
||||
"Blue",
|
||||
"Red",
|
||||
true,
|
||||
(byte) 11,
|
||||
(byte) 14,
|
||||
"Volley Pig",
|
||||
"Punch the pig on the enemy side.");
|
||||
|
||||
@ -60,9 +62,6 @@ public class ChallengeVolleyPig extends Challenge
|
||||
Settings.setLockInventory(4);
|
||||
Settings.setDuration(30000);
|
||||
|
||||
_blueTeam = new ChallengeTeam("Blue");
|
||||
_redTeam = new ChallengeTeam("Red");
|
||||
|
||||
_blueCenter = getCenter().add(0, 3, 5);
|
||||
_redCenter = getCenter().add(0, 3, -5);
|
||||
}
|
||||
@ -117,7 +116,6 @@ public class ChallengeVolleyPig extends Challenge
|
||||
Host.DamagePvE = true;
|
||||
|
||||
spawnPig();
|
||||
addPlayersOnTeam();
|
||||
equipKnockbackStick();
|
||||
equipTeamHelmets();
|
||||
startMainTask();
|
||||
@ -154,8 +152,8 @@ public class ChallengeVolleyPig extends Challenge
|
||||
|
||||
if (!fromBlock.isEmpty() && !toBlock.isEmpty())
|
||||
{
|
||||
boolean crossedBlue = _redTeam.isMember(player) && (fromBlock.getData() == 11 || toBlock.getData() == 11);
|
||||
boolean crossedRed = _blueTeam.isMember(player) && (fromBlock.getData() == 14 || toBlock.getData() == 14);
|
||||
boolean crossedBlue = getSecondTeam().isMember(player) && (fromBlock.getData() == 11 || toBlock.getData() == 11);
|
||||
boolean crossedRed = getFirstTeam().isMember(player) && (fromBlock.getData() == 14 || toBlock.getData() == 14);
|
||||
boolean fromStainedGlass = fromBlock.getType() == Material.STAINED_GLASS;
|
||||
boolean toStainedGlass = toBlock.getType() == Material.STAINED_GLASS;
|
||||
|
||||
@ -184,18 +182,6 @@ public class ChallengeVolleyPig extends Challenge
|
||||
pig.setHealth(pig.getMaxHealth());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
_blueTeam.remove(player);
|
||||
_redTeam.remove(player);
|
||||
}
|
||||
|
||||
private void startMainTask()
|
||||
{
|
||||
new BukkitRunnable()
|
||||
@ -226,45 +212,6 @@ public class ChallengeVolleyPig extends Challenge
|
||||
Host.CreatureAllow = false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void addPlayersOnTeam()
|
||||
{
|
||||
// int half = getPlayersAlive().size() / 2;
|
||||
// int current = 0;
|
||||
//
|
||||
// for (Player player : getPlayersAlive())
|
||||
// {
|
||||
// if (current < half)
|
||||
// {
|
||||
// _blueTeam.add(player);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _redTeam.add(player);
|
||||
// }
|
||||
//
|
||||
// current++;
|
||||
// }
|
||||
|
||||
for (Player player : getPlayersAlive())
|
||||
{
|
||||
Location location = player.getLocation();
|
||||
Block blockBelow = player.getWorld().getBlockAt(location.add(0, -1, 0));
|
||||
|
||||
if (blockBelow.getType() == Material.STAINED_CLAY)
|
||||
{
|
||||
if (blockBelow.getData() == (byte) 11)
|
||||
{
|
||||
_blueTeam.add(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
_redTeam.add(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void equipTeamHelmets()
|
||||
{
|
||||
ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
|
||||
@ -273,7 +220,7 @@ public class ChallengeVolleyPig extends Challenge
|
||||
meta.setColor(Color.BLUE);
|
||||
helmet.setItemMeta(meta);
|
||||
|
||||
for (Player player : _blueTeam.getPlayers())
|
||||
for (Player player : getFirstTeam().getPlayers())
|
||||
{
|
||||
player.getInventory().setHelmet(helmet);
|
||||
}
|
||||
@ -281,7 +228,7 @@ public class ChallengeVolleyPig extends Challenge
|
||||
meta.setColor(Color.RED);
|
||||
helmet.setItemMeta(meta);
|
||||
|
||||
for (Player player : _redTeam.getPlayers())
|
||||
for (Player player : getSecondTeam().getPlayers())
|
||||
{
|
||||
player.getInventory().setHelmet(helmet);
|
||||
}
|
||||
@ -310,10 +257,14 @@ public class ChallengeVolleyPig extends Challenge
|
||||
|
||||
private Location getTeamCenter(Player player)
|
||||
{
|
||||
if (_blueTeam.isMember(player))
|
||||
if (getFirstTeam().isMember(player))
|
||||
{
|
||||
return _blueCenter;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _redCenter;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -350,14 +301,14 @@ public class ChallengeVolleyPig extends Challenge
|
||||
{
|
||||
if (_redSide > 10000)
|
||||
{
|
||||
for (Player bluePlayer : _blueTeam.getPlayers())
|
||||
for (Player bluePlayer : getFirstTeam().getPlayers())
|
||||
{
|
||||
setCompleted(bluePlayer);
|
||||
}
|
||||
}
|
||||
else if (_blueSide > 10000)
|
||||
{
|
||||
for (Player redPlayer : _redTeam.getPlayers())
|
||||
for (Player redPlayer : getSecondTeam().getPlayers())
|
||||
{
|
||||
setCompleted(redPlayer);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class ChickenAttack
|
||||
|
||||
public void start(Player player)
|
||||
{
|
||||
_host.getPlayersTeam().RemovePlayer(player);
|
||||
_host.getPlayerTeam().RemovePlayer(player);
|
||||
_host.getChickenTeam().AddPlayer(player, true);
|
||||
|
||||
UtilInv.Clear(player);
|
||||
|
@ -20,7 +20,7 @@ public class TagMasterTracker extends ChallengeStatTracker
|
||||
{
|
||||
ChallengeReverseTag reverseTag = (ChallengeReverseTag) challenge;
|
||||
|
||||
for (Player player : reverseTag.getTagged().getPlayers())
|
||||
for (Player player : reverseTag.getFirstTeam().getPlayers())
|
||||
{
|
||||
if (reverseTag.getData().isCompleted(player))
|
||||
{
|
||||
|
@ -747,7 +747,8 @@ public class GameManager implements Listener
|
||||
public void run()
|
||||
{
|
||||
//Teleport
|
||||
team.SpawnTeleport(player);
|
||||
if (game.SpawnTeleport)
|
||||
team.SpawnTeleport(player);
|
||||
|
||||
Manager.Clear(player);
|
||||
UtilInv.Clear(player);
|
||||
|
Loading…
Reference in New Issue
Block a user