gpt4 book ai didi

java - 使用此代码给我一个内部错误。怎么修?

转载 作者:行者123 更新时间:2023-11-29 03:18:16 25 4
gpt4 key购买 nike

<分区>

这段代码给我一个错误,我不知道为什么。我已经尝试了很多修复,但都不起作用:/这是我的代码:

public class Main extends JavaPlugin {



public void onEnable() {
this.getCommand("bounty").setExecutor(this);
Bukkit.getServer().getLogger().info("[Bounty] Enabled");
Bukkit.getServer().getLogger().info("[Bounty] Developed by ITaco_v2");

}

public void onDisable() {
Bukkit.getServer().getLogger().info("[Bounty] Disabled");
}



public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
final int b = Integer.parseInt(args[1]);
//Integer to find the bounty amount
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "[" + ChatColor.GREEN + "Bounty" + ChatColor.RED + "] " + ChatColor.GOLD + "In game use only!");
return true;
}

if (cmd.getName().equalsIgnoreCase("bounty")){
if (sender.hasPermission("bounty.setbounty"));
//Command and Permissions


if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "Please specify a Player and a bounty amount.");
sender.sendMessage(ChatColor.GREEN + "Like this: /bounty <playername> <amount>");
return true;
//If player doesn't show enough arguments

}

if (b > 10000){
sender.sendMessage(ChatColor.GRAY + "[" + ChatColor.RED + "Bounty" + ChatColor.GRAY + "] " + ChatColor.BLUE + "The maximum bounty is 10000");
return true;
//Check for maximum bounty

}






final Player target = Bukkit.getServer().getPlayer(args[0]);
//Bounty target variable

if (b <= 10000 && target != null) {
Bukkit.getServer().broadcastMessage(ChatColor.GRAY + "[" + ChatColor.RED + "Bounty" + ChatColor.GRAY + "] " + ChatColor.DARK_GREEN + ChatColor.RED + sender.getName() + "" + " Has set a bounty of " + ChatColor.GRAY + b + ChatColor.DARK_GREEN + " on " + ChatColor.RED + target.getName() + "");
return true;
}

if (target == null) {
sender.sendMessage(ChatColor.RED + "Could not find player!");
return true;
//Checks if target isnt online or cannot be found


}

if (target != null) {
sender.sendMessage(ChatColor.RED + "Please specify a bounty amount.");
sender.sendMessage(ChatColor.GREEN + "Like this: /bounty " + args[0] + " <amount>");
return true;
//If target is online but not enough arguments

}



}




return true;
}
}

我不知道应该如何修复,但这是我的错误。如果有人能帮助我我会很高兴:)

org.bukkit.command.CommandException: Unhandled exception executing command 'bounty' in plugin Bounty v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) ~[craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServer.java:740) ~[craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at net.minecraft.server.v1_7_R4.PlayerConnection.handleCommand(PlayerConnection.java:957) [craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:818) [craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at net.minecraft.server.v1_7_R4.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at net.minecraft.server.v1_7_R4.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:157) [craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at net.minecraft.server.v1_7_R4.ServerConnection.c(SourceFile:134) [craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:258) [craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at com.itaco.bounty.Main.onCommand(Main.java:29) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit-1.7.10-R0.1-20140804.183445-7.jar:git-Bukkit-1.7.9-R0.2-18-ga04b586-b3107jnks]
... 13 more

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