1.8.8 Set up title duration as a string Packets

Discussion in 'Spigot Plugin Development' started by zarotli, Feb 3, 2020.

  1. Hello i am trying for a while now to create a title with a duration (taking the duration from the config)
    but it wont let me. the title works but it ignores the duration

    My Code

    Code (Text):
                        PacketPlayOutTitle title = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, IChatBaseComponent.ChatSerializer.a("{\"text\":\"" + titleMessage + "\"}"));
                        PacketPlayOutTitle dur= new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TIMES, (IChatBaseComponent) null, 20, duration,20);
                        ((org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) p).getHandle().playerConnection.sendPacket(title);
                        ((org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) p).getHandle().playerConnection.sendPacket(dur);
    Code (Text):
                    int duration = plugin.getConfig().getInt(JoinCondition + ".Title.Duration");
  2. IIRC you have to send the duration packet before the title packet. Try that
  3. Probably the config path does not exists, so the default value would be 0, and thus ignoring it?
  4. But why are you sending the two packets separate, and not in one? If you look at the available constructors:
    Code (Java):
        public PacketPlayOutTitle(final EnumTitleAction enumTitleAction, final IChatBaseComponent chatBaseComponent) {
            this(enumTitleAction, chatBaseComponent, -1, -1, -1);
        public PacketPlayOutTitle(final int n, final int n2, final int n3) {
            this(EnumTitleAction.TIMES, null, n, n2, n3);
        public PacketPlayOutTitle(final EnumTitleAction a, final IChatBaseComponent b, final int c, final int d, final int e) {
            this.a = a;
            this.b = b;
            this.c = c;
            this.d = d;
            this.e = e;
    You can see that apart from sending it sperately, you can also just do it inside 1 packet, which will probably prevent headaches.
    • Useful Useful x 2
    • Agree Agree x 1
  5. thank you for the advice i solved the problem (y)