Remove sheep with sertain name?

Discussion in 'Plugin Development' started by Nojus, May 20, 2014.

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

    Nojus

    I wan't to remove all sheeps that is named something but i get error and i don't know why. Here is my code.

    Code:java
    1. List<Entity> e = Bukkit.getWorld("world").getEntities();
    2.  
    3. for(Entity entity : e) {
    4. if(e instanceof CraftSheep){
    5. CraftSheep sheep = (CraftSheep) entity;
    6. String name = sheep.getCustomName();
    7.  
    8. if(name == "§aS§bp§ca§dl§ev§ao§bt§ca §da§ev§ai§bs§c!") {
    9. Bukkit.getServer().broadcastMessage("removed");
    10. }
    11. }
    12. }



    Here is the error i get:

    Code:
    org.bukkit.command.CommandException: Unhandled exception executing command 'clearbitces' in plugin Whitelist v0.1
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-1468]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) ~[spigot.jar:git-Spigot-1468]
    at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:728) ~[spigot.jar:git-Spigot-1468]
    at net.minecraft.server.v1_7_R3.PlayerConnection.handleCommand(PlayerConnection.java:985) [spigot.jar:git-Spigot-1468]
    at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:830) [spigot.jar:git-Spigot-1468]
    at net.minecraft.server.v1_7_R3.PacketPlayInChat.a(PacketPlayInChat.java:28) [spigot.jar:git-Spigot-1468]
    at net.minecraft.server.v1_7_R3.PacketPlayInChat.handle(PacketPlayInChat.java:65) [spigot.jar:git-Spigot-1468]
    at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:180) [spigot.jar:git-Spigot-1468]
    at net.minecraft.server.v1_7_R3.ServerConnection.c(ServerConnection.java:81) [spigot.jar:git-Spigot-1468]
    at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:713) [spigot.jar:git-Spigot-1468]
    at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:283) [spigot.jar:git-Spigot-1468]
    at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:576) [spigot.jar:git-Spigot-1468]
    at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:482) [spigot.jar:git-Spigot-1468]
    at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-Spigot-1468]
    Caused by: java.lang.NoClassDefFoundError: org/bukkit/craftbukkit/v1_7_R1/entity/CraftSheep
    at nojus741.whitelist.main.onCommand(main.java:107) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-1468]
    ... 13 more
    Caused by: java.lang.ClassNotFoundException: org.bukkit.craftbukkit.v1_7_R1.entity.CraftSheep
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:67) ~[spigot.jar:git-Spigot-1468]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:62) ~[spigot.jar:git-Spigot-1468]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_51]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_51]
    at nojus741.whitelist.main.onCommand(main.java:107) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-1468]
    ... 13 more
     
  2. Offline

    hugokk

    You are likely building your plugin with another version of craftbukkit than your server is running on.
    And why dont get the livingentities for a world, and then check if they are an instanceof org.bukkit.entity.Sheep?
     
  3. Offline

    Gamecube762

    I don't think that you need CraftSheep, Sheep should work just fine. CraftSheep is from the minecraft vinilla code and is version sensitive with MC's version. "java.lang.NoClassDefFoundError" is the error you get when the required version the plugin is looking for isn't the version that the server has.
     
  4. Offline

    Iroh

    Locked.

    We do not support the development of plugins for unofficial builds.
     
Thread Status:
Not open for further replies.

Share This Page