Solved Needing help with a ItemTP Plugin. Not what you think!

Discussion in 'Plugin Development' started by wiredbrother, Sep 1, 2016.

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

    wiredbrother

    Greeting to all!

    So i started making this plugin called ItemTP. Basically its for a shop. So a player goes hey I need this item but doesn't know where it is in the shop because the shop is huge! So the player can do "/itemtp dirt" and then the plugin will Tp the player automatically to the location in the shop where dirt is. But say you need to make a itemtp you will do "/itemadd (name)" and then the plugin will automatically take the players location and right it down in a config. So I started Developing this but when i tested the first part of it all it did when i did the command was repeat it back so i would do /itemadd dirt and in chat it would say "/itmeadd dirt" But it doesn't have my IGN in front of it so there is something wrong with the plugin.

    Code:

    Code:
    package me.cyborgtwins;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class ItemTP extends JavaPlugin {
      
       @Override
       public void onEnable() {
        
       }
      
       @Override
       public void onDisable() {
        
       }
      
       public boolean onCammand(CommandSender sender, Command cmd, String label, String[] args) {
        
         Player player = (Player) sender;
        
         FileConfiguration config = this.getConfig();
        
         //Joining challenge
         if (cmd.getName().equalsIgnoreCase("itemadd") && sender instanceof Player) {
            
           if (args.length >= 1) {
          
             String list = "";
            
             Location location = player.getLocation();
            
              for (String arg : args) {
                list = list + arg;
              }
              
                //Handling arguments
                if (!config.contains(list)) {
                   config.set(list, location);
                   player.sendMessage(ChatColor.GREEN + "Item Has Now Been Added!");
                   saveConfig();
                } else player.sendMessage(ChatColor.RED + "This Item Has Already Been Added!");
                
           } else player.sendMessage(ChatColor.RED + "Please Enter the name of the item after /additem");
          
           return true;
          
         }
        
        
          //Viewing Items
           if (cmd.getName().equalsIgnoreCase("itemlist") && sender instanceof Player) {
                
               //Loop for stuff? you will never know.
               for (String key : config.getKeys(false)) {
                 player.sendMessage(ChatColor.YELLOW + key + ": " + config.getString(key));
               }
                 if (config.getKeys(false).isEmpty()) {
                   player.sendMessage(ChatColor.RED + "No items are here!");
                 }
              
               return true;
             }
          
          
           //Deleting Challengers
           if (cmd.getName().equalsIgnoreCase("itemdelete") && sender instanceof Player) {
            
             if (args.length == 1) {
              
               if (config.contains(args[0].toLowerCase())) {
                
                 config.set(args[0], null);
                 saveConfig();
                 player.sendMessage(ChatColor.GREEN + "Item deleted!");
                
               } else player.sendMessage(ChatColor.RED + "Item Not Found!");
              
             } else player.sendMessage(ChatColor.RED + "Invalid Entry! Need More Then That!");
            
             return true;
           }
          
           //The Fucking guy who made this
        if (cmd.getName().equalsIgnoreCase("iteminfo") && sender instanceof Player) {
            
             player.sendMessage(ChatColor.GREEN + "Made by your master and ruler CYBORGTWINS!");
              
        } else player.sendMessage(ChatColor.RED + "Invalid permissions!");
        
        
         return false;
        
       }
    
    }

    YML:

    Code:
    name: ItemTP
    main: me.cyborgtwins.ItemTP
    version: 1.0
    commands:
      itemadd:
      description: Add's A Item To The List Of Items You Can TP To In The Shop!
      usage: /<command>
      itemlist:
      description: Allow's You To Be Able To Look At All The Items In The Shop!
      usage: /<command>
      itemdelete:
      description: Deletes A Item From The List!
      usage: /<command>
      iteminfo:
      description: The Guy Who Made This!
      usage: /<command>
     
    Last edited by a moderator: Sep 1, 2016
  2. Offline

    Rayzr522

    In onCommand when you return false it shows the command usage, so instead you need to return true.
     
  3. Offline

    wiredbrother

    Thank you for the quick response! I shall see if this works and get back!

    So I replaced false with true on the onCommad like this.

    public boolean onCammand(CommandSender sender, Command cmd, String label, String[] args) {
    blah blah blah!
    return false;
    }

    and I did not work it still just said what I typed.
     
    Last edited: Sep 1, 2016
  4. Offline

    Rayzr522

    "return false;" should be "return true;"
     
  5. Offline

    wiredbrother

    Oh Im sorry! That was a typo I meant return true; But it still does the same thing any other ideas?
     
  6. @wiredbrother
    At the very bottom of your class, you still return false.
     
  7. Offline

    wiredbrother

    @AlvinB
    I DO! But I still get the error! Plz I really need to get this up and running and I am stumped!
     
  8. Offline

    wiredbrother

    @AlvinB

    Same as last time
    Code:

    Code:
    package me.cyborgtwins;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class ItemTP extends JavaPlugin {
    
    @Override
    public void onEnable() {
    
    }
    
    @Override
    public void onDisable() {
    
    }
    
    public boolean onCammand(CommandSender sender, Command cmd, String label, String[] args) {
    
    Player player = (Player) sender;
    
    FileConfiguration config = this.getConfig();
    
    //Joining challenge
    if (cmd.getName().equalsIgnoreCase("itemadd") && sender instanceof Player) {
    
    if (args.length >= 1) {
    
    String list = "";
    
    Location location = player.getLocation();
    
    for (String arg : args) {
    list = list + arg;
    }
    
    //Handling arguments
    if (!config.contains(list)) {
    config.set(list, location);
    player.sendMessage(ChatColor.GREEN + "Item Has Now Been Added!");
    saveConfig();
    } else player.sendMessage(ChatColor.RED + "This Item Has Already Been Added!");
    
    } else player.sendMessage(ChatColor.RED + "Please Enter the name of the item after /additem");
    
    return true;
    
    }
    
    
    //Viewing Items
    if (cmd.getName().equalsIgnoreCase("itemlist") && sender instanceof Player) {
    
    //Loop for stuff? you will never know.
    for (String key : config.getKeys(false)) {
    player.sendMessage(ChatColor.YELLOW + key + ": " + config.getString(key));
    }
    if (config.getKeys(false).isEmpty()) {
    player.sendMessage(ChatColor.RED + "No items are here!");
    }
    
    return true;
    }
    
    
    //Deleting Challengers
    if (cmd.getName().equalsIgnoreCase("itemdelete") && sender instanceof Player) {
    
    if (args.length == 1) {
    
    if (config.contains(args[0].toLowerCase())) {
    
    config.set(args[0], null);
    saveConfig();
    player.sendMessage(ChatColor.GREEN + "Item deleted!");
    
    } else player.sendMessage(ChatColor.RED + "Item Not Found!");
    
    } else player.sendMessage(ChatColor.RED + "Invalid Entry! Need More Then That!");
    
    return true;
    }
    
    //The Fucking guy who made this
    if (cmd.getName().equalsIgnoreCase("iteminfo") && sender instanceof Player) {
    
    player.sendMessage(ChatColor.GREEN + "Made by your master and ruler CYBORGTWINS!");
    
    } else player.sendMessage(ChatColor.RED + "Invalid permissions!");
    
    
    return false;
    
    }
    
    }
     
  9. @wiredbrother
    So this is the class you're currently using? Because you are still returning false at the bottom of it.
     
  10. Offline

    wiredbrother

    @AlvinB
    No what happened is that i tried the return true and it did the same thing. So i went to the deafault.
     
  11. @wiredbrother
    Well the second obvious issue is that your method is named "onCammand" instead of "onCommand".
     
  12. Offline

    wiredbrother

    @AlvinB and @Rayzr522

    OK so I got the capture part done and almost the tp part done. But it keeps giving me this error. Oh and here is the new code.

    Error:

    Code:
    [01:12:53] [Server thread/INFO]: Starting minecraft server version 1.8.8
    [01:12:53] [Server thread/INFO]: Loading properties
    [01:12:53] [Server thread/INFO]: Default game type: SURVIVAL
    [01:12:53] [Server thread/INFO]: Generating keypair
    [01:12:53] [Server thread/INFO]: Starting Minecraft server on *:25565
    [01:12:53] [Server thread/INFO]: Using default channel type
    [01:12:53] [Server thread/INFO]: This server is running CraftBukkit version git-Bukkit-e1ebe52 (MC: 1.8.8) (Implementing API version 1.8.8-R0.1-SNAPSHOT)
    [01:12:53] [Server thread/INFO]: [ItemTP] Loading ItemTP v1.2
    [01:12:53] [Server thread/INFO]: Preparing level "world"
    [01:12:54] [Server thread/INFO]: Preparing start region for level 0 (Seed: 3304873887225295798)
    [01:12:55] [Server thread/INFO]: Preparing spawn area: 49%
    [01:12:55] [Server thread/INFO]: Preparing start region for level 1 (Seed: 3304873887225295798)
    [01:12:56] [Server thread/INFO]: Preparing start region for level 2 (Seed: 3304873887225295798)
    [01:12:56] [Server thread/INFO]: [ItemTP] Enabling ItemTP v1.2
    [01:12:56] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [01:12:56] [Server thread/INFO]: Done (2.575s)! For help, type "help" or "?"
    [01:13:07] [User Authenticator #1/INFO]: UUID of player cyborgtwins is f8c39491-a323-4708-8b6b-cae0cb8ed058
    [01:13:07] [Server thread/INFO]: cyborgtwins[/127.0.0.1:52220] logged in with entity id 91 at ([world]-71.92729390087331, 71.0, 82.70652439465708)
    [01:13:12] [Server thread/INFO]: cyborgtwins issued server command: /itemlist
    [01:13:21] [Server thread/INFO]: cyborgtwins issued server command: /itemtp dirt
    [01:13:21] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'itemtp' in plugin ItemTP v1.2
       at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-e1ebe52]
       at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:140) ~[craftbukkit.jar:git-Bukkit-e1ebe52]
       at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:620) ~[craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1106) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:966) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:37) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:9) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_101]
       at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_101]
       at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:673) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:629) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:537) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at java.lang.Thread.run(Unknown Source) [?:1.8.0_101]
    Caused by: java.lang.NumberFormatException: For input string: "dirt"
       at java.lang.NumberFormatException.forInputString(Unknown Source) ~[?:1.8.0_101]
       at java.lang.Integer.parseInt(Unknown Source) ~[?:1.8.0_101]
       at java.lang.Integer.parseInt(Unknown Source) ~[?:1.8.0_101]
       at me.cyborgtwins.ItemTP.onCommand(ItemTP.java:101) ~[?:?]
       at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-e1ebe52]
       ... 15 more
    [01:19:59] [Server thread/INFO]: CONSOLE: [0;31;1mPlease note that this command is not supported and may cause issues when using some plugins.[m
    [01:19:59] [Server thread/INFO]: CONSOLE: [0;31;1mIf you encounter any issues please use the /stop command to restart your server.[m
    [01:19:59] [Server thread/INFO]: [ItemTP] Disabling ItemTP v1.2
    [01:19:59] [Server thread/INFO]: [ItemTP] Loading ItemTP v1.2
    [01:19:59] [Server thread/INFO]: [ItemTP] Enabling ItemTP v1.2
    [01:19:59] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [01:19:59] [Server thread/INFO]: CONSOLE: [0;32;1mReload complete.[m
    [01:20:17] [Server thread/INFO]: cyborgtwins issued server command: /itemadd lol
    [01:20:24] [Server thread/INFO]: cyborgtwins issued server command: /itemtp lol
    [01:20:24] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'itemtp' in plugin ItemTP v1.2
       at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-e1ebe52]
       at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:140) ~[craftbukkit.jar:git-Bukkit-e1ebe52]
       at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:620) ~[craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1106) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:966) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:37) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:9) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_101]
       at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_101]
       at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:673) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:629) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:537) [craftbukkit.jar:git-Bukkit-e1ebe52]
       at java.lang.Thread.run(Unknown Source) [?:1.8.0_101]
    Caused by: java.lang.NumberFormatException: For input string: "lol"
       at java.lang.NumberFormatException.forInputString(Unknown Source) ~[?:1.8.0_101]
       at java.lang.Integer.parseInt(Unknown Source) ~[?:1.8.0_101]
       at java.lang.Integer.parseInt(Unknown Source) ~[?:1.8.0_101]
       at me.cyborgtwins.ItemTP.onCommand(ItemTP.java:102) ~[?:?]
       at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-e1ebe52]
       ... 15 more
    [01:20:27] [Server thread/INFO]: cyborgtwins lost connection: Disconnected
    [01:20:27] [Server thread/INFO]: cyborgtwins left the game.
    [01:20:45] [Server thread/INFO]: Stopping the server
    [01:20:45] [Server thread/INFO]: Stopping server
    [01:20:45] [Server thread/INFO]: [ItemTP] Disabling ItemTP v1.2
    [01:20:45] [Server thread/INFO]: Saving players
    [01:20:45] [Server thread/INFO]: Saving worlds
    [01:20:45] [Server thread/INFO]: Saving chunks for level 'world'/Overworld
    [01:20:45] [Server thread/INFO]: Saving chunks for level 'world_nether'/Nether
    [01:20:45] [Server thread/INFO]: Saving chunks for level 'world_the_end'/The End
    
    
    Code for plugin:
    
    package me.cyborgtwins;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class ItemTP extends JavaPlugin {
    
       @Override
       public void onEnable() {
      
       }
    
       @Override
       public void onDisable() {
      
       }
    
       public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
      
         Player player = (Player) sender;
      
         FileConfiguration config = this.getConfig();
      
         //Making items
         if (cmd.getName().equalsIgnoreCase("itemadd") && sender instanceof Player) {
          
           if (args.length >= 1) {
        
             String list = "";
          
               for (String arg : args) {
                list = list + arg;
              }
            
               String locks = "";
            
               int x = player.getLocation().getBlockX();
               int y = player.getLocation().getBlockY();
               int z = player.getLocation().getBlockZ();
               String worldname = player.getWorld().getName();
              
               locks = locks +" x" + x + " y" + y + " z" + z + " " + worldname + " ";
            
                //Handling arguments
                if (!config.contains(list)) {
                   config.set(list, locks);
                   player.sendMessage(ChatColor.GREEN + "Item Has Now Been Added!");
                   saveConfig();
                } else player.sendMessage(ChatColor.RED + "This Item Has Already Been Added!");
              
           } else player.sendMessage(ChatColor.RED + "Please Enter the name of the item after /additem");
        
           return true;
        
         }
        
           //Deleting items
           if (cmd.getName().equalsIgnoreCase("itemdelete") && sender instanceof Player) {
          
             if (args.length == 1) {
            
               if (config.contains(args[0])) {
              
                 config.set(args[0], null);
                 saveConfig();
                 player.sendMessage(ChatColor.GREEN + "Item deleted!");
              
               } else player.sendMessage(ChatColor.RED + "Item Not Found! Make sure to use capital if you used caps!");
            
             } else player.sendMessage(ChatColor.RED + "Invalid Entry! Need More Then That!");
          
             return true;
           }
        
           //Viewing Items
           if (cmd.getName().equalsIgnoreCase("itemlist") && sender instanceof Player) {
              
               //Loop for stuff? you will never know.
               for (String key : config.getKeys(false)) {
                 player.sendMessage(ChatColor.YELLOW + key + ": " + config.getString(key));
               }
                 if (config.getKeys(false).isEmpty()) {
                   player.sendMessage(ChatColor.RED + "No items are here!");
                 }
            
               return true;
             }
        
           //Tp to item!
           if (cmd.getName().equalsIgnoreCase("itemtp") && sender instanceof Player) {
              
             if(args.length==1) {
          
      if (config.contains(args[0])) {
              
         int num = Integer.parseInt(args[0]);
         int x = getConfig().getInt(sender.getName() + "." + num + ".x");
         int y = getConfig().getInt(sender.getName() + "." + num + ".y");
         int z = getConfig().getInt(sender.getName() + "." + num + ".z");
      
         String worldname = player.getWorld().getName();
              
                 Object licks = worldname;
      
         Location hi = new Location((World) licks,x,y,z);
      
         if(sender instanceof Player){
           Player p = (Player)sender;
           p.teleport(hi);
           p.sendMessage(ChatColor.GOLD + "You have been teleported to the item!");
        
         } else player.sendMessage(ChatColor.RED + "You are a console! You do not have a home!");
      
               } else player.sendMessage(ChatColor.RED + "Item Not Found! Make sure to use capital if you used caps!");
            
            
             } else player.sendMessage(ChatColor.RED + "Invalid Entry! Need More Then That!");
            
            
            return true;
           }
        
        
           //The guy who made this
        if (cmd.getName().equalsIgnoreCase("iteminfo") && sender instanceof Player) {
          
             player.sendMessage(ChatColor.GREEN + "Made by your master and ruler CYBORGTWINS!");
            
        } else player.sendMessage(ChatColor.RED + "Invalid permissions!");
      
      
         return true;
      
       }
    
    }
     
  13. Offline

    Zombie_Striker

    Your problem is that you are trying to convert a word to a number on line 101. For this example, you are trying to find what number "dirt" is, but a word is not a number.

    Since "num" most likely represents the ID of the teleport, I have two suggestions for you:
    1. (Recommended) remove "num" entirely, and replace it with "args[0]". That way, the path looks like "Name.Dirt.x"
    2. Find some way to convert "dirt" to a numeric value, though I do not know how you would do this.
     
  14. Offline

    wiredbrother

    @Zombie_Striker

    So how would you make it. As in if you where coding a itemtp plugin like how I described at the top. How would you code it?
     
  15. Offline

    Zombie_Striker

    @wiredbrother
    Simply use:
    and save it using
     
  16. 1. I'd recommend to rename the command to shoptp for less confusion.
    2. I'd recommend making a command for setting the location.
     
  17. Offline

    ZP18

    /itemadd ... Did you read all the above replies?
    As for the command message in chat @wiredbrother try putting the return true before the last else.
    I do agree with @TheEnderCrafter9 on the command name however especially if you are going to publish this plugin


    Sent from my iPhone using Tapatalk
     
  18. Offline

    wiredbrother

    @ZP18 @TheEnderCrafter9 @Zombie_Striker
    Hey guys sorry I didn't respond I was really busy. As for the plugin itself I was just really stumped on how to do the last part. If you guys wouldnt mind. Could you give me exact code as i am new to plugins and such. That would be absolutely AMAZING!
    -wiredbrother
     
  19. Offline

    BeastyBoo

    Why not create a custom warp plugin but with different labels? There is forum tutorials on that subject that helped me make this exact same plugin, only I use it for different tps.
     
  20. Offline

    wiredbrother

    :)
    Well that is a great idea! do you have the link(s) for the tutorial(s) of that?

    @ZP18 @TheEnderCrafter9 @Zombie_Striker
    Ok guys so here is the scoop! I have developed the code below! But i guess it doesnt work so ya. Do you guys know how to make this work?

    Code:
    //Tp to item!
           if (cmd.getName().equalsIgnoreCase("itemtp") && sender instanceof Player) {
                 
             if(args.length==1) {
             
      if (config.contains(args[0])) {
                 
         int num = Integer.parseInt(args[0]);
         int x = getConfig().getInt(sender.getName() + "." + num + ".x");
         int y = getConfig().getInt(sender.getName() + "." + num + ".y");
         int z = getConfig().getInt(sender.getName() + "." + num + ".z");
         
         String worldname = player.getWorld().getName();
                 
                 Object licks = worldname;
         
         Location hi = new Location((World) licks,x,y,z);
         
         if(sender instanceof Player){
           Player p = (Player)sender;
           p.teleport(hi);
           p.sendMessage(ChatColor.GOLD + "You have been teleported to the item!");
           
         } else player.sendMessage(ChatColor.RED + "You are a console! You do not have a home!");
         
               } else player.sendMessage(ChatColor.RED + "Item Not Found! Make sure to use capital if you used caps!");
               
               
             } else player.sendMessage(ChatColor.RED + "Invalid Entry! Need More Then That!");
               
               
            return true;
           }
    @AlvinB @Rayzr522
    Look above maybe you guys can help as well! XD

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Sep 8, 2016
  21. Offline

    ZP18

    Do you get any errors? And that is not a very good way to check if it is a player. You should check at the start so that unnecessary code is not run. Anyway if you're not getting any errors make sure the command is registered


    Sent from my iPhone using Tapatalk
     
  22. Offline

    wiredbrother

    @ZP18

    Oh I am sorry about that! XD Completely spaced that part kinda important! Well first in the game i get this "An internal error occurred while attempting to perform this command" and as for the console
    Code:
    [16:56:57] [Server thread/INFO]: Starting minecraft server version 1.8.8
    [16:56:57] [Server thread/INFO]: Loading properties
    [16:56:57] [Server thread/INFO]: Default game type: SURVIVAL
    [16:56:57] [Server thread/INFO]: Generating keypair
    [16:56:58] [Server thread/INFO]: Starting Minecraft server on *:25565
    [16:56:58] [Server thread/INFO]: Using default channel type
    [16:57:00] [Server thread/INFO]: This server is running CraftBukkit version git-Bukkit-e1ebe52 (MC: 1.8.8) (Implementing API version 1.8.8-R0.1-SNAPSHOT)
    [16:57:00] [Server thread/INFO]: [ItemTP] Loading ItemTP v1.2
    [16:57:00] [Server thread/INFO]: Preparing level "world"
    [16:57:00] [Server thread/INFO]: Preparing start region for level 0 (Seed: 3304873887225295798)
    [16:57:01] [Server thread/INFO]: Preparing spawn area: 3%
    [16:57:02] [Server thread/INFO]: Preparing spawn area: 49%
    [16:57:03] [Server thread/INFO]: Preparing start region for level 1 (Seed: 3304873887225295798)
    [16:57:04] [Server thread/INFO]: Preparing spawn area: 67%
    [16:57:04] [Server thread/INFO]: Preparing start region for level 2 (Seed: 3304873887225295798)
    [16:57:05] [Server thread/INFO]: [ItemTP] Enabling ItemTP v1.2
    [16:57:05] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [16:57:05] [Server thread/INFO]: Done (4.838s)! For help, type "help" or "?"
    [16:57:38] [User Authenticator #1/INFO]: UUID of player cyborgtwins is blank
    [16:57:39] [Server thread/INFO]: cyborgtwins[/127.0.0.1:55775] logged in with entity id 97 at ([world]-71.96409366885925, 71.0, 77.30000001192093)
    [16:57:47] [Server thread/INFO]: cyborgtwins issued server command: /itemlist
    [16:57:54] [Server thread/INFO]: cyborgtwins issued server command: /itemtp lol
    [16:57:54] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'itemtp' in plugin ItemTP v1.2
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-e1ebe52]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:140) ~[craftbukkit.jar:git-Bukkit-e1ebe52]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:620) ~[craftbukkit.jar:git-Bukkit-e1ebe52]
    at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1106) [craftbukkit.jar:git-Bukkit-e1ebe52]
    at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:966) [craftbukkit.jar:git-Bukkit-e1ebe52]
    at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:37) [craftbukkit.jar:git-Bukkit-e1ebe52]
    at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:9) [craftbukkit.jar:git-Bukkit-e1ebe52]
    at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit.jar:git-Bukkit-e1ebe52]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_101]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_101]
    at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [craftbukkit.jar:git-Bukkit-e1ebe52]
    at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:673) [craftbukkit.jar:git-Bukkit-e1ebe52]
    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit.jar:git-Bukkit-e1ebe52]
    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:629) [craftbukkit.jar:git-Bukkit-e1ebe52]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:537) [craftbukkit.jar:git-Bukkit-e1ebe52]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_101]
    Caused by: java.lang.NumberFormatException: For input string: "lol"
    at java.lang.NumberFormatException.forInputString(Unknown Source) ~[?:1.8.0_101]
    at java.lang.Integer.parseInt(Unknown Source) ~[?:1.8.0_101]
    at java.lang.Integer.parseInt(Unknown Source) ~[?:1.8.0_101]
    at me.cyborgtwins.ItemTP.onCommand(ItemTP.java:102) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-e1ebe52]
    ... 15 more
     
  23. Offline

    ZP18

    What is line 102 of ItemTP.java?


    Sent from my iPhone using Tapatalk
     
  24. Offline

    wiredbrother

    @ZP18

    Code:
    package me.cyborgtwins;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class ItemTP extends JavaPlugin {
       
       @Override
       public void onEnable() {
         
       }
       
       @Override
       public void onDisable() {
         
       }
       
       public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
         
         Player player = (Player) sender;
         
         FileConfiguration config = this.getConfig();
         
         //Joining items
         if (cmd.getName().equalsIgnoreCase("itemadd") && sender instanceof Player) {
             
           if (args.length >= 1) {
           
             String list = "";
             
               for (String arg : args) {
                list = list + arg;
              }
               
               String locks = "";
               
               int x = player.getLocation().getBlockX();
               int y = player.getLocation().getBlockY();
               int z = player.getLocation().getBlockZ();
               String worldname = player.getWorld().getName();
                 
               locks = locks +" x" + x + " y" + y + " z" + z + " " + worldname + " ";
               
                //Handling arguments
                if (!config.contains(list)) {
                   config.set(list, locks);
                   player.sendMessage(ChatColor.GREEN + "Item Has Now Been Added!");
                   saveConfig();
                } else player.sendMessage(ChatColor.RED + "This Item Has Already Been Added!");
                 
           } else player.sendMessage(ChatColor.RED + "Please Enter the name of the item after /additem");
           
           return true;
           
         }   
           
           //Deleting items
           if (cmd.getName().equalsIgnoreCase("itemdelete") && sender instanceof Player) {
             
             if (args.length == 1) {
               
               if (config.contains(args[0])) {
                 
                 config.set(args[0], null);
                 saveConfig();
                 player.sendMessage(ChatColor.GREEN + "Item deleted!");
                 
               } else player.sendMessage(ChatColor.RED + "Item Not Found! Make sure to use capital if you used caps!");
               
             } else player.sendMessage(ChatColor.RED + "Invalid Entry! Need More Then That!");
             
             return true;
           }
           
           //Viewing Items
           if (cmd.getName().equalsIgnoreCase("itemlist") && sender instanceof Player) {
                 
               //Loop for stuff? you will never know.
               for (String key : config.getKeys(false)) {
                 player.sendMessage(ChatColor.YELLOW + key + ": " + config.getString(key));
               }
                 if (config.getKeys(false).isEmpty()) {
                   player.sendMessage(ChatColor.RED + "No items are here!");
                 }
               
               return true;
             }
           
           //Tp to item!
           if (cmd.getName().equalsIgnoreCase("itemtp") && sender instanceof Player) {
                 
             if(args.length==1) {
             
      if (config.contains(args[0])) {
                 
         int num = Integer.parseInt(args[0]);
         int x = getConfig().getInt(sender.getName() + "." + num + ".x");
         int y = getConfig().getInt(sender.getName() + "." + num + ".y");
         int z = getConfig().getInt(sender.getName() + "." + num + ".z");
         
         String worldname = player.getWorld().getName();
                 
                 Object licks = worldname;
         
         Location hi = new Location((World) licks,x,y,z);
         
         if(sender instanceof Player){
           Player p = (Player)sender;
           p.teleport(hi);
           p.sendMessage(ChatColor.GOLD + "You have been teleported to the item!");
           
         } else player.sendMessage(ChatColor.RED + "You are a console! You do not have a home!");
         
               } else player.sendMessage(ChatColor.RED + "Item Not Found! Make sure to use capital if you used caps!");
               
               
             } else player.sendMessage(ChatColor.RED + "Invalid Entry! Need More Then That!");
               
               
            return true;
           }
           
           
           //The guy who made this
        if (cmd.getName().equalsIgnoreCase("iteminfo") && sender instanceof Player) {
             
             player.sendMessage(ChatColor.GREEN + "Made by your master and ruler CYBORGTWINS!");
               
        } else player.sendMessage(ChatColor.RED + "Invalid permissions!");
         
         
         return true;     
       }
    
    }
     
  25. Offline

    ZP18

    The exact line 102 plz, I'm on my phone I can't see line numbers


    Sent from my iPhone using Tapatalk
     
  26. Offline

    Zombie_Striker

    @wiredbrother
    Since the [.code] tags are broken, can you please post only line 102.
     
  27. Offline

    wiredbrother

    @ZP18 and @Zombie_Striker
    Sorry for the delay was eating dinner.

    line 102 is
    int num = Integer.parseInt(args[0]);
     
  28. Offline

    ZP18

    Then you're most likely not putting a number as your first argument in the command. You may have confused the indexing of your arguments. What's the command you are running to test it?


    Sent from my iPhone using Tapatalk
     
  29. Offline

    wiredbrother


    I am trying to do the command /itemtp (name of item) and then it will tp me. But when I do I get a error in the game called "An internal error occurred while attempting to perform this command" in the console it is this.


    So I dont know anymore! Please if you can fix it send the fixed code! Also THANK YOU!
     
Thread Status:
Not open for further replies.

Share This Page