Remove WorldBorder packet

Discussion in 'Plugin Development' started by jarnoboy404, Feb 13, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    jarnoboy404

    Hello, i have a plugin that let players see a worldborder.

    I also want to let players to be able to remove the worldborder with a command.
    But i don't know how i can remove certain packets from a player.

    Here is my code to initialize the worldborder:

    Code (open)

    Code:
        public void createWorldBorder() {
            WorldBorder worldBorder = new WorldBorder();
            worldBorder.world = ((CraftWorld) center.getWorld()).getHandle();
            worldBorder.setSize(new Settings().ISLAND_SIZE * 2);
            worldBorder.setCenter(center.getX(), center.getZ());
           
            packetPlayOutWorldBorder = new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE);
        }
    
        public void sendWorldBorderPacket(Player p) {
            ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packetPlayOutWorldBorder);
        }
       
        public void removeWorldBorderPacket(Player p) {
           
        }


    I hope someone knows how i remove a worldborderPacket from a player.
     
  2. Offline

    Kars

    I think you misunderstand. You can (apparently) send a packet to make someone see a world border but you can't 'remove' a packet. A packet gets sent over a network.

    Anyway. Did you try sending that same packet, but with the border in a totally unrelated location? That way the border should no longer be at the initial location and therefore be 'removed' of sorts.
     
  3. Offline

    MCMastery

    Maybe setting null as the worldBorder in new PacketPlayOutWorldBorder could remove it.
     
Thread Status:
Not open for further replies.

Share This Page