Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
Jonathan Williams 2014-06-27 20:25:09 -07:00
commit 8e8e66f8c1
25 changed files with 549 additions and 946 deletions

View File

@ -1,6 +1,8 @@
package mineplex.core.portal; package mineplex.core.portal;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -15,6 +17,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.messaging.PluginMessageListener;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
@ -23,7 +26,7 @@ import mineplex.core.common.util.NautHashMap;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
public class Portal extends MiniPlugin public class Portal extends MiniPlugin implements PluginMessageListener
{ {
private static Object _transferLock = new Object(); private static Object _transferLock = new Object();
@ -34,12 +37,14 @@ public class Portal extends MiniPlugin
private boolean _retrieve = true; private boolean _retrieve = true;
private CoreClientManager _clientier; private CoreClientManager _clientier;
private String serverName = "";
public Portal(JavaPlugin plugin) public Portal(JavaPlugin plugin)
{ {
super("Portal", plugin); super("Portal", plugin);
Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord"); Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord");
Bukkit.getMessenger().registerIncomingPluginChannel(GetPlugin(), "BungeeCord", this);
_repository.initialize(plugin.getConfig().getBoolean("serverstatus.us")); _repository.initialize(plugin.getConfig().getBoolean("serverstatus.us"));
_clientier = CoreClientManager.Initialize(plugin, plugin.getConfig().getString("webServer")); _clientier = CoreClientManager.Initialize(plugin, plugin.getConfig().getString("webServer"));
@ -94,6 +99,34 @@ public class Portal extends MiniPlugin
}, 20L); }, 20L);
} }
private void ProcessServerName(final Player player)
{
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try
{
out.writeUTF("GetServer");
}
catch (IOException e)
{
// Can never happen
}
finally
{
try
{
out.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
player.sendPluginMessage(GetPlugin(), "BungeeCord", b.toByteArray());
}
private void SendPlayerToServerWithMessage(Player player, String serverName) private void SendPlayerToServerWithMessage(Player player, String serverName)
{ {
SendPlayerToServer(player, serverName); SendPlayerToServer(player, serverName);
@ -180,7 +213,8 @@ public class Portal extends MiniPlugin
if(args.length == 0) if(args.length == 0)
{ {
player.sendMessage(ChatColor.YELLOW + "You are currently on server: " + ChatColor.GOLD + GetPlugin().getServer().getName() + " " + GetPlugin().getServer().getServerName()); ProcessServerName(player);
player.sendMessage(ChatColor.YELLOW + "You are currently on server: " + ChatColor.GOLD + serverName);
return; return;
} }
else if(args.length == 1) else if(args.length == 1)
@ -256,4 +290,40 @@ public class Portal extends MiniPlugin
} }
} }
} }
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message)
{
if (!channel.equals("BungeeCord"))
{
return;
}
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
try
{
String subchannel = in.readUTF();
if (subchannel.equals("GetServer"))
{
serverName = in.readUTF();
}
}
catch (IOException e)
{
// Should never happen
}
finally
{
try
{
in.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
} }

View File

@ -430,12 +430,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
if (_game == null || _game.GetState() == GameState.Recruit) if (_game == null || _game.GetState() == GameState.Recruit)
{ {
if (_game != null && _game.GetType() == GameType.UHC)
{
event.setMotd(ChatColor.RED + "UHC - Season 5");
return;
}
if (_game != null && _game.GetCountdown() != -1) if (_game != null && _game.GetCountdown() != -1)
{ {
event.setMotd(ChatColor.GREEN + "Starting in " + _game.GetCountdown() + " Seconds" + extrainformation); event.setMotd(ChatColor.GREEN + "Starting in " + _game.GetCountdown() + " Seconds" + extrainformation);

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.game;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import mineplex.core.timing.TimingManager; import mineplex.core.timing.TimingManager;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -24,6 +25,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.GameScore;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
@ -372,6 +374,12 @@ public abstract class Game implements Listener
System.out.println("Created Team: " + team.GetName()); System.out.println("Created Team: " + team.GetName());
} }
public void RemoveTeam(GameTeam team)
{
if (GetTeamList().remove(team))
System.out.println("Deleted Team: " + team.GetName());
}
public boolean HasTeam(GameTeam team) public boolean HasTeam(GameTeam team)
{ {
for (GameTeam cur : GetTeamList()) for (GameTeam cur : GetTeamList())
@ -1000,4 +1008,13 @@ public abstract class Game implements Listener
{ {
return _prepareCountdown; return _prepareCountdown;
} }
@EventHandler
public void TeamPlayerPlacement(PlayerStateChangeEvent event)
{
GameTeam team = GetTeam(event.GetPlayer());
if (team != null)
team.SetPlacement(event.GetPlayer(), event.GetState());
}
} }

View File

@ -10,6 +10,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitAvailability;
@ -66,6 +67,9 @@ public class GameTeam
private boolean _visible = true; private boolean _visible = true;
//Records order players go out in
protected ArrayList<Player> _places = new ArrayList<Player>();
public GameTeam(Game host, String name, ChatColor color, ArrayList<Location> spawns) public GameTeam(Game host, String name, ChatColor color, ArrayList<Location> spawns)
{ {
Host = host; Host = host;
@ -338,4 +342,36 @@ public class GameTeam
{ {
return _respawnTime; return _respawnTime;
} }
public void SetPlacement(Player player, PlayerState state)
{
if (state == PlayerState.OUT)
if (!_places.contains(player))
_places.add(0, player);
else
_places.remove(player);
}
public ArrayList<Player> GetPlacements(boolean includeAlivePlayers)
{
if (includeAlivePlayers)
{
ArrayList<Player> placesClone = new ArrayList<Player>();
for (Player player : _places)
{
placesClone.add(player);
}
for (Player player : GetPlayers(true))
{
_places.add(0, player);
}
return placesClone;
}
return _places;
}
} }

View File

@ -19,7 +19,7 @@ import nautilus.game.arcade.kit.Kit;
public abstract class SoloGame extends Game public abstract class SoloGame extends Game
{ {
protected ArrayList<Player> _places = new ArrayList<Player>(); private GameTeam _players;
public SoloGame(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc) public SoloGame(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
{ {
@ -32,19 +32,9 @@ public abstract class SoloGame extends Game
if (event.GetState() != GameState.Recruit) if (event.GetState() != GameState.Recruit)
return; return;
this.GetTeamList().get(0).SetColor(ChatColor.YELLOW); _players = GetTeamList().get(0);
this.GetTeamList().get(0).SetName("Players"); _players.SetColor(ChatColor.YELLOW);
} _players.SetName("Players");
@EventHandler
public void EndStateChange(PlayerStateChangeEvent event)
{
if (event.GetState() == PlayerState.OUT)
if (!_places.contains(event.GetPlayer()))
_places.add(0, event.GetPlayer());
else
_places.remove(event.GetPlayer());
} }
@Override @Override
@ -53,27 +43,22 @@ public abstract class SoloGame extends Game
if (!IsLive()) if (!IsLive())
return; return;
//Add Winner if (GetPlayers(true).size() <= 1)
if (GetPlayers(true).size() == 1)
{ {
SetPlayerState(GetPlayers(true).get(0), PlayerState.OUT); ArrayList<Player> places = _players.GetPlacements(true);
return;
}
if (GetPlayers(true).size() <= 0)
{
//Announce //Announce
AnnounceEnd(_places); AnnounceEnd(places);
//Gems //Gems
if (_places.size() >= 1) if (places.size() >= 1)
AddGems(_places.get(0), 20, "1st Place", false); AddGems(places.get(0), 20, "1st Place", false);
if (_places.size() >= 2) if (places.size() >= 2)
AddGems(_places.get(1), 15, "2nd Place", false); AddGems(places.get(1), 15, "2nd Place", false);
if (_places.size() >= 3) if (places.size() >= 3)
AddGems(_places.get(2), 10, "3rd Place", false); AddGems(places.get(2), 10, "3rd Place", false);
for (Player player : GetPlayers(false)) for (Player player : GetPlayers(false))
if (player.isOnline()) if (player.isOnline())
@ -81,7 +66,6 @@ public abstract class SoloGame extends Game
//End //End
SetState(GameState.End); SetState(GameState.End);
} }
} }
@ -135,11 +119,6 @@ public abstract class SoloGame extends Game
Scoreboard.Draw(); Scoreboard.Draw();
} }
public ArrayList<Player> GetPlaces()
{
return _places;
}
public int GetScoreboardScore(Player player) public int GetScoreboardScore(Player player)
{ {
return 0; return 0;

View File

@ -18,10 +18,14 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
public abstract class TeamGame extends Game public abstract class TeamGame extends Game
{ {
protected ArrayList<GameTeam> _places = new ArrayList<GameTeam>();
private NautHashMap<String, Long> _rejoinTime = new NautHashMap<String, Long>(); private NautHashMap<String, Long> _rejoinTime = new NautHashMap<String, Long>();
protected NautHashMap<String, GameTeam> RejoinTeam = new NautHashMap<String, GameTeam>(); protected NautHashMap<String, GameTeam> RejoinTeam = new NautHashMap<String, GameTeam>();
protected NautHashMap<String, Kit> RejoinKit = new NautHashMap<String, Kit>(); protected NautHashMap<String, Kit> RejoinKit = new NautHashMap<String, Kit>();
@ -33,6 +37,26 @@ public abstract class TeamGame extends Game
super(manager, gameType, kits, gameDesc); super(manager, gameType, kits, gameDesc);
} }
@EventHandler
public void EndStateChange(PlayerStateChangeEvent event)
{
GameTeam team = this.GetTeam(event.GetPlayer());
if (team == null)
return;
if (event.GetState() == PlayerState.OUT)
if (!team.IsTeamAlive())
_places.add(0, team);
else
_places.remove(team);
}
public ArrayList<GameTeam> GetPlaces()
{
return _places;
}
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void PlayerQuit(PlayerQuitEvent event) public void PlayerQuit(PlayerQuitEvent event)
{ {

View File

@ -1,8 +1,10 @@
package nautilus.game.arcade.game.games; package nautilus.game.arcade.game.games;
import nautilus.game.arcade.game.PlayerScore;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class GameScore public class GameScore implements PlayerScore
{ {
public org.bukkit.entity.Player Player; public org.bukkit.entity.Player Player;
public double Score; public double Score;
@ -12,4 +14,9 @@ public class GameScore
Player = player; Player = player;
Score = i; Score = i;
} }
public Player GetPlayer()
{
return Player;
}
} }

View File

@ -38,36 +38,6 @@ public class BaconBrawl extends SoloGame
this.PrepareFreeze = false; this.PrepareFreeze = false;
} }
@Override
public void EndCheck()
{
if (!IsLive())
return;
if (GetPlayers(true).size() <= 1)
{
if (GetPlayers(true).size() == 1)
GetPlaces().add(0, GetPlayers(true).get(0));
if (GetPlaces().size() >= 1)
AddGems(GetPlaces().get(0), 15, "1st Place", false);
if (GetPlaces().size() >= 2)
AddGems(GetPlaces().get(1), 10, "2nd Place", false);
if (GetPlaces().size() >= 3)
AddGems(GetPlaces().get(2), 5, "3rd Place", false);
for (Player player : GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
SetState(GameState.End);
AnnounceEnd(GetPlaces());
}
}
@EventHandler @EventHandler
public void Hunger(UpdateEvent event) public void Hunger(UpdateEvent event)
{ {

View File

@ -60,36 +60,6 @@ public class Barbarians extends SoloGame
this.BlockBreakAllow.add(136); this.BlockBreakAllow.add(136);
} }
@Override
public void EndCheck()
{
if (!IsLive())
return;
if (GetPlayers(true).size() <= 1)
{
if (GetPlayers(true).size() == 1)
GetPlaces().add(0, GetPlayers(true).get(0));
if (GetPlaces().size() >= 1)
AddGems(GetPlaces().get(0), 15, "1st Place", false);
if (GetPlaces().size() >= 2)
AddGems(GetPlaces().get(1), 10, "2nd Place", false);
if (GetPlaces().size() >= 3)
AddGems(GetPlaces().get(2), 5, "3rd Place", false);
for (Player player : GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
SetState(GameState.End);
AnnounceEnd(GetPlaces());
}
}
@EventHandler @EventHandler
public void BlockDamage(BlockDamageEvent event) public void BlockDamage(BlockDamageEvent event)
{ {

View File

@ -1,5 +1,7 @@
package nautilus.game.arcade.game.games.deathtag; package nautilus.game.arcade.game.games.deathtag;
import java.util.ArrayList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -20,6 +22,7 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.deathtag.kits.*; import nautilus.game.arcade.game.games.deathtag.kits.*;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.NullKit; import nautilus.game.arcade.kit.NullKit;
@ -189,8 +192,9 @@ public class DeathTag extends SoloGame
public void SetChaser(Player player, boolean forced) public void SetChaser(Player player, boolean forced)
{ {
if (!GetPlaces().contains(player)) //Set them as OUT!
GetPlaces().add(0, player); if (GetTeam(player) != null)
GetTeam(player).SetPlacement(player, PlayerState.OUT);
SetPlayerTeam(player, _chasers); SetPlayerTeam(player, _chasers);
@ -262,24 +266,24 @@ public class DeathTag extends SoloGame
if (_runners.GetPlayers(true).size() <= 1) if (_runners.GetPlayers(true).size() <= 1)
{ {
if (_runners.GetPlayers(true).size() == 1) ArrayList<Player> places = _runners.GetPlacements(true);
GetPlaces().add(0, GetPlayers(true).get(0));
if (GetPlaces().size() >= 1) if (places.size() >= 1)
AddGems(GetPlaces().get(0), 15, "1st Place", false); AddGems(places.get(0), 15, "1st Place", false);
if (GetPlaces().size() >= 2) if (places.size() >= 2)
AddGems(GetPlaces().get(1), 10, "2nd Place", false); AddGems(places.get(1), 10, "2nd Place", false);
if (GetPlaces().size() >= 3) if (places.size() >= 3)
AddGems(GetPlaces().get(2), 5, "3rd Place", false); AddGems(places.get(2), 5, "3rd Place", false);
for (Player player : GetPlayers(false)) for (Player player : GetPlayers(false))
if (player.isOnline()) if (player.isOnline())
AddGems(player, 10, "Participation", false); AddGems(player, 10, "Participation", false);
AnnounceEnd(places);
SetState(GameState.End); SetState(GameState.End);
AnnounceEnd(GetPlaces());
} }
} }

View File

@ -350,26 +350,25 @@ public class DragonEscape extends SoloGame
{ {
SortScores(); SortScores();
_places.clear(); ArrayList<Player> places = new ArrayList<Player>();
for (DragonScore score : _ranks) for (DragonScore score : _ranks)
_places.add(score.Player); places.add(score.Player);
//Announce //Announce
AnnounceEnd(_places); AnnounceEnd(places);
//Gems //Gems
if (_winner != null) if (_winner != null)
AddGems(_winner, 10, "Course Complete", false); AddGems(_winner, 10, "Course Complete", false);
if (_places.size() >= 1) if (places.size() >= 1)
AddGems(_places.get(0), 20, "1st Place", false); AddGems(places.get(0), 20, "1st Place", false);
if (_places.size() >= 2) if (places.size() >= 2)
AddGems(_places.get(1), 15, "2nd Place", false); AddGems(places.get(1), 15, "2nd Place", false);
if (_places.size() >= 3) if (places.size() >= 3)
AddGems(_places.get(2), 10, "3rd Place", false); AddGems(places.get(2), 10, "3rd Place", false);
for (Player player : GetPlayers(false)) for (Player player : GetPlayers(false))
if (player.isOnline()) if (player.isOnline())

View File

@ -580,9 +580,9 @@ public class Draw extends SoloGame
SortScores(); SortScores();
//Set Places //Set Places
_places.clear(); ArrayList<Player> places = new ArrayList<Player>();
for (int i=0 ; i<_ranks.size() ; i++) for (int i=0 ; i<_ranks.size() ; i++)
_places.add(i, _ranks.get(i).Player); places.add(i, _ranks.get(i).Player);
//Award Gems //Award Gems
if (_ranks.size() >= 1) if (_ranks.size() >= 1)
@ -600,7 +600,7 @@ public class Draw extends SoloGame
AddGems(player, 10, "Participation", false); AddGems(player, 10, "Participation", false);
SetState(GameState.End); SetState(GameState.End);
AnnounceEnd(_places); AnnounceEnd(places);
} }
} }

View File

@ -257,9 +257,9 @@ public class Evolution extends SoloGame
SortScores(); SortScores();
//Set Places //Set Places
_places.clear(); ArrayList<Player> places = new ArrayList<Player>();
for (int i=0 ; i<_ranks.size() ; i++) for (int i=0 ; i<_ranks.size() ; i++)
_places.add(i, _ranks.get(i).Player); places.add(i, _ranks.get(i).Player);
//Award Gems //Award Gems
if (_ranks.size() >= 1) if (_ranks.size() >= 1)
@ -277,7 +277,7 @@ public class Evolution extends SoloGame
AddGems(player, 10, "Participation", false); AddGems(player, 10, "Participation", false);
SetState(GameState.End); SetState(GameState.End);
AnnounceEnd(_places); AnnounceEnd(places);
} }
@Override @Override

View File

@ -42,6 +42,7 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.milkcow.kits.*; import nautilus.game.arcade.game.games.milkcow.kits.*;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.NullKit; import nautilus.game.arcade.kit.NullKit;
@ -279,8 +280,9 @@ public class MilkCow extends SoloGame
public void SetCow(Player player, boolean forced) public void SetCow(Player player, boolean forced)
{ {
if (!GetPlaces().contains(player)) //Set them as OUT!
GetPlaces().add(0, player); if (GetTeam(player) != null)
GetTeam(player).SetPlacement(player, PlayerState.OUT);
SetPlayerTeam(player, _cows); SetPlayerTeam(player, _cows);
@ -424,9 +426,9 @@ public class MilkCow extends SoloGame
SortScores(); SortScores();
//Set Places //Set Places
_places.clear(); ArrayList<Player> places = new ArrayList<Player>();
for (int i=0 ; i<_ranks.size() ; i++) for (int i=0 ; i<_ranks.size() ; i++)
_places.add(i, _ranks.get(i).Player); places.add(i, _ranks.get(i).Player);
//Award Gems //Award Gems
if (_ranks.size() >= 1) if (_ranks.size() >= 1)
@ -444,7 +446,7 @@ public class MilkCow extends SoloGame
AddGems(player, 10, "Participation", false); AddGems(player, 10, "Participation", false);
SetState(GameState.End); SetState(GameState.End);
AnnounceEnd(_places); AnnounceEnd(places);
} }
@Override @Override

View File

@ -289,9 +289,9 @@ public class Quiver extends SoloGame
if ((!_ranks.isEmpty() && _ranks.get(0).Kills >= 20) || GetPlayers(true).size() <= 1) if ((!_ranks.isEmpty() && _ranks.get(0).Kills >= 20) || GetPlayers(true).size() <= 1)
{ {
//Set Places //Set Places
_places.clear(); ArrayList<Player> places = new ArrayList<Player>();
for (int i=0 ; i<_ranks.size() ; i++) for (int i=0 ; i<_ranks.size() ; i++)
_places.add(i, _ranks.get(i).Player); places.add(i, _ranks.get(i).Player);
//Award Gems //Award Gems
if (_ranks.size() >= 1) if (_ranks.size() >= 1)
@ -323,7 +323,7 @@ public class Quiver extends SoloGame
AddGems(player, 10, "Participation", false); AddGems(player, 10, "Participation", false);
SetState(GameState.End); SetState(GameState.End);
AnnounceEnd(_places); AnnounceEnd(places);
} }
} }
} }

