Why is my code running on everyone

Discussion in 'Plugin Development' started by bloodless2010, Aug 11, 2013.

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

    bloodless2010

    Okay, so basically I made this plugin, and it works fine, but when I run it on my server, (i.e if I run /setcolour red) I will see everyones name as red,
    How can I make it so ONLY the person who runs the command or the 2nd argument on my command /setcolour?
    this is my first plugin and so far so good it's just this little bug, if anyone could help I would much appreciate it,
    Here is my source: http://pastebin.com/raw.php?i=GwVX2KNP
    Thank you!

    Just realised I screwed up the thread title, I renamed it. Still looking for help though, much appreciated.

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

    Assist

    bloodless2010
    PlayerRecieveNametagEvent is for all players, unless said otherwise.
     
  3. Offline

    ibWill

    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String commandlabel, String[] args){
    2. if(commandlabel.equalsIgnoreCase("setcolour"){
    3. if(args.length == 1){
    4. Player player = (Player) sender;
    5. } else {
    6. Player player = Bukkit.getPlayerExact(args[1]);
    7. if(player == null){
    8. sender.sendMessage("Player is not online!");
    9. return true;
    10. }
    11. }
    12. // Rest of Code Here
    13. }
    14. }
    15.  
    16.  


    Also, to make the class a little shorter, change the setting of the tag to happen in the command

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

    xXMaTTHDXx

    Not sure it it would work but when you type the command everyone is added to a list and then you remove the sender, then everyone in the list has that name color except the sender. bloodless2010
     
Thread Status:
Not open for further replies.

Share This Page