Need help with TagApi

Discussion in 'Plugin Development' started by kevin3220, Oct 15, 2013.

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

    kevin3220

    Hi,


    Well my problem is that i need to check player tag when ever player moves. I need to put PlayerReciveNameTagEvent to OnPlayerMovmentEvent.
    Code:java
    1. package pl.plugin;
    2.  
    3. import org.bukkit.entity.Player;
    4. import org.bukkit.event.EventHandler;
    5. import org.bukkit.event.Listener;
    6. import org.bukkit.event.player.PlayerMoveEvent;
    7. import org.bukkit.util.Vector;
    8. import org.kitteh.tag.PlayerReceiveNameTagEvent;
    9.  
    10. public class onMovement implements Listener {
    11. @EventHandler
    12. public void onMove(PlayerMoveEvent e){
    13. public void onNameTag(PlayerReceiveNameTagEvent event) {
    14. if (event.getTag().equals("Kevin")) {
    15. event.setTag("Notch");
    16. }
    17.  
    18.  
    19.  
    20.  
    21. }
    22.  
    23.  
    24.  
    25.  
    26.  
    27. }
    28.  


    How do i do that? Whenever some player moves then it is going to check is Kevin tag equaled to Kevin? On player movment event is just for testing!

    Sorry for my really bad English and grammar. All questions are welcome.
    Thank you,
     
  2. Offline

    MiniDigger

    kevin3220 you cant put a event handler into another.I dont know TagAPI very well but i think if you listen to
    PlayerReceiveNameTagEvent it should work
     
  3. Offline

    kevin3220

    Thank you for answering! ;) But i don't know how to put event handler into another ;( Could you please show me some example? ;) Cheers
     
  4. Offline

    MiniDigger

    :D
     
  5. Offline

    kevin3220

    ou sorry i got bad english? but how do i do then ? ;)
     
  6. Offline

    Garris0n

    There should be no reason for you to do this and it would be nice if you could explain what you're doing because there's probably a better way, however you would use TagAPI.refereshPlayer(event.getPlayer()) in the PlayerMoveEvent. Also, read this.
     
  7. Offline

    MiniDigger

    no i just said that you can't put a event handler into another and you asked me again how to do so :D
     
  8. Offline

    kevin3220

    still need help
     
  9. Offline

    MiniDigger

    kevin3220 use this:
    Code:
    @EventHandler
    public void onNameTag(PlayerReceiveNameTagEvent event) {
    if (event.getTag().equals("Kevin")) {
    event.setTag("Notch");
    }
    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event) {
    TagAPI.refereshPlayer(event.getPlayer());
    }
    
     
  10. Offline

    kevin3220

    not working ;/
     
  11. Offline

    MiniDigger

    kevin3220 what you want to see and what are you seeing?
    This will change the nametag of the players you are seeing to Notch so that you are surroned by notchs
     
  12. Offline

    kevin3220

    well i need to umm. Change player tag.
     
  13. kevin3220 The code MiniDigger gave you should work. Did you register the listener properly?
     
  14. Offline

    kevin3220

    well i need to change player tags who are in list
     
  15. Offline

    MiniDigger

    kevin3220 which list? The list you get by pressing tab?
     
  16. Offline

    kevin3220

    No, well lets say that i need to update player tags who are in arraylist
     
  17. Offline

    MiniDigger

    kevin3220
    for(Player p : arraylist){
    TagAPI.refereshPlayer(p);
    }
     
  18. Offline

    kevin3220

    <
    But is it possible to change player tags who are in arraylist ?
     
  19. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Calling refresh in the move event is a terrible idea. Could you describe what you're trying to do here, so I can help better handle this?
     
  20. Offline

    MiniDigger

    mbaxter I thinks he is trying to change the nametag of players, who are in a arraylist. But not realy shure :D
     
  21. Offline

    kevin3220

    yeah true

    @mbaxter I thinks he is trying to change the nametag of players, who are in a arraylist. But not realy shure :D
    Yeah thats true ;) But i dont know how ;(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  22. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    kevin3220

    What defines the player's membership in that array?
    How often does that membership change?
    Is a player put there on join, or only later?
     
Thread Status:
Not open for further replies.

Share This Page