View File

@ -171,10 +171,11 @@ public class SquidShooter extends SoloGame
if ((!_ranks.isEmpty() && _ranks.get(0).Kills >= 20) || GetPlayers(true).size() <= 1) if ((!_ranks.isEmpty() && _ranks.get(0).Kills >= 20) || GetPlayers(true).size() <= 1)
{ {
ArrayList<Player> places = new ArrayList<Player>();
//Set Places //Set Places
_places.clear();
for (int i=0 ; i<_ranks.size() ; i++) for (int i=0 ; i<_ranks.size() ; i++)
_places.add(i, _ranks.get(i).Player); places.add(i, _ranks.get(i).Player);
//Award Gems //Award Gems
if (_ranks.size() >= 1) if (_ranks.size() >= 1)
@ -192,7 +193,7 @@ public class SquidShooter extends SoloGame
AddGems(player, 10, "Participation", false); AddGems(player, 10, "Participation", false);
SetState(GameState.End); SetState(GameState.End);
AnnounceEnd(_places); AnnounceEnd(places);
} }
} }
} }

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.game.games.zombiesurvival; package nautilus.game.arcade.game.games.zombiesurvival;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -29,6 +30,7 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.zombiesurvival.kits.*; import nautilus.game.arcade.game.games.zombiesurvival.kits.*;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.NullKit; import nautilus.game.arcade.kit.NullKit;
@ -141,9 +143,11 @@ public class ZombieSurvival extends SoloGame
public void SetChaser(Player player, boolean forced) public void SetChaser(Player player, boolean forced)
{ {
if (!GetPlaces().contains(player)) //Set them as OUT!
GetPlaces().add(0, player); if (GetTeam(player) != null)
GetTeam(player).SetPlacement(player, PlayerState.OUT);
//Change to Undead
SetPlayerTeam(player, _undead); SetPlayerTeam(player, _undead);
//Kit //Kit
@ -323,35 +327,25 @@ public class ZombieSurvival extends SoloGame
if (_survivors.GetPlayers(true).size() <= 1) if (_survivors.GetPlayers(true).size() <= 1)
{ {
if (_survivors.GetPlayers(true).size() == 1) ArrayList<Player> places = _survivors.GetPlacements(true);
GetPlaces().add(0, GetPlayers(true).get(0));
if (GetPlaces().size() >= 1) if (places.size() >= 1)
AddGems(GetPlaces().get(0), 15, "1st Place", false); AddGems(places.get(0), 15, "1st Place", false);
if (GetPlaces().size() >= 2) if (places.size() >= 2)
AddGems(GetPlaces().get(1), 10, "2nd Place", false); AddGems(places.get(1), 10, "2nd Place", false);
if (GetPlaces().size() >= 3) if (places.size() >= 3)
AddGems(GetPlaces().get(2), 5, "3rd Place", false); AddGems(places.get(2), 5, "3rd Place", false);
/*
int sections = GetPlaces().size()/10;
for (int i=0 ; i<5 ; i++)
{
for (int j=i*sections ; j < j*sections + sections ; j++)
{
AddGems(GetPlaces().get(j), 5-i, "Top " + ((i+1)*10) + "%", false);
}
}
*/
for (Player player : GetPlayers(false)) for (Player player : GetPlayers(false))
if (player.isOnline()) if (player.isOnline())
AddGems(player, 10, "Participation", false); AddGems(player, 10, "Participation", false);
AnnounceEnd(places);
SetState(GameState.End); SetState(GameState.End);
AnnounceEnd(GetPlaces());
} }
} }

