Solved Join Message Plugin Need Help!

Discussion in 'Plugin Development' started by BrandonLabs, Apr 1, 2014.

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

    BrandonLabs

    I was working on a plugin for my server, but when I finished the plugin and logged onto my server, I got the VIP join message instead of the Admin join message.

    This is my code below:

    Code:java
    1. package zephon;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.event.player.PlayerJoinEvent;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public class Main
    12. extends JavaPlugin
    13. implements Listener
    14. {
    15. public void onEnable()
    16. {
    17. getLogger().info("Enabled");
    18. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    19. }
    20.  
    21. public void onDisable()
    22. {
    23. getLogger().info("Disabled");
    24. }
    25.  
    26. @EventHandler
    27. public void onPlayerJoin(PlayerJoinEvent pje)
    28. {
    29. final Player player = pje.getPlayer();
    30. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
    31. {
    32. public void run()
    33. {
    34. if (player.hasPermission("zephon.join.vip")) {
    35. Bukkit.broadcastMessage(ChatColor.GREEN + "[VIP] " + player.getName() + ChatColor.GOLD + " joined the lobby!");
    36. } else if (player.hasPermission("zephon.join.vip+")) {
    37. Bukkit.broadcastMessage(ChatColor.GREEN + "[VIP" + ChatColor.YELLOW + "+" + ChatColor.GREEN + "] " + player.getName() + ChatColor.GOLD + " joined the lobby!");
    38. } else if (player.hasPermission("zephon.join.mvp")) {
    39. Bukkit.broadcastMessage(ChatColor.AQUA + "[MVP] " + player.getName() + ChatColor.GOLD + " joined the lobby!");
    40. } else if (player.hasPermission("zephon.join.mvp+")) {
    41. Bukkit.broadcastMessage(ChatColor.AQUA + "[MVP" + ChatColor.RED + "+" + ChatColor.AQUA + "] " + player.getName() + ChatColor.GOLD + " joined the lobby!");
    42. } else if (player.hasPermission("zephon.join.helper")) {
    43. Bukkit.broadcastMessage(ChatColor.BLUE + "[HELPER] " + player.getName() + ChatColor.GOLD + " joined the lobby!");
    44. } else if (player.hasPermission("zephon.join.mod")) {
    45. Bukkit.broadcastMessage(ChatColor.DARK_GREEN + "[MOD] " + player.getName() + ChatColor.GOLD + " joined the lobby!");
    46. } else if (player.hasPermission("zephon.join.admin")) {
    47. Bukkit.broadcastMessage(ChatColor.DARK_RED + "[ADMIN] " + player.getName() + ChatColor.GOLD + " joined the lobby!");
    48. }
    49. }
    50. }, 20L);
    51. }
    52. }
     
  2. Offline

    RawCode

    reverse order of your checks and add returns inside.

    admins in most cases do have all permissions, this is reason of issue.
     
  3. Offline

    PratamaJr

    BrandonLabs

    Hi there...

    check ur permission file
    make sure "admin" group has ADMIn MESSAGE permission
    and remove all message permissions on the admin group, except admin message permissions
     
  4. Offline

    mickedplay

    Or set if(player.isOp() && player.hasPermissions("xyz").
    The most admins in the server are op's^^
     
    BrandonLabs likes this.
  5. Offline

    MooshViolet

    BrandonLabs That is happening because probably the admins on your server have all of the permissions. So when this runs, it checks the first one and says "Oh hey, he has this, so I am going to run this message"
     
    Xyplo likes this.
  6. Offline

    BrandonLabs

  7. Offline

    Xyplo

    GG XD
     
Thread Status:
Not open for further replies.

Share This Page