@EventHandler public void onPlayerQuit(PlayerQuitEvent e) { Player p = e.getPlayer(); SPlayer player = new SPlayer(p); e.setQuitMessage(null); player.removePlayer(); }
@EventHandler public void onPlayerJoin(PlayerJoinEvent e) { FileConfiguration locationsFile = YamlConfiguration.loadConfiguration(Main.getInstance().locations); Player p = e.getPlayer(); SPlayer player = new SPlayer(p); int blue = Team.BLUE.getPlayers().size(); int red = Team.RED.getPlayers().size(); p.teleport(locationUtil.deserializeLoc(locationsFile.getString("arena.lobby"))); gameManager.setCarrying(p, 0); Scoreboard sb = Bukkit.getScoreboardManager().getNewScoreboard(); org.bukkit.scoreboard.Team r = sb.registerNewTeam("red"); r.setPrefix(Color.np("&c")); org.bukkit.scoreboard.Team b = sb.registerNewTeam("blue"); b.setPrefix(Color.np("&b")); for (Player online : Bukkit.getOnlinePlayers()) { Team team = teamManager.getTeam(online); if (team == Team.BLUE) { b.addEntry(online.getName()); } else { r.addEntry(online.getName()); } } p.setScoreboard(sb); e.setJoinMessage(null); if (blue <= red) { player.setTeam(Team.BLUE); } else { player.setTeam(Team.RED); } }