Scoreboard with amount of zombies on player's world

Discussion in 'Plugin Development' started by Ensign Trojan, Jun 30, 2013.

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

    Ensign Trojan

    Hai,
    I know just a little bit about java & bukkit but I am making a server and I am using this plugin on it to make scoreboards (for online players and ping) http://dev.bukkit.org/bukkit-plugins/scoreboardstats/

    but i want to add new variable (zombies on player's map) so i wrote simple plugin to test something and i made this:
    Code:
     if(event.getClickedBlock().getType() == Material.DIAMOND_BLOCK){
                   
               
                    ArrayList<Entity> Zombies = new ArrayList<Entity>();
                    for (Entity entity : player.getWorld().getEntities()) {
                      if (entity instanceof Zombie) {
                        Zombies.add((Zombie) entity);
                      }
                    }
                   
                    player.sendMessage("Zombies: " + Zombies.size());
                   
                   
                    }
    just to check if it's possible to check how much zombies are nearby. And it works, but now i want to put this into score board (instead of PlayerInteractEvent and sending message to player) but I also don't want to remove my old scoreboards from server, ouh, I have no idea how to write what i mean ^^ sorry but i am 16 and i live in Poland so my grammar sucks etc. BUT i hope you know what i mean and you can help me :D
     
  2. I would try something like this:

    Code:java
    1. getPlayer().getScoreboard().getObjective(DisplaySlot.SIDEBAR).getScore(Bukkit.getOfflinePlayer("Zombies:")).setScore(zombieSize);
     
  3. Offline

    Ensign Trojan

    that ain't working

    this is error:
    Code:
    2013-06-30 14:00:13 [SEVERE] Could not pass event PlayerMoveEvent to MineZ_potion_effects vTEST_1.0
    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.SimplePluginManager.fireEvent(SimplePluginManager.java:477)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462)
        at net.minecraft.server.v1_5_R3.PlayerConnection.a(PlayerConnection.java:222)
        at net.minecraft.server.v1_5_R3.Packet10Flying.handle(SourceFile:136)
        at net.minecraft.server.v1_5_R3.NetworkManager.b(NetworkManager.java:292)
        at net.minecraft.server.v1_5_R3.PlayerConnection.d(PlayerConnection.java:115)
        at net.minecraft.server.v1_5_R3.ServerConnection.b(SourceFile:35)
        at net.minecraft.server.v1_5_R3.DedicatedServerConnection.b(SourceFile:30)
        at net.minecraft.server.v1_5_R3.MinecraftServer.r(MinecraftServer.java:581)
        at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:226)
        at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:477)
        at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java:410)
        at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:573)
    Caused by: java.lang.NullPointerException
        at net.EnsignTrojan.ISDABEST.Main.onMove(Main.java:125)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425)
        ... 14 more
    Main.java line 125 is: event.getPlayer().getScoreboard().getObjective(DisplaySlot.SIDEBAR).getScore(Bukkit.getOfflinePlayer("Zombies:")).setScore(Zombies.size());

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

Share This Page