-1
My Bukkitプラグインコマンドは、実行時に常に例外をスローします。My Bukkit Pluginコマンドで例外がスローされる
私は私のコマンドを入力します。/config set
(それは/設定をファイルに情報を保存する必要があります)、私はチャットでこのエラーが表示されます。
、このコマンドを実行するためにattemping中に内部エラーが発生しました。
どうしてですか?
コンソールログ:
[13:23:24 INFO]: whispereq issued server command: /config set
[13:23:24 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'config' in plugin registyPlayer v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:175) ~[src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.java:683) ~[src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerConnection.java:952) [src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:814) [src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java:28) [src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat.java:47) [src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at whispereq.saver.onCommand(saver.java:14) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[src.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
... 13 more
saver
クラスからの私のコード:
package whispereq;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class saver implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("config")) {
if (sender instanceof Player) {
if (args.length == 1) {
if (args[1].equalsIgnoreCase("set")) {
sender.sendMessage("§6Registering player§c " + args[0] + "§6 to Server....");
Player p = (Player) sender;
String nick = p.getName().toLowerCase();
String uid = p.getUniqueId().toString();
boolean op = p.isOp();
GameMode gm = p.getGameMode();
GameMode dgm = Bukkit.getDefaultGameMode();
float exp = p.getExp();
float explvl = p.getExpToLevel();
Main.getInst().getConfig().set("players." + nick + ".uuid", uid);
Main.getInst().getConfig().set("players." + nick + ".isOpped", op);
Main.getInst().getConfig().set("players." + nick + ".CurrentGameMode", gm);
Main.getInst().getConfig().set("players." + nick + ".DefaultGameMode", dgm);
Main.getInst().getConfig().set("players." + nick + ".Exp", exp);
Main.getInst().getConfig().set("players." + nick + ".ExpLevel", explvl);
Main.getInst().saveConfig();
sender.sendMessage("§6Finished!, yours Current in-game Status was SUccesfully registered to the config.yml File in Plugin's Directory. use §c/registy getMe§6 to view your Property.");
return true;
} else if (args[1].equalsIgnoreCase("get")) {
Player p = (Player) sender;
String nick = p.getName().toLowerCase();
if (Main.getInst().getConfig().get("players." + nick) != null) {
p.sendMessage("§8_____________________________________________________");
p.sendMessage(Main.getInst().getConfig().getString("players." + nick + ".uuid"));
p.sendMessage(Main.getInst().getConfig().getString("players." + nick + ".isOpped"));
p.sendMessage(Main.getInst().getConfig().getString("players." + nick + ".CurrentGameMode"));
p.sendMessage(Main.getInst().getConfig().getString("players." + nick + ".DefaultGameMode"));
p.sendMessage(Main.getInst().getConfig().getString("players." + nick + ".Exp"));
p.sendMessage(Main.getInst().getConfig().getString("players." + nick + "ExpLevel"));
p.sendMessage("§8_____________________________________________________");
}
}
}
}
}
return false;
}
}
Main
クラス:
package whispereq;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
public static Main instance;
public void onEnable() {
instance = this;
System.out.println("Loading RegistyPlayer ..");
getCommand("config").setExecutor(new saver());
saveDefaultConfig();
}
public static Main getInst() {
return instance;
}
}
設定ファイル(空):
#-----------------------------------------------------------#
plugin.yml:
name: registyPlayer
version: 1.0
main: whispereq.Main
commands:
config:
Craftbukkit:1.7.2 R03
BukkitのAPI:1.7.2 R03
サーバーCraftbukkit:1.7.2 R03
私を助けてくれてありがとう! – whispereq