diff --git a/MultiArena-TheBridge/particles.yml b/MultiArena-TheBridge/particles.yml index 1ed1bc9..d9f9913 100644 --- a/MultiArena-TheBridge/particles.yml +++ b/MultiArena-TheBridge/particles.yml @@ -30,7 +30,7 @@ trails: isBuy: true name: "Default Arrow Effect" effect: - type: CRIT + type: EMPTY ammount: 20 permission: bridges.arrow.default description: @@ -49,7 +49,7 @@ trails: isBuy: true name: "Default Feet Effect" effect: - type: CRIT + type: EMPTY ammount: 20 permission: bridges.feet.default description: diff --git a/MultiArena-TheBridge/plugin.yml b/MultiArena-TheBridge/plugin.yml index c89bbb0..27d7052 100644 --- a/MultiArena-TheBridge/plugin.yml +++ b/MultiArena-TheBridge/plugin.yml @@ -1,6 +1,6 @@ main: cx.sfy.TheBridge.Main name: TheBridge -version: 2.4.5 +version: 2.4.6-BETA1 authors: [Stefatorus, pintux98, Leonardo0013YT] softdepend: [PlaceholderAPI, LeaderHeads, FastAsyncWorldEdit, WorldEdit] commands: diff --git a/MultiArena-TheBridge/pom.xml b/MultiArena-TheBridge/pom.xml index b09a0b8..74c6e47 100644 --- a/MultiArena-TheBridge/pom.xml +++ b/MultiArena-TheBridge/pom.xml @@ -6,7 +6,7 @@ TheBridge TheBridge - 2.4.5 + 2.4.6-BETA1 TheBridge jar diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/cmds/SetupCMD.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/cmds/SetupCMD.java index 934eed1..59acf91 100644 --- a/MultiArena-TheBridge/src/cx/sfy/TheBridge/cmds/SetupCMD.java +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/cmds/SetupCMD.java @@ -37,968 +37,964 @@ public class SetupCMD implements CommandExecutor { if (sender instanceof Player) { final Player p = (Player) sender; if (args.length < 1) { - if (p.hasPermission("bridges.admin")) { + if (p.hasPermission("bridges.admin")) sendHelp(p); - } else { + else sendPlayerCommands(p); - } return true; } switch (args[0].toLowerCase()) { - case "hotbar": - if (!p.hasPermission("bridges.hotbar")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (plugin.getConfig().getString("kit") == null) { - p.sendMessage(plugin.getLang().get("messages.noHaveKit")); - return true; - } - plugin.getHotbar().createHotbarMenu(p); - break; - case "archievements": - if (!p.hasPermission("bridges.archievements")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (plugin.isArchiDisabled()) { - p.sendMessage(plugin.getLang().get("messages.archiDisabled")); - return true; - } - if (args.length < 1) { - sendHelp(p); - return true; - } - if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { - p.sendMessage(plugin.getLang().get("messages.alreadyGame")); - return true; - } - plugin.getArchimenu().createArchievementsMenu(p, 1); - break; - case "ach": - if (!p.hasPermission("bridges.archievements")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (plugin.isArchiDisabled()) { - p.sendMessage(plugin.getLang().get("messages.archiDisabled")); - return true; - } - if (args.length < 1) { - sendHelp(p); - return true; - } - if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { - p.sendMessage(plugin.getLang().get("messages.alreadyGame")); - return true; - } - plugin.getArchimenu().createArchievementsMenu(p, 1); - break; - case "menu": - if (!p.hasPermission("bridges.menu")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 1) { - sendHelp(p); - return true; - } - if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { - p.sendMessage(plugin.getLang().get("messages.alreadyGame")); - return true; - } - plugin.getGmu().openGameMenu(p); - break; - case "shop": - if (!p.hasPermission("bridges.shop")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 1) { - sendHelp(p); - return true; - } - if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { - p.sendMessage(plugin.getLang().get("messages.alreadyGame")); - return true; - } - plugin.getShop().openShopMenu(p); - break; - case "cages": - if (!p.hasPermission("bridges.cages")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 1) { - sendHelp(p); - return true; - } - if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { - p.sendMessage(plugin.getLang().get("messages.alreadyGame")); - return true; - } - if (plugin.isCage()) - plugin.getGlam().createGlassMenu(p); - else - p.sendMessage(plugin.getLang().get("messages.noEnabedGlass")); - break; - case "random": - if (!p.hasPermission("bridges.random")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 2) { - sendHelp(p); - return true; - } - if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { - p.sendMessage(plugin.getLang().get("messages.alreadyGame")); - return true; - } - switch (args[1].toLowerCase()) { - case "normal": - for (final GameDuo game : plugin.getGm().getGames()) { - GameDuo g = null; - int alto = 0; - if (game.isState(State.FINISH) || game.isState(State.INGAME) || game.isState(State.RESTARTING) - || game.isState(State.PREGAME)) - continue; - if (game.getPlayers() == game.getMax()) - continue; - if (game.getPlayers() <= alto) { - g = game; - alto = game.getPlayers(); - } - if (g != null) - plugin.getGm().addPlayerGame(p, game); - else - p.sendMessage(plugin.getLang().get("messages.noGames")); + case "hotbar": + if (!p.hasPermission("bridges.hotbar")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (plugin.getConfig().getString("kit") == null) { + p.sendMessage(plugin.getLang().get("messages.noHaveKit")); + return true; } + plugin.getHotbar().createHotbarMenu(p); break; - case "four": - for (final GameFour game : plugin.getGm().getGamesFour()) { - GameFour g = null; - int alto = 0; - if (game.isState(FState.FINISH) || game.isState(FState.INGAME) - || game.isState(FState.RESTARTING) || game.isState(FState.PREGAME)) - continue; - if (game.getPlayers().size() == game.getMax()) - continue; - if (game.getPlayers().size() <= alto) { - g = game; - alto = game.getPlayers().size(); - } - if (g != null) - plugin.getGm().addPlayerGameFour(p, game); - else - p.sendMessage(plugin.getLang().get("messages.noGames")); + case "archievements": + if (!p.hasPermission("bridges.archievements")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (plugin.isArchiDisabled()) { + p.sendMessage(plugin.getLang().get("messages.archiDisabled")); + return true; } + if (args.length < 1) { + sendHelp(p); + return true; + } + if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { + p.sendMessage(plugin.getLang().get("messages.alreadyGame")); + return true; + } + plugin.getArchimenu().createArchievementsMenu(p, 1); break; - } - break; - case "settop": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 2) { - sendHelp(p); - return true; - } - switch (args[1].toLowerCase()) { - case "normal": - if (args.length < 3) { + case "ach": + if (!p.hasPermission("bridges.archievements")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (plugin.isArchiDisabled()) { + p.sendMessage(plugin.getLang().get("messages.archiDisabled")); + return true; + } + if (args.length < 1) { sendHelp(p); return true; } - switch (args[2].toLowerCase()) { - case "kills": - final String kills = plugin.getLm().getLocationString(p.getLocation()); - plugin.getConfig().set("tops.normal.kills", kills); - plugin.saveConfig(); - plugin.getLm().reloadLocations(); - p.sendMessage("§aNormal TOP Kills setted."); - break; - case "wins": - final String wins = plugin.getLm().getLocationString(p.getLocation()); - plugin.getConfig().set("tops.normal.wins", wins); - plugin.saveConfig(); - plugin.getLm().reloadLocations(); - p.sendMessage("§aNormal TOP Wins setted."); - break; - case "goals": - final String goals3 = plugin.getLm().getLocationString(p.getLocation()); - plugin.getConfig().set("tops.normal.goals", goals3); - plugin.saveConfig(); - plugin.getLm().reloadLocations(); - p.sendMessage("§aNormal TOP Goals setted."); - break; + if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { + p.sendMessage(plugin.getLang().get("messages.alreadyGame")); + return true; } + plugin.getArchimenu().createArchievementsMenu(p, 1); break; - case "four": - switch (args[2].toLowerCase()) { - case "kills": - final String kills2 = plugin.getLm().getLocationString(p.getLocation()); - plugin.getConfig().set("tops.four.kills", kills2); - plugin.saveConfig(); - plugin.getLm().reloadLocations(); - p.sendMessage("§aFour TOP Kills setted."); - break; - case "wins": - final String wins2 = plugin.getLm().getLocationString(p.getLocation()); - plugin.getConfig().set("tops.four.wins", wins2); - plugin.saveConfig(); - plugin.getLm().reloadLocations(); - p.sendMessage("§aFour TOP Wins setted."); - break; - case "goals": - final String goals2 = plugin.getLm().getLocationString(p.getLocation()); - plugin.getConfig().set("tops.four.goals", goals2); - plugin.saveConfig(); - plugin.getLm().reloadLocations(); - p.sendMessage("§aFour TOP Goals setted."); - break; + case "menu": + if (!p.hasPermission("bridges.menu")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 1) { + sendHelp(p); + return true; } + if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { + p.sendMessage(plugin.getLang().get("messages.alreadyGame")); + return true; + } + plugin.getGmu().openSelectTypeMenu(p); break; - } - break; - case "setstats": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - final String stats = plugin.getLm().getLocationString(p.getLocation()); - plugin.getConfig().set("stats", stats); - plugin.saveConfig(); - plugin.getLm().reloadLocations(); - p.sendMessage("§aStats setted."); - break; - case "help": - if (!p.hasPermission("bridges.admin")) { + case "shop": + if (!p.hasPermission("bridges.shop")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 1) { + sendHelp(p); + return true; + } + if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { + p.sendMessage(plugin.getLang().get("messages.alreadyGame")); + return true; + } + plugin.getShop().openShopMenu(p); + break; + case "cages": + if (!p.hasPermission("bridges.cages")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 1) { + sendHelp(p); + return true; + } + if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { + p.sendMessage(plugin.getLang().get("messages.alreadyGame")); + return true; + } + if (plugin.isCage()) + plugin.getGlam().createGlassMenu(p); + else + p.sendMessage(plugin.getLang().get("messages.noEnabedGlass")); + break; + case "random": + if (!p.hasPermission("bridges.random")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } if (args.length < 2) { - sendPlayerCommands(p); + sendHelp(p); return true; } - return true; - } - if (args.length < 2) { - sendHelp(p); - return true; - } - switch (args[1].toLowerCase()) { - case "player": - sendPlayerCommands(p); + if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { + p.sendMessage(plugin.getLang().get("messages.alreadyGame")); + return true; + } + switch (args[1].toLowerCase()) { + case "normal": + for (final GameDuo game : plugin.getGm().getGames()) { + GameDuo g = null; + if (game.isState(State.FINISH) || game.isState(State.INGAME) + || game.isState(State.RESTARTING) || game.isState(State.PREGAME)) + continue; + if (game.getPlayers() == game.getMax()) + continue; + if (game.getPlayers() < game.getMax()) + g = game; + if (g != null) { + plugin.getGm().addPlayerGame(p, game); + return true; + } else + p.sendMessage(plugin.getLang().get("messages.noGames")); + } + break; + case "four": + for (final GameFour game : plugin.getGm().getGamesFour()) { + GameFour g = null; + if (game.isState(FState.FINISH) || game.isState(FState.INGAME) + || game.isState(FState.RESTARTING) || game.isState(FState.PREGAME)) + continue; + if (game.getPlayers().size() == game.getMax()) + continue; + if (game.getPlayers().size() < game.getMax()) + g = game; + if (g != null) { + plugin.getGm().addPlayerGameFour(p, game); + return true; + } else + p.sendMessage(plugin.getLang().get("messages.noGames")); + } + break; + } break; - case "lobby": - sendLobbyCommands(p); + case "settop": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 2) { + sendHelp(p); + return true; + } + switch (args[1].toLowerCase()) { + case "normal": + if (args.length < 3) { + sendHelp(p); + return true; + } + switch (args[2].toLowerCase()) { + case "kills": + final String kills = plugin.getLm().getLocationString(p.getLocation()); + plugin.getConfig().set("tops.normal.kills", kills); + plugin.saveConfig(); + plugin.getLm().reloadLocations(); + p.sendMessage("§aNormal TOP Kills setted."); + break; + case "wins": + final String wins = plugin.getLm().getLocationString(p.getLocation()); + plugin.getConfig().set("tops.normal.wins", wins); + plugin.saveConfig(); + plugin.getLm().reloadLocations(); + p.sendMessage("§aNormal TOP Wins setted."); + break; + case "goals": + final String goals3 = plugin.getLm().getLocationString(p.getLocation()); + plugin.getConfig().set("tops.normal.goals", goals3); + plugin.saveConfig(); + plugin.getLm().reloadLocations(); + p.sendMessage("§aNormal TOP Goals setted."); + break; + } + break; + case "four": + switch (args[2].toLowerCase()) { + case "kills": + final String kills2 = plugin.getLm().getLocationString(p.getLocation()); + plugin.getConfig().set("tops.four.kills", kills2); + plugin.saveConfig(); + plugin.getLm().reloadLocations(); + p.sendMessage("§aFour TOP Kills setted."); + break; + case "wins": + final String wins2 = plugin.getLm().getLocationString(p.getLocation()); + plugin.getConfig().set("tops.four.wins", wins2); + plugin.saveConfig(); + plugin.getLm().reloadLocations(); + p.sendMessage("§aFour TOP Wins setted."); + break; + case "goals": + final String goals2 = plugin.getLm().getLocationString(p.getLocation()); + plugin.getConfig().set("tops.four.goals", goals2); + plugin.saveConfig(); + plugin.getLm().reloadLocations(); + p.sendMessage("§aFour TOP Goals setted."); + break; + } + break; + } break; - case "all": - sendAllTypesCommands(p); + case "setstats": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + final String stats = plugin.getLm().getLocationString(p.getLocation()); + plugin.getConfig().set("stats", stats); + plugin.saveConfig(); + plugin.getLm().reloadLocations(); + p.sendMessage("§aStats setted."); break; - case "normal": - sendNormalTypeCommands(p); + case "help": + if (!p.hasPermission("bridges.admin")) { + if (args.length < 2) { + sendPlayerCommands(p); + return true; + } + return true; + } + if (args.length < 2) { + sendHelp(p); + return true; + } + switch (args[1].toLowerCase()) { + case "player": + sendPlayerCommands(p); + break; + case "lobby": + sendLobbyCommands(p); + break; + case "all": + sendAllTypesCommands(p); + break; + case "normal": + sendNormalTypeCommands(p); + break; + case "four": + sendFourTypeCommands(p); + break; + } break; - case "four": - sendFourTypeCommands(p); + case "leave": + if (plugin.getGm().getGameByPlayer(p) == null && plugin.getGm().getGameFourByPlayer(p) == null) { + p.sendMessage(plugin.getLang().get("messages.noGame")); + return true; + } + if (plugin.getGm().getGameByPlayer(p) != null) { + final GameDuo game = plugin.getGm().getGameByPlayer(p); + plugin.getGm().removePlayerGame(p, game); + return true; + } + if (plugin.getGm().getGameFourByPlayer(p) != null) { + final GameFour game = plugin.getGm().getGameFourByPlayer(p); + plugin.getGm().removePlayerGameFour(p, game); + return true; + } break; - } - break; - case "leave": - if (plugin.getGm().getGameByPlayer(p) == null && plugin.getGm().getGameFourByPlayer(p) == null) { - p.sendMessage(plugin.getLang().get("messages.noGame")); - return true; - } - if (plugin.getGm().getGameByPlayer(p) != null) { - final GameDuo game = plugin.getGm().getGameByPlayer(p); - plugin.getGm().removePlayerGame(p, game); - return true; - } - if (plugin.getGm().getGameFourByPlayer(p) != null) { - final GameFour game = plugin.getGm().getGameFourByPlayer(p); - plugin.getGm().removePlayerGameFour(p, game); - return true; - } - break; - case "setmainlobby": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - plugin.getLm().setMainLobby(p); - break; - case "setkit": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - final Inventory inv = Bukkit.getServer().createInventory(null, 36); - for (int i = 0; i < 35; i++) { - if (p.getInventory().getItem(i) == null || p.getInventory().getItem(i).getType() == Material.AIR) { - inv.setItem(i, new ItemStack(Material.BARRIER, 1, (short) 0)); - continue; - } - inv.setItem(i, p.getInventory().getItem(i)); - } - final String kit = plugin.getKit().toBase64(inv); - plugin.getConfig().set("kit", kit); - plugin.saveConfig(); - plugin.getGm().reloadKit(); - p.sendMessage("§aKit saved and reloaded."); - break; - case "join": - if (!p.hasPermission("bridges.join")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 2) { - sendHelp(p); - return true; - } - final String name100 = args[1]; - if (!plugin.getFm().arenaExists(name100)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { - p.sendMessage(plugin.getLang().get("messages.alreadyGame")); - return true; - } - if (plugin.getGm().getGameByName(name100) != null) { - final GameDuo game = plugin.getGm().getGameByName(name100); - if (game.getPlayers() >= game.getMax()) { - p.sendMessage(plugin.getLang().get("messages.gameFull")); - return true; - } - plugin.getGm().addPlayerGame(p, game); - return true; - } - if (plugin.getGm().getGameFourByName(name100) != null) { - final GameFour game = plugin.getGm().getGameFourByName(name100); - if (game.getPlayers().size() >= game.getMax()) { - p.sendMessage(plugin.getLang().get("messages.gameFull")); - return true; - } - plugin.getGm().addPlayerGameFour(p, game); - return true; - } - break; - case "create": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 2) { - sendHelp(p); - return true; - } - final String name = args[1]; - if (Bukkit.getWorld(name) != null) - if (Bukkit.getWorlds().contains(Bukkit.getWorld(name))) { - plugin.getFm().createNewFile(name); - final File c = new File(plugin.getDataFolder() + "/arenas", name + ".yml"); - final YamlConfiguration config = YamlConfiguration.loadConfiguration(c); - config.set("enabled", false); - config.set("name", name); - try { - config.save(c); - } catch (final IOException e) { - e.printStackTrace(); + case "setmainlobby": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + plugin.getLm().setMainLobby(p); + break; + case "setkit": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + final Inventory inv = Bukkit.getServer().createInventory(null, 36); + for (int i = 0; i < 35; i++) { + if (p.getInventory().getItem(i) == null + || p.getInventory().getItem(i).getType() == Material.AIR) { + inv.setItem(i, new ItemStack(Material.BARRIER, 1, (short) 0)); + continue; } - p.sendMessage("§aArena §e" + name + "§a has been created."); - return true; - } - if (plugin.getFm().arenaExists(name)) { - p.sendMessage("§cThis arena already exists."); - return true; - } - plugin.getWc().createEmptyWorld(p, name); - plugin.getFm().createNewFile(name); - final File c = new File(plugin.getDataFolder() + "/arenas", name + ".yml"); - final YamlConfiguration config = YamlConfiguration.loadConfiguration(c); - config.set("enabled", false); - config.set("name", name); - try { - config.save(c); - } catch (final IOException e) { - e.printStackTrace(); - } - p.sendMessage("§aArena §e" + name + "§a has been created."); - break; - case "save": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - plugin.getWc().copyWorld(p.getWorld()); - p.sendMessage("§aArena §e" + p.getWorld().getName() + "§a has been saved."); - break; - case "wand": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - final ItemStack wand = ItemBuilder.item(Material.BLAZE_ROD, 1, (short) 0, "§eSetup TheBridge", ""); - p.getInventory().addItem(wand); - break; - case "settype": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 3) { - sendHelp(p); - return true; - } - final String name1 = args[1]; - switch (args[2].toLowerCase()) { - case "four": - final String type1 = args[2].toLowerCase(); - if (!plugin.getFm().arenaExists(name1)) { + inv.setItem(i, p.getInventory().getItem(i)); + } + final String kit = plugin.getKit().toBase64(inv); + plugin.getConfig().set("kit", kit); + plugin.saveConfig(); + plugin.getGm().reloadKit(); + p.sendMessage("§aKit saved and reloaded."); + break; + case "join": + if (!p.hasPermission("bridges.join")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 2) { + sendHelp(p); + return true; + } + final String name100 = args[1]; + if (!plugin.getFm().arenaExists(name100)) { p.sendMessage("§cThis arena doest exists."); return true; } - final File c1 = new File(plugin.getDataFolder() + "/arenas", name1 + ".yml"); - final YamlConfiguration config1 = YamlConfiguration.loadConfiguration(c1); - config1.set("mode", type1); + if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) { + p.sendMessage(plugin.getLang().get("messages.alreadyGame")); + return true; + } + if (plugin.getGm().getGameByName(name100) != null) { + final GameDuo game = plugin.getGm().getGameByName(name100); + if (game.getPlayers() >= game.getMax()) { + p.sendMessage(plugin.getLang().get("messages.gameFull")); + return true; + } + plugin.getGm().addPlayerGame(p, game); + return true; + } + if (plugin.getGm().getGameFourByName(name100) != null) { + final GameFour game = plugin.getGm().getGameFourByName(name100); + if (game.getPlayers().size() >= game.getMax()) { + p.sendMessage(plugin.getLang().get("messages.gameFull")); + return true; + } + plugin.getGm().addPlayerGameFour(p, game); + return true; + } + break; + case "create": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 2) { + sendHelp(p); + return true; + } + final String name = args[1]; + if (Bukkit.getWorld(name) != null) + if (Bukkit.getWorlds().contains(Bukkit.getWorld(name))) { + plugin.getFm().createNewFile(name); + final File c = new File(plugin.getDataFolder() + "/arenas", name + ".yml"); + final YamlConfiguration config = YamlConfiguration.loadConfiguration(c); + config.set("enabled", false); + config.set("name", name); + try { + config.save(c); + } catch (final IOException e) { + e.printStackTrace(); + } + p.sendMessage("§aArena §e" + name + "§a has been created."); + return true; + } + if (plugin.getFm().arenaExists(name)) { + p.sendMessage("§cThis arena already exists."); + return true; + } + plugin.getWc().createEmptyWorld(p, name); + plugin.getFm().createNewFile(name); + final File c = new File(plugin.getDataFolder() + "/arenas", name + ".yml"); + final YamlConfiguration config = YamlConfiguration.loadConfiguration(c); + config.set("enabled", false); + config.set("name", name); try { - config1.save(c1); + config.save(c); } catch (final IOException e) { e.printStackTrace(); } - p.sendMessage("§aArena type of §e" + name1 + "§a has been setted to §e" + type1 + "§a."); + p.sendMessage("§aArena §e" + name + "§a has been created."); + break; + case "save": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + plugin.getWc().copyWorld(p.getWorld()); + p.sendMessage("§aArena §e" + p.getWorld().getName() + "§a has been saved."); + break; + case "wand": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + final ItemStack wand = ItemBuilder.item(Material.BLAZE_ROD, 1, (short) 0, "§eSetup TheBridge", ""); + p.getInventory().addItem(wand); + break; + case "settype": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 3) { + sendHelp(p); + return true; + } + final String name1 = args[1]; + switch (args[2].toLowerCase()) { + case "four": + final String type1 = args[2].toLowerCase(); + if (!plugin.getFm().arenaExists(name1)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final File c1 = new File(plugin.getDataFolder() + "/arenas", name1 + ".yml"); + final YamlConfiguration config1 = YamlConfiguration.loadConfiguration(c1); + config1.set("mode", type1); + try { + config1.save(c1); + } catch (final IOException e) { + e.printStackTrace(); + } + p.sendMessage("§aArena type of §e" + name1 + "§a has been setted to §e" + type1 + "§a."); + break; + case "normal": + final String type2 = args[2].toLowerCase(); + if (!plugin.getFm().arenaExists(name1)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final File c2 = new File(plugin.getDataFolder() + "/arenas", name1 + ".yml"); + final YamlConfiguration config2 = YamlConfiguration.loadConfiguration(c2); + config2.set("mode", type2); + try { + config2.save(c2); + } catch (final IOException e) { + e.printStackTrace(); + } + p.sendMessage("§aArena type of §e" + name1 + "§a has been setted to §e" + type2 + "§a."); + break; + } break; - case "normal": - final String type2 = args[2].toLowerCase(); - if (!plugin.getFm().arenaExists(name1)) { + case "setspawn": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 3) { + sendHelp(p); + return true; + } + final String name2 = args[1]; + if (!plugin.getFm().arenaExists(name2)) { p.sendMessage("§cThis arena doest exists."); return true; } - final File c2 = new File(plugin.getDataFolder() + "/arenas", name1 + ".yml"); - final YamlConfiguration config2 = YamlConfiguration.loadConfiguration(c2); - config2.set("mode", type2); - try { - config2.save(c2); - } catch (final IOException e) { - e.printStackTrace(); + final File c3 = new File(plugin.getDataFolder() + "/arenas", name2 + ".yml"); + final YamlConfiguration config3 = YamlConfiguration.loadConfiguration(c3); + switch (args[2].toLowerCase()) { + case "blue": + config3.set("locations.spawns.blue", getLocationString(p.getLocation())); + try { + config3.save(c3); + } catch (final IOException e) { + e.printStackTrace(); + } + p.sendMessage("§aSpawn location for §eBLUE §ahas been setted."); + break; + case "red": + config3.set("locations.spawns.red", getLocationString(p.getLocation())); + try { + config3.save(c3); + } catch (final IOException e) { + e.printStackTrace(); + } + p.sendMessage("§aSpawn location for §eRED §ahas been setted."); + break; + case "green": + config3.set("locations.spawns.green", getLocationString(p.getLocation())); + try { + config3.save(c3); + } catch (final IOException e) { + e.printStackTrace(); + } + p.sendMessage("§aSpawn location for §eGREEN §ahas been setted."); + break; + case "yellow": + config3.set("locations.spawns.yellow", getLocationString(p.getLocation())); + try { + config3.save(c3); + } catch (final IOException e) { + e.printStackTrace(); + } + p.sendMessage("§aSpawn location for §eYELLOW §ahas been setted."); + break; } - p.sendMessage("§aArena type of §e" + name1 + "§a has been setted to §e" + type2 + "§a."); break; - } - break; - case "setspawn": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 3) { - sendHelp(p); - return true; - } - final String name2 = args[1]; - if (!plugin.getFm().arenaExists(name2)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final File c3 = new File(plugin.getDataFolder() + "/arenas", name2 + ".yml"); - final YamlConfiguration config3 = YamlConfiguration.loadConfiguration(c3); - switch (args[2].toLowerCase()) { - case "blue": - config3.set("locations.spawns.blue", getLocationString(p.getLocation())); - try { - config3.save(c3); - } catch (final IOException e) { - e.printStackTrace(); + case "setrespawn": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 3) { + sendHelp(p); + return true; + } + final String name3 = args[1]; + if (!plugin.getFm().arenaExists(name3)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final File c4 = new File(plugin.getDataFolder() + "/arenas", name3 + ".yml"); + final YamlConfiguration config4 = YamlConfiguration.loadConfiguration(c4); + switch (args[2].toLowerCase()) { + case "blue": + config4.set("locations.respawns.blue", getLocationString(p.getLocation())); + try { + config4.save(c4); + } catch (final IOException e) { + e.printStackTrace(); + } + p.sendMessage("§aRespawn location for §eBLUE §ahas been setted."); + break; + case "red": + config4.set("locations.respawns.red", getLocationString(p.getLocation())); + try { + config4.save(c4); + } catch (final IOException e) { + e.printStackTrace(); + } + p.sendMessage("§aRespawn location for §eRED §ahas been setted."); + break; + case "green": + config4.set("locations.respawns.green", getLocationString(p.getLocation())); + try { + config4.save(c4); + } catch (final IOException e) { + e.printStackTrace(); + } + p.sendMessage("§aRespawn location for §eGREEN §ahas been setted."); + break; + case "yellow": + config4.set("locations.respawns.yellow", getLocationString(p.getLocation())); + try { + config4.save(c4); + } catch (final IOException e) { + e.printStackTrace(); + } + p.sendMessage("§aRespawn location for §eYELLOW §ahas been setted."); + break; } - p.sendMessage("§aSpawn location for §eBLUE §ahas been setted."); break; - case "red": - config3.set("locations.spawns.red", getLocationString(p.getLocation())); - try { - config3.save(c3); - } catch (final IOException e) { - e.printStackTrace(); + case "setportal": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 3) { + sendHelp(p); + return true; + } + final String name4 = args[1]; + if (!plugin.getFm().arenaExists(name4)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final File c5 = new File(plugin.getDataFolder() + "/arenas", name4 + ".yml"); + final YamlConfiguration config5 = YamlConfiguration.loadConfiguration(c5); + if (!plugin.getSm().getSelect().containsKey(p)) { + p.sendMessage("§cYou have not selected anything."); + return true; + } + if (!plugin.getSm().getSelect().get(p).containsKey("MIN")) { + p.sendMessage("§cYou have not selected the minimum."); + return true; + } + if (!plugin.getSm().getSelect().get(p).containsKey("MAX")) { + p.sendMessage("§cYou have not selected the minimum."); + return true; + } + switch (args[2].toLowerCase()) { + case "red": + final ArrayList portal = new ArrayList<>(); + final Location location = plugin.getSm().getSelect().get(p).get("MIN"); + final Location location2 = plugin.getSm().getSelect().get(p).get("MAX"); + final int n = Math.min(location.getBlockX(), location2.getBlockX()); + final int n2 = Math.max(location.getBlockX(), location2.getBlockX()); + final int n3 = Math.min(location.getBlockZ(), location2.getBlockZ()); + final int n4 = Math.max(location.getBlockZ(), location2.getBlockZ()); + final int n5 = Math.min(location.getBlockY(), location2.getBlockY()); + final int n6 = Math.max(location.getBlockY(), location2.getBlockY()); + for (int i = n; i <= n2; ++i) + for (int j = n5; j <= n6; ++j) + for (int k = n3; k <= n4; ++k) { + final Location location3 = new Location(p.getWorld(), i, j, k); + if (location3.getBlock().getType() == Material.AIR) + continue; + if (location3.getBlock().getType() == Material.OBSIDIAN) + portal.add(getLocationString(location3)); + } + config5.set("locations.portal.red", portal); + config5.set("locations.holograms.red", getLocationString(p.getLocation())); + try { + config5.save(c5); + } catch (final IOException e) { + e.printStackTrace(); + } + plugin.getSm().getSelect().remove(p); + p.sendMessage("§aPortal location for §eRED §ahas been setted."); + break; + case "blue": + final ArrayList bportal = new ArrayList<>(); + final Location blocation = plugin.getSm().getSelect().get(p).get("MIN"); + final Location blocation2 = plugin.getSm().getSelect().get(p).get("MAX"); + final int bn = Math.min(blocation.getBlockX(), blocation2.getBlockX()); + final int bn2 = Math.max(blocation.getBlockX(), blocation2.getBlockX()); + final int bn3 = Math.min(blocation.getBlockZ(), blocation2.getBlockZ()); + final int bn4 = Math.max(blocation.getBlockZ(), blocation2.getBlockZ()); + final int bn5 = Math.min(blocation.getBlockY(), blocation2.getBlockY()); + final int bn6 = Math.max(blocation.getBlockY(), blocation2.getBlockY()); + for (int i = bn; i <= bn2; ++i) + for (int j = bn5; j <= bn6; ++j) + for (int k = bn3; k <= bn4; ++k) { + final Location location3 = new Location(p.getWorld(), i, j, k); + if (p.getWorld().getBlockAt(location3).getType() == Material.OBSIDIAN) + bportal.add(getLocationString(location3)); + } + config5.set("locations.portal.blue", bportal); + config5.set("locations.holograms.blue", getLocationString(p.getLocation())); + try { + config5.save(c5); + } catch (final IOException e) { + e.printStackTrace(); + } + plugin.getSm().getSelect().remove(p); + p.sendMessage("§aPortal location for §eBLUE §ahas been setted."); + break; + case "green": + final ArrayList gportal = new ArrayList<>(); + final Location glocation = plugin.getSm().getSelect().get(p).get("MIN"); + final Location glocation2 = plugin.getSm().getSelect().get(p).get("MAX"); + final int gn = Math.min(glocation.getBlockX(), glocation2.getBlockX()); + final int gn2 = Math.max(glocation.getBlockX(), glocation2.getBlockX()); + final int gn3 = Math.min(glocation.getBlockZ(), glocation2.getBlockZ()); + final int gn4 = Math.max(glocation.getBlockZ(), glocation2.getBlockZ()); + final int gn5 = Math.min(glocation.getBlockY(), glocation2.getBlockY()); + final int gn6 = Math.max(glocation.getBlockY(), glocation2.getBlockY()); + for (int i = gn; i <= gn2; ++i) + for (int j = gn5; j <= gn6; ++j) + for (int k = gn3; k <= gn4; ++k) { + final Location location3 = new Location(p.getWorld(), i, j, k); + if (p.getWorld().getBlockAt(location3).getType() == Material.OBSIDIAN) + gportal.add(getLocationString(location3)); + } + config5.set("locations.portal.green", gportal); + config5.set("locations.holograms.green", getLocationString(p.getLocation())); + try { + config5.save(c5); + } catch (final IOException e) { + e.printStackTrace(); + } + plugin.getSm().getSelect().remove(p); + p.sendMessage("§aPortal location for §eGREEN §ahas been setted."); + break; + case "yellow": + final ArrayList yportal = new ArrayList<>(); + final Location ylocation = plugin.getSm().getSelect().get(p).get("MIN"); + final Location ylocation2 = plugin.getSm().getSelect().get(p).get("MAX"); + final int yn = Math.min(ylocation.getBlockX(), ylocation2.getBlockX()); + final int yn2 = Math.max(ylocation.getBlockX(), ylocation2.getBlockX()); + final int yn3 = Math.min(ylocation.getBlockZ(), ylocation2.getBlockZ()); + final int yn4 = Math.max(ylocation.getBlockZ(), ylocation2.getBlockZ()); + final int yn5 = Math.min(ylocation.getBlockY(), ylocation2.getBlockY()); + final int yn6 = Math.max(ylocation.getBlockY(), ylocation2.getBlockY()); + for (int i = yn; i <= yn2; ++i) + for (int j = yn5; j <= yn6; ++j) + for (int k = yn3; k <= yn4; ++k) { + final Location location3 = new Location(p.getWorld(), i, j, k); + if (p.getWorld().getBlockAt(location3).getType() == Material.OBSIDIAN) + yportal.add(getLocationString(location3)); + } + config5.set("locations.portal.yellow", yportal); + config5.set("locations.holograms.yellow", getLocationString(p.getLocation())); + try { + config5.save(c5); + } catch (final IOException e) { + e.printStackTrace(); + } + plugin.getSm().getSelect().remove(p); + p.sendMessage("§aPortal location for §eYELLOW §ahas been setted."); + break; } - p.sendMessage("§aSpawn location for §eRED §ahas been setted."); break; - case "green": - config3.set("locations.spawns.green", getLocationString(p.getLocation())); + case "setbuild": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 2) { + sendHelp(p); + return true; + } + final String name5 = args[1]; + if (!plugin.getFm().arenaExists(name5)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final File c6 = new File(plugin.getDataFolder() + "/arenas", name5 + ".yml"); + final YamlConfiguration config6 = YamlConfiguration.loadConfiguration(c6); + if (!plugin.getSm().getSelect().containsKey(p)) { + p.sendMessage("§cYou have not selected anything."); + return true; + } + if (!plugin.getSm().getSelect().get(p).containsKey("MIN")) { + p.sendMessage("§cYou have not selected the minimum."); + return true; + } + if (!plugin.getSm().getSelect().get(p).containsKey("MAX")) { + p.sendMessage("§cYou have not selected the minimum."); + return true; + } + final Location l1 = plugin.getSm().getSelect().get(p).get("MIN"); + final Location l2 = plugin.getSm().getSelect().get(p).get("MAX"); + config6.set("locations.build.min", getLocationString(l1)); + config6.set("locations.build.max", getLocationString(l2)); try { - config3.save(c3); + config6.save(c6); } catch (final IOException e) { e.printStackTrace(); } - p.sendMessage("§aSpawn location for §eGREEN §ahas been setted."); + plugin.getSm().getSelect().remove(p); + p.sendMessage("§aBuild location has been setted."); break; - case "yellow": - config3.set("locations.spawns.yellow", getLocationString(p.getLocation())); + case "setlobby": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 2) { + sendHelp(p); + return true; + } + final String name6 = args[1]; + if (!plugin.getFm().arenaExists(name6)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final File c7 = new File(plugin.getDataFolder() + "/arenas", name6 + ".yml"); + final YamlConfiguration config7 = YamlConfiguration.loadConfiguration(c7); + config7.set("locations.lobby", getLocationString(p.getLocation())); try { - config3.save(c3); + config7.save(c7); } catch (final IOException e) { e.printStackTrace(); } - p.sendMessage("§aSpawn location for §eYELLOW §ahas been setted."); + p.sendMessage("§aLobby location has been setted."); break; - } - break; - case "setrespawn": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 3) { - sendHelp(p); - return true; - } - final String name3 = args[1]; - if (!plugin.getFm().arenaExists(name3)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final File c4 = new File(plugin.getDataFolder() + "/arenas", name3 + ".yml"); - final YamlConfiguration config4 = YamlConfiguration.loadConfiguration(c4); - switch (args[2].toLowerCase()) { - case "blue": - config4.set("locations.respawns.blue", getLocationString(p.getLocation())); + case "setspect": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 2) { + sendHelp(p); + return true; + } + final String name7 = args[1]; + if (!plugin.getFm().arenaExists(name7)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final File c8 = new File(plugin.getDataFolder() + "/arenas", name7 + ".yml"); + final YamlConfiguration config8 = YamlConfiguration.loadConfiguration(c8); + config8.set("locations.spect", getLocationString(p.getLocation())); try { - config4.save(c4); + config8.save(c8); } catch (final IOException e) { e.printStackTrace(); } - p.sendMessage("§aRespawn location for §eBLUE §ahas been setted."); + p.sendMessage("§aSpect location has been setted."); break; - case "red": - config4.set("locations.respawns.red", getLocationString(p.getLocation())); + case "setmin": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 3) { + sendHelp(p); + return true; + } + final String name8 = args[1]; + if (!plugin.getFm().arenaExists(name8)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final int min = Integer.parseInt(args[2]); + final File c9 = new File(plugin.getDataFolder() + "/arenas", name8 + ".yml"); + final YamlConfiguration config9 = YamlConfiguration.loadConfiguration(c9); + config9.set("minPlayers", min); try { - config4.save(c4); + config9.save(c9); } catch (final IOException e) { e.printStackTrace(); } - p.sendMessage("§aRespawn location for §eRED §ahas been setted."); + p.sendMessage("§aMin players has been setted. To §e" + min + "§a."); break; - case "green": - config4.set("locations.respawns.green", getLocationString(p.getLocation())); + case "setstarting": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 3) { + sendHelp(p); + return true; + } + final String name13 = args[1]; + if (!plugin.getFm().arenaExists(name13)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final int starting = Integer.parseInt(args[2]); + final File c13 = new File(plugin.getDataFolder() + "/arenas", name13 + ".yml"); + final YamlConfiguration config13 = YamlConfiguration.loadConfiguration(c13); + config13.set("timers.starting", starting); try { - config4.save(c4); + config13.save(c13); } catch (final IOException e) { e.printStackTrace(); } - p.sendMessage("§aRespawn location for §eGREEN §ahas been setted."); + p.sendMessage("§aStarting time has been setted. To §e" + starting + "§a."); break; - case "yellow": - config4.set("locations.respawns.yellow", getLocationString(p.getLocation())); + case "setprestarting": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 3) { + sendHelp(p); + return true; + } + final String name14 = args[1]; + if (!plugin.getFm().arenaExists(name14)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final int prestart = Integer.parseInt(args[2]); + final File c14 = new File(plugin.getDataFolder() + "/arenas", name14 + ".yml"); + final YamlConfiguration config14 = YamlConfiguration.loadConfiguration(c14); + config14.set("timers.prestart", prestart); try { - config4.save(c4); + config14.save(c14); } catch (final IOException e) { e.printStackTrace(); } - p.sendMessage("§aRespawn location for §eYELLOW §ahas been setted."); + p.sendMessage("§aPrestart time has been setted. To §e" + prestart + "§a."); break; - } - break; - case "setportal": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 3) { - sendHelp(p); - return true; - } - final String name4 = args[1]; - if (!plugin.getFm().arenaExists(name4)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final File c5 = new File(plugin.getDataFolder() + "/arenas", name4 + ".yml"); - final YamlConfiguration config5 = YamlConfiguration.loadConfiguration(c5); - if (!plugin.getSm().getSelect().containsKey(p)) { - p.sendMessage("§cYou have not selected anything."); - return true; - } - if (!plugin.getSm().getSelect().get(p).containsKey("MIN")) { - p.sendMessage("§cYou have not selected the minimum."); - return true; - } - if (!plugin.getSm().getSelect().get(p).containsKey("MAX")) { - p.sendMessage("§cYou have not selected the minimum."); - return true; - } - switch (args[2].toLowerCase()) { - case "red": - final ArrayList portal = new ArrayList<>(); - final Location location = plugin.getSm().getSelect().get(p).get("MIN"); - final Location location2 = plugin.getSm().getSelect().get(p).get("MAX"); - final int n = Math.min(location.getBlockX(), location2.getBlockX()); - final int n2 = Math.max(location.getBlockX(), location2.getBlockX()); - final int n3 = Math.min(location.getBlockZ(), location2.getBlockZ()); - final int n4 = Math.max(location.getBlockZ(), location2.getBlockZ()); - final int n5 = Math.min(location.getBlockY(), location2.getBlockY()); - final int n6 = Math.max(location.getBlockY(), location2.getBlockY()); - for (int i = n; i <= n2; ++i) - for (int j = n5; j <= n6; ++j) - for (int k = n3; k <= n4; ++k) { - final Location location3 = new Location(p.getWorld(), i, j, k); - if (location3.getBlock().getType() == Material.AIR) - continue; - if (location3.getBlock().getType() == Material.OBSIDIAN) - portal.add(getLocationString(location3)); - } - config5.set("locations.portal.red", portal); - config5.set("locations.holograms.red", getLocationString(p.getLocation())); + case "setrestart": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 3) { + sendHelp(p); + return true; + } + final String name15 = args[1]; + if (!plugin.getFm().arenaExists(name15)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final int restart = Integer.parseInt(args[2]); + final File c15 = new File(plugin.getDataFolder() + "/arenas", name15 + ".yml"); + final YamlConfiguration config15 = YamlConfiguration.loadConfiguration(c15); + config15.set("timers.restart", restart); try { - config5.save(c5); + config15.save(c15); } catch (final IOException e) { e.printStackTrace(); } - plugin.getSm().getSelect().remove(p); - p.sendMessage("§aPortal location for §eRED §ahas been setted."); + p.sendMessage("§aRestart time has been setted. To §e" + restart + "§a."); break; - case "blue": - final ArrayList bportal = new ArrayList<>(); - final Location blocation = plugin.getSm().getSelect().get(p).get("MIN"); - final Location blocation2 = plugin.getSm().getSelect().get(p).get("MAX"); - final int bn = Math.min(blocation.getBlockX(), blocation2.getBlockX()); - final int bn2 = Math.max(blocation.getBlockX(), blocation2.getBlockX()); - final int bn3 = Math.min(blocation.getBlockZ(), blocation2.getBlockZ()); - final int bn4 = Math.max(blocation.getBlockZ(), blocation2.getBlockZ()); - final int bn5 = Math.min(blocation.getBlockY(), blocation2.getBlockY()); - final int bn6 = Math.max(blocation.getBlockY(), blocation2.getBlockY()); - for (int i = bn; i <= bn2; ++i) - for (int j = bn5; j <= bn6; ++j) - for (int k = bn3; k <= bn4; ++k) { - final Location location3 = new Location(p.getWorld(), i, j, k); - if (p.getWorld().getBlockAt(location3).getType() == Material.OBSIDIAN) - bportal.add(getLocationString(location3)); - } - config5.set("locations.portal.blue", bportal); - config5.set("locations.holograms.blue", getLocationString(p.getLocation())); + case "setteamsize": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 3) { + sendHelp(p); + return true; + } + final String name9 = args[1]; + if (!plugin.getFm().arenaExists(name9)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final int teamSize = Integer.parseInt(args[2]); + final File c10 = new File(plugin.getDataFolder() + "/arenas", name9 + ".yml"); + final YamlConfiguration config10 = YamlConfiguration.loadConfiguration(c10); + config10.set("teamSize", teamSize); try { - config5.save(c5); + config10.save(c10); } catch (final IOException e) { e.printStackTrace(); } - plugin.getSm().getSelect().remove(p); - p.sendMessage("§aPortal location for §eBLUE §ahas been setted."); + p.sendMessage("§aTeam size has been setted. To §e" + teamSize + "§a."); break; - case "green": - final ArrayList gportal = new ArrayList<>(); - final Location glocation = plugin.getSm().getSelect().get(p).get("MIN"); - final Location glocation2 = plugin.getSm().getSelect().get(p).get("MAX"); - final int gn = Math.min(glocation.getBlockX(), glocation2.getBlockX()); - final int gn2 = Math.max(glocation.getBlockX(), glocation2.getBlockX()); - final int gn3 = Math.min(glocation.getBlockZ(), glocation2.getBlockZ()); - final int gn4 = Math.max(glocation.getBlockZ(), glocation2.getBlockZ()); - final int gn5 = Math.min(glocation.getBlockY(), glocation2.getBlockY()); - final int gn6 = Math.max(glocation.getBlockY(), glocation2.getBlockY()); - for (int i = gn; i <= gn2; ++i) - for (int j = gn5; j <= gn6; ++j) - for (int k = gn3; k <= gn4; ++k) { - final Location location3 = new Location(p.getWorld(), i, j, k); - if (p.getWorld().getBlockAt(location3).getType() == Material.OBSIDIAN) - gportal.add(getLocationString(location3)); - } - config5.set("locations.portal.green", gportal); - config5.set("locations.holograms.green", getLocationString(p.getLocation())); + case "setmaxgoals": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 3) { + sendHelp(p); + return true; + } + final String name10 = args[1]; + if (!plugin.getFm().arenaExists(name10)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final int goals = Integer.parseInt(args[2]); + final File c11 = new File(plugin.getDataFolder() + "/arenas", name10 + ".yml"); + final YamlConfiguration config11 = YamlConfiguration.loadConfiguration(c11); + config11.set("maxGoals", goals); try { - config5.save(c5); + config11.save(c11); } catch (final IOException e) { e.printStackTrace(); } - plugin.getSm().getSelect().remove(p); - p.sendMessage("§aPortal location for §eGREEN §ahas been setted."); + p.sendMessage("§aMax goals has been setted. To §e" + goals + "§a."); break; - case "yellow": - final ArrayList yportal = new ArrayList<>(); - final Location ylocation = plugin.getSm().getSelect().get(p).get("MIN"); - final Location ylocation2 = plugin.getSm().getSelect().get(p).get("MAX"); - final int yn = Math.min(ylocation.getBlockX(), ylocation2.getBlockX()); - final int yn2 = Math.max(ylocation.getBlockX(), ylocation2.getBlockX()); - final int yn3 = Math.min(ylocation.getBlockZ(), ylocation2.getBlockZ()); - final int yn4 = Math.max(ylocation.getBlockZ(), ylocation2.getBlockZ()); - final int yn5 = Math.min(ylocation.getBlockY(), ylocation2.getBlockY()); - final int yn6 = Math.max(ylocation.getBlockY(), ylocation2.getBlockY()); - for (int i = yn; i <= yn2; ++i) - for (int j = yn5; j <= yn6; ++j) - for (int k = yn3; k <= yn4; ++k) { - final Location location3 = new Location(p.getWorld(), i, j, k); - if (p.getWorld().getBlockAt(location3).getType() == Material.OBSIDIAN) - yportal.add(getLocationString(location3)); - } - config5.set("locations.portal.yellow", yportal); - config5.set("locations.holograms.yellow", getLocationString(p.getLocation())); + case "setstartlife": + if (!p.hasPermission("bridges.admin")) { + p.sendMessage(plugin.getLang().get("messages.noPermission")); + return true; + } + if (args.length < 3) { + sendHelp(p); + return true; + } + final String name11 = args[1]; + if (!plugin.getFm().arenaExists(name11)) { + p.sendMessage("§cThis arena doest exists."); + return true; + } + final int lifes = Integer.parseInt(args[2]); + final File c12 = new File(plugin.getDataFolder() + "/arenas", name11 + ".yml"); + final YamlConfiguration config12 = YamlConfiguration.loadConfiguration(c12); + config12.set("defaultLife", lifes); try { - config5.save(c5); + config12.save(c12); } catch (final IOException e) { e.printStackTrace(); } - plugin.getSm().getSelect().remove(p); - p.sendMessage("§aPortal location for §eYELLOW §ahas been setted."); + p.sendMessage("§aDefault lifes has been setted. To §e" + lifes + "§a."); break; - } - break; - case "setbuild": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 2) { - sendHelp(p); - return true; - } - final String name5 = args[1]; - if (!plugin.getFm().arenaExists(name5)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final File c6 = new File(plugin.getDataFolder() + "/arenas", name5 + ".yml"); - final YamlConfiguration config6 = YamlConfiguration.loadConfiguration(c6); - if (!plugin.getSm().getSelect().containsKey(p)) { - p.sendMessage("§cYou have not selected anything."); - return true; - } - if (!plugin.getSm().getSelect().get(p).containsKey("MIN")) { - p.sendMessage("§cYou have not selected the minimum."); - return true; - } - if (!plugin.getSm().getSelect().get(p).containsKey("MAX")) { - p.sendMessage("§cYou have not selected the minimum."); - return true; - } - final Location l1 = plugin.getSm().getSelect().get(p).get("MIN"); - final Location l2 = plugin.getSm().getSelect().get(p).get("MAX"); - config6.set("locations.build.min", getLocationString(l1)); - config6.set("locations.build.max", getLocationString(l2)); - try { - config6.save(c6); - } catch (final IOException e) { - e.printStackTrace(); - } - plugin.getSm().getSelect().remove(p); - p.sendMessage("§aBuild location has been setted."); - break; - case "setlobby": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 2) { - sendHelp(p); - return true; - } - final String name6 = args[1]; - if (!plugin.getFm().arenaExists(name6)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final File c7 = new File(plugin.getDataFolder() + "/arenas", name6 + ".yml"); - final YamlConfiguration config7 = YamlConfiguration.loadConfiguration(c7); - config7.set("locations.lobby", getLocationString(p.getLocation())); - try { - config7.save(c7); - } catch (final IOException e) { - e.printStackTrace(); - } - p.sendMessage("§aLobby location has been setted."); - break; - case "setspect": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 2) { - sendHelp(p); - return true; - } - final String name7 = args[1]; - if (!plugin.getFm().arenaExists(name7)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final File c8 = new File(plugin.getDataFolder() + "/arenas", name7 + ".yml"); - final YamlConfiguration config8 = YamlConfiguration.loadConfiguration(c8); - config8.set("locations.spect", getLocationString(p.getLocation())); - try { - config8.save(c8); - } catch (final IOException e) { - e.printStackTrace(); - } - p.sendMessage("§aSpect location has been setted."); - break; - case "setmin": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 3) { - sendHelp(p); - return true; - } - final String name8 = args[1]; - if (!plugin.getFm().arenaExists(name8)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final int min = Integer.parseInt(args[2]); - final File c9 = new File(plugin.getDataFolder() + "/arenas", name8 + ".yml"); - final YamlConfiguration config9 = YamlConfiguration.loadConfiguration(c9); - config9.set("minPlayers", min); - try { - config9.save(c9); - } catch (final IOException e) { - e.printStackTrace(); - } - p.sendMessage("§aMin players has been setted. To §e" + min + "§a."); - break; - case "setstarting": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 3) { - sendHelp(p); - return true; - } - final String name13 = args[1]; - if (!plugin.getFm().arenaExists(name13)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final int starting = Integer.parseInt(args[2]); - final File c13 = new File(plugin.getDataFolder() + "/arenas", name13 + ".yml"); - final YamlConfiguration config13 = YamlConfiguration.loadConfiguration(c13); - config13.set("timers.starting", starting); - try { - config13.save(c13); - } catch (final IOException e) { - e.printStackTrace(); - } - p.sendMessage("§aStarting time has been setted. To §e" + starting + "§a."); - break; - case "setprestarting": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 3) { - sendHelp(p); - return true; - } - final String name14 = args[1]; - if (!plugin.getFm().arenaExists(name14)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final int prestart = Integer.parseInt(args[2]); - final File c14 = new File(plugin.getDataFolder() + "/arenas", name14 + ".yml"); - final YamlConfiguration config14 = YamlConfiguration.loadConfiguration(c14); - config14.set("timers.prestart", prestart); - try { - config14.save(c14); - } catch (final IOException e) { - e.printStackTrace(); - } - p.sendMessage("§aPrestart time has been setted. To §e" + prestart + "§a."); - break; - case "setrestart": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 3) { - sendHelp(p); - return true; - } - final String name15 = args[1]; - if (!plugin.getFm().arenaExists(name15)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final int restart = Integer.parseInt(args[2]); - final File c15 = new File(plugin.getDataFolder() + "/arenas", name15 + ".yml"); - final YamlConfiguration config15 = YamlConfiguration.loadConfiguration(c15); - config15.set("timers.restart", restart); - try { - config15.save(c15); - } catch (final IOException e) { - e.printStackTrace(); - } - p.sendMessage("§aRestart time has been setted. To §e" + restart + "§a."); - break; - case "setteamsize": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 3) { - sendHelp(p); - return true; - } - final String name9 = args[1]; - if (!plugin.getFm().arenaExists(name9)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final int teamSize = Integer.parseInt(args[2]); - final File c10 = new File(plugin.getDataFolder() + "/arenas", name9 + ".yml"); - final YamlConfiguration config10 = YamlConfiguration.loadConfiguration(c10); - config10.set("teamSize", teamSize); - try { - config10.save(c10); - } catch (final IOException e) { - e.printStackTrace(); - } - p.sendMessage("§aTeam size has been setted. To §e" + teamSize + "§a."); - break; - case "setmaxgoals": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 3) { - sendHelp(p); - return true; - } - final String name10 = args[1]; - if (!plugin.getFm().arenaExists(name10)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final int goals = Integer.parseInt(args[2]); - final File c11 = new File(plugin.getDataFolder() + "/arenas", name10 + ".yml"); - final YamlConfiguration config11 = YamlConfiguration.loadConfiguration(c11); - config11.set("maxGoals", goals); - try { - config11.save(c11); - } catch (final IOException e) { - e.printStackTrace(); - } - p.sendMessage("§aMax goals has been setted. To §e" + goals + "§a."); - break; - case "setstartlife": - if (!p.hasPermission("bridges.admin")) { - p.sendMessage(plugin.getLang().get("messages.noPermission")); - return true; - } - if (args.length < 3) { - sendHelp(p); - return true; - } - final String name11 = args[1]; - if (!plugin.getFm().arenaExists(name11)) { - p.sendMessage("§cThis arena doest exists."); - return true; - } - final int lifes = Integer.parseInt(args[2]); - final File c12 = new File(plugin.getDataFolder() + "/arenas", name11 + ".yml"); - final YamlConfiguration config12 = YamlConfiguration.loadConfiguration(c12); - config12.set("defaultLife", lifes); - try { - config12.save(c12); - } catch (final IOException e) { - e.printStackTrace(); - } - p.sendMessage("§aDefault lifes has been setted. To §e" + lifes + "§a."); - break; } } else { if (args.length < 1) { @@ -1006,60 +1002,60 @@ public class SetupCMD implements CommandExecutor { return true; } switch (args[0].toLowerCase()) { - case "player": - if (args.length < 4) { - sendStatsHelp(sender); - return true; - } - Player pl = Bukkit.getPlayer(args[1]); - if (pl == null) { - sender.sendMessage("Player with that name not found"); - return true; - } - PlayerStat ps = PlayerStat.getPlayerStat(pl); - if (ps == null) { - sender.sendMessage("Data for that player not found!"); - return true; - } - switch (args[2].toLowerCase()) { - case "give": - if (args[3].equalsIgnoreCase("exp")) { - ps.addXP(Integer.valueOf(args[4])); - sender.sendMessage("Exp updated"); - return true; - } - if (args[3].equalsIgnoreCase("coins")) { - ps.addCoins(Integer.valueOf(args[4])); - sender.sendMessage("Coins updated"); - return true; - } - break; - case "take": - if (args[3].equalsIgnoreCase("exp")) { - ps.removeXP(Integer.valueOf(args[4])); - sender.sendMessage("Exp updated"); + case "player": + if (args.length < 4) { + sendStatsHelp(sender); return true; } - if (args[3].equalsIgnoreCase("coins")) { - ps.removeCoins(Integer.valueOf(args[4])); - sender.sendMessage("Coins updated"); + Player pl = Bukkit.getPlayer(args[1]); + if (pl == null) { + sender.sendMessage("Player with that name not found"); return true; } - break; - case "set": - if (args[3].equalsIgnoreCase("exp")) { - ps.setXp(Integer.valueOf(args[4])); - sender.sendMessage("Exp updated"); + PlayerStat ps = PlayerStat.getPlayerStat(pl); + if (ps == null) { + sender.sendMessage("Data for that player not found!"); return true; } - if (args[3].equalsIgnoreCase("coins")) { - ps.setCoins(Integer.valueOf(args[4])); - sender.sendMessage("Coins updated"); - return true; + switch (args[2].toLowerCase()) { + case "give": + if (args[3].equalsIgnoreCase("exp")) { + ps.addXP(Integer.valueOf(args[4])); + sender.sendMessage("Exp updated"); + return true; + } + if (args[3].equalsIgnoreCase("coins")) { + ps.addCoins(Integer.valueOf(args[4])); + sender.sendMessage("Coins updated"); + return true; + } + break; + case "take": + if (args[3].equalsIgnoreCase("exp")) { + ps.removeXP(Integer.valueOf(args[4])); + sender.sendMessage("Exp updated"); + return true; + } + if (args[3].equalsIgnoreCase("coins")) { + ps.removeCoins(Integer.valueOf(args[4])); + sender.sendMessage("Coins updated"); + return true; + } + break; + case "set": + if (args[3].equalsIgnoreCase("exp")) { + ps.setXp(Integer.valueOf(args[4])); + sender.sendMessage("Exp updated"); + return true; + } + if (args[3].equalsIgnoreCase("coins")) { + ps.setCoins(Integer.valueOf(args[4])); + sender.sendMessage("Coins updated"); + return true; + } + break; } break; - } - break; } } return false; @@ -1075,16 +1071,16 @@ public class SetupCMD implements CommandExecutor { public void sendHelp(Player p) { p.sendMessage("§7§m---------------------------"); new FancyMessage("§a§lPLAYER COMMANDS").tooltip("§bShow player commands. §7(Click here)") - .command("/bridges help player").send(p); + .command("/bridges help player").send(p); if (p.hasPermission("bridges.admin")) { new FancyMessage("§a§lSETUP COMMANDS - ALL TYPES").tooltip("§bShow commands for all types. §7(Click here)") - .command("/bridges help all").send(p); + .command("/bridges help all").send(p); new FancyMessage("§a§lSETUP COMMANDS - LOBBY").tooltip("§bShow commands for lobby. §7(Click here)") - .command("/bridges help lobby").send(p); + .command("/bridges help lobby").send(p); new FancyMessage("§a§lSETUP COMMANDS - NORMAL").tooltip("§bShow commands for normal type. §7(Click here)") - .command("/bridges help normal").send(p); + .command("/bridges help normal").send(p); new FancyMessage("§a§lSETUP COMMANDS - FOUR").tooltip("§bShow commands for four type. §7(Click here)") - .command("/bridges help four").send(p); + .command("/bridges help four").send(p); } p.sendMessage("§7§m---------------------------"); } @@ -1116,14 +1112,14 @@ public class SetupCMD implements CommandExecutor { new FancyMessage("§b/bridges settype NORMAL/FOUR").tooltip("§eSet type of Arena.").send(p); new FancyMessage("§b/bridges setstarting ").tooltip("§eSet starting time to arena.").send(p); new FancyMessage("§b/bridges setprestarting ").tooltip("§eSet prestarting time to arena.") - .send(p); + .send(p); new FancyMessage("§b/bridges setrestart ").tooltip("§eSet restart time to arena.").send(p); new FancyMessage("§b/bridges setspect ").tooltip("§eSet Spect location.").send(p); new FancyMessage("§b/bridges setlobby ").tooltip("§eSet Lobby location.").send(p); new FancyMessage("§b/bridges setteamsize ").tooltip("§eSet team size to arena.").send(p); new FancyMessage("§b/bridges setmin ").tooltip("§eSet min players to arena.").send(p); new FancyMessage("§b/bridges setbuild ") - .tooltip("§eSet build location. §c(You first need has selected MIN and MAX locations)").send(p); + .tooltip("§eSet build location. §c(You first need has selected MIN and MAX locations)").send(p); new FancyMessage("§b/bridges save ").tooltip("§eSave the sand in the Maps folder.").send(p); p.sendMessage("§7§m---------------------------"); } @@ -1133,7 +1129,7 @@ public class SetupCMD implements CommandExecutor { new FancyMessage("§b/bridges setspawn BLUE/RED").tooltip("§eSet the spawn point of the cage.").send(p); new FancyMessage("§b/bridges setrespawn BLUE/RED").tooltip("§eSet the spawn point of respawn.").send(p); new FancyMessage("§b/bridges setportal BLUE/RED") - .tooltip("§eSet portal of team. §c(You need has selected MIN and MAX locations)").send(p); + .tooltip("§eSet portal of team. §c(You need has selected MIN and MAX locations)").send(p); new FancyMessage("§b/bridges setmaxgoals ").tooltip("§eSet max goals to arena.").send(p); p.sendMessage("§7§m---------------------------"); } @@ -1141,11 +1137,11 @@ public class SetupCMD implements CommandExecutor { public void sendFourTypeCommands(Player p) { p.sendMessage("§7§m---------------------------"); new FancyMessage("§b/bridges setspawn BLUE/RED/GREEN/YELLOW") - .tooltip("§eSet the spawn point of the cage.").send(p); + .tooltip("§eSet the spawn point of the cage.").send(p); new FancyMessage("§b/bridges setrespawn BLUE/RED/GREEN/YELLOW") - .tooltip("§eSet the spawn point of respawn.").send(p); + .tooltip("§eSet the spawn point of respawn.").send(p); new FancyMessage("§b/bridges setportal BLUE/RED/GREEN/YELLOW") - .tooltip("§eSet portal of team. §c(You need has selected MIN and MAX locations)").send(p); + .tooltip("§eSet portal of team. §c(You need has selected MIN and MAX locations)").send(p); new FancyMessage("§b/bridges setstartlife ").tooltip("§eSet start lifes to arena.").send(p); p.sendMessage("§7§m---------------------------"); } diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/cosmetics/Particle.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/cosmetics/Particle.java index 35306f4..1724a96 100644 --- a/MultiArena-TheBridge/src/cx/sfy/TheBridge/cosmetics/Particle.java +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/cosmetics/Particle.java @@ -37,10 +37,9 @@ public class Particle { this.plugin = plugin; this.icon = new ItemStack(Material.valueOf(plugin.getParticles().get(path + ".icon")), plugin.getParticles().getInt(path + ".amount"), (short) plugin.getParticles().getInt(path + ".data")); - this.lore = new ArrayList(); - for (String l : plugin.getParticles().getList(path + ".description")) { + this.lore = new ArrayList<>(); + for (String l : plugin.getParticles().getList(path + ".description")) lore.add(l.replaceAll("&", "§")); - } this.id = id; this.name = plugin.getParticles().get(path + ".name"); this.permission = plugin.getParticles().get(path + ".permission"); @@ -54,17 +53,14 @@ public class Particle { public ItemStack getHasIcon() { ItemStack perm = icon; ItemMeta permM = perm.getItemMeta(); - List nLore = new ArrayList(); - ; - for (String msg : plugin.getParticles().getList("unlocked")) { - if (msg.contains("")) { - for (String l : lore) { + List nLore = new ArrayList<>(); + + for (String msg : plugin.getParticles().getList("unlocked")) + if (msg.contains("")) + for (String l : lore) nLore.add(l); - } - } else { + else nLore.add(msg.replaceAll("&", "§").replaceAll("", String.valueOf(price))); - } - } permM.setLore(nLore); permM.setDisplayName("§a" + name); perm.setItemMeta(permM); @@ -74,17 +70,14 @@ public class Particle { public ItemStack getPermIcon() { ItemStack perm = icon; ItemMeta permM = perm.getItemMeta(); - List nLore = new ArrayList(); - ; - for (String msg : plugin.getParticles().getList("noPerm")) { - if (msg.contains("")) { - for (String l : lore) { + List nLore = new ArrayList<>(); + + for (String msg : plugin.getParticles().getList("noPerm")) + if (msg.contains("")) + for (String l : lore) nLore.add(l); - } - } else { + else nLore.add(msg.replaceAll("&", "§").replaceAll("", String.valueOf(price))); - } - } permM.setLore(nLore); permM.setDisplayName("§c" + name); perm.setItemMeta(permM); @@ -94,17 +87,14 @@ public class Particle { public ItemStack getBuyIcon() { ItemStack perm = icon; ItemMeta permM = perm.getItemMeta(); - List nLore = new ArrayList(); - ; - for (String msg : plugin.getParticles().getList("locked")) { - if (msg.contains("")) { - for (String l : lore) { + List nLore = new ArrayList<>(); + + for (String msg : plugin.getParticles().getList("locked")) + if (msg.contains("")) + for (String l : lore) nLore.add(l); - } - } else { + else nLore.add(msg.replaceAll("&", "§").replaceAll("", String.valueOf(price))); - } - } permM.setLore(nLore); permM.setDisplayName("§c" + name); perm.setItemMeta(permM); diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/game/InventoryData.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/game/InventoryData.java index 599e052..8c92bd2 100644 --- a/MultiArena-TheBridge/src/cx/sfy/TheBridge/game/InventoryData.java +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/game/InventoryData.java @@ -13,13 +13,13 @@ import org.bukkit.scheduler.BukkitRunnable; import cx.sfy.TheBridge.Main; public class InventoryData { - - private static HashMap inventoryData = new HashMap(); + + private static HashMap inventoryData = new HashMap<>(); private UUID uuid; private Inventory inv; private ItemStack[] armor; private boolean restored; - + public InventoryData(Player p) { this.uuid = p.getUniqueId(); this.armor = p.getInventory().getArmorContents(); @@ -30,13 +30,12 @@ public class InventoryData { p.getInventory().clear(); p.getInventory().setArmorContents(null); } - + public void restore() { if (!restored) { Player p = this.getPlayer(); - if (p == null) { + if (p == null) return; - } if (Main.get().isStop()) { p.getInventory().setContents(inv.getContents()); p.getInventory().setArmorContents(armor); @@ -56,15 +55,15 @@ public class InventoryData { }.runTaskLater(Main.get(), 1); } } - + public Player getPlayer() { return Bukkit.getPlayer(uuid); } - + public UUID getUUID() { return uuid; } - + public static void remove(Player p) { inventoryData.remove(p); } @@ -74,10 +73,9 @@ public class InventoryData { } public static InventoryData getInventoryData(Player p) { - if (inventoryData.containsKey(p)) { + if (inventoryData.containsKey(p)) return inventoryData.get(p); - } return null; } - + } \ No newline at end of file diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/game/PlayerData.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/game/PlayerData.java index e4fe15f..8f1d7dd 100644 --- a/MultiArena-TheBridge/src/cx/sfy/TheBridge/game/PlayerData.java +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/game/PlayerData.java @@ -46,9 +46,8 @@ public class PlayerData { public void restore() { if (!restored) { Player p = this.getPlayer(); - if (p == null) { + if (p == null) return; - } restored = true; p.closeInventory(); p.setGameMode(gm); @@ -66,9 +65,8 @@ public class PlayerData { Location respawn = Main.get().getMainLobby(); p.teleport(respawn, TeleportCause.END_PORTAL); Utils.setPlayerExperience(p, PlayerStat.getPlayerStat(p).getXp()); - if (!Main.get().isStop()) { + if (!Main.get().isStop()) Main.get().getTop().createInfo(p); - } } } diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/PlayerListener.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/PlayerListener.java index aaade11..340a700 100644 --- a/MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/PlayerListener.java +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/PlayerListener.java @@ -79,37 +79,43 @@ public class PlayerListener implements Listener { private BukkitTask task; public void sendArrowParticle(Player p, Entity e) { + if (plugin.getPam().getParticleByName("arrow", PlayerStat.getPlayerStat(p).getArrow_trail()).getTrail() + .equalsIgnoreCase("EMPTY")) + return; task = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, () -> { Location loc = e.getLocation(); - if (e.isOnGround() || e.getLocation().getY() < 10) { + if (e.isOnGround() || e.getLocation().getY() < 10 || leaving.contains(p)) { task.cancel(); + return; } createTrail(loc, plugin.getPam().getParticleByName("arrow", PlayerStat.getPlayerStat(p).getArrow_trail())); }, 0, 1); } public void sendFeetParticle(Player p) { - if (p.isFlying() || p.hasPotionEffect(PotionEffectType.INVISIBILITY) || p.getGameMode() == GameMode.SPECTATOR) { + if (plugin.getPam().getParticleByName("arrow", PlayerStat.getPlayerStat(p).getArrow_trail()).getTrail() + .equalsIgnoreCase("EMPTY")) + return; + if (p.isFlying() || p.hasPotionEffect(PotionEffectType.INVISIBILITY) || p.getGameMode() == GameMode.SPECTATOR + || leaving.contains(p)) return; - } Location loc = p.getLocation(); createTrail(loc, plugin.getPam().getParticleByName("feet", PlayerStat.getPlayerStat(p).getFeet_trail())); } public void createTrail(Location loc, cx.sfy.TheBridge.cosmetics.Particle particle) { plugin.getNms().sendParticle(ParticleType.valueOf(particle.getTrail()), 1, particle.getAmmount(), 0.05) - .sendToLocation(loc); + .sendToLocation(loc); } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onShoot(ProjectileLaunchEvent e) { - if (e.getEntity().getShooter() instanceof Player) { + if (e.getEntity().getShooter() instanceof Player) if (e.getEntity() instanceof Arrow) { Player p = (Player) e.getEntity().getShooter(); if (plugin.getGm().getGameByPlayer(p) != null || plugin.getGm().getGameFourByPlayer(p) != null) sendArrowParticle(p, e.getEntity()); } - } } @EventHandler @@ -300,7 +306,7 @@ public class PlayerListener implements Listener { } if (item.getType().equals(Material.REDSTONE_COMPARATOR) || item.getType().equals(Material.REDSTONE_COMPARATOR_OFF) && item.getItemMeta().getDisplayName() - .equals(plugin.getLang().get("items.config.nameItem"))) { + .equals(plugin.getLang().get("items.config.nameItem"))) { e.setCancelled(true); plugin.getSom().openOptionsMenu(p); } @@ -319,6 +325,7 @@ public class PlayerListener implements Listener { } }.runTaskLater(plugin, 20); } + return; } } if (plugin.getGm().getGameByPlayer(p) != null) { @@ -339,16 +346,19 @@ public class PlayerListener implements Listener { if (!leaving.contains(p)) { leaving.add(p); new BukkitRunnable() { + @Override public void run() { leaving.remove(p); } }.runTaskLater(plugin, 20); } + return; } } if (plugin.getGm().getGameFourByPlayer(p) == null && plugin.getGm().getGameByPlayer(p) == null) { if (p.getItemInHand() != null && p.getItemInHand().getType() != Material.AIR) { + final ItemStack item = p.getItemInHand(); if (item.hasItemMeta()) { if (plugin.getConfig().getBoolean("items.menu.enabled")) { @@ -370,23 +380,42 @@ public class PlayerListener implements Listener { plugin.getConfig().getString("items.random.nameItem").replaceAll("&", "§"), plugin.getConfig().getString("items.random.loreItem").replaceAll("&", "§")); if (item.equals(random)) { - GameDuo g = null; - int alto = 0; - for (final GameDuo game : plugin.getGm().getGames()) { - if (game.isState(State.FINISH) || game.isState(State.INGAME) - || game.isState(State.RESTARTING) || game.isState(State.PREGAME)) - continue; - if (game.getPlayers() == game.getMax()) - continue; - if (game.getPlayers() <= alto) { - g = game; - alto = game.getPlayers(); + int rand = (int) (Math.random() * 1); + if (rand == 0) { + GameDuo g = null; + for (final GameDuo game : plugin.getGm().getGames()) { + if (game.isState(State.FINISH) || game.isState(State.INGAME) + || game.isState(State.RESTARTING) || game.isState(State.PREGAME)) + continue; + if (game.getPlayers() == game.getMax()) + continue; + if (game.getPlayers() < game.getMax()) { + g = game; + break; + } } + if (g != null) + plugin.getGm().addPlayerGame(p, g); + else + p.sendMessage(plugin.getLang().get("messages.noGames")); + } else if (rand == 1) { + GameFour g = null; + for (final GameFour game : plugin.getGm().getGamesFour()) { + if (game.isState(FState.FINISH) || game.isState(FState.INGAME) + || game.isState(FState.RESTARTING) || game.isState(FState.PREGAME)) + continue; + if (game.getPlayers().size() == game.getMax()) + continue; + if (game.getPlayers().size() < game.getMax()) { + g = game; + break; + } + } + if (g != null) + plugin.getGm().addPlayerGameFour(p, g); + else + p.sendMessage(plugin.getLang().get("messages.noGames")); } - if (g != null) - plugin.getGm().addPlayerGame(p, g); - else - p.sendMessage(plugin.getLang().get("messages.noGames")); } } if (plugin.getConfig().getBoolean("items.hotbar.enabled")) { @@ -440,9 +469,9 @@ public class PlayerListener implements Listener { } catch (Exception ex) { ex.printStackTrace(); plugin.getServer().getConsoleSender() - .sendMessage(ChatColor.RED + "Server " + ChatColor.YELLOW - + plugin.getConfig().getString("items.lobby.server") + ChatColor.RED - + " not found... Please check you config!"); + .sendMessage(ChatColor.RED + "Server " + ChatColor.YELLOW + + plugin.getConfig().getString("items.lobby.server") + ChatColor.RED + + " not found... Please check you config!"); } } } @@ -489,9 +518,8 @@ public class PlayerListener implements Listener { final Player p = e.getPlayer(); if (plugin.getGm().getGameByPlayer(p) != null) { final GameDuo game = plugin.getGm().getGameByPlayer(p); - if (e.getFrom() != e.getTo()) { + if (e.getFrom() != e.getTo()) sendFeetParticle(p); - } if (game.isState(State.WAITING) || game.isState(State.STARTING) || game.isState(State.FINISH)) if (p.getLocation().getY() < 30) p.teleport(game.getLobby()); @@ -516,9 +544,8 @@ public class PlayerListener implements Listener { } if (plugin.getGm().getGameFourByPlayer(p) != null) { final GameFour game = plugin.getGm().getGameFourByPlayer(p); - if (e.getFrom() != e.getTo()) { + if (e.getFrom() != e.getTo()) sendFeetParticle(p); - } if (game.isState(FState.WAITING) || game.isState(FState.STARTING) || game.isState(FState.FINISH)) if (p.getLocation().getY() < 30) p.teleport(game.getLobby()); @@ -527,28 +554,28 @@ public class PlayerListener implements Listener { if (!game.getTeams().get(ChatColor.RED).getDeath() && !game.getTeamPlayer(p).getColor().equals(ChatColor.RED) && game.getTeams().get(ChatColor.RED).getPortal() - .contains(p.getLocation().getBlock().getLocation())) { + .contains(p.getLocation().getBlock().getLocation())) { game.celebrateGoal(game.getTeamPlayer(p), game.getTeams().get(ChatColor.RED), p); return; } if (!game.getTeams().get(ChatColor.BLUE).getDeath() && !game.getTeamPlayer(p).getColor().equals(ChatColor.BLUE) && game.getTeams().get(ChatColor.BLUE).getPortal() - .contains(p.getLocation().getBlock().getLocation())) { + .contains(p.getLocation().getBlock().getLocation())) { game.celebrateGoal(game.getTeamPlayer(p), game.getTeams().get(ChatColor.BLUE), p); return; } if (!game.getTeams().get(ChatColor.YELLOW).getDeath() && !game.getTeamPlayer(p).getColor().equals(ChatColor.YELLOW) && game.getTeams().get(ChatColor.YELLOW).getPortal() - .contains(p.getLocation().getBlock().getLocation())) { + .contains(p.getLocation().getBlock().getLocation())) { game.celebrateGoal(game.getTeamPlayer(p), game.getTeams().get(ChatColor.YELLOW), p); return; } if (!game.getTeams().get(ChatColor.GREEN).getDeath() && !game.getTeamPlayer(p).getColor().equals(ChatColor.GREEN) && game.getTeams().get(ChatColor.GREEN).getPortal() - .contains(p.getLocation().getBlock().getLocation())) { + .contains(p.getLocation().getBlock().getLocation())) { game.celebrateGoal(game.getTeamPlayer(p), game.getTeams().get(ChatColor.GREEN), p); return; } @@ -714,7 +741,7 @@ public class PlayerListener implements Listener { e.setCancelled(true); if (e.getClickedInventory().getTitle().equals(plugin.getLang().get("menus.hotbar.title"))) if (e.getSlot() == 53 || e.getSlot() == 52 || e.getSlot() == 51 || e.getSlot() == 48 - || e.getSlot() == 47 || e.getSlot() == 46 || e.getSlot() == 45) + || e.getSlot() == 47 || e.getSlot() == 46 || e.getSlot() == 45) e.setCancelled(true); } } @@ -845,7 +872,7 @@ public class PlayerListener implements Listener { else if (cage.isBuy() && cage.getPrice() <= PlayerStat.getPlayerStat(p).getCoins()) { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), plugin.getConfig().getString("permFormat").replaceAll("", p.getName()) - .replaceAll("", cage.getPermission())); + .replaceAll("", cage.getPermission())); PlayerStat.getPlayerStat(p).removeCoins(cage.getPrice()); p.getOpenInventory().close(); new BukkitRunnable() { @@ -879,10 +906,11 @@ public class PlayerListener implements Listener { else if (arrow.isBuy() && arrow.getPrice() <= PlayerStat.getPlayerStat(p).getCoins()) { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), plugin.getConfig().getString("permFormat").replaceAll("", p.getName()) - .replaceAll("", arrow.getPermission())); + .replaceAll("", arrow.getPermission())); PlayerStat.getPlayerStat(p).removeCoins(arrow.getPrice()); p.getOpenInventory().close(); new BukkitRunnable() { + @Override public void run() { plugin.getAtm().createArrowMenu(p); @@ -903,7 +931,9 @@ public class PlayerListener implements Listener { e.setCancelled(true); if (e.getCurrentItem() == null || e.getCurrentItem().getType() == Material.AIR) return; - for (final cx.sfy.TheBridge.cosmetics.Particle feet : plugin.getPam().getFeet_trails().values()) + for ( + + final cx.sfy.TheBridge.cosmetics.Particle feet : plugin.getPam().getFeet_trails().values()) if (feet.getSlot() == e.getSlot()) if (!p.hasPermission(feet.getPermission())) { if (!feet.isBuy()) @@ -913,7 +943,7 @@ public class PlayerListener implements Listener { else if (feet.isBuy() && feet.getPrice() <= PlayerStat.getPlayerStat(p).getCoins()) { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), plugin.getConfig().getString("permFormat").replaceAll("", p.getName()) - .replaceAll("", feet.getPermission())); + .replaceAll("", feet.getPermission())); PlayerStat.getPlayerStat(p).removeCoins(feet.getPrice()); p.getOpenInventory().close(); new BukkitRunnable() { @@ -1108,11 +1138,11 @@ public class PlayerListener implements Listener { game.removeAllPlayerTeam(p); if (game.getTeams().get(ChatColor.BLUE).getTeamSize() < game.getTeamSize() && game.getTeams().get(ChatColor.BLUE).getTeamSize() <= game.getTeams().get(ChatColor.RED) - .getTeamSize() + .getTeamSize() && game.getTeams().get(ChatColor.BLUE).getTeamSize() <= game.getTeams() - .get(ChatColor.YELLOW).getTeamSize() + .get(ChatColor.YELLOW).getTeamSize() && game.getTeams().get(ChatColor.BLUE).getTeamSize() <= game.getTeams().get(ChatColor.GREEN) - .getTeamSize()) { + .getTeamSize()) { game.addPlayerTeam(p, game.getTeams().get(ChatColor.BLUE)); p.sendMessage(plugin.getLang().get("messages.joinedTeam").replaceAll("", "§9" + plugin.getConfig().getString("names.blue"))); @@ -1134,11 +1164,11 @@ public class PlayerListener implements Listener { game.removeAllPlayerTeam(p); if (game.getTeams().get(ChatColor.RED).getTeamSize() < game.getTeamSize() && game.getTeams().get(ChatColor.RED).getTeamSize() <= game.getTeams().get(ChatColor.BLUE) - .getTeamSize() + .getTeamSize() && game.getTeams().get(ChatColor.RED).getTeamSize() <= game.getTeams().get(ChatColor.YELLOW) - .getTeamSize() + .getTeamSize() && game.getTeams().get(ChatColor.RED).getTeamSize() <= game.getTeams().get(ChatColor.GREEN) - .getTeamSize()) { + .getTeamSize()) { game.addPlayerTeam(p, game.getTeams().get(ChatColor.RED)); p.sendMessage(plugin.getLang().get("messages.joinedTeam").replaceAll("", "§c" + plugin.getConfig().getString("names.red"))); @@ -1160,11 +1190,11 @@ public class PlayerListener implements Listener { game.removeAllPlayerTeam(p); if (game.getTeams().get(ChatColor.GREEN).getTeamSize() < game.getTeamSize() && game.getTeams().get(ChatColor.GREEN).getTeamSize() <= game.getTeams().get(ChatColor.RED) - .getTeamSize() + .getTeamSize() && game.getTeams().get(ChatColor.GREEN).getTeamSize() <= game.getTeams() - .get(ChatColor.YELLOW).getTeamSize() + .get(ChatColor.YELLOW).getTeamSize() && game.getTeams().get(ChatColor.GREEN).getTeamSize() <= game.getTeams().get(ChatColor.BLUE) - .getTeamSize()) { + .getTeamSize()) { game.addPlayerTeam(p, game.getTeams().get(ChatColor.GREEN)); p.sendMessage(plugin.getLang().get("messages.joinedTeam").replaceAll("", "§a" + plugin.getConfig().getString("names.green"))); @@ -1186,11 +1216,11 @@ public class PlayerListener implements Listener { game.removeAllPlayerTeam(p); if (game.getTeams().get(ChatColor.YELLOW).getTeamSize() < game.getTeamSize() && game.getTeams().get(ChatColor.YELLOW).getTeamSize() <= game.getTeams().get(ChatColor.RED) - .getTeamSize() + .getTeamSize() && game.getTeams().get(ChatColor.YELLOW).getTeamSize() <= game.getTeams() - .get(ChatColor.BLUE).getTeamSize() + .get(ChatColor.BLUE).getTeamSize() && game.getTeams().get(ChatColor.YELLOW).getTeamSize() <= game.getTeams() - .get(ChatColor.GREEN).getTeamSize()) { + .get(ChatColor.GREEN).getTeamSize()) { game.addPlayerTeam(p, game.getTeams().get(ChatColor.YELLOW)); p.sendMessage(plugin.getLang().get("messages.joinedTeam").replaceAll("", "§e" + plugin.getConfig().getString("names.yellow"))); @@ -1206,7 +1236,7 @@ public class PlayerListener implements Listener { public void onShoot(EntityShootBowEvent e) { if (e.getEntity() instanceof Player) { final Player p = (Player) e.getEntity(); - if (plugin.getGm().getGameFourByPlayer(p) != null || plugin.getGm().getGameByPlayer(p) != null) { + if (plugin.getGm().getGameFourByPlayer(p) != null || plugin.getGm().getGameByPlayer(p) != null) if (bow.contains(p)) { p.sendMessage(plugin.getLang().get("messages.noShoot")); e.setCancelled(true); @@ -1214,7 +1244,6 @@ public class PlayerListener implements Listener { timeBow(p); bow.add(p); } - } } } @@ -1339,37 +1368,39 @@ public class PlayerListener implements Listener { p.setHealth(p.getMaxHealth()); if (plugin.getConfig().getBoolean("remove.absorption") == true) new BukkitRunnable() { - @Override - public void run() { - p.removePotionEffect(PotionEffectType.ABSORPTION); - } - }.runTaskLater(plugin, 1); + @Override + public void run() { + p.removePotionEffect(PotionEffectType.ABSORPTION); + } + }.runTaskLater(plugin, 1); if (plugin.getConfig().getBoolean("remove.regeneration") == true) new BukkitRunnable() { - @Override - public void run() { - p.removePotionEffect(PotionEffectType.REGENERATION); - } - }.runTaskLater(plugin, 1); + @Override + public void run() { + p.removePotionEffect(PotionEffectType.REGENERATION); + } + }.runTaskLater(plugin, 1); } if (plugin.getGm().getGameFourByPlayer(p) != null) if (e.getItem().getType().equals(Material.GOLDEN_APPLE)) { p.setHealth(p.getMaxHealth()); if (plugin.getConfig().getBoolean("remove.absorption") == true) new BukkitRunnable() { - @Override - public void run() { - p.removePotionEffect(PotionEffectType.ABSORPTION); - } - }.runTaskLater(plugin, 1); + + @Override + public void run() { + p.removePotionEffect(PotionEffectType.ABSORPTION); + } + }.runTaskLater(plugin, 1); if (plugin.getConfig().getBoolean("remove.regeneration") == true) new BukkitRunnable() { - @Override - public void run() { - p.removePotionEffect(PotionEffectType.REGENERATION); - } - }.runTaskLater(plugin, 1); + @Override + public void run() { + p.removePotionEffect(PotionEffectType.REGENERATION); + } + }.runTaskLater(plugin, 1); } + } @EventHandler @@ -1511,9 +1542,9 @@ public class PlayerListener implements Listener { .replaceAll("", game.getTeamPlayer(k).getColor() + "") .replaceAll("", d.getName()).replaceAll("", k.getName()) + plugin.getLang().get("deathMessages.player") - .replaceAll("", game.getTeamPlayer(d).getColor() + "") - .replaceAll("", game.getTeamPlayer(k).getColor() + "") - .replaceAll("", d.getName()).replaceAll("", k.getName())); + .replaceAll("", game.getTeamPlayer(d).getColor() + "") + .replaceAll("", game.getTeamPlayer(k).getColor() + "") + .replaceAll("", d.getName()).replaceAll("", k.getName())); else { final DamageCause cause = d.getLastDamageCause().getCause(); if (cause.equals(DamageCause.VOID)) @@ -1523,9 +1554,9 @@ public class PlayerListener implements Listener { .replaceAll("", game.getTeamPlayer(k).getColor() + "") .replaceAll("", d.getName()).replaceAll("", k.getName()) + plugin.getLang().get("deathMessages.player") - .replaceAll("", game.getTeamPlayer(d).getColor() + "") - .replaceAll("", game.getTeamPlayer(k).getColor() + "") - .replaceAll("", d.getName()).replaceAll("", k.getName())); + .replaceAll("", game.getTeamPlayer(d).getColor() + "") + .replaceAll("", game.getTeamPlayer(k).getColor() + "") + .replaceAll("", d.getName()).replaceAll("", k.getName())); else if (cause.equals(DamageCause.ENTITY_ATTACK)) for (final Player on : game.getGamePlayers()) on.sendMessage(plugin.getLang().get("deathMessages.damage") @@ -1533,9 +1564,9 @@ public class PlayerListener implements Listener { .replaceAll("", game.getTeamPlayer(k).getColor() + "") .replaceAll("", d.getName()).replaceAll("", k.getName()) + plugin.getLang().get("deathMessages.player") - .replaceAll("", game.getTeamPlayer(d).getColor() + "") - .replaceAll("", game.getTeamPlayer(k).getColor() + "") - .replaceAll("", d.getName()).replaceAll("", k.getName())); + .replaceAll("", game.getTeamPlayer(d).getColor() + "") + .replaceAll("", game.getTeamPlayer(k).getColor() + "") + .replaceAll("", d.getName()).replaceAll("", k.getName())); else for (final Player on : game.getGamePlayers()) on.sendMessage(plugin.getLang().get("deathMessages.custom") @@ -1543,9 +1574,9 @@ public class PlayerListener implements Listener { .replaceAll("", game.getTeamPlayer(k).getColor() + "") .replaceAll("", d.getName()).replaceAll("", k.getName()) + plugin.getLang().get("deathMessages.player") - .replaceAll("", game.getTeamPlayer(d).getColor() + "") - .replaceAll("", game.getTeamPlayer(k).getColor() + "") - .replaceAll("", d.getName()).replaceAll("", k.getName())); + .replaceAll("", game.getTeamPlayer(d).getColor() + "") + .replaceAll("", game.getTeamPlayer(k).getColor() + "") + .replaceAll("", d.getName()).replaceAll("", k.getName())); } } else { final GameDuo game = plugin.getGm().getGameByPlayer(d); @@ -1594,9 +1625,9 @@ public class PlayerListener implements Listener { .replaceAll("", game.getTeamPlayer(k).getColor() + "") .replaceAll("", d.getName()).replaceAll("", k.getName()) + plugin.getLang().get("deathMessages.player") - .replaceAll("", game.getTeamPlayer(d).getColor() + "") - .replaceAll("", game.getTeamPlayer(k).getColor() + "") - .replaceAll("", d.getName()).replaceAll("", k.getName())); + .replaceAll("", game.getTeamPlayer(d).getColor() + "") + .replaceAll("", game.getTeamPlayer(k).getColor() + "") + .replaceAll("", d.getName()).replaceAll("", k.getName())); else { final DamageCause cause = d.getLastDamageCause().getCause(); if (cause.equals(DamageCause.VOID)) @@ -1606,9 +1637,9 @@ public class PlayerListener implements Listener { .replaceAll("", game.getTeamPlayer(k).getColor() + "") .replaceAll("", d.getName()).replaceAll("", k.getName()) + plugin.getLang().get("deathMessages.player") - .replaceAll("", game.getTeamPlayer(d).getColor() + "") - .replaceAll("", game.getTeamPlayer(k).getColor() + "") - .replaceAll("", d.getName()).replaceAll("", k.getName())); + .replaceAll("", game.getTeamPlayer(d).getColor() + "") + .replaceAll("", game.getTeamPlayer(k).getColor() + "") + .replaceAll("", d.getName()).replaceAll("", k.getName())); else if (cause.equals(DamageCause.ENTITY_ATTACK)) for (final Player on : game.getPlayers()) on.sendMessage(plugin.getLang().get("deathMessages.damage") @@ -1616,9 +1647,9 @@ public class PlayerListener implements Listener { .replaceAll("", game.getTeamPlayer(k).getColor() + "") .replaceAll("", d.getName()).replaceAll("", k.getName()) + plugin.getLang().get("deathMessages.player") - .replaceAll("", game.getTeamPlayer(d).getColor() + "") - .replaceAll("", game.getTeamPlayer(k).getColor() + "") - .replaceAll("", d.getName()).replaceAll("", k.getName())); + .replaceAll("", game.getTeamPlayer(d).getColor() + "") + .replaceAll("", game.getTeamPlayer(k).getColor() + "") + .replaceAll("", d.getName()).replaceAll("", k.getName())); else for (final Player on : game.getPlayers()) on.sendMessage(plugin.getLang().get("deathMessages.custom") @@ -1626,9 +1657,9 @@ public class PlayerListener implements Listener { .replaceAll("", game.getTeamPlayer(k).getColor() + "") .replaceAll("", d.getName()).replaceAll("", k.getName()) + plugin.getLang().get("deathMessages.player") - .replaceAll("", game.getTeamPlayer(d).getColor() + "") - .replaceAll("", game.getTeamPlayer(k).getColor() + "") - .replaceAll("", d.getName()).replaceAll("", k.getName())); + .replaceAll("", game.getTeamPlayer(d).getColor() + "") + .replaceAll("", game.getTeamPlayer(k).getColor() + "") + .replaceAll("", d.getName()).replaceAll("", k.getName())); } } else { final GameFour game = plugin.getGm().getGameFourByPlayer(d); diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/GenericNMS.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/GenericNMS.java index b160481..3e8b421 100644 --- a/MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/GenericNMS.java +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/GenericNMS.java @@ -14,8 +14,8 @@ import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; import cx.sfy.TheBridge.packets.ParticleHandler; -import cx.sfy.TheBridge.packets.Reflection; import cx.sfy.TheBridge.packets.ParticleHandler.ParticleType; +import cx.sfy.TheBridge.packets.Reflection; public class GenericNMS implements NMS { @@ -45,14 +45,11 @@ public class GenericNMS implements NMS { @Override public ChunkData generateChunkData(World world, Random random, int cx, int cz, BiomeGrid biome) { final ChunkGenerator.ChunkData chunkData = this.createChunkData(world); - for (int x = 0; x < 16; ++x) { - for (int z = 0; z < 16; ++z) { + for (int x = 0; x < 16; ++x) + for (int z = 0; z < 16; ++z) biome.setBiome(x, z, bm()); - } - } - if (0 >= cx << 4 && 0 < cx + 1 << 4 && 0 >= cz << 4 && 0 < cz + 1 << 4) { + if (0 >= cx << 4 && 0 < cx + 1 << 4 && 0 >= cz << 4 && 0 < cz + 1 << 4) chunkData.setBlock(0, 81, 0, Material.STONE); - } return chunkData; } }; @@ -68,25 +65,25 @@ public class GenericNMS implements NMS { } final String s = serverVersion; switch (s) { - case "v1_8_R1": - case "v1_8_R2": - case "v1_8_R3": { - b = Biome.PLAINS; - break; - } - case "v1_9_R1": - case "v1_9_R2": - case "v1_10_R1": - case "v1_11_R1": - case "v1_12_R1": - case "v1_13_R1": { - b = Biome.valueOf("VOID"); - break; - } - default: { - b = Biome.valueOf("THE_VOID"); - break; - } + case "v1_8_R1": + case "v1_8_R2": + case "v1_8_R3": { + b = Biome.PLAINS; + break; + } + case "v1_9_R1": + case "v1_9_R2": + case "v1_10_R1": + case "v1_11_R1": + case "v1_12_R1": + case "v1_13_R1": { + b = Biome.valueOf("VOID"); + break; + } + default: { + b = Biome.valueOf("THE_VOID"); + break; + } } return b; } @@ -107,5 +104,5 @@ public class GenericNMS implements NMS { public ParticleHandler sendParticle(ParticleType type, double speed, int count, double radius) { return new ParticleHandler(type, speed, count, radius); } - + } diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/NMS.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/NMS.java index de5dfe4..0dfe556 100644 --- a/MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/NMS.java +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/NMS.java @@ -8,12 +8,12 @@ import cx.sfy.TheBridge.packets.ParticleHandler.ParticleType; public interface NMS { - public ChunkGenerator getChunkGenerator(); + ChunkGenerator getChunkGenerator(); - public void sendTitle(Player player, int fadein, int stay, int fadeout, String title, String subtitle); + void sendTitle(Player player, int fadein, int stay, int fadeout, String title, String subtitle); - public void sendActionBar(Player player, String s); + void sendActionBar(Player player, String s); - public ParticleHandler sendParticle(ParticleType type, double speed, int count, double radius); + ParticleHandler sendParticle(ParticleType type, double speed, int count, double radius); } \ No newline at end of file diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/ParticleHandler.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/ParticleHandler.java index a7d8388..24d6528 100644 --- a/MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/ParticleHandler.java +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/ParticleHandler.java @@ -12,40 +12,41 @@ import org.bukkit.Particle; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import lombok.Getter; + @SuppressWarnings({ "unchecked", "rawtypes" }) public class ParticleHandler { - private static Class packetClass = null; private static Constructor packetConstructor = null; - private static Field player_connection = null; - private static Method player_sendPacket = null; - private static HashMap, Method> handles = new HashMap, Method>(); + private static Field playerCon = null; + private static Method sendPacket = null; + private static HashMap, Method> handles = new HashMap<>(); - private static Class enumParticle = null; + private static Class enump = null; private ParticleType type; + @Getter private double speed; + @Getter private int count; + @Getter private double radius; public static void load() { - String vString = getVersion().replace("v", ""); - double v = 0; - if (!vString.isEmpty()) { - String[] array = vString.split("_"); - v = Double.parseDouble(array[0] + "." + array[1]); + String str = getVersion().replace("v", ""); + double version = 0; + if (!str.isEmpty()) { + String[] array = str.split("_"); + version = Double.parseDouble(array[0] + "." + array[1]); } try { - packetClass = getNmsClass("PacketPlayOutWorldParticles"); - if (v == 1.8) { - Bukkit.getLogger().info("[ParticleHandler] Hooking into Netty NMS classes"); - Bukkit.getLogger().info("[ParticleHandler] Version is " + v + " - using packet constructor"); - enumParticle = (Class) getNmsClass("EnumParticle"); - packetConstructor = packetClass.getDeclaredConstructor(enumParticle, boolean.class, float.class, - float.class, float.class, float.class, float.class, float.class, float.class, int.class, - int[].class); - } else { + if (version == 1.8) { + Bukkit.getLogger().info("[ParticleHandler] Version is " + version + " - using packet constructor"); + enump = (Class) getNmsClass("EnumParticle"); + packetConstructor = getNmsClass("PacketPlayOutWorldParticles").getDeclaredConstructor(enump, + boolean.class, float.class, float.class, float.class, float.class, float.class, float.class, + float.class, int.class, int[].class); + } else Bukkit.getLogger().info("[ParticleHandler] Hooking into the new particle system"); - } } catch (Exception ex) { ex.printStackTrace(); Bukkit.getLogger().severe("[ParticleHandler] Failed to initialize NMS components!"); @@ -59,18 +60,6 @@ public class ParticleHandler { this.radius = radius; } - public double getSpeed() { - return speed; - } - - public int getCount() { - return count; - } - - public double getRadius() { - return radius; - } - public void sendToLocation(Location location) { String vString = getVersion().replace("v", ""); double v = 0; @@ -78,29 +67,26 @@ public class ParticleHandler { String[] array = vString.split("_"); v = Double.parseDouble(array[0] + "." + array[1]); } - if (v == 1.8) { + if (v == 1.8) try { Object packet = createPacket(location); - for (Player player : Bukkit.getOnlinePlayers()) { + for (Player player : Bukkit.getOnlinePlayers()) sendPacket(player, packet); - } } catch (Exception e) { e.printStackTrace(); } - } else { - location.getWorld().spawnParticle(Particle.valueOf(type.getName().toUpperCase()), (float) location.getX(), - (float) location.getY(), (float) location.getZ(), this.count, (float) this.radius, - (float) this.radius, (float) this.radius, (float) this.speed); - } + else + location.getWorld().spawnParticle(Particle.valueOf(type.getParticle().toUpperCase()), + (float) location.getX(), (float) location.getY(), (float) location.getZ(), this.count, + (float) this.radius, (float) this.radius, (float) this.radius, (float) this.speed); } private Object createPacket(Location location) { try { - if (this.count <= 0) { + if (this.count <= 0) this.count = 1; - } Object packet; - Object particleType = enumParticle.getEnumConstants()[type.getId()]; + Object particleType = enump.getEnumConstants()[type.getId()]; packet = packetConstructor.newInstance(particleType, true, (float) location.getX(), (float) location.getY(), (float) location.getZ(), (float) this.radius, (float) this.radius, (float) this.radius, (float) this.speed, this.count, new int[0]); @@ -120,15 +106,13 @@ public class ParticleHandler { private static void sendPacket(Player p, Object packet) throws IllegalArgumentException { try { - if (player_connection == null) { - player_connection = getHandle(p).getClass().getField("playerConnection"); - for (Method m : player_connection.get(getHandle(p)).getClass().getMethods()) { - if (m.getName().equalsIgnoreCase("sendPacket")) { - player_sendPacket = m; - } - } + if (playerCon == null) { + playerCon = getHandle(p).getClass().getField("playerConnection"); + for (Method m : playerCon.get(getHandle(p)).getClass().getMethods()) + if (m.getName().equalsIgnoreCase("sendPacket")) + sendPacket = m; } - player_sendPacket.invoke(player_connection.get(getHandle(p)), packet); + sendPacket.invoke(playerCon.get(getHandle(p)), packet); } catch (IllegalAccessException ex) { ex.printStackTrace(); Bukkit.getLogger().severe("[ParticleHandler] Failed to send packet!"); @@ -176,45 +160,60 @@ public class ParticleHandler { return ""; } + @Getter public enum ParticleType { - EXPLOSION_NORMAL("explode", 0, 17), EXPLOSION_LARGE("largeexplode", 1, 1), - EXPLOSION_HUGE("hugeexplosion", 2, 0), FIREWORKS_SPARK("fireworksSpark", 3, 2), WATER_BUBBLE("bubble", 4, 3), - WATER_SPLASH("splash", 5, 21), WATER_WAKE("wake", 6, -1), SUSPENDED("suspended", 7, 4), - SUSPENDED_DEPTH("depthsuspend", 8, 5), CRIT("crit", 9, 7), CRIT_MAGIC("magicCrit", 10, 8), - SMOKE_NORMAL("smoke", 11, -1), SMOKE_LARGE("largesmoke", 12, 22), SPELL("spell", 13, 11), - SPELL_INSTANT("instantSpell", 14, 12), SPELL_MOB("mobSpell", 15, 9), - SPELL_MOB_AMBIENT("mobSpellAmbient", 16, 10), SPELL_WITCH("witchMagic", 17, 13), - DRIP_WATER("dripWater", 18, 27), DRIP_LAVA("dripLava", 19, 28), VILLAGER_ANGRY("angryVillager", 20, 31), - VILLAGER_HAPPY("happyVillager", 21, 32), TOWN_AURA("townaura", 22, 6), NOTE("note", 23, 24), - PORTAL("portal", 24, 15), ENCHANTMENT_TABLE("enchantmenttable", 25, 16), FLAME("flame", 26, 18), - LAVA("lava", 27, 19), FOOTSTEP("footstep", 28, 20), CLOUD("cloud", 29, 23), REDSTONE("reddust", 30, 24), - SNOWBALL("snowballpoof", 31, 25), SNOW_SHOVEL("snowshovel", 32, 28), SLIME("slime", 33, 29), - HEART("heart", 34, 30), BARRIER("barrier", 35, -1), ITEM_CRACK("iconcrack_", 36, 33), - BLOCK_CRACK("tilecrack_", 37, 34), BLOCK_DUST("blockdust_", 38, -1), WATER_DROP("droplet", 39, -1), - ITEM_TAKE("take", 40, -1), MOB_APPEARANCE("mobappearance", 41, -1); - - private String name; + CRIT("crit", 9, 7), + CRIT_MAGIC("magicCrit", 10, 8), + SMOKE_NORMAL("smoke", 11, -1), + SMOKE_LARGE("largesmoke", 12, 22), + SPELL("spell", 13, 11), + SPELL_INSTANT("instantSpell", 14, 12), + SPELL_MOB("mobSpell", 15, 9), + SPELL_MOB_AMBIENT("mobSpellAmbient", 16, 10), + SLIME("slime", 33, 29), + HEART("heart", 34, 30), + BARRIER("barrier", 35, -1), + ITEM_CRACK("iconcrack_", 36, 33), + BLOCK_CRACK("tilecrack_", 37, 34), + BLOCK_DUST("blockdust_", 38, -1), + SPELL_WITCH("witchMagic", 17, 13), + DRIP_WATER("dripWater", 18, 27), + DRIP_LAVA("dripLava", 19, 28), + VILLAGER_ANGRY("angryVillager", 20, 31), + VILLAGER_HAPPY("happyVillager", 21, 32), + TOWN_AURA("townaura", 22, 6), + EXPLOSION_NORMAL("explode", 0, 17), + EXPLOSION_LARGE("largeexplode", 1, 1), + EXPLOSION_HUGE("hugeexplosion", 2, 0), + FIREWORKS_SPARK("fireworksSpark", 3, 2), + WATER_BUBBLE("bubble", 4, 3), + WATER_SPLASH("splash", 5, 21), + WATER_WAKE("wake", 6, -1), + SUSPENDED("suspended", 7, 4), + SUSPENDED_DEPTH("depthsuspend", 8, 5), + NOTE("note", 23, 24), + PORTAL("portal", 24, 15), + ENCHANTMENT_TABLE("enchantmenttable", 25, 16), + FLAME("flame", 26, 18), + LAVA("lava", 27, 19), + FOOTSTEP("footstep", 28, 20), + CLOUD("cloud", 29, 23), + REDSTONE("reddust", 30, 24), + SNOWBALL("snowballpoof", 31, 25), + SNOW_SHOVEL("snowshovel", 32, 28), + WATER_DROP("droplet", 39, -1), + ITEM_TAKE("take", 40, -1), + MOB_APPEARANCE("mobappearance", 41, -1); + + private String particle; private int id; - private int legacyId; + private int legId; - ParticleType(String name, int id, int legacyId) { - this.name = name; + ParticleType(String particle, int id, int legId) { + this.particle = particle; this.id = id; - this.legacyId = legacyId; - } - - String getName() { - return name; - } - - int getId() { - return id; - } - - int getLegacyId() { - return legacyId; + this.legId = legId; } } - }