Development Assistance Need help programming a coordinates plugin

Discussion in 'Plugin Help/Development/Requests' started by WishMachine, Mar 29, 2015.

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

    WishMachine

    I am working on a simple plugin for a survival server so that you can record the position of your base or a mob spawner or something with the command (/addCoord <string> <x> <y> <z>) and then with the commands (/coords) you can see coordinates for places that people all across the server recorded with the first command.

    I want a string variable to be set to whatever the player inputs after /addCoord and for the x y z ints to be set to whatever ints the player inputs after the string. Hopefully that makes sense, I just really don't know how to go about doing this. It's similar to the vanilla teleport command how it is set up in the way "/tp player x y z", I just want to know how to make a command similar to that, that will detect the ints that the player inputs with that basic structure.

    if (cmd.getName().equalsIgnoreCase("addcoords") && sender instanceof Player) {

    Any help I can get will be appreciated, I feel like there's a simple fix to this that I'm not realizing. I will explain a different way if you need me to because it's kinda hard to explain. Thanks
     
    Last edited: Mar 29, 2015
  2. Parse args into an integer using: Integer.parseInt(args[NUMBER]); this will check for an int. Then all you have to do is save the coords to a config or something. Example code:
    Code:
    int x = Integer.parseInt(args[NUMBER]);
    int y = Integer.parseInt(args[NUMBER]);
    int z = Integer.parseInt(args[NUMBER]);
    Then save them numbers to a file.

    Note: I'm not sure if it's fully correct, I didn't do this in an IDE and it's 13 minutes past midnight...
     
  3. Offline

    WishMachine

    Thank you very much, I was actually starting to figure out that I needed to do something like this but you just confirmed it and gave me the syntax. Much love
     
Thread Status:
Not open for further replies.

Share This Page