Location to String

Discussion in 'Plugin Development' started by wiiboy123, Nov 22, 2015.

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

    wiiboy123

    Hello to all. How would a parse a location variable to a string (or three)? One would be the x, the y, and the z variables. How could one do such a thing, because other plugins have done it.
    I'm using it in this code, by the way:
    Code:
    if (handItem.hasItemMeta()) {
                        if (handItem.getItemMeta().getDisplayName().equalsIgnoreCase("§6Set Spawn Points          §ePlayer 1")) {
                            playerOneSpawn = e.getClickedBlock().getLocation();
                            MessageManager.getInstance().info(p, "Set Arena Broundary 2 at position: (" + playerOneSpawn + ")", true);
                        } else if (handItem.getItemMeta().getDisplayName().equalsIgnoreCase("§6Set Spawn Points          §ePlayer 2")) {
                            playerTwoSpawn = e.getClickedBlock().getLocation();
                            MessageManager.getInstance().info(p, "Set Arena Broundary 2 at position: (" + playerTwoSpawn + ")", true);
                        } else if (handItem.getItemMeta().getDisplayName().equalsIgnoreCase("§6Set Spawn Points          §eSpectator")) {
                            spectatorSpawn = e.getClickedBlock().getLocation();
                            MessageManager.getInstance().info(p, "Set Arena Broundary 2 at position: (" + spectatorSpawn + ")", true);
                        } else if (handItem.getItemMeta().getDisplayName().equalsIgnoreCase("§6Set Arena Bounds")) {
                            arenaBoundTwo = e.getClickedBlock().getLocation();
                            MessageManager.getInstance().info(p, "Set Arena Broundary 2 at position: (" + arenaBoundTwo + ")", true);
                        }
                    }
     
  2. Offline

    CraftCreeper6

    @wiiboy123
    Location#getX();
    Location#getY();
    Location#getZ();
    Location#getWorld();
    Location#getYaw();

    You get the picture.
     
  3. Offline

    Zombie_Striker

    -snip-. Though you said FROM a string to a location.
     
    Last edited: Nov 22, 2015
  4. Offline

    CraftCreeper6

  5. Offline

    wiiboy123

    Works, thanks
     
  6. Offline

    Zombie_Striker

  7. Offline

    CraftCreeper6

  8. Offline

    Xerox262

    Last edited: Nov 22, 2015
  9. Offline

    Scimiguy

    @Zombie_Striker
    What @Xerox262 is saying is that all Objects inherit toString(). That doesn't mean the method handles as you'd expect.
    You do have to use the concept that CraftCreeper hinted at above
     
Thread Status:
Not open for further replies.

Share This Page