Solved Help with Join Events/Permissions

Discussion in 'Spigot Plugin Development' started by ItsLewizzz, May 20, 2016.

Thread Status:
Not open for further replies.
  1. I Made this plugin which if you have the permission such as staffjoin.mod when the player with that specific permission joins they will get a message saying [Mod]{playername} Has Joined! Aswell as a sound. even without the permission it still executes the code. Even if i dont have the permission.
    Here is the code:
    [Removed]

    Also need to say it is a staff announce plugin.
    Basically it executes the two if statements even when the player dosen't have the permission! ;o
     
    #1 ItsLewizzz, May 20, 2016
    Last edited: Jun 1, 2017
  2. Need more details;

    Are the player testing it OPed?: Yes/No
    And also a copy of your plugin.yml please.
     
  3. Yes i was OP when testing it. I deoped myself just there to test it that way and it looks like it works when not opped. But when a op joins i dont want it to say the messages for an owner which is opped. Here is my plugin.yml
    [​IMG]
     
  4. Yeah i tested it when not opped and the plugin works perfectly when not opped.
     
  5. Here is your problem, you did not register your permissions, add your permissions in this format (making an example with this):
    Code (Text):

    permissions:
      staffjoin.mod:
        default: op
     
    More details over there: http://wiki.bukkit.org/Plugin_YAML

    If your problem is solved, please tag your post as "Solved"!
     
  6. is there any spaces at the permissions word for the plugin.yml?
     
  7. Umm, look at the syntax in the link I gave you.
    Go all the way down and you'll find the example, follow the same syntax and you'll understand!
    If you have any doubts you may ask me again.
     
  8. I added the permissions part to my plugin.yml and exported the plugin again but when i am opped i still get those messages when im owner so i wouldn't like them messages to appear. Here is a minecraft screenshot:
    [​IMG]
    And here is my updated plugin.yml:
    [​IMG]
     
  9. You see those two "if" blocks? Try linking them with an "else", it should do "if(){//BlaBla} else if(){//BlaBla)}"
    Ok you know what, wait, I am remaking your whole onPlayerJoin block...
     
  10. Also if you dont want ops without the permission to be welcomed use "false" as the default
     
    #11 Orinion77, May 20, 2016
    Last edited: May 20, 2016
  11. Ok, here it is, make the auto adjustments needed (I have not tested it, just made it).
    Code (Text):

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e){
        if(e.getPlayer().hasPermission("staffjoin.mod")){
            for(Player p : Bukkit.getOnlinePlayers()){
                p.playSound(p.getLocation(), Sound.valueOf(ModJoinSound), 50.0F, 50.0F);
            }
            Bukkit.broadcastMessage(ChatColor.GREEN + "[Mod] " + ChatColor.AQUA + e.getPlayer().getName() + " Has Joined!");
        } else if(e.getPlayer().hasPermission("staffjoin.admin")){
        for(Player p : Bukkit.getOnlinePlayers()){
                p.playSound(p.getLocation(), Sound.valueOf(AdminJoinSound), 50.0F, 50.0F);
            }
            Bukkit.broadcastMessage(ChatColor.GREEN + "[Admin] " + ChatColor.AQUA + e.getPlayer().getName() + " Has Joined!");
        }
    }
     
    Keep me updated
     
  12. Gosh, did you look at the Plugin YAML link I gave? It's "true" not "not op"...
     
  13. Im NOT opped with NO permissions and now this happened:
    [​IMG]
     
  14. Actualy what i meant was "false" XD
     
  15. Seems better...
    And for you, Orinion77 is right, didnt think about it but change "default: op" by "default: false".
    Any error log in console?
     
  16. And you should use e.setJoinMessage() and put the message there. And also you should make an else and put there a message to show when a normal player joins... F.e.
    Code (Text):
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e){
        if(e.getPlayer().hasPermission("staffjoin.mod")){
            for(Player p : Bukkit.getOnlinePlayers()){
                p.playSound(p.getLocation(), Sound.valueOf(ModJoinSound), 50.0F, 50.0F);
            }
            e.setJoinMessage(ChatColor.GREEN + "[Mod] " + ChatColor.AQUA + e.getPlayer().getName() + " Has Joined!");
        } else if(e.getPlayer().hasPermission("staffjoin.admin")){
        for(Player p : Bukkit.getOnlinePlayers()){
                p.playSound(p.getLocation(), Sound.valueOf(AdminJoinSound), 50.0F, 50.0F);
            }
            e.setJoinMessage(ChatColor.GREEN + "[Admin] " + ChatColor.AQUA + e.getPlayer().getName() + " Has Joined!");
        }else{
           e.setJoinMessage(ChatColor.GREEN + "[Player] " + ChatColor.AQUA + e.getPlayer().getName() + " Has Joined!");
      }
    }
     
  17. I do not agree... if he still wants to see the normal join messages and the additionnal ones he does not have to use it. There's a difference between a "you should" and a "you can"...
     
  18. And also, he just wants to show staff joined, he is not making new join messages...
     
  19. Thats how I would do it... Sry when I didn't use the correct word because English is not my first language... But the default messages are very ugly.... xD
     
Thread Status:
Not open for further replies.