Plugin Help Sending a message to players with certain perms.

Discussion in 'Plugin Help/Development/Requests' started by Minecraft_GOLD, Dec 1, 2015.

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

    Minecraft_GOLD

    This took me quite a while to figure out but i ended up using Bukkit.broadcast(ChatColor.GOLD + "Player, " + sender.getName() + "Report Player, " + args[0], "report.manage");

    Although i've been staring at my code for about an hour now trying to figure out what's wrong, i kinda gave up!

    my code: http://pastebin.com/3AqCUPMu

    Since im kinda new to coding i kind of rely on the eclipse warnings to guide me, however there's no warnings though in game when i try to run my plugin i get the error : an internal error occurred while attempting to perform this command

    What im trying to do is a plugin where a player can /report (name)
    for hacking or what not, this will then msg the staff (players with the permission) a message

    I've looked over the console but im still stumped, would be nice if someone could help me out!
     
  2. Offline

    DoggyCode™

    Why do you have
    if(cmd.getName().equalsIgnoreCase(...){

    Twice?! Remove it.. And it will work.
     
  3. Offline

    Minecraft_GOLD

    Thanks so much for the reply! I deleted it, now it's doing something! https://gyazo.com/d618f349579b1b9b19ee2f6be973a4fe
    still coming up with the error but it says please specify a player aswell, although when i do /report rileys the error doesn't come up! how can i fix this, thanks again!
     
  4. Offline

    DoggyCode™

    I don't wanna see the errors in chat. Go to console and screenshot it here
     
  5. Offline

    Firestar311

    First off, you onEnable() and onDisable() methods do not need the logger things, Bukkit does this already.
    And for the Broadcasting to each player with a permission node, the best way is to use the for-each loop, so the code;
    Code:
     Bukkit.broadcast(ChatColor.GOLD + "Player, " + sender.getName() + "Report Player, " + args[0], 
    Would be;
    Code:
    for(Player p : Bukkit.getOnlinePlayers()) {
        if(p.hasPermission("report.manage") {
            p.sendMessage(...);
       }
    }
    "..." - Your message
    I have used this code many times in my Custom Plugin for my server. It works. If it does not send me the code again
     
  6. Offline

    DoggyCode™

    That won't fix his issue... And no, it doesn't work better. Only difference is that the for method (I think) would not send the message to OPs, but it works.
     
  7. Offline

    Firestar311

    This does send a message to the OPs, because when there is a permission plugin intalled, ops have the permission node "*" which is ALL permission and does count the OPs as having it.

    And how won't it fix the issue? As the issue is pasted below...
     
  8. Offline

    DoggyCode™

    Because he's obviously doing a lot of other stuff wrong as well.
     
Thread Status:
Not open for further replies.

Share This Page