From e982d136cb7c462744c1952eb0f122bea42f42d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Sun, 1 Sep 2024 13:36:05 +0200 Subject: [PATCH] feat: AutoBestRocket Added all the rockets (#180) --- .../bestrocket/BestRocketConfig.java | 5 +- .../bestrocket/SupportedRockets.java | 50 ------------------- .../types/suppliers/BestRocketSupplier.java | 6 +-- src/main/resources/plugin.json | 2 +- 4 files changed, 7 insertions(+), 56 deletions(-) delete mode 100644 src/main/java/com/deeme/behaviours/bestrocket/SupportedRockets.java diff --git a/src/main/java/com/deeme/behaviours/bestrocket/BestRocketConfig.java b/src/main/java/com/deeme/behaviours/bestrocket/BestRocketConfig.java index 5bf4c7b8..14180053 100644 --- a/src/main/java/com/deeme/behaviours/bestrocket/BestRocketConfig.java +++ b/src/main/java/com/deeme/behaviours/bestrocket/BestRocketConfig.java @@ -6,6 +6,7 @@ import eu.darkbot.api.config.annotations.Configuration; import eu.darkbot.api.config.annotations.Dropdown; import eu.darkbot.api.config.annotations.Option; +import eu.darkbot.api.game.items.SelectableItem.Rocket; @Configuration("best_rocket") public class BestRocketConfig { @@ -15,11 +16,11 @@ public class BestRocketConfig { @Option("best_rocket.rockets_to_use_npcs") @Dropdown(multi = true) - public Set rocketsToUseNPCs = EnumSet.noneOf(SupportedRockets.class); + public Set rocketsToUseNPCs = EnumSet.noneOf(Rocket.class); @Option("best_rocket.rockets_to_use_players") @Dropdown(multi = true) - public Set rocketsToUsePlayers = EnumSet.allOf(SupportedRockets.class); + public Set rocketsToUsePlayers = EnumSet.allOf(Rocket.class); @Option("general.tick_stopped") public boolean tickStopped = false; diff --git a/src/main/java/com/deeme/behaviours/bestrocket/SupportedRockets.java b/src/main/java/com/deeme/behaviours/bestrocket/SupportedRockets.java deleted file mode 100644 index 7e411b63..00000000 --- a/src/main/java/com/deeme/behaviours/bestrocket/SupportedRockets.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.deeme.behaviours.bestrocket; - -import java.util.Locale; - -import eu.darkbot.api.game.items.ItemCategory; -import eu.darkbot.api.game.items.SelectableItem; - -/** - * Based on - * https://github.com/darkbot-reloaded/DarkBotAPI/blob/master/api/src/main/java/eu/darkbot/api/game/items/SelectableItem.java - */ - -public enum SupportedRockets implements SelectableItem { - R_310, - PLT_2026, - PLT_2021, - PLT_3030, - PLD_8(true), - DCR_250(true), - BDR_1211, - R_IC3(true), - SR_5(true), - K_300M(true), - SP_100X(true), - AGT_500, - RC_100(true); - - private static final String PREFIX = "ammunition_rocket_"; - private static final String PREFIX_SPECIAL = "ammunition_specialammo_"; - private final String id; - - SupportedRockets() { - this(false); - } - - SupportedRockets(boolean isSpecial) { - this.id = (isSpecial ? PREFIX_SPECIAL : PREFIX) + name().toLowerCase(Locale.ROOT).replace("_", "-"); - } - - @Override - public String getId() { - return id; - } - - @Override - public ItemCategory getCategory() { - return ItemCategory.ROCKETS; - } - -} diff --git a/src/main/java/com/deeme/types/suppliers/BestRocketSupplier.java b/src/main/java/com/deeme/types/suppliers/BestRocketSupplier.java index d9805ef2..19977a09 100644 --- a/src/main/java/com/deeme/types/suppliers/BestRocketSupplier.java +++ b/src/main/java/com/deeme/types/suppliers/BestRocketSupplier.java @@ -6,7 +6,6 @@ import java.util.Set; import com.deeme.behaviours.bestrocket.BestRocketConfig; -import com.deeme.behaviours.bestrocket.SupportedRockets; import com.deeme.types.SharedFunctions; import eu.darkbot.api.PluginAPI; @@ -34,7 +33,8 @@ public class BestRocketSupplier { List damageOrder = Arrays.asList(Rocket.SP_100X, Rocket.PLT_3030, Rocket.PLT_2021, Rocket.BDR_1211, Rocket.PLT_2026, - Rocket.R_310); + Rocket.R_310, + Rocket.WIZ_X); List damageOrderNPCs = Arrays.asList(Rocket.BDR_1211, Rocket.SP_100X, Rocket.PLT_3030, @@ -156,7 +156,7 @@ private boolean ableToUse(SelectableItem rocket, boolean isNpc) { return ableToUse(rocket, config.rocketsToUsePlayers); } - private boolean ableToUse(SelectableItem rocket, Set rockets) { + private boolean ableToUse(SelectableItem rocket, Set rockets) { return rocket != null && rockets.stream().anyMatch(s -> s.getId() != null && s.getId().equals(rocket.getId())) && ableToUse(rocket); } diff --git a/src/main/resources/plugin.json b/src/main/resources/plugin.json index 2c206668..ddc4acc3 100644 --- a/src/main/resources/plugin.json +++ b/src/main/resources/plugin.json @@ -1,7 +1,7 @@ { "name": "DmPlugin", "author": "Dm94Dani", - "version": "2.3.0 beta 5", + "version": "2.3.0 beta 6", "minVersion": "1.131", "supportedVersion": "1.131.2", "basePackage": "com.deeme",