所以,我想在我的BasicStuff插件(插件名称)中使用 /togglepickaxe,让玩家每次手里拿着镐时都扔掉镐。如果有人也遇到这个问题,请告诉我为什么会发生这种情况,因为我得到了这个多次:/这是我的代码,在执行命令后崩溃服务器:
package MainPackage;
import java.util.LinkedList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin{
public static LinkedList<String> nopickaxeplayers = new LinkedList<String>();
@Override
public void onEnable()
{
System.out.println("TogglePickaxe is enable");
}
@Override
public void onDisable()
{
System.out.println("TogglePickaxe is disabled");
}
public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args)
{
if(cmdlabel.equalsIgnoreCase("togglepickaxe"))
{
if(sender instanceof Player)
{
Player player = (Player) sender;
if(player.hasPermission("BasicStuff.togglepickaxe"))
{
if(args.length == 1)
{
Player trolled_player = Bukkit.getPlayer(args[0]);
if(trolled_player == null)
{
player.sendMessage(ChatColor.RED + args[0] + " is not online");
return false;
}
if(trolled_player.hasPermission("BasicStuff.togglepickaxe.exempt"))
{
player.sendMessage(ChatColor.RED + "You can't deny pickaxe usage on this Player");
return false;
}
if(Main.nopickaxeplayers.contains(trolled_player.getName()))
{
Main.nopickaxeplayers.remove(trolled_player.getName());
trolled_player.sendMessage(ChatColor.GOLD + "You can use Pickaxes again");
player.sendMessage(ChatColor.GOLD + trolled_player.getName() + " can use Pickaxes again");
}
else
{
Main.nopickaxeplayers.add(trolled_player.getName());
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable()
{
@Override
public void run()
{
Player player;
while(Main.nopickaxeplayers.size() > 0)
{
for(int i = 0; i < Main.nopickaxeplayers.size(); i++) {
if(Bukkit.getPlayer(Main.nopickaxeplayers.get(i)) != null)
{
player = Bukkit.getPlayer(Main.nopickaxeplayers.get(i));
if(player.getInventory().getItemInMainHand() != null) {
if(player.getInventory().getItemInMainHand().getType() == Material.DIAMOND_PICKAXE
|| player.getInventory().getItemInMainHand().getType() == Material.GOLDEN_PICKAXE
|| player.getInventory().getItemInMainHand().getType() == Material.IRON_PICKAXE
|| player.getInventory().getItemInMainHand().getType() == Material.NETHERITE_PICKAXE
|| player.getInventory().getItemInMainHand().getType() == Material.STONE_PICKAXE
|| player.getInventory().getItemInMainHand().getType() == Material.WOODEN_PICKAXE
)
{
ItemStack axe = player.getInventory().getItemInMainHand();
player.getInventory().setItemInMainHand(null);
player.getWorld().dropItemNaturally(player.getLocation(), axe);
}
}
}
}
}
}
}, 0, 5);
trolled_player.sendMessage(ChatColor.GOLD + "You can no longer use Pickaxes");
player.sendMessage(ChatColor.GOLD + trolled_player.getName() + " can no longer use Pickaxes");
}
}// if args.length == 1
else
{
player.sendMessage("/togglepickaxe <player>");
}
}
else
{
player.sendMessage(ChatColor.DARK_RED + "You don't have permission to do that");
}
}
else
{
sender.sendMessage(ChatColor.RED + "Only Players can execute /togglepickaxe <player>");
}
}
return false;
}//onCommand
}//阶级
这是一个错误代码,它并不能说明什么(我猜)
[13:11:13 ERROR]: Fatal error trying to convert TogglePickaxe v1.0:MainPackage/Main$1.class
org.bukkit.plugin.AuthorNagException: No legacy enum constant for GOLDEN_PICKAXE. Did you forget to define a modern (1.13+) api-version in your plugin.yml?
at org.bukkit.craftbukkit.v1_16_R3.util.Commodore$1$1.visitFieldInsn(Commodore.java:314) ~[paper.jar:git-Paper-414]
at org.bukkit.craftbukkit.libs.org.objectweb.asm.ClassReader.readCode(ClassReader.java:2415) ~[paper.jar:git-Paper-414]
at org.bukkit.craftbukkit.libs.org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1488) ~[paper.jar:git-Paper-414]
at org.bukkit.craftbukkit.libs.org.objectweb.asm.ClassReader.accept(ClassReader.java:718) ~[paper.jar:git-Paper-414]
at org.bukkit.craftbukkit.libs.org.objectweb.asm.ClassReader.accept(ClassReader.java:401) ~[paper.jar:git-Paper-414]
at org.bukkit.craftbukkit.v1_16_R3.util.Commodore.convert(Commodore.java:174) ~[paper.jar:git-Paper-414]
at org.bukkit.craftbukkit.v1_16_R3.util.CraftMagicNumbers.processClass(CraftMagicNumbers.java:340) ~[paper.jar:git-Paper-414]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:155) ~[paper.jar:git-Paper-414]
at org.bukkit.plugin.java.JavaPluginLoader.getClassByName(JavaPluginLoader.java:216) ~[paper.jar:git-Paper-414]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:122) ~[paper.jar:git-Paper-414]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:111) ~[paper.jar:git-Paper-414]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_251]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_251]
at MainPackage.Main.onCommand(Main.java:67) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper.jar:git-Paper-414]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper.jar:git-Paper-414]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:807) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.PlayerConnection.handleCommand(PlayerConnection.java:2021) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.PlayerConnection.c(PlayerConnection.java:1832) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1785) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:47) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:5) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:23) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1132) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1125) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeAll(IAsyncTaskHandler.java:95) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1261) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:996) ~[paper.jar:git-Paper-414]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:173) ~[paper.jar:git-Paper-414]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_251]
这就是插件。yml:
name: TogglePickaxe
author: StepsisObserver
version: 1.0
main: MainPackage.Main
commands:
togglepickaxe:
description: toggles if a player can use a pickaxe
我用龙头。jar作为参考库,我的服务器是纸质的。jar(不是spigot/bukkit)但对于我的所有其他插件来说:(
我找到了解决办法。。。我在重复任务调度程序中使用了一个while循环。。。我去掉了while(尺寸)
每次启动Farming Valley服务器时,都会出现以下错误: 我基本上没有这方面的经验,我不明白这是怎么回事。如有任何帮助,我们将不胜感激!提前道谢。知道我从OVH那里买了一台服务器可能会很好
我第一次尝试做一个新的命令,并遵循这个教程,虽然有点旧,但我相信它仍然有效。完成后,我试着运行我的mod,一切正常,但我的命令不存在。这是我的密码: 和我实际的类: 它正在调用一个实体,这是我自己创建的,只是一个爆炸威力增加的火球。
严重:初始化连接器[connector[HTTP/1.1-8080]]org.apache.catalina.LifecyCleException失败:尝试为组件[connector[HTTP/1.1-8080]]进行无效的生命周期转换([before_init]),该组件处于状态[INITIALIZED],位于org.apache.catalina.util.LifecyCleBase.inva
Logcat消息: java.lang.IllegalStateException:在Android的父上下文或祖先上下文中找不到方法@={()->ViewModel.OnBtnClicked()(View):在id为“button”的视图类AndroidX.AppCompat.Widget.AppCompatButton上定义的OnClick属性 文件1:activity_main.xml 文件
我正在使用来自ViewPager(在调用活动中)的活动转换,以及共享元素和内容转换。我得到这个崩溃时,重新进入调用活动: 此外,一旦返回,屏幕开始持续闪烁,白色屏幕来回闪烁。 以下是我的转换标志: 我尝试在调用和调用活动上设置进入/退出转换,但没有运气。
我试图用LWJGL编写一个opengl渲染器。为了打开窗户,我用的是GLFW。但是,当我调用glfwCreateWindow时,它会崩溃,出现以下错误: Java运行时环境检测到一个致命错误: 谢了!