Implement gamemode feature with modifiable variables and working on first moded games

This commit is contained in:
xXVevzZXx 2016-04-27 17:42:50 +02:00
parent 962175364b
commit aa219ec3e5
22 changed files with 1766 additions and 1022 deletions

View File

@ -50,6 +50,7 @@ public class ServerGroup
private boolean _generateFreeVersions;
private String _games;
private String _modes;
private String _serverType;
private boolean _addNoCheat;
private boolean _addWorldEdit;
@ -87,6 +88,7 @@ public class ServerGroup
_tournamentPoints = Boolean.valueOf(data.get("tournamentPoints"));
_generateFreeVersions = Boolean.valueOf(data.get("generateFreeVersions"));
_games = data.get("games");
_modes = data.get("modes");
_serverType = data.get("serverType");
_addNoCheat = Boolean.valueOf(data.get("addNoCheat"));
_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
, 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 rewardAchievements, boolean hotbarInventory, boolean hotbarHubClock, boolean playerKickIdle, boolean staffOnly, boolean whitelist, String resourcePack, Region region
, String teamServerKey, String portalBottomCornerLocation, String portalTopCornerLocation, String npcName)
@ -140,6 +142,7 @@ public class ServerGroup
_tournament = tournament;
_tournamentPoints = tournamentPoints;
_games = games;
_modes = modes;
_serverType = serverType;
_addNoCheat = noCheat;
_addWorldEdit = worldEdit;
@ -210,6 +213,7 @@ public class ServerGroup
public boolean getGenerateFreeVersions() { return _generateFreeVersions; }
public String getGames() { return _games; }
public String getModes() { return _modes; }
public String getServerType() { return _serverType; }
public boolean getAddNoCheat() { return _addNoCheat; }
public boolean getAddWorldEdit() { return _addWorldEdit; }

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade;
import java.io.File;
import java.util.HashMap ;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -219,7 +220,8 @@ public class Arcade extends JavaPlugin
for (String gameName : _serverConfiguration.getServerGroup().getGames().split(","))
{
try
{System.out.println(gameName);
{
System.out.println(gameName);
GameType type = GameType.valueOf(gameName);
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)
{
@ -273,4 +295,23 @@ public class Arcade extends JavaPlugin
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);
}
}
}

View File

@ -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;
}
}

View File

