msg spam

Discussion in 'Plugin Development' started by TerroDoor, Mar 25, 2020.

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

    TerroDoor

    Code:
     public boolean getLoc(Location loc) {
     return (loc.getX() >= minx && loc.getX() <= maxx && loc.getY() >= miny && loc.getY() <= maxy
     && loc.getZ() >= minz && loc.getZ() <= maxz);
     }
    
    I have a Boolean check for a player loc stepping in/out of a region. if true it welcomes the player with a message but it's spamming. I know why this is happening and it's because each time the player moves while it's true, its going to spam, but I cant find a way around this!

    heres the listener:

    Code:
     public Main pl;
     public Protection(Main ins) {
     pl = ins;
     }
     
     @EventHandler
     public void onProtect(PlayerMoveEvent e) {
     Player p = (Player)e.getPlayer();
     
     if (pl.cube.getLoc(p.getLocation())) {
     
     p.sendMessage("welcome to spawn");
     return;
     
     }
     
     return;
     }
     
  2. Offline

    timtower Administrator Administrator Moderator

    @TerroDoor Save if the player has gotten the message already.
     
  3. Offline

    TerroDoor

  4. Offline

    timtower Administrator Administrator Moderator

    @TerroDoor Never store Player objects, use UUID's instead.
    And a List or Map
     
  5. Offline

    TerroDoor

    I used this, but my Boolean method is confusing me, it returns the players location but when using the method in the listener I get confused, would an if statement be saying: “if the player loc is inside the min/max, then return true?”


    Sent from my iPhone using Tapatalk
     
  6. Offline

    timtower Administrator Administrator Moderator

Thread Status:
Not open for further replies.

Share This Page