player.hasPermission() not working

Discussion in 'Spigot Plugin Development' started by zozidalom, May 11, 2016.

Thread Status:
Not open for further replies.
  1. Code (Text):

            pm.registerEvents(new YourEvent(), this);
    This goes to your on enable, of course assuming you followed my register permissions comment, if not you need to make a PluginManager like:

    Code (Text):

            PluginManager pm = Bukkit.getPluginManager();
    Or you can simply use

    Code (Text):

            Bukkit.getPluginManager().registerEvents(new YourEvent(), this);
    You can do this for each event class you have.

    Edit: Are you using @EventHandler ?
     
  2. new Events(this)?

    I've never heard of doing it that way... try:
    getServer().getPluginManager().registerEvents(this, this);

    The first "this" is the plugin registering the events and
    the second "this" is the class that extends JavaPlugin, namely Main.class for my plugins.
     

  3. You can only use this if your event is in your main class. He is using separate classes for events
     
  4. Not necessarily.

    What I do if I have events in other classes, is I pass reference to Main thru the constructors
    of later objects that follow the initialization of my plugins.

    Like such:
    public class SomeClass implements Listener{

    //Constructor - Receives Main as a parameter
    public SomeClass(Main main){
    getServer().getPluginManager().registerEvents(this,main);
    //Stuff
    }

    ...

    }

    This is how I do it and it works very well.

    Because of course, you cannot extend Main thru these
    classes because Main which extends JavaPlugin is static
    which means that when you call new SomeClass(main),
    you'll get a nasty error, so extension is not doable,
    so I just pass main all over the place.
     
  5. Make:
    if(player.hasPermission("your.permission")) { //What you want to when he/she has the perms } else { //What you want (no perms)}
     
  6. You said that it keeps on going like #hasPermission is always true. Are you sure you're not just op? ;)
     
  7. OMG maybe the Owner (I) have got * permission LOL Thank you very much!
     
  8. MiniDigger

    Supporter

    wow
     
    • Agree Agree x 1
  9. If this is solved, please mark it as solved! :D
     
  10. Is this solved?
     
  11. #1 Permissions don't need to be registered anywhere unless you wish to use "wildcards" (in that case you register them in the plugin.yml).
    #2 You guys telling him to register his listener, in which he did and has the right code, telling him no and giving him the wrong code or literally telling him to do exactly what he already has is a little... unnecessary.
    #3 JD-GUI sucks. Use Luyten.
    #4 "Are you using EventHandler?" Are you able to read? He clearly has it in his first post.
    #5 "Use the API, not the server" While this is recommended, it won't solve the problem. Also he may be using NMS/OBC.
    #6 Not a single person asked if there was an error or stacktrace?
    #7 Nobody wanted to tell him his depend section in the plugin.yml is wrong? Needs to be
    Code (Text):
    depend: [PluginOne, PluginTwo]
    not
    Code (Text):
    depend: [PluginOne]
    depend: [PluginTwo]
    #8 The only person I see to ask the right question or say the right thing is @xMrPoi regarding debug messages.
    Me at your "attempt" to help the OP.
     
    • Winner Winner x 2
  12. Ohhh someone likes to talk MAD shit. Sorry we figured he already knew that adding the little * permission means his plugin wouldn't work right for him in the first place. Theres no way his code could cause an error. Quit being a stuck up douchedick like 60% of the others on this toxic site.

    Thanks.
     
    • Optimistic Optimistic x 2
  13. JamesJ

    Supporter

    No. You don't.
    If you're going to help people, at least give them the right information..
     
    • Agree Agree x 2
    • Like Like x 1
  14. You're the one swearing... And you shouldn't be helping people solve their problems if you don't know the answer. It's like someone asking you for directions, you have no clue, so you point in one direction, they say they couldn't find it, so you point in another way over and over and over, typically until you miraculously get it correct or you just give up (which seems to be apparent).

    /e Maybe the forum wouldn't be toxic to you if you were able to rightfully contribute to this forum. There's a reason everybody is toxic towards you.
     
    • Agree Agree x 1
    • Winner Winner x 1
  15. And you contributed to this SOLVED thread by: _______
     
  16. when i saw the thread the first thing i thought was that he might be op player or have op rank lol
     
  17. MiniDigger

    Supporter

    fernflower ftw
     
    • Like Like x 1
Thread Status:
Not open for further replies.