gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 12:21:28 33 4
gpt4 key购买 nike

我只是想创建我的第一个简单的 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 "?"

最佳答案

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

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

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

关于java - 我尝试编写我的第一个 Bukkit 插件,但无法安装它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26636376/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com