PlayerMoveEvent HELP

Discussion in 'Plugin Development' started by BloodBacker, Dec 27, 2013.

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

    BloodBacker

    Hello,
    I have make this EventHandler, but it is spamming my hole chat.

    My code:


    Code:
        @EventHandler
        public void onPlayerMove(PlayerMoveEvent event){
            final Player p = event.getPlayer();
            final Block block = p.getLocation().getBlock().getRelative(BlockFace.DOWN);
            if(block.getType() == Material.REDSTONE_BLOCK){
                p.getWorld().playEffect(p.getLocation(), Effect.MOBSPAWNER_FLAMES, 6);
                        if (p.hasPermission("kits.speed")) {
                            p.sendMessage(ChatColor.RED + "Speed Perk activated!");
                        }
                        if (p.hasPermission("kits.jump")) {
                            p.sendMessage(ChatColor.RED + "Jump Perk activated!");
                        }
                    }
                }
     
  2. Offline

    gomeow

    That's the way it works, PlayerMoveEvent fires every time a player moves, which can be 20 times a second, so your chat is going to spam.
     
  3. Offline

    Tirelessly

    BloodBacker Why would it not spam your chat? If those conditions are true it should send the message every time you move even slightly.
     
  4. Offline

    BloodBacker


    You can set a delay? or sometimer a timer? can you help me? with this as this possible?


    ?

    One time is good, so when you move on it, you get one message, not 20 can you fix this or is this automatic
     
  5. Offline

    Tirelessly

    BloodBacker YOU can fix this. By using code. Check and see if the player has been sent the message already.
     
  6. Offline

    maciekmm

    Check if block that player is standing on has changed.
     
  7. Offline

    BloodBacker


    Can you give me the code i dont understand..
     
  8. Offline

    AoH_Ruthless

    BloodBacker
    It's not terribly difficult ... just use a boolean and if false, activate the perk and set to true. If true, return; so the event doesn't fire.
     
  9. Offline

    BloodBacker

    Can you use my code, and fix all? Post it back, would you do that for me?
    I mean you finish the code?

    AoH_Ruthless ?
     
  10. Offline

    AoH_Ruthless

    BloodBacker
    No, I'm not going to code for you, nor will many other people on the forums. You should know how Java works, and therefore you can understand what I said and apply it to your code. It's not my role to spoonfeed you code.

    Also, don't bump your post so often. Quoting my post does the same thing as tahging me. I will come to the thread when I get a chance / am online.
     
  11. Offline

    BloodBacker

    I understand what you saying! But come one can you finish the code? ITS not hard i Think 3 / 4 lines.
    I give you a feedback + like so can you make me today happy?
     
  12. Offline

    AoH_Ruthless

    BloodBacker
    You're right, it isn't hard. So do it yourself. Will take you longer to convince me to give you code than to do it yourself.

    You can't bribe me with a like ....
     
  13. Offline

    xTigerRebornx

    BloodBacker He just said he isn't going to spoonfeed you code, so he wont complete it. The whole point of asking for help here is that you learn from the help given, not just copy/paste code and make a new post a few min later because you have a problem with code you don't understand

    AoH_Ruthless Can't bribe you with a like....but what about.....2 LIKES! (sarcasm)
     
    AoH_Ruthless likes this.
  14. Offline

    BloodBacker

    I know but finish the code and explain what you have doing..

    I mean iTS not much*
    Can you finish the code and explain what you have do?
    I learn to for the next time..
     
  15. Offline

    AoH_Ruthless

    BloodBacker
    You could have just said you didn't understand what to do, instead of acting as if it isn't hard and not saying anything.

    I am assuming (maybe unjustly) that you do not know Java. You seem to have little understanding about what I was talking about, which wasn't a bukkit concept but a fundamental Java concept. So, with that said, I would recommend you spend some time reading up on Java before working with 3rd party API's. Coding with Bukkit will only get harder, especially when you need people to give you code.
     
  16. Offline

    BloodBacker


    I i'm learning About java right now, but when you finish the code , i see the code i'm thinking in my self, right that works so..
    And i learn from you
    So for the last question can you finish it....

    Can you give an awnser ? AoH_Ruthless


    How? Can you finish my code? I learn from you..
     
  17. Offline

    AndyMcB1

    If you can't understand how to code to this you should go back to basics.
     
  18. Offline

    pookeythekid

    Just check if the player has the effect.

    else if (player.hasPotionEffect(//whatever effect it is)) {
    //just do nothing if they have the effect. That way it doesn't spam your chat and it doesn't lag or error.
    }
     
  19. Offline

    gomeow

    People often learn better from trying themselves. I would suggest trying to finish this on your own instead of asking everybody for the code, we aren't here to code your plugin for you.
     
  20. Offline

    BloodBacker

    I mean the chat is spamming
    Code:
                      if(p.hasPermission("kits.speed")) {
                            p.sendMessage(ChatColor.RED + "Speed Perk activated!");
                        }
                        if (p.hasPermission("kits.jump")) {
                            p.sendMessage(ChatColor.RED + "Jump Perk activated!");
     
  21. Offline

    amhokies

    BloodBacker
    Just stop and think about it for a second... you only want it to send the message once. You need someway of checking to see if it's already been sent to a certain player, so each time they move you check to see if it's already been sent. If it has been sent, don't send it again, if it hasn't, send it once, then use a way of telling your plugin not to send it again.
     
  22. Offline

    BloodBacker

    I dont know, how to check the player has already the server, can you explain it , and finsinsh the code?

    message*

    PS: i cant edit
     
  23. Offline

    Necrodoom

    Oh, goody, another duplicate thread despite me warning you for this just the day before, and more double post flood and even attempting to bribe with likes.
    Locked.
     
Thread Status:
Not open for further replies.

Share This Page