1. Es freut uns dass du in unser Minecraft Forum gefunden hast. Hier kannst du mit über 130.000 Minecraft Fans über Minecraft diskutieren, Fragen stellen und anderen helfen. In diesem Minecraft Forum kannst du auch nach Teammitgliedern, Administratoren, Moderatoren , Supporter oder Sponsoren suchen. Gerne kannst du im Offtopic Bereich unseres Minecraft Forums auch über nicht Minecraft spezifische Themen reden. Wir hoffen dir gefällt es in unserem Minecraft Forum!

Wo liegt das Problem ^^ [PLEASE HELP] [PRGRAMMIREN BUKKIT] [COMMAND]

Dieses Thema im Forum "Programmierung" wurde erstellt von necnuc, 19. Februar 2014.


  1. necnuc
    Offline

    necnuc

    Registriert seit:
    15. Dezember 2013
    Beiträge:
    36
    Minecraft:
    necnuc | Der Kunde
    Hey Comm.
    Ich brauche heute mal eure Hilfe bei einem Command der bei mir nicht funkzioniert aber ich weis nicht warum ?

    Code (Text):
    1. package de.necnuc.cmd;
    2.  
    3. import java.io.IOException;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandExecutor;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.EventHandler;
    11. import org.bukkit.event.Listener;
    12. import org.bukkit.event.player.PlayerLoginEvent;
    13. import org.bukkit.event.player.PlayerLoginEvent.Result;
    14.  
    15. import de.necnuc.DATA.Data;
    16.  
    17. public class CommandBan
    18. implements CommandExecutor ,Listener
    19. {
    20.    
    21.    
    22.      public static void addwarn(Player targ, int anzahl){
    23.          
    24.          int Warns = Data.baninfocfg.getInt("Player." + targ + ".warns");
    25.          Warns += anzahl;
    26.          
    27.          Data.baninfocfg.set("Player." + targ + ".warns", Warns);
    28.        }
    29.  
    30.     @Override
    31.     public boolean onCommand(CommandSender sender, Command cmd, String label,String[] args) {
    32.        Player p = (Player)sender;
    33.  
    34.        if(cmd.getName().equalsIgnoreCase("Warn")){
    35.            if(!(p.hasPermission("MZS.BANSTATE"))){
    36.                p.sendMessage(Data.messinfocfg.getString("Messages.NoPermission"));
    37.            } else {
    38.            
    39.            if(args.length > 2){
    40.                p.sendMessage("§c/warn <player> <grund>");
    41.            } else {
    42.            
    43.                Player target = Bukkit.getPlayer(args[0]);
    44.                String grund = args[1].replace("&", "§");
    45.                
    46.                if(Data.baninfocfg.getString("Player." + target + ".warns") == null){
    47.                    Data.baninfocfg.set("Player." + target + ".warns", 0);
    48.                    Data.baninfocfg.set("Player." + target + ".banstate", false);
    49.                    try {
    50.                     Data.baninfocfg.save(Data.baninfo);
    51.                 } catch (IOException e) {
    52.                     // TODO Auto-generated catch block
    53.                     e.printStackTrace();
    54.                 }
    55.                }
    56.                
    57.                String mess = Data.messinfocfg.getString("Messages.Warn").replace("&", "§").replace("%target", target.getName()).replace("%player", p.getName()).replace("%grund", grund);
    58.                
    59.                Bukkit.broadcastMessage(mess);
    60.                
    61.               this.addwarn(target, 1);
    62.              
    63.               if(Data.baninfocfg.getInt("Player." + target + ".warns") == 10){
    64.                   Data.baninfocfg.set("Player." + target + ".banstate", true);
    65.                   Bukkit.getOfflinePlayer("System").getPlayer().kickPlayer(target.getName());
    66.               } else
    67.               if(Data.baninfocfg.getInt("Player." + target + ".warns") == 9){
    68.                   target.sendMessage("§cDas ist jetzt dein 9. Warn, 1 Warn noch und du wirst automatich gebannt !");
    69.                  
    70.                try {
    71.                 Data.baninfocfg.save(Data.baninfo);
    72.             } catch (IOException e) {
    73.                 // TODO Auto-generated catch block
    74.                 e.printStackTrace();
    75.             }
    76.                  
    77.               }
    78.                
    79.                try {
    80.                 Data.baninfocfg.save(Data.baninfo);
    81.             } catch (IOException e) {
    82.                 // TODO Auto-generated catch block
    83.                 e.printStackTrace();
    84.             }
    85.                
    86.            }
    87.            }
    88.        }
    89.        
    90.        
    91.        if(cmd.getName().equalsIgnoreCase("Ban")){
    92.            if(!(p.hasPermission("MZS.BANSTATE"))){
    93.                p.sendMessage(Data.messinfocfg.getString("Messages.NoPermission"));
    94.            } else {
    95.            Player target = Bukkit.getPlayer(args[0]);
    96.            Data.baninfocfg.set("Player." + target + ".banstate", true);
    97.            Bukkit.getOfflinePlayer("System").getPlayer().kickPlayer(target.getName());
    98.            try {
    99.             Data.baninfocfg.save(Data.baninfo);
    100.         } catch (IOException e) {
    101.             // TODO Auto-generated catch block
    102.             e.printStackTrace();
    103.         }
    104.            }
    105.        }
    106.         return false;
    107.     }
    108.    
    109.    
    110.     @EventHandler
    111.     public void onBanKick(PlayerLoginEvent e){
    112.         Player jlp = e.getPlayer();
    113.         if(Data.baninfocfg.getBoolean("Player." + jlp.getName() + "banstate") == true){
    114.             e.disallow(Result.KICK_BANNED, Data.messinfocfg.getString("Messages.CantJoinBanned"));
    115.         }
    116.     }
    117.    
    118.    
    119.  
    120. }
    121.  
     
  2. Werbung
    Online

    Werbung

  3. Benutzer
    Offline

    Benutzer

    Registriert seit:
    1. November 2012
    Beiträge:
    56
    Wo genau liegt denn der Fehler?
     
  4. necnuc
    Offline

    necnuc

    Registriert seit:
    15. Dezember 2013
    Beiträge:
    36
    Minecraft:
    necnuc | Der Kunde
    ...

    Wen ich den cmd eingebe kommt ein Error
     
  5. Pappi
    Offline

    Pappi Gesperrt

    Registriert seit:
    28. Oktober 2012
    Beiträge:
    141
    Minecraft:
    Pappi / PapaHarni
    Teilst du uns den Error auch mit? Oder sollen wir uns einen aussuchen?
     
  6. necnuc
    Offline

    necnuc

    Registriert seit:
    15. Dezember 2013
    Beiträge:
    36
    Minecraft:
    necnuc | Der Kunde
    Error

    Code (Text):
    1. [12:15:03] [Server thread/INFO]: necnuc issued server command: /ban
    2. [12:15:03] [Server thread/ERROR]: null
    3. org.bukkit.command.CommandException: Unhandled exception executing command 'ban' in plugin MZS v0.1
    4.     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    5.     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:175) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    6.     at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.java:683) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    7.     at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerConnection.java:952) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    8.     at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:814) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    9.     at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    10.     at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    11.     at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    12.     at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    13.     at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    14.     at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    15.     at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    16.     at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    17.     at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    18. Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
    19.     at de.necnuc.cmd.CommandBan.onCommand(CommandBan.java:95) ~[?:?]
    20.     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    21.     ... 13 more
    - - - Aktualisiert - - -

    Code (Text):
    1. [12:26:23] [Server thread/INFO]: Plattio issued server command: /ban
    2. [12:26:23] [Server thread/ERROR]: null
    3. org.bukkit.command.CommandException: Unhandled exception executing command 'ban' in plugin MZS v0.1
    4.     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    5.     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:175) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    6.     at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.java:683) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    7.     at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerConnection.java:952) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    8.     at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:814) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    9.     at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    10.     at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    11.     at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    12.     at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    13.     at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    14.     at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    15.     at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    16.     at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    17.     at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    18. Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
    19.     at de.necnuc.cmd.CommandBan.onCommand(CommandBan.java:95) ~[?:?]
    20.     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    21.     ... 13 more












    Code (Text):
    1. package de.necnuc.cmd;
    2.  
    3. import java.io.IOException;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandExecutor;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.EventHandler;
    11. import org.bukkit.event.Listener;
    12. import org.bukkit.event.player.PlayerLoginEvent;
    13. import org.bukkit.event.player.PlayerLoginEvent.Result;
    14.  
    15. import de.necnuc.DATA.Data;
    16.  
    17. public class CommandBan
    18. implements CommandExecutor ,Listener
    19. {
    20.    
    21.    
    22.      public static void addwarn(Player targ, int anzahl){
    23.          
    24.          int Warns = Data.baninfocfg.getInt("Player." + targ + ".warns");
    25.          Warns += anzahl;
    26.          
    27.          Data.baninfocfg.set("Player." + targ + ".warns", Warns);
    28.        }
    29.  
    30.     @Override
    31.     public boolean onCommand(CommandSender sender, Command cmd, String label,String[] args) {
    32.        Player p = (Player)sender;
    33.  
    34.        if(cmd.getName().equalsIgnoreCase("Warn")){
    35.            if(!(p.hasPermission("MZS.BANSTATE"))){
    36.                p.sendMessage(Data.messinfocfg.getString("Messages.NoPermission"));
    37.            } else {
    38.            
    39.            if(args.length > 2){
    40.                p.sendMessage("§c/warn <player> <grund>");
    41.            } else if(args.length < 2){
    42.            
    43.                Player target = Bukkit.getPlayer(args[0]);
    44.                String grund = args[1].replace("&", "§");
    45.                
    46.                if(Data.baninfocfg.getString("Player." + target + ".warns") == null){
    47.                    Data.baninfocfg.set("Player." + target + ".warns", 0);
    48.                    Data.baninfocfg.set("Player." + target + ".banstate", false);
    49.                    try {
    50.                     Data.baninfocfg.save(Data.baninfo);
    51.                 } catch (IOException e) {
    52.                     // TODO Auto-generated catch block
    53.                     e.printStackTrace();
    54.                 }
    55.                }
    56.                
    57.                String mess = Data.messinfocfg.getString("Messages.Warn").replace("&", "§").replace("%target", target.getName()).replace("%player", p.getName()).replace("%grund", grund);
    58.                
    59.                Bukkit.broadcastMessage(mess);
    60.                
    61.               this.addwarn(target, 1);
    62.              
    63.               if(Data.baninfocfg.getInt("Player." + target + ".warns") == 10){
    64.                   Data.baninfocfg.set("Player." + target + ".banstate", true);
    65.                   Bukkit.getOfflinePlayer("System").getPlayer().kickPlayer(target.getName());
    66.               } else
    67.               if(Data.baninfocfg.getInt("Player." + target + ".warns") == 9){
    68.                   target.sendMessage("§cDas ist jetzt dein 9. Warn, 1 Warn noch und du wirst automatich gebannt !");
    69.                  
    70.                try {
    71.                 Data.baninfocfg.save(Data.baninfo);
    72.             } catch (IOException e) {
    73.                 // TODO Auto-generated catch block
    74.                 e.printStackTrace();
    75.             }
    76.                  
    77.               }
    78.                
    79.                try {
    80.                 Data.baninfocfg.save(Data.baninfo);
    81.             } catch (IOException e) {
    82.                 // TODO Auto-generated catch block
    83.                 e.printStackTrace();
    84.             }
    85.                
    86.            }
    87.            }
    88.        }
    89.        
    90.        
    91.        if(cmd.getName().equalsIgnoreCase("Ban")){
    92.            if(!(p.hasPermission("MZS.BANSTATE"))){
    93.                p.sendMessage(Data.messinfocfg.getString("Messages.NoPermission"));
    94.            } else if(args.length < 1){
    95.            Player target = Bukkit.getPlayer(args[0]);
    96.            Data.baninfocfg.set("Player." + target + ".banstate", true);
    97.            Bukkit.getOfflinePlayer("System").getPlayer().kickPlayer(target.getName());
    98.            try {
    99.             Data.baninfocfg.save(Data.baninfo);
    100.         } catch (IOException e) {
    101.             // TODO Auto-generated catch block
    102.             e.printStackTrace();
    103.         }
    104.            }
    105.        }
    106.         return false;
    107.     }
    108.    
    109.    
    110.     @EventHandler
    111.     public void onBanKick(PlayerLoginEvent e){
    112.         Player jlp = e.getPlayer();
    113.         if(Data.baninfocfg.getBoolean("Player." + jlp.getName() + "banstate") == true){
    114.             e.disallow(Result.KICK_BANNED, Data.messinfocfg.getString("Messages.CantJoinBanned"));
    115.         }
    116.     }
    117.    
    118.    
    119.  
    120. }
    121.  
     
  7. Pappi
    Offline

    Pappi Gesperrt

    Registriert seit:
    28. Oktober 2012
    Beiträge:
    141
    Minecraft:
    Pappi / PapaHarni