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

    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)

    but i want to add new variable (zombies on player's map) so i wrote simple plugin to test something and i made this:
     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:

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

    Ensign Trojan

    that ain't working

    this is error:
    2013-06-30 14:00:13 [SEVERE] Could not pass event PlayerMoveEvent to MineZ_potion_effects vTEST_1.0
        at org.bukkit.plugin.RegisteredListener.callEvent(
        at org.bukkit.plugin.SimplePluginManager.fireEvent(
        at org.bukkit.plugin.SimplePluginManager.callEvent(
        at net.minecraft.server.v1_5_R3.PlayerConnection.a(
        at net.minecraft.server.v1_5_R3.Packet10Flying.handle(SourceFile:136)
        at net.minecraft.server.v1_5_R3.NetworkManager.b(
        at net.minecraft.server.v1_5_R3.PlayerConnection.d(
        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(
        at net.minecraft.server.v1_5_R3.DedicatedServer.r(
        at net.minecraft.server.v1_5_R3.MinecraftServer.q(
    Caused by: java.lang.NullPointerException
        at net.EnsignTrojan.ISDABEST.Main.onMove(
        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)
        ... 14 more 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