Don't take damage from WorldBorder

Discussion in 'Plugin Development' started by masu7, Jun 29, 2017.

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

    masu7

    Hello.I'm trying to create a WorldBorder per player,but if i'm outside of him i don't take damage.The border size decreases every second.

    My code:

    Code:
    WorldBorder border = new WorldBorder();
           border.setSize(20);
           border.setCenter(p.getLocation().getX(), p.getLocation().getZ());
           border.setDamageAmount(5);
           border.setDamageBuffer(5);
           PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(border, EnumWorldBorderAction.INITIALIZE);
           ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
           new BukkitRunnable() {
    
             public void run() {
                 border.setSize(border.getSize() - 1);
               PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(border,
                   EnumWorldBorderAction.SET_SIZE);
               ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
    
             }
           }.runTaskTimer(Main.INSTANCE, 0, 20);
    
    
    [​IMG]
     
    Last edited: Jun 29, 2017
  2. Offline

    Zombie_Striker

    @masu7
    The damage is controlled by the server, not the worldboarder packet. You will need to check if the player is outside of the worldboarder, and if so, damage them.
     
  3. Offline

    masu7

  4. Offline

    Zombie_Striker

    @masu7
    Use boarder#getCenter to get the center of the world boarder.
     
  5. Offline

    masu7

    @Zombie_Striker this method doesn't exist for a custom WorldBorder made with NMS,this method is just from org.bukkit.WorldBorder .
     
  6. Offline

    timtower Administrator Administrator Moderator

    @masu7 You have a border in the runnable...
     
  7. Offline

    masu7

    Does it affect with something the runnable?There is other way to decrease the WorldBorder size without a runnable?
     
  8. Offline

    masu7

    BUMP
     
Thread Status:
Not open for further replies.

Share This Page