View File

@ -61,10 +61,10 @@ public class GameChatManager implements Listener
//Rank Prefix //Rank Prefix
String rankStr = ""; String rankStr = "";
if (rank != Rank.ALL && (Manager.GetGame() != null && Manager.GetGame().GetType() != GameType.UHC)) if (rank != Rank.ALL)
rankStr = rank.GetTag(true, true) + " "; rankStr = rank.GetTag(true, true) + " ";
if (ownsUltra && !rank.Has(Rank.ULTRA) && (Manager.GetGame() != null && Manager.GetGame().GetType() != GameType.UHC)) if (ownsUltra && !rank.Has(Rank.ULTRA))
rankStr = Rank.ULTRA.GetTag(true, true) + " "; rankStr = Rank.ULTRA.GetTag(true, true) + " ";
//Base Format //Base Format
@ -91,11 +91,6 @@ public class GameChatManager implements Listener
{ {
globalMessage = true; globalMessage = true;
event.setFormat(dead + rankStr + team.GetColor() + "%1$s " + C.cWhite + "%2$s"); event.setFormat(dead + rankStr + team.GetColor() + "%1$s " + C.cWhite + "%2$s");
if (Manager.GetGame().GetType() == GameType.UHC)
event.setFormat(ChatColor.YELLOW + "%1$s " + ChatColor.WHITE + "%2$s");
else
event.setFormat(dead + rankStr + team.GetColor() + "%1$s " + C.cWhite + "%2$s");
} }
} }