@ -1,7 +1,6 @@
package nautilus.game.arcade;
import java.util.AbstractMap;
import java.util.Map.Entry;
import org.bukkit.Material;
import mineplex.core.common.MinecraftVersion;
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.bouncyballs.BouncyBalls;
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.modes.TeamBuild ;
import nautilus.game.arcade.game.games.cards.Cards;
import nautilus.game.arcade.game.games.castlesiege.CastleSiege;
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.rings.ElytraRings;
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.sheep.SheepGame;
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.survivalgames.SoloSurvivalGames;
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.turfforts.TurfForts;
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.zombiesurvival.ZombieSurvival;
import org.bukkit.Material;
public enum GameType
{
//Mini
BaconBrawl(BaconBrawl.class, GameDisplay.BaconBrawl),
Barbarians(Barbarians.class, GameDisplay.Barbarians),
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),
ChampionsCTF(ChampionsCTF.class, GameDisplay.ChampionsCTF),
ChampionsDominate(ChampionsDominate.class, GameDisplay.ChampionsDominate),
@ -124,7 +125,7 @@ public enum GameType
Paintball(Paintball.class, GameDisplay.Paintball),
Quiver(Quiver.class, GameDisplay.Quiver),
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),
Sheep(SheepGame.class, GameDisplay.Sheep),
TypeWars(TypeWars.class, GameDisplay.TypeWars),
@ -140,7 +141,7 @@ public enum GameType
SpleefTeams(SpleefTeams.class, GameDisplay.SpleefTeams),
SquidShooter(SquidShooter.class, GameDisplay.SquidShooter),
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),
Tug(Tug.class, GameDisplay.Tug),
TurfWars(TurfForts.class, GameDisplay.TurfWars),
@ -151,7 +152,7 @@ public enum GameType
Pair.create(MinecraftVersion.ALL, "http://file.mineplex.com/ResWizards.zip")
}, true),
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),
Skywars(SoloSkywars.class, GameDisplay.Skywars),
SkywarsTeams(TeamSkywars.class, GameDisplay.SkywarsTeams, new GameType[]{GameType.Skywars}, false),
@ -182,28 +183,46 @@ public enum GameType
Pair<MinecraftVersion, String>[] _resourcePacks;
Class<? extends Game> _gameClass;
GameMode[] _gameModes;
private int _gameId; // Unique identifying id for this gamemode (used for statistics)
public int getGameId() { return _gameId; }
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)
{
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)
{
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;
_gameClass = gameClass;
_gameModes = gameModes;
_resourcePacks = resourcePackUrls;
_enforceResourcePack = enforceResourcePack;
_mapSource = mapSource;
@ -215,6 +234,11 @@ public enum GameType
return _gameClass;
}
public GameMode[] getGameModes()
{
return _gameModes;
}
public boolean isEnforceResourcePack()
{
return _enforceResourcePack;

View File

@ -38,21 +38,27 @@ public class SetCommand extends CommandBase<ArcadeManager>
if (args.length >= 2)
{
String map = "";
String source = "";
if(args.length == 3)
String source = game;
Plugin.GetGameCreationManager().MapSource = game;
for(String token : args)
{
Plugin.GetGameCreationManager().MapSource = args[1];
Plugin.GetGameCreationManager().MapPref = args[2];
source = args[1];
map = args[2];
}
else
{
Plugin.GetGameCreationManager().MapSource = args[0];
Plugin.GetGameCreationManager().MapPref = args[1];
source = args[0];
map = args[1];
if(token.startsWith("s"))
{
Plugin.GetGameCreationManager().MapSource = token.substring(1);
source = token.substring(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);
}

View File

@ -35,6 +35,8 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
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.PlayerQuitEvent;
import org.bukkit.event.world.WorldLoadEvent;
@ -58,6 +60,7 @@ import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.recharge.Recharge ;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
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.PlayerGameRespawnEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState ;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
@ -330,6 +334,16 @@ public abstract class Game implements Listener
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 int _deadBodyCount;
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>();
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)
{
Manager = manager;
@ -1060,6 +1076,10 @@ public abstract class Game implements Listener
public boolean CanJoinTeam(GameTeam team)
{
if(TeamMode)
{
return team.GetSize() < PlayersPerTeam;
}
return Manager.IsTeamBalance() ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length / GetTeamList().size())
: true;
}
@ -1771,6 +1791,332 @@ public abstract class Game implements Listener
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(){}

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game;
import java.util.ArrayList;
import java.util.HashMap ;
import nautilus.game.arcade.GameType;
@ -10,6 +11,9 @@ public class GameServerConfig
public int MinPlayers = -1;
public int MaxPlayers = -1;
public ArrayList<GameType> GameList = new ArrayList<GameType>();
public ArrayList<String> GameModeList = new ArrayList<String>();
public HashMap<String, HashMap<String, String>> GameModeMods = new HashMap<>();
//Flags
public String HostName = "";

View File

@ -316,7 +316,7 @@ public class Bridge extends TeamGame implements OreObsfucation
if (!WorldData.GetCustomLocs("22").isEmpty()) ParseOre(WorldData.GetCustomLocs("22"));
}
private void ParseChests()
protected void ParseChests()
{
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())
{
@ -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 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;
@ -637,7 +637,7 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
private void ParseWoodBridge() {
protected void ParseWoodBridge() {
_woodBridge = new ArrayList<Location>();
// 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")) {
_lavaBridge.add(loc.getBlock().getLocation());
}
@ -685,12 +685,12 @@ public class Bridge extends TeamGame implements OreObsfucation
_lavaSource = WorldData.GetDataLocs("BLACK");
}
private void ParseIceBridge()
protected void ParseIceBridge()
{
_iceBridge = WorldData.GetDataLocs("LIGHT_BLUE");
}
private void ParseMushrooms()
protected void ParseMushrooms()
{
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"))
{
@ -747,7 +747,7 @@ public class Bridge extends TeamGame implements OreObsfucation
buildMushroom();
}
private void BuildLava()
protected void BuildLava()
{
for (int i = 0; i < 3; i++)
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++)
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));
}
private void buildMushroom()
protected void buildMushroom()
{
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))
{
@ -943,7 +943,7 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
private void BuildWood()
protected void BuildWood()
{
if (_woodBridgeBlocks != null && !_woodBridgeBlocks.isEmpty())
{
@ -1955,4 +1955,9 @@ public class Bridge extends TeamGame implements OreObsfucation
_bridgeTime = time;
}
public double getOreDensity()
{
return _oreDensity;
}
}

View File

@ -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";
}
}

