Plugin Errors

Discussion in 'Plugin Development' started by Smith__, Mar 2, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    Smith__

    Ok so this is going to need help on like a lot of these, now I know a decent amount of coding, I cannot figure this out. So the error is an Internal Error when I do /warning now it should just say No permission or Usage, but It just shows up with an error, please help, thank you.
    Code:
    Plugin.yml
    name: Emotions
    main: me.LilBaconBits.Emotions
    version: 1.0
    commands:
       slap:
          description: real way to slap someone you hate!
          usage: /<command>
       punch:
          description: real men use this besides slapping them!
          usage: /<command>
       backhand:
          description: Make there face red from your hand!
          usage: /<command>
       warning:
          description: Broadcast a warning.
          usage: /<command>
       alert:
          description: Broadcast an Alert Message.
          usage: /<command>
    
    
    Code:
    Direct Code:
    package me.LilBaconBits;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Sound;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.permissions.Permission;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    import org.bukkit.util.io.BukkitObjectInputStream;
    
    public class Emotions extends JavaPlugin {
        public Permission Slap = new Permission ("Emotion.Slap");
        public Permission Punch = new Permission ("Emotion.Punch");
        public Permission BackHand = new Permission ("emotion.backhand");
        public Permission Broadcast = new Permission ("Broadcast.alert");
        public Permission Warning = new Permission ("Broadcast.warning");
    
        @Override
        public void onEnable() {
            getLogger().info("Emotions has been Enabled.");
            PluginManager pm = getServer().getPluginManager();
            pm.addPermission(Slap);
            pm.addPermission(Punch);
            pm.addPermission(BackHand);
            pm.addPermission(Broadcast);
        }
        @Override
        public void onDisable() {
    
        }
    
        public boolean onCommand(CommandSender sender, Command command, String cmd,
                String[] args) {
            Player target = Bukkit.getServer().getPlayer(args[0]);
            String t = Bukkit.getServer().getPlayer(args[0]).getName();
            Player p = (Player) sender;
            String name = sender.getName();
            Location location = p.getLocation();
            if (cmd.equalsIgnoreCase("slap")){
                if (!(sender instanceof Player)) {
                    sender.sendMessage("Really, Only players can slap players.");
    
                } else {
                    if (!p.hasPermission(Slap)){
                        p.sendMessage("§4Ummmmm No.");
    
                    } else if (args.length == 0) {
                        p.sendMessage("§aPlease enter a persons name to slap!");
                    } else {
                        getServer().broadcastMessage("§b" + name + " " + "§3Slapped§b " + t);
                        p.playSound(location,Sound.CAT_MEOW,1, 0);
                        target.playSound(location, Sound.CAT_HIT, 1, 0);
                        target.sendMessage("§bYour face has a hand print on it...");
                    }
                }
            }
            if (cmd.equalsIgnoreCase("punch")){
                if (!(sender instanceof Player)) {
                    sender.sendMessage("You really wanna punch someone then...");
    
                } else {
                    if (!p.hasPermission(Punch)){
                        p.sendMessage("§4Haha Funny.");
    
                    } else if (args.length == 0) {
                        p.sendMessage("§aPlease enter a persons name to punch");
                    } else {
                        getServer().broadcastMessage("§c" + name + " " + "§4Punched§c " + t + " §4in the face!");
                        target.sendMessage("§cOh your face! oh wait, thats your normal look.");
                        p.playSound(location,Sound.LEVEL_UP,1, 0);
                        target.playSound(location, Sound.SKELETON_HURT, 1, 0);
                    }
                }
            }
            if (cmd.equalsIgnoreCase("punch")){
                if (!(sender instanceof Player)) {
                    sender.sendMessage("You really wanna punch someone then...");
    
                } else {
                    if (!p.hasPermission(Punch)){
                        p.sendMessage("§4Haha Funny.");
    
                    } else if (args.length == 0) {
                        p.sendMessage("§aPlease enter a persons name to punch");
                    } else {
                        getServer().broadcastMessage("§c" + name + " " + "§4Punched§c " + t + " §4in the face!");
                        target.sendMessage("§cOh your face! oh wait, thats your normal look.");
                        p.playSound(location,Sound.LEVEL_UP,1, 0);
                        target.playSound(location, Sound.SKELETON_HURT, 1, 0);
                    }
                }
            }
            if (cmd.equalsIgnoreCase("backhand")){
                if (!(sender instanceof Player)) {
                    sender.sendMessage("Haha leave there face burning, sorry but only for players :)");
    
                } else {
                    if (!p.hasPermission(Punch)){
                        p.sendMessage("§4Haha Funny.");
    
                    } else if (args.length == 0) {
                        p.sendMessage("§aPlease enter a persons name to punch");
                    } else {
                        getServer().broadcastMessage("§a" + name + " " + "§2backhanded§a " + t + "'s §2face!");
                        target.sendMessage("§aOuch! Thats gotta burn...");
                        p.playSound(location,Sound.SHOOT_ARROW,1, 0);
                        target.playSound(location, Sound.GHAST_DEATH, 1, 0);
                    }
                }
            }
            if (cmd.equalsIgnoreCase("alert")){
    
                if (!p.hasPermission(Broadcast)){
                    p.sendMessage("§8[§4Alert§8] §cNope.");
    
                } else if(args.length == 0){
                    p.sendMessage("§8[§4Alert§8] §cUsage: /alert <Message>");
    
                } else {
                    getServer().broadcastMessage("§8[§4Alert§8] §c" + message(args));
                }
            }
            if (cmd.equalsIgnoreCase("warning")){
                if(!p.hasPermission(Warning)){
                    p.sendMessage("§8[§4Warning§8] §cYou do not have permissions to /warning");
                }
                if(args.length == 0){
                    p.sendMessage("§8[§4Warning§8] §c/warnings list to see the full list of warnings.");
                }
                if(args[0].equalsIgnoreCase("list")){
                    p.sendMessage("§8[§4Warning's§8]");
                    p.sendMessage("§4Warning §creload §7Shows a list of reload timers.");
                }
                if(args[0].equalsIgnoreCase("reload")){
                    if(args.length < 3){
                    p.sendMessage("§8[§4Reload List§8]");
                    p.sendMessage("§4Reload 10");
                    }
                }
            }
            return true;
        }
        public String message(String[] args) {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < args.length; i++) {
                builder.append(args[i]);
                builder.append(" ");
            }
            return builder.toString().trim();
        }
    }
    
    
    Code:
    Console Log:
    Slap:
    02.03 23:11:14 [Server] INFO LilBaconBits issued server command: /slap 02.03 23:11:14 [Server] ERROR null 02.03 23:11:14 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'slap' in plugin Emotions v1.0 02.03 23:11:14 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_121] 02.03 23:11:14 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_121] 02.03 23:11:14 [Server] INFO at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121] 02.03 23:11:14 [Server] INFO Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 02.03 23:11:14 [Server] INFO at me.LilBaconBits.Emotions.onCommand(Emotions.java:41) ~[?:?] 02.03 23:11:14 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:11:14 [Server] INFO ... 15 more
    
    Punch (For some reason It does the broadcast twice):
    02.03 23:12:10 [Server] INFO LilBaconBits issued server command: /punch 02.03 23:12:10 [Server] ERROR null 02.03 23:12:10 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'punch' in plugin Emotions v1.0 02.03 23:12:10 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_121] 02.03 23:12:10 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_121] 02.03 23:12:10 [Server] INFO at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121] 02.03 23:12:10 [Server] INFO Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 02.03 23:12:10 [Server] INFO at me.LilBaconBits.Emotions.onCommand(Emotions.java:41) ~[?:?] 02.03 23:12:10 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:10 [Server] INFO ... 15 more
    
    Backhand:
    02.03 23:12:50 [Server] INFO LilBaconBits issued server command: /backhand 02.03 23:12:50 [Server] ERROR null 02.03 23:12:50 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'backhand' in plugin Emotions v1.0 02.03 23:12:50 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_121] 02.03 23:12:50 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_121] 02.03 23:12:50 [Server] INFO at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121] 02.03 23:12:50 [Server] INFO Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 02.03 23:12:50 [Server] INFO at me.LilBaconBits.Emotions.onCommand(Emotions.java:41) ~[?:?] 02.03 23:12:50 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:12:50 [Server] INFO ... 15 more
    
    Warning:
    02.03 23:15:19 [Server] INFO LilBaconBits issued server command: /warning 02.03 23:15:19 [Server] ERROR null 02.03 23:15:19 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'warning' in plugin Emotions v1.0 02.03 23:15:19 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_121] 02.03 23:15:19 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_121] 02.03 23:15:19 [Server] INFO at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121] 02.03 23:15:19 [Server] INFO Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 02.03 23:15:19 [Server] INFO at me.LilBaconBits.Emotions.onCommand(Emotions.java:41) ~[?:?] 02.03 23:15:19 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:19 [Server] INFO ... 15 more
    
    Alert:
    02.03 23:15:58 [Server] INFO LilBaconBits issued server command: /alert 02.03 23:15:58 [Server] ERROR null 02.03 23:15:58 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'alert' in plugin Emotions v1.0 02.03 23:15:58 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_121] 02.03 23:15:58 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_121] 02.03 23:15:58 [Server] INFO at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121] 02.03 23:15:58 [Server] INFO Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 02.03 23:15:58 [Server] INFO at me.LilBaconBits.Emotions.onCommand(Emotions.java:41) ~[?:?] 02.03 23:15:58 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52] 02.03 23:15:58 [Server] INFO ... 15 more
    
    
     
  2. Offline

    timtower Administrator Administrator Moderator

    Moved to plugin development.
     
  3. Offline

    Zombie_Striker

    Please read this. No one should be on 1.8 anymore. Please update


    Don't log your own plugins. Bukkit does this for you. remove this line

    If the onDisable does nothing, delete it.

    1. Only create these variables when they are needed. By creating them at the top of the class, all of your commands will create the exact same variables even if they are not needed.
    2. Don't create sender before you check. Move the player line to be below the instanceof checl.
    3. name is just one sender plus one method. You do not need to create name. Same with the location.
    4. Main problem: You are automatically assuming a first arg exists without checking if the player provided any args. Make sure there is a first arg before getting the target (and check if the first arg exists by checking if the args length is greater or equal to 1)
     
  4. Offline

    MaxFireIce

    @Smith__

    On the punch, it is broadcasting twice because you check the command name twice (use if cmd.equals(Punch) and added code) so therefore it checks twice and broadcasts twice ;). Also, @Zombie_Striker and @Smith__ , where is this coming from?
     
  5. Offline

    Smith__

    @MaxFireIce
    If the end means Java:41 meaning the Line, this is line 41.
    Code:
    Player target = Bukkit.getServer().getPlayer(args[0]);
    @Zombie_Striker
    I dont understand what your saying here, could you clarify a little more please?
    Thank you guys for replying!
     
  6. Offline

    Zombie_Striker

    @MaxFireIce
    For the last bit, do not create the variables at the top of the onCommand method. Only create those variables when a command needs it, and you know that those args exist.
     
  7. Offline

    MaxFireIce

    @Smith__ that out of bounds is your error
     
  8. Offline

    Smith__

    @MaxFireIce, So sorry, the actual code for Line:41 in Emotions is
    Code:
    if (cmd.equalsIgnoreCase("slap")){
    The full line is this
    Code:
    if (cmd.equalsIgnoreCase("slap")){
                if (!(sender instanceof Player)) {
                    sender.sendMessage("Really, Only players can slap players.");
    
                } else {
                    if (!p.hasPermission(Slap)){
                        p.sendMessage("§4Ummmmm No.");
    
                    } else if (args.length == 0) {
                        p.sendMessage("§aPlease enter a persons name to slap!");
                    } else {
                        getServer().broadcastMessage("§b" + name + " " + "§3Slapped§b " + t);
                        p.playSound(location,Sound.CAT_MEOW,1, 0);
                        target.playSound(location, Sound.CAT_HIT, 1, 0);
                        target.sendMessage("§bYour face has a hand print on it...");
                    }
                }
            }
    
     
    Last edited: Mar 5, 2017
  9. Offline

    Smith__

    @MaxFireIce please tell me how to fix this, I dont see anything wrong with the code.
     
  10. Offline

    Zombie_Striker

    @Smith__
    Have you made any changes to your code since the error was posted? If so, try posting an updated version of the error.
     
  11. Offline

    Smith__

    No I haven't, I need help figuring out the problem, you guys seem to have found it, I just haven't been able to follow what you are trying to say. @Zombie_Striker
     
Thread Status:
Not open for further replies.

Share This Page