View File

@ -132,9 +132,6 @@ public class GameGemManager implements Listener
if (Manager.IsTournamentServer()) if (Manager.IsTournamentServer())
return; return;
if (game.GetType() == GameType.UHC)
return;
//Inform Gems //Inform Gems
AnnounceGems(game, player, game.GetPlayerGems().get(player), give); AnnounceGems(game, player, game.GetPlayerGems().get(player), give);

View File

@ -303,21 +303,8 @@ public class GameLobbyManager implements IPacketRunnable, Listener
return; return;
} }
//UHC Empty
if (game.GetTeamList().size() > 10 && game.GetType() == GameType.UHC)
{
WriteTeamLine("Season", 0, 159, (byte)15);
WriteTeamLine("7", 1, 159, (byte)4);
WriteKitLine("Season", 0, 159, (byte)15);
WriteKitLine("7", 1, 159, (byte)4);
CreateScoreboards();
return;
}
//Standard //Standard
if (game.GetKits().length > 1 || game.GetType() != GameType.UHC) if (game.GetKits().length > 1 || game.GetTeamList().size() < 6)
{ {
//Display //Display
ArrayList<GameTeam> teams = new ArrayList<GameTeam>(); ArrayList<GameTeam> teams = new ArrayList<GameTeam>();

View File

@ -171,6 +171,13 @@ public class GameManager implements Listener
} }
} }
else if (game.GetType() != GameType.UHC) else if (game.GetType() != GameType.UHC)
{
if (UtilTime.elapsed(game.GetStateTime(), 10800000))
{
game.SetState(GameState.End);
}
}
else
{ {
if (UtilTime.elapsed(game.GetStateTime(), 1200000)) if (UtilTime.elapsed(game.GetStateTime(), 1200000))
{ {

View File

@ -218,19 +218,6 @@ public class GamePlayerManager implements Listener
if (past != null) if (past != null)
{ {
game.RemoveTeamPreference(player); game.RemoveTeamPreference(player);
if (game.GetType() == GameType.UHC)
{
String players = "";
for (Player other : game.GetTeamPreferences().get(past))
players += other.getName() + " ";
if (players.length() > 0)
players = players.substring(0, players.length()-1);
for (Player other : game.GetTeamPreferences().get(past))
UtilPlayer.message(other, past.GetFormattedName() + " Team: " + ChatColor.RESET + players);
}
} }
if (!game.GetTeamPreferences().containsKey(team)) if (!game.GetTeamPreferences().containsKey(team))
@ -239,23 +226,8 @@ public class GamePlayerManager implements Listener
game.GetTeamPreferences().get(team).add(player); game.GetTeamPreferences().get(team).add(player);
} }
if (game.GetType() == GameType.UHC)
{
String players = "";
for (Player other : game.GetTeamPreferences().get(team))
players += other.getName() + " ";
if (players.length() > 0)
players = players.substring(0, players.length()-1);
for (Player other : game.GetTeamPreferences().get(team))
UtilPlayer.message(other, team.GetFormattedName() + " Team: " + ChatColor.RESET + players);
}
else
{
UtilPlayer.message(player, F.main("Team", "You are " + F.elem(game.GetTeamQueuePosition(player)) + " in queue for " + F.elem(team.GetFormattedName() + " Team") + ".")); UtilPlayer.message(player, F.main("Team", "You are " + F.elem(game.GetTeamQueuePosition(player)) + " in queue for " + F.elem(team.GetFormattedName() + " Team") + "."));
} }
}
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void KitInteract(PlayerInteractEntityEvent event) public void KitInteract(PlayerInteractEntityEvent event)

