Muting player

Discussion in 'Plugin Development' started by Abyssal, Nov 12, 2015.

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

    Abyssal

    Hey,
    Making this plugin where if you left click a player with a blazerod it mutes them. When a player "mutes" a player by hitting them, it says that the player is muted in Chat, but they can still speak.
    Can you spot the issue?

    CODE: http://pastebin.com/MHGeL56z

    Config file:
    mutedplayers:
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Abyssal Why don't you just store it in variables and let the config be a clone of that instead of the other way around?
    And it probably has to do with the fact that you are removing the old muted players every time that you mute somebody.
     
  3. Offline

    Abyssal

    Hi,
    I am very new to doing plugins, this is my second one.

    I remove the muted players from the list so it doesn't keep adding the same muted players to the list again, but it seems to only add one name, I have no idea what is happening, I am out of my depth to be honest, but I just want to know what is wrong.. XD

    Is there a way to add a name to a config list instead of setting the list?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 12, 2015
  4. Offline

    timtower Administrator Administrator Moderator

    @Abyssal Use a Set, then it won't add him again.
    And you add a user, set the list, then you remove the user, you never look at what is actually in the list.
     
  5. Offline

    Abyssal

    But when the server restarts the string list(not config one) will become empty, so then it will set the list again and unmute them automatically, or am I wrong
     
  6. Offline

    timtower Administrator Administrator Moderator

    Then you save in the onDisable and load in the onEnable
     
  7. Offline

    CraftCreeper6

    @Abyssal
    You can create a method that inputs the objects into the config onDisable(); then add them again in the onEnable();

    EDIT: Sniped.
     
  8. Offline

    Abyssal

    I have tried this

    public void onEnable() {
    Bukkit.getServer().getPluginManager().registerEvents(this, this);
    muted.set(this.getConfig().getList("restart"));
    }

    public void onDisable() {
    this.getConfig().set("restart", muted);
    }

    But, I can't set the "muted" in the onEnable because it's a list
     
  9. Offline

    timtower Administrator Administrator Moderator

    @Abyssal muted = config.getList("restart");
    Also: don't forget to save the config
     
  10. Offline

    Abyssal

    Thanks for your help, and I am sorry that I am being such a pain. I have another issue now, when I hit the player (with mute mode enabled) this error comes up: http://i.imgur.com/bD80m4h.png - caused by the EntityDamageByEntity event

    Code: http://pastebin.com/Rw1XBWhm
     
  11. Offline

    timtower Administrator Administrator Moderator

    @Abyssal 1. There is a method getStringList, then you don't need to cast it.
    2. There is no value in the config yet, so muted is set to null in the onEnable
     
  12. Offline

    Abyssal

    THANK YOU VERY MUCH :)

    You have helped a lot
     
  13. Offline

    Scimiguy

    If your problem is fixed, edit the title of your thread and mark this as solved please
     
Thread Status:
Not open for further replies.

Share This Page