I need help with a bug...

Discussion in 'Plugin Development' started by jeeperscreeper77, Oct 19, 2014.

Thread Status:
Not open for further replies.
  1. So I made a plugin and it doesn't work...

    Code:java
    1. package me.jeeperscreeper77.AdminTags;
    2.  
    3. //imports
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.EventPriority;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.player.AsyncPlayerChatEvent;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class AdminTags extends JavaPlugin implements Listener {
    13.  
    14. @EventHandler(priority = EventPriority.LOW)
    15. public void onPlayerChat(AsyncPlayerChatEvent event) {
    16.  
    17. Player player = event.getPlayer();
    18.  
    19. if (player.hasPermission("AdminTags.Owner")) {
    20.  
    21. event.setFormat(ChatColor.GOLD + "[" + ChatColor.BLUE + "Owner" + ChatColor.GOLD + "] " + player.getDisplayName() + " " + ChatColor.BLUE + event.getMessage());
    22.  
    23. }
    24.  
    25. else if (player.hasPermission("AdminTags.Admin")) {
    26.  
    27. event.setFormat(ChatColor.GOLD + "[" + ChatColor.DARK_RED + "Admin" + ChatColor.GOLD + "] " + player.getDisplayName() + " " + ChatColor.DARK_RED + event.getMessage());
    28.  
    29. }
    30.  
    31. else if (player.hasPermission("AdminTags.SemiAdmin")) {
    32.  
    33. event.setFormat(ChatColor.GOLD + "[" + ChatColor.RED + "Semi-Admin" + ChatColor.GOLD + "] " + player.getDisplayName() + " " + ChatColor.RED + event.getMessage());
    34.  
    35. }
    36.  
    37. else if (player.hasPermission("AdminTags.Mod")) {
    38.  
    39. event.setFormat(ChatColor.GOLD + "[" + ChatColor.DARK_GREEN + "Mod" + ChatColor.GOLD + "] " + player.getDisplayName() + " " + ChatColor.DARK_GREEN + event.getMessage());
    40.  
    41. }
    42.  
    43. else if (player.hasPermission("AdminTags.TMod")) {
    44.  
    45. event.setFormat(ChatColor.GOLD + "[" + ChatColor.GREEN + "TMod" + ChatColor.GOLD + "] " + player.getDisplayName() + " " + ChatColor.GREEN + event.getMessage());
    46.  
    47. }
    48.  
    49. else if (player.hasPermission("AdminTags.Builder")) {
    50.  
    51. event.setFormat(ChatColor.GOLD + "[" + ChatColor.AQUA + "Builder" + ChatColor.GOLD + "] " + player.getDisplayName() + " " + ChatColor.AQUA + event.getMessage());
    52.  
    53. }
    54.  
    55. else if (player.hasPermission("AdminTags.VIP")) {
    56.  
    57. event.setFormat(ChatColor.GOLD + "[" + ChatColor.LIGHT_PURPLE + "VIP" + ChatColor.LIGHT_PURPLE + "] " + player.getDisplayName() + " " + ChatColor.GOLD + event.getMessage());
    58.  
    59. }
    60.  
    61. else if (player.hasPermission("AdminTags.Player")) {
    62.  
    63. event.setFormat(ChatColor.GOLD + "[" + ChatColor.WHITE + "Player" + ChatColor.GOLD + "] " + player.getDisplayName() + " " + ChatColor.WHITE + event.getMessage());
    64.  
    65. }
    66.  
    67. else if (player.hasPermission("AdminTags.Default")) {
    68.  
    69. event.setFormat(ChatColor.GOLD + "[" + ChatColor.WHITE + "Default" + ChatColor.GOLD + "] " + player.getDisplayName() + " " + ChatColor.WHITE + event.getMessage());
    70.  
    71. }
    72.  
    73. else if (player.hasPermission("AdminTags.Member")) {
    74.  
    75. event.setFormat(ChatColor.GOLD + "[" + ChatColor.BLACK + "Member" + ChatColor.GOLD + "] " + player.getDisplayName() + " " + ChatColor.WHITE + event.getMessage());
    76.  
    77. }
    78.  
    79. else if (player.hasPermission("AdminTags.OP")) {
    80.  
    81. event.setFormat(ChatColor.GOLD + "[" + ChatColor.BOLD + "OP" + ChatColor.GOLD + "] " + player.getDisplayName() + " " + ChatColor.BOLD + event.getMessage());
    82.  
    83. }
    84.  
    85. else if (player.hasPermission("AdminTags.Ranger")) {
    86.  
    87. event.setFormat(ChatColor.GOLD + "[" + ChatColor.BLACK + "Ranger" + ChatColor.GOLD + "] " + player.getDisplayName() + " " + ChatColor.BLACK + event.getMessage());
    88.  
    89. }
    90.  
    91.  
    92.  
    93. }
    94.  
    95. }


    and this is what it does in game...

    <~Jeepers>
    I am oped,
    I gave myself the perm for the Owner tag...
    I have deoped myself and tried it...

    Code:
    Here is my plguin.yml
    name: AdminTags
    author: jeeperscreeper77
    version: 1
    description: adds prefixes to player names based on perms!
    main: me.jeeperscreeper77.AdminTags.AdminTags
    commands:
     
    permissions:
    AdminTags.Owner:
    description: Gives the Owner tag in game
    AdminTags.Admin:
    description: Gives the Admin tag in game
    AdminTags.SemiAdmin:
    description: Gives the SemiAdmin tag in game
    AdminTags.Mod:
    description: Gives the Mod tag in game
    AdminTags.TMod:
    description: Gives the TMod tag in game
    AdminTags.Builder:
    description: Gives the Builder tag in game
    AdminTags.VIP:
    description: Gives the VIP tag in game
    AdminTags.Player:
    description: Gives the Player tag in game
    AdminTags.Default:
    description: Gives the Default tag in game
    AdminTags.Member:
    description: Gives the Member tag in game
    AdminTags.OP:
    description: Gives the OP tag in game
    default: op
    AdminTags.Ranger:
    description: Gives the Ranger tag in game
    
    Please help me!
     

    Attached Files:

  2. Offline

    Dudemister1999

    jeeperscreeper77 Do you have Essentials (+EssentialsChat) installed? It can often add that ~ in displayNames. It can also override the chat format.
     
  3. Dudemister1999
    I do have essentials installed, I tried it without Essentials and it still didn't work...
     
  4. Offline

    klosjaarrr

  5. Offline

    teej107

    klosjaarrr jeeperscreeper77 Post code using the code syntax so we don't have to get redirected to a different webpage and of coarse, for easier reading.
    Code:java
    1.  
     
  6. Offline

    FerusGrim

    Code:
    [syntax=java]public void someJavaMethod() {
        // something here
    }[/syntax]
    :)
     
  7. Offline

    teej107

  8. Code:java
    1. void org.bukkit.event.player.AsyncPlayerChatEvent.setFormat(String arg0) throws IllegalFormatException, NullPointerException
    2.  


    thats the error I am getting

    teej107 FerusGrim

    Is that better?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  9. Offline

    guitargun

    few questions.
    is this your main class?
    if yes then where are the on enable and on disable methods (on disable can be forgotten if it stays empty)

    if no then why do you extend JavaPlugin in this class since JavaPlugin is only for the main.
    also don't forget to register this class as a eventslistener in the main. if this is not your main class
     
Thread Status:
Not open for further replies.

Share This Page