Error on console when I launch my plugin

Discussion in 'Programming' started by Azen0x, Jun 25, 2015.

  1. Hi,
    I try to create my first plugin ! I use bukkit-1.8.1-R4-20111031.021102-1.

    But I have some problems when I start my server...
    I show you my error :

    [16:10:20 INFO]: [Test_2_events] Enabling Test_2_events v1.0.0
    [16:10:20 ERROR]: Error occurred while enabling Test_2_events v1.0.0 (Is it up t
    o date?)
    java.lang.NoClassDefFoundError: org/bukkit/event/Event$Type
    at fr.azenox.test_2_events.Main.onEnable(Main.java:21) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[c
    raftbukkit-1.8.jar:git-Bukkit-726656b]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader
    .java:327) [craftbukkit-1.8.jar:git-Bukkit-726656b]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage
    r.java:404) [craftbukkit-1.8.jar:git-Bukkit-726656b]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugin(CraftServer.jav
    a:341) [craftbukkit-1.8.jar:git-Bukkit-726656b]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.enablePlugins(CraftServer.
    java:313) [craftbukkit-1.8.jar:git-Bukkit-726656b]
    at net.minecraft.server.v1_8_R1.MinecraftServer.q(MinecraftServer.java:3
    94) [craftbukkit-1.8.jar:git-Bukkit-726656b]
    at net.minecraft.server.v1_8_R1.MinecraftServer.k(MinecraftServer.java:3
    62) [craftbukkit-1.8.jar:git-Bukkit-726656b]
    at net.minecraft.server.v1_8_R1.MinecraftServer.a(MinecraftServer.java:3
    17) [craftbukkit-1.8.jar:git-Bukkit-726656b]
    at net.minecraft.server.v1_8_R1.DedicatedServer.init(DedicatedServer.jav
    a:190) [craftbukkit-1.8.jar:git-Bukkit-726656b]
    at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java
    :484) [craftbukkit-1.8.jar:git-Bukkit-726656b]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]
    Caused by: java.lang.ClassNotFoundException: org.bukkit.event.Event$Type
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:67) ~[craftbukkit-1.8.jar:git-Bukkit-726656b]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:62) ~[craftbukkit-1.8.jar:git-Bukkit-726656b]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_45]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_45]
    ... 12 more

    My plugin is called "Test_2_events", and there is the source code:


    package fr.azenox.test_2_events;

    import java.util.logging.Logger;

    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;


    public class Main extends JavaPlugin implements Listener {

    public Logger Log = Logger.getLogger("Minecraft");

    public void onEnable() {
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvent(Event.Type.PLAYER_JOIN, this, Priority.Normal, this);
    Log.info(ChatColor.RED + "[Test_2]" + ChatColor.WHITE + " Chargement du plugin reussi");
    }

    public void onDisable() {
    Log.info(ChatColor.RED + "[Test_2]" + ChatColor.WHITE + " Déchargement du plugin reussi");
    }


    public void onJoin(PlayerJoinEvent e){
    if(e.getPlayer() instanceof Player){
    e.getPlayer().sendMessage("§c[Test_2] §aHELLO " + e.getPlayer() + " !");
    }
    }

    }

    I want to create my a plugin with an event which when someone is connecting on server, It say "Hello" !

    Can you help me please ?
     
  2. You're registering your listener wrong.

    It should be pm.registerEvent(this, this). I believe.

    Also, Use @EventHandler to set your listener priority.