"Internal error occured"

Discussion in 'Plugin Development' started by Joeypalko, Jun 18, 2014.

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

    Joeypalko

    So i'm making a server selection plugin with a gui and all and whenever i loaded the plugin into the server, it worked once, but whenever the server was reloaded or restarted or if the plugin was changed out with a newer one....it stopped working. whenever i did the commands i made it, instead of opening the gui like it was supposed to, it sent back: "an internal error occured while attempting to perform this command" i have 2 commands. one of them works everytimg like a charm but the other one is the one sending back the error! HELP!

    this is my main class:
    Code:java
    1. package me.bukkit.paljoey123;
    2.  
    3. import org.bukkit.permissions.Permission;
    4. import org.bukkit.plugin.PluginManager;
    5. import org.bukkit.plugin.java.JavaPlugin;
    6.  
    7. public class MassiveTeleport extends JavaPlugin {
    8.  
    9. SettingsManager settings = SettingsManager.getInstance();
    10. private final gui InventoryClick = new gui();
    11.  
    12. @Override
    13. public void onEnable() {
    14.  
    15. PluginManager pm = getServer().getPluginManager();
    16. pm.addPermission(use);
    17. pm.addPermission(set);
    18. pm.registerEvents(InventoryClick, this);
    19. settings.setup(this);
    20. getCommand("mcompass").setExecutor(new Commands());
    21. getCommand("mteleport").setExecutor(new Commands());
    22.  
    23. }
    24.  
    25. @Override
    26. public void onDisable() {
    27.  
    28. settings.saveData();
    29. getServer().getLogger().info("Data.yml for MassiveTeleport has been saved!");
    30.  
    31. }
    32.  
    33. Permission use = new Permission("mteleport.use");
    34. Permission set = new Permission("mteleport.set");
    35.  
    36. }


    this is my commands class:

    Code:java
    1. package me.bukkit.paljoey123;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Sound;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandExecutor;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9.  
    10. public class Commands implements CommandExecutor {
    11.  
    12. SettingsManager settings = SettingsManager.getInstance();
    13.  
    14. public boolean onCommand(CommandSender sender, Command cmd, String Commandlabel, String[] args) {
    15.  
    16. Player p = (Player) sender;
    17.  
    18. if (cmd.getName().equalsIgnoreCase("mcompass")) {
    19. if (p instanceof Player) {
    20. gui.open(p);
    21. p.playSound(p.getLocation(), Sound.NOTE_PLING, 10, 1);
    22. }else {
    23. p.sendMessage(ChatColor.RED + "Consoles dont have inventories!");
    24. }
    25. }
    26.  
    27. if (cmd.getName().equalsIgnoreCase("mteleport")) {
    28. if (p instanceof Player) {
    29. if (p.hasPermission("MassiveTeleport.set")) {
    30. if (args.length == 0) {
    31. p.sendMessage(ChatColor.RED + "Please specify!");
    32. }
    33.  
    34. if (args[0].equalsIgnoreCase("set")) {
    35.  
    36. if (args.length == 1) {
    37.  
    38. p.sendMessage(ChatColor.RED + "Please specify name!");
    39.  
    40.  
    41. }
    42.  
    43. if (args.length == 2) {
    44.  
    45. settings.getData().set("warps." + args[1] + ".world", p.getLocation().getWorld().getName());
    46. settings.getData().set("warps." + args[1] + ".x", p.getLocation().getX());
    47. settings.getData().set("warps." + args[1] + ".y", p.getLocation().getY());
    48. settings.getData().set("warps." + args[1] + ".z", p.getLocation().getZ());
    49. settings.saveData();
    50. p.sendMessage(ChatColor.GREEN + "Set location: " + ChatColor.YELLOW + args[1]);
    51.  
    52. }
    53.  
    54. }
    55. }
    56. }else {
    57.  
    58. p.sendMessage(ChatColor.RED + "Seriously? are you stupid? console doesnt have a location!!!!");
    59.  
    60. }
    61. }
    62.  
    63. return true;
    64.  
    65. }
    66.  
    67. }
    68.  


    this is my gui class:
    Code:
    package me.bukkit.paljoey123;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.DyeColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.entity.HumanEntity;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.material.Wool;
     
    public class gui implements Listener {
       
       
        public static void open(Player p) {
           
            Inventory inv = Bukkit.createInventory(p, 18, ChatColor.DARK_RED + "          Massive" + ChatColor.DARK_GRAY + "Mine" + ChatColor.GOLD + "Teleport");
           
            ItemStack pvp = new ItemStack(Material.DIAMOND_SWORD);
            ItemMeta mpvp = pvp.getItemMeta();
            mpvp.setDisplayName(ChatColor.DARK_RED + "PvP");
            pvp.setItemMeta(mpvp);
            inv.setItem(0, pvp);
           
            ItemStack gladiator = new ItemStack(Material.GOLD_BARDING);
            ItemMeta mglad =  gladiator.getItemMeta();
            mglad.setDisplayName(ChatColor.GRAY + "Gladiator");
            gladiator.setItemMeta(mglad);
            inv.setItem(1, gladiator);
     
            ItemStack minez = new ItemStack(Material.SKULL_ITEM, 1);
            ItemMeta mminez = minez.getItemMeta();
            mminez.setDisplayName(ChatColor.WHITE + "Mine" + ChatColor.DARK_RED + "Z");
            minez.setItemMeta(mminez);
            inv.setItem(2, minez);
           
            ItemStack oitc = new ItemStack(Material.ARROW);
            ItemMeta moitc = oitc.getItemMeta();
            moitc.setDisplayName(ChatColor.AQUA + "OITC");
            oitc.setItemMeta(moitc);
            inv.setItem(3, oitc);
           
            Wool close = new Wool(DyeColor.RED);
            ItemStack closey = close.toItemStack();
            ItemMeta mclose = closey.getItemMeta();
           
            mclose.setDisplayName(ChatColor.RED + "Exit");
            closey.setItemMeta(mclose);
           
            inv.setItem(4, closey);
           
            ItemStack skyblock = new ItemStack(Material.SAPLING);
            ItemMeta msky = skyblock.getItemMeta();
            msky.setDisplayName(ChatColor.BLUE + "SkyBlock");
            skyblock.setItemMeta(msky);
            inv.setItem(5, skyblock);
           
            ItemStack tf2 = new ItemStack(Material.MAGMA_CREAM);
            ItemMeta mtf2 = tf2.getItemMeta();
            mtf2.setDisplayName(ChatColor.GOLD + "TF2");
            tf2.setItemMeta(mtf2);
            inv.setItem(6, tf2);
           
            ItemStack create = new ItemStack(Material.GRASS);
            ItemMeta mcreate = create.getItemMeta();
            mcreate.setDisplayName(ChatColor.DARK_GREEN + "Creative");
            create.setItemMeta(mcreate);
            inv.setItem(7, create);
           
            ItemStack hg = new ItemStack(Material.CHEST);
            ItemMeta mhg = hg.getItemMeta();
            mhg.setDisplayName(ChatColor.DARK_GRAY + "HungerGames");
            hg.setItemMeta(mhg);
            inv.setItem(8, hg);
           
            ItemStack auction = new ItemStack(Material.EMERALD);
            ItemMeta mauc = auction.getItemMeta();
            mauc.setDisplayName(ChatColor.GREEN + "Auction");
            auction.setItemMeta(mauc);
            inv.setItem(12, auction);
           
            ItemStack jail = new ItemStack(Material.IRON_FENCE);
            ItemMeta mjail = jail.getItemMeta();
            mjail.setDisplayName(ChatColor.BLACK + "Jail");
            jail.setItemMeta(mjail);
            inv.setItem(13, jail);
           
            ItemStack hall = new ItemStack(Material.DIAMOND);
            ItemMeta mhall = hall.getItemMeta();
            mhall.setDisplayName(ChatColor.DARK_AQUA + "Hall of fame");
            hall.setItemMeta(mhall);
            inv.setItem(14, hall);
           
            p.openInventory(inv);
       
        }       
       
        SettingsManager settings = SettingsManager.getInstance();
       
        @EventHandler
        public void InventoryClick(InventoryClickEvent e) {
            if (!e.getInventory().getName().equals(ChatColor.DARK_RED + "          Massive" + ChatColor.DARK_GRAY + "Mine" + ChatColor.GOLD + "Teleport")) return;
            if (e.getCurrentItem().getItemMeta() == null) return;
            HumanEntity p = e.getWhoClicked();
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("PvP")) {
                e.setCancelled(true);
                World w = Bukkit.getServer().getWorld(settings.getData().getString("warps." + "pvp" + ".world"));
                double x = settings.getData().getDouble("warps." + "pvp" + ".x");
                double y = settings.getData().getDouble("warps." + "pvp" + ".y");
                double z = settings.getData().getDouble("warps." + "pvp" + ".z");
                p.teleport(new Location(w, x, y, z));
                p.closeInventory();
                  }
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Gladiator")) {
                e.setCancelled(true);
                World w = Bukkit.getServer().getWorld(settings.getData().getString("warps." + "gladiator" + ".world"));
                double x = settings.getData().getDouble("warps." + "gladiator" + ".x");
                double y = settings.getData().getDouble("warps." + "gladiator" + ".y");
                double z = settings.getData().getDouble("warps." + "gladiator" + ".z");
                p.teleport(new Location(w, x, y, z));
                p.closeInventory();
            }
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("MineZ")) {
                e.setCancelled(true);
                World w = Bukkit.getServer().getWorld(settings.getData().getString("warps." + "minez" + ".world"));
                double x = settings.getData().getDouble("warps." + "minez" + ".x");
                double y = settings.getData().getDouble("warps." + "minez" + ".y");
                double z = settings.getData().getDouble("warps." + "minez" + ".z");
                p.teleport(new Location(w, x, y, z));
                p.closeInventory();
            }
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("OITC")) {
                e.setCancelled(true);
                World w = Bukkit.getServer().getWorld(settings.getData().getString("warps." + "oitc" + ".world"));
                double x = settings.getData().getDouble("warps." + "oitc" + ".x");
                double y = settings.getData().getDouble("warps." + "oitc" + ".y");
                double z = settings.getData().getDouble("warps." + "oitc" + ".z");
                p.teleport(new Location(w, x, y, z));
                p.closeInventory();
            }
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Exit")) {
                e.setCancelled(true);
                p.closeInventory();
            }
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("SkyBlock")) {
                e.setCancelled(true);
                World w = Bukkit.getServer().getWorld(settings.getData().getString("warps." + "skyblock" + ".world"));
                double x = settings.getData().getDouble("warps." + "skyblock" + ".x");
                double y = settings.getData().getDouble("warps." + "skyblock" + ".y");
                double z = settings.getData().getDouble("warps." + "skyblock" + ".z");
                p.teleport(new Location(w, x, y, z));
                p.closeInventory();
            }
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("TF2")) {
                e.setCancelled(true);
                World w = Bukkit.getServer().getWorld(settings.getData().getString("warps." + "tf2" + ".world"));
                double x = settings.getData().getDouble("warps." + "tf2" + ".x");
                double y = settings.getData().getDouble("warps." + "tf2" + ".y");
                double z = settings.getData().getDouble("warps." + "tf2" + ".z");
                p.teleport(new Location(w, x, y, z));
                p.closeInventory();
            }
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Creative")) {
                e.setCancelled(true);
                World w = Bukkit.getServer().getWorld(settings.getData().getString("warps." + "creative" + ".world"));
                double x = settings.getData().getDouble("warps." + "creative" + ".x");
                double y = settings.getData().getDouble("warps." + "creative" + ".y");
                double z = settings.getData().getDouble("warps." + "creative" + ".z");
                p.teleport(new Location(w, x, y, z));
                p.closeInventory();
            }
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("HungerGames")) {
                e.setCancelled(true);
                World w = Bukkit.getServer().getWorld(settings.getData().getString("warps." + "hungergames" + ".world"));
                double x = settings.getData().getDouble("warps." + "hungergames" + ".x");
                double y = settings.getData().getDouble("warps." + "hungergames" + ".y");
                double z = settings.getData().getDouble("warps." + "hungergames" + ".z");
                p.teleport(new Location(w, x, y, z));
                p.closeInventory();
            }
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Auction")) {
                e.setCancelled(true);
                World w = Bukkit.getServer().getWorld(settings.getData().getString("warps." + "auction" + ".world"));
                double x = settings.getData().getDouble("warps." + "auction" + ".x");
                double y = settings.getData().getDouble("warps." + "auction" + ".y");
                double z = settings.getData().getDouble("warps." + "auction" + ".z");
                p.teleport(new Location(w, x, y, z));
                p.closeInventory();
            }
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Jail")) {
                e.setCancelled(true);
                World w = Bukkit.getServer().getWorld(settings.getData().getString("warps." + "jail" + ".world"));
                double x = settings.getData().getDouble("warps." + "jail" + ".x");
                double y = settings.getData().getDouble("warps." + "jail" + ".y");
                double z = settings.getData().getDouble("warps." + "jail" + ".z");
                p.teleport(new Location(w, x, y, z));
                p.closeInventory();
            }
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Hall of fame")) {
                e.setCancelled(true);
                World w = Bukkit.getServer().getWorld(settings.getData().getString("warps." + "halloffame" + ".world"));
                double x = settings.getData().getDouble("warps." + "halloffame" + ".x");
                double y = settings.getData().getDouble("warps." + "halloffame" + ".y");
                double z = settings.getData().getDouble("warps." + "halloffame" + ".z");
                p.teleport(new Location(w, x, y, z));
                p.closeInventory();
            }
           
        }
       
    }
    
    this is my plugin.yml
    Code:
    name: MassiveTeleport
    main: me.bukkit.paljoey123.MassiveTeleport
    version: 1.0
    commands:
      mcompass:
        description: Opens MassiveMines's main menu!
        usage: /<command>
      mteleport:
        description: sets locations for mcompass
        usage: /<command>
     
  2. Offline

    chasechocolate

    Error? Check console. Also you arg checks are a bit weird; you have to check if the array is long enough before you can get a value.
     
  3. Offline

    Joeypalko

    I fixed the args like you said, but it didn't fix the command that i was having issues with. is still throws the error.
    Here is what im getting in the console:
    Code:
    [21:24:29] [Server thread/INFO]: paljoey123 issued server command: /mcompass
    [21:24:29] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'mcompass' in plugin MassiveTeleport v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:701) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.PlayerConnection.handleCommand(PlayerConnection.java:956) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:817) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:157) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    Caused by: java.lang.IllegalArgumentException: Title cannot be longer than 32 characters
        at org.apache.commons.lang.Validate.isTrue(Validate.java:157) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at org.bukkit.craftbukkit.v1_7_R3.inventory.CraftInventoryCustom$MinecraftInventory.<init>(CraftInventoryCustom.java:57) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at org.bukkit.craftbukkit.v1_7_R3.inventory.CraftInventoryCustom.<init>(CraftInventoryCustom.java:30) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.createInventory(CraftServer.java:1518) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    
    If that means anything to anyone that would be great! thanks :)

    I FEEL SO STUPID OMG! I FOUND THE ISSUE! THE TITLE WAS TOO LONG! OMG LOL XD

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
Thread Status:
Not open for further replies.

Share This Page