Plugin problem: Classnotfound exception...

Discussion in 'Plugin Development' started by toughenough6, Sep 23, 2012.

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

    toughenough6

    I know it's a common problem, and I'm still fairly new to bukkit plugin dev, but I can't for the life of me figure this one out! I feel like everything's working fine. Then again, a lot of this was guessing what to do until the red squiggly lines went away in eclipse, because I couldn't find any tutorials on something similar to this.

    Basically, what I'm trying to do is: When a player dies, it gets the killer, and adds one to their number in the hashmap, which means their kill count. Later on, at certain intervals, they will get rewards, etc.

    Here's my error log:
    Show Spoiler

    Code:
    11:14:29 [SEVERE] Could not load 'plugins\KillCounts.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.ClassNotFoundException: me.t
    oughenough6.KillCounts.KillCounts
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:155)
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:305)
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:230)
    at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:222)
    at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:198)
    at net.minecraft.server.ServerConfigurationManagerAbstract.<init>(Server
    ConfigurationManagerAbstract.java:50)
    at net.minecraft.server.ServerConfigurationManager.<init>(SourceFile:11)
     
    at net.minecraft.server.DedicatedServer.init(DedicatedServer.java:105)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:378)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
    Caused by: java.lang.ClassNotFoundException: me.toughenough6.KillCounts.KillCoun
    ts
    at java.net.URLClassLoader$1.run(Unknown Source)
    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:44)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:29)
    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:144)
    ... 9 more
    


    Here's my plugin.yml:
    Show Spoiler

    Code:
    name: KillCounts
    version: 1.0
    description: Counts kills, and does other PVP related things. Made for the Rangers PVP server!
    author: toughenough6 AKA mrhow2minecraft AKA Dan.
    main: me.toughenough6.KillCounts.KillCounts
    permissions:
    killcounts.*:
    description: Gives access to all KillCounts commands
    children:
    killcounts.setcount: true
    killcounts.viewcount: true
    killcounts.topcount: true
    killcounts.viewotherscount: true
    killcounts.setcount:
    description: Allows you to set the count of any player
    default: op
    killcounts.viewcount:
    description: Allows you to view your count.
    default: true
    killcounts.topcount:
    description: Lets you view the top counts.
    default: true
    killcounts.viewotherscount:
    description: Lets you view other players' counts.
    default: true.
    

    (I intend to use those permissions later in the code.)

    Aanndd here's my source:
    Show Spoiler

    Code:
    package me.toughenough6.KillCounts;
     
    import java.util.HashMap;
    import java.util.Map;
     
     
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.plugin.java.JavaPlugin;
     
     
    public class KillCounts extends JavaPlugin{
     
    public int kills = 0;
    public Map<Player, Integer> hashmap = new HashMap<Player, Integer>();
    @EventHandler
    public void onEntityDeath(final PlayerDeathEvent event){
    if(event.getEntity() instanceof Player){
    Player deadplayer = (Player) event.getEntity();
    Player killerplayer = deadplayer.getKiller();
    if(killerplayer == null) {
    return;
    } else {
    killerplayer.sendMessage("You seem to have killed " + deadplayer + ". Congrats.");
    hashmap.put(killerplayer, +1);
    deadplayer.sendMessage("You were killed by " + killerplayer + ". That sucks.");
    }
    }
    }
    }
    

    So, if anyone has any idea how to fix this, I would greatly appreciate it. Maybe even giving me some tips on where to go with this plugin? Right now it's going to be a killcounter with rewards given at certain intervals, and the ability to check your own/others kill counts.
    Thanks!

    Also, I've already looked here, so don't send me there.
     
  2. Offline

    andf54

    Bukkit can't find your KillCounts class.

    Are you sure you dealt with all compilation errors? Are you sure you include KillCounts
    when you create the .jar file?

    Also, don’t store Players in HashMaps, store their names instead.
    Package names begin with a lowercase letter.
    Your plugin needs to have a onEnable() method that registers the events.
    hashmap in not very descriptive.
     
Thread Status:
Not open for further replies.

Share This Page