Solved After Command Is Performed It Does The Action But Prints Back The Command

Discussion in 'Plugin Development' started by SeaniePlays, May 16, 2014.

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


    Hi Guys,
    So basically i have this plugin for my server which has custom commands. I was working on a Chatclear Command but There is a error with Player player = (player) sender; the second player is underlined in yellow.Like this Player player = (player) sender; .All of the other commands are fine just this one is being weird Heres the bit of code im working on

    1. //ChatClear
    2. else if (cmd.getName().equalsIgnoreCase("cc") && sender instanceof Player){
    4. Player player = (Player) sender;
    5. for (int i = 0; i <= 120; i++) {
    7. Bukkit.broadcastMessage("");
    8. }
    9. Bukkit.broadcastMessage("Chat Has Been Cleared By A Staff Member");
    10. }
    11. return false;
  2. Offline


    Change return false to return true;
  3. Do you even need to get the player for this piece of code, it seems kinda useless, you're not calling the player variable anywhere. That is why it's yellow, its unused.
  4. Offline


    Thank You Mr360zack
    I missed out the obvious XD But the sencond player is still underlined even though it works O.0

    Oh now it makes sense BugsyFTW
    Didnt Realise, I thought you needed it for every player issued command

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


    By the way, you can't clear the chat by making the server broadcast ""... (nothing)

    You have to make it broadcast something like this: " " 7 times or so
  6. Offline


    You would only need a player variable if you need to use methods that are specific to players (such as teleporting). Otherwise, you would be fine sticking with sender.
  7. Offline


    Code0 Nope because i have
    for (int i = 0; i <= 120; i++) {
    So The int automatically does it a set amount of times enough to clear the chat
  8. Offline


    Just noticed, yea :)
Thread Status:
Not open for further replies.

Share This Page