Solved java.lang.ClassCastException in Plugin

Discussion in 'Plugin Development' started by vemacs, Oct 27, 2012.

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



    I've just written my first plugin, and it would seem to work (except for the PlayerChatEvent deprecation, but it should still work), but I get this in the console when it tries to start:

    Could not load 'plugins\GamemodeDetector.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.ClassCastException: class com.vemacs.GamemodeDetector.GamemodeDetector
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(
        at org.bukkit.craftbukkit.CraftServer.<init>(
        at net.minecraft.server.ServerConfigurationManagerAbstract.<init>(
        at net.minecraft.server.ServerConfigurationManager.<init>(SourceFile:11)
        at net.minecraft.server.DedicatedServer.init(
    Caused by: java.lang.ClassCastException: class com.vemacs.GamemodeDetector.GamemodeDetector
        at java.lang.Class.asSubclass(Unknown Source)
        ... 9 more
    Here's my plugin source (ignore the fact that I don't own, I just want to get it working):
    package com.vemacs.GamemodeDetector;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerChatEvent;
    public class GamemodeDetector implements Listener {
        private GamemodeDetector plugin;
        public GamemodeDetector(GamemodeDetector instance) {
            plugin = instance;
        public void onPlayerMessage(PlayerChatEvent E) {
                Player player = E.getPlayer();
                String playerName = player.getName();
                String message = E.getMessage().toLowerCase();
                Bukkit.broadcastMessage( playerName + "used the /gamemode command!");
    And here's my plugin.yml:
    name: GamemodeDetector
    main: com.vemacs.GamemodeDetector.GamemodeDetector
    version: 1.0
    The plugin.yml is in the package tree, not in the source tree. What's going wrong?
    Thanks for the help. I'm running the latest craftbukkit recommended.

    The project is attached (
  2. Offline

    Sagacious_Zed Bukkit Docs

    Your plugin is not a java plugin,
    Please refer to the documentation. Specifically you failed here
Thread Status:
Not open for further replies.

Share This Page