gpt4 book ai didi

Could not load 'plugins\TownTheServer-1.0-SNAPSHOT.jar' in folder 'plugins'(无法在文件夹“plugins”中加载“plugins\TownTheServer-1.0-SNAPSHOT.jar”)

转载 作者:bug小助手 更新时间:2023-10-22 16:11:31 30 4
gpt4 key购买 nike



When starting the server, refuses to load my plugin with an error:

启动服务器时,拒绝加载我的插件,并出现错误:


Could not load 'plugins\TownTheServer-1.0-SNAPSHOT.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: main class `me.fixegg.towntheserver.CityCreateCommand' does not extend JavaPlugin
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:145) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:394) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:301) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:381) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:224) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:928) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.ClassCastException: class me.fixegg.towntheserver.CityCreateCommand
at java.lang.Class.asSubclass(Class.java:3853) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:74) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]

My code:

我的代码:


1) CityCreateCommand.java:

1) 城市创建命令.java:


package me.fixegg.towntheserver;

import org.bukkit.Chunk;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.HashMap;
import java.util.Map;

public class CityCreateCommand implements CommandExecutor {
private final Map<String, Chunk> cityChunks;

public CityCreateCommand() {
this.cityChunks = new HashMap<>();
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command can only be executed by a player.");
return true;
}

if (args.length != 1) {
sender.sendMessage("Usage: /t citycreate <cityName>");
return true;
}

Player player = (Player) sender;
String cityName = args[0];
Chunk chunk = player.getLocation().getChunk();

cityChunks.put(cityName, chunk);

sender.sendMessage("City '" + cityName + "' created with coordinates: " +
"X: " + chunk.getX() + ", Z: " + chunk.getZ());

return true;
}

// Run this method periodically to check if players are standing on the saved city chunks
public void checkCityChunks() {
for (Map.Entry<String, Chunk> entry : cityChunks.entrySet()) {
String cityName = entry.getKey();
Chunk chunk = entry.getValue();

for (Player player : chunk.getWorld().getPlayers()) {
if (player.getLocation().getChunk().equals(chunk)) {
System.out.println(player.getName() + " is in city: " + cityName);
}
}
}
}
}


2) plugin.yml:

2) plugin.yml:


name: CityCreateCommand
version: 1.0

main: me.fixegg.towntheserver.CityCreateCommand

api-version: '1.16'
# Chat Command Description /t citycreate
commands:
citycreate:
description: Create new Town on player position
aliases: [cc]
usage: /t citycreate <cityName>

# Rights for command
permissions:
towntheserver.citycreate:
description: Allows the player to use the command /t citycreate
default: true



  1. pom.xml:


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>me.fixegg</groupId>
<artifactId>TownTheServer</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>TownTheServer</name>

<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>.

I tried to find an answer and solve this problem on my own, but I did not succeed. My Java runtime doesn't detect any syntax errors, compilation succeeds too. I don’t know what the problem is, so I will be glad to absolutely any answer, I wish you all the best!

我试图找到答案并独自解决这个问题,但没有成功。我的Java运行时没有检测到任何语法错误,编译也成功了。我不知道问题出在哪里,所以我很乐意得到任何答案,祝你一切顺利!


更多回答

Follow the error message: "main class me.fixegg.towntheserver.CityCreateCommand' does not extend JavaPlugin". In other words, either CityCreateCommand` needs to extend JavaPlugin, or your actual JavaPlugin-derived class needs to be the main specified in the plugin.yml.

遵循错误消息:“main class me.fixegg.towntheserver.CityCreateCommand”不扩展JavaPlugin。换句话说,CityCreateCommand`需要扩展JavaPlugin,或者实际的JavaPlugin派生类需要是plugin.yml中指定的main。

优秀答案推荐

You should have a main class which extend JavaPlugin. For example:

您应该有一个扩展JavaPlugin的主类。例如:


public class TownTheServer extends JavaPlugin {
@Override
public void onEnable() {
getCommand("citycreate").setExecutor(new CityCreateCommand());
}
}

Then, edit the plugin.yml file to let "main" value be the direction to the JavaPlugin's class as this:

然后,编辑plugin.yml文件,使“main”值成为JavaPlugin类的方向,如下所示:


main: me.fixegg.towntheserver.TownTheServer

更多回答

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