Displayname = null? [Help]

Discussion in 'Plugin Development' started by iBCoLLiN, Aug 3, 2013.

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

    iBCoLLiN

    Hey guys,

    So I am having a bit of problem with my prefix plugin. All the new players names are "null" or if your name is not in the config. What could be causing this?

    Code:java
    1. package us.alreadycoded.ssp;
    2.  
    3.  
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.EventHandler;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.player.AsyncPlayerChatEvent;
    12. import org.bukkit.plugin.java.JavaPlugin;
    13.  
    14. public class Main extends JavaPlugin implements Listener {
    15.  
    16. public void onEnable(){
    17. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    18. }
    19. public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String args[]){
    20. Player p = (Player) sender;
    21.  
    22. if(!(p instanceof Player)){
    23. p.sendMessage(Utils.colorize("&4Only players can have prefix's"));
    24. }
    25.  
    26.  
    27.  
    28. if(cmd.getName().equalsIgnoreCase("mp")){
    29. if(p.hasPermission("myprefix.prefix"));
    30. if (args.length == 0){
    31. p.sendMessage(Utils.colorize("&cYou did not type a prefix in!"));
    32. return true;
    33. }
    34. String prefix = "";
    35. for(String arg : args){
    36. prefix = arg + " ";
    37. }
    38. prefix = prefix.substring(0, prefix.length() - 1);
    39. prefix = prefix.replaceAll("&", "ยง");
    40. p.sendMessage(Utils.colorize("&aYou just changed your prefix!"));
    41. this.getConfig().set(p.getName(), prefix + " " + ChatColor.RESET + p.getName());
    42. this.saveConfig();
    43.  
    44.  
    45. }
    46.  
    47.  
    48. return true;
    49.  
    50.  
    51. }
    52.  
    53.  
    54.  
    55. @EventHandler
    56. public void onPlayerChat(AsyncPlayerChatEvent e){
    57. if (this.getConfig().getString(e.getPlayer().getName()) != null);
    58. e.getPlayer().setDisplayName(this.getConfig().getString(e.getPlayer().getName()));
    59. }
    60.  
    61. }
     
  2. "So I am having a bit of problem with my prefix plugin. All the new players names are "null" or if your name is not in the config. What could be causing this?"

    What? please explain a little more, what is the problem, is there an error when u use the plugin... etc the more info you can provide the easier I can help
     
Thread Status:
Not open for further replies.

Share This Page