I am trying to save the location of a player in minecraft to a list this works good but now how do I get my location back by searching trought the list on playerName?
Piece of code where the list class is created and the list
public static class Character {
private String name;
private Location location;
public Character(String name, Location location) {
this.name = name;
this.location = location;
}
}
public static class Location {
private int x;
private int y;
private int z;
public Location(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
}
List<Character> rawInput = new ArrayList<Character>();
piece of code where I add an item to the list :
else if (args[0].equalsIgnoreCase("select"))
{
int tmpX = (int)player.getLocation().getX();
int tmpY = (int)player.getLocation().getY();
int tmpZ = (int)player.getLocation().getZ();
rawInput.add(
new Character( player.getName(), new Location( tmpX, tmpY, tmpZ )));
player.sendMessage(
ChatColor.GOLD + "[PlusCommands] " + ChatColor.GREEN
+ "selected location set to player location!");
}
This works all fine but how do I get the the data back for example :
This is a list with locations : Playername X Y Z :
PlayerThree 32 13 46
PlayerTwo 12 60 212
PlayerOne 43 62 523
So I want to search for the right player in this example case I am PlayerOne So I want to get the data from the playerList where the string says PlayerOne
In this case thats this one : PlayerOne 43 62 523
How do I do this???
I hope I am clear enough sorry for it if not.
public static Location getLocation(String name) { //Do stuff to check if name is available //Get location specific to name return location; }