LuizB Postado Março 5, 2016 Denunciar Compartilhar Postado Março 5, 2016 Galera Ta Dando Erro Quando Eu Digito o comando Erro : an internal error occurred while attempting to perform this command Código OnEnable: @SuppressWarnings("deprecation") public class Principal extends JavaPlugin implements Listener{ File file = new File(getDataFolder().getPath(), "presos.yml"); FileConfiguration preso = YamlConfiguration.loadConfiguration(file); public static Principal getNomeFunlibs(){ return (Principal) Bukkit.getServer().getPluginManager().getPlugin("Funlibs"); } public static JavaPlugin instance; @Override public void onEnable() { instance = this; getCommand("spawn").setExecutor(new Spawn()); getCommand("prender").setExecutor(new Comandos()); this.getServer().getPluginManager().registerEvents((Listener)this, (Plugin)this); System.out.println("Plugin ativado"); File f = new File(getDataFolder(), "config.yml"); if(!f.exists()); saveResource("config.yml", false); } Classe Do Comando /prender : package cadeia; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Comandos implements CommandExecutor{ @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player p = (Player) sender; Player targetPlayer = p.getServer().getPlayer(args[0]); if(command.getName().equalsIgnoreCase("prender")) { if(args.length == 0) { p.sendMessage("§cUso Correto:§b /prender <nick> <motivo>"); }else if (args.length == 1) { p.sendMessage("§cUso Correto:§b /prender <nick> <motivo>"); }else if (args.length == 2) { Bukkit.broadcastMessage("O Jogador" + args[0] + "Foi Preso Motivo:" + args[1]); } } return false; } } Link para o comentário Compartilhar em outros sites More sharing options...
??? Postado Março 5, 2016 Denunciar Compartilhar Postado Março 5, 2016 Funcionou, pode me explicar o que tava acontecendo ? Você estava tentando pegar o args[0] antes de verificar, e no lugar de ficar usando sempre args.lenght == 0, args.length == 1, coloquei args.lenght != 2 que significa, enquanto o tamanho dos argumentos for diferente de 2(que é o necessário para realizar a função que deseja), ele manda a mensagem de uso correto, logo após isso que já confirmado que todos os argumentos estão presentes, você pega o player pelo nome(args[0]). 1 Link para o comentário Compartilhar em outros sites More sharing options...
Arkasher Postado Março 5, 2016 Denunciar Compartilhar Postado Março 5, 2016 (editado) Vc colocou "p.getServer().getPlayer(args[0]);" Tenta: Bukkit.getPlayer(args[0]); Editado Março 5, 2016 por Arkasher197 Link para o comentário Compartilhar em outros sites More sharing options...
LuizB Postado Março 5, 2016 Autor Denunciar Compartilhar Postado Março 5, 2016 Vc colocou "p.getServer().getPlayer(args[0]);" Tenta: Bukkit.getPlayer(args[0]); n deu o Problema é que outros comandos em diferentes Classes estão dando Erro tambem Erro: [18:58:02] [Server thread/INFO]: Cuthmf issued server command: /prender [18:58:02] [Server thread/ERROR]: null org.bukkit.command.CommandException: Unhandled exception executing command 'prender' in plugin Funlibs v1.0 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-18fbb24] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:140) ~[craftbukkit.jar:git-Bukkit-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:620) ~[craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1106) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:966) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:37) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:9) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit.jar:git-Bukkit-18fbb24] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_60] at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_60] at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:673) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:629) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:537) [craftbukkit.jar:git-Bukkit-18fbb24] at java.lang.Thread.run(Unknown Source) [?:1.8.0_60] Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at cadeia.Comandos.onCommand(Comandos.java:14) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-18fbb24] ... 15 more Link para o comentário Compartilhar em outros sites More sharing options...
Proyx Postado Março 5, 2016 Denunciar Compartilhar Postado Março 5, 2016 n deu o Problema é que outros comandos em diferentes Classes estão dando Erro tambem Erro: [18:58:02] [Server thread/INFO]: Cuthmf issued server command: /prender [18:58:02] [Server thread/ERROR]: null org.bukkit.command.CommandException: Unhandled exception executing command 'prender' in plugin Funlibs v1.0 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-18fbb24] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:140) ~[craftbukkit.jar:git-Bukkit-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:620) ~[craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1106) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:966) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:37) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:9) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit.jar:git-Bukkit-18fbb24] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_60] at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_60] at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:673) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:629) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:537) [craftbukkit.jar:git-Bukkit-18fbb24] at java.lang.Thread.run(Unknown Source) [?:1.8.0_60] Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at cadeia.Comandos.onCommand(Comandos.java:14) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-18fbb24] ... 15 more Esse erro é o mesmo que ele disse. Não existe args[0], dai ele dá esse erro. Link para o comentário Compartilhar em outros sites More sharing options...
LuizB Postado Março 5, 2016 Autor Denunciar Compartilhar Postado Março 5, 2016 Esse erro é o mesmo que ele disse. Não existe args[0], dai ele dá esse erro. pera n entendi n esta dando só pq eu coloquei /prender ? e n colooquei /prender <nick> <motivo> ? Link para o comentário Compartilhar em outros sites More sharing options...
??? Postado Março 5, 2016 Denunciar Compartilhar Postado Março 5, 2016 (editado) n deu o Problema é que outros comandos em diferentes Classes estão dando Erro tambem Erro: [18:58:02] [Server thread/INFO]: Cuthmf issued server command: /prender [18:58:02] [Server thread/ERROR]: null org.bukkit.command.CommandException: Unhandled exception executing command 'prender' in plugin Funlibs v1.0 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-18fbb24] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:140) ~[craftbukkit.jar:git-Bukkit-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:620) ~[craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1106) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:966) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:37) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:9) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit.jar:git-Bukkit-18fbb24] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_60] at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_60] at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:673) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:629) [craftbukkit.jar:git-Bukkit-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:537) [craftbukkit.jar:git-Bukkit-18fbb24] at java.lang.Thread.run(Unknown Source) [?:1.8.0_60] Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at cadeia.Comandos.onCommand(Comandos.java:14) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-18fbb24] ... 15 more Esse erro é o mesmo que ele disse. Não existe args[0], dai ele dá esse erro. "Não existe args[0], dai ele dá esse erro." if(args.lenght == 0 ){ p.sendMessage("Use /prender <player> <motivo>"); return true; } package cadeia; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Comandos implements CommandExecutor{ @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(command.getName().equalsIgnoreCase("prender")) { if(!(sender instanceof Player)){ sender.sendMessage("§cSomente players"); return true; } Player p = (Player) sender; if(args.length != 2){ p.sendMessage("§cUso Correto:§b /prender <nick> <motivo>"); return true; } Player targetPlayer = p.getServer().getPlayer(args[0]); Bukkit.broadcastMessage("O Jogador" + args[0] + "Foi Preso Motivo:" + args[1]); return true; } return false; } } Editado Março 5, 2016 por Kaway 1 Link para o comentário Compartilhar em outros sites More sharing options...
leonardosc Postado Março 5, 2016 Denunciar Compartilhar Postado Março 5, 2016 Tu ta checando o tamanho dos args depois de já ter usado ele................... os cara ja responderam... Link para o comentário Compartilhar em outros sites More sharing options...
LuizB Postado Março 5, 2016 Autor Denunciar Compartilhar Postado Março 5, 2016 "Não existe args[0], dai ele dá esse erro." if(args.lenght == 0 ){ p.sendMessage("Use /prender <player> <motivo>"); return true; } package cadeia; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Comandos implements CommandExecutor{ @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(command.getName().equalsIgnoreCase("prender")) { if(!(sender instanceof Player)){ sender.sendMessage("§cSomente players"); return true; } Player p = (Player) sender; if(args.length != 2){ p.sendMessage("§cUso Correto:§b /prender <nick> <motivo>"); return true; } Player targetPlayer = p.getServer().getPlayer(args[0]); Bukkit.broadcastMessage("O Jogador" + args[0] + "Foi Preso Motivo:" + args[1]); return true; } return false; } } Funcionou, pode me explicar o que tava acontecendo ? Link para o comentário Compartilhar em outros sites More sharing options...
Proyx Postado Março 5, 2016 Denunciar Compartilhar Postado Março 5, 2016 "Não existe args[0], dai ele dá esse erro." if(args.lenght == 0 ){ p.sendMessage("Use /prender <player> <motivo>"); return true; } package cadeia; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Comandos implements CommandExecutor{ @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(command.getName().equalsIgnoreCase("prender")) { if(!(sender instanceof Player)){ sender.sendMessage("§cSomente players"); return true; } Player p = (Player) sender; if(args.length != 2){ p.sendMessage("§cUso Correto:§b /prender <nick> <motivo>"); return true; } Player targetPlayer = p.getServer().getPlayer(args[0]); Bukkit.broadcastMessage("O Jogador" + args[0] + "Foi Preso Motivo:" + args[1]); return true; } return false; } } me citou porque? Link para o comentário Compartilhar em outros sites More sharing options...
??? Postado Março 6, 2016 Denunciar Compartilhar Postado Março 6, 2016 me citou porque? Pq sua resposta tava certa e eu tava com preguiça de digitar ai furtei tua resposta citando :c Sua dúvida foi marcada como [Resolvido] e movido à área de dúvidas resolvidas. Atenciosamente, Gamer's Board Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
LuizB
Galera Ta Dando Erro Quando Eu Digito o comando
Erro :
an internal error occurred while attempting to perform this commandCódigo OnEnable:
Classe Do Comando /prender :
Link para o comentário
Compartilhar em outros sites
10 respostass a esta questão
Posts Recomendados