could not pass event PlayerJointEvent

Discussion in 'Plugin Development' started by PizzaPixel, Feb 11, 2014.

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

    PizzaPixel

    this is what it give me in my console :

    Code:
    Could not pass event PlayerJoinEvent to CTO v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427) ~[spigot.jar:git-Spigot-1223]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-1223]
        at org.bukkit.plugin.TimedRegisteredListener.callEvent(TimedRegisteredListener.java:30) ~[spigot.jar:git-Spigot-1223]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:482) [spigot.jar:git-Spigot-1223]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:467) [spigot.jar:git-Spigot-1223]
        at net.minecraft.server.v1_7_R1.PlayerList.c(PlayerList.java:225) [spigot.jar:git-Spigot-1223]
        at net.minecraft.server.v1_7_R1.PlayerList.a(PlayerList.java:116) [spigot.jar:git-Spigot-1223]
        at net.minecraft.server.v1_7_R1.LoginListener.c(LoginListener.java:87) [spigot.jar:git-Spigot-1223]
        at net.minecraft.server.v1_7_R1.LoginListener.a(LoginListener.java:42) [spigot.jar:git-Spigot-1223]
        at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:150) [spigot.jar:git-Spigot-1223]
        at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [spigot.jar:git-Spigot-1223]
        at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:657) [spigot.jar:git-Spigot-1223]
        at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:273) [spigot.jar:git-Spigot-1223]
        at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:540) [spigot.jar:git-Spigot-1223]
        at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:446) [spigot.jar:git-Spigot-1223]
        at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [spigot.jar:git-Spigot-1223]
    Caused by: java.lang.NullPointerException
        at me.firstminigame.CTO.onPlayerJoin(CTO.java:111) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65]
        at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425) ~[spigot.jar:git-Spigot-1223]
        ... 15 more
    >
    
     
  2. Offline

    GaaTavares

    At least your code?
     
  3. Offline

    PizzaPixel

    Code:
    package me.firstminigame;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.ScoreboardManager;
     
     
    public class CTO extends JavaPlugin implements Listener {
        public static CTO instance;
        public static CTO plugin;
       
        ScoreboardManager sbManager = null;
        Scoreboard sBoard = null;
       
        Objective first = null;
        Objective second = null;
        Objective third = null;
        Objective fourth = null;
        Objective fifth = null;
        Objective sixth = null;
        Objective seventh = null;
        Objective eighth = null;
       
        Score fst = null;
        Score snd = null;
        Score thd = null;
        Score fth = null;
        Score fith = null;
        Score sth = null;
        Score seth = null;
        Score eth = null;
       
        @Override
        public void onEnable() {
            getServer().getPluginManager().registerEvents(this, this);
        instance = this;
       
        sbManager = Bukkit.getScoreboardManager();
        sBoard = sbManager.getNewScoreboard();
           
           
            first = sBoard.registerNewObjective("first", "dummy");
            second = sBoard.registerNewObjective("second", "dummy");
            third = sBoard.registerNewObjective("third", "dummy");
            fourth = sBoard.registerNewObjective("fourth", "dummy");
            fifth = sBoard.registerNewObjective("fifth", "dummy");
            sixth = sBoard.registerNewObjective("sixth", "dummy");
            seventh = sBoard.registerNewObjective("seventh", "dummy");
            eighth = sBoard.registerNewObjective("eight", "dummy");
     
            first.setDisplaySlot(DisplaySlot.SIDEBAR);
            second.setDisplaySlot(DisplaySlot.SIDEBAR);
            third.setDisplaySlot(DisplaySlot.SIDEBAR);
            fourth.setDisplaySlot(DisplaySlot.SIDEBAR);
            fifth.setDisplaySlot(DisplaySlot.SIDEBAR);
            sixth.setDisplaySlot(DisplaySlot.SIDEBAR);
            seventh.setDisplaySlot(DisplaySlot.SIDEBAR);
            eighth.setDisplaySlot(DisplaySlot.SIDEBAR);
           
            first.setDisplayName(ChatColor.AQUA + "    Welcome to");
            second.setDisplayName(ChatColor.GREEN + " SoMinecrafty");
            third.setDisplayName("---------------------");
            fourth.setDisplayName("");
            fifth.setDisplayName(ChatColor.DARK_RED + "Visit us at");
            sixth.setDisplayName(ChatColor.BLACK + "sominecrafty.com");
            seventh.setDisplayName("");
            eighth.setDisplayName("---------------------");
           
            for(Player online : Bukkit.getOnlinePlayers()){
           
            Score fst = first.getScore(online);
            fst.setScore(8);
           
            Score snd = second.getScore(online);
            snd.setScore(7);
           
            Score thd = third.getScore(online);
            thd.setScore(6);
           
            Score fth = fourth.getScore(online);
            fth.setScore(5);
           
            Score fith = fifth.getScore(online);
            fith.setScore(4);
           
            Score sth = sixth.getScore(online);
            sth.setScore(3);
           
            Score seth = seventh.getScore(online);
            seth.setScore(2);
           
            Score eth = eighth.getScore(online);
            eth.setScore(1);
           
            }
        }
           
            @EventHandler
            public void onPlayerJoin(PlayerJoinEvent event){
           
           
        for ( Player player : plugin.getServer().getOnlinePlayers() ) {
        player.setScoreboard(sBoard);
           
       
       
               
     
            }
        }
    }
       
     
     
           
           
        
     
  4. why loop through the whole player list when a player joins? why not just send the scoreboard to that player that fired the event when they join?
     
  5. Offline

    PizzaPixel

    This is only my second plugin so can u give me an example please?
     
  6. What you want to do is, when a player joins, to send them the scoreboard and nobody else.. its a waste to send it to other players that are already on the server and have a scoreboard already from when they joined, here is an example:

    Code:java
    1. @EventHandler (priority = EventPriority.MONITOR)
    2. public void onPlayerJoin(PlayerJoinEvent event){
    3. Player player = event.getPlayer();
    4. player.setScoreboard(sBoard);
    5. }


    that code should work fine, I have not tested it tho.
     
  7. Offline

    PizzaPixel

    im gonna test it now
     
  8. there might be other problems in your code causing this too, make sure when players leave that it removes the scoreboard, as its good pratice to do so.
     
  9. Offline

    PizzaPixel

    The scoreboard works now but only one objective comes up and my name is not suppose to be there

    [​IMG]
     
  10. screenshot?
     
  11. Offline

    PizzaPixel

    The scoreboard is always suppose to stay there its a display.

    file://localhost/Users/denis/Library/Application%20Support/minecraft/screenshots/2014-02-11_13.07.37.png

    how do i put a screenshot?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  12. try using gyazo? or imgur?
     
  13. Offline

    PizzaPixel

    Last edited by a moderator: Jun 6, 2016
  14. Offline

    PizzaPixel

    Last edited by a moderator: Jun 6, 2016
  15. I havnt dealt with multiple objectives on scoreboards yet, so im not sure. Pretty sure someone else can help with this :)
     
  16. Offline

    PizzaPixel

    You know anyone who can help me?
     
  17. I managed to get multiple scores showing in one of my plugins, you need one single objective, and multiple scores. Then add the scores to each objective.
     
  18. Offline

    MrAwellstein

    Uhhh, not sure if spigot talk is allowed here, and what I mean by that, is that your error could be spigot related, and since it's not really bukkit, its considered a topic to avoid or something.

    Edit:
    Didn't/don't have time to read above, but you have a null exception error.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page