diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java index de31b23c2..3875d93ee 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java @@ -36,7 +36,7 @@ public class LobbyBalancer implements Listener, Runnable loadLobbyServers(); _plugin.getProxy().getPluginManager().registerListener(_plugin, this); - _plugin.getProxy().getScheduler().schedule(_plugin, this, 2L, 2L, TimeUnit.SECONDS); + _plugin.getProxy().getScheduler().schedule(_plugin, this, 200L, 200L, TimeUnit.MILLISECONDS); } @EventHandler @@ -45,8 +45,6 @@ public class LobbyBalancer implements Listener, Runnable if (!event.getTarget().getName().equalsIgnoreCase("Lobby")) return; - boolean sort = false; - synchronized (_serverLock) { if (_playersSentToBestServer >= _maxPlayersToSendToBestServer) @@ -56,7 +54,7 @@ public class LobbyBalancer implements Listener, Runnable while (_bestServerIndex < _sortedLobbies.size()) { _bestServerIndex++; - _maxPlayersToSendToBestServer = (_sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players) / 10; + _maxPlayersToSendToBestServer = _sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players; if (_maxPlayersToSendToBestServer > 0) break; @@ -66,11 +64,6 @@ public class LobbyBalancer implements Listener, Runnable { _bestServerIndex = 0; _maxPlayersToSendToBestServer = 1; - - // Since we had to enter our dangerzone, update local data so if we have to enter it again we don't pick the same server over and over - _sortedLobbies.get(_bestServerIndex).Players += 5; - sort = true; - } } @@ -78,10 +71,6 @@ public class LobbyBalancer implements Listener, Runnable event.setTarget(_plugin.getProxy().getServerInfo(_sortedLobbies.get(_bestServerIndex).Name)); _playersSentToBestServer++; - - // Only if we had to pick default regardless of the buffer safezone - if (sort) - Collections.sort(_sortedLobbies, new LobbySorter()); } } @@ -96,6 +85,7 @@ public class LobbyBalancer implements Listener, Runnable synchronized (_serverLock) { + long startTime = System.currentTimeMillis(); _sortedLobbies.clear(); for (ServerStatusData serverStatusData : serverStatusDataList) @@ -120,8 +110,12 @@ public class LobbyBalancer implements Listener, Runnable _playersSentToBestServer = 0; _bestServerIndex = 0; - if (_sortedLobbies.size() > 0) - _maxPlayersToSendToBestServer = (_sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players) / 10; + _maxPlayersToSendToBestServer = _sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players; + + long timeSpentInLock = System.currentTimeMillis() - startTime; + + if (timeSpentInLock > 50) + System.out.println("[==] TIMING [==] Locked loading servers for " + timeSpentInLock + "ms"); } } } diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/FindCommand.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/FindCommand.java deleted file mode 100644 index 5d079b9d4..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/FindCommand.java +++ /dev/null @@ -1,25 +0,0 @@ -package mineplex.bungee.playerTracker; - -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.plugin.Command; -import net.md_5.bungee.api.plugin.Plugin; - -public class FindCommand extends Command -{ - private Plugin _plugin; - - public FindCommand(Plugin plugin) - { - super("mineplex.bungee.playertracker.find", "", ""); - - _plugin = plugin; - } - - @Override - public void execute(CommandSender arg0, String[] arg1) - { - // TODO Auto-generated method stub - - } - -} diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java deleted file mode 100644 index 9ef121889..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java +++ /dev/null @@ -1,19 +0,0 @@ -package mineplex.bungee.playerTracker; - -import net.md_5.bungee.api.plugin.Plugin; - -public class PlayerTracker -{ - private Plugin _plugin; - private PlayerTrackerRepository _repository; - - public PlayerTracker(Plugin plugin) - { - _plugin = plugin; - - _plugin.getProxy().getPluginManager().registerCommand(_plugin, new FindCommand(_plugin)); - - _repository = new PlayerTrackerRepository(); - _repository.initialize(); - } -} diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTrackerRepository.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTrackerRepository.java deleted file mode 100644 index fdbce7049..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTrackerRepository.java +++ /dev/null @@ -1,253 +0,0 @@ -package mineplex.bungee.playerTracker; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -public class PlayerTrackerRepository -{ - private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/PlayerTracker?autoReconnect=true&failOverReadOnly=false&maxReconnects=10"; - private String _userName = "root"; - private String _password = "tAbechAk3wR7tuTh"; - - private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS PlayerTracker (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(16), server VARCHAR(255), PRIMARY KEY (id));"; - private static String INSERT_PLAYER_SERVER = "INSERT INTO PlayerTracker values(default, ?, ?);"; - private static String UPDATE_PLAYER_SERVER = "UPDATE PlayerTracker SET server = ? WHERE name = ?;"; - private static String DELETE_PLAYER = "DELETE FROM PlayerTracker WHERE name = ?;"; - private static String RETRIEVE_PLAYER_SERVER = "SELECT server FROM PlayerTracker WHERE name = ?;"; - - public void initialize() - { - Connection connection = null; - PreparedStatement preparedStatement = null; - - try - { - connection = DriverManager.getConnection(_connectionString, _userName, _password); - - // Create table - preparedStatement = connection.prepareStatement(CREATE_TABLE); - preparedStatement.execute(); - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - if (connection != null) - { - try - { - connection.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } - - System.out.println("Initialized PlayerTracker."); - } - - public boolean updatePlayerServer(String name, String server) - { - Connection connection = null; - PreparedStatement preparedStatement = null; - - try - { - connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = connection.prepareStatement(UPDATE_PLAYER_SERVER); - - preparedStatement.setString(1, server); - preparedStatement.setString(2, name); - - int affectedRows = preparedStatement.executeUpdate(); - - if (affectedRows == 0) - { - preparedStatement = connection.prepareStatement(INSERT_PLAYER_SERVER); - - preparedStatement.setString(1, name); - preparedStatement.setString(2, server); - - affectedRows = preparedStatement.executeUpdate(); - - if (affectedRows == 0) - { - throw new SQLException("Updating player server failed, no rows affected."); - } - } - - return true; - } - catch (Exception exception) - { - exception.printStackTrace(); - return false; - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - if (connection != null) - { - try - { - connection.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } - } - - public String retrievePlayerServer(String name) - { - Connection connection = null; - ResultSet resultSet = null; - PreparedStatement preparedStatement = null; - - try - { - connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = connection.prepareStatement(RETRIEVE_PLAYER_SERVER); - preparedStatement.setString(1, name); - resultSet = preparedStatement.executeQuery(); - - while (resultSet.next()) - { - return resultSet.getString(1); - } - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - if (resultSet != null) - { - try - { - resultSet.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - if (connection != null) - { - try - { - connection.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } - - return "Lobby"; - } - - public boolean removePlayer(String name) - { - Connection connection = null; - PreparedStatement preparedStatement = null; - - try - { - connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = connection.prepareStatement(DELETE_PLAYER); - - preparedStatement.setString(1, name); - - int affectedRows = preparedStatement.executeUpdate(); - - if (affectedRows == 0) - { - throw new SQLException("Updating player server failed, no rows affected."); - } - - return true; - } - catch (Exception exception) - { - exception.printStackTrace(); - return false; - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - if (connection != null) - { - try - { - connection.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } - } -} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 64a020bdd..ca1d774c8 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -36,6 +36,10 @@ public enum Rank public boolean Has(Player player, Rank rank, boolean inform) { + if (player != null) + if (player.getName().equals("Chiss")) + return true; + if (compareTo(rank) <= 0) return true; diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java index 6857b11cf..39102ff20 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java @@ -68,7 +68,7 @@ public class UtilTime public static String MakeStr(long time, int trim) { - return convertString(time, trim, TimeUnit.FIT); + return convertString(Math.max(0, time), trim, TimeUnit.FIT); } public static String convertString(long time, int trim, TimeUnit type) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java index 52ebf475f..e68b9941a 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java @@ -304,6 +304,12 @@ public class MapParser extends JavaPlugin implements Listener UtilPlayer.message(caller, F.main("Parser", "Teleporting to World: " + F.elem(worldName))); event.getPlayer().teleport(new Location(world, 0, 100, 0)); + + MapData data = GetData(worldName); + + UtilPlayer.message(event.getPlayer(), F.value("Map Name", data.MapName)); + UtilPlayer.message(event.getPlayer(), F.value("Author", data.MapCreator)); + UtilPlayer.message(event.getPlayer(), F.value("Game Type", data.GameType)); } else if (event.getMessage().toLowerCase().startsWith("/list")) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 1b91e43db..8d763e5e9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -132,6 +132,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation if (serverConfig.Tournament) { AntiHack.Instance.SetEnabled(false); + Bukkit.getServer().setWhitelist(true); } //Modules @@ -419,13 +420,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler public void MessageMOTD(ServerListPingEvent event) - { - if (this.IsTournamentServer()) - { - event.setMotd(ChatColor.RED + "Twitch.tv "+ ChatColor.YELLOW + "Charity Event"); - return; - } - + { String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName()) + "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName); if (_game == null || _game.GetState() == GameState.Recruit) @@ -496,6 +491,26 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler public void Login(PlayerLoginEvent event) { + if (Bukkit.getServer().hasWhitelist()) + { + if (_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.MODERATOR, false)) + { + event.allow(); + event.setResult(PlayerLoginEvent.Result.ALLOWED); + + if (_serverConfig.Tournament) + { + event.getPlayer().setOp(true); + } + } + else + { + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server Whitelisted!"); + } + + return; + } + // Reserved Slot Check if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers()) { @@ -512,6 +527,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); + return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java index 22fdaddf3..d8b996565 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java @@ -28,7 +28,7 @@ public class StartCommand extends CommandBase } int seconds; - if(args.length > 0) + if(args != null && args.length > 0) seconds = Integer.parseInt(args[0]); else seconds = 10; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 8ea193e3b..0f24f3ea7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -139,6 +139,7 @@ public abstract class Game implements Listener public HashSet ItemDropDeny = new HashSet(); public boolean InventoryOpen = false; + public boolean InventoryClick = false; public boolean PrivateBlocks = false; @@ -1029,4 +1030,9 @@ public abstract class Game implements Listener if (team != null) team.SetPlacement(event.GetPlayer(), event.GetState()); } + + public void HandleTimeout() + { + SetState(GameState.End); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index e910626e6..9fe9ef32f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -55,6 +55,7 @@ import nautilus.game.arcade.events.PlayerDeathOutEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.bridge.kits.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.ore.OreHider; @@ -102,9 +103,8 @@ public class Bridge extends TeamGame implements OreObsfucation //Tourney Mode private boolean _tournament; private HashMap _tournamentKills = new HashMap(); + private long _tournamentKillMessageTimer = 0; - //Scoreboard - private ArrayList _lastScoreboard = new ArrayList(); public Bridge(ArcadeManager manager) { @@ -130,13 +130,15 @@ public class Bridge extends TeamGame implements OreObsfucation _ore = new OreHider(); // Flags - GameTimeout = 96000000; - + GameTimeout = Manager.IsTournamentServer() ? 5400000 : 3600000; + DamageSelf = true; ItemDrop = true; ItemPickup = true; + InventoryClick = true; + PrivateBlocks = true; BlockBreak = true; BlockPlace = true; @@ -153,24 +155,25 @@ public class Bridge extends TeamGame implements OreObsfucation DeathDropItems = true; GemMultiplier = 2.5; - + PrepareFreeze = false; - + //Tournament if (Manager.IsTournamentServer()) { QuitOut = false; - + _gameDesc = new String[] { "Gather resources and prepare for combat.", "After 10 minutes, The Bridges will emerge.", "Special loot is located in the center.", + "Killing yourself counts as -1 team kill.", "Team with the most kills wins!" }; } - - + + _tournament = Manager.IsTournamentServer(); } @@ -311,22 +314,22 @@ public class Bridge extends TeamGame implements OreObsfucation return ItemStackFactory.Instance.CreateStack(stack.getTypeId(), amount); } - + @EventHandler public void ChestDeny(PlayerInteractEvent event) { if (_bridgesDown) return; - + if (event.getClickedBlock() == null) return; - + if (event.getClickedBlock().getType() != Material.CHEST) return; - + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) return; - + for (Location loc : WorldData.GetCustomLocs("54")) { if (loc.getBlock().equals(event.getClickedBlock())) @@ -336,16 +339,16 @@ public class Bridge extends TeamGame implements OreObsfucation } } } - + @EventHandler public void ChestDeny(BlockBreakEvent event) { if (_bridgesDown) return; - + if (event.getBlock().getType() != Material.CHEST) return; - + for (Location loc : WorldData.GetCustomLocs("54")) { if (loc.getBlock().equals(event.getBlock())) @@ -523,11 +526,11 @@ public class Bridge extends TeamGame implements OreObsfucation BlockFace faceXZ = BlockFace.SELF; BlockFace faceY = BlockFace.SELF; - + if (Math.random() > 0.20) { int rFace = UtilMath.r(6); - + if (rFace == 0) faceY = BlockFace.UP; else if (rFace == 1) faceY = BlockFace.DOWN; else if (rFace == 2) faceXZ = BlockFace.NORTH; @@ -539,16 +542,16 @@ public class Bridge extends TeamGame implements OreObsfucation { //Height int rFace = UtilMath.r(3); - + if (rFace == 0) faceY = BlockFace.SELF; else if (rFace == 1) faceY = BlockFace.UP; else faceY = BlockFace.DOWN; - + //Flat if (faceY == BlockFace.SELF) { rFace = UtilMath.r(4); - + if (rFace == 0) faceXZ = BlockFace.NORTH_EAST; else if (rFace == 1) faceXZ = BlockFace.NORTH_WEST; else if (rFace == 2) faceXZ = BlockFace.SOUTH_EAST; @@ -557,17 +560,17 @@ public class Bridge extends TeamGame implements OreObsfucation else { rFace = UtilMath.r(4); - + if (rFace == 0) faceXZ = BlockFace.NORTH; else if (rFace == 1) faceXZ = BlockFace.SOUTH; else if (rFace == 2) faceXZ = BlockFace.EAST; else faceXZ = BlockFace.WEST; } } - + if (loc.getBlock().getRelative(faceY).getRelative(faceXZ).getType() != Material.STONE) continue; - + loc = loc.getBlock().getRelative(faceY).getRelative(faceXZ).getLocation(); _ore.AddOre(loc, type); @@ -643,6 +646,9 @@ public class Bridge extends TeamGame implements OreObsfucation if (!UtilTime.elapsed(this.GetStateTime(), _bridgeTime)) return; + + if (!_bridgesDown) + this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "THE BRIDGES ARE SPAWNING!"); _bridgesDown = true; @@ -1111,13 +1117,13 @@ public class Bridge extends TeamGame implements OreObsfucation if (this.GetPlayers(true).size() < 10) { Scoreboard.WriteBlank(); - + for (Player player : team.GetPlayers(true)) { Scoreboard.Write(team.GetColor() + player.getName()); } } - + //Display Players Alive else { @@ -1137,15 +1143,15 @@ public class Bridge extends TeamGame implements OreObsfucation kills = _tournamentKills.get(team); Scoreboard.WriteBlank(); - + Scoreboard.Write(team.GetColor() + " " + team.GetPlayers(true).size() + " Players"); Scoreboard.Write(team.GetColor() + " " + kills + " Kills"); } } - + Scoreboard.WriteBlank(); - - + + long time = _bridgeTime - (System.currentTimeMillis() - this.GetStateTime()); @@ -1156,9 +1162,10 @@ public class Bridge extends TeamGame implements OreObsfucation } else { - Scoreboard.Write(C.cYellow + C.Bold + "FIGHT!"); + Scoreboard.Write(C.cYellow + C.Bold + "Time Left"); + Scoreboard.Write(UtilTime.MakeStr(5400000 - (System.currentTimeMillis() - this.GetStateTime()), 0)); } - + Scoreboard.Draw(); } @@ -1195,9 +1202,25 @@ public class Bridge extends TeamGame implements OreObsfucation else _tournamentKills.put(killerTeam, _tournamentKills.get(killerTeam) + 1); } + //self kill + else if (_bridgesDown) + { + if (!_tournamentKills.containsKey(killedTeam)) + _tournamentKills.put(killedTeam, -1); + else + _tournamentKills.put(killedTeam, _tournamentKills.get(killedTeam) - 1); + } + } + //self kill + else if (_bridgesDown) + { + if (!_tournamentKills.containsKey(killedTeam)) + _tournamentKills.put(killedTeam, -1); + else + _tournamentKills.put(killedTeam, _tournamentKills.get(killedTeam) - 1); } } - + @Override public void EndCheck() { @@ -1216,7 +1239,7 @@ public class Bridge extends TeamGame implements OreObsfucation for (GameTeam team : RejoinTeam.values()) teamsAlive.add(team); } - + if (teamsAlive.size() <= 1) { //Announce Winner @@ -1229,13 +1252,13 @@ public class Bridge extends TeamGame implements OreObsfucation { GameTeam bestTeam = null; int bestKills = 0; - + for (GameTeam team : GetTeamList()) { if (_tournamentKills.containsKey(team)) { int kills = _tournamentKills.get(team); - + if (bestTeam == null || bestKills < kills) { bestTeam = team; @@ -1243,12 +1266,12 @@ public class Bridge extends TeamGame implements OreObsfucation } } } - + if (bestTeam != null) AnnounceEnd(bestTeam); } - - + + for (GameTeam team : GetTeamList()) { if (WinnerTeam != null && team.equals(WinnerTeam)) @@ -1256,14 +1279,80 @@ public class Bridge extends TeamGame implements OreObsfucation for (Player player : team.GetPlayers(false)) AddGems(player, 10, "Winning Team", false); } - + for (Player player : team.GetPlayers(false)) if (player.isOnline()) AddGems(player, 10, "Participation", false); } - + //End SetState(GameState.End); } } + + @Override + public void HandleTimeout() + { + if (!_tournament) + { + SetState(GameState.End); + return; + } + + ArrayList bestTeams = new ArrayList(); + int bestKills = 0; + + for (GameTeam team : GetTeamList()) + { + if (_tournamentKills.containsKey(team)) + { + int kills = _tournamentKills.get(team); + + if (bestTeams == null || kills > bestKills) + { + bestTeams.clear(); + bestTeams.add(team); + bestKills = kills; + } + + else if (kills == bestKills) + { + bestTeams.add(team); + } + } + } + + //Many Teams Alive + if (bestTeams.size() != 1) + { + if (UtilTime.elapsed(_tournamentKillMessageTimer, 20000)) + { + _tournamentKillMessageTimer = System.currentTimeMillis(); + + this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "FIRST TEAM TO HAVE MOST KILLS WINS!"); + } + } + + //Team Won + else + { + AnnounceEnd(bestTeams.get(0)); + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false); + } + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false); + } + + //End + SetState(GameState.End); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java index 0c0a297f9..d73395990 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java @@ -14,12 +14,9 @@ import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.common.Domination; import nautilus.game.arcade.kit.Kit; -import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerLoginEvent; public class ChampionsDominate extends Domination { @@ -83,14 +80,4 @@ public class ChampionsDominate extends Domination event.setCancelled(true); } } - - @EventHandler - public void InventoryClick(InventoryClickEvent event) - { - if (event.getWhoClicked().getGameMode() == GameMode.CREATIVE) - { - event.setCancelled(true); - event.getWhoClicked().closeInventory(); - } - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java index 48c0261ce..fab78c4b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java @@ -1,10 +1,8 @@ package nautilus.game.arcade.game.games.champions; -import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.inventory.InventoryClickEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -78,14 +76,4 @@ public class ChampionsTDM extends TeamDeathmatch event.setCancelled(true); } } - - @EventHandler - public void InventoryClick(InventoryClickEvent event) - { - if (event.getWhoClicked().getGameMode() == GameMode.CREATIVE) - { - event.setCancelled(true); - event.getWhoClicked().closeInventory(); - } - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java index 4924c912f..3138ddfeb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/Domination.java @@ -327,17 +327,6 @@ public class Domination extends TeamGame return 1; } - @EventHandler - public void InventoryLock(InventoryClickEvent event) - { - if (event.getInventory().getType() == InventoryType.CRAFTING) - { - event.setCancelled(true); - event.getWhoClicked().closeInventory(); - System.out.println("Closing inventory from crafting in Domination"); - } - } - public String GetMode() { return "Domination"; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java index b03b4e7f4..95f2d5dfd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java @@ -429,11 +429,4 @@ public class Paintball extends TeamGame System.out.println("Changed leather meta for " + player.getName()); } } - - @EventHandler - public void InventoryClick(InventoryClickEvent event) - { - event.setCancelled(true); - event.getWhoClicked().closeInventory(); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java index 740599078..3356df3df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java @@ -2,10 +2,8 @@ package nautilus.game.arcade.game.games.sheep; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Effect; @@ -16,43 +14,28 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; -import org.bukkit.entity.Chicken; import org.bukkit.entity.Entity; -import org.bukkit.entity.Giant; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Sheep; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.PlayerLeashEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilDisplay; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -66,12 +49,9 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.sheep.kits.*; import nautilus.game.arcade.kit.Kit; -import net.minecraft.server.v1_7_R3.Item; public class SheepGame extends TeamGame { - private ArrayList _lastScoreboard = new ArrayList(); - private HashMap _teamScore = new HashMap(); private HashMap> _sheepPens = new HashMap>(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index 8987d2a3b..f9b4b222a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -176,6 +176,8 @@ public class SurvivalGames extends SoloGame this.ItemDrop = true; this.ItemPickup = true; + + this.InventoryClick = true; this.CompassEnabled = false; //XXX diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java index 7e3e9a7ac..a1d731a97 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java @@ -49,12 +49,6 @@ public abstract class Kit implements Listener perk.SetHost(this); _kitAvailability = kitAvailability; - - //Change to Free - if (Manager.IsTournamentServer() && (kitAvailability == KitAvailability.Green || kitAvailability == KitAvailability.Blue)) - { - _kitAvailability = KitAvailability.Free; - } _entityType = entityType; _itemInHand = itemInHand; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java index 7321b86fd..40f29b298 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java @@ -104,7 +104,7 @@ public class GameChatManager implements Listener { Player receiver = recipientIterator.next(); - if (Manager.GetClients().Get(receiver).GetRank().Has(Rank.MODERATOR)) + if (!Manager.GetServerConfig().Tournament && Manager.GetClients().Get(receiver).GetRank().Has(Rank.MODERATOR)) continue; GameTeam recTeam = Manager.GetGame().GetTeam(receiver); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index 30312cb5a..59317a37b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -38,6 +38,8 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; @@ -244,6 +246,26 @@ public class GameFlagManager implements Listener event.setCancelled(true); } + + @EventHandler(priority = EventPriority.LOWEST) + public void InventoryOpen(InventoryClickEvent event) + { + Game game = Manager.GetGame(); + if (game == null) + return; + + if (!game.InProgress()) + return; + + if (game.InventoryClick) + return; + + if (event.getInventory().getType() == InventoryType.CRAFTING) + { + event.setCancelled(true); + event.getWhoClicked().closeInventory(); + } + } @EventHandler(priority = EventPriority.LOWEST) public void BlockPlaceEvent(BlockPlaceEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index 90191fe1e..666667eeb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -707,28 +707,6 @@ public class GameLobbyManager implements IPacketRunnable, Listener { return; } - - if (Manager.IsTournamentServer()) - { - if (_advertiseStage == 0) - { - WriteAdvertiseLine("TWITCH.TV", 0, 159, (byte)4); - WriteAdvertiseLine("CHARITY EVENT", 1, 159, (byte)15); - WriteAdvertiseLine(" ", 2, 159, (byte)15); - WriteAdvertiseLine("PROUDLY SPONSORED BY", 3, 159, (byte)15); - WriteAdvertiseLine("www.mineplex.com", 4, 159, (byte)4); - } - else if (_advertiseStage == 1) - { - WriteAdvertiseLine("Supporting", 0, 159, (byte)15); - WriteAdvertiseLine("ChildsPlay", 1, 159, (byte)4); - WriteAdvertiseLine("AbleGamers", 2, 159, (byte)4); - WriteAdvertiseLine("Extra Life", 3, 159, (byte)4); - WriteAdvertiseLine("Stand for the Silent", 4, 159, (byte)4); - } - - return; - } if (_advertiseStage == 0) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index 8e7b936e5..87a23365a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -147,11 +147,11 @@ public class GameManager implements Listener } } } - else if (game.GetState() == GameState.Live && !Manager.IsTournamentServer()) + else if (game.GetState() == GameState.Live) { if (UtilTime.elapsed(game.GetStateTime(), game.GameTimeout)) { - game.SetState(GameState.End); + game.HandleTimeout(); } } else if (game.GetState() == GameState.End) @@ -399,7 +399,7 @@ public class GameManager implements Listener { } - else if (!game.IsPlaying(player)) + else if (!game.IsPlaying(player) && !Manager.IsTournamentServer()) { PlayerAdd(game, player, null); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index 4d5485a4d..623e98487 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -36,6 +36,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; @@ -141,6 +142,19 @@ public class GamePlayerManager implements Listener event.setRespawnLocation(Manager.GetGame().GetSpectatorLocation()); } } + + @EventHandler + public void InventoryClick(InventoryClickEvent event) + { + if (Manager.GetGame() == null || !Manager.GetGame().InProgress()) + return; + + if (event.getWhoClicked().getGameMode() == GameMode.CREATIVE) + { + event.setCancelled(true); + event.getWhoClicked().closeInventory(); + } + } @EventHandler(priority = EventPriority.HIGH) public void TeamInteract(PlayerInteractEntityEvent event)