View File

@ -34,6 +34,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
import nautilus.game.arcade.game.Game ;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.build.gui.MobShop;
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.inventory.ItemStack;
public class Build extends SoloGame
public class Build extends Game
{
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)
{
result = C.cWhite + "Inappropriate Build";
_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");
abusiveBulid();
}
else if (!hasDecentVote)
{
@ -442,7 +431,14 @@ public class Build extends SoloGame
}
//Announce Builder
UtilTextMiddle.display(result, "Built by: " + C.Bold + _viewData.Player.getName(), 0, 80, 5);
if(_viewData.Player != null)
{
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;
@ -513,69 +509,92 @@ public class Build extends SoloGame
{
tallyScores();
ArrayList<Player> places = new ArrayList<Player>();
//Calculate Places
boolean first = true;
while (!_data.isEmpty())
{
Player bestPlayer = null;
double bestPoints = 0;
for (Player player : _data.keySet())
{
double points = _data.get(player).getPoints();
if (bestPlayer == null || points > bestPoints)
{
bestPlayer = player;
bestPoints = points;
}
}
//Average points per player is 1000, so divided by 50 = 20 gems
AddGems(bestPlayer, bestPoints / 50, "Build Votes", false, false);
BuildData data = _data.remove(bestPlayer);
//Teleport to winner
if (first)
{
teleportPlayers(data);
first = false;
}
places.add(bestPlayer);
_scoreboardPlaces.add(new AbstractMap.SimpleEntry<Player, Double>(bestPlayer, bestPoints));
}
calculatePlaces();
writeScoreboard();
//Announce
AnnounceEnd(places);
//Gems
if (places.size() >= 1)
{
_winnerUUID = places.get(0).getUniqueId();
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);
}
}
public void calculatePlaces()
{
ArrayList<Player> places = new ArrayList<Player>();
//Calculate Places
boolean first = true;
while (!_data.isEmpty())
{
Player bestPlayer = null;
double bestPoints = 0;
for (Player player : _data.keySet())
{
double points = _data.get(player).getPoints();
if (bestPlayer == null || points > bestPoints)
{
bestPlayer = player;
bestPoints = points;
}
}
//Average points per player is 1000, so divided by 50 = 20 gems
AddGems(bestPlayer, bestPoints / 50, "Build Votes", false, false);
BuildData data = _data.remove(bestPlayer);
//Teleport to winner
if (first)
{
teleportPlayers(data);
first = false;
}
places.add(bestPlayer);
_scoreboardPlaces.add(new AbstractMap.SimpleEntry<Player, Double>(bestPlayer, bestPoints));
}
//Announce
AnnounceEnd(places);
//Gems
if (places.size() >= 1)
{
_winnerUUID = places.get(0).getUniqueId();
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);
}
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()
{
//Reset, if being re-called
@ -641,7 +660,7 @@ public class Build extends SoloGame
return _buildStateTime == 0;
}
private void teleportPlayers(BuildData data)
public void teleportPlayers(BuildData data)
{
//Teleport
for (int i=0 ; i<UtilServer.getPlayers().length ; i++)
@ -784,16 +803,22 @@ public class Build extends SoloGame
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))
return;
//Vote Abuse
if (UtilGear.isMat(event.getPlayer().getItemInHand(), Material.BOOK))
{
_viewData.addAbuseVote(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!");
processReport(event.getPlayer());
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
public void playerQuit(PlayerQuitEvent event)
{
@ -1070,7 +1103,7 @@ public class Build extends SoloGame
if (data == null)
return;
if (data.Player.equals(event.getPlayer()))
if (data.Team.HasPlayer(event.getPlayer()))
{
event.getItem().remove();
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)
{
data.addParticles(particleType);
data.addParticles(event.getPlayer(), particleType);
}
event.setCancelled(true);
@ -1573,4 +1606,80 @@ public class Build extends SoloGame
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;
}
}

View File

@ -4,19 +4,6 @@ import java.util.ArrayList;
import java.util.HashSet;
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.Material;
import org.bukkit.Sound;
@ -28,6 +15,20 @@ import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
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.PacketPlayOutSpawnEntityWeather;
@ -35,6 +36,8 @@ public class BuildData
{
public Player Player;
public GameTeam Team;
public boolean Judged = false;
public Location Spawn;
@ -65,6 +68,19 @@ public class BuildData
public BuildData(Player player, Location spawn, ArrayList<Location> buildBorders)
{
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;
CornerA = UtilAlg.findClosest(spawn, buildBorders);
@ -90,50 +106,68 @@ public class BuildData
return true;
}
public boolean addParticles(ParticleType particleType)
public boolean addParticles(Player player, ParticleType particleType)
{
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;
}
Location toPlace = Player.getEyeLocation().add(Player.getLocation().getDirection());
Location toPlace = player.getEyeLocation().add(player.getLocation().getDirection());
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;
}
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;
}
public void resetParticles()
public void resetParticles(Player player)
{
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)
{
if (entity instanceof Ghast)
{
UtilPlayer.message(Player, F.main("Game", "You cannot spawn Ghasts!"));
if(Player != null)
{
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();
return false;
}
if (Entities.size() >= 16)
{
UtilPlayer.message(Player, F.main("Game", "You cannot spawn more than 16 Entities!"));
if(Player != null)
{
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();
return false;
}
@ -243,11 +277,26 @@ public class BuildData
amount = 1;
if (all)
{
UtilParticle.PlayParticle(type, loc, 0.4f, 0.4f, 0.4f, 0, amount,
ViewDist.LONGER, UtilServer.getPlayers());
}
else
UtilParticle.PlayParticle(type, loc, 0.4f, 0.4f, 0.4f, 0, amount,
ViewDist.LONGER, Player);
{
if(Player != null)
{
UtilParticle.PlayParticle(type, loc, 0.4f, 0.4f, 0.4f, 0, amount,
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);
}
}
}
}
}
@ -266,7 +315,17 @@ public class BuildData
}
else
{
playWeather(Player, type);
if(Player != null)
{
playWeather(Player, type);
}
else
{
for(Player player : Team.GetPlayers(true))
{
playWeather(player, 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;
}
@ -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 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 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);
}
}

