@Override public void onEnable() { plugin = this; GameState.setState(GameState.IN_LOBBY); Game.setCanStart(false); new Thread(new StartCountdown()).start(); registerListeners(); for (Player p : Bukkit.getOnlinePlayers()) { p.kickPlayer(ChatColor.GREEN + "Reloading. Rejoin."); } for (World w : Bukkit.getServer().getWorlds()) { w.setTime(0); w.setStorm(false); w.setWeatherDuration(9999999); for (Entity e : w.getEntities()) { e.remove(); } } PointSB.initializeScoreboard(); }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerJoinEvent(PlayerJoinEvent e) { e.setJoinMessage(""); Player p = e.getPlayer(); Game.players.add(p.getUniqueId()); p.setHealth(20.0); p.setExp(0); ChatUtilities.broadcast(e.getPlayer().getDisplayName() + " has joined!"); p.removePotionEffect(PotionEffectType.INVISIBILITY); p.setGameMode(GameMode.ADVENTURE); p.getInventory().clear(); p.getInventory().setHelmet(null); Game.setCanStart(Bukkit.getOnlinePlayers().size() >= 2); LocationUtilities.teleportToLobby(p); CraftPlayer craftplayer = (CraftPlayer) p; PlayerConnection connection = craftplayer.getHandle().playerConnection; IChatBaseComponent header = ChatSerializer.a("{\"text\": \" §3Villager Hunt \"}"); IChatBaseComponent footer = ChatSerializer.a("{\"text\": \" §4Development Test \"}"); PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter(); try { Field headerField = packet.getClass().getDeclaredField("a"); headerField.setAccessible(true); headerField.set(packet, header); headerField.setAccessible(!headerField.isAccessible()); Field footerField = packet.getClass().getDeclaredField("b"); footerField.setAccessible(true); footerField.set(packet, footer); footerField.setAccessible(!footerField.isAccessible()); } catch (Exception ex) { ex.printStackTrace(); } connection.sendPacket(packet); }