Пример #1
0
  public static void TabHF(Player player, String header, String footer) {
    CraftPlayer craftplayer = (CraftPlayer) player;
    PlayerConnection connection = craftplayer.getHandle().playerConnection;
    IChatBaseComponent JSONheader = ChatSerializer.a("{\"text\": \"" + header + "\"}");
    IChatBaseComponent JSONfooter = ChatSerializer.a("{\"text\": \"" + footer + "\"}");
    PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
    try {
      Field headerField = packet.getClass().getDeclaredField("a");
      headerField.setAccessible(true);
      headerField.set(packet, JSONheader);
      headerField.setAccessible(!headerField.isAccessible());

      Field footerField = packet.getClass().getDeclaredField("b");
      footerField.setAccessible(true);
      footerField.set(packet, JSONfooter);
      footerField.setAccessible(!footerField.isAccessible());
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    connection.sendPacket(packet);
  }
Пример #2
0
  @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);
  }
Пример #3
0
 public static void sendJson(Player player, Object s) {
   CraftPlayer craftPlayer = (CraftPlayer) player;
   PlayerConnection playConnection = craftPlayer.getHandle().playerConnection;
   playConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a(s.toString())));
 }