Cant figure this out!

Discussion in 'Plugin Development' started by lpjz2, Mar 24, 2011.

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

    lpjz2

    hey im trying to make a Entity_Damage listener (that will put my health back to 20 when i take damage)

    however when i start my console i get alot of errors... (i will come back to the console in a sec)

    here is my main code...
    Code:
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.logging.Logger;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    
    
     //////////////////////////////////////////
    
    
    public class Test extends JavaPlugin {
    
        private static final Logger log = Logger.getLogger("Minecraft");
        private final TestDListen damageListener = new TestDListen();
        public final HashMap<Player, ArrayList<Block>> Gods = new HashMap<Player, ArrayList<Block>>();
        
        public void onDisable() {
           log.info("Test Disabled");
            
        }
    
        
        public void onEnable() {
    
        log.info("Test Enabled");
        
        
        PluginManager pm = getServer().getPluginManager();
        pm.registerEvent(Event.Type.ENTITY_DAMAGE, damageListener,
                Event.Priority.Normal, this);
            
        
        
        }
    [code]
    
    and my Damage listener... (its empty i know, adding the rest of code after i fix this)
    
    [code]
    package me.lpjz2.Test;
    import org.bukkit.event.entity.EntityListener;
    
    
    public class TestDListen extends EntityListener{
    
    }
    

    and this is the console error im getting...

    Code:
    22:10:49 [SEVERE] Could not load plugins\Test.jar in plugins: null
    org.bukkit.plugin.InvalidPluginException
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:113)
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:159)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:107)
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:61)
            at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:260)
            at org.bukkit.command.SimpleCommandMap$ReloadCommand.execute(SimpleComma
    ndMap.java:196)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:80
    )
            at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:2
    21)
            at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:379)
            at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:365)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:271)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    Caused by: java.lang.ClassNotFoundException: me.lpjz2.Test.Test
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:30)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:105)
            ... 11 more
    22:10:49 [INFO] Reload complete.
    
    i thank you in advance for helping me, i love the bukkit community =P

    will read replys in the morning as i have to study before i sleep. thanks [cake]
     
  2. Offline

    nekosune

    I think it is expecting to find functions in TestDListen, it is not finding,. try filling that in with some skeleton code first.
     
  3. Offline

    cjc343

    Something's wrong with your plugin.yml or you forgot to add the Test class to the package.

    E: And that ^ too.
     
  4. Offline

    nekosune

    Looking at it more, do you have your package set right? it is obviously reading plugin.yml , as it is looking for the class me.lpjz2.Test.Test

    Edit:
    beaten to it
     
  5. Offline

    lpjz2

    if i take away

    Code:
    private final TestDListen damageListener = new TestDListen();
    
    and
    Code:
        PluginManager pm = getServer().getPluginManager();
        pm.registerEvent(Event.Type.ENTITY_DAMAGE, damageListener,
                Event.Priority.Normal, this);
    
    there is no console errors and the plugin loads, but will the damage listener still work?
     
  6. Offline

    nekosune

    no it would not, as we said you need to add the code to damage listener before it will work, you can not have a blank one, that is what is causing the error
     
Thread Status:
Not open for further replies.

Share This Page