I get two messages instead of one

Discussion in 'Plugin Development' started by Sicka_gp, Jun 18, 2013.

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

    Sicka_gp

    Hello, I get two messages instead of one, could anyone advise how to fix it? thanks
    Code:java
    1. @EventHandler(ignoreCancelled = true)
    2. public void onPlayerJoin(PlayerJoinEvent e) {
    3. Player p = e.getPlayer();
    4. if(s.isSidebarEnable()){
    5. score.setScoreboard(p);
    6. }
    7. OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(p.getName());
    8. if(!(offlinePlayer.hasPlayedBefore())){
    9. if(s.isFirstMessageEnable()){
    10. Bukkit.broadcastMessage(str.replacer(p, "Newbies.First-message"));
    11. }
    12. if(s.isKitsEnable()){
    13. setKits(p);
    14. }
    15. }
    16. if(s.isMessageEnable()){
    17. if(s.isMessageGroupEnable() && plugin.chat != null && plugin.perm != null){
    18. String jmessage = "Messages.Groups." + plugin.permission.getPrimaryGroup(p) + ".join-message";
    19. e.setJoinMessage(str.replacer(p, jmessage));
    20. }else{
    21. e.setJoinMessage(str.replacer(p, "Messages.Default.join-message"));
    22. }
    23. }else{
    24. e.setJoinMessage(null);
    25. }
    26. }

    [​IMG]
     
  2. Offline

    ZachBora

    Sicka_gp I don't know how to fix your problem but I can help.

    First off, you don't have to change the joinmessage. You can set it null then directly message the player.
    Secondly, your plugin does not take into account invisible players. You can check one of my plugins to see how to deal with invisible players https://github.com/ZachBora/PlayerS...ornica/playerstatus/PSPlayerListener.java#L72

    Now with that out of the way. What I usually do is add some debugging to my plugin when I have a bug to squash. It's very easy to do and works almost everytime.

    Add outputs to console. Now since it's hard to debug (or impossible), the 2nd best way to see what paths is taken and what variables contains is to output to console. If you're in the plugin class it's simply .getLogger().info("" + variable);. If you're in another class it's either plugin.getLogger() or you can also do like I did recently :

    Code:java
    1.  
    2. public class PlotMe_Core extends JavaPlugin{
    3.  
    4. public static PlotMe_Core self = null;
    5.  
    6. public void onDisable(){
    7. self = null;
    8. }
    9.  
    10. public void onEnable(){
    11. self = this;
    12. }
    13. }
    14.  


    Then you can simple do PlotMe_Core.self.getLogger()
     
  3. Offline

    AmShaegar

    Did you double register your Listener in your onEnable() ?
     
  4. Offline

    Sicka_gp

    ZachBora
    Problem could be related with this error message? receives only some of the users of my plugin?

    2013-06-08 19:35:47 [INFO] N1T3SLAY3R logged in from 216.197.170.207:54392 in world "world" (Entity #881) 2013-06-08 19:35:47 [SEVERE] Could not pass event PlayerJoinEvent to ConfigurableMessages v0.3 org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427) at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) at org.bukkit.plugin.TimedRegisteredListener.callEvent(TimedRegisteredListener.java:30) at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:478) at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:463) at net.minecraft.server.v1_5_R3.PlayerList.c(PlayerList.java:204) at net.minecraft.server.v1_5_R3.PlayerList.a(PlayerList.java:100) at net.minecraft.server.v1_5_R3.PendingConnection.d(PendingConnection.java:134) at net.minecraft.server.v1_5_R3.PendingConnection.c(PendingConnection.java:49) at org.spigotmc.MultiplexingServerConnection.b(MultiplexingServerConnection.java:77) at net.minecraft.server.v1_5_R3.MinecraftServer.r(MinecraftServer.java:583) at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:227) at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:472) at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java:404) at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:573) Caused by: java.lang.NullPointerException at cz.Sicka_gp.ConfigurableMessages.Settings.ConfMsfStringSetings.replacer(ConfMsfStringSetings.java:24) at cz.Sicka_gp.ConfigurableMessages.ConfigurableMessagesListener.onPlayerJoin(ConfigurableMessagesListener.java:44) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425) ... 14 more[/CODE]
    Only once it is registered
     
  5. Offline

    Ivan

    AmShaegar said:
    Did you double register your Listener in your onEnable() ?​
    Yes I am

    You double register your listener?? That's where the error is :p. It will be executed twice.
     
  6. Offline

    Sicka_gp

    ou: D bad translation
     
Thread Status:
Not open for further replies.

Share This Page