Development Assistance (/Msg) Plugin Errors...

Discussion in 'Plugin Help/Development/Requests' started by Soviet_MC, Mar 6, 2015.

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

    Soviet_MC

    Code For The Plugin
    |
    V

    Code:
    package shade.message;
    
    import net.md_5.bungee.api.ChatColor;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Sound;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.permissions.Permission;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class ShadeMessage extends JavaPlugin {
     
        public void onEnable() {
            Bukkit.getServer().getConsoleSender().sendMessage("[ShadeMC] Msg Enabled!");
        }
        public void onDisable() {
            Bukkit.getServer().getConsoleSender().sendMessage("[ShadeMC] Msg Disabled!");
        }
     
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            if (sender instanceof Player) {
                if (args.length >= 0) {
                      Player Target = Bukkit.getServer().getPlayer(args[0]);
                      if (Target != null) {
            Player player = (Player) sender;
                if (cmd.getName().equalsIgnoreCase("msg")) {
                    if (player.isOp()|| player.hasPermission(new Permission("shademc.msg"))) {
                     
                    if (args.length >= 2) {
                         
                            String msg = "";
                            for (int i = 1; i < args.length; i++) {
                            msg = msg + args[i] + " ";
                            }
                         
                            player.sendMessage(ChatColor.LIGHT_PURPLE + "(To " + ChatColor.GREEN + Target.getDisplayName() + ChatColor.LIGHT_PURPLE + ")" + " " + msg);
                            Target.sendMessage(ChatColor.LIGHT_PURPLE + "(From " + ChatColor.GREEN + player.getDisplayName() + ChatColor.LIGHT_PURPLE + ")" + " " + msg);
                            Target.playSound(Target.getLocation(), Sound.NOTE_PLING, 10, Target.getLocation().getPitch());
                            return true;
                    }
                    if (args.length <= 1) {
                        player.sendMessage(ChatColor.RED + "Too few arguments." + " " + ChatColor.RED + "\n /msg <player> <message>");
                        {
                    if (!(player.hasPermission("shademc.msg"))) {
                        player.sendMessage(ChatColor.RED + "You Do Not Have Permission To Use </msg>");
                        {
                    if (!(sender instanceof Player)) {
                        Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "[ShadeMC] Msg - </msg> Can Not Be Used From The Console! - I Cri Evry Tiem");
                    }
                        }
                     
                     
                    }
                        }
                }
            }
        }
                return true;
    }{
    }{
        }
    return true;
    }
    }
            return true;
        }
    }

    Console Error:
    |
    V

    Code:
    [21:36:40] [Server thread/INFO]: Soviet_Union issued server command: /msg
    [21:36:40] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'msg' in plugin ShadeMsg v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-b73910a-726656b]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-b73910a-726656b]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServer.java:646) ~[spigot.jar:git-Spigot-b73910a-726656b]
        at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerConnection.java:1115) [spigot.jar:git-Spigot-b73910a-726656b]
        at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:950) [spigot.jar:git-Spigot-b73910a-726656b]
        at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:26) [spigot.jar:git-Spigot-b73910a-726656b]
        at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:53) [spigot.jar:git-Spigot-b73910a-726656b]
        at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot.jar:git-Spigot-b73910a-726656b]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_31]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_31]
        at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:696) [spigot.jar:git-Spigot-b73910a-726656b]
        at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot.jar:git-Spigot-b73910a-726656b]
        at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot.jar:git-Spigot-b73910a-726656b]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot.jar:git-Spigot-b73910a-726656b]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_31]
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
        at shade.message.ShadeMessage.onCommand(ShadeMessage.java:26) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-b73910a-726656b]
        ... 14 more
    Plugin.yml
    |
    V

    Code:
    name: ShadeMC - Msg
    version: 1.0
    main: shade.message.ShadeMessage
    description: (Message With Sounds)
    
    commands:
       msg:
            aliases: [message]
            description: (Message With Sounds)

    So the problem is when I type /msg the text says: Internal Error...
    When I type /msg <Player>, it will send the player a message to specify a message.
    When I type /msg <Player> <message>, it works and messages the person with sound.
    When I also issue the /msg from the console it says nothing...
    Everything looks good to me...
    Thx For The Help
    <3
     
    Last edited: Mar 6, 2015
  2. Offline

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives.
     
Thread Status:
Not open for further replies.

Share This Page