需要有关minecraft插口插件的帮助。
这是布局(或者构建路径,如果您想这样称呼它的话)
下面是主文件(main.java)的代码
package com.angosa;
import org.bukkit.plugin.java.JavaPlugin;
import com.angosa.listener.Listeners;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new Listeners(), this);
}
}
下面是listeners.java(在listener包中)的代码
package com.angosa.listener;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
public class Listeners implements Listener {
@EventHandler
public void creatureSpawn(CreatureSpawnEvent event) {
if(event.getEntityType() == EntityType.CREEPER) {
Creeper creeper = (Creeper) event.getEntity();
creeper.setPowered(true);
creeper.setHealth(100);
creeper.setExplosionRadius(200);
}
}
}
这是yml文件
main: com.angosa.Main
name: OPCreeper
version: 1.0
author: Claim
另外,如果版本不对,下面是我上传到服务器时的样子。
[18:06:11 ERROR]: Could not load 'plugins/OPCreeper.jar' in folder 'plugins'
org.bukkit.plugin.invaliddescriptionexception:org.bukkit.plugin.java.javapluginloader.getplugindescription(javapluginloader)上的invalid plugin.yml。java:170)~[插口-1.16.4。jar:git-spigot-37d799b-3eb7236]在org.bukkit.plugin.simplepluginmanager.loadplugins(simplepluginmanager。java:144)~[插口-1.16.4。jar:git-spigot-37d799b-3eb7236]在org.bukkit.craftbukkit.v1\u 16\u r3.craftserver.loadplugins(craftserver。java:383)~[插口-1.16.4。jar:git-spigot-37d799b-3eb7236]在net.minecraft.server.v1\u 16\u r3.dedicatedserver.init(dedicatedserver。java:185)~[插口-1.16.4。jar:git-spigot-37d799b-3eb7236]在net.minecraft.server.v1\u 16\u r3.minecraftserver.w(minecraftserver。java:808) ~[插口-1.16.4。jar:git-spigot-37d799b-3eb7236]在net.minecraft.server.v1\u 16\u r3.minecraftserver.lambda$0(minecraftserver。java:164)~[插口-1.16.4。jar:git-spigot-37d799b-3eb7236]在java.lang.thread.run(线程。java:832)[?:?]原因:org.yaml.snakeyaml.scanner.scannerexception:在扫描下一个标记时发现字符“\t(tab)”,该字符无法启动任何令牌(不要在“reader”第7行第1列中使用\t(制表符)进行缩进:
^
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:419) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:227) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:558) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:148) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:235) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:162) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:95) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:119) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:150) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:472) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.Yaml.load(Yaml.java:411) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:252) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:165) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
... 6 more
2条答案
按热度按时间yyyllmsg1#
我在第一个控制台行中看到问题:
最后你可以看到:
在我看来,你只需要:
清除plugin.yml文件并重新正确填充(不使用tab键)
将plugin.yml文件放入src文件夹
导出前保存*
但是当你发送这个线程时,正确的值是:
所以别忘了在导出你的插件之前保存,我一点也不确定,但这可能是问题所在*
为向您展示我正在使用的插件示例:
https://i.stack.imgur.com/55jve.png :package explorer和plugin.ymlhttps://i.stack.imgur.com/tiwpn.png :主类
(本例中orbedisplay.java=main.java)
如果这之后不起作用,我会寻找另一个解决方案,所以随时通知我。
对不起,我的英语不好,我来自法国,我刚刚开始学习。
wwodge7n2#
不要在yaml文件中使用标签,比如plugin.yml,而是使用空格