View File

@ -64,7 +64,7 @@ public class GroundPage extends ShopPageBase<ArcadeManager, OptionsShop>
@Override
public void onClick(Player player, ClickType clickType)
{
buildData.setGround(data);
buildData.setGround(player, data);
}
});
index++;

View File

@ -70,7 +70,7 @@ public class ParticlesPage extends ShopPageBase<ArcadeManager, OptionsShop>
@Override
public void onClick(Player player, ClickType clickType)
{
buildData.resetParticles();
buildData.resetParticles(player);
}
});

View File

@ -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";
}
}

View File

@ -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";
}
}

View File

@ -34,8 +34,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class TeamSkywars extends Skywars
{
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
public TeamSkywars(ArcadeManager manager)
{
super(manager, GameType.SkywarsTeams,
@ -46,152 +44,17 @@ public class TeamSkywars extends Skywars
"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
public void CustomTeamGeneration(GameStateChangeEvent event)
{
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;
PlayerTeamSelection = true;
TeamMode = true;
TeamPerSpawn = true;
}
@Override
@ -262,8 +125,6 @@ public class TeamSkywars extends Skywars
}
}
Scoreboard.Draw();
}
@ -329,147 +190,6 @@ public class TeamSkywars extends Skywars
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
public String GetMode()
{

View File

@ -29,12 +29,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
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)
{
super(manager, GameType.SmashTeams,
@ -45,15 +39,18 @@ public class TeamSuperSmash extends SuperSmash
"Last team alive wins!"
});
this.PlayersPerTeam = 2;
this.FillTeamsInOrderToCount = 2;
PlayersPerTeam = 2;
FillTeamsInOrderToCount = 2;
this.SpawnNearAllies = true;
this.DamageTeamSelf = false;
SpawnNearAllies = true;
DamageTeamSelf = false;
this.TeamArmorHotbar = true;
TeamArmorHotbar = true;
this.DontAllowOverfill = true;
DontAllowOverfill = true;
TeamMode = true;
PlayerTeamSelection = true;
registerChatStats(
Kills,
@ -122,112 +119,6 @@ public class TeamSuperSmash extends SuperSmash
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
public void EndCheck()
{
@ -236,7 +127,7 @@ public class TeamSuperSmash extends SuperSmash
ArrayList<GameTeam> teamsAlive = new ArrayList<GameTeam>();
for (GameTeam team : this.GetTeamList())
for (GameTeam team : GetTeamList())
if (team.GetPlayers(true).size() > 0)
teamsAlive.add(team);
@ -290,147 +181,6 @@ public class TeamSuperSmash extends SuperSmash
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
public String GetMode()
{

View File

@ -310,7 +310,7 @@ public abstract class SurvivalGames extends Game
event.setCancelled(true);
}
private ItemStack buildCompass(int uses)
protected ItemStack buildCompass(int uses)
{
ItemBuilder item = new ItemBuilder(Material.COMPASS);
item.setTitle(C.cWhite + "Player Tracker" + buildTime());
@ -715,7 +715,7 @@ public abstract class SurvivalGames extends Game
event.blockList().clear();
}
private void fillChest(Player looter, Block block)
public void fillChest(Player looter, Block block)
{
_lootedBlocks.add(block.getLocation());
@ -787,7 +787,7 @@ public abstract class SurvivalGames extends Game
_supplyCrates.remove(block);
}
private ItemStack GetChestItem(boolean superChest)
protected ItemStack GetChestItem(boolean superChest)
{
if (superChest)
return _crateLoot.getLoot();
@ -2021,27 +2021,37 @@ public abstract class SurvivalGames extends Game
public int getSecondsSinceStart()
{
return this._secondsSinceStart;
return _secondsSinceStart;
}
public int getChestRefillTime()
{
return this._chestRefillTime;
return _chestRefillTime;
}
public int getDeathMatchTime()
{
return this._deathMatchTime;
return _deathMatchTime;
}
public boolean isDeathMatchTeleported()
{
return this._deathMatchTeleported;
return _deathMatchTeleported;
}
public int getGameEndTime()
{
return this._gameEndTime;
return _gameEndTime;
}
public ArrayList<Block> getSupplyBlocks()
{
return _supplyCrates;
}
public HashSet<Location> getLootedBlocks()
{
return _lootedBlocks;
}
}

View File

@ -31,12 +31,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
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)
{
super(manager, GameType.SurvivalGamesTeams,
@ -51,123 +45,17 @@ public class TeamSurvivalGames extends SurvivalGames
"Last team alive wins!"
});
this.PlayersPerTeam = 2;
this.FillTeamsInOrderToCount = 2;
PlayersPerTeam = 2;
FillTeamsInOrderToCount = 2;
this.SpawnNearAllies = true;
this.SpawnNearEnemies = true;
SpawnNearAllies = true;
SpawnNearEnemies = true;
this.DamageTeamSelf = false;
DamageTeamSelf = false;
this.DontAllowOverfill = 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;
DontAllowOverfill = true;
TeamMode = true;
PlayerTeamSelection = true;
}
@Override
@ -185,7 +73,7 @@ public class TeamSurvivalGames extends SurvivalGames
Scoreboard.WriteBlank();
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.Write(C.cYellow + C.Bold + "Teams");
@ -221,21 +109,21 @@ public class TeamSurvivalGames extends SurvivalGames
Scoreboard.WriteBlank();
if (this.getChestRefillTime() > 0 && this.getDeathMatchTime() > 60)
if (getChestRefillTime() > 0 && getDeathMatchTime() > 60)
{
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(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
{
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();
@ -249,7 +137,7 @@ public class TeamSurvivalGames extends SurvivalGames
ArrayList<GameTeam> teamsAlive = new ArrayList<GameTeam>();
for (GameTeam team : this.GetTeamList())
for (GameTeam team : GetTeamList())
if (team.GetPlayers(true).size() > 0)
teamsAlive.add(team);
@ -303,147 +191,6 @@ public class TeamSurvivalGames extends SurvivalGames
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
public String GetMode()
{

View File

@ -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";
}
}

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.managers;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
@ -14,6 +15,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.CombatManager.AttackReason;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameMode;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
@ -34,10 +36,12 @@ public class GameCreationManager implements Listener
private GameType _nextGame = null;
private String _lastMap = "";
private String _lastMode = "";
private ArrayList<GameType> _lastGames = new ArrayList<GameType>();
public String MapPref = null;
public String MapSource = null;
public String ModePref = null;
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(MapPref == null ? "Map Pref = null" : "Map Pref = " + MapPref);
System.out.println(ModePref == null ? "Gamemode Pref = null" : "Gamemode Pref = " + ModePref);
//Chosen Game
if (_nextGame != null)
{
@ -186,6 +192,7 @@ public class GameCreationManager implements Listener
for (int i=0 ; i<50 ; i++)
{
gameType = Manager.GetGameList().get(UtilMath.r(Manager.GetGameList().size()));
ModePref = randomGameMode(gameType);
if (!_lastGames.contains(gameType))
break;
@ -197,9 +204,36 @@ public class GameCreationManager implements Listener
_lastGames.add(0, gameType);
boolean setVars = false;
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);
}
@ -234,8 +268,117 @@ public class GameCreationManager implements Listener
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)
{
_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");
}
}
}
}
}

View File

@ -7,46 +7,6 @@ import java.util.HashMap;
import java.util.List;
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.ChatColor;
import org.bukkit.Color;
@ -77,6 +37,39 @@ import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
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 ArcadeManager Manager;
@ -994,10 +987,10 @@ public class GameLobbyManager implements Listener
{
WriteGameLine(game.GetType().GetLobbyName(), 0, 159, (byte)14);
if (game.GetMode() == null)
if (Manager.GetGame().GetMode() == null)
WriteGameLine(" ", 1, 159, (byte)1);
else
WriteGameLine(game.GetMode(), 1, 159, (byte)1);
WriteGameLine(Manager.GetGame().GetMode(), 1, 159, (byte)1);
DisplayWaiting();
CreateKits(game);