Skip to content

Commit

Permalink
Separated Astral changes in this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
dm94 committed Aug 18, 2023
1 parent 3347aed commit 4c19f5e
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 49 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/deeme/behaviours/ProfileChanger.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ private void changeAction() {
}
} else {
resetCounters();
if (config.reloadBot) {
Main.API.handleRefresh();
}
main.setConfig(config.BOT_PROFILE);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.deeme.behaviours.ambulance;

import eu.darkbot.api.config.annotations.Configuration;
import eu.darkbot.api.config.annotations.Dropdown;
import eu.darkbot.api.config.annotations.Number;
import eu.darkbot.api.config.annotations.Option;
import eu.darkbot.api.config.annotations.Percentage;
Expand All @@ -11,10 +10,6 @@ public class AmbulanceConfig {
@Option("general.enabled")
public boolean enable = false;

@Option("ambulance.ship_type")
@Dropdown
public AvailableShips shipType = AvailableShips.AEGIS;

@Option("general.next_check_time")
@Number(min = 1, max = 300, step = 1)
public int timeToCheck = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class ProfileChangerConfig {
@Option("profile_changer.close_bot")
public boolean closeBot = false;

@Option("profile_changer.reload_bot")
public boolean reloadBot = false;

@Option("profile_changer.only_one_condition")
public boolean orConditional = false;

Expand Down
20 changes: 14 additions & 6 deletions src/main/java/com/deeme/lang/strings_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,18 @@ astral.best_ammo=Auto choose the best ammo
astral.best_ammo.list.always=Always
astral.best_ammo.list.special_logic=Special Logic
astral.best_ammo.list.only_marked=Only marked NPCs
astral.choose_portal=Auto choose the portal (TEST)
astral.choose_portal.desc=It will choose the map that he thinks is the most appropriate.
astral.choose_item=Auto choose the item (TEST)
astral.choose_item.desc=It will choose the items randomly. DON´T USE FOR NOW
astral.display_warning=Display a warning when necessary
astral.display_warning.desc=Displays a warning when manual action is required
astral.auto_choose=Auto choose the best option [PLUS]
astral.auto_choose.desc=PLUS options only work for some users
astral.ship_to_choose=Ship to choose [PLUS]
astral.ship_to_choose.desc=PLUS options only work for some users
astral.choose_portal.desc=It will choose the portal and item that he thinks is the most appropriate.
astral.min_cpus=Minimum number of CPUs
astral.min_cpus.desc=It will not open any more astrals if it is below this number.
astral.portal_table=Portal Types
astral.portal_table.priority=Priority
astral.portal_table.priority.desc=Lower value = higher priority
astral.portal_table.ignore_limit=Ignore Limit
astral.portal_table.ignore_limit.desc=It will enter the portal even if you have the maximum of those items.
ambulance.ship_type=Type of ship
ambulance.ship_type.desc=Also works with the plus versions
Expand Down Expand Up @@ -195,6 +199,8 @@ defense.help_list.everyone=Everyone
hitac_follower.go_pvp=Go to PVP Maps
hitac_follower.return_waiting_map=Return to waiting map
hitac_follower.waiting_map=Waiting map
hitac_follower.go_for_the_title=Going for the titles
hitac_follower.go_for_the_title.desc=The bot will go to the maps where it is announced that there is a title.
profile_changer.only_one_condition=Only one condition is necessary
profile_changer.only_one_condition.desc=Only one condition in true will be necessary for the change to be made.
Expand All @@ -216,6 +222,8 @@ profile_changer.deaths_condition=Deaths condition
profile_changer.deaths_condition.max_deaths=Max deaths
profile_changer.close_bot=Close bot
profile_changer.close_bot.desc=Will close the bot instead of changing profile
profile_changer.reload_bot=Reload Bot
profile_changer.reload_bot.desc=It will Reload the bot when changing profile.
palladium_hangar.go_portal_change=Travel to portal before switch
palladium_hangar.go_portal_change.desc=Go to the portal to change the hangar
Expand Down
12 changes: 2 additions & 10 deletions src/main/java/com/deeme/modules/PalladiumHangar.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,8 @@ public PalladiumHangar(Main main, PluginAPI api, AuthAPI auth, SafetyFinder safe
this.bases = entities.getStations();

StarSystemAPI starSystem = api.getAPI(StarSystemAPI.class);
try {
this.sellMap = starSystem.getByName("5-2");
} catch (Exception e) {
this.sellMap = main.starManager.byName("5-2");
}
try {
this.activeMap = starSystem.getByName("5-3");
} catch (Exception e) {
this.activeMap = main.starManager.byName("5-3");
}
this.sellMap = starSystem.findMap("5-2").orElse(starSystem.findMap(92).orElse(null));
this.activeMap = starSystem.findMap("5-3").orElse(starSystem.findMap(93).orElse(null));

this.currentStatus = State.WAIT;
this.lastStatus = State.WAIT;
Expand Down
18 changes: 6 additions & 12 deletions src/main/java/com/deeme/tasks/AutoChangeMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,12 @@ private void selectMap(Map.Entry<String, MapData> chosseMap) {
}

private void updateWorkingMap(String mapName) {
try {
GameMap map = star.getByName(mapName);
if (map == null) {
return;
}

int mapId = map.getId();

api.requireAPI(ConfigAPI.class).requireConfig("general.working_map").setValue(mapId);
mapsAlreadyUsed.add(mapName);
} catch (Exception e) {
/* Nothing here */
GameMap map = star.findMap(mapName).orElse(null);
if (map == null) {
return;
}

api.requireAPI(ConfigAPI.class).requireConfig("general.working_map").setValue(map.getId());
mapsAlreadyUsed.add(mapName);
}
}
29 changes: 19 additions & 10 deletions src/main/java/com/deeme/tasks/HitacFollower.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import eu.darkbot.api.extensions.Feature;
import eu.darkbot.api.extensions.Task;
import eu.darkbot.api.game.entities.Npc;
import eu.darkbot.api.game.other.GameMap;
import eu.darkbot.api.managers.AuthAPI;
import eu.darkbot.api.managers.BotAPI;
import eu.darkbot.api.managers.ConfigAPI;
Expand Down Expand Up @@ -106,8 +107,7 @@ public void onTickTask() {
public void onLogMessage(GameLogAPI.LogMessageEvent message) {
if (followerConfig.enable && extensionsAPI.getFeatureInfo(this.getClass()).isEnabled()) {
String msg = message.getMessage();
if ((!msg.isEmpty() && msg.contains("Hitac")
&& ((followerConfig.goToPVP && msg.contains("PvP")) || !msg.contains("PvP")))) {
if (!msg.isEmpty() && msg.contains("Hitac") && titleFilter(msg) && pvpFilter(msg)) {
Matcher matcher = pattern.matcher(msg);
if (matcher.find()) {
lastHitacMap = matcher.group(0);
Expand All @@ -120,6 +120,15 @@ public void onLogMessage(GameLogAPI.LogMessageEvent message) {
}
}

private boolean pvpFilter(String message) {
return (followerConfig.goToPVP && message.contains("PvP")) || !message.contains("PvP");
}

private boolean titleFilter(String message) {
return followerConfig.goForTheTitle || (!message.contains("Hitac-Underling")
&& !message.contains("Hitac-Underboss"));
}

private void goToNextMap() {
String currentMap = hero.getMap().getName();
String nextMap = null;
Expand Down Expand Up @@ -164,18 +173,18 @@ private boolean hasHitac() {
return false;
}
return npcs.stream()
.filter(s -> (s.getInfo() != null && s.getEntityInfo() != null
.anyMatch(s -> (s.getEntityInfo() != null
&& s.getEntityInfo().getUsername() != null
&& s.getEntityInfo().getUsername().contains("Hitac")))
.findAny().orElse(null) != null;
&& s.getEntityInfo().getUsername().contains("Hitac")
&& !s.getEntityInfo().getUsername().contains("Hitac-Underling")
&& !s.getEntityInfo().getUsername().contains("Hitac-Underboss")));
}

private void changeMap(String mapName) {
try {
int map = star.getByName(mapName).getId();
api.requireAPI(ConfigAPI.class).requireConfig("general.working_map").setValue(map);
} catch (Exception e) {
System.out.println("Map not found" + e.getMessage());
GameMap nextMap = star.findMap(mapName).orElse(null);
if (nextMap == null) {
return;
}
api.requireAPI(ConfigAPI.class).requireConfig("general.working_map").setValue(nextMap.getId());
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/deeme/tasks/discord/Discord.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private String getAuthorPart() {
String help = "";
help += "\"author\": {";
help += "\"name\": \"Dm94Dani's Projects Discord\",";
help += "\"url\": \"https://discord.gg/GPRTRRZJPw\",";
help += "\"url\": \"" + Utils.DISCORD_URL + "\",";
help += "\"icon_url\": \"https://raw.githubusercontent.com/dm94/dm94/master/FENIX-dm94dani.png\"";
help += "}";

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/deeme/types/backpage/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import eu.darkbot.util.SystemUtils;

public class Utils {
public static final String DISCORD_URL = "https://discord.gg/GPRTRRZJPw";

private Utils() {
throw new IllegalStateException("Utility class");
Expand All @@ -39,7 +40,7 @@ public static void showDiscordDialog() {
JButton discordBtn = new JButton("Discord");
JButton closeBtn = new JButton("Close");
discordBtn.addActionListener(e -> {
SystemUtils.openUrl("https://discord.gg/GPRTRRZJPw");
SystemUtils.openUrl(DISCORD_URL);
SwingUtilities.getWindowAncestor(discordBtn).setVisible(false);
});
closeBtn.addActionListener(e -> SwingUtilities.getWindowAncestor(closeBtn).setVisible(false));
Expand Down Expand Up @@ -77,7 +78,7 @@ public static void showDiscordDonorDialog() {
JButton discordBtn = new JButton("Discord");
JButton closeBtn = new JButton("Close");
discordBtn.addActionListener(e -> {
SystemUtils.openUrl("https://discord.gg/GPRTRRZJPw");
SystemUtils.openUrl(DISCORD_URL);
SwingUtilities.getWindowAncestor(discordBtn).setVisible(false);
});
closeBtn.addActionListener(e -> SwingUtilities.getWindowAncestor(closeBtn).setVisible(false));
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/deeme/types/config/HitacFollowerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class HitacFollowerConfig {
@Option("hitac_follower.go_pvp")
public boolean goToPVP = true;

@Option("hitac_follower.go_for_the_title")
public boolean goForTheTitle = false;

@Option("hitac_follower.return_waiting_map")
public boolean returnToWaitingMap = true;

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/plugin.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "DmPlugin",
"author": "Dm94Dani",
"version": "2.0.2",
"minVersion": "1.120",
"version": "2.0.4",
"minVersion": "1.127",
"supportedVersion": "1.127",
"basePackage": "com.deeme",
"features": [
Expand Down Expand Up @@ -34,6 +34,6 @@
],
"donation": "https://ko-fi.com/deeme",
"discord": "https://discord.gg/GPRTRRZJPw",
"download": "https://github.com/darkbot-reloaded/DmPlugin/releases/download/v2.0.2/DmPlugin.jar",
"download": "https://github.com/darkbot-reloaded/DmPlugin/releases/download/v2.0.4/DmPlugin.jar",
"update": "https://raw.githubusercontent.com/darkbot-reloaded/DmPlugin/master/src/main/resources/plugin.json"
}

0 comments on commit 4c19f5e

Please sign in to comment.