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

This commit is contained in:
Jonathan Williams 2014-08-30 02:04:32 -07:00
commit b07670f6af
26 changed files with 274 additions and 47 deletions

View File

@ -115,6 +115,9 @@ public class UtilAlg
public static <T> T Random(List<T> list)
{
if (list.isEmpty())
return null;
return list.get(UtilMath.r(list.size()));
}

View File

@ -142,13 +142,13 @@ public enum Achievement
BLOCK_HUNT_HUNTER_OF_THE_YEAR("Hunter of the Year", 1200,
new String[] {"Block Hunt.HunterOfTheYear"},
new String[] {"Kill 7 Hiders in a single game"},
new int[] {100},
new int[] {1},
AchievementCategory.BLOCK_HUNT),
BLOCK_HUNT_BAD_HIDER("Bad Hider", 1000,
new String[] {"Block Hunt.BadHider"},
new String[] {"Win as Hider without disguising"},
new int[] {100},
new int[] {1},
AchievementCategory.BLOCK_HUNT),
//Draw My Thing

View File

@ -46,7 +46,7 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
{
newArgs = new String[args.length - 1];
for (int i = 0 ; i < newArgs.length; i++)
for (int i = 0 ; i < newArgs.length; i++)
{
newArgs[i] = args[i+1];
}

View File

@ -73,6 +73,7 @@ import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.commands.ForcefieldRadius;
import mineplex.hub.commands.GameModeCommand;
import mineplex.hub.commands.NewsCommand;
import mineplex.hub.modules.ForcefieldManager;
import mineplex.hub.modules.JumpManager;
@ -309,6 +310,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
public void AddCommands()
{
AddCommand(new NewsCommand(this));
AddCommand(new GameModeCommand(this));
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -463,7 +465,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
@EventHandler(priority = EventPriority.LOW)
public void AdminOP(PlayerJoinEvent event)
{
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.ADMIN))
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.OWNER))
event.getPlayer().setOp(true);
else
event.getPlayer().setOp(false);

View File

@ -0,0 +1,25 @@
package mineplex.hub.commands;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.hub.HubManager;
public class GameModeCommand extends CommandBase<HubManager>
{
public GameModeCommand(HubManager plugin)
{
super(plugin, Rank.ADMIN, new String[] {"gm"});
}
@Override
public void Execute(Player caller, String[] args)
{
if (caller.getGameMode() == GameMode.SURVIVAL)
caller.setGameMode(GameMode.CREATIVE);
else
caller.setGameMode(GameMode.SURVIVAL);
}
}

View File

