Implement gamemode feature with modifiable variables and working on first moded games
This commit is contained in:
parent
962175364b
commit
aa219ec3e5
@ -50,6 +50,7 @@ public class ServerGroup
|
|||||||
private boolean _generateFreeVersions;
|
private boolean _generateFreeVersions;
|
||||||
|
|
||||||
private String _games;
|
private String _games;
|
||||||
|
private String _modes;
|
||||||
private String _serverType;
|
private String _serverType;
|
||||||
private boolean _addNoCheat;
|
private boolean _addNoCheat;
|
||||||
private boolean _addWorldEdit;
|
private boolean _addWorldEdit;
|
||||||
@ -87,6 +88,7 @@ public class ServerGroup
|
|||||||
_tournamentPoints = Boolean.valueOf(data.get("tournamentPoints"));
|
_tournamentPoints = Boolean.valueOf(data.get("tournamentPoints"));
|
||||||
_generateFreeVersions = Boolean.valueOf(data.get("generateFreeVersions"));
|
_generateFreeVersions = Boolean.valueOf(data.get("generateFreeVersions"));
|
||||||
_games = data.get("games");
|
_games = data.get("games");
|
||||||
|
_modes = data.get("modes");
|
||||||
_serverType = data.get("serverType");
|
_serverType = data.get("serverType");
|
||||||
_addNoCheat = Boolean.valueOf(data.get("addNoCheat"));
|
_addNoCheat = Boolean.valueOf(data.get("addNoCheat"));
|
||||||
_addWorldEdit = Boolean.valueOf(data.get("addWorldEdit"));
|
_addWorldEdit = Boolean.valueOf(data.get("addWorldEdit"));
|
||||||
@ -117,7 +119,7 @@ public class ServerGroup
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ServerGroup(String name, String prefix, String host, int ram, int cpu, int totalServers, int joinable, int portSection, boolean arcade, String worldZip, String plugin, String configPath
|
public ServerGroup(String name, String prefix, String host, int ram, int cpu, int totalServers, int joinable, int portSection, boolean arcade, String worldZip, String plugin, String configPath
|
||||||
, int minPlayers, int maxPlayers, boolean pvp, boolean tournament, boolean tournamentPoints, String games, String serverType, boolean noCheat, boolean worldEdit, boolean teamRejoin
|
, int minPlayers, int maxPlayers, boolean pvp, boolean tournament, boolean tournamentPoints, String games, String modes, String serverType, boolean noCheat, boolean worldEdit, boolean teamRejoin
|
||||||
, boolean teamAutoJoin, boolean teamForceBalance, boolean gameAutoStart, boolean gameTimeout, boolean rewardGems, boolean rewardItems, boolean rewardStats
|
, boolean teamAutoJoin, boolean teamForceBalance, boolean gameAutoStart, boolean gameTimeout, boolean rewardGems, boolean rewardItems, boolean rewardStats
|
||||||
, boolean rewardAchievements, boolean hotbarInventory, boolean hotbarHubClock, boolean playerKickIdle, boolean staffOnly, boolean whitelist, String resourcePack, Region region
|
, boolean rewardAchievements, boolean hotbarInventory, boolean hotbarHubClock, boolean playerKickIdle, boolean staffOnly, boolean whitelist, String resourcePack, Region region
|
||||||
, String teamServerKey, String portalBottomCornerLocation, String portalTopCornerLocation, String npcName)
|
, String teamServerKey, String portalBottomCornerLocation, String portalTopCornerLocation, String npcName)
|
||||||
@ -140,6 +142,7 @@ public class ServerGroup
|
|||||||
_tournament = tournament;
|
_tournament = tournament;
|
||||||
_tournamentPoints = tournamentPoints;
|
_tournamentPoints = tournamentPoints;
|
||||||
_games = games;
|
_games = games;
|
||||||
|
_modes = modes;
|
||||||
_serverType = serverType;
|
_serverType = serverType;
|
||||||
_addNoCheat = noCheat;
|
_addNoCheat = noCheat;
|
||||||
_addWorldEdit = worldEdit;
|
_addWorldEdit = worldEdit;
|
||||||
@ -210,6 +213,7 @@ public class ServerGroup
|
|||||||
public boolean getGenerateFreeVersions() { return _generateFreeVersions; }
|
public boolean getGenerateFreeVersions() { return _generateFreeVersions; }
|
||||||
|
|
||||||
public String getGames() { return _games; }
|
public String getGames() { return _games; }
|
||||||
|
public String getModes() { return _modes; }
|
||||||
public String getServerType() { return _serverType; }
|
public String getServerType() { return _serverType; }
|
||||||
public boolean getAddNoCheat() { return _addNoCheat; }
|
public boolean getAddNoCheat() { return _addNoCheat; }
|
||||||
public boolean getAddWorldEdit() { return _addWorldEdit; }
|
public boolean getAddWorldEdit() { return _addWorldEdit; }
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package nautilus.game.arcade;
|
package nautilus.game.arcade;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.HashMap ;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -219,7 +220,8 @@ public class Arcade extends JavaPlugin
|
|||||||
for (String gameName : _serverConfiguration.getServerGroup().getGames().split(","))
|
for (String gameName : _serverConfiguration.getServerGroup().getGames().split(","))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{System.out.println(gameName);
|
{
|
||||||
|
System.out.println(gameName);
|
||||||
GameType type = GameType.valueOf(gameName);
|
GameType type = GameType.valueOf(gameName);
|
||||||
config.GameList.add(type);
|
config.GameList.add(type);
|
||||||
}
|
}
|
||||||
@ -228,6 +230,26 @@ public class Arcade extends JavaPlugin
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(_serverConfiguration.getServerGroup().getModes().contains(","))
|
||||||
|
{
|
||||||
|
for (String modeName : _serverConfiguration.getServerGroup().getModes().split(","))
|
||||||
|
{
|
||||||
|
addGamemode(modeName, config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addGamemode(_serverConfiguration.getServerGroup().getModes(), config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.out.println("Error reading Gamemode variable values : " + ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -273,4 +295,23 @@ public class Arcade extends JavaPlugin
|
|||||||
System.out.println("Deleted Old Game: " + file.getName());
|
System.out.println("Deleted Old Game: " + file.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addGamemode(String gamemode, GameServerConfig config)
|
||||||
|
{
|
||||||
|
String mode = gamemode.split("{")[0];
|
||||||
|
System.out.println(mode);
|
||||||
|
config.GameModeList.add(mode);
|
||||||
|
|
||||||
|
String mods = gamemode.split("{")[1];
|
||||||
|
mods = mods.replace("}", "");
|
||||||
|
|
||||||
|
config.GameModeMods.put(mode, new HashMap<>());
|
||||||
|
|
||||||
|
for(String varSet : mods.split(";"))
|
||||||
|
{
|
||||||
|
String var = varSet.split("=")[0];
|
||||||
|
String value = varSet.split("=")[1];
|
||||||
|
config.GameModeMods.get(mode).put(var, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
package nautilus.game.arcade;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.Game;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GameMode
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class GameMode
|
||||||
|
{
|
||||||
|
|
||||||
|
private Class<? extends Game> _gameMode;
|
||||||
|
private String _name;
|
||||||
|
|
||||||
|
public GameMode(Class<? extends Game> gameMode, String name)
|
||||||
|
{
|
||||||
|
_gameMode = gameMode;
|
||||||
|
_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<? extends Game> getGameClass()
|
||||||
|
{
|
||||||
|
return _gameMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package nautilus.game.arcade;
|
package nautilus.game.arcade;
|
||||||
|
|
||||||
import java.util.AbstractMap;
|
import org.bukkit.Material;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import mineplex.core.common.MinecraftVersion;
|
import mineplex.core.common.MinecraftVersion;
|
||||||
import mineplex.core.common.Pair;
|
import mineplex.core.common.Pair;
|
||||||
@ -13,7 +12,9 @@ import nautilus.game.arcade.game.games.barbarians.Barbarians;
|
|||||||
import nautilus.game.arcade.game.games.bossbattles.BossBattles;
|
import nautilus.game.arcade.game.games.bossbattles.BossBattles;
|
||||||
import nautilus.game.arcade.game.games.bouncyballs.BouncyBalls;
|
import nautilus.game.arcade.game.games.bouncyballs.BouncyBalls;
|
||||||
import nautilus.game.arcade.game.games.bridge.Bridge;
|
import nautilus.game.arcade.game.games.bridge.Bridge;
|
||||||
|
import nautilus.game.arcade.game.games.bridge.modes.OverpoweredBridge ;
|
||||||
import nautilus.game.arcade.game.games.build.Build;
|
import nautilus.game.arcade.game.games.build.Build;
|
||||||
|
import nautilus.game.arcade.game.games.build.modes.TeamBuild ;
|
||||||
import nautilus.game.arcade.game.games.cards.Cards;
|
import nautilus.game.arcade.game.games.cards.Cards;
|
||||||
import nautilus.game.arcade.game.games.castlesiege.CastleSiege;
|
import nautilus.game.arcade.game.games.castlesiege.CastleSiege;
|
||||||
import nautilus.game.arcade.game.games.champions.ChampionsCTF;
|
import nautilus.game.arcade.game.games.champions.ChampionsCTF;
|
||||||
@ -48,6 +49,7 @@ import nautilus.game.arcade.game.games.quiver.Quiver;
|
|||||||
import nautilus.game.arcade.game.games.quiver.QuiverTeams;
|
import nautilus.game.arcade.game.games.quiver.QuiverTeams;
|
||||||
import nautilus.game.arcade.game.games.rings.ElytraRings;
|
import nautilus.game.arcade.game.games.rings.ElytraRings;
|
||||||
import nautilus.game.arcade.game.games.runner.Runner;
|
import nautilus.game.arcade.game.games.runner.Runner;
|
||||||
|
import nautilus.game.arcade.game.games.runner.modes.FasterThanLight ;
|
||||||
import nautilus.game.arcade.game.games.searchanddestroy.SearchAndDestroy;
|
import nautilus.game.arcade.game.games.searchanddestroy.SearchAndDestroy;
|
||||||
import nautilus.game.arcade.game.games.sheep.SheepGame;
|
import nautilus.game.arcade.game.games.sheep.SheepGame;
|
||||||
import nautilus.game.arcade.game.games.skywars.SoloSkywars;
|
import nautilus.game.arcade.game.games.skywars.SoloSkywars;
|
||||||
@ -65,6 +67,7 @@ import nautilus.game.arcade.game.games.squidshooter.SquidShooter;
|
|||||||
import nautilus.game.arcade.game.games.stacker.Stacker;
|
import nautilus.game.arcade.game.games.stacker.Stacker;
|
||||||
import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames;
|
import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames;
|
||||||
import nautilus.game.arcade.game.games.survivalgames.TeamSurvivalGames;
|
import nautilus.game.arcade.game.games.survivalgames.TeamSurvivalGames;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.modes.OverpoweredSurvival ;
|
||||||
import nautilus.game.arcade.game.games.tug.Tug;
|
import nautilus.game.arcade.game.games.tug.Tug;
|
||||||
import nautilus.game.arcade.game.games.turfforts.TurfForts;
|
import nautilus.game.arcade.game.games.turfforts.TurfForts;
|
||||||
import nautilus.game.arcade.game.games.typewars.TypeWars;
|
import nautilus.game.arcade.game.games.typewars.TypeWars;
|
||||||
@ -74,15 +77,13 @@ import nautilus.game.arcade.game.games.wither.WitherGame;
|
|||||||
import nautilus.game.arcade.game.games.wizards.Wizards;
|
import nautilus.game.arcade.game.games.wizards.Wizards;
|
||||||
import nautilus.game.arcade.game.games.zombiesurvival.ZombieSurvival;
|
import nautilus.game.arcade.game.games.zombiesurvival.ZombieSurvival;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
|
|
||||||
public enum GameType
|
public enum GameType
|
||||||
{
|
{
|
||||||
//Mini
|
//Mini
|
||||||
BaconBrawl(BaconBrawl.class, GameDisplay.BaconBrawl),
|
BaconBrawl(BaconBrawl.class, GameDisplay.BaconBrawl),
|
||||||
Barbarians(Barbarians.class, GameDisplay.Barbarians),
|
Barbarians(Barbarians.class, GameDisplay.Barbarians),
|
||||||
BossBattles(BossBattles.class, GameDisplay.BossBattles),
|
BossBattles(BossBattles.class, GameDisplay.BossBattles),
|
||||||
Bridge(Bridge.class, GameDisplay.Bridge),
|
Bridge(Bridge.class, new GameMode[]{new GameMode(OverpoweredBridge.class, "OP Bridges")}, GameDisplay.Bridge),
|
||||||
CastleSiege(CastleSiege.class, GameDisplay.CastleSiege),
|
CastleSiege(CastleSiege.class, GameDisplay.CastleSiege),
|
||||||
ChampionsCTF(ChampionsCTF.class, GameDisplay.ChampionsCTF),
|
ChampionsCTF(ChampionsCTF.class, GameDisplay.ChampionsCTF),
|
||||||
ChampionsDominate(ChampionsDominate.class, GameDisplay.ChampionsDominate),
|
ChampionsDominate(ChampionsDominate.class, GameDisplay.ChampionsDominate),
|
||||||
@ -124,7 +125,7 @@ public enum GameType
|
|||||||
Paintball(Paintball.class, GameDisplay.Paintball),
|
Paintball(Paintball.class, GameDisplay.Paintball),
|
||||||
Quiver(Quiver.class, GameDisplay.Quiver),
|
Quiver(Quiver.class, GameDisplay.Quiver),
|
||||||
QuiverTeams(QuiverTeams.class, GameDisplay.QuiverTeams),
|
QuiverTeams(QuiverTeams.class, GameDisplay.QuiverTeams),
|
||||||
Runner(Runner.class, GameDisplay.Runner),
|
Runner(Runner.class, new GameMode[]{new GameMode(FasterThanLight.class, "Gotta Go Fast")}, GameDisplay.Runner),
|
||||||
SearchAndDestroy(SearchAndDestroy.class, GameDisplay.SearchAndDestroy),
|
SearchAndDestroy(SearchAndDestroy.class, GameDisplay.SearchAndDestroy),
|
||||||
Sheep(SheepGame.class, GameDisplay.Sheep),
|
Sheep(SheepGame.class, GameDisplay.Sheep),
|
||||||
TypeWars(TypeWars.class, GameDisplay.TypeWars),
|
TypeWars(TypeWars.class, GameDisplay.TypeWars),
|
||||||
@ -140,7 +141,7 @@ public enum GameType
|
|||||||
SpleefTeams(SpleefTeams.class, GameDisplay.SpleefTeams),
|
SpleefTeams(SpleefTeams.class, GameDisplay.SpleefTeams),
|
||||||
SquidShooter(SquidShooter.class, GameDisplay.SquidShooter),
|
SquidShooter(SquidShooter.class, GameDisplay.SquidShooter),
|
||||||
Stacker(Stacker.class, GameDisplay.Stacker),
|
Stacker(Stacker.class, GameDisplay.Stacker),
|
||||||
SurvivalGames(SoloSurvivalGames.class, GameDisplay.SurvivalGames),
|
SurvivalGames(SoloSurvivalGames.class, new GameMode[]{new GameMode(OverpoweredSurvival.class, "OP Survival Games")}, GameDisplay.SurvivalGames),
|
||||||
SurvivalGamesTeams(TeamSurvivalGames.class, GameDisplay.SurvivalGamesTeams, new GameType[]{GameType.SurvivalGames}, false),
|
SurvivalGamesTeams(TeamSurvivalGames.class, GameDisplay.SurvivalGamesTeams, new GameType[]{GameType.SurvivalGames}, false),
|
||||||
Tug(Tug.class, GameDisplay.Tug),
|
Tug(Tug.class, GameDisplay.Tug),
|
||||||
TurfWars(TurfForts.class, GameDisplay.TurfWars),
|
TurfWars(TurfForts.class, GameDisplay.TurfWars),
|
||||||
@ -151,7 +152,7 @@ public enum GameType
|
|||||||
Pair.create(MinecraftVersion.ALL, "http://file.mineplex.com/ResWizards.zip")
|
Pair.create(MinecraftVersion.ALL, "http://file.mineplex.com/ResWizards.zip")
|
||||||
}, true),
|
}, true),
|
||||||
ZombieSurvival(ZombieSurvival.class, GameDisplay.ZombieSurvival),
|
ZombieSurvival(ZombieSurvival.class, GameDisplay.ZombieSurvival),
|
||||||
Build(Build.class, GameDisplay.Build),
|
Build(Build.class, new GameMode[]{new GameMode(TeamBuild.class, "Team Master Builders")}, GameDisplay.Build),
|
||||||
Cards(Cards.class, GameDisplay.Cards),
|
Cards(Cards.class, GameDisplay.Cards),
|
||||||
Skywars(SoloSkywars.class, GameDisplay.Skywars),
|
Skywars(SoloSkywars.class, GameDisplay.Skywars),
|
||||||
SkywarsTeams(TeamSkywars.class, GameDisplay.SkywarsTeams, new GameType[]{GameType.Skywars}, false),
|
SkywarsTeams(TeamSkywars.class, GameDisplay.SkywarsTeams, new GameType[]{GameType.Skywars}, false),
|
||||||
@ -182,28 +183,46 @@ public enum GameType
|
|||||||
Pair<MinecraftVersion, String>[] _resourcePacks;
|
Pair<MinecraftVersion, String>[] _resourcePacks;
|
||||||
Class<? extends Game> _gameClass;
|
Class<? extends Game> _gameClass;
|
||||||
|
|
||||||
|
GameMode[] _gameModes;
|
||||||
|
|
||||||
private int _gameId; // Unique identifying id for this gamemode (used for statistics)
|
private int _gameId; // Unique identifying id for this gamemode (used for statistics)
|
||||||
public int getGameId() { return _gameId; }
|
public int getGameId() { return _gameId; }
|
||||||
|
|
||||||
GameType(Class<? extends Game> gameClass, GameDisplay display)
|
GameType(Class<? extends Game> gameClass, GameDisplay display)
|
||||||
{
|
{
|
||||||
this(gameClass, display, null, false, null, true);
|
this(gameClass, new GameMode[]{}, display, null, false, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameType(Class<? extends Game> gameClass, GameDisplay display, Pair<MinecraftVersion, String>[] resourcePackUrl, boolean enforceResourcePack)
|
GameType(Class<? extends Game> gameClass, GameDisplay display, Pair<MinecraftVersion, String>[] resourcePackUrl, boolean enforceResourcePack)
|
||||||
{
|
{
|
||||||
this(gameClass, display, resourcePackUrl, enforceResourcePack, null, true);
|
this(gameClass, new GameMode[]{}, display, resourcePackUrl, enforceResourcePack, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameType(Class<? extends Game> gameClass, GameDisplay display, GameType[] mapSource, boolean ownMap)
|
GameType(Class<? extends Game> gameClass, GameDisplay display, GameType[] mapSource, boolean ownMap)
|
||||||
{
|
{
|
||||||
this(gameClass, display, null, false, mapSource, ownMap);
|
this(gameClass, new GameMode[]{}, display, null, false, mapSource, ownMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameType(Class<? extends Game> gameClass, GameDisplay display, Pair<MinecraftVersion, String>[] resourcePackUrls, boolean enforceResourcePack, GameType[] mapSource, boolean ownMaps)
|
GameType(Class<? extends Game> gameClass, GameMode[] gameModes, GameDisplay display)
|
||||||
|
{
|
||||||
|
this(gameClass, gameModes, display, null, false, null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameType(Class<? extends Game> gameClass, GameMode[] gameModes, GameDisplay display, Pair<MinecraftVersion, String>[] resourcePackUrl, boolean enforceResourcePack)
|
||||||
|
{
|
||||||
|
this(gameClass, gameModes, display, resourcePackUrl, enforceResourcePack, null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameType(Class<? extends Game> gameClass, GameMode[] gameModes, GameDisplay display, GameType[] mapSource, boolean ownMap)
|
||||||
|
{
|
||||||
|
this(gameClass, gameModes, display, null, false, mapSource, ownMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameType(Class<? extends Game> gameClass, GameMode[] gameModes, GameDisplay display, Pair<MinecraftVersion, String>[] resourcePackUrls, boolean enforceResourcePack, GameType[] mapSource, boolean ownMaps)
|
||||||
{
|
{
|
||||||
_display = display;
|
_display = display;
|
||||||
_gameClass = gameClass;
|
_gameClass = gameClass;
|
||||||
|
_gameModes = gameModes;
|
||||||
_resourcePacks = resourcePackUrls;
|
_resourcePacks = resourcePackUrls;
|
||||||
_enforceResourcePack = enforceResourcePack;
|
_enforceResourcePack = enforceResourcePack;
|
||||||
_mapSource = mapSource;
|
_mapSource = mapSource;
|
||||||
@ -215,6 +234,11 @@ public enum GameType
|
|||||||
return _gameClass;
|
return _gameClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameMode[] getGameModes()
|
||||||
|
{
|
||||||
|
return _gameModes;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEnforceResourcePack()
|
public boolean isEnforceResourcePack()
|
||||||
{
|
{
|
||||||
return _enforceResourcePack;
|
return _enforceResourcePack;
|
||||||
|
@ -38,21 +38,27 @@ public class SetCommand extends CommandBase<ArcadeManager>
|
|||||||
if (args.length >= 2)
|
if (args.length >= 2)
|
||||||
{
|
{
|
||||||
String map = "";
|
String map = "";
|
||||||
String source = "";
|
String source = game;
|
||||||
if(args.length == 3)
|
Plugin.GetGameCreationManager().MapSource = game;
|
||||||
|
|
||||||
|
for(String token : args)
|
||||||
{
|
{
|
||||||
Plugin.GetGameCreationManager().MapSource = args[1];
|
if(token.startsWith("s"))
|
||||||
Plugin.GetGameCreationManager().MapPref = args[2];
|
|
||||||
source = args[1];
|
|
||||||
map = args[2];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Plugin.GetGameCreationManager().MapSource = args[0];
|
Plugin.GetGameCreationManager().MapSource = token.substring(1);
|
||||||
Plugin.GetGameCreationManager().MapPref = args[1];
|
source = token.substring(1);
|
||||||
source = args[0];
|
|
||||||
map = args[1];
|
|
||||||
}
|
}
|
||||||
|
else if(token.startsWith("m"))
|
||||||
|
{
|
||||||
|
Plugin.GetGameCreationManager().MapPref = token.substring(1);
|
||||||
|
map = token.substring(1);
|
||||||
|
}
|
||||||
|
else if(token.startsWith("e"))
|
||||||
|
{
|
||||||
|
Plugin.GetGameCreationManager().ModePref = token.substring(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UtilPlayer.message(caller, C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + source + ":" + map);
|
UtilPlayer.message(caller, C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + source + ":" + map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,8 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
|
|||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent ;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEntityEvent ;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
@ -58,6 +60,7 @@ import mineplex.core.disguise.disguises.DisguisePlayer;
|
|||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.core.packethandler.IPacketHandler;
|
import mineplex.core.packethandler.IPacketHandler;
|
||||||
import mineplex.core.packethandler.PacketInfo;
|
import mineplex.core.packethandler.PacketInfo;
|
||||||
|
import mineplex.core.recharge.Recharge ;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent;
|
import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent;
|
||||||
@ -69,6 +72,7 @@ import nautilus.game.arcade.GameType;
|
|||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
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.Game.GameState ;
|
||||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
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;
|
||||||
@ -330,6 +334,16 @@ public abstract class Game implements Listener
|
|||||||
|
|
||||||
public boolean AllowEntitySpectate = true;
|
public boolean AllowEntitySpectate = true;
|
||||||
|
|
||||||
|
public boolean PlayerTeamSelection = false;
|
||||||
|
|
||||||
|
public boolean TeamMode = false;
|
||||||
|
|
||||||
|
public boolean TeamPerSpawn = false;
|
||||||
|
|
||||||
|
public boolean ForceTeamSize = true;
|
||||||
|
public int PlayersPerTeam = 2;
|
||||||
|
public int TeamCount = 0;
|
||||||
|
|
||||||
private IPacketHandler _useEntityPacketHandler;
|
private IPacketHandler _useEntityPacketHandler;
|
||||||
private int _deadBodyCount;
|
private int _deadBodyCount;
|
||||||
private NautHashMap<String, Entity> _deadBodies = new NautHashMap<String, Entity>();
|
private NautHashMap<String, Entity> _deadBodies = new NautHashMap<String, Entity>();
|
||||||
@ -338,6 +352,8 @@ public abstract class Game implements Listener
|
|||||||
public ArrayList<String> GemBoosters = new ArrayList<String>();
|
public ArrayList<String> GemBoosters = new ArrayList<String>();
|
||||||
private final Set<StatTracker<? extends Game>> _statTrackers = new HashSet<>();
|
private final Set<StatTracker<? extends Game>> _statTrackers = new HashSet<>();
|
||||||
|
|
||||||
|
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
|
||||||
|
|
||||||
public Game(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
|
public Game(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
|
||||||
{
|
{
|
||||||
Manager = manager;
|
Manager = manager;
|
||||||
@ -1060,6 +1076,10 @@ public abstract class Game implements Listener
|
|||||||
|
|
||||||
public boolean CanJoinTeam(GameTeam team)
|
public boolean CanJoinTeam(GameTeam team)
|
||||||
{
|
{
|
||||||
|
if(TeamMode)
|
||||||
|
{
|
||||||
|
return team.GetSize() < PlayersPerTeam;
|
||||||
|
}
|
||||||
return Manager.IsTeamBalance() ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length / GetTeamList().size())
|
return Manager.IsTeamBalance() ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length / GetTeamList().size())
|
||||||
: true;
|
: true;
|
||||||
}
|
}
|
||||||
@ -1771,6 +1791,332 @@ public abstract class Game implements Listener
|
|||||||
itel.remove();
|
itel.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void teamSelectInteract(PlayerInteractEntityEvent event)
|
||||||
|
{
|
||||||
|
if(!PlayerTeamSelection)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (GetState() != GameState.Recruit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.getRightClicked() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(event.getRightClicked() instanceof Player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
//Observer
|
||||||
|
if (Manager.IsObserver(player))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectTeamMate(player, (Player)event.getRightClicked());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void teamSelectCommand(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
if(!PlayerTeamSelection)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (GetState() != GameState.Recruit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!event.getMessage().toLowerCase().startsWith("/team "))
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true);
|
||||||
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Observer
|
||||||
|
if (Manager.IsObserver(event.getPlayer()))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getPlayer().equals(target))
|
||||||
|
return;
|
||||||
|
|
||||||
|
selectTeamMate(event.getPlayer(), target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectTeamMate(Player player, Player ally)
|
||||||
|
{
|
||||||
|
//Accept Invite
|
||||||
|
if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player))
|
||||||
|
{
|
||||||
|
//Remove Prefs
|
||||||
|
_teamReqs.remove(player);
|
||||||
|
_teamReqs.remove(ally);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!"));
|
||||||
|
UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!"));
|
||||||
|
|
||||||
|
//Leave Old Teams
|
||||||
|
if (GetTeam(player) != null)
|
||||||
|
GetTeam(player).DisbandTeam();
|
||||||
|
|
||||||
|
if (GetTeam(ally) != null)
|
||||||
|
GetTeam(ally).DisbandTeam();
|
||||||
|
|
||||||
|
//Get Team
|
||||||
|
GameTeam team = getEmptyTeam();
|
||||||
|
if (team == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Join Team
|
||||||
|
SetPlayerTeam(player, team, true);
|
||||||
|
SetPlayerTeam(ally, team, true);
|
||||||
|
}
|
||||||
|
//Send Invite
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Already on Team with Target
|
||||||
|
if (GetTeam(player) != null)
|
||||||
|
if (GetTeam(player).HasPlayer(ally))
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Inform Player
|
||||||
|
UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!"));
|
||||||
|
|
||||||
|
//Inform Target
|
||||||
|
if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!"));
|
||||||
|
UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add Pref
|
||||||
|
_teamReqs.put(player, ally);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void teamQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
if(!PlayerTeamSelection)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (GetState() != GameState.Recruit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (GetTeam(player) != null)
|
||||||
|
GetTeam(player).DisbandTeam();
|
||||||
|
|
||||||
|
Iterator<Player> teamIter = _teamReqs.keySet().iterator();
|
||||||
|
while (teamIter.hasNext())
|
||||||
|
{
|
||||||
|
Player sender = teamIter.next();
|
||||||
|
if (sender.equals(player) || _teamReqs.get(sender).equals(player))
|
||||||
|
teamIter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameTeam getEmptyTeam()
|
||||||
|
{
|
||||||
|
for (GameTeam team : GetTeamList())
|
||||||
|
{
|
||||||
|
if (team.GetPlayers(false).isEmpty())
|
||||||
|
return team;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void CustomTeamGeneration(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if(!TeamMode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.GetState() != GameState.Recruit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ArrayList<Location> initialSpawns = this.GetTeamList().get(0).GetSpawns();
|
||||||
|
ArrayList<Location> spawns = this.GetTeamList().get(0).GetSpawns();
|
||||||
|
this.GetTeamList().clear();
|
||||||
|
|
||||||
|
TeamColors color = TeamColors.DARK_AQUA;
|
||||||
|
|
||||||
|
if(TeamPerSpawn)
|
||||||
|
{
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for(Location location : initialSpawns)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
spawns = new ArrayList<>();
|
||||||
|
|
||||||
|
spawns.add(location);
|
||||||
|
|
||||||
|
addRelativeSpawns(spawns, location);
|
||||||
|
|
||||||
|
//Got Spawns
|
||||||
|
color = getNextColor(color);
|
||||||
|
int e = 0;
|
||||||
|
for(GameTeam teams : GetTeamList())
|
||||||
|
{
|
||||||
|
if(teams.GetColor() == color.getColor())
|
||||||
|
{
|
||||||
|
e++;
|
||||||
|
if(getColorName(color.getColor()).length <= e)
|
||||||
|
{
|
||||||
|
e = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GameTeam team = new GameTeam(this, getColorName(color.getColor())[e], color.getColor(), spawns, true);
|
||||||
|
team.SetVisible(true);
|
||||||
|
GetTeamList().add(team);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!this.ForceTeamSize)
|
||||||
|
{
|
||||||
|
for(int i = 1; i <= this.TeamCount; i++)
|
||||||
|
{
|
||||||
|
color = getNextColor(color);
|
||||||
|
GameTeam team = new GameTeam(this, String.valueOf(i), color.getColor(), spawns);
|
||||||
|
team.SetVisible(true);
|
||||||
|
GetTeamList().add(team);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(int i = 1; i <= Manager.GetPlayerFull() / this.PlayersPerTeam; i++)
|
||||||
|
{
|
||||||
|
//Got Spawns
|
||||||
|
color = getNextColor(color);
|
||||||
|
int e = 0;
|
||||||
|
for(GameTeam teams : GetTeamList())
|
||||||
|
{
|
||||||
|
if(teams.GetColor() == color.getColor())
|
||||||
|
{
|
||||||
|
e++;
|
||||||
|
if(getColorName(color.getColor()).length <= e)
|
||||||
|
{
|
||||||
|
e = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GameTeam team = new GameTeam(this, getColorName(color.getColor())[e], color.getColor(), spawns, true);
|
||||||
|
team.SetVisible(true);
|
||||||
|
GetTeamList().add(team);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addRelativeSpawns(ArrayList<Location> spawns, Location location)
|
||||||
|
{
|
||||||
|
//Gather Extra Spawns
|
||||||
|
for(int x = -1; x <= 1; x++)
|
||||||
|
{
|
||||||
|
for(int z = -1; z <= 1; z++)
|
||||||
|
{
|
||||||
|
if(x != 0 && z != 0)
|
||||||
|
{
|
||||||
|
Location newSpawn = location.clone().add(x, 0, z);
|
||||||
|
|
||||||
|
//Search Downward for Solid
|
||||||
|
while (UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN)) && newSpawn.getY() > location.getY()-5)
|
||||||
|
{
|
||||||
|
newSpawn.subtract(0, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Move Up out of Solid
|
||||||
|
while (!UtilBlock.airFoliage(newSpawn.getBlock()) && newSpawn.getY() < location.getY()+5)
|
||||||
|
{
|
||||||
|
newSpawn.add(0, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//On Solid, with 2 Air Above
|
||||||
|
if (UtilBlock.airFoliage(newSpawn.getBlock()) &&
|
||||||
|
UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.UP)) &&
|
||||||
|
!UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN)))
|
||||||
|
{
|
||||||
|
spawns.add(newSpawn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum TeamColors
|
||||||
|
{
|
||||||
|
|
||||||
|
YELLOW(ChatColor.YELLOW, new String[]{"Banana", "Sunshine", "Custard", "Sponge", "Star", "Giraffe", "Lego", "Light"}),
|
||||||
|
GREEN(ChatColor.GREEN, new String[]{"Creepers", "Alien", "Seaweed", "Emerald", "Grinch", "Shrub", "Snake", "Leaf"}),
|
||||||
|
AQUA(ChatColor.AQUA, new String[]{"Diamond", "Ice", "Pool", "Kraken", "Aquatic", "Ocean"}),
|
||||||
|
RED(ChatColor.RED, new String[]{"Heart", "Tomato", "Ruby", "Jam", "Rose", "Apple", "TNT"}),
|
||||||
|
GOLD(ChatColor.GOLD, new String[]{"Mango", "Foxes", "Sunset", "Nuggets", "Lion", "Desert", "Gapple"}),
|
||||||
|
LIGHT_PURPLE(ChatColor.LIGHT_PURPLE, new String[]{"Dream", "Cupcake", "Cake", "Candy", "Unicorn"}),
|
||||||
|
DARK_BLUE(ChatColor.DARK_BLUE, new String[]{"Squid", "Lapis", "Sharks", "Galaxy", "Empoleon"}),
|
||||||
|
DARK_RED(ChatColor.DARK_RED, new String[]{"Rose", "Apple", "Twizzler", "Rocket", "Blood"}),
|
||||||
|
WHITE(ChatColor.WHITE, new String[]{"Ghosts", "Spookies", "Popcorn", "Seagull", "Rice", "Snowman", "Artic"}),
|
||||||
|
BLUE(ChatColor.BLUE, new String[]{"Sky", "Whale", "Lake", "Birds", "Bluebird", "Piplup"}),
|
||||||
|
DARK_GREEN(ChatColor.DARK_GREEN, new String[]{"Forest", "Zombies", "Cactus", "Slime", "Toxic", "Poison"}),
|
||||||
|
DARK_PURPLE(ChatColor.DARK_PURPLE, new String[]{"Amethyst", "Slugs", "Grape", "Witch", "Magic", "Zula"}),
|
||||||
|
DARK_AQUA(ChatColor.DARK_AQUA, new String[]{"Snorlax", "Aquatic", "Clam", "Fish"});
|
||||||
|
|
||||||
|
private ChatColor color;
|
||||||
|
private String[] names;
|
||||||
|
|
||||||
|
private TeamColors(ChatColor color, String[] names)
|
||||||
|
{
|
||||||
|
this.color = color;
|
||||||
|
this.names = names;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getColor()
|
||||||
|
{
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getNames()
|
||||||
|
{
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] getColorName(ChatColor color)
|
||||||
|
{
|
||||||
|
for(TeamColors colors : TeamColors.values())
|
||||||
|
{
|
||||||
|
if(colors.getColor() == color)
|
||||||
|
{
|
||||||
|
return colors.getNames();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TeamColors getNextColor(TeamColors color)
|
||||||
|
{
|
||||||
|
for(TeamColors colors : TeamColors.values()) {
|
||||||
|
if(colors.ordinal() == color.ordinal() + 1)
|
||||||
|
{
|
||||||
|
return colors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TeamColors.YELLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTutorials(){}
|
public void addTutorials(){}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package nautilus.game.arcade.game;
|
package nautilus.game.arcade.game;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap ;
|
||||||
|
|
||||||
import nautilus.game.arcade.GameType;
|
import nautilus.game.arcade.GameType;
|
||||||
|
|
||||||
@ -10,6 +11,9 @@ public class GameServerConfig
|
|||||||
public int MinPlayers = -1;
|
public int MinPlayers = -1;
|
||||||
public int MaxPlayers = -1;
|
public int MaxPlayers = -1;
|
||||||
public ArrayList<GameType> GameList = new ArrayList<GameType>();
|
public ArrayList<GameType> GameList = new ArrayList<GameType>();
|
||||||
|
public ArrayList<String> GameModeList = new ArrayList<String>();
|
||||||
|
|
||||||
|
public HashMap<String, HashMap<String, String>> GameModeMods = new HashMap<>();
|
||||||
|
|
||||||
//Flags
|
//Flags
|
||||||
public String HostName = "";
|
public String HostName = "";
|
||||||
|
@ -316,7 +316,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
if (!WorldData.GetCustomLocs("22").isEmpty()) ParseOre(WorldData.GetCustomLocs("22"));
|
if (!WorldData.GetCustomLocs("22").isEmpty()) ParseOre(WorldData.GetCustomLocs("22"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseChests()
|
protected void ParseChests()
|
||||||
{
|
{
|
||||||
for (Location loc : WorldData.GetCustomLocs("54"))
|
for (Location loc : WorldData.GetCustomLocs("54"))
|
||||||
{
|
{
|
||||||
@ -335,7 +335,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack GetChestItem()
|
protected ItemStack GetChestItem()
|
||||||
{
|
{
|
||||||
if (_chestLoot.isEmpty())
|
if (_chestLoot.isEmpty())
|
||||||
{
|
{
|
||||||
@ -417,7 +417,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void ParseOre(ArrayList<Location> teamOre)
|
public void ParseOre(ArrayList<Location> teamOre)
|
||||||
{
|
{
|
||||||
int coal = (int) ((teamOre.size() / 32d) * _oreDensity);
|
int coal = (int) ((teamOre.size() / 32d) * _oreDensity);
|
||||||
int iron = (int) ((teamOre.size() / 24d) * _oreDensity);
|
int iron = (int) ((teamOre.size() / 24d) * _oreDensity);
|
||||||
@ -571,7 +571,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateOre(Location loc, Material type, int amount)
|
public void CreateOre(Location loc, Material type, int amount)
|
||||||
{
|
{
|
||||||
double bonus = Math.random() + 1;
|
double bonus = Math.random() + 1;
|
||||||
|
|
||||||
@ -637,7 +637,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseWoodBridge() {
|
protected void ParseWoodBridge() {
|
||||||
_woodBridge = new ArrayList<Location>();
|
_woodBridge = new ArrayList<Location>();
|
||||||
|
|
||||||
// Load Wood In
|
// Load Wood In
|
||||||
@ -671,7 +671,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseLavaBridge() {
|
protected void ParseLavaBridge() {
|
||||||
for (Location loc : WorldData.GetDataLocs("RED")) {
|
for (Location loc : WorldData.GetDataLocs("RED")) {
|
||||||
_lavaBridge.add(loc.getBlock().getLocation());
|
_lavaBridge.add(loc.getBlock().getLocation());
|
||||||
}
|
}
|
||||||
@ -685,12 +685,12 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
_lavaSource = WorldData.GetDataLocs("BLACK");
|
_lavaSource = WorldData.GetDataLocs("BLACK");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseIceBridge()
|
protected void ParseIceBridge()
|
||||||
{
|
{
|
||||||
_iceBridge = WorldData.GetDataLocs("LIGHT_BLUE");
|
_iceBridge = WorldData.GetDataLocs("LIGHT_BLUE");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseMushrooms()
|
protected void ParseMushrooms()
|
||||||
{
|
{
|
||||||
for (Location loc : WorldData.GetCustomLocs("21"))
|
for (Location loc : WorldData.GetCustomLocs("21"))
|
||||||
{
|
{
|
||||||
@ -704,7 +704,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseLillyPad()
|
protected void ParseLillyPad()
|
||||||
{
|
{
|
||||||
for (Location loc : WorldData.GetDataLocs("LIME"))
|
for (Location loc : WorldData.GetDataLocs("LIME"))
|
||||||
{
|
{
|
||||||
@ -747,7 +747,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
buildMushroom();
|
buildMushroom();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildLava()
|
protected void BuildLava()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
if (_lavaBridge != null && _lavaSource != null
|
if (_lavaBridge != null && _lavaSource != null
|
||||||
@ -778,7 +778,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildLillyPad()
|
protected void BuildLillyPad()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
if (_lillyPads != null && !_lillyPads.isEmpty())
|
if (_lillyPads != null && !_lillyPads.isEmpty())
|
||||||
@ -810,7 +810,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
_lillyPads.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000));
|
_lillyPads.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildMushroom()
|
protected void buildMushroom()
|
||||||
{
|
{
|
||||||
if (_mushroomStem != null && !_mushroomStem.isEmpty())
|
if (_mushroomStem != null && !_mushroomStem.isEmpty())
|
||||||
{
|
{
|
||||||
@ -902,7 +902,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildIce()
|
protected void BuildIce()
|
||||||
{
|
{
|
||||||
if (_iceBridge == null || _iceBridge.isEmpty() || UtilTime.elapsed(this.GetStateTime(), _bridgeTime + 120000))
|
if (_iceBridge == null || _iceBridge.isEmpty() || UtilTime.elapsed(this.GetStateTime(), _bridgeTime + 120000))
|
||||||
{
|
{
|
||||||
@ -943,7 +943,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildWood()
|
protected void BuildWood()
|
||||||
{
|
{
|
||||||
if (_woodBridgeBlocks != null && !_woodBridgeBlocks.isEmpty())
|
if (_woodBridgeBlocks != null && !_woodBridgeBlocks.isEmpty())
|
||||||
{
|
{
|
||||||
@ -1955,4 +1955,9 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
_bridgeTime = time;
|
_bridgeTime = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getOreDensity()
|
||||||
|
{
|
||||||
|
return _oreDensity;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,224 @@
|
|||||||
|
package nautilus.game.arcade.game.games.bridge.modes;
|
||||||
|
|
||||||
|
import java.util.ArrayList ;
|
||||||
|
|
||||||
|
import org.bukkit.Location ;
|
||||||
|
import org.bukkit.Material ;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilMath ;
|
||||||
|
import nautilus.game.arcade.ArcadeManager ;
|
||||||
|
import nautilus.game.arcade.game.games.bridge.Bridge ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OverpoweredBridge
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class OverpoweredBridge extends Bridge
|
||||||
|
{
|
||||||
|
|
||||||
|
public OverpoweredBridge(ArcadeManager manager)
|
||||||
|
{
|
||||||
|
super(manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ParseData()
|
||||||
|
{
|
||||||
|
ParseLavaBridge();
|
||||||
|
ParseWoodBridge();
|
||||||
|
ParseIceBridge();
|
||||||
|
ParseLillyPad();
|
||||||
|
ParseMushrooms();
|
||||||
|
|
||||||
|
ParseChests();
|
||||||
|
|
||||||
|
ParseOre(WorldData.GetCustomLocs("73")); // Red
|
||||||
|
ParseOre(WorldData.GetCustomLocs("14")); // Yellow
|
||||||
|
ParseOre(WorldData.GetCustomLocs("129")); // Green
|
||||||
|
ParseOre(WorldData.GetCustomLocs("56")); // Blue
|
||||||
|
|
||||||
|
//Mass Teams
|
||||||
|
if (!WorldData.GetCustomLocs("152").isEmpty()) ParseOre(WorldData.GetCustomLocs("152"));
|
||||||
|
if (!WorldData.GetCustomLocs("41").isEmpty()) ParseOre(WorldData.GetCustomLocs("41"));
|
||||||
|
if (!WorldData.GetCustomLocs("133").isEmpty()) ParseOre(WorldData.GetCustomLocs("133"));
|
||||||
|
if (!WorldData.GetCustomLocs("57").isEmpty()) ParseOre(WorldData.GetCustomLocs("57"));
|
||||||
|
|
||||||
|
if (!WorldData.GetCustomLocs("100").isEmpty()) ParseOre(WorldData.GetCustomLocs("100"));
|
||||||
|
if (!WorldData.GetCustomLocs("86").isEmpty()) ParseOre(WorldData.GetCustomLocs("86"));
|
||||||
|
if (!WorldData.GetCustomLocs("103").isEmpty()) ParseOre(WorldData.GetCustomLocs("103"));
|
||||||
|
if (!WorldData.GetCustomLocs("22").isEmpty()) ParseOre(WorldData.GetCustomLocs("22"));
|
||||||
|
|
||||||
|
ParseEnchantTables();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ParseEnchantTables()
|
||||||
|
{
|
||||||
|
for(Location loc : WorldData.GetDataLocs("PINK"))
|
||||||
|
{
|
||||||
|
loc.getBlock().setType(Material.ENCHANTMENT_TABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ParseOre(ArrayList<Location> teamOre)
|
||||||
|
{
|
||||||
|
int coal = (int) ((teamOre.size() / 32d) * getOreDensity());
|
||||||
|
int iron = (int) ((teamOre.size() / 24d) * getOreDensity());
|
||||||
|
int gold = (int) ((teamOre.size() / 64d) * getOreDensity());
|
||||||
|
int diamond = 100 + (int) ((teamOre.size() / 32d) * getOreDensity());
|
||||||
|
|
||||||
|
int gravel = (int) ((teamOre.size() / 64d) * getOreDensity());
|
||||||
|
|
||||||
|
int lowY = 256;
|
||||||
|
int highY = 0;
|
||||||
|
|
||||||
|
for (Location loc : teamOre)
|
||||||
|
{
|
||||||
|
if (loc.getBlockY() < lowY)
|
||||||
|
lowY = loc.getBlockY();
|
||||||
|
|
||||||
|
if (loc.getBlockY() > highY)
|
||||||
|
highY = loc.getBlockY();
|
||||||
|
|
||||||
|
loc.getBlock().setTypeId(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int varY = highY - lowY;
|
||||||
|
|
||||||
|
//Gravel
|
||||||
|
for (int i = 0; i < gravel && !teamOre.isEmpty(); i++)
|
||||||
|
{
|
||||||
|
int attempts = 20;
|
||||||
|
int id = 0;
|
||||||
|
|
||||||
|
while (attempts > 0)
|
||||||
|
{
|
||||||
|
id = UtilMath.r(teamOre.size());
|
||||||
|
|
||||||
|
double height = (double) (teamOre.get(id).getBlockY() - lowY) / (double) varY;
|
||||||
|
|
||||||
|
if (height > 0.8)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else if (height > 0.6 && Math.random() > 0.4)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else if (height > 0.4 && Math.random() > 0.6)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else if (height > 0.2 && Math.random() > 0.8)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateOre(teamOre.remove(id), Material.GRAVEL, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Coal
|
||||||
|
for (int i = 0; i < coal && !teamOre.isEmpty(); i++)
|
||||||
|
{
|
||||||
|
int attempts = 20;
|
||||||
|
int id = 0;
|
||||||
|
|
||||||
|
while (attempts > 0)
|
||||||
|
{
|
||||||
|
id = UtilMath.r(teamOre.size());
|
||||||
|
|
||||||
|
double height = (double) (teamOre.get(id).getBlockY() - lowY) / (double) varY;
|
||||||
|
|
||||||
|
if (height > 0.8)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else if (height > 0.6 && Math.random() > 0.4)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else if (height > 0.4 && Math.random() > 0.6)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else if (height > 0.2 && Math.random() > 0.8)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateOre(teamOre.remove(id), Material.COAL_ORE, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Iron
|
||||||
|
for (int i = 0; i < iron && !teamOre.isEmpty(); i++)
|
||||||
|
{
|
||||||
|
int id = UtilMath.r(teamOre.size());
|
||||||
|
|
||||||
|
CreateOre(teamOre.remove(id), Material.IRON_ORE, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Gold
|
||||||
|
for (int i = 0; i < gold && !teamOre.isEmpty(); i++)
|
||||||
|
{
|
||||||
|
int attempts = 20;
|
||||||
|
int id = 0;
|
||||||
|
|
||||||
|
while (attempts > 0)
|
||||||
|
{
|
||||||
|
id = UtilMath.r(teamOre.size());
|
||||||
|
|
||||||
|
double height = (double) (teamOre.get(id).getBlockY() - lowY)
|
||||||
|
/ (double) varY;
|
||||||
|
|
||||||
|
if (height > 0.8 && Math.random() > 0.8)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else if (height > 0.6 && Math.random() > 0.7)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else if (height > 0.4 && Math.random() > 0.6)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else if (height > 0.2 && Math.random() > 0.4)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else if (Math.random() > 0.2)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateOre(teamOre.remove(id), Material.GOLD_ORE, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Diamond
|
||||||
|
for (int i = 0; i < diamond && !teamOre.isEmpty(); i++)
|
||||||
|
{
|
||||||
|
int attempts = 20;
|
||||||
|
int id = 0;
|
||||||
|
|
||||||
|
while (attempts > 0)
|
||||||
|
{
|
||||||
|
id = UtilMath.r(teamOre.size());
|
||||||
|
|
||||||
|
double height = (double) (teamOre.get(id).getBlockY() - lowY)
|
||||||
|
/ (double) varY;
|
||||||
|
|
||||||
|
if (height > 0.8)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
else if (height > 0.6 && Math.random() > 0.9)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else if (height > 0.4 && Math.random() > 0.7)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else if (height > 0.2 && Math.random() > 0.5)
|
||||||
|
break;
|
||||||
|
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateOre(teamOre.remove(id), Material.DIAMOND_ORE, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String GetMode()
|
||||||
|
{
|
||||||
|
return "OP Bridges";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -34,6 +34,7 @@ import nautilus.game.arcade.ArcadeManager;
|
|||||||
import nautilus.game.arcade.GameType;
|
import nautilus.game.arcade.GameType;
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
|
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
|
||||||
|
import nautilus.game.arcade.game.Game ;
|
||||||
import nautilus.game.arcade.game.SoloGame;
|
import nautilus.game.arcade.game.SoloGame;
|
||||||
import nautilus.game.arcade.game.games.build.gui.MobShop;
|
import nautilus.game.arcade.game.games.build.gui.MobShop;
|
||||||
import nautilus.game.arcade.game.games.build.gui.OptionsShop;
|
import nautilus.game.arcade.game.games.build.gui.OptionsShop;
|
||||||
@ -106,7 +107,7 @@ import org.bukkit.event.vehicle.VehicleCreateEvent;
|
|||||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class Build extends SoloGame
|
public class Build extends Game
|
||||||
{
|
{
|
||||||
private NautHashMap<Player, BuildData> _data = new NautHashMap<Player, BuildData>();
|
private NautHashMap<Player, BuildData> _data = new NautHashMap<Player, BuildData>();
|
||||||
|
|
||||||
@ -415,19 +416,7 @@ public class Build extends SoloGame
|
|||||||
if (GetPlayers(true).size() >= 4 && _viewData.AbuseVotes.size() >= (double)(GetPlayers(true).size() - 1) / 2d)
|
if (GetPlayers(true).size() >= 4 && _viewData.AbuseVotes.size() >= (double)(GetPlayers(true).size() - 1) / 2d)
|
||||||
{
|
{
|
||||||
result = C.cWhite + "Inappropriate Build";
|
result = C.cWhite + "Inappropriate Build";
|
||||||
_viewData.setAbusive();
|
abusiveBulid();
|
||||||
|
|
||||||
//Record Abuse
|
|
||||||
AddStat(_viewData.Player, "Build Draw Abuse", 1, false, true);
|
|
||||||
|
|
||||||
//Announce
|
|
||||||
Announce(C.cWhite + C.Bold + _viewData.Player.getName() + " has been reported for an inappropriate build.", false);
|
|
||||||
_viewData.Spawn.getWorld().playSound(_viewData.Spawn, Sound.ENDERDRAGON_GROWL, 10f, 1f);
|
|
||||||
|
|
||||||
UtilPlayer.message(_viewData.Player, C.cWhite + C.Bold + "Inappropriate Builds can result in a Master Buildres ban.");
|
|
||||||
|
|
||||||
//Return to Hub
|
|
||||||
getArcadeManager().GetPortal().sendPlayerToServer(_viewData.Player, "Lobby");
|
|
||||||
}
|
}
|
||||||
else if (!hasDecentVote)
|
else if (!hasDecentVote)
|
||||||
{
|
{
|
||||||
@ -442,8 +431,15 @@ public class Build extends SoloGame
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Announce Builder
|
//Announce Builder
|
||||||
|
if(_viewData.Player != null)
|
||||||
|
{
|
||||||
UtilTextMiddle.display(result, "Built by: " + C.Bold + _viewData.Player.getName(), 0, 80, 5);
|
UtilTextMiddle.display(result, "Built by: " + C.Bold + _viewData.Player.getName(), 0, 80, 5);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilTextMiddle.display(result, "Built by: " + C.Bold + _viewData.Team.getDisplayName(), 0, 80, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_viewData.Judged = true;
|
_viewData.Judged = true;
|
||||||
}
|
}
|
||||||
@ -513,6 +509,18 @@ public class Build extends SoloGame
|
|||||||
{
|
{
|
||||||
tallyScores();
|
tallyScores();
|
||||||
|
|
||||||
|
calculatePlaces();
|
||||||
|
|
||||||
|
writeScoreboard();
|
||||||
|
|
||||||
|
//End
|
||||||
|
SetState(GameState.End);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void calculatePlaces()
|
||||||
|
{
|
||||||
|
|
||||||
ArrayList<Player> places = new ArrayList<Player>();
|
ArrayList<Player> places = new ArrayList<Player>();
|
||||||
|
|
||||||
//Calculate Places
|
//Calculate Places
|
||||||
@ -549,8 +557,6 @@ public class Build extends SoloGame
|
|||||||
_scoreboardPlaces.add(new AbstractMap.SimpleEntry<Player, Double>(bestPlayer, bestPoints));
|
_scoreboardPlaces.add(new AbstractMap.SimpleEntry<Player, Double>(bestPlayer, bestPoints));
|
||||||
}
|
}
|
||||||
|
|
||||||
writeScoreboard();
|
|
||||||
|
|
||||||
//Announce
|
//Announce
|
||||||
AnnounceEnd(places);
|
AnnounceEnd(places);
|
||||||
|
|
||||||
@ -570,10 +576,23 @@ public class Build extends SoloGame
|
|||||||
for (Player player : GetPlayers(false))
|
for (Player player : GetPlayers(false))
|
||||||
if (player.isOnline())
|
if (player.isOnline())
|
||||||
AddGems(player, 10, "Participation", false, false);
|
AddGems(player, 10, "Participation", false, false);
|
||||||
|
|
||||||
//End
|
|
||||||
SetState(GameState.End);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void abusiveBulid()
|
||||||
|
{
|
||||||
|
_viewData.setAbusive();
|
||||||
|
|
||||||
|
//Record Abuse
|
||||||
|
AddStat(_viewData.Player, "Build Draw Abuse", 1, false, true);
|
||||||
|
|
||||||
|
//Announce
|
||||||
|
Announce(C.cWhite + C.Bold + _viewData.Player.getName() + " has been reported for an inappropriate build.", false);
|
||||||
|
_viewData.Spawn.getWorld().playSound(_viewData.Spawn, Sound.ENDERDRAGON_GROWL, 10f, 1f);
|
||||||
|
|
||||||
|
UtilPlayer.message(_viewData.Player, C.cWhite + C.Bold + "Inappropriate Builds can result in a Master Buildres ban.");
|
||||||
|
|
||||||
|
//Return to Hub
|
||||||
|
getArcadeManager().GetPortal().sendPlayerToServer(_viewData.Player, "Lobby");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tallyScores()
|
private void tallyScores()
|
||||||
@ -641,7 +660,7 @@ public class Build extends SoloGame
|
|||||||
return _buildStateTime == 0;
|
return _buildStateTime == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void teleportPlayers(BuildData data)
|
public void teleportPlayers(BuildData data)
|
||||||
{
|
{
|
||||||
//Teleport
|
//Teleport
|
||||||
for (int i=0 ; i<UtilServer.getPlayers().length ; i++)
|
for (int i=0 ; i<UtilServer.getPlayers().length ; i++)
|
||||||
@ -784,16 +803,22 @@ public class Build extends SoloGame
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(_viewData.Team != null)
|
||||||
|
{
|
||||||
|
if(_viewData.Team.HasPlayer(event.getPlayer()))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot vote on your own creation!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!UtilTime.elapsed(_buildStateTime, 1500))
|
if (!UtilTime.elapsed(_buildStateTime, 1500))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Vote Abuse
|
//Vote Abuse
|
||||||
if (UtilGear.isMat(event.getPlayer().getItemInHand(), Material.BOOK))
|
if (UtilGear.isMat(event.getPlayer().getItemInHand(), Material.BOOK))
|
||||||
{
|
{
|
||||||
_viewData.addAbuseVote(event.getPlayer());
|
processReport(event.getPlayer());
|
||||||
UtilTextMiddle.display(null, C.cWhite + C.Bold + "Inappropriate Build", 0, 40, 5, event.getPlayer());
|
|
||||||
UtilPlayer.message(event.getPlayer(), C.cWhite + C.Bold + "You reported " + _viewData.Player.getName() + " for inappropriate build!");
|
|
||||||
UtilPlayer.message(event.getPlayer(), C.cWhite + C.Bold + "Thanks for helping us keep Master Builders clean!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -834,6 +859,14 @@ public class Build extends SoloGame
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void processReport(Player reporter)
|
||||||
|
{
|
||||||
|
_viewData.addAbuseVote(reporter);
|
||||||
|
UtilTextMiddle.display(null, C.cWhite + C.Bold + "Inappropriate Build", 0, 40, 5, reporter);
|
||||||
|
UtilPlayer.message(reporter, C.cWhite + C.Bold + "You reported " + _viewData.Player.getName() + " for inappropriate build!");
|
||||||
|
UtilPlayer.message(reporter, C.cWhite + C.Bold + "Thanks for helping us keep Master Builders clean!");
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void playerQuit(PlayerQuitEvent event)
|
public void playerQuit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
@ -1070,7 +1103,7 @@ public class Build extends SoloGame
|
|||||||
if (data == null)
|
if (data == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (data.Player.equals(event.getPlayer()))
|
if (data.Team.HasPlayer(event.getPlayer()))
|
||||||
{
|
{
|
||||||
event.getItem().remove();
|
event.getItem().remove();
|
||||||
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, event.getItem().getLocation().add(0, 0.5, 0), 0, 0, 0, 0, 1,
|
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, event.getItem().getLocation().add(0, 0.5, 0), 0, 0, 0, 0, 1,
|
||||||
@ -1386,7 +1419,7 @@ public class Build extends SoloGame
|
|||||||
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
data.addParticles(particleType);
|
data.addParticles(event.getPlayer(), particleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -1573,4 +1606,80 @@ public class Build extends SoloGame
|
|||||||
|
|
||||||
return Arrays.asList(player);
|
return Arrays.asList(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NautHashMap<Player, BuildData> getData()
|
||||||
|
{
|
||||||
|
return _data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWord(String word)
|
||||||
|
{
|
||||||
|
_word = word;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWord()
|
||||||
|
{
|
||||||
|
return _word;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean useHolidayWords()
|
||||||
|
{
|
||||||
|
return _useHolidayWords;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getHolidayWords()
|
||||||
|
{
|
||||||
|
return _holidayWords;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getWords()
|
||||||
|
{
|
||||||
|
return _words;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuildData getViewData()
|
||||||
|
{
|
||||||
|
return _viewData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBuildGameState()
|
||||||
|
{
|
||||||
|
return _buildGameState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBuildStateTime()
|
||||||
|
{
|
||||||
|
return _buildStateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBuildTime()
|
||||||
|
{
|
||||||
|
return _buildTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getVoteTime()
|
||||||
|
{
|
||||||
|
return _voteTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void EndCheck()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Player> getLosers()
|
||||||
|
{
|
||||||
|
List<Player> winners = getWinners();
|
||||||
|
|
||||||
|
if (winners == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
List<Player> losers = GetPlayers(false);
|
||||||
|
|
||||||
|
losers.removeAll(winners);
|
||||||
|
|
||||||
|
return losers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import mineplex.core.common.util.F;
|
|
||||||
import mineplex.core.common.util.MapUtil;
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
|
||||||
import mineplex.core.common.util.UtilAlg;
|
|
||||||
import mineplex.core.common.util.UtilBlock;
|
|
||||||
import mineplex.core.common.util.UtilEnt;
|
|
||||||
import mineplex.core.common.util.UtilParticle;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
|
||||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
|
||||||
import mineplex.core.recharge.Recharge;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -28,6 +15,20 @@ import org.bukkit.entity.Item;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.MapUtil;
|
||||||
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
import net.minecraft.server.v1_8_R3.EntityLightning;
|
import net.minecraft.server.v1_8_R3.EntityLightning;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityWeather;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityWeather;
|
||||||
|
|
||||||
@ -35,6 +36,8 @@ public class BuildData
|
|||||||
{
|
{
|
||||||
public Player Player;
|
public Player Player;
|
||||||
|
|
||||||
|
public GameTeam Team;
|
||||||
|
|
||||||
public boolean Judged = false;
|
public boolean Judged = false;
|
||||||
|
|
||||||
public Location Spawn;
|
public Location Spawn;
|
||||||
@ -65,6 +68,19 @@ public class BuildData
|
|||||||
public BuildData(Player player, Location spawn, ArrayList<Location> buildBorders)
|
public BuildData(Player player, Location spawn, ArrayList<Location> buildBorders)
|
||||||
{
|
{
|
||||||
Player = player;
|
Player = player;
|
||||||
|
Team = null;
|
||||||
|
Spawn = spawn;
|
||||||
|
|
||||||
|
CornerA = UtilAlg.findClosest(spawn, buildBorders);
|
||||||
|
buildBorders.remove(CornerA);
|
||||||
|
CornerB = UtilAlg.findClosest(spawn, buildBorders);
|
||||||
|
buildBorders.remove(CornerB);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuildData(GameTeam team, Location spawn, ArrayList<Location> buildBorders)
|
||||||
|
{
|
||||||
|
Player = null;
|
||||||
|
Team = team;
|
||||||
Spawn = spawn;
|
Spawn = spawn;
|
||||||
|
|
||||||
CornerA = UtilAlg.findClosest(spawn, buildBorders);
|
CornerA = UtilAlg.findClosest(spawn, buildBorders);
|
||||||
@ -90,50 +106,68 @@ public class BuildData
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addParticles(ParticleType particleType)
|
public boolean addParticles(Player player, ParticleType particleType)
|
||||||
{
|
{
|
||||||
if (Particles.size() >= 24)
|
if (Particles.size() >= 24)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(Player, F.main("Game", "You cannot spawn more than 24 Particles!"));
|
UtilPlayer.message(player, F.main("Game", "You cannot spawn more than 24 Particles!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location toPlace = Player.getEyeLocation().add(Player.getLocation().getDirection());
|
Location toPlace = player.getEyeLocation().add(player.getLocation().getDirection());
|
||||||
|
|
||||||
if (!inBuildArea(toPlace.getBlock()))
|
if (!inBuildArea(toPlace.getBlock()))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(Player, F.main("Game", "You cannot place particles outside your plot!"));
|
UtilPlayer.message(player, F.main("Game", "You cannot place particles outside your plot!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Particles.put(toPlace, particleType);
|
Particles.put(toPlace, particleType);
|
||||||
|
|
||||||
UtilPlayer.message(Player, F.main("Game", "You placed " + particleType.getFriendlyName() + "!"));
|
UtilPlayer.message(player, F.main("Game", "You placed " + particleType.getFriendlyName() + "!"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetParticles()
|
public void resetParticles(Player player)
|
||||||
{
|
{
|
||||||
Particles.clear();
|
Particles.clear();
|
||||||
|
|
||||||
UtilPlayer.message(Player, F.main("Game", "You cleared your Particles!"));
|
UtilPlayer.message(player, F.main("Game", "You cleared your Particles!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addEntity(Entity entity)
|
public boolean addEntity(Entity entity)
|
||||||
{
|
{
|
||||||
if (entity instanceof Ghast)
|
if (entity instanceof Ghast)
|
||||||
|
{
|
||||||
|
if(Player != null)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(Player, F.main("Game", "You cannot spawn Ghasts!"));
|
UtilPlayer.message(Player, F.main("Game", "You cannot spawn Ghasts!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(Player player : Team.GetPlayers(true))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Game", "You cannot spawn Ghasts!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
entity.remove();
|
entity.remove();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Entities.size() >= 16)
|
if (Entities.size() >= 16)
|
||||||
|
{
|
||||||
|
if(Player != null)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(Player, F.main("Game", "You cannot spawn more than 16 Entities!"));
|
UtilPlayer.message(Player, F.main("Game", "You cannot spawn more than 16 Entities!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(Player player : Team.GetPlayers(true))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Game", "You cannot spawn more than 16 Entities!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
entity.remove();
|
entity.remove();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -243,12 +277,27 @@ public class BuildData
|
|||||||
amount = 1;
|
amount = 1;
|
||||||
|
|
||||||
if (all)
|
if (all)
|
||||||
|
{
|
||||||
UtilParticle.PlayParticle(type, loc, 0.4f, 0.4f, 0.4f, 0, amount,
|
UtilParticle.PlayParticle(type, loc, 0.4f, 0.4f, 0.4f, 0, amount,
|
||||||
ViewDist.LONGER, UtilServer.getPlayers());
|
ViewDist.LONGER, UtilServer.getPlayers());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if(Player != null)
|
||||||
|
{
|
||||||
UtilParticle.PlayParticle(type, loc, 0.4f, 0.4f, 0.4f, 0, amount,
|
UtilParticle.PlayParticle(type, loc, 0.4f, 0.4f, 0.4f, 0, amount,
|
||||||
ViewDist.LONGER, Player);
|
ViewDist.LONGER, Player);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(Player player : Team.GetPlayers(true))
|
||||||
|
{
|
||||||
|
UtilParticle.PlayParticle(type, loc, 0.4f, 0.4f, 0.4f, 0, amount,
|
||||||
|
ViewDist.LONGER, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playWeather(boolean b)
|
public void playWeather(boolean b)
|
||||||
@ -265,9 +314,19 @@ public class BuildData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if(Player != null)
|
||||||
{
|
{
|
||||||
playWeather(Player, type);
|
playWeather(Player, type);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(Player player : Team.GetPlayers(true))
|
||||||
|
{
|
||||||
|
playWeather(player, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playWeather(Player player, org.bukkit.WeatherType type)
|
public void playWeather(Player player, org.bukkit.WeatherType type)
|
||||||
@ -294,11 +353,11 @@ public class BuildData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGround(GroundData ground)
|
public void setGround(Player player, GroundData ground)
|
||||||
{
|
{
|
||||||
if (!Recharge.Instance.use(Player, "Change Ground", 2000, true, false))
|
if (!Recharge.Instance.use(player, "Change Ground", 2000, true, false))
|
||||||
{
|
{
|
||||||
Player.playSound(Player.getLocation(), Sound.NOTE_BASS_GUITAR, 1f, 0.1f);
|
player.playSound(player.getLocation(), Sound.NOTE_BASS_GUITAR, 1f, 0.1f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +374,7 @@ public class BuildData
|
|||||||
for (int x= Math.min(CornerA.getBlockX(), CornerB.getBlockX()) ; x <= Math.max(CornerA.getBlockX(), CornerB.getBlockX()) ; x++)
|
for (int x= Math.min(CornerA.getBlockX(), CornerB.getBlockX()) ; x <= Math.max(CornerA.getBlockX(), CornerB.getBlockX()) ; x++)
|
||||||
for (int z= Math.min(CornerA.getBlockZ(), CornerB.getBlockZ()) ; z <= Math.max(CornerA.getBlockZ(), CornerB.getBlockZ()) ; z++)
|
for (int z= Math.min(CornerA.getBlockZ(), CornerB.getBlockZ()) ; z <= Math.max(CornerA.getBlockZ(), CornerB.getBlockZ()) ; z++)
|
||||||
{
|
{
|
||||||
MapUtil.QuickChangeBlockAt(Player.getWorld(), x, y, z, Material.AIR, data);
|
MapUtil.QuickChangeBlockAt(player.getWorld(), x, y, z, Material.AIR, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +382,7 @@ public class BuildData
|
|||||||
for (int x= Math.min(CornerA.getBlockX(), CornerB.getBlockX()) ; x <= Math.max(CornerA.getBlockX(), CornerB.getBlockX()) ; x++)
|
for (int x= Math.min(CornerA.getBlockX(), CornerB.getBlockX()) ; x <= Math.max(CornerA.getBlockX(), CornerB.getBlockX()) ; x++)
|
||||||
for (int z= Math.min(CornerA.getBlockZ(), CornerB.getBlockZ()) ; z <= Math.max(CornerA.getBlockZ(), CornerB.getBlockZ()) ; z++)
|
for (int z= Math.min(CornerA.getBlockZ(), CornerB.getBlockZ()) ; z <= Math.max(CornerA.getBlockZ(), CornerB.getBlockZ()) ; z++)
|
||||||
{
|
{
|
||||||
MapUtil.QuickChangeBlockAt(Player.getWorld(), x, y, z, mat, data);
|
MapUtil.QuickChangeBlockAt(player.getWorld(), x, y, z, mat, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class GroundPage extends ShopPageBase<ArcadeManager, OptionsShop>
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(Player player, ClickType clickType)
|
public void onClick(Player player, ClickType clickType)
|
||||||
{
|
{
|
||||||
buildData.setGround(data);
|
buildData.setGround(player, data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
index++;
|
index++;
|
||||||
|
@ -70,7 +70,7 @@ public class ParticlesPage extends ShopPageBase<ArcadeManager, OptionsShop>
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(Player player, ClickType clickType)
|
public void onClick(Player player, ClickType clickType)
|
||||||
{
|
{
|
||||||
buildData.resetParticles();
|
buildData.resetParticles(player);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -0,0 +1,219 @@
|
|||||||
|
package nautilus.game.arcade.game.games.build.modes;
|
||||||
|
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
|
import nautilus.game.arcade.game.games.build.Build;
|
||||||
|
import nautilus.game.arcade.game.games.build.BuildData;
|
||||||
|
import nautilus.game.arcade.game.games.build.BuildQuality;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TeamBuild
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class TeamBuild extends Build
|
||||||
|
{
|
||||||
|
|
||||||
|
private ArrayList<Player> _winners;
|
||||||
|
private ArrayList<Entry<GameTeam,Double>> _scoreboardPlaces = new ArrayList<Entry<GameTeam,Double>>();
|
||||||
|
|
||||||
|
public TeamBuild(ArcadeManager manager)
|
||||||
|
{
|
||||||
|
super(manager);
|
||||||
|
|
||||||
|
TeamMode = true;
|
||||||
|
PlayerTeamSelection = true;
|
||||||
|
TeamPerSpawn = true;
|
||||||
|
FillTeamsInOrderToCount = 2;
|
||||||
|
|
||||||
|
_winners = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@EventHandler
|
||||||
|
public void prepare(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() == GameState.Live)
|
||||||
|
{
|
||||||
|
for (GameTeam team : GetTeamList())
|
||||||
|
{
|
||||||
|
Location spawn = team.GetSpawns().get(0);
|
||||||
|
|
||||||
|
BuildData data = new BuildData(team, spawn, WorldData.GetDataLocs("YELLOW"));
|
||||||
|
|
||||||
|
for(Player player : team.GetPlayers(true))
|
||||||
|
{
|
||||||
|
getData().put(player, data);
|
||||||
|
player.setFlySpeed(0.1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!useHolidayWords() || Math.random() >= 0.5)
|
||||||
|
setWord(getWords()[UtilMath.r(getWords().length)]);
|
||||||
|
else
|
||||||
|
setWord(getHolidayWords()[UtilMath.r(getHolidayWords().length)]);
|
||||||
|
|
||||||
|
UtilTextMiddle.display(null, C.cYellow + "Build " + C.cWhite + getWord(), 0, 80, 5);
|
||||||
|
|
||||||
|
this.WorldTimeSet = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processReport(Player reporter)
|
||||||
|
{
|
||||||
|
getViewData().addAbuseVote(reporter);
|
||||||
|
UtilTextMiddle.display(null, C.cWhite + C.Bold + "Inappropriate Build", 0, 40, 5, reporter);
|
||||||
|
UtilPlayer.message(reporter, C.cWhite + C.Bold + "You reported " + getViewData().Team.getDisplayName() + " for inappropriate build!");
|
||||||
|
UtilPlayer.message(reporter, C.cWhite + C.Bold + "Thanks for helping us keep Master Builders clean!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void abusiveBulid()
|
||||||
|
{
|
||||||
|
getViewData().setAbusive();
|
||||||
|
|
||||||
|
for(Player player : getViewData().Team.GetPlayers(true))
|
||||||
|
{
|
||||||
|
//Record Abuse
|
||||||
|
AddStat(player, "Build Draw Abuse", 1, false, true);
|
||||||
|
|
||||||
|
UtilPlayer.message(player, C.cWhite + C.Bold + "Inappropriate Builds can result in a Master Buildres ban.");
|
||||||
|
|
||||||
|
//Announce
|
||||||
|
Announce(C.cWhite + C.Bold + player.getName() + " has been reported for an inappropriate build.", false);
|
||||||
|
|
||||||
|
//Return to Hub
|
||||||
|
getArcadeManager().GetPortal().sendPlayerToServer(player, "Lobby");
|
||||||
|
}
|
||||||
|
|
||||||
|
getViewData().Spawn.getWorld().playSound(getViewData().Spawn, Sound.ENDERDRAGON_GROWL, 10f, 1f);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeScoreboard()
|
||||||
|
{
|
||||||
|
//Wipe Last
|
||||||
|
Scoreboard.Reset();
|
||||||
|
|
||||||
|
Scoreboard.WriteBlank();
|
||||||
|
Scoreboard.Write(C.cYellow + C.Bold + "Build Theme");
|
||||||
|
Scoreboard.Write(getWord());
|
||||||
|
|
||||||
|
|
||||||
|
Scoreboard.WriteBlank();
|
||||||
|
|
||||||
|
if (getBuildGameState() == 0)
|
||||||
|
{
|
||||||
|
Scoreboard.Write(C.cYellow + C.Bold + "Build Time");
|
||||||
|
Scoreboard.Write(UtilTime.MakeStr(Math.max(0, getBuildTime() - (System.currentTimeMillis() - this.GetStateTime())), 0));
|
||||||
|
}
|
||||||
|
else if (getBuildGameState() == 2)
|
||||||
|
{
|
||||||
|
Scoreboard.Write(C.cYellow + C.Bold + "Vote Time");
|
||||||
|
Scoreboard.Write(UtilTime.MakeStr(Math.max(0, getVoteTime() - (System.currentTimeMillis() - getBuildStateTime())), 0));
|
||||||
|
}
|
||||||
|
else if (getBuildGameState() == 4)
|
||||||
|
{
|
||||||
|
for (Entry<GameTeam, Double> score : _scoreboardPlaces)
|
||||||
|
{
|
||||||
|
Scoreboard.Write(BuildQuality.getFinalQuality(score.getValue()).getColor() + (int)(score.getValue().intValue()/10) + " " + ChatColor.RESET + score.getKey().getDisplayName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Scoreboard.Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void calculatePlaces()
|
||||||
|
{
|
||||||
|
|
||||||
|
ArrayList<GameTeam> places = new ArrayList<GameTeam>();
|
||||||
|
|
||||||
|
//Calculate Places
|
||||||
|
boolean first = true;
|
||||||
|
while (!getData().isEmpty())
|
||||||
|
{
|
||||||
|
GameTeam bestTeam = null;
|
||||||
|
double bestPoints = 0;
|
||||||
|
|
||||||
|
for (Player player : getData().keySet())
|
||||||
|
{
|
||||||
|
double points = getData().get(player).getPoints();
|
||||||
|
|
||||||
|
if (bestTeam == null || points > bestPoints)
|
||||||
|
{
|
||||||
|
bestTeam = getData().get(player).Team;
|
||||||
|
bestPoints = points;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildData data = null;
|
||||||
|
//Average points per player is 1000, so divided by 50 = 20 gems
|
||||||
|
for(Player player : bestTeam.GetPlayers(true))
|
||||||
|
{
|
||||||
|
AddGems(player, bestPoints / 50, "Build Votes", false, false);
|
||||||
|
|
||||||
|
data = getData().remove(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Teleport to winner
|
||||||
|
if (first)
|
||||||
|
{
|
||||||
|
teleportPlayers(data);
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
places.add(bestTeam);
|
||||||
|
_scoreboardPlaces.add(new AbstractMap.SimpleEntry<GameTeam, Double>(bestTeam, bestPoints));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Announce
|
||||||
|
AnnounceEnd(places.get(0));
|
||||||
|
|
||||||
|
//Gems
|
||||||
|
if (places.size() >= 1)
|
||||||
|
{
|
||||||
|
for(Player player : places.get(0).GetPlayers(true))
|
||||||
|
{
|
||||||
|
_winners.add(player);
|
||||||
|
AddGems(player, 20, "1st Place", false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : GetPlayers(false))
|
||||||
|
if (player.isOnline())
|
||||||
|
AddGems(player, 10, "Participation", false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Player> getWinners()
|
||||||
|
{
|
||||||
|
return _winners;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String GetMode()
|
||||||
|
{
|
||||||
|
return "Team Master Builders";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package nautilus.game.arcade.game.games.runner.modes;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.game.games.runner.Runner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GottaGoFast
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class FasterThanLight extends Runner
|
||||||
|
{
|
||||||
|
|
||||||
|
public FasterThanLight(ArcadeManager manager)
|
||||||
|
{
|
||||||
|
super(manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void speed(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.SEC)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Player player : GetPlayers(true))
|
||||||
|
{
|
||||||
|
Manager.GetCondition().Factory().Speed("Game Mode", player, player, 3, 4, true, true,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String GetMode()
|
||||||
|
{
|
||||||
|
return "Faster Than Light";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -34,8 +34,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
public class TeamSkywars extends Skywars
|
public class TeamSkywars extends Skywars
|
||||||
{
|
{
|
||||||
|
|
||||||
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
|
|
||||||
|
|
||||||
public TeamSkywars(ArcadeManager manager)
|
public TeamSkywars(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
super(manager, GameType.SkywarsTeams,
|
super(manager, GameType.SkywarsTeams,
|
||||||
@ -46,152 +44,17 @@ public class TeamSkywars extends Skywars
|
|||||||
"Last team alive wins!"
|
"Last team alive wins!"
|
||||||
});
|
});
|
||||||
|
|
||||||
this.FillTeamsInOrderToCount = 2;
|
FillTeamsInOrderToCount = 2;
|
||||||
|
|
||||||
this.SpawnNearAllies = true;
|
SpawnNearAllies = true;
|
||||||
|
|
||||||
this.DamageTeamSelf = false;
|
DamageTeamSelf = false;
|
||||||
|
|
||||||
this.DontAllowOverfill = true;
|
DontAllowOverfill = true;
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
PlayerTeamSelection = true;
|
||||||
public void CustomTeamGeneration(GameStateChangeEvent event)
|
TeamMode = true;
|
||||||
{
|
TeamPerSpawn = true;
|
||||||
if (event.GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ArrayList<Location> initialSpawns = this.GetTeamList().get(0).GetSpawns();
|
|
||||||
this.GetTeamList().clear();
|
|
||||||
|
|
||||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
|
||||||
|
|
||||||
TeamColors color = TeamColors.DARK_AQUA;
|
|
||||||
|
|
||||||
//Create 1 Team for each Spawn
|
|
||||||
int i = 0;
|
|
||||||
for(Location location : initialSpawns)
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
|
|
||||||
spawns.add(location);
|
|
||||||
|
|
||||||
addRelativeSpawns(spawns, location);
|
|
||||||
|
|
||||||
//Got Spawns
|
|
||||||
color = getNextColor(color);
|
|
||||||
int e = 0;
|
|
||||||
for(GameTeam teams : GetTeamList())
|
|
||||||
{
|
|
||||||
if(teams.GetColor() == color.getColor())
|
|
||||||
{
|
|
||||||
e++;
|
|
||||||
if(getColorName(color.getColor()).length <= e)
|
|
||||||
{
|
|
||||||
e = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GameTeam team = new GameTeam(this, getColorName(color.getColor())[e], color.getColor(), spawns, true);
|
|
||||||
team.SetVisible(true);
|
|
||||||
GetTeamList().add(team);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addRelativeSpawns(ArrayList<Location> spawns, Location location)
|
|
||||||
{
|
|
||||||
//Gather Extra Spawns
|
|
||||||
for(int x = -1; x <= 1; x++)
|
|
||||||
{
|
|
||||||
for(int z = -1; z <= 1; z++)
|
|
||||||
{
|
|
||||||
if(x != 0 && z != 0)
|
|
||||||
{
|
|
||||||
Location newSpawn = location.clone().add(x, 0, z);
|
|
||||||
|
|
||||||
//Search Downward for Solid
|
|
||||||
while (UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN)) && newSpawn.getY() > location.getY()-5)
|
|
||||||
{
|
|
||||||
newSpawn.subtract(0, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Move Up out of Solid
|
|
||||||
while (!UtilBlock.airFoliage(newSpawn.getBlock()) && newSpawn.getY() < location.getY()+5)
|
|
||||||
{
|
|
||||||
newSpawn.add(0, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//On Solid, with 2 Air Above
|
|
||||||
if (UtilBlock.airFoliage(newSpawn.getBlock()) &&
|
|
||||||
UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.UP)) &&
|
|
||||||
!UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN)))
|
|
||||||
{
|
|
||||||
spawns.add(newSpawn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum TeamColors
|
|
||||||
{
|
|
||||||
|
|
||||||
YELLOW(ChatColor.YELLOW, new String[]{"Banana", "Sunshine", "Custard", "Sponge", "Star", "Giraffe", "Lego", "Light"}),
|
|
||||||
GREEN(ChatColor.GREEN, new String[]{"Creepers", "Alien", "Seaweed", "Emerald", "Grinch", "Shrub", "Snake", "Leaf"}),
|
|
||||||
AQUA(ChatColor.AQUA, new String[]{"Diamond", "Ice", "Pool", "Kraken", "Aquatic", "Ocean"}),
|
|
||||||
RED(ChatColor.RED, new String[]{"Heart", "Tomato", "Ruby", "Jam", "Rose", "Apple", "TNT"}),
|
|
||||||
GOLD(ChatColor.GOLD, new String[]{"Mango", "Foxes", "Sunset", "Nuggets", "Lion", "Desert", "Gapple"}),
|
|
||||||
LIGHT_PURPLE(ChatColor.LIGHT_PURPLE, new String[]{"Dream", "Cupcake", "Cake", "Candy", "Unicorn"}),
|
|
||||||
DARK_BLUE(ChatColor.DARK_BLUE, new String[]{"Squid", "Lapis", "Sharks", "Galaxy", "Empoleon"}),
|
|
||||||
DARK_RED(ChatColor.DARK_RED, new String[]{"Rose", "Apple", "Twizzler", "Rocket", "Blood"}),
|
|
||||||
WHITE(ChatColor.WHITE, new String[]{"Ghosts", "Spookies", "Popcorn", "Seagull", "Rice", "Snowman", "Artic"}),
|
|
||||||
BLUE(ChatColor.BLUE, new String[]{"Sky", "Whale", "Lake", "Birds", "Bluebird", "Piplup"}),
|
|
||||||
DARK_GREEN(ChatColor.DARK_GREEN, new String[]{"Forest", "Zombies", "Cactus", "Slime", "Toxic", "Poison"}),
|
|
||||||
DARK_PURPLE(ChatColor.DARK_PURPLE, new String[]{"Amethyst", "Slugs", "Grape", "Witch", "Magic", "Zula"}),
|
|
||||||
DARK_AQUA(ChatColor.DARK_AQUA, new String[]{"Snorlax", "Aquatic", "Clam", "Fish"});
|
|
||||||
|
|
||||||
private ChatColor color;
|
|
||||||
private String[] names;
|
|
||||||
|
|
||||||
private TeamColors(ChatColor color, String[] names)
|
|
||||||
{
|
|
||||||
this.color = color;
|
|
||||||
this.names = names;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatColor getColor()
|
|
||||||
{
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getNames()
|
|
||||||
{
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] getColorName(ChatColor color)
|
|
||||||
{
|
|
||||||
for(TeamColors colors : TeamColors.values())
|
|
||||||
{
|
|
||||||
if(colors.getColor() == color)
|
|
||||||
{
|
|
||||||
return colors.getNames();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TeamColors getNextColor(TeamColors color)
|
|
||||||
{
|
|
||||||
for(TeamColors colors : TeamColors.values()) {
|
|
||||||
if(colors.ordinal() == color.ordinal() + 1)
|
|
||||||
{
|
|
||||||
return colors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TeamColors.YELLOW;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -262,8 +125,6 @@ public class TeamSkywars extends Skywars
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Scoreboard.Draw();
|
Scoreboard.Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,147 +190,6 @@ public class TeamSkywars extends Skywars
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean CanJoinTeam(GameTeam team)
|
|
||||||
{
|
|
||||||
return team.GetSize() < 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void teamSelectInteract(PlayerInteractEntityEvent event)
|
|
||||||
{
|
|
||||||
if (GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getRightClicked() == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!(event.getRightClicked() instanceof Player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
//Observer
|
|
||||||
if (Manager.IsObserver(player))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
selectTeamMate(player, (Player)event.getRightClicked());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void teamSelectCommand(PlayerCommandPreprocessEvent event)
|
|
||||||
{
|
|
||||||
if (GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!event.getMessage().toLowerCase().startsWith("/team "))
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true);
|
|
||||||
if (target == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Observer
|
|
||||||
if (Manager.IsObserver(event.getPlayer()))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getPlayer().equals(target))
|
|
||||||
return;
|
|
||||||
|
|
||||||
selectTeamMate(event.getPlayer(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectTeamMate(Player player, Player ally)
|
|
||||||
{
|
|
||||||
//Accept Invite
|
|
||||||
if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player))
|
|
||||||
{
|
|
||||||
//Remove Prefs
|
|
||||||
_teamReqs.remove(player);
|
|
||||||
_teamReqs.remove(ally);
|
|
||||||
|
|
||||||
//Inform
|
|
||||||
UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!"));
|
|
||||||
UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!"));
|
|
||||||
|
|
||||||
//Leave Old Teams
|
|
||||||
if (GetTeam(player) != null)
|
|
||||||
GetTeam(player).DisbandTeam();
|
|
||||||
|
|
||||||
if (GetTeam(ally) != null)
|
|
||||||
GetTeam(ally).DisbandTeam();
|
|
||||||
|
|
||||||
//Get Team
|
|
||||||
GameTeam team = getEmptyTeam();
|
|
||||||
if (team == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Join Team
|
|
||||||
SetPlayerTeam(player, team, true);
|
|
||||||
SetPlayerTeam(ally, team, true);
|
|
||||||
}
|
|
||||||
//Send Invite
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Already on Team with Target
|
|
||||||
if (GetTeam(player) != null)
|
|
||||||
if (GetTeam(player).HasPlayer(ally))
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Inform Player
|
|
||||||
UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!"));
|
|
||||||
|
|
||||||
//Inform Target
|
|
||||||
if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!"));
|
|
||||||
UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add Pref
|
|
||||||
_teamReqs.put(player, ally);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void teamQuit(PlayerQuitEvent event)
|
|
||||||
{
|
|
||||||
if (GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (GetTeam(player) != null)
|
|
||||||
GetTeam(player).DisbandTeam();
|
|
||||||
|
|
||||||
Iterator<Player> teamIter = _teamReqs.keySet().iterator();
|
|
||||||
while (teamIter.hasNext())
|
|
||||||
{
|
|
||||||
Player sender = teamIter.next();
|
|
||||||
if (sender.equals(player) || _teamReqs.get(sender).equals(player))
|
|
||||||
teamIter.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameTeam getEmptyTeam()
|
|
||||||
{
|
|
||||||
for (GameTeam team : GetTeamList())
|
|
||||||
{
|
|
||||||
if (team.GetPlayers(false).isEmpty())
|
|
||||||
return team;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetMode()
|
public String GetMode()
|
||||||
{
|
{
|
||||||
|
@ -29,12 +29,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
public class TeamSuperSmash extends SuperSmash
|
public class TeamSuperSmash extends SuperSmash
|
||||||
{
|
{
|
||||||
|
|
||||||
public boolean ForceTeamSize = true;
|
|
||||||
public int PlayersPerTeam = 2;
|
|
||||||
public int TeamCount = 0;
|
|
||||||
|
|
||||||
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
|
|
||||||
|
|
||||||
public TeamSuperSmash(ArcadeManager manager)
|
public TeamSuperSmash(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
super(manager, GameType.SmashTeams,
|
super(manager, GameType.SmashTeams,
|
||||||
@ -45,15 +39,18 @@ public class TeamSuperSmash extends SuperSmash
|
|||||||
"Last team alive wins!"
|
"Last team alive wins!"
|
||||||
});
|
});
|
||||||
|
|
||||||
this.PlayersPerTeam = 2;
|
PlayersPerTeam = 2;
|
||||||
this.FillTeamsInOrderToCount = 2;
|
FillTeamsInOrderToCount = 2;
|
||||||
|
|
||||||
this.SpawnNearAllies = true;
|
SpawnNearAllies = true;
|
||||||
this.DamageTeamSelf = false;
|
DamageTeamSelf = false;
|
||||||
|
|
||||||
this.TeamArmorHotbar = true;
|
TeamArmorHotbar = true;
|
||||||
|
|
||||||
this.DontAllowOverfill = true;
|
DontAllowOverfill = true;
|
||||||
|
|
||||||
|
TeamMode = true;
|
||||||
|
PlayerTeamSelection = true;
|
||||||
|
|
||||||
registerChatStats(
|
registerChatStats(
|
||||||
Kills,
|
Kills,
|
||||||
@ -122,112 +119,6 @@ public class TeamSuperSmash extends SuperSmash
|
|||||||
Scoreboard.Draw();
|
Scoreboard.Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void CustomTeamGeneration(GameStateChangeEvent event)
|
|
||||||
{
|
|
||||||
if (event.GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ArrayList<Location> spawns = this.GetTeamList().get(0).GetSpawns();
|
|
||||||
this.GetTeamList().clear();
|
|
||||||
|
|
||||||
TeamColors color = TeamColors.DARK_AQUA;
|
|
||||||
|
|
||||||
if(!this.ForceTeamSize)
|
|
||||||
{
|
|
||||||
for(int i = 1; i <= this.TeamCount; i++)
|
|
||||||
{
|
|
||||||
color = getNextColor(color);
|
|
||||||
GameTeam team = new GameTeam(this, String.valueOf(i), color.getColor(), spawns);
|
|
||||||
team.SetVisible(true);
|
|
||||||
GetTeamList().add(team);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for(int i = 1; i <= Manager.GetPlayerFull() / this.PlayersPerTeam; i++)
|
|
||||||
{
|
|
||||||
color = getNextColor(color);
|
|
||||||
int e = 0;
|
|
||||||
for(GameTeam teams : GetTeamList())
|
|
||||||
{
|
|
||||||
if(teams.GetColor() == color.getColor())
|
|
||||||
{
|
|
||||||
e++;
|
|
||||||
if(getColorName(color.getColor()).length <= e)
|
|
||||||
{
|
|
||||||
e = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GameTeam team = new GameTeam(this, getColorName(color.getColor())[e], color.getColor(), spawns, true);
|
|
||||||
team.SetVisible(true);
|
|
||||||
GetTeamList().add(team);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum TeamColors
|
|
||||||
{
|
|
||||||
|
|
||||||
YELLOW(ChatColor.YELLOW, new String[]{"Banana", "Sunshine", "Custard", "Sponge", "Star", "Giraffe", "Lego", "Light"}),
|
|
||||||
GREEN(ChatColor.GREEN, new String[]{"Creepers", "Alien", "Seaweed", "Emerald", "Grinch", "Shrub", "Snake", "Leaf"}),
|
|
||||||
AQUA(ChatColor.AQUA, new String[]{"Diamond", "Ice", "Pool", "Kraken", "Aquatic", "Ocean"}),
|
|
||||||
RED(ChatColor.RED, new String[]{"Heart", "Tomato", "Ruby", "Jam", "Rose", "Apple", "TNT"}),
|
|
||||||
GOLD(ChatColor.GOLD, new String[]{"Mango", "Foxes", "Sunset", "Nuggets", "Lion", "Desert", "Gapple"}),
|
|
||||||
LIGHT_PURPLE(ChatColor.LIGHT_PURPLE, new String[]{"Dream", "Cupcake", "Cake", "Candy", "Unicorn"}),
|
|
||||||
DARK_BLUE(ChatColor.DARK_BLUE, new String[]{"Squid", "Lapis", "Sharks", "Galaxy", "Empoleon"}),
|
|
||||||
DARK_RED(ChatColor.DARK_RED, new String[]{"Rose", "Apple", "Twizzler", "Rocket", "Blood"}),
|
|
||||||
WHITE(ChatColor.WHITE, new String[]{"Ghosts", "Spookies", "Popcorn", "Seagull", "Rice", "Snowman", "Artic"}),
|
|
||||||
BLUE(ChatColor.BLUE, new String[]{"Sky", "Whale", "Lake", "Birds", "Bluebird", "Piplup"}),
|
|
||||||
DARK_GREEN(ChatColor.DARK_GREEN, new String[]{"Forest", "Zombies", "Cactus", "Slime", "Toxic", "Poison"}),
|
|
||||||
DARK_PURPLE(ChatColor.DARK_PURPLE, new String[]{"Amethyst", "Slugs", "Grape", "Witch", "Magic", "Zula"}),
|
|
||||||
DARK_AQUA(ChatColor.DARK_AQUA, new String[]{"Snorlax", "Aquatic", "Clam", "Fish"});
|
|
||||||
|
|
||||||
private ChatColor color;
|
|
||||||
private String[] names;
|
|
||||||
|
|
||||||
private TeamColors(ChatColor color, String[] names)
|
|
||||||
{
|
|
||||||
this.color = color;
|
|
||||||
this.names = names;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatColor getColor()
|
|
||||||
{
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getNames()
|
|
||||||
{
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] getColorName(ChatColor color)
|
|
||||||
{
|
|
||||||
for(TeamColors colors : TeamColors.values())
|
|
||||||
{
|
|
||||||
if(colors.getColor() == color)
|
|
||||||
{
|
|
||||||
return colors.getNames();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TeamColors getNextColor(TeamColors color)
|
|
||||||
{
|
|
||||||
for(TeamColors colors : TeamColors.values()) {
|
|
||||||
if(colors.ordinal() == color.ordinal() + 1)
|
|
||||||
{
|
|
||||||
return colors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TeamColors.YELLOW;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void EndCheck()
|
public void EndCheck()
|
||||||
{
|
{
|
||||||
@ -236,7 +127,7 @@ public class TeamSuperSmash extends SuperSmash
|
|||||||
|
|
||||||
ArrayList<GameTeam> teamsAlive = new ArrayList<GameTeam>();
|
ArrayList<GameTeam> teamsAlive = new ArrayList<GameTeam>();
|
||||||
|
|
||||||
for (GameTeam team : this.GetTeamList())
|
for (GameTeam team : GetTeamList())
|
||||||
if (team.GetPlayers(true).size() > 0)
|
if (team.GetPlayers(true).size() > 0)
|
||||||
teamsAlive.add(team);
|
teamsAlive.add(team);
|
||||||
|
|
||||||
@ -290,147 +181,6 @@ public class TeamSuperSmash extends SuperSmash
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean CanJoinTeam(GameTeam team)
|
|
||||||
{
|
|
||||||
return team.GetSize() < PlayersPerTeam;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void teamSelectInteract(PlayerInteractEntityEvent event)
|
|
||||||
{
|
|
||||||
if (GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getRightClicked() == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!(event.getRightClicked() instanceof Player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
//Observer
|
|
||||||
if (Manager.IsObserver(player))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
selectTeamMate(player, (Player)event.getRightClicked());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void teamSelectCommand(PlayerCommandPreprocessEvent event)
|
|
||||||
{
|
|
||||||
if (GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!event.getMessage().toLowerCase().startsWith("/team "))
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true);
|
|
||||||
if (target == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Observer
|
|
||||||
if (Manager.IsObserver(event.getPlayer()))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getPlayer().equals(target))
|
|
||||||
return;
|
|
||||||
|
|
||||||
selectTeamMate(event.getPlayer(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectTeamMate(Player player, Player ally)
|
|
||||||
{
|
|
||||||
//Accept Invite
|
|
||||||
if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player))
|
|
||||||
{
|
|
||||||
//Remove Prefs
|
|
||||||
_teamReqs.remove(player);
|
|
||||||
_teamReqs.remove(ally);
|
|
||||||
|
|
||||||
//Inform
|
|
||||||
UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!"));
|
|
||||||
UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!"));
|
|
||||||
|
|
||||||
//Leave Old Teams
|
|
||||||
if (GetTeam(player) != null)
|
|
||||||
GetTeam(player).DisbandTeam();
|
|
||||||
|
|
||||||
if (GetTeam(ally) != null)
|
|
||||||
GetTeam(ally).DisbandTeam();
|
|
||||||
|
|
||||||
//Get Team
|
|
||||||
GameTeam team = getEmptyTeam();
|
|
||||||
if (team == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Join Team
|
|
||||||
SetPlayerTeam(player, team, true);
|
|
||||||
SetPlayerTeam(ally, team, true);
|
|
||||||
}
|
|
||||||
//Send Invite
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Already on Team with Target
|
|
||||||
if (GetTeam(player) != null)
|
|
||||||
if (GetTeam(player).HasPlayer(ally))
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Inform Player
|
|
||||||
UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!"));
|
|
||||||
|
|
||||||
//Inform Target
|
|
||||||
if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!"));
|
|
||||||
UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add Pref
|
|
||||||
_teamReqs.put(player, ally);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void teamQuit(PlayerQuitEvent event)
|
|
||||||
{
|
|
||||||
if (GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (GetTeam(player) != null)
|
|
||||||
GetTeam(player).DisbandTeam();
|
|
||||||
|
|
||||||
Iterator<Player> teamIter = _teamReqs.keySet().iterator();
|
|
||||||
while (teamIter.hasNext())
|
|
||||||
{
|
|
||||||
Player sender = teamIter.next();
|
|
||||||
if (sender.equals(player) || _teamReqs.get(sender).equals(player))
|
|
||||||
teamIter.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameTeam getEmptyTeam()
|
|
||||||
{
|
|
||||||
for (GameTeam team : GetTeamList())
|
|
||||||
{
|
|
||||||
if (team.GetPlayers(false).isEmpty())
|
|
||||||
return team;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetMode()
|
public String GetMode()
|
||||||
{
|
{
|
||||||
|
@ -310,7 +310,7 @@ public abstract class SurvivalGames extends Game
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack buildCompass(int uses)
|
protected ItemStack buildCompass(int uses)
|
||||||
{
|
{
|
||||||
ItemBuilder item = new ItemBuilder(Material.COMPASS);
|
ItemBuilder item = new ItemBuilder(Material.COMPASS);
|
||||||
item.setTitle(C.cWhite + "Player Tracker" + buildTime());
|
item.setTitle(C.cWhite + "Player Tracker" + buildTime());
|
||||||
@ -715,7 +715,7 @@ public abstract class SurvivalGames extends Game
|
|||||||
event.blockList().clear();
|
event.blockList().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillChest(Player looter, Block block)
|
public void fillChest(Player looter, Block block)
|
||||||
{
|
{
|
||||||
_lootedBlocks.add(block.getLocation());
|
_lootedBlocks.add(block.getLocation());
|
||||||
|
|
||||||
@ -787,7 +787,7 @@ public abstract class SurvivalGames extends Game
|
|||||||
_supplyCrates.remove(block);
|
_supplyCrates.remove(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack GetChestItem(boolean superChest)
|
protected ItemStack GetChestItem(boolean superChest)
|
||||||
{
|
{
|
||||||
if (superChest)
|
if (superChest)
|
||||||
return _crateLoot.getLoot();
|
return _crateLoot.getLoot();
|
||||||
@ -2021,27 +2021,37 @@ public abstract class SurvivalGames extends Game
|
|||||||
|
|
||||||
public int getSecondsSinceStart()
|
public int getSecondsSinceStart()
|
||||||
{
|
{
|
||||||
return this._secondsSinceStart;
|
return _secondsSinceStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getChestRefillTime()
|
public int getChestRefillTime()
|
||||||
{
|
{
|
||||||
return this._chestRefillTime;
|
return _chestRefillTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDeathMatchTime()
|
public int getDeathMatchTime()
|
||||||
{
|
{
|
||||||
return this._deathMatchTime;
|
return _deathMatchTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeathMatchTeleported()
|
public boolean isDeathMatchTeleported()
|
||||||
{
|
{
|
||||||
return this._deathMatchTeleported;
|
return _deathMatchTeleported;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGameEndTime()
|
public int getGameEndTime()
|
||||||
{
|
{
|
||||||
return this._gameEndTime;
|
return _gameEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Block> getSupplyBlocks()
|
||||||
|
{
|
||||||
|
return _supplyCrates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashSet<Location> getLootedBlocks()
|
||||||
|
{
|
||||||
|
return _lootedBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
public class TeamSurvivalGames extends SurvivalGames
|
public class TeamSurvivalGames extends SurvivalGames
|
||||||
{
|
{
|
||||||
|
|
||||||
public boolean ForceTeamSize = true;
|
|
||||||
public int PlayersPerTeam = 2;
|
|
||||||
public int TeamCount = 0;
|
|
||||||
|
|
||||||
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
|
|
||||||
|
|
||||||
public TeamSurvivalGames(ArcadeManager manager)
|
public TeamSurvivalGames(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
super(manager, GameType.SurvivalGamesTeams,
|
super(manager, GameType.SurvivalGamesTeams,
|
||||||
@ -51,123 +45,17 @@ public class TeamSurvivalGames extends SurvivalGames
|
|||||||
"Last team alive wins!"
|
"Last team alive wins!"
|
||||||
});
|
});
|
||||||
|
|
||||||
this.PlayersPerTeam = 2;
|
PlayersPerTeam = 2;
|
||||||
this.FillTeamsInOrderToCount = 2;
|
FillTeamsInOrderToCount = 2;
|
||||||
|
|
||||||
this.SpawnNearAllies = true;
|
SpawnNearAllies = true;
|
||||||
this.SpawnNearEnemies = true;
|
SpawnNearEnemies = true;
|
||||||
|
|
||||||
this.DamageTeamSelf = false;
|
DamageTeamSelf = false;
|
||||||
|
|
||||||
this.DontAllowOverfill = true;
|
DontAllowOverfill = true;
|
||||||
|
TeamMode = true;
|
||||||
}
|
PlayerTeamSelection = true;
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void CustomTeamGeneration(GameStateChangeEvent event)
|
|
||||||
{
|
|
||||||
if (event.GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ArrayList<Location> spawns = this.GetTeamList().get(0).GetSpawns();
|
|
||||||
this.GetTeamList().clear();
|
|
||||||
|
|
||||||
TeamColors color = TeamColors.DARK_AQUA;
|
|
||||||
|
|
||||||
if(!this.ForceTeamSize)
|
|
||||||
{
|
|
||||||
for(int i = 1; i <= this.TeamCount; i++)
|
|
||||||
{
|
|
||||||
color = getNextColor(color);
|
|
||||||
GameTeam team = new GameTeam(this, String.valueOf(i), color.getColor(), spawns);
|
|
||||||
team.SetVisible(true);
|
|
||||||
GetTeamList().add(team);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for(int i = 1; i <= Manager.GetPlayerFull() / this.PlayersPerTeam; i++)
|
|
||||||
{
|
|
||||||
//Got Spawns
|
|
||||||
color = getNextColor(color);
|
|
||||||
int e = 0;
|
|
||||||
for(GameTeam teams : GetTeamList())
|
|
||||||
{
|
|
||||||
if(teams.GetColor() == color.getColor())
|
|
||||||
{
|
|
||||||
e++;
|
|
||||||
if(getColorName(color.getColor()).length <= e)
|
|
||||||
{
|
|
||||||
e = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GameTeam team = new GameTeam(this, getColorName(color.getColor())[e], color.getColor(), spawns, true);
|
|
||||||
team.SetVisible(true);
|
|
||||||
GetTeamList().add(team);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum TeamColors
|
|
||||||
{
|
|
||||||
|
|
||||||
YELLOW(ChatColor.YELLOW, new String[]{"Banana", "Sunshine", "Custard", "Sponge", "Star", "Giraffe", "Lego", "Light"}),
|
|
||||||
GREEN(ChatColor.GREEN, new String[]{"Creepers", "Alien", "Seaweed", "Emerald", "Grinch", "Shrub", "Snake", "Leaf"}),
|
|
||||||
AQUA(ChatColor.AQUA, new String[]{"Diamond", "Ice", "Pool", "Kraken", "Aquatic", "Ocean"}),
|
|
||||||
RED(ChatColor.RED, new String[]{"Heart", "Tomato", "Ruby", "Jam", "Rose", "Apple", "TNT"}),
|
|
||||||
GOLD(ChatColor.GOLD, new String[]{"Mango", "Foxes", "Sunset", "Nuggets", "Lion", "Desert", "Gapple"}),
|
|
||||||
LIGHT_PURPLE(ChatColor.LIGHT_PURPLE, new String[]{"Dream", "Cupcake", "Cake", "Candy", "Unicorn"}),
|
|
||||||
DARK_BLUE(ChatColor.DARK_BLUE, new String[]{"Squid", "Lapis", "Sharks", "Galaxy", "Empoleon"}),
|
|
||||||
DARK_RED(ChatColor.DARK_RED, new String[]{"Rose", "Apple", "Twizzler", "Rocket", "Blood"}),
|
|
||||||
WHITE(ChatColor.WHITE, new String[]{"Ghosts", "Spookies", "Popcorn", "Seagull", "Rice", "Snowman", "Artic"}),
|
|
||||||
BLUE(ChatColor.BLUE, new String[]{"Sky", "Whale", "Lake", "Birds", "Bluebird", "Piplup"}),
|
|
||||||
DARK_GREEN(ChatColor.DARK_GREEN, new String[]{"Forest", "Zombies", "Cactus", "Slime", "Toxic", "Poison"}),
|
|
||||||
DARK_PURPLE(ChatColor.DARK_PURPLE, new String[]{"Amethyst", "Slugs", "Grape", "Witch", "Magic", "Zula"}),
|
|
||||||
DARK_AQUA(ChatColor.DARK_AQUA, new String[]{"Snorlax", "Aquatic", "Clam", "Fish"});
|
|
||||||
|
|
||||||
private ChatColor color;
|
|
||||||
private String[] names;
|
|
||||||
|
|
||||||
private TeamColors(ChatColor color, String[] names)
|
|
||||||
{
|
|
||||||
this.color = color;
|
|
||||||
this.names = names;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatColor getColor()
|
|
||||||
{
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getNames()
|
|
||||||
{
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] getColorName(ChatColor color)
|
|
||||||
{
|
|
||||||
for(TeamColors colors : TeamColors.values())
|
|
||||||
{
|
|
||||||
if(colors.getColor() == color)
|
|
||||||
{
|
|
||||||
return colors.getNames();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TeamColors getNextColor(TeamColors color)
|
|
||||||
{
|
|
||||||
for(TeamColors colors : TeamColors.values()) {
|
|
||||||
if(colors.ordinal() == color.ordinal() + 1)
|
|
||||||
{
|
|
||||||
return colors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TeamColors.YELLOW;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -185,7 +73,7 @@ public class TeamSurvivalGames extends SurvivalGames
|
|||||||
Scoreboard.WriteBlank();
|
Scoreboard.WriteBlank();
|
||||||
|
|
||||||
Scoreboard.Write(C.cGreen + C.Bold + "Time");
|
Scoreboard.Write(C.cGreen + C.Bold + "Time");
|
||||||
Scoreboard.Write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT));
|
Scoreboard.Write(UtilTime.convertString(getSecondsSinceStart() * 1000, 0, TimeUnit.FIT));
|
||||||
|
|
||||||
Scoreboard.WriteBlank();
|
Scoreboard.WriteBlank();
|
||||||
Scoreboard.Write(C.cYellow + C.Bold + "Teams");
|
Scoreboard.Write(C.cYellow + C.Bold + "Teams");
|
||||||
@ -221,21 +109,21 @@ public class TeamSurvivalGames extends SurvivalGames
|
|||||||
|
|
||||||
Scoreboard.WriteBlank();
|
Scoreboard.WriteBlank();
|
||||||
|
|
||||||
if (this.getChestRefillTime() > 0 && this.getDeathMatchTime() > 60)
|
if (getChestRefillTime() > 0 && getDeathMatchTime() > 60)
|
||||||
{
|
{
|
||||||
Scoreboard.Write(C.cGold + C.Bold + "Chest Refill");
|
Scoreboard.Write(C.cGold + C.Bold + "Chest Refill");
|
||||||
Scoreboard.Write(UtilTime.convertString(this.getChestRefillTime() * 1000, 0, TimeUnit.FIT));
|
Scoreboard.Write(UtilTime.convertString(getChestRefillTime() * 1000, 0, TimeUnit.FIT));
|
||||||
}
|
}
|
||||||
else if (this.getDeathMatchTime() > 0)
|
else if (getDeathMatchTime() > 0)
|
||||||
{
|
{
|
||||||
Scoreboard.Write(C.cRed + C.Bold + "Deathmatch");
|
Scoreboard.Write(C.cRed + C.Bold + "Deathmatch");
|
||||||
Scoreboard.Write(UtilTime.convertString(
|
Scoreboard.Write(UtilTime.convertString(
|
||||||
Math.min(this.getDeathMatchTime(), this.isDeathMatchTeleported() ? 10 : this.getDeathMatchTime()) * 1000, 0, TimeUnit.FIT));
|
Math.min(getDeathMatchTime(), isDeathMatchTeleported() ? 10 : getDeathMatchTime()) * 1000, 0, TimeUnit.FIT));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Scoreboard.Write(C.cRed + C.Bold + "Game End");
|
Scoreboard.Write(C.cRed + C.Bold + "Game End");
|
||||||
Scoreboard.Write(UtilTime.convertString(Math.max(0, this.getGameEndTime()) * 1000, 0, TimeUnit.FIT));
|
Scoreboard.Write(UtilTime.convertString(Math.max(0, getGameEndTime()) * 1000, 0, TimeUnit.FIT));
|
||||||
}
|
}
|
||||||
|
|
||||||
Scoreboard.Draw();
|
Scoreboard.Draw();
|
||||||
@ -249,7 +137,7 @@ public class TeamSurvivalGames extends SurvivalGames
|
|||||||
|
|
||||||
ArrayList<GameTeam> teamsAlive = new ArrayList<GameTeam>();
|
ArrayList<GameTeam> teamsAlive = new ArrayList<GameTeam>();
|
||||||
|
|
||||||
for (GameTeam team : this.GetTeamList())
|
for (GameTeam team : GetTeamList())
|
||||||
if (team.GetPlayers(true).size() > 0)
|
if (team.GetPlayers(true).size() > 0)
|
||||||
teamsAlive.add(team);
|
teamsAlive.add(team);
|
||||||
|
|
||||||
@ -303,147 +191,6 @@ public class TeamSurvivalGames extends SurvivalGames
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean CanJoinTeam(GameTeam team)
|
|
||||||
{
|
|
||||||
return team.GetSize() < PlayersPerTeam;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void teamSelectInteract(PlayerInteractEntityEvent event)
|
|
||||||
{
|
|
||||||
if (GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getRightClicked() == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!(event.getRightClicked() instanceof Player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
//Observer
|
|
||||||
if (Manager.IsObserver(player))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
selectTeamMate(player, (Player)event.getRightClicked());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void teamSelectCommand(PlayerCommandPreprocessEvent event)
|
|
||||||
{
|
|
||||||
if (GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!event.getMessage().toLowerCase().startsWith("/team "))
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true);
|
|
||||||
if (target == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Observer
|
|
||||||
if (Manager.IsObserver(event.getPlayer()))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getPlayer().equals(target))
|
|
||||||
return;
|
|
||||||
|
|
||||||
selectTeamMate(event.getPlayer(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectTeamMate(Player player, Player ally)
|
|
||||||
{
|
|
||||||
//Accept Invite
|
|
||||||
if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player))
|
|
||||||
{
|
|
||||||
//Remove Prefs
|
|
||||||
_teamReqs.remove(player);
|
|
||||||
_teamReqs.remove(ally);
|
|
||||||
|
|
||||||
//Inform
|
|
||||||
UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!"));
|
|
||||||
UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!"));
|
|
||||||
|
|
||||||
//Leave Old Teams
|
|
||||||
if (GetTeam(player) != null)
|
|
||||||
GetTeam(player).DisbandTeam();
|
|
||||||
|
|
||||||
if (GetTeam(ally) != null)
|
|
||||||
GetTeam(ally).DisbandTeam();
|
|
||||||
|
|
||||||
//Get Team
|
|
||||||
GameTeam team = getEmptyTeam();
|
|
||||||
if (team == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Join Team
|
|
||||||
SetPlayerTeam(player, team, true);
|
|
||||||
SetPlayerTeam(ally, team, true);
|
|
||||||
}
|
|
||||||
//Send Invite
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Already on Team with Target
|
|
||||||
if (GetTeam(player) != null)
|
|
||||||
if (GetTeam(player).HasPlayer(ally))
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Inform Player
|
|
||||||
UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!"));
|
|
||||||
|
|
||||||
//Inform Target
|
|
||||||
if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!"));
|
|
||||||
UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add Pref
|
|
||||||
_teamReqs.put(player, ally);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void teamQuit(PlayerQuitEvent event)
|
|
||||||
{
|
|
||||||
if (GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (GetTeam(player) != null)
|
|
||||||
GetTeam(player).DisbandTeam();
|
|
||||||
|
|
||||||
Iterator<Player> teamIter = _teamReqs.keySet().iterator();
|
|
||||||
while (teamIter.hasNext())
|
|
||||||
{
|
|
||||||
Player sender = teamIter.next();
|
|
||||||
if (sender.equals(player) || _teamReqs.get(sender).equals(player))
|
|
||||||
teamIter.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameTeam getEmptyTeam()
|
|
||||||
{
|
|
||||||
for (GameTeam team : GetTeamList())
|
|
||||||
{
|
|
||||||
if (team.GetPlayers(false).isEmpty())
|
|
||||||
return team;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetMode()
|
public String GetMode()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,265 @@
|
|||||||
|
package nautilus.game.arcade.game.games.survivalgames.modes;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit ;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material ;
|
||||||
|
import org.bukkit.block.Block ;
|
||||||
|
import org.bukkit.block.Chest ;
|
||||||
|
import org.bukkit.enchantments.Enchantment ;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.inventory.ItemStack ;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilMath ;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.GameType;
|
||||||
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent ;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.SurvivalGames;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.kit.KitLooter ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OverpoweredSurvival
|
||||||
|
*
|
||||||
|
* @author xXVevzZXx
|
||||||
|
*/
|
||||||
|
public class OverpoweredSurvival extends SurvivalGames
|
||||||
|
{
|
||||||
|
|
||||||
|
private GameTeam _players;
|
||||||
|
|
||||||
|
public OverpoweredSurvival(ArcadeManager manager)
|
||||||
|
{
|
||||||
|
super(manager, GameType.SurvivalGames, new String[]
|
||||||
|
{
|
||||||
|
"Search for chests to find loot",
|
||||||
|
|
||||||
|
"Slaughter your opponents",
|
||||||
|
|
||||||
|
"Stay away from the borders!",
|
||||||
|
|
||||||
|
"Last tribute alive wins!"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillChest(Player looter, Block block)
|
||||||
|
{
|
||||||
|
getLootedBlocks().add(block.getLocation());
|
||||||
|
|
||||||
|
Chest chest = (Chest) block.getState();
|
||||||
|
|
||||||
|
chest.getBlockInventory().clear();
|
||||||
|
|
||||||
|
int items = 2;
|
||||||
|
if (Math.random() > 0.20)
|
||||||
|
items++;
|
||||||
|
if (Math.random() > 0.40)
|
||||||
|
items++;
|
||||||
|
if (Math.random() > 0.60)
|
||||||
|
items++;
|
||||||
|
if (Math.random() > 0.80)
|
||||||
|
items++;
|
||||||
|
|
||||||
|
if (GetKit(looter) instanceof KitLooter)
|
||||||
|
{
|
||||||
|
items += UtilMath.r(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < items; i++)
|
||||||
|
{
|
||||||
|
ItemStack item;
|
||||||
|
|
||||||
|
item = GetChestItem(UtilMath.r(4) == 0);
|
||||||
|
|
||||||
|
if (item.getType() == Material.COMPASS)
|
||||||
|
{
|
||||||
|
item = buildCompass(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(getSupplyBlocks().contains(block))
|
||||||
|
{
|
||||||
|
if(item.getType() == Material.DIAMOND_CHESTPLATE
|
||||||
|
|| item.getType() == Material.DIAMOND_LEGGINGS
|
||||||
|
|| item.getType() == Material.DIAMOND_BOOTS
|
||||||
|
|| item.getType() == Material.DIAMOND_HELMET)
|
||||||
|
{
|
||||||
|
item.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, UtilMath.r(4) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(item.getType() == Material.DIAMOND_SWORD
|
||||||
|
|| item.getType() == Material.DIAMOND_AXE)
|
||||||
|
{
|
||||||
|
item.addEnchantment(Enchantment.DAMAGE_ALL, UtilMath.r(5) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
chest.getBlockInventory().setItem(UtilMath.r(27), item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getSupplyBlocks().contains(block))
|
||||||
|
{
|
||||||
|
Bukkit.getPluginManager().callEvent(
|
||||||
|
new SupplyChestOpenEvent(looter, block));
|
||||||
|
}
|
||||||
|
|
||||||
|
getSupplyBlocks().remove(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void CustomTeamGeneration(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() != GameState.Recruit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_players = GetTeamList().get(0);
|
||||||
|
_players.SetColor(ChatColor.YELLOW);
|
||||||
|
_players.SetName("Players");
|
||||||
|
_players.setDisplayName(C.cYellow + C.Bold + "Players");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@EventHandler
|
||||||
|
public void ScoreboardUpdate(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.FAST)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (GetTeamList().isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Scoreboard.Reset();
|
||||||
|
|
||||||
|
Scoreboard.WriteBlank();
|
||||||
|
|
||||||
|
GameTeam team = GetTeamList().get(0);
|
||||||
|
|
||||||
|
Scoreboard.Write(C.cGreen + C.Bold + "Time");
|
||||||
|
Scoreboard
|
||||||
|
.Write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT));
|
||||||
|
|
||||||
|
Scoreboard.WriteBlank();
|
||||||
|
|
||||||
|
Scoreboard.Write(C.cYellow + C.Bold + "Tributes");
|
||||||
|
if (team.GetPlayers(true).size() > 7)
|
||||||
|
{
|
||||||
|
Scoreboard.Write("" + team.GetPlayers(true).size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Player player : team.GetPlayers(true))
|
||||||
|
{
|
||||||
|
Scoreboard.Write(C.cWhite + player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Scoreboard.WriteBlank();
|
||||||
|
|
||||||
|
if (this.getChestRefillTime() > 0 && this.getDeathMatchTime() > 60)
|
||||||
|
{
|
||||||
|
Scoreboard.Write(C.cGold + C.Bold + "Chest Refill");
|
||||||
|
Scoreboard.Write(
|
||||||
|
UtilTime.convertString(this.getChestRefillTime() * 1000, 0, TimeUnit.FIT));
|
||||||
|
}
|
||||||
|
else if (this.getDeathMatchTime() > 0)
|
||||||
|
{
|
||||||
|
Scoreboard.Write(C.cRed + C.Bold + "Deathmatch");
|
||||||
|
Scoreboard
|
||||||
|
.Write(UtilTime
|
||||||
|
.convertString(
|
||||||
|
Math.min(this.getDeathMatchTime(),
|
||||||
|
this.isDeathMatchTeleported() ? 10
|
||||||
|
: this.getDeathMatchTime())
|
||||||
|
* 1000,
|
||||||
|
0, TimeUnit.FIT));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Scoreboard.Write(C.cRed + C.Bold + "Game End");
|
||||||
|
Scoreboard.Write(UtilTime.convertString(Math.max(0, this.getGameEndTime()) * 1000, 0,
|
||||||
|
TimeUnit.FIT));
|
||||||
|
}
|
||||||
|
|
||||||
|
Scoreboard.Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void EndCheck()
|
||||||
|
{
|
||||||
|
if (!IsLive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (GetPlayers(true).size() <= 1)
|
||||||
|
{
|
||||||
|
ArrayList<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||||
|
|
||||||
|
//Announce
|
||||||
|
AnnounceEnd(places);
|
||||||
|
|
||||||
|
//Gems
|
||||||
|
if (places.size() >= 1)
|
||||||
|
AddGems(places.get(0), 20, "1st Place", false, false);
|
||||||
|
|
||||||
|
if (places.size() >= 2)
|
||||||
|
AddGems(places.get(1), 15, "2nd Place", false, false);
|
||||||
|
|
||||||
|
if (places.size() >= 3)
|
||||||
|
AddGems(places.get(2), 10, "3rd Place", false, false);
|
||||||
|
|
||||||
|
for (Player player : GetPlayers(false))
|
||||||
|
if (player.isOnline())
|
||||||
|
AddGems(player, 10, "Participation", false, false);
|
||||||
|
|
||||||
|
//End
|
||||||
|
SetState(GameState.End);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Player> getWinners()
|
||||||
|
{
|
||||||
|
if (GetState().ordinal() >= GameState.End.ordinal())
|
||||||
|
{
|
||||||
|
List<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||||
|
|
||||||
|
if (places.isEmpty() || !places.get(0).isOnline())
|
||||||
|
return Arrays.asList();
|
||||||
|
else
|
||||||
|
return Arrays.asList(places.get(0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Player> getLosers()
|
||||||
|
{
|
||||||
|
List<Player> winners = getWinners();
|
||||||
|
|
||||||
|
if (winners == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
List<Player> losers = GetTeamList().get(0).GetPlayers(false);
|
||||||
|
|
||||||
|
losers.removeAll(winners);
|
||||||
|
|
||||||
|
return losers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String GetMode()
|
||||||
|
{
|
||||||
|
return "OP Survival Games";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package nautilus.game.arcade.managers;
|
package nautilus.game.arcade.managers;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -14,6 +15,7 @@ import mineplex.core.updater.UpdateType;
|
|||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.core.combat.CombatManager.AttackReason;
|
import mineplex.minecraft.game.core.combat.CombatManager.AttackReason;
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.GameMode;
|
||||||
import nautilus.game.arcade.GameType;
|
import nautilus.game.arcade.GameType;
|
||||||
import nautilus.game.arcade.game.Game;
|
import nautilus.game.arcade.game.Game;
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
@ -34,10 +36,12 @@ public class GameCreationManager implements Listener
|
|||||||
private GameType _nextGame = null;
|
private GameType _nextGame = null;
|
||||||
|
|
||||||
private String _lastMap = "";
|
private String _lastMap = "";
|
||||||
|
private String _lastMode = "";
|
||||||
private ArrayList<GameType> _lastGames = new ArrayList<GameType>();
|
private ArrayList<GameType> _lastGames = new ArrayList<GameType>();
|
||||||
|
|
||||||
public String MapPref = null;
|
public String MapPref = null;
|
||||||
public String MapSource = null;
|
public String MapSource = null;
|
||||||
|
public String ModePref = null;
|
||||||
|
|
||||||
public GameCreationManager(ArcadeManager manager)
|
public GameCreationManager(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
@ -171,6 +175,8 @@ public class GameCreationManager implements Listener
|
|||||||
System.out.println(_nextGame == null ? "Next Game = null" : "Next Game = " + _nextGame.GetName());
|
System.out.println(_nextGame == null ? "Next Game = null" : "Next Game = " + _nextGame.GetName());
|
||||||
System.out.println(MapPref == null ? "Map Pref = null" : "Map Pref = " + MapPref);
|
System.out.println(MapPref == null ? "Map Pref = null" : "Map Pref = " + MapPref);
|
||||||
|
|
||||||
|
System.out.println(ModePref == null ? "Gamemode Pref = null" : "Gamemode Pref = " + ModePref);
|
||||||
|
|
||||||
//Chosen Game
|
//Chosen Game
|
||||||
if (_nextGame != null)
|
if (_nextGame != null)
|
||||||
{
|
{
|
||||||
@ -186,6 +192,7 @@ public class GameCreationManager implements Listener
|
|||||||
for (int i=0 ; i<50 ; i++)
|
for (int i=0 ; i<50 ; i++)
|
||||||
{
|
{
|
||||||
gameType = Manager.GetGameList().get(UtilMath.r(Manager.GetGameList().size()));
|
gameType = Manager.GetGameList().get(UtilMath.r(Manager.GetGameList().size()));
|
||||||
|
ModePref = randomGameMode(gameType);
|
||||||
|
|
||||||
if (!_lastGames.contains(gameType))
|
if (!_lastGames.contains(gameType))
|
||||||
break;
|
break;
|
||||||
@ -197,9 +204,36 @@ public class GameCreationManager implements Listener
|
|||||||
|
|
||||||
_lastGames.add(0, gameType);
|
_lastGames.add(0, gameType);
|
||||||
|
|
||||||
|
boolean setVars = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Game game = gameType.getGameClass().getConstructor(ArcadeManager.class).newInstance(Manager);
|
GameMode mode = null;
|
||||||
|
Class<? extends Game> gameClass = gameType.getGameClass();
|
||||||
|
|
||||||
|
if(ModePref != null)
|
||||||
|
{
|
||||||
|
for(GameMode modes : gameType.getGameModes())
|
||||||
|
{
|
||||||
|
if(modes.getName().replaceAll(" ", "").equalsIgnoreCase(ModePref))
|
||||||
|
{
|
||||||
|
_lastMode = ModePref;
|
||||||
|
mode = modes;
|
||||||
|
gameClass = modes.getGameClass();
|
||||||
|
setVars = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ModePref = null;
|
||||||
|
|
||||||
|
Game game = gameClass.getConstructor(ArcadeManager.class).newInstance(Manager);
|
||||||
|
|
||||||
|
if(setVars && mode != null)
|
||||||
|
{
|
||||||
|
modifyGameConfiguration(gameClass, mode, game);
|
||||||
|
}
|
||||||
|
|
||||||
Manager.SetGame(game);
|
Manager.SetGame(game);
|
||||||
}
|
}
|
||||||
@ -234,8 +268,117 @@ public class GameCreationManager implements Listener
|
|||||||
TimingManager.stop("registerEvents");
|
TimingManager.stop("registerEvents");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String randomGameMode(GameType type)
|
||||||
|
{
|
||||||
|
ArrayList<String> modes = Manager.GetServerConfig().GameModeList;
|
||||||
|
if(modes.size() == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
GameMode[] gameModes = type.getGameModes();
|
||||||
|
|
||||||
|
String mode = modes.get(UtilMath.r(modes.size()));
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while(mode.equalsIgnoreCase(_lastMode) && !containsMode(gameModes, mode) && i != 25)
|
||||||
|
{
|
||||||
|
mode = modes.get(UtilMath.r(modes.size()));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean containsMode(GameMode[] modes, String mode)
|
||||||
|
{
|
||||||
|
for(GameMode otherMode : modes)
|
||||||
|
{
|
||||||
|
if(otherMode.getName().equalsIgnoreCase(mode))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetNextGameType(GameType type)
|
public void SetNextGameType(GameType type)
|
||||||
{
|
{
|
||||||
_nextGame = type;
|
_nextGame = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void modifyGameConfiguration(Class<? extends Game> gameClass, GameMode mode, Game game)
|
||||||
|
{
|
||||||
|
ArrayList<Class<? extends Game>> classes = new ArrayList<>();
|
||||||
|
classes.add(gameClass);
|
||||||
|
classes.add((Class<? extends Game>) gameClass.getSuperclass());
|
||||||
|
if(gameClass.getSuperclass() != Game.class)
|
||||||
|
{
|
||||||
|
Class<? extends Game> gameType = (Class<? extends Game>) gameClass.getSuperclass();
|
||||||
|
classes.add((Class<? extends Game>) gameType.getSuperclass());
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<String, String> varSet = Manager.GetServerConfig().GameModeMods.get(mode.getName());
|
||||||
|
|
||||||
|
for(Class<? extends Game> clazz : classes)
|
||||||
|
{
|
||||||
|
for(String var : varSet.keySet())
|
||||||
|
{
|
||||||
|
Field f = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
f = clazz.getDeclaredField(var);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
f = clazz.getDeclaredField("_" + var);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {}
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
f.setAccessible(true);
|
||||||
|
String value = varSet.get(var);
|
||||||
|
if(f.getType() == boolean.class)
|
||||||
|
{
|
||||||
|
f.set(game, Boolean.parseBoolean(value));
|
||||||
|
}
|
||||||
|
else if(f.getType() == String.class)
|
||||||
|
{
|
||||||
|
f.set(game, value);
|
||||||
|
}
|
||||||
|
else if(f.getType() == int.class)
|
||||||
|
{
|
||||||
|
f.set(game, Integer.parseInt(value));
|
||||||
|
}
|
||||||
|
else if(f.getType() == float.class)
|
||||||
|
{
|
||||||
|
f.set(game, Float.parseFloat(value));
|
||||||
|
}
|
||||||
|
else if(f.getType() == double.class)
|
||||||
|
{
|
||||||
|
f.set(game, Double.parseDouble(value));
|
||||||
|
}
|
||||||
|
else if(f.getType() == long.class)
|
||||||
|
{
|
||||||
|
f.set(game, Long.parseLong(value));
|
||||||
|
}
|
||||||
|
else if(f.getType() == byte.class)
|
||||||
|
{
|
||||||
|
f.set(game, Byte.parseByte(value));
|
||||||
|
}
|
||||||
|
else if(f.getType() == short.class)
|
||||||
|
{
|
||||||
|
f.set(game, Short.parseShort(value));
|
||||||
|
}
|
||||||
|
f.setAccessible(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.out.println("Error while setting variable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,46 +7,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClient;
|
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.F;
|
|
||||||
import mineplex.core.common.util.MapUtil;
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
|
||||||
import mineplex.core.common.util.UtilAlg;
|
|
||||||
import mineplex.core.common.util.UtilBlockText;
|
|
||||||
import mineplex.core.common.util.UtilBlockText.TextAlign;
|
|
||||||
import mineplex.core.common.util.UtilEnt;
|
|
||||||
import mineplex.core.common.util.UtilFirework;
|
|
||||||
import mineplex.core.common.util.UtilInv;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.common.util.UtilTime;
|
|
||||||
import mineplex.core.common.util.UtilWorld;
|
|
||||||
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
|
|
||||||
import mineplex.core.donation.Donor;
|
|
||||||
import mineplex.core.event.CustomTagEvent;
|
|
||||||
import mineplex.core.packethandler.IPacketHandler;
|
|
||||||
import mineplex.core.packethandler.PacketHandler;
|
|
||||||
import mineplex.core.packethandler.PacketInfo;
|
|
||||||
import mineplex.core.packethandler.PacketVerifier;
|
|
||||||
import mineplex.core.updater.UpdateType;
|
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
|
||||||
import nautilus.game.arcade.GameType;
|
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
|
||||||
import nautilus.game.arcade.game.Game;
|
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
|
||||||
import nautilus.game.arcade.game.GameTeam;
|
|
||||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
|
||||||
import nautilus.game.arcade.kit.Kit;
|
|
||||||
import nautilus.game.arcade.kit.KitAvailability;
|
|
||||||
import nautilus.game.arcade.kit.KitSorter;
|
|
||||||
import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject;
|
|
||||||
import net.minecraft.server.v1_8_R3.Packet;
|
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
@ -77,6 +37,39 @@ import org.bukkit.scoreboard.DisplaySlot;
|
|||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClient;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.MapUtil;
|
||||||
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilBlockText;
|
||||||
|
import mineplex.core.common.util.UtilBlockText.TextAlign;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilFirework;
|
||||||
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.common.util.UtilWorld;
|
||||||
|
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
|
||||||
|
import mineplex.core.donation.Donor;
|
||||||
|
import mineplex.core.event.CustomTagEvent;
|
||||||
|
import mineplex.core.packethandler.PacketHandler;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.GameType;
|
||||||
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
|
import nautilus.game.arcade.game.Game;
|
||||||
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
|
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||||
|
import nautilus.game.arcade.kit.Kit;
|
||||||
|
import nautilus.game.arcade.kit.KitAvailability;
|
||||||
|
import nautilus.game.arcade.kit.KitSorter;
|
||||||
|
|
||||||
public class GameLobbyManager implements Listener
|
public class GameLobbyManager implements Listener
|
||||||
{
|
{
|
||||||
public ArcadeManager Manager;
|
public ArcadeManager Manager;
|
||||||
@ -994,10 +987,10 @@ public class GameLobbyManager implements Listener
|
|||||||
{
|
{
|
||||||
WriteGameLine(game.GetType().GetLobbyName(), 0, 159, (byte)14);
|
WriteGameLine(game.GetType().GetLobbyName(), 0, 159, (byte)14);
|
||||||
|
|
||||||
if (game.GetMode() == null)
|
if (Manager.GetGame().GetMode() == null)
|
||||||
WriteGameLine(" ", 1, 159, (byte)1);
|
WriteGameLine(" ", 1, 159, (byte)1);
|
||||||
else
|
else
|
||||||
WriteGameLine(game.GetMode(), 1, 159, (byte)1);
|
WriteGameLine(Manager.GetGame().GetMode(), 1, 159, (byte)1);
|
||||||
|
|
||||||
DisplayWaiting();
|
DisplayWaiting();
|
||||||
CreateKits(game);
|
CreateKits(game);
|
||||||
|
Loading…
Reference in New Issue
Block a user