Solved help11!!1!11

Discussion in 'Plugin Development' started by InspectorFacepalm, May 16, 2013.

Thread Status:
Not open for further replies.
  1. I need some help with this, I want to make this so only OP see this message, and for some reason, when I do it, guests/members can see the message too
                    if(p.hasPermission("loltest.t") || player.isOp()) {
  2. Offline


    Either guests/members have the permission "loltest.t", the person testing is in guest/member group but also has op or there's a problem somewhere else in your code.
    And why do you have p and player instead of player and player or p and p?
  3. I even removed all of my permission plugin, my permission.yml etc everything, reloaded twice, added the plugin, people who arent op can still use it
    Well I mean it's not really a command
    it's a broadcaster, only people with the permission, loltest.t should see the message, instead non-ops see it too
    also I use p because of this
          Player p = (Player)sender;
  4. Offline


    Are you iterating correctly over the 'said' players?
  5. Yeah I guess
    sure i'll post in a sec

    for(Player p : Bukkit.getOnlinePlayers()){
                    if(p.hasPermission("loltest.t") || player.isOp()) {
                        Bukkit.Broadcast+(ChatColor.GOLD + "loooolswag");
    I tried it
    Still happening, everyone can see it still

    yep, exactly

    nope, they're not op or anything, they can still see the message C:

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jan 21, 2020
  6. Offline


    Do you mind showing us the rest of the code relevant to what you're doing then?

    You're doing a broadcast, that will broadcast to everyone, you have to use p.sendMessage("loooolswag"); instead

    Edit: Wait what, what's "Bukkit.Broadcast+();"

    You're doing something like this right?:
    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
        if (p.hasPermission("loltest.t") || p.isOp()) {
            p.sendMessage(ChatColor.GOLD + "loooolswag");
    Make sure whoever is testing isn't op/being wierd then, if not op then something else might be wrong in your code.

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


    Bukkit.broadcastMessage() broadcasts a global message to all worlds, anyone on the server can see it regardless of permission

    Your permissions are messed up, because I use this type of code all the time, no issues
  8. Wait, do I have to put the permission in my plugin.yml?
  9. Offline


  10. Yeah then it doesn't work
  11. Offline


    ' It doesn't work ' --

    Nobody can help you with that.
  12. ergh k..
  13. Offline


    did you setup the permissions in the plugin.yml?
    So that the permission loltest.t default OP, and not for everyone?
    InspectorFacepalm likes this.
  14. Offline


    bennie3211 Everyone wouldn't have the permission node by default if they didn't put it in the plugin.yml
    InspectorFacepalm likes this.
  15. Offline

    Jamie Marks


    what your actually doing her is when a player types the command everyone with the node gets that message, theres a build in thing for that its Bukkit.broadcast(perm,message) what that does it sends messages to people with the correct perm when ever its executed

    if you want to send the message to only the sender then try this:

    //replace sender with what ever your sender is
    if(sender instanceof Player){
    Player pSend = (Player) sender
    sender.sendMessage("must be player");
    pSend.sendMessage("this is the message you asked for");
    that will just send it only to the sender.
    InspectorFacepalm likes this.
  16. @everyonewhopostedhere
    sorry I couldn't see your replies, everything was messed up, sorry for the really late reply, It's fixed now, thanks though!
Thread Status:
Not open for further replies.

Share This Page