Skip to content

Commit c89edd3

Browse files
authored
Merge pull request #87 from benny-dreamly/add-location-id-helper
Add a helper function to get the location ID from an inputted name
2 parents da42ef0 + 3ced9cc commit c89edd3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/main/java/io/github/archipelagomw/LocationManager.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,23 @@ public void setMissingLocations(Set<Long> missingLocations) {
9292
this.missingLocations.clear();
9393
this.missingLocations.addAll(missingLocations);
9494
}
95+
96+
/**
97+
Helper to get the location ID from an inputted location name as a String. Only use this
98+
if you know what you're dealing with, and can accept that getting this from the datapackage
99+
is not 100% reliable.
100+
101+
@param locationName The name of the location you wish to look up.
102+
@return The ID of the location that you have looked up from the datapackage.
103+
*/
104+
public Optional<Long> getLocationNameFromID(String locationName){
105+
return Optional.ofNullable(
106+
this.client
107+
.getDataPackage()
108+
.getGame(this.client.getGame())
109+
)
110+
.map(game -> game.locationNameToId
111+
.get(locationName)
112+
);
113+
}
95114
}

0 commit comments

Comments
 (0)