Skip to content

Commit

Permalink
Update to support api v0.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablete1234 committed Nov 25, 2023
1 parent 8e24f8c commit 74b3bf0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 34 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ publishing {
}

dependencies {
val apiVersion = "0.8.2"
val apiVersion = "0.8.3"
val flatLafVersion = "3.1.1"

// use this if you want to use local(mavenLocal) darkbot API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@
import eu.darkbot.api.managers.EventBrokerAPI;
import eu.darkbot.api.managers.StarSystemAPI;
import eu.darkbot.util.Timer;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;

import static com.github.manolo8.darkbot.Main.API;

Expand All @@ -57,7 +55,6 @@ public class MapManager implements Manager, StarSystemAPI {
private long viewAddress;
private long boundsAddress;
public long eventAddress;
private long settings3DAddress;

public static int id = -1;
public Lazy<Map> mapChange = new Lazy.NoCache<>();
Expand Down Expand Up @@ -485,6 +482,11 @@ public GameMap getOrCreateMap(int mapId) {
return starManager.byId(mapId);
}

@Override
public GameMap getOrCreateMap(String mapName) {
return starManager.byName(mapName);
}

@Override
public Optional<GameMap> findMap(int mapId) {
return starManager.getMaps().stream()
Expand All @@ -501,21 +503,6 @@ public Optional<GameMap> findMap(String mapName) {
.findFirst();
}

@Override
public GameMap getById(int mapId) throws MapNotFoundException {
return starManager.getById(mapId);
}

@Override
public GameMap getOrCreateMapById(int mapId) {
return starManager.byId(mapId);
}

@Override
public GameMap getByName(@NotNull String mapName) throws MapNotFoundException {
return starManager.getByName(mapName);
}

@Override
public Portal findNext(GameMap targetMap) {
return starManager.next(main.hero, starManager.byId(targetMap.getId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.github.manolo8.darkbot.core.objects.Map;
import eu.darkbot.api.API;
import eu.darkbot.api.config.annotations.Dropdown;
import eu.darkbot.api.managers.StarSystemAPI;
import org.jetbrains.annotations.NotNull;
import org.jgrapht.Graph;
import org.jgrapht.alg.shortestpath.DijkstraShortestPath;

Expand Down Expand Up @@ -242,16 +242,6 @@ public Portal next(HeroManager hero, Map target) {
.thenComparing(p -> hero.locationInfo.distance(p.locationInfo))).orElse(null);
}

public Map byName(String name) {
return starSystem.vertexSet().stream().filter(m -> m.name.equals(name)).findAny()
.orElseGet(() -> addMap(new Map(--INVALID_MAP_ID, name, false, false)));
}

public Map getByName(String name) throws StarSystemAPI.MapNotFoundException {
return starSystem.vertexSet().stream().filter(m -> m.name.equals(name)).findAny()
.orElseThrow(() -> new StarSystemAPI.MapNotFoundException(name));
}

public Stream<Map> mapSet() {
return starSystem.vertexSet().stream();
}
Expand All @@ -265,9 +255,9 @@ public Map byId(int id) {
.orElseGet(() -> addMap(new Map(id, "Unknown map " + id, false, false)));
}

public Map getById(int id) throws StarSystemAPI.MapNotFoundException {
return starSystem.vertexSet().stream().filter(m -> m.id == id).findAny()
.orElseThrow(() -> new StarSystemAPI.MapNotFoundException(id));
public Map byName(String name) {
return starSystem.vertexSet().stream().filter(m -> m.name.equals(name)).findAny()
.orElseGet(() -> addMap(new Map(--INVALID_MAP_ID, name, false, false)));
}

private Map addMap(Map map) {
Expand Down Expand Up @@ -346,7 +336,7 @@ public List<Integer> options() {
}

@Override
public String getText(Integer option) {
public @NotNull String getText(Integer option) {
if (option == null) return "";
return star.byId(option).getName();
}
Expand Down

0 comments on commit 74b3bf0

Please sign in to comment.