diff --git a/src/main/java/org/mcsg/survivalgames/CommandHandler.java b/src/main/java/org/mcsg/survivalgames/CommandHandler.java index 74244b6..307de4f 100644 --- a/src/main/java/org/mcsg/survivalgames/CommandHandler.java +++ b/src/main/java/org/mcsg/survivalgames/CommandHandler.java @@ -32,24 +32,22 @@ import org.mcsg.survivalgames.commands.Spectate; import org.mcsg.survivalgames.commands.SubCommand; import org.mcsg.survivalgames.commands.Teleport; -import org.mcsg.survivalgames.commands.Test; import org.mcsg.survivalgames.commands.Vote; - - public class CommandHandler implements CommandExecutor { - private Plugin plugin; - private HashMap < String, SubCommand > commands; - private HashMap < String, Integer > helpinfo; - private MessageManager msgmgr = MessageManager.getInstance(); + private final Plugin plugin; + private final HashMap commands; + private final HashMap helpinfo; + private final MessageManager msgmgr = MessageManager.getInstance(); + public CommandHandler(Plugin plugin) { this.plugin = plugin; - commands = new HashMap < String, SubCommand > (); - helpinfo = new HashMap < String, Integer > (); + commands = new HashMap(); + helpinfo = new HashMap(); loadCommands(); loadHelpInfo(); } - + private void loadCommands() { commands.put("createarena", new CreateArena()); commands.put("join", new Join()); @@ -72,14 +70,16 @@ private void loadCommands() { commands.put("list", new ListPlayers()); commands.put("tp", new Teleport()); commands.put("reload", new Reload()); - commands.put("test", new Test()); - + // commands.put("test", new Test()); + // commands.put("sponsor", new Sponsor()); } - + private void loadHelpInfo() { - //you can do this by iterating thru the hashmap from a certian index btw instead of using a new hashmap, - //plus, instead of doing three differnet ifs, just iterate thru and check if the value == the page + // you can do this by iterating thru the hashmap from a certian index + // btw instead of using a new hashmap, + // plus, instead of doing three differnet ifs, just iterate thru and + // check if the value == the page helpinfo.put("createarena", 3); helpinfo.put("join", 1); helpinfo.put("addwall", 3); @@ -99,10 +99,10 @@ private void loadHelpInfo() { helpinfo.put("leavequeue", 1); helpinfo.put("list", 1); commands.put("reload", new Reload()); - - //helpinfo.put("sponsor", 1); + + // helpinfo.put("sponsor", 1); } - + @Override public boolean onCommand(CommandSender sender, Command cmd1, String commandLabel, String[] args) { PluginDescriptionFile pdfFile = plugin.getDescription(); @@ -110,21 +110,21 @@ public boolean onCommand(CommandSender sender, Command cmd1, String commandLabel msgmgr.logMessage(PrefixType.WARNING, "Only in-game players can use SurvivalGames commands! "); return true; } - + Player player = (Player) sender; - + if (SurvivalGames.config_todate == false) { msgmgr.sendMessage(PrefixType.WARNING, "The config file is out of date. Please tell an administrator to reset the config.", player); return true; } - + if (SurvivalGames.dbcon == false) { msgmgr.sendMessage(PrefixType.WARNING, "Could not connect to server. Plugin disabled.", player); return true; } - + if (cmd1.getName().equalsIgnoreCase("survivalgames")) { - if (args == null || args.length < 1) { + if ((args == null) || (args.length < 1)) { msgmgr.sendMessage(PrefixType.INFO, "Version " + pdfFile.getVersion() + " by Double0negative", player); msgmgr.sendMessage(PrefixType.INFO, "Type /sg help for command information", player); return true; @@ -132,8 +132,7 @@ public boolean onCommand(CommandSender sender, Command cmd1, String commandLabel if (args[0].equalsIgnoreCase("help")) { if (args.length == 1) { help(player, 1); - } - else { + } else { if (args[1].toLowerCase().startsWith("player")) { help(player, 1); return true; @@ -145,18 +144,17 @@ public boolean onCommand(CommandSender sender, Command cmd1, String commandLabel if (args[1].toLowerCase().startsWith("admin")) { help(player, 3); return true; - } - else { + } else { msgmgr.sendMessage(PrefixType.WARNING, args[1] + " is not a valid page! Valid pages are Player, Staff, and Admin.", player); } } return true; } String sub = args[0]; - Vector < String > l = new Vector < String > (); + Vector l = new Vector(); l.addAll(Arrays.asList(args)); l.remove(0); - args = (String[]) l.toArray(new String[0]); + args = l.toArray(new String[0]); if (!commands.containsKey(sub)) { msgmgr.sendMessage(PrefixType.WARNING, "Command doesn't exist.", player); msgmgr.sendMessage(PrefixType.INFO, "Type /sg help for command information", player); @@ -166,15 +164,15 @@ public boolean onCommand(CommandSender sender, Command cmd1, String commandLabel commands.get(sub).onCommand(player, args); } catch (Exception e) { e.printStackTrace(); - msgmgr.sendFMessage(PrefixType.ERROR, "error.command", player, "command-["+sub+"] "+Arrays.toString(args)); + msgmgr.sendFMessage(PrefixType.ERROR, "error.command", player, "command-[" + sub + "] " + Arrays.toString(args)); msgmgr.sendMessage(PrefixType.INFO, "Type /sg help for command information", player); } return true; } return false; } - - public void help (Player p, int page) { + + public void help(Player p, int page) { if (page == 1) { p.sendMessage(ChatColor.BLUE + "------------ " + msgmgr.pre + ChatColor.DARK_AQUA + " Player Commands" + ChatColor.BLUE + " ------------"); } @@ -184,25 +182,22 @@ public void help (Player p, int page) { if (page == 3) { p.sendMessage(ChatColor.BLUE + "------------ " + msgmgr.pre + ChatColor.DARK_AQUA + " Admin Commands" + ChatColor.BLUE + " ------------"); } - + for (String command : commands.keySet()) { - try{ + try { if (helpinfo.get(command) == page) { - + msgmgr.sendMessage(PrefixType.INFO, commands.get(command).help(p), p); } - }catch(Exception e){} + } catch (Exception e) { + } } - /*for (SubCommand v : commands.values()) { - if (v.permission() != null) { - if (p.hasPermission(v.permission())) { - msgmgr.sendMessage(PrefixType.INFO1, v.help(p), p); - } else { - msgmgr.sendMessage(PrefixType.WARNING, v.help(p), p); - } - } else { - msgmgr.sendMessage(PrefixType.INFO, v.help(p), p); - } - }*/ + /* + * for (SubCommand v : commands.values()) { if (v.permission() != null) + * { if (p.hasPermission(v.permission())) { + * msgmgr.sendMessage(PrefixType.INFO1, v.help(p), p); } else { + * msgmgr.sendMessage(PrefixType.WARNING, v.help(p), p); } } else { + * msgmgr.sendMessage(PrefixType.INFO, v.help(p), p); } } + */ } } \ No newline at end of file diff --git a/src/main/java/org/mcsg/survivalgames/Game.java b/src/main/java/org/mcsg/survivalgames/Game.java index cb82760..06d8e3a 100644 --- a/src/main/java/org/mcsg/survivalgames/Game.java +++ b/src/main/java/org/mcsg/survivalgames/Game.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -12,7 +13,6 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.Plugin; import org.mcsg.survivalgames.MessageManager.PrefixType; import org.mcsg.survivalgames.api.PlayerJoinArenaEvent; import org.mcsg.survivalgames.api.PlayerKilledEvent; @@ -23,68 +23,62 @@ import org.mcsg.survivalgames.util.ItemReader; import org.mcsg.survivalgames.util.Kit; -import com.sk89q.wepif.PluginPermissionsResolver; - - - //Data container for a game public class Game { - + public static enum GameMode { - DISABLED, LOADING, INACTIVE, WAITING, - STARTING, INGAME, FINISHING, RESETING, ERROR + DISABLED, LOADING, INACTIVE, WAITING, STARTING, INGAME, FINISHING, RESETING, ERROR } - + private GameMode mode = GameMode.DISABLED; - private ArrayList < Player > activePlayers = new ArrayList < Player > (); - private ArrayList < Player > inactivePlayers = new ArrayList < Player > (); - private ArrayList < String > spectators = new ArrayList < String > (); - private ArrayList < Player > queue = new ArrayList < Player > (); - private HashMap < String, Object > flags = new HashMap < String, Object > (); - HashMap < Player, Integer > nextspec = new HashMap < Player, Integer > (); - private ArrayListtasks = new ArrayList(); - + private final ArrayList activePlayers = new ArrayList(); + private final ArrayList inactivePlayers = new ArrayList(); + private final ArrayList spectators = new ArrayList(); + private final ArrayList queue = new ArrayList(); + private HashMap flags = new HashMap(); + HashMap nextspec = new HashMap(); + private final ArrayList tasks = new ArrayList(); + private Arena arena; - private int gameID; + private final int gameID; private int gcount = 0; private FileConfiguration config; private FileConfiguration system; - private HashMap < Integer, Player > spawns = new HashMap < Integer, Player > (); - private HashMap < Player, ItemStack[][] > inv_store = new HashMap < Player, ItemStack[][] > (); + private final HashMap spawns = new HashMap(); + private final HashMap inv_store = new HashMap(); private int spawnCount = 0; private int vote = 0; private boolean disabled = false; - private int endgameTaskID = 0; + private final int endgameTaskID = 0; private boolean endgameRunning = false; private double rbpercent = 0; private String rbstatus = ""; private long startTime = 0; private boolean countdownRunning; - private StatsManager sm = StatsManager.getInstance(); - private HashMap < String, String > hookvars = new HashMap < String, String > (); - private MessageManager msgmgr = MessageManager.getInstance(); - - + private final StatsManager sm = StatsManager.getInstance(); + private final HashMap hookvars = new HashMap(); + private final MessageManager msgmgr = MessageManager.getInstance(); + public Game(int gameid) { gameID = gameid; reloadConfig(); setup(); } - - public void reloadConfig(){ + + public void reloadConfig() { config = SettingsManager.getInstance().getConfig(); system = SettingsManager.getInstance().getSystemConfig(); } - - public void $(String msg){ + + public void $(String msg) { SurvivalGames.$(msg); } - - public void debug(String msg){ + + public void debug(String msg) { SurvivalGames.debug(msg); } - + public void setup() { mode = GameMode.LOADING; int x = system.getInt("sg-system.arenas." + gameID + ".x1"); @@ -99,67 +93,63 @@ public void setup() { $(max.toString()); Location min = new Location(SettingsManager.getGameWorld(gameID), Math.min(x, x1), Math.min(y, y1), Math.min(z, z1)); $(min.toString()); - + arena = new Arena(min, max); - + loadspawns(); - + hookvars.put("arena", gameID + ""); hookvars.put("maxplayers", spawnCount + ""); hookvars.put("activeplayers", "0"); - + mode = GameMode.WAITING; } - + public void reloadFlags() { flags = SettingsManager.getInstance().getGameFlags(gameID); } - + public void saveFlags() { SettingsManager.getInstance().saveGameFlags(flags, gameID); } - + public void loadspawns() { for (int a = 1; a <= SettingsManager.getInstance().getSpawnCount(gameID); a++) { spawns.put(a, null); spawnCount = a; } } - + public void addSpawn() { spawnCount++; spawns.put(spawnCount, null); } - + public void setMode(GameMode m) { mode = m; } - + public GameMode getGameMode() { return mode; } - + public Arena getArena() { return arena; } - - + /* * * ################################################ * - * ENABLE + * ENABLE * * ################################################ - * - * */ - - + public void enable() { mode = GameMode.WAITING; - if(disabled){ - MessageManager.getInstance().broadcastFMessage(PrefixType.INFO, "broadcast.gameenabled", "arena-"+gameID); + if (disabled) { + MessageManager.getInstance().broadcastFMessage(PrefixType.INFO, "broadcast.gameenabled", "arena-" + gameID); } disabled = false; int b = (SettingsManager.getInstance().getSpawnCount(gameID) > queue.size()) ? queue.size() : SettingsManager.getInstance().getSpawnCount(gameID); @@ -171,188 +161,190 @@ public void enable() { msgmgr.sendMessage(PrefixType.INFO, "You are now #" + c + " in line for arena " + gameID, p); c++; } - + LobbyManager.getInstance().updateWall(gameID); - - MessageManager.getInstance().broadcastFMessage(PrefixType.INFO, "broadcast.gamewaiting", "arena-"+gameID); - + + MessageManager.getInstance().broadcastFMessage(PrefixType.INFO, "broadcast.gamewaiting", "arena-" + gameID); + } - - + /* * * ################################################ * - * ADD PLAYER + * ADD PLAYER * * ################################################ - * - * */ - - + public boolean addPlayer(Player p) { - if(SettingsManager.getInstance().getLobbySpawn() == null){ + if (SettingsManager.getInstance().getLobbySpawn() == null) { msgmgr.sendFMessage(PrefixType.WARNING, "error.nolobbyspawn", p); return false; } - if(!p.hasPermission("sg.arena.join."+gameID)){ - debug("permission needed to join arena: " + "sg.arena.join."+gameID); - msgmgr.sendFMessage(PrefixType.WARNING, "game.nopermission", p, "arena-"+gameID); + if (!p.hasPermission("sg.arena.join." + gameID)) { + debug("permission needed to join arena: " + "sg.arena.join." + gameID); + msgmgr.sendFMessage(PrefixType.WARNING, "game.nopermission", p, "arena-" + gameID); return false; } - HookManager.getInstance().runHook("GAME_PRE_ADDPLAYER", "arena-"+gameID, "player-"+p.getName(), "maxplayers-"+spawns.size(), "players-"+activePlayers.size()); - + HookManager.getInstance().runHook("GAME_PRE_ADDPLAYER", "arena-" + gameID, "player-" + p.getName(), "maxplayers-" + spawns.size(), "players-" + activePlayers.size()); + GameManager.getInstance().removeFromOtherQueues(p, gameID); - + if (GameManager.getInstance().getPlayerGameId(p) != -1) { if (GameManager.getInstance().isPlayerActive(p)) { msgmgr.sendMessage(PrefixType.ERROR, "Cannot join multiple games!", p); return false; } } - if(p.isInsideVehicle()){ + if (p.isInsideVehicle()) { p.leaveVehicle(); } - if (spectators.contains(p)) removeSpectator(p); - if (mode == GameMode.WAITING || mode == GameMode.STARTING) { + if (spectators.contains(p)) { + removeSpectator(p); + } + if ((mode == GameMode.WAITING) || (mode == GameMode.STARTING)) { if (activePlayers.size() < SettingsManager.getInstance().getSpawnCount(gameID)) { msgmgr.sendMessage(PrefixType.INFO, "Joining Arena " + gameID, p); PlayerJoinArenaEvent joinarena = new PlayerJoinArenaEvent(p, GameManager.getInstance().getGame(gameID)); Bukkit.getServer().getPluginManager().callEvent(joinarena); - if(joinarena.isCancelled()) return false; + if (joinarena.isCancelled()) { + return false; + } boolean placed = false; int spawnCount = SettingsManager.getInstance().getSpawnCount(gameID); - + for (int a = 1; a <= spawnCount; a++) { if (spawns.get(a) == null) { placed = true; spawns.put(a, p); p.setGameMode(org.bukkit.GameMode.SURVIVAL); - + p.teleport(SettingsManager.getInstance().getLobbySpawn()); - saveInv(p);clearInv(p); + saveInv(p); + clearInv(p); p.teleport(SettingsManager.getInstance().getSpawnPoint(gameID, a)); - - p.setHealth(p.getMaxHealth());p.setFoodLevel(20);clearInv(p); - - activePlayers.add(p);sm.addPlayer(p, gameID); - - hookvars.put("activeplayers", activePlayers.size()+""); + + p.setHealth(p.getMaxHealth()); + p.setFoodLevel(20); + clearInv(p); + + activePlayers.add(p); + sm.addPlayer(p, gameID); + + hookvars.put("activeplayers", activePlayers.size() + ""); LobbyManager.getInstance().updateWall(gameID); showMenu(p); - HookManager.getInstance().runHook("GAME_POST_ADDPLAYER", "activePlayers-"+activePlayers.size()); - - if(spawnCount == activePlayers.size()){ + HookManager.getInstance().runHook("GAME_POST_ADDPLAYER", "activePlayers-" + activePlayers.size()); + + if (spawnCount == activePlayers.size()) { countdown(5); } break; } } if (!placed) { - msgmgr.sendFMessage(PrefixType.ERROR,"error.gamefull", p,"arena-"+gameID); + msgmgr.sendFMessage(PrefixType.ERROR, "error.gamefull", p, "arena-" + gameID); return false; } - + } else if (SettingsManager.getInstance().getSpawnCount(gameID) == 0) { msgmgr.sendMessage(PrefixType.WARNING, "No spawns set for Arena " + gameID + "!", p); return false; } else { - msgmgr.sendFMessage(PrefixType.WARNING, "error.gamefull", p, "arena-"+gameID); + msgmgr.sendFMessage(PrefixType.WARNING, "error.gamefull", p, "arena-" + gameID); return false; } - msgFall(PrefixType.INFO, "game.playerjoingame", "player-"+p.getName(), "activeplayers-"+ getActivePlayers(), "maxplayers-"+ SettingsManager.getInstance().getSpawnCount(gameID)); - if (activePlayers.size() >= config.getInt("auto-start-players") && !countdownRunning) countdown(config.getInt("auto-start-time")); + msgFall(PrefixType.INFO, "game.playerjoingame", "player-" + p.getName(), "activeplayers-" + getActivePlayers(), "maxplayers-" + SettingsManager.getInstance().getSpawnCount(gameID)); + if ((activePlayers.size() >= config.getInt("auto-start-players")) && !countdownRunning) { + countdown(config.getInt("auto-start-time")); + } return true; } else { if (config.getBoolean("enable-player-queue")) { if (!queue.contains(p)) { queue.add(p); - msgmgr.sendFMessage(PrefixType.INFO, "game.playerjoinqueue", p, "queuesize-"+queue.size()); + msgmgr.sendFMessage(PrefixType.INFO, "game.playerjoinqueue", p, "queuesize-" + queue.size()); } int a = 1; - for (Player qp: queue) { + for (Player qp : queue) { if (qp == p) { - msgmgr.sendFMessage(PrefixType.INFO, "game.playercheckqueue", p,"queuepos-"+a); + msgmgr.sendFMessage(PrefixType.INFO, "game.playercheckqueue", p, "queuepos-" + a); break; } a++; } } } - if (mode == GameMode.INGAME) msgmgr.sendFMessage(PrefixType.WARNING, "error.alreadyingame", p); - else if (mode == GameMode.DISABLED) msgmgr.sendFMessage(PrefixType.WARNING, "error.gamedisabled", p, "arena-"+gameID); - else if (mode == GameMode.RESETING) msgmgr.sendFMessage(PrefixType.WARNING, "error.gamereseting", p); - else msgmgr.sendMessage(PrefixType.INFO, "Cannot join game!", p); + if (mode == GameMode.INGAME) { + msgmgr.sendFMessage(PrefixType.WARNING, "error.alreadyingame", p); + } else if (mode == GameMode.DISABLED) { + msgmgr.sendFMessage(PrefixType.WARNING, "error.gamedisabled", p, "arena-" + gameID); + } else if (mode == GameMode.RESETING) { + msgmgr.sendFMessage(PrefixType.WARNING, "error.gamereseting", p); + } else { + msgmgr.sendMessage(PrefixType.INFO, "Cannot join game!", p); + } LobbyManager.getInstance().updateWall(gameID); return false; } - - - public void showMenu(Player p){ + + public void showMenu(Player p) { GameManager.getInstance().openKitMenu(p); - Inventory i = Bukkit.getServer().createInventory(p, 90, ChatColor.RED+""+ChatColor.BOLD+"Kit Selection"); - + Inventory i = Bukkit.getServer().createInventory(p, 90, ChatColor.RED + "" + ChatColor.BOLD + "Kit Selection"); + int a = 0; int b = 0; - - - ArrayListkits = GameManager.getInstance().getKits(p); - SurvivalGames.debug(kits+""); - if(kits == null || kits.size() == 0 || !SettingsManager.getInstance().getKits().getBoolean("enabled")){ + + ArrayList kits = GameManager.getInstance().getKits(p); + SurvivalGames.debug(kits + ""); + if ((kits == null) || (kits.size() == 0) || !SettingsManager.getInstance().getKits().getBoolean("enabled")) { GameManager.getInstance().leaveKitMenu(p); return; } - - for(Kit k: kits){ + + for (Kit k : kits) { ItemStack i1 = k.getIcon(); ItemMeta im = i1.getItemMeta(); - - debug(k.getName()+" "+i1+" "+im); - - im.setDisplayName(ChatColor.GOLD+""+ChatColor.BOLD+k.getName()); + + debug(k.getName() + " " + i1 + " " + im); + + im.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + k.getName()); i1.setItemMeta(im); i.setItem((9 * a) + b, i1); a = 2; - - for(ItemStack s2:k.getContents()){ - if(s2 != null){ + + for (ItemStack s2 : k.getContents()) { + if (s2 != null) { i.setItem((9 * a) + b, s2); a++; } } - + a = 0; b++; } p.openInventory(i); debug("Showing menu"); } - - - - + public void removeFromQueue(Player p) { queue.remove(p); } - + /* * * ################################################ * - * VOTE + * VOTE * * ################################################ - * - * */ - - - ArrayList < Player > voted = new ArrayList < Player > (); - + + ArrayList voted = new ArrayList(); + public void vote(Player pl) { - - + if (GameMode.STARTING == mode) { msgmgr.sendMessage(PrefixType.WARNING, "Game already starting!", pl); return; @@ -367,115 +359,119 @@ public void vote(Player pl) { } vote++; voted.add(pl); - msgmgr.sendFMessage(PrefixType.INFO, "game.playervote", pl, "player-"+pl.getName()); - HookManager.getInstance().runHook("PLAYER_VOTE", "player-"+pl.getName()); - /*for(Player p: activePlayers){ - p.sendMessage(ChatColor.AQUA+pl.getName()+" Voted to start the game! "+ Math.round((vote +0.0) / ((getActivePlayers() +0.0)*100)) +"/"+((c.getInt("auto-start-vote")+0.0))+"%"); - }*/ - // Bukkit.getServer().broadcastPrefixType((vote +0.0) / (getActivePlayers() +0.0) +"% voted, needs "+(c.getInt("auto-start-vote")+0.0)/100); - if ((((vote + 0.0) / (getActivePlayers() +0.0))>=(config.getInt("auto-start-vote")+0.0)/100) && getActivePlayers() > 1) { + msgmgr.sendFMessage(PrefixType.INFO, "game.playervote", pl, "player-" + pl.getName()); + HookManager.getInstance().runHook("PLAYER_VOTE", "player-" + pl.getName()); + /* + * for(Player p: activePlayers){ + * p.sendMessage(ChatColor.AQUA+pl.getName( + * )+" Voted to start the game! "+ Math.round((vote +0.0) / + * ((getActivePlayers() +0.0)*100)) + * +"/"+((c.getInt("auto-start-vote")+0.0))+"%"); } + */ + // Bukkit.getServer().broadcastPrefixType((vote +0.0) / + // (getActivePlayers() +0.0) + // +"% voted, needs "+(c.getInt("auto-start-vote")+0.0)/100); + if ((((vote + 0.0) / (getActivePlayers() + 0.0)) >= ((config.getInt("auto-start-vote") + 0.0) / 100)) && (getActivePlayers() > 1)) { countdown(config.getInt("auto-start-time")); - for (Player p: activePlayers) { - //p.sendMessage(ChatColor.LIGHT_PURPLE + "Game Starting in " + c.getInt("auto-start-time")); + for (Player p : activePlayers) { + // p.sendMessage(ChatColor.LIGHT_PURPLE + "Game Starting in " + + // c.getInt("auto-start-time")); msgmgr.sendMessage(PrefixType.INFO, "Game starting in " + config.getInt("auto-start-time") + "!", p); } } } - + /* * * ################################################ * - * START GAME + * START GAME * * ################################################ - * - * */ public void startGame() { if (mode == GameMode.INGAME) { return; } - + if (activePlayers.size() <= 0) { - for (Player pl: activePlayers) { + for (Player pl : activePlayers) { msgmgr.sendMessage(PrefixType.WARNING, "Not enough players!", pl); mode = GameMode.WAITING; LobbyManager.getInstance().updateWall(gameID); - + } return; } else { startTime = new Date().getTime(); - for (Player pl: activePlayers) { + for (Player pl : activePlayers) { pl.setHealth(pl.getMaxHealth()); - //clearInv(pl); + // clearInv(pl); msgmgr.sendFMessage(PrefixType.INFO, "game.goodluck", pl); } if (config.getBoolean("restock-chest")) { SettingsManager.getGameWorld(gameID).setTime(0); gcount++; - tasks.add(Bukkit.getScheduler().scheduleSyncDelayedTask(GameManager.getInstance().getPlugin(), - new NightChecker(), - 14400)); + tasks.add(Bukkit.getScheduler().scheduleSyncDelayedTask(GameManager.getInstance().getPlugin(), new NightChecker(), 14400)); } if (config.getInt("grace-period") != 0) { - for (Player play: activePlayers) { + for (Player play : activePlayers) { msgmgr.sendMessage(PrefixType.INFO, "You have a " + config.getInt("grace-period") + " second grace period!", play); } Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GameManager.getInstance().getPlugin(), new Runnable() { + @Override public void run() { - for (Player play: activePlayers) { + for (Player play : activePlayers) { msgmgr.sendMessage(PrefixType.INFO, "Grace period has ended!", play); } } }, config.getInt("grace-period") * 20); } - if(config.getBoolean("deathmatch.enabled")){ - tasks.add(Bukkit.getScheduler().scheduleSyncDelayedTask(GameManager.getInstance().getPlugin(), - new DeathMatch(), config.getInt("deathmatch.time") * 20 * 60)); + if (config.getBoolean("deathmatch.enabled")) { + tasks.add(Bukkit.getScheduler().scheduleSyncDelayedTask(GameManager.getInstance().getPlugin(), new DeathMatch(), config.getInt("deathmatch.time") * 20 * 60)); } } - + mode = GameMode.INGAME; LobbyManager.getInstance().updateWall(gameID); - MessageManager.getInstance().broadcastFMessage(PrefixType.INFO, "broadcast.gamestarted", "arena-"+gameID); - + MessageManager.getInstance().broadcastFMessage(PrefixType.INFO, "broadcast.gamestarted", "arena-" + gameID); + } + /* * * ################################################ * - * COUNTDOWN + * COUNTDOWN * * ################################################ - * - * */ public int getCountdownTime() { return count; } - + int count = 20; int tid = 0; + public void countdown(int time) { - //Bukkit.broadcastMessage(""+time); - MessageManager.getInstance().broadcastFMessage(PrefixType.INFO, "broadcast.gamestarting", "arena-"+gameID, "t-"+time); + // Bukkit.broadcastMessage(""+time); + MessageManager.getInstance().broadcastFMessage(PrefixType.INFO, "broadcast.gamestarting", "arena-" + gameID, "t-" + time); countdownRunning = true; count = time; Bukkit.getScheduler().cancelTask(tid); - - if (mode == GameMode.WAITING || mode == GameMode.STARTING) { - mode = GameMode.STARTING; - tid = Bukkit.getScheduler().scheduleSyncRepeatingTask((Plugin) GameManager.getInstance().getPlugin(), new Runnable() { + + if ((mode == GameMode.WAITING) || (mode == GameMode.STARTING)) { + mode = GameMode.STARTING; + tid = Bukkit.getScheduler().scheduleSyncRepeatingTask(GameManager.getInstance().getPlugin(), new Runnable() { + @Override public void run() { if (count > 0) { - if (count % 10 == 0) { - msgFall(PrefixType.INFO, "game.countdown","t-"+count); + if ((count % 10) == 0) { + msgFall(PrefixType.INFO, "game.countdown", "t-" + count); } if (count < 6) { - msgFall(PrefixType.INFO, "game.countdown","t-"+count); - + msgFall(PrefixType.INFO, "game.countdown", "t-" + count); + } count--; LobbyManager.getInstance().updateWall(gameID); @@ -486,323 +482,306 @@ public void run() { } } }, 0, 20); - + } } - + /* * * ################################################ * - * REMOVE PLAYER + * REMOVE PLAYER * * ################################################ - * - * */ - + public void removePlayer(Player p, boolean b) { p.teleport(SettingsManager.getInstance().getLobbySpawn()); - ///$("Teleporting to lobby"); + // /$("Teleporting to lobby"); if (mode == GameMode.INGAME) { killPlayer(p, b); } else { sm.removePlayer(p, gameID); - // if (!b) p.teleport(SettingsManager.getInstance().getLobbySpawn()); + // if (!b) + // p.teleport(SettingsManager.getInstance().getLobbySpawn()); restoreInv(p); activePlayers.remove(p); inactivePlayers.remove(p); for (Object in : spawns.keySet().toArray()) { - if (spawns.get(in) == p) spawns.remove(in); + if (spawns.get(in) == p) { + spawns.remove(in); + } } LobbyManager.getInstance().clearSigns(gameID); } - - HookManager.getInstance().runHook("PLAYER_REMOVED", "player-"+p.getName()); - - PlayerLeaveArenaEvent pl = new PlayerLeaveArenaEvent(p, this, b); - + + HookManager.getInstance().runHook("PLAYER_REMOVED", "player-" + p.getName()); + + new PlayerLeaveArenaEvent(p, this, b); + LobbyManager.getInstance().updateWall(gameID); } - + public void playerLeave(Player p) { - + } - + /* * * ################################################ * - * KILL PLAYER + * KILL PLAYER * * ################################################ - * - * */ public void killPlayer(Player p, boolean left) { - try{ + try { clearInv(p); if (!left) { p.teleport(SettingsManager.getInstance().getLobbySpawn()); } sm.playerDied(p, activePlayers.size(), gameID, new Date().getTime() - startTime); - - if (!activePlayers.contains(p)) return; - else restoreInv(p); - + + if (!activePlayers.contains(p)) { + return; + } else { + restoreInv(p); + } + activePlayers.remove(p); inactivePlayers.add(p); PlayerKilledEvent pk = null; if (left) { - msgFall(PrefixType.INFO, "game.playerleavegame","player-"+p.getName() ); + msgFall(PrefixType.INFO, "game.playerleavegame", "player-" + p.getName()); } else { - if (mode != GameMode.WAITING && p.getLastDamageCause() != null && p.getLastDamageCause().getCause() != null) { + if ((mode != GameMode.WAITING) && (p.getLastDamageCause() != null) && (p.getLastDamageCause().getCause() != null)) { switch (p.getLastDamageCause().getCause()) { - case ENTITY_ATTACK: - if(p.getLastDamageCause().getEntityType() == EntityType.PLAYER){ - Player killer = p.getKiller(); - msgFall(PrefixType.INFO, "death."+p.getLastDamageCause().getEntityType(), - "player-"+(SurvivalGames.auth.contains(p.getName()) ? ChatColor.DARK_RED + "" + ChatColor.BOLD : "") + p.getName(), - "killer-"+((killer != null)?(SurvivalGames.auth.contains(killer.getName()) ? ChatColor.DARK_RED + "" + ChatColor.BOLD : "") - + killer.getName():"Unknown"), - "item-"+((killer!=null)?ItemReader.getFriendlyItemName(killer.getItemInHand().getType()) : "Unknown Item")); - if(killer != null && p != null) - sm.addKill(killer, p, gameID); - pk = new PlayerKilledEvent(p, this, killer, p.getLastDamageCause().getCause()); - } - else{ - msgFall(PrefixType.INFO, "death."+p.getLastDamageCause().getEntityType(), "player-" - +(SurvivalGames.auth.contains(p.getName()) ? ChatColor.DARK_RED + "" + ChatColor.BOLD : "") - + p.getName(), "killer-"+p.getLastDamageCause().getEntityType()); + case ENTITY_ATTACK: + if (p.getLastDamageCause().getEntityType() == EntityType.PLAYER) { + Player killer = p.getKiller(); + msgFall(PrefixType.INFO, "death." + p.getLastDamageCause().getEntityType(), "player-" + (SurvivalGames.auth.contains(p.getName()) ? ChatColor.DARK_RED + "" + ChatColor.BOLD : "") + p.getName(), "killer-" + ((killer != null) ? (SurvivalGames.auth.contains(killer.getName()) ? ChatColor.DARK_RED + "" + ChatColor.BOLD : "") + killer.getName() : "Unknown"), "item-" + ((killer != null) ? ItemReader.getFriendlyItemName(killer.getItemInHand().getType()) : "Unknown Item")); + if ((killer != null) && (p != null)) { + sm.addKill(killer, p, gameID); + } + pk = new PlayerKilledEvent(p, this, killer, p.getLastDamageCause().getCause()); + } else { + msgFall(PrefixType.INFO, "death." + p.getLastDamageCause().getEntityType(), "player-" + (SurvivalGames.auth.contains(p.getName()) ? ChatColor.DARK_RED + "" + ChatColor.BOLD : "") + p.getName(), "killer-" + p.getLastDamageCause().getEntityType()); + pk = new PlayerKilledEvent(p, this, null, p.getLastDamageCause().getCause()); + + } + break; + default: + msgFall(PrefixType.INFO, "death." + p.getLastDamageCause().getCause().name(), "player-" + (SurvivalGames.auth.contains(p.getName()) ? ChatColor.DARK_RED + "" + ChatColor.BOLD : "") + p.getName(), "killer-" + p.getLastDamageCause().getCause()); pk = new PlayerKilledEvent(p, this, null, p.getLastDamageCause().getCause()); - - } - break; - default: - msgFall(PrefixType.INFO, "death."+p.getLastDamageCause().getCause().name(), - "player-"+(SurvivalGames.auth.contains(p.getName()) ? ChatColor.DARK_RED + "" + ChatColor.BOLD : "") + p.getName(), - "killer-"+p.getLastDamageCause().getCause()); - pk = new PlayerKilledEvent(p, this, null, p.getLastDamageCause().getCause()); - - break; + + break; } Bukkit.getServer().getPluginManager().callEvent(pk); - + if (getActivePlayers() > 1) { - for (Player pl: getAllPlayers()) { - msgmgr.sendMessage(PrefixType.INFO, ChatColor.DARK_AQUA + "There are " + ChatColor.YELLOW + "" - + getActivePlayers() + ChatColor.DARK_AQUA + " players remaining!", pl); + for (Player pl : getAllPlayers()) { + msgmgr.sendMessage(PrefixType.INFO, ChatColor.DARK_AQUA + "There are " + ChatColor.YELLOW + "" + getActivePlayers() + ChatColor.DARK_AQUA + " players remaining!", pl); } } } - + } - - for (Player pe: activePlayers) { + + for (Player pe : activePlayers) { Location l = pe.getLocation(); l.setY(l.getWorld().getMaxHeight()); l.getWorld().strikeLightningEffect(l); } - - if (getActivePlayers() <= config.getInt("endgame.players") && config.getBoolean("endgame.fire-lighting.enabled") && !endgameRunning) { - - tasks.add(Bukkit.getScheduler().scheduleSyncRepeatingTask(GameManager.getInstance().getPlugin(), - new EndgameManager(), - 0, - config.getInt("endgame.fire-lighting.interval") * 20)); + + if ((getActivePlayers() <= config.getInt("endgame.players")) && config.getBoolean("endgame.fire-lighting.enabled") && !endgameRunning) { + + tasks.add(Bukkit.getScheduler().scheduleSyncRepeatingTask(GameManager.getInstance().getPlugin(), new EndgameManager(), 0, config.getInt("endgame.fire-lighting.interval") * 20)); } - - if (activePlayers.size() < 2 && mode != GameMode.WAITING) { + + if ((activePlayers.size() < 2) && (mode != GameMode.WAITING)) { playerWin(p); endGame(); } LobbyManager.getInstance().updateWall(gameID); - }catch (Exception e){ + } catch (Exception e) { SurvivalGames.$("???????????????????????"); e.printStackTrace(); - SurvivalGames.$("ID"+gameID); - SurvivalGames.$(left+""); - SurvivalGames.$(activePlayers.size()+""); + SurvivalGames.$("ID" + gameID); + SurvivalGames.$(left + ""); + SurvivalGames.$(activePlayers.size() + ""); SurvivalGames.$(activePlayers.toString()); SurvivalGames.$(p.getName()); SurvivalGames.$(p.getLastDamageCause().getCause().name()); } } - + /* * * ################################################ * - * PLAYER WIN + * PLAYER WIN * * ################################################ - * - * */ public void playerWin(Player p) { - if (GameMode.DISABLED == mode) return; + if (GameMode.DISABLED == mode) { + return; + } Player win = activePlayers.get(0); // clearInv(p); win.teleport(SettingsManager.getInstance().getLobbySpawn()); restoreInv(win); - msgmgr.broadcastFMessage(PrefixType.INFO, "game.playerwin","arena-"+gameID, "victim-"+p.getName(), "player-"+win.getName()); - LobbyManager.getInstance().display(new String[] { - win.getName(), "", "Won the ", "Survival Games!" - }, gameID); - + msgmgr.broadcastFMessage(PrefixType.INFO, "game.playerwin", "arena-" + gameID, "victim-" + p.getName(), "player-" + win.getName()); + LobbyManager.getInstance().display(new String[] { win.getName(), "", "Won the ", "Survival Games!" }, gameID); + mode = GameMode.FINISHING; - + clearSpecs(); win.setHealth(p.getMaxHealth()); win.setFoodLevel(20); win.setFireTicks(0); win.setFallDistance(0); - + sm.playerWin(win, gameID, new Date().getTime() - startTime); sm.saveGame(gameID, win, getActivePlayers() + getInactivePlayers(), new Date().getTime() - startTime); - + activePlayers.clear(); inactivePlayers.clear(); spawns.clear(); - + loadspawns(); LobbyManager.getInstance().updateWall(gameID); - MessageManager.getInstance().broadcastFMessage(PrefixType.INFO, "broadcast.gameend", "arena-"+gameID); - + MessageManager.getInstance().broadcastFMessage(PrefixType.INFO, "broadcast.gameend", "arena-" + gameID); + } - + public void endGame() { mode = GameMode.WAITING; resetArena(); LobbyManager.getInstance().clearSigns(gameID); LobbyManager.getInstance().updateWall(gameID); - + } + /* * * ################################################ * - * DISABLE + * DISABLE * * ################################################ - * - * */ public void disable() { disabled = true; spawns.clear(); - + for (int a = 0; a < activePlayers.size(); a = 0) { try { - + Player p = activePlayers.get(a); msgmgr.sendMessage(PrefixType.WARNING, "Game disabled!", p); removePlayer(p, false); - } catch (Exception e) {} - + } catch (Exception e) { + } + } - + for (int a = 0; a < inactivePlayers.size(); a = 0) { try { - + Player p = inactivePlayers.remove(a); msgmgr.sendMessage(PrefixType.WARNING, "Game disabled!", p); - } catch (Exception e) {} - + } catch (Exception e) { + } + } - + clearSpecs(); queue.clear(); - + endGame(); LobbyManager.getInstance().updateWall(gameID); - MessageManager.getInstance().broadcastFMessage(PrefixType.INFO, "broadcast.gamedisabled", "arena-"+gameID); - + MessageManager.getInstance().broadcastFMessage(PrefixType.INFO, "broadcast.gamedisabled", "arena-" + gameID); + } + /* * * ################################################ * - * RESET + * RESET * * ################################################ - * - * */ public void resetArena() { - - for(Integer i: tasks){ + + for (Integer i : tasks) { Bukkit.getScheduler().cancelTask(i); } - + tasks.clear(); vote = 0; voted.clear(); - + mode = GameMode.RESETING; endgameRunning = false; - + Bukkit.getScheduler().cancelTask(endgameTaskID); GameManager.getInstance().gameEndCallBack(gameID); QueueManager.getInstance().rollback(gameID, false); LobbyManager.getInstance().updateWall(gameID); - + } - + public void resetCallback() { - if (!disabled){ + if (!disabled) { enable(); + } else { + mode = GameMode.DISABLED; } - else mode = GameMode.DISABLED; LobbyManager.getInstance().updateWall(gameID); } - + public void saveInv(Player p) { ItemStack[][] store = new ItemStack[2][1]; - + store[0] = p.getInventory().getContents(); store[1] = p.getInventory().getArmorContents(); - + inv_store.put(p, store); - + } - + public void restoreInvOffline(String p) { restoreInv(Bukkit.getPlayer(p)); } - - + /* * * ################################################ * - * SPECTATOR + * SPECTATOR * * ################################################ - * - * */ - - - - + public void addSpectator(Player p) { if (mode != GameMode.INGAME) { msgmgr.sendMessage(PrefixType.WARNING, "You can only spectate running games!", p); return; } - + saveInv(p); clearInv(p); p.teleport(SettingsManager.getInstance().getSpawnPoint(gameID, 1).add(0, 10, 0)); - - HookManager.getInstance().runHook("PLAYER_SPECTATE", "player-"+p.getName()); - - for (Player pl: Bukkit.getOnlinePlayers()) { + + HookManager.getInstance().runHook("PLAYER_SPECTATE", "player-" + p.getName()); + + for (Player pl : Bukkit.getOnlinePlayers()) { pl.hidePlayer(p); } - + p.setAllowFlight(true); p.setFlying(true); spectators.add(p.getName()); @@ -810,14 +789,14 @@ public void addSpectator(Player p) { msgmgr.sendMessage(PrefixType.INFO, "Right click while holding shift to teleport to the next ingame player, left click to go back.", p); nextspec.put(p, 0); } - + public void removeSpectator(Player p) { - ArrayList < Player > players = new ArrayList < Player > (); + ArrayList players = new ArrayList(); players.addAll(activePlayers); players.addAll(inactivePlayers); - - if(p.isOnline()){ - for (Player pl: Bukkit.getOnlinePlayers()) { + + if (p.isOnline()) { + for (Player pl : Bukkit.getOnlinePlayers()) { pl.showPlayer(p); } } @@ -830,26 +809,35 @@ public void removeSpectator(Player p) { p.setSaturation(20); p.teleport(SettingsManager.getInstance().getLobbySpawn()); // Bukkit.getServer().broadcastPrefixType("Removing Spec "+p.getName()+" "+spectators.size()+" left"); - spectators.remove(p.getName()); + + // We don't want to call this anymore (see clearSpecs() below + // spectators.remove(p.getName()); + // Bukkit.getServer().broadcastPrefixType("Removed"); - + nextspec.remove(p); } - + public void clearSpecs() { - - for (int a = 0; a < spectators.size(); a = 0) { - removeSpectator(Bukkit.getPlayerExact(spectators.get(0))); + + // This is better + for (String name : spectators) { + removeSpectator(Bukkit.getPlayerExact(name)); } + + /* + * What is this??? for (int a = 0; a < spectators.size(); a = 0) { + * removeSpectator(Bukkit.getPlayerExact(spectators.get(0))); } + */ + spectators.clear(); nextspec.clear(); } - - - public HashMap < Player, Integer > getNextSpec() { + + public HashMap getNextSpec() { return nextspec; } - + @SuppressWarnings("deprecation") public void restoreInv(Player p) { try { @@ -858,10 +846,14 @@ public void restoreInv(Player p) { p.getInventory().setArmorContents(inv_store.get(p)[1]); inv_store.remove(p); p.updateInventory(); - } catch (Exception e) { /*p.sendMessage(ChatColor.RED+"Inentory failed to restore or nothing was in it.");*/ + } catch (Exception e) { /* + * p.sendMessage(ChatColor.RED+ + * "Inventory failed to restore or nothing was in it." + * ); + */ } } - + @SuppressWarnings("deprecation") public void clearInv(Player p) { ItemStack[] inv = p.getInventory().getContents(); @@ -875,172 +867,165 @@ public void clearInv(Player p) { } p.getInventory().setArmorContents(inv); p.updateInventory(); - + } - - - + class NightChecker implements Runnable { boolean reset = false; int tgc = gcount; + + @Override public void run() { if (SettingsManager.getGameWorld(gameID).getTime() > 14000) { - for (Player pl: activePlayers) { + for (Player pl : activePlayers) { msgmgr.sendMessage(PrefixType.INFO, "Chests restocked!", pl); } GameManager.openedChest.get(gameID).clear(); reset = true; } - + } } - + class EndgameManager implements Runnable { @Override public void run() { - for (Player player: activePlayers.toArray(new Player[0])) { + for (Player player : activePlayers.toArray(new Player[0])) { Location l = player.getLocation(); l.add(0, 5, 0); player.getWorld().strikeLightningEffect(l); } - + } } - - - class DeathMatch implements Runnable{ - public void run(){ - for(Player p: activePlayers){ - for(int a = 0; a < spawns.size(); a++){ - if(spawns.get(a) == p){ + + class DeathMatch implements Runnable { + @Override + public void run() { + for (Player p : activePlayers) { + for (int a = 0; a < spawns.size(); a++) { + if (spawns.get(a) == p) { p.teleport(SettingsManager.getInstance().getSpawnPoint(gameID, a)); break; } } } - tasks.add(Bukkit.getScheduler().scheduleSyncDelayedTask(GameManager.getInstance().getPlugin(), new Runnable(){ - public void run(){ - for(Player p: activePlayers){ + tasks.add(Bukkit.getScheduler().scheduleSyncDelayedTask(GameManager.getInstance().getPlugin(), new Runnable() { + @Override + public void run() { + for (Player p : activePlayers) { p.getLocation().getWorld().strikeLightning(p.getLocation()); } } }, config.getInt("deathmatch.killtime") * 20 * 60)); } } - + public boolean isBlockInArena(Location v) { return arena.containsBlock(v); } - + public boolean isProtectionOn() { long t = startTime / 1000; long l = config.getLong("grace-period"); long d = new Date().getTime() / 1000; - if ((d - t) < l) return true; + if ((d - t) < l) { + return true; + } return false; } - + public int getID() { return gameID; } - + public int getActivePlayers() { return activePlayers.size(); } - + public int getInactivePlayers() { return inactivePlayers.size(); } - + public Player[][] getPlayers() { - return new Player[][] { - activePlayers.toArray(new Player[0]), inactivePlayers.toArray(new Player[0]) - }; + return new Player[][] { activePlayers.toArray(new Player[0]), inactivePlayers.toArray(new Player[0]) }; } - - public ArrayList < Player > getAllPlayers() { - ArrayList < Player > all = new ArrayList < Player > (); + + public ArrayList getAllPlayers() { + ArrayList all = new ArrayList(); all.addAll(activePlayers); all.addAll(inactivePlayers); return all; } - + public boolean isSpectator(Player p) { return spectators.contains(p.getName()); } - + public boolean isInQueue(Player p) { return queue.contains(p); } - + public boolean isPlayerActive(Player player) { return activePlayers.contains(player); } + public boolean isPlayerinactive(Player player) { return inactivePlayers.contains(player); } + public boolean hasPlayer(Player p) { return activePlayers.contains(p) || inactivePlayers.contains(p); } + public GameMode getMode() { return mode; } - + public synchronized void setRBPercent(double d) { rbpercent = d; } - + public double getRBPercent() { return rbpercent; } - + public void setRBStatus(String s) { rbstatus = s; } - + public String getRBStatus() { return rbstatus; } - + public String getName() { - return "Arena "+gameID; + return "Arena " + gameID; } - - public void msgFall(PrefixType type, String msg, String...vars){ - for(Player p: getAllPlayers()){ + + public void msgFall(PrefixType type, String msg, String... vars) { + for (Player p : getAllPlayers()) { msgmgr.sendFMessage(type, msg, p, vars); } } - - /*public void randomTrap() { + + /* + * public void randomTrap() { * - World world = SettingsManager.getGameWorld(gameID); - - double xcord; - double zcord; - double ycord = 80; - Random rand = new Random(); - xcord = rand.nextInt(1000); - zcord = rand.nextInt(1000); - Location trap = new Location(world, xcord, ycord, zcord); - boolean isAir = true; - - while(isAir == true) { - ycord--; - Byte blockData = trap.getBlock().getData(); - if(blockData != 0) { - trap.getBlock().setType(Material.AIR); - ycord--; - trap.getBlock().setType(Material.AIR); - ycord--; - trap.getBlock().setType(Material.AIR); - ycord--; - trap.getBlock().setType(Material.LAVA); - isAir = false; - } else { - isAir = true; - } - } - - }*/ + * World world = SettingsManager.getGameWorld(gameID); + * + * double xcord; double zcord; double ycord = 80; Random rand = new + * Random(); xcord = rand.nextInt(1000); zcord = rand.nextInt(1000); + * Location trap = new Location(world, xcord, ycord, zcord); boolean isAir = + * true; + * + * while(isAir == true) { ycord--; Byte blockData = + * trap.getBlock().getData(); if(blockData != 0) { + * trap.getBlock().setType(Material.AIR); ycord--; + * trap.getBlock().setType(Material.AIR); ycord--; + * trap.getBlock().setType(Material.AIR); ycord--; + * trap.getBlock().setType(Material.LAVA); isAir = false; } else { isAir = + * true; } } + * + * } + */ } \ No newline at end of file