View File

@ -120,9 +120,6 @@ public class MiscManager implements Listener
if (Manager.GetGame() == null) if (Manager.GetGame() == null)
return; return;
if (Manager.GetGame().GetType() == GameType.UHC)
return;
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
if (!Manager.GetGame().IsAlive(player)) if (!Manager.GetGame().IsAlive(player))

View File

@ -50,6 +50,11 @@ public class GameScoreboard
return _sideObjective; return _sideObjective;
} }
public String ParseTeamName(String name)
{
return name.substring(0, Math.min(16, name.length()));
}
public void CreateTeams() public void CreateTeams()
{ {
System.out.println("Creating Scoreboard Teams."); System.out.println("Creating Scoreboard Teams.");
@ -57,16 +62,7 @@ public class GameScoreboard
//Base Groups //Base Groups
for (Rank rank : Rank.values()) for (Rank rank : Rank.values())
{ {
//Spectator _scoreboard.registerNewTeam(ParseTeamName(rank.Name + "SPEC")).setPrefix(ChatColor.GRAY + "");
if (rank == Rank.ALL)
{
_scoreboard.registerNewTeam(rank.Name + "SPEC").setPrefix(ChatColor.GRAY + "");
}
else
{
_scoreboard.registerNewTeam(rank.Name + "SPEC").setPrefix(ChatColor.GRAY + "");
//_scoreboard.registerNewTeam(rank.Name + "SPEC").setPrefix(rank.Color + C.Bold + rank.Name.toUpperCase() + ChatColor.RESET + " " + ChatColor.GRAY);
}
} }
//Team Groups //Team Groups
@ -74,15 +70,7 @@ public class GameScoreboard
{ {
for (Rank rank : Rank.values()) for (Rank rank : Rank.values())
{ {
if (rank == Rank.ALL) _scoreboard.registerNewTeam(ParseTeamName(rank.Name + team.GetName().toUpperCase())).setPrefix(team.GetColor() + "");
{
_scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + "");
}
else
{
//_scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.Color + C.Bold + rank.Name.toUpperCase() + ChatColor.RESET + " " + team.GetColor());
_scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + "");
}
} }
} }
} }
@ -95,7 +83,7 @@ public class GameScoreboard
if (teamName == null) if (teamName == null)
teamName = ""; teamName = "";
String team = Game.Manager.GetClients().Get(player).GetRank().Name + teamName; String team = ParseTeamName(Game.Manager.GetClients().Get(player).GetRank().Name + teamName);
try try
{ {