@ -178,6 +178,54 @@ public class Arcade extends JavaPlugin
{
config.Tournament = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("TEAM_REJOIN"))
{
config.TeamRejoin = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("TEAM_AUTO_JOIN"))
{
config.TeamAutoJoin = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("TEAM_FORCE_BALANCE"))
{
config.TeamForceBalance = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("GAME_AUTO_START"))
{
config.GameAutoStart = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("GAME_TIMEOUT"))
{
config.GameTimeout = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("REWARD_GEMS"))
{
config.RewardGems = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("REWARD_ITEMS"))
{
config.RewardItems = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("REWARD_STATS"))
{
config.RewardStats = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("REWARD_ACHIEVEMENTS"))
{
config.RewardAchievements = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("HOTBAR_INVENTORY"))
{
config.HotbarInventory = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("HOTBAR_HUB_CLOCK"))
{
config.HotbarHubClock = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("PLAYER_KICK_IDLE"))
{
config.PlayerKickIdle = Boolean.parseBoolean(tokens[1]);
}
//Games
else
{
@ -233,7 +281,26 @@ public class Arcade extends JavaPlugin
out.write("SERVER_TYPE=" + config.ServerType + "\n");
out.write("PLAYERS_MIN=" + config.MinPlayers + "\n");
out.write("PLAYERS_MAX=" + config.MaxPlayers + "\n");
out.write("\nTOURNAMENT=" + config.Tournament + "\n");
out.write("\nTEAM_REJOIN=" + config.TeamRejoin + "\n");
out.write("TEAM_AUTO_JOIN=" + config.TeamAutoJoin + "\n");
out.write("TEAM_FORCE_BALANCE=" + config.TeamForceBalance + "\n");
out.write("\nGAME_AUTO_START=" + config.GameAutoStart + "\n");
out.write("GAME_TIMEOUT=" + config.GameTimeout + "\n");
out.write("\nREWARD_GEMS=" + config.RewardGems + "\n");
out.write("REWARD_ITEMS=" + config.RewardItems + "\n");
out.write("REWARD_STATS=" + config.RewardStats + "\n");
out.write("REWARD_ACHIEVEMENTS=" + config.RewardAchievements + "\n");
out.write("\nHOTBAR_INVENTORY=" + config.HotbarInventory + "\n");
out.write("HOTBAR_HUB_CLOCK=" + config.HotbarHubClock + "\n");
out.write("\nPLAYER_KICK_IDLE=" + config.PlayerKickIdle + "\n");
out.write("\n\nGames List;\n");
for (GameType type : GameType.values())

View File

@ -526,6 +526,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
public void HubClock(Player player)
{
if (!IsHotbarHubClock())
return;
if (_game != null && !_game.GiveClock)
return;
@ -816,6 +819,66 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return _serverConfig.Tournament;
}
public boolean IsTeamRejoin()
{
return _serverConfig.TeamRejoin;
}
public boolean IsTeamAutoJoin()
{
return _serverConfig.TeamAutoJoin;
}
public boolean IsGameAutoStart()
{
return _serverConfig.GameAutoStart;
}
public boolean IsGameTimeout()
{
return _serverConfig.GameTimeout;
}
public boolean IsTeamBalance()
{
return _serverConfig.TeamForceBalance;
}
public boolean IsRewardGems()
{
return _serverConfig.RewardGems;
}
public boolean IsRewardItems()
{
return _serverConfig.RewardItems;
}
public boolean IsRewardStats()
{
return _serverConfig.RewardStats;
}
public boolean IsRewardAchievements()
{
return _serverConfig.RewardAchievements;
}
public boolean IsHotbarInventory()
{
return _serverConfig.HotbarInventory;
}
public boolean IsHotbarHubClock()
{
return _serverConfig.HotbarHubClock;
}
public boolean IsPlayerKickIdle()
{
return _serverConfig.PlayerKickIdle;
}
public int GetDesiredPlayerAmount()
{
return _serverConfig.MaxPlayers;
@ -855,6 +918,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
public void setTournamentTeam(Player player, GameTeam team)
{
if (!IsTeamRejoin())
return;
_tournamentTeam.put(player.getName(), team.GetName());
}

View File

@ -371,7 +371,12 @@ public abstract class Game implements Listener
System.out.println(GetName() + " state set to " + state.toString());
}
public void SetStateTime(long time)
{
_gameStateTime = time;
}
public long GetStateTime()
{
return _gameStateTime;
@ -446,7 +451,7 @@ public abstract class Game implements Listener
//Use this to parse in extra location data from maps
}
public void SetPlayerTeam(Player player, GameTeam team)
public void SetPlayerTeam(Player player, GameTeam team, boolean in)
{
//Clean Old Team
GameTeam pastTeam = this.GetTeam(player);
@ -455,7 +460,7 @@ public abstract class Game implements Listener
pastTeam.RemovePlayer(player);
}
team.AddPlayer(player);
team.AddPlayer(player, in);
//Ensure Valid Kit
ValidateKit(player, team);
@ -467,8 +472,7 @@ public abstract class Game implements Listener
Manager.GetLobby().AddPlayerToScoreboards(player, team.GetName().toUpperCase());
//Save Tournament Team
if (Manager.IsTournamentServer())
Manager.setTournamentTeam(player, team);
Manager.setTournamentTeam(player, team);
}
public GameTeam ChooseTeam(Player player)
@ -811,7 +815,7 @@ public abstract class Game implements Listener
public boolean CanJoinTeam(GameTeam team)
{
return (AutoBalance && !Manager.IsTournamentServer()) ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length/GetTeamList().size()) : true;
return (AutoBalance && Manager.IsTeamBalance()) ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length/GetTeamList().size()) : true;
}
public GameTeam GetTeamPreference(Player player)
@ -1017,13 +1021,13 @@ public abstract class Game implements Listener
return;
if (_helpColor == ChatColor.YELLOW)
_helpColor = ChatColor.GREEN;
_helpColor = ChatColor.GOLD;
else
_helpColor = ChatColor.YELLOW;
_helpTimer = System.currentTimeMillis();
String msg = C.cWhite + C.Bold + "TIP " + ChatColor.RESET + _helpColor + _help[_helpIndex];
String msg = C.cWhite + C.Bold + "TIP> " + ChatColor.RESET + _helpColor + _help[_helpIndex];
for (Player player : UtilServer.getPlayers())
{
@ -1090,6 +1094,9 @@ public abstract class Game implements Listener
public void AddStat(Player player, String stat, int amount, boolean limitTo1, boolean global)
{
if (!Manager.IsRewardStats())
return;
if (!_stats.containsKey(player))
_stats.put(player, new HashMap<String, Integer>());
@ -1098,6 +1105,9 @@ public abstract class Game implements Listener
else
stat = GetName() + "." + stat;
if (Manager.IsTournamentServer())
stat += ".Tournament";
int past = 0;
if (_stats.get(player).containsKey(stat))
past = _stats.get(player).get(stat);

View File

@ -10,8 +10,27 @@ public class GameServerConfig
public int MinPlayers = -1;
public int MaxPlayers = -1;
public ArrayList<GameType> GameList = new ArrayList<GameType>();
//Flags
public boolean Tournament = false;
public boolean TeamRejoin = false;
public boolean TeamAutoJoin = true;
public boolean TeamForceBalance = true;
public boolean GameAutoStart = true;
public boolean GameTimeout = true;
public boolean RewardGems = true;
public boolean RewardItems = true;
public boolean RewardStats = true;
public boolean RewardAchievements = true;
public boolean HotbarInventory = true;
public boolean HotbarHubClock = true;
public boolean PlayerKickIdle = true;
public boolean IsValid()
{
return ServerType != null && MinPlayers != -1 && MaxPlayers != -1;

View File

@ -134,9 +134,9 @@ public class GameTeam
return _spawns.get(UtilMath.r(_spawns.size()));
}
public void AddPlayer(Player player)
public void AddPlayer(Player player, boolean in)
{
_players.put(player, PlayerState.IN);
_players.put(player, in ? PlayerState.IN : PlayerState.OUT);
UtilPlayer.message(player, F.main("Team", _color + C.Bold + "You joined " + _name + " Team") + ".");
@ -226,7 +226,12 @@ public class GameTeam
public void SpawnTeleport()
{
for (Player player : GetPlayers(true))
SpawnTeleport(true);
}
public void SpawnTeleport(boolean aliveOnly)
{
for (Player player : GetPlayers(aliveOnly))
{
SpawnTeleport(player);
}

View File

@ -131,7 +131,7 @@ public abstract class SoloGame extends Game
{
List<Player> places = _players.GetPlacements(true);
if (places.isEmpty())
if (places.isEmpty() || !places.get(0).isOnline())
return Arrays.asList();
else
return Arrays.asList(places.get(0));

View File

@ -97,7 +97,7 @@ public abstract class TeamGame extends Game
GameTeam team = RejoinTeam.remove(event.getPlayer().getName());
if (team != null && _rejoinTime.remove(event.getPlayer().getName()) != null)
{
team.AddPlayer(event.getPlayer());
team.AddPlayer(event.getPlayer(), true);
Announce(team.GetColor() + C.Bold + event.getPlayer().getName() + " has reconnected!", false);

View File

@ -239,7 +239,7 @@ public class DeathTag extends SoloGame
if (GetTeam(player) != null)
GetTeam(player).SetPlacement(player, PlayerState.OUT);
SetPlayerTeam(player, _chasers);
SetPlayerTeam(player, _chasers, true);
//Kit
Kit newKit = GetKits()[5]; //Normal

View File

@ -206,7 +206,7 @@ public class Draw extends SoloGame
for (Player player : _drawers.GetPlayers(false))
{
_drawers.RemovePlayer(player);
_guessers.AddPlayer(player);
_guessers.AddPlayer(player, true);
UtilInv.Clear(player);
player.setAllowFlight(false);
@ -228,7 +228,7 @@ public class Draw extends SoloGame
//Select New Drawer
Player drawer = _roundPlayer.remove(0);
_guessers.RemovePlayer(drawer);
_drawers.AddPlayer(drawer);
_drawers.AddPlayer(drawer, true);
//Get Word
String word = _words[UtilMath.r(_words.length)];

View File

@ -958,7 +958,7 @@ public class HideSeek extends TeamGame
public void SetSeeker(Player player, boolean forced)
{
SetPlayerTeam(player, _seekers);
SetPlayerTeam(player, _seekers, true);
Manager.GetDisguise().undisguise(player);

View File

@ -284,7 +284,7 @@ public class MilkCow extends SoloGame
if (GetTeam(player) != null)
GetTeam(player).SetPlacement(player, PlayerState.OUT);
SetPlayerTeam(player, _cows);
SetPlayerTeam(player, _cows, true);
//Kit
Kit newKit = GetKits()[2];

View File

@ -148,7 +148,7 @@ public class ZombieSurvival extends SoloGame
GetTeam(player).SetPlacement(player, PlayerState.OUT);
//Change to Undead
SetPlayerTeam(player, _undead);
SetPlayerTeam(player, _undead, true);
//Kit
Kit newKit = this.GetKits()[4];

View File

@ -1,7 +1,5 @@
package nautilus.game.arcade.managers;
import java.util.HashMap;
import mineplex.core.achievement.Achievement;
import mineplex.core.achievement.AchievementData;
import mineplex.core.achievement.AchievementLog;
@ -46,7 +44,7 @@ public class GameAchievementManager implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void processAchievementLog(final GameStateChangeEvent event)
{
if (Manager.IsTournamentServer())
if (!Manager.IsRewardAchievements())
return;
if (event.GetState() != GameState.Dead)
@ -67,6 +65,9 @@ public class GameAchievementManager implements Listener
public void displayAchievementLog(final Player player, Game game, NautHashMap<Achievement, AchievementLog> log)
{
if (!Manager.IsRewardAchievements())
return;
if (log == null)
return;

View File

@ -43,7 +43,7 @@ public class GameGemManager implements Listener
@EventHandler
public void PlayerKillAward(CombatDeathEvent event)
{
if (Manager.IsTournamentServer())
if (!Manager.IsRewardGems())
return;
Game game = Manager.GetGame();
@ -91,7 +91,7 @@ public class GameGemManager implements Listener
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
if (Manager.IsTournamentServer())
if (!Manager.IsRewardGems())
return;
Game game = Manager.GetGame();
@ -103,7 +103,7 @@ public class GameGemManager implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void PlayerStateChange(PlayerStateChangeEvent event)
{
if (Manager.IsTournamentServer())
if (!Manager.IsRewardGems())
return;
if (event.GetState() != PlayerState.OUT)
@ -118,7 +118,7 @@ public class GameGemManager implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void GameStateChange(GameStateChangeEvent event)
{
if (Manager.IsTournamentServer())
if (!Manager.IsRewardGems())
return;
if (event.GetState() != GameState.Dead)
@ -130,7 +130,7 @@ public class GameGemManager implements Listener
public void RewardGems(Game game, Player player, boolean give)
{
if (Manager.IsTournamentServer())
if (!Manager.IsRewardGems())
return;
//Inform Gems
@ -143,7 +143,7 @@ public class GameGemManager implements Listener
public void GiveGems(Game game, Player player, HashMap<String,GemData> gems, double gameMult)
{
if (Manager.IsTournamentServer())
if (!Manager.IsRewardGems())
return;
if (gems == null)
@ -183,7 +183,7 @@ public class GameGemManager implements Listener
public void AnnounceGems(Game game, Player player, HashMap<String,GemData> gems, boolean give)
{
if (Manager.IsTournamentServer())
if (!Manager.IsRewardGems())
return;
if (gems == null)

View File

@ -1157,7 +1157,7 @@ public class GameLobbyManager implements IPacketRunnable, Listener
@EventHandler
public void InventoryUpdate(UpdateEvent event)
{
if (Manager.IsTournamentServer())
if (!Manager.IsHotbarInventory())
return;
if (event.getType() != UpdateType.FAST)
@ -1182,7 +1182,7 @@ public class GameLobbyManager implements IPacketRunnable, Listener
@EventHandler(priority = EventPriority.LOWEST)
public void GemBoosterInteract(ActivateGemBoosterEvent event)
{
if (Manager.IsTournamentServer() || Manager.GetGame() == null || Manager.GetGame().GetState() != GameState.Recruit)
if (!Manager.IsHotbarInventory() || Manager.GetGame() == null || Manager.GetGame().GetState() != GameState.Recruit)
{
event.setCancelled(true);

View File

@ -123,7 +123,7 @@ public class GameManager implements Listener
if (game.GetCountdown() != -1)
StateCountdown(game, -1, false);
else if (game.AutoStart && !Manager.IsTournamentServer())
else if (game.AutoStart && !Manager.IsGameAutoStart())
{
if (UtilServer.getPlayers().length >= Manager.GetPlayerFull())
StateCountdown(game, 20, false);
@ -160,7 +160,7 @@ public class GameManager implements Listener
}
else if (game.GetState() == GameState.Live)
{
if (UtilTime.elapsed(game.GetStateTime(), game.GameTimeout))
if (UtilTime.elapsed(game.GetStateTime(), game.GameTimeout) && Manager.IsGameTimeout())
{
game.HandleTimeout();
}
@ -274,6 +274,9 @@ public class GameManager implements Listener
@EventHandler
public void StatEnableDisable(GameStateChangeEvent event)
{
if (!Manager.IsRewardStats())
return;
if (event.GetState() != GameState.Live)
return;
@ -288,6 +291,9 @@ public class GameManager implements Listener
@EventHandler
public void StatRegister(GameStateChangeEvent event)
{
if (!Manager.IsRewardStats())
return;
if (event.GetState() != GameState.Dead)
return;
@ -389,7 +395,7 @@ public class GameManager implements Listener
}
else
{
game.SetPlayerTeam(player, team);
game.SetPlayerTeam(player, team, true);
}
}
}
@ -435,10 +441,10 @@ public class GameManager implements Listener
//Player Swap
queueIterator.remove();
game.SetPlayerTeam(player, team);
game.SetPlayerTeam(player, team, true);
//Other Swap
game.SetPlayerTeam(other, currentTeam);
game.SetPlayerTeam(other, currentTeam, true);
break;
}
@ -461,7 +467,7 @@ public class GameManager implements Listener
{
}
else if (!game.IsPlaying(player) && !Manager.IsTournamentServer())
else if (!game.IsPlaying(player) && Manager.IsTeamAutoJoin())
{
PlayerAdd(game, player, null);
}
@ -523,7 +529,7 @@ public class GameManager implements Listener
if (team == null)
return false;
game.SetPlayerTeam(player, team);
game.SetPlayerTeam(player, team, true);
//Game Mode
player.setGameMode(GameMode.SURVIVAL);

View File

@ -40,7 +40,7 @@ public class IdleManager implements Listener
if (event.getType() != UpdateType.FAST)
return;
if (Manager.IsTournamentServer())
if (!Manager.IsPlayerKickIdle())
return;
if (Manager.GetGame() == null)

View File

@ -113,7 +113,7 @@ public class MiscManager implements Listener
@EventHandler
public void HubClockUpdate(UpdateEvent event)
{
if (Manager.IsTournamentServer())
if (!Manager.IsHotbarHubClock())
return;
if (event.getType() != UpdateType.FAST)
@ -137,7 +137,7 @@ public class MiscManager implements Listener
@EventHandler(priority = EventPriority.LOWEST)
public void HubClockInteract(PlayerInteractEvent event)
{
if (Manager.IsTournamentServer())
if (!Manager.IsHotbarHubClock())
return;
Player player = event.getPlayer();

View File

@ -50,7 +50,7 @@ public class BackstabKillStatTracker extends StatTracker<Game>
if (player == null)
return;
if (event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().equalsIgnoreCase("Backstab"))
if (event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().contains("Backstab"))
{
Set<UUID> hasDamaged = _hasDamaged.get(player.getUniqueId());

View File

@ -1,16 +1,22 @@
package nautilus.game.arcade.stats;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerQuitEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
public class LoseStatTracker extends StatTracker<Game>
{
private final Set<UUID> _losers = new HashSet<>();
public LoseStatTracker(Game game)
{
super(game);
@ -27,6 +33,9 @@ public class LoseStatTracker extends StatTracker<Game>
{
for (Player loser : losers)
{
if (_losers.contains(loser.getUniqueId()))
continue;
addStat(loser, "Losses", 1, false, false);
if (getGame().GetKit(loser) != null)
@ -35,4 +44,18 @@ public class LoseStatTracker extends StatTracker<Game>
}
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event)
{
if (getGame().GetState() == Game.GameState.Live && getGame().IsAlive(event.getPlayer()))
{
addStat(event.getPlayer(), "Losses", 1, false, false);
if (getGame().GetKit(event.getPlayer()) != null)
addStat(event.getPlayer(), getGame().GetKit(event.getPlayer()).GetName() + " Losses", 1, false, false);
_losers.add(event.getPlayer().getUniqueId());
}
}
}

View File

@ -43,7 +43,7 @@ public class TheLongestShotStatTracker extends StatTracker<Game>
if (player == null)
return;
if (event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().equalsIgnoreCase("longshot"))
if (event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().contains("Longshot"))
{
if (player.getLastDamageCause() instanceof EntityDamageByEntityEvent)
{