我试图编写我的第一个Bukkit插件,但我无法安装它

时间:2014-10-29 16:57:56

标签: java bukkit

我只是想创建我的第一个简单的Bukkit插件,我看了一些教程,但我无法在我的服务器上安装它!

这是我的代码:

package me.valli308.MintCraftBasic;

import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class Example extends JavaPlugin implements Listener {
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }
    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        event.setJoinMessage(ChatColor.AQUA + event.getPlayer().getName() + 
                             " has joined the game");
    }
}

以下是plugin.yml文件:

name: MintCraftBasic
main: me.valli308.MintCraftBasic.Main
version: 1
author: valli308

以下是server.log文件:

2014-10-29 17:47:32 [INFO] Starting minecraft server version 1.6.2
2014-10-29 17:47:32 [WARNING] To start the server with more ram, launch it as "java    -Xmx1024M -Xms1024M -jar minecraft_server.jar"
2014-10-29 17:47:32 [INFO] Loading properties
2014-10-29 17:47:32 [INFO] Default game type: SURVIVAL
2014-10-29 17:47:32 [INFO] Generating keypair
2014-10-29 17:47:32 [INFO] Starting Minecraft server on *:25565
2014-10-29 17:47:32 [INFO] This server is running CraftBukkit version git-Bukkit-1.5.2-R1.0-25-g2a13a5a-b2812jnks (MC: 1.6.2) (Implementing API version 1.6.2-R0.1-SNAPSHOT)
2014-10-29 17:47:32 [SEVERE] Could not load 'plugins\MintCraftBasic.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.ClassCastException: class me.valli308.MintCraftBasic.Main
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:184)
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
    at org.bukkit.craftbukkit.v1_6_R2.CraftServer.loadPlugins(CraftServer.java:239)
    at org.bukkit.craftbukkit.v1_6_R2.CraftServer.<init>(CraftServer.java:217)
    at net.minecraft.server.v1_6_R2.PlayerList.<init>(PlayerList.java:56)
    at net.minecraft.server.v1_6_R2.DedicatedPlayerList.<init>(SourceFile:11)
    at net.minecraft.server.v1_6_R2.DedicatedServer.init(DedicatedServer.java:106)
    at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:391)
    at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
Caused by: java.lang.ClassCastException: class me.valli308.MintCraftBasic.Main
    at java.lang.Class.asSubclass(Unknown Source)
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:174)
    ... 9 more
2014-10-29 17:47:32 [INFO] Preparing level "world"
2014-10-29 17:47:32 [INFO] Preparing start region for level 0 (Seed: 2867628193957491119)
2014-10-29 17:47:32 [WARNING] Could not get information about this CraftBukkit version; perhaps you are running a custom one?: IOException
2014-10-29 17:47:32 [WARNING] Could not get latest artifact information: IOException
2014-10-29 17:47:32 [INFO] Preparing start region for level 1 (Seed: 2867628193957491119)
2014-10-29 17:47:33 [INFO] Preparing start region for level 2 (Seed: 2867628193957491119)
2014-10-29 17:47:33 [INFO] Server permissions file permissions.yml is empty, ignoring it
2014-10-29 17:47:33 [INFO] Done (0,880s)! For help, type "help" or "?"

1 个答案:

答案 0 :(得分:1)

您设置了错误的主类。 选择以下解决方案之一。

  • main: me.valli308.MintCraftBasic.Main文件中的main: me.valli308.MintCraftBasic.Example更改为plugin.yml

  • public class Example extends JavaPlugin implements Listener {文件中的public class Main extends JavaPlugin implements Listener {更改为Example.java,并将其重命名为Main.java