public void clean() { PlayerInventory inv = this.player.getInventory(); inv.setArmorContents(new ItemStack[4]); inv.setContents(new ItemStack[] {}); this.player.setAllowFlight(false); this.player.setFlying(false); this.player.setExp(0.0F); this.player.setLevel(0); this.player.setSneaking(false); this.player.setSprinting(false); this.player.setFoodLevel(20); this.player.setMaxHealth(20.0D); this.player.setHealth(20.0D); this.player.setFireTicks(0); this.player.setGameMode(GameMode.SURVIVAL); boolean teamnameOnTab = Main.getInstance().getBooleanConfig("teamname-on-tab", true); boolean overwriteNames = Main.getInstance().getBooleanConfig("overwrite-names", false); if (overwriteNames) { Game game = Main.getInstance().getGameManager().getGameOfPlayer(this.player); if (game != null) { Team team = game.getPlayerTeam(this.player); if (team != null) { this.player.setDisplayName(team.getChatColor() + this.player.getName()); } else { this.player.setDisplayName(this.player.getName()); } } } if (teamnameOnTab && Utils.isSupportingTitles()) { Game game = Main.getInstance().getGameManager().getGameOfPlayer(this.player); if (game != null) { Team team = game.getPlayerTeam(this.player); if (team != null) { this.player.setPlayerListName( team.getChatColor() + team.getName() + ChatColor.WHITE + " | " + team.getChatColor() + this.player.getName()); } else { this.player.setPlayerListName(this.player.getName()); } } } if (this.player.isInsideVehicle()) { this.player.leaveVehicle(); } for (PotionEffect e : this.player.getActivePotionEffects()) { this.player.removePotionEffect(e.getType()); } this.player.updateInventory(); }
@SuppressWarnings("deprecation") public void openTeamSelection(Game game) { BedwarsOpenTeamSelectionEvent openEvent = new BedwarsOpenTeamSelectionEvent(game, this.player); Main.getInstance().getServer().getPluginManager().callEvent(openEvent); if (openEvent.isCancelled()) { return; } HashMap<String, Team> teams = game.getTeams(); int nom = (teams.size() % 9 == 0) ? 9 : (teams.size() % 9); Inventory inv = Bukkit.createInventory(this.player, teams.size() + (9 - nom), Main._l("lobby.chooseteam")); for (Team team : teams.values()) { List<Player> players = team.getPlayers(); if (players.size() >= team.getMaxPlayers()) { continue; } ItemStack is = new ItemStack(Material.WOOL, 1, team.getColor().getDyeColor().getData()); ItemMeta im = is.getItemMeta(); im.setDisplayName(team.getChatColor() + team.getName()); ArrayList<String> teamplayers = new ArrayList<>(); int teamPlayerSize = team.getPlayers().size(); int maxPlayers = team.getMaxPlayers(); String current = "0"; if (teamPlayerSize >= maxPlayers) { current = ChatColor.RED + String.valueOf(teamPlayerSize); } else { current = ChatColor.YELLOW + String.valueOf(teamPlayerSize); } teamplayers.add( ChatColor.GRAY + "(" + current + ChatColor.GRAY + "/" + ChatColor.YELLOW + String.valueOf(maxPlayers) + ChatColor.GRAY + ")"); teamplayers.add(ChatColor.WHITE + "---------"); for (Player teamPlayer : players) { teamplayers.add(team.getChatColor() + teamPlayer.getName()); } im.setLore(teamplayers); is.setItemMeta(im); inv.addItem(is); } this.player.openInventory(inv); }
public void loadLobbyInventory(Game game) { ItemMeta im = null; // choose team only when autobalance is disabled if (!game.isAutobalanceEnabled()) { // Choose team (Wool) ItemStack teamSelection = new ItemStack(Material.BED, 1); im = teamSelection.getItemMeta(); im.setDisplayName(Main._l("lobby.chooseteam")); teamSelection.setItemMeta(im); this.player.getInventory().addItem(teamSelection); } // Leave Game (Slimeball) ItemStack leaveGame = new ItemStack(Material.SLIME_BALL, 1); im = leaveGame.getItemMeta(); im.setDisplayName(Main._l("lobby.leavegame")); leaveGame.setItemMeta(im); this.player.getInventory().setItem(8, leaveGame); Team team = game.getPlayerTeam(this.player); if (team != null) { ItemStack chestplate = new ItemStack(Material.LEATHER_CHESTPLATE, 1); LeatherArmorMeta meta = (LeatherArmorMeta) chestplate.getItemMeta(); meta.setDisplayName(team.getChatColor() + team.getDisplayName()); meta.setColor(team.getColor().getColor()); chestplate.setItemMeta(meta); this.player.getInventory().setItem(7, chestplate); team.equipPlayerWithLeather(this.player); } if (this.player.hasPermission("bw.setup") || this.player.isOp() || this.player.hasPermission("bw.vip.forcestart")) { // Force start game (Diamond) ItemStack startGame = new ItemStack(Material.DIAMOND, 1); im = startGame.getItemMeta(); im.setDisplayName(Main._l("lobby.startgame")); startGame.setItemMeta(im); this.player.getInventory().addItem(startGame); } this.player.updateInventory(); }