Skip to content

Commit

Permalink
clean up datapackage
Browse files Browse the repository at this point in the history
  • Loading branch information
KonoTyran committed May 22, 2024
1 parent e2b4f30 commit 33c67a2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 48 deletions.
3 changes: 1 addition & 2 deletions src/main/java/dev/koifysh/archipelago/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,7 @@ public boolean checkLocations(Collection<Long> locationIDs) {
* @param locationIDs List of location ID's to request info on.
*/
public void scoutLocations(ArrayList<Long> locationIDs) {
HashMap<Long, String> locations = dataPackage.getLocationsForGame(game);
locationIDs.removeIf( location -> !locations.containsKey(location));
locationIDs.removeIf( location -> !dataPackage.getGame(game).locationNameToId.containsValue(location));
webSocket.scoutLocation(locationIDs);
}

Expand Down
48 changes: 2 additions & 46 deletions src/main/java/dev/koifysh/archipelago/parts/DataPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public class DataPackage implements Serializable {
@SerializedName("games")
HashMap<String, Game> games = new HashMap<>();

HashMap<Long, String> itemIdToName = new HashMap<>();

HashMap<Long, String> locationIdToName = new HashMap<>();

public String uuid = UUID.randomUUID().toString();

public String getItem(long itemID, String game) {
Expand Down Expand Up @@ -50,48 +46,8 @@ public HashMap<String, Game> getGames() {
return games;
}

public HashMap<Long, String> getItems() {
if(itemIdToName.isEmpty()) {
for (Map.Entry<String, Game> gameEntry : games.entrySet()) {
for (Map.Entry<String, Long> items : gameEntry.getValue().itemNameToId.entrySet()) {
itemIdToName.put(items.getValue(), items.getKey());
}
}
}
return itemIdToName;
}

public HashMap<Long, String> getItemsForGame(String game) {
HashMap<Long, String> ret = new HashMap<>();
for (Map.Entry<String, Game> gameEntry : games.entrySet()) {
if(!gameEntry.getKey().equals(game)) continue;
for (Map.Entry<String, Long> items : gameEntry.getValue().itemNameToId.entrySet()) {
ret.put(items.getValue(), items.getKey());
}
}
return ret;
}

public HashMap<Long, String> getLocations() {
if(locationIdToName.isEmpty()) {
for (Map.Entry<String, Game> gameEntry : games.entrySet()) {
for (Map.Entry<String, Long> locations : gameEntry.getValue().locationNameToId.entrySet()) {
itemIdToName.put(locations.getValue(), locations.getKey());
}
}
}
return itemIdToName;
}

public HashMap<Long, String> getLocationsForGame(String game) {
HashMap<Long, String> ret = new HashMap<>();
for (Map.Entry<String, Game> gameEntry : games.entrySet()) {
if(!gameEntry.getKey().equals(game)) continue;
for (Map.Entry<String, Long> locations : gameEntry.getValue().locationNameToId.entrySet()) {
ret.put(locations.getValue(), locations.getKey());
}
}
return ret;
public Game getGame(String game) {
return games.get(game);
}


Expand Down

0 comments on commit 33c67a2

Please sign in to comment.