From 94c49fc76fb1c2815065521da68a7c1097adb57a Mon Sep 17 00:00:00 2001 From: Dm94 Date: Sat, 8 Apr 2023 17:04:18 +0200 Subject: [PATCH 1/3] v1.7.27 Updated the HangarSwitcher module to remove the darkbot dependency. --- pom.xml | 4 +-- .../com/deeme/modules/PalladiumHangar.java | 4 +-- .../modules/temporal/HangarSwitcher.java | 30 ++++++++----------- .../java/com/deeme/tasks/WeeklySchedule.java | 2 +- .../java/com/deeme/types/SharedFunctions.java | 5 ++++ src/main/resources/plugin.json | 2 +- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/pom.xml b/pom.xml index e4a13126..16cf6b0a 100644 --- a/pom.xml +++ b/pom.xml @@ -31,12 +31,12 @@ eu.darkbot DarkBot - master-a5fa9a8a26-1 + master-SNAPSHOT eu.darkbot DarkBotAPI - 0.7.0 + 0.7.1 diff --git a/src/main/java/com/deeme/modules/PalladiumHangar.java b/src/main/java/com/deeme/modules/PalladiumHangar.java index 555f6681..462ee86c 100644 --- a/src/main/java/com/deeme/modules/PalladiumHangar.java +++ b/src/main/java/com/deeme/modules/PalladiumHangar.java @@ -196,7 +196,7 @@ && canBeDisconnected()) { this.currentStatus = State.DEPOSIT_FULL_SWITCHING_HANGAR; if (botApi.getModule().getClass() != HangarSwitcher.class) { this.activeHangar = null; - botApi.setModule(new HangarSwitcher(main, api, configPa.sellHangar)); + botApi.setModule(new HangarSwitcher(api, configPa.sellHangar)); } } else { pet.setEnabled(true); @@ -211,7 +211,7 @@ && canBeDisconnected()) { this.currentStatus = State.SWITCHING_PALA_HANGAR; if (botApi.getModule().getClass() != HangarSwitcher.class) { this.activeHangar = null; - botApi.setModule(new HangarSwitcher(main, api, configPa.collectHangar)); + botApi.setModule(new HangarSwitcher(api, configPa.collectHangar)); } } } diff --git a/src/main/java/com/deeme/modules/temporal/HangarSwitcher.java b/src/main/java/com/deeme/modules/temporal/HangarSwitcher.java index 011148c4..c1e34a26 100644 --- a/src/main/java/com/deeme/modules/temporal/HangarSwitcher.java +++ b/src/main/java/com/deeme/modules/temporal/HangarSwitcher.java @@ -2,14 +2,14 @@ import com.deeme.types.SharedFunctions; import com.github.manolo8.darkbot.Main; -import com.github.manolo8.darkbot.backpage.HangarManager; -import com.github.manolo8.darkbot.backpage.hangar.Hangar; import eu.darkbot.api.PluginAPI; import eu.darkbot.api.game.other.Gui; import eu.darkbot.api.managers.BackpageAPI; import eu.darkbot.api.managers.BotAPI; +import eu.darkbot.api.managers.EntitiesAPI; import eu.darkbot.api.managers.GameScreenAPI; +import eu.darkbot.api.managers.HangarAPI; import eu.darkbot.api.managers.HeroAPI; import eu.darkbot.api.utils.Inject; import eu.darkbot.shared.modules.TemporalModule; @@ -18,14 +18,14 @@ public class HangarSwitcher extends TemporalModule { protected final PluginAPI api; protected final HeroAPI heroapi; protected final BackpageAPI backpageAPI; + protected final HangarAPI hangarApi; + protected final EntitiesAPI entities; protected final Gui lostConnectionGUI; protected final Gui logout; private Integer activeHangar = null; private Integer hangarToChage = null; - private final Main main; - private final HangarManager hangarManager; private State currentStatus; private long waitinUntil = 0; @@ -51,19 +51,19 @@ private enum State { } } - public HangarSwitcher(Main m, PluginAPI api, Integer hangar) { - this(m, api, api.requireAPI(BotAPI.class), hangar); + public HangarSwitcher(PluginAPI api, Integer hangar) { + this(api, api.requireAPI(BotAPI.class), hangar); } @Inject - public HangarSwitcher(Main m, PluginAPI api, BotAPI bot, Integer hangar) { + public HangarSwitcher(PluginAPI api, BotAPI bot, Integer hangar) { super(bot); - this.main = m; - this.hangarManager = main.backpage.hangarManager; this.api = api; this.heroapi = api.getAPI(HeroAPI.class); this.backpageAPI = api.getAPI(BackpageAPI.class); + this.hangarApi = api.getAPI(HangarAPI.class); + this.entities = api.getAPI(EntitiesAPI.class); this.hangarToChage = hangar; this.checkCount = 0; @@ -127,7 +127,7 @@ public void onTickModule() { goBack(); } else { this.currentStatus = State.SWITCHING_HANGAR; - if (hangarManager.changeHangar(String.valueOf(hangarToChage))) { + if (hangarApi.changeHangar(hangarToChage)) { hangarChanged = true; this.currentStatus = State.HANGAR_CHANGED; waitinUntil = System.currentTimeMillis() + 10000; @@ -138,7 +138,7 @@ public void onTickModule() { this.activeHangar = null; } } - } else if (!heroapi.isAttacking() && !SharedFunctions.hasAttacker(heroapi, main)) { + } else if (!heroapi.isAttacking() && !SharedFunctions.hasAttacker(heroapi, entities, heroapi)) { disconnect(); } else { goBack(); @@ -177,12 +177,8 @@ private void disconnect() { private void updateHangarActive() { this.currentStatus = State.LOADING_HANGARS; try { - hangarManager.updateHangarList(); - activeHangar = hangarManager.getHangarList().getData().getRet().getHangars().stream() - .filter(Hangar::isActive) - .map(Hangar::getHangarId) - .findFirst() - .orElse(null); + hangarApi.updateHangarList(); + activeHangar = hangarApi.getCurrentHangarId(); } catch (Exception ignored) { waitinUntil = System.currentTimeMillis() + 20000; activeHangar = null; diff --git a/src/main/java/com/deeme/tasks/WeeklySchedule.java b/src/main/java/com/deeme/tasks/WeeklySchedule.java index dee58e34..575767ed 100644 --- a/src/main/java/com/deeme/tasks/WeeklySchedule.java +++ b/src/main/java/com/deeme/tasks/WeeklySchedule.java @@ -135,7 +135,7 @@ public void onTickTask() { if (!profileToUse.hangarId.equals(activeHangar)) { if (isDisconnect()) { if (botApi.getModule().getClass() != HangarSwitcher.class) { - botApi.setModule(new HangarSwitcher(main, api, profileToUse.hangarId)); + botApi.setModule(new HangarSwitcher(api, profileToUse.hangarId)); } this.activeHangar = null; } else if (botApi.getModule().getClass() != DisconnectModule.class) { diff --git a/src/main/java/com/deeme/types/SharedFunctions.java b/src/main/java/com/deeme/types/SharedFunctions.java index d164583f..cb5909fb 100644 --- a/src/main/java/com/deeme/types/SharedFunctions.java +++ b/src/main/java/com/deeme/types/SharedFunctions.java @@ -52,6 +52,11 @@ public static boolean hasAttacker(Ship assaulted, Main main) { return ship != null; } + public static boolean hasAttacker(Ship assaulted, EntitiesAPI entities, HeroAPI hero) { + Ship ship = getAttacker(assaulted, entities.getShips(), hero); + return ship != null; + } + public static boolean isNpcByName(ConfigAPI config, String name) { ConfigSetting> configSetting = config.requireConfig("loot.npc_infos"); if (configSetting.getValue() != null) { diff --git a/src/main/resources/plugin.json b/src/main/resources/plugin.json index 99b55449..b4cb3c09 100644 --- a/src/main/resources/plugin.json +++ b/src/main/resources/plugin.json @@ -1,7 +1,7 @@ { "name": "DmPlugin", "author": "Dm94Dani", - "version": "1.7.26", + "version": "1.7.27", "minVersion": "1.13.17 beta 111", "supportedVersion": "1.120", "basePackage": "com.deeme", From 1f6201f2ba7861514a4aae78f635cea18c40bdcb Mon Sep 17 00:00:00 2001 From: Dm94 Date: Sun, 16 Apr 2023 10:36:50 +0200 Subject: [PATCH 2/3] Revert "v1.7.27" This reverts commit 94c49fc76fb1c2815065521da68a7c1097adb57a. --- pom.xml | 4 +-- .../com/deeme/modules/PalladiumHangar.java | 4 +-- .../modules/temporal/HangarSwitcher.java | 30 +++++++++++-------- .../java/com/deeme/tasks/WeeklySchedule.java | 2 +- .../java/com/deeme/types/SharedFunctions.java | 5 ---- src/main/resources/plugin.json | 2 +- 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index 16cf6b0a..e4a13126 100644 --- a/pom.xml +++ b/pom.xml @@ -31,12 +31,12 @@ eu.darkbot DarkBot - master-SNAPSHOT + master-a5fa9a8a26-1 eu.darkbot DarkBotAPI - 0.7.1 + 0.7.0 diff --git a/src/main/java/com/deeme/modules/PalladiumHangar.java b/src/main/java/com/deeme/modules/PalladiumHangar.java index 462ee86c..555f6681 100644 --- a/src/main/java/com/deeme/modules/PalladiumHangar.java +++ b/src/main/java/com/deeme/modules/PalladiumHangar.java @@ -196,7 +196,7 @@ && canBeDisconnected()) { this.currentStatus = State.DEPOSIT_FULL_SWITCHING_HANGAR; if (botApi.getModule().getClass() != HangarSwitcher.class) { this.activeHangar = null; - botApi.setModule(new HangarSwitcher(api, configPa.sellHangar)); + botApi.setModule(new HangarSwitcher(main, api, configPa.sellHangar)); } } else { pet.setEnabled(true); @@ -211,7 +211,7 @@ && canBeDisconnected()) { this.currentStatus = State.SWITCHING_PALA_HANGAR; if (botApi.getModule().getClass() != HangarSwitcher.class) { this.activeHangar = null; - botApi.setModule(new HangarSwitcher(api, configPa.collectHangar)); + botApi.setModule(new HangarSwitcher(main, api, configPa.collectHangar)); } } } diff --git a/src/main/java/com/deeme/modules/temporal/HangarSwitcher.java b/src/main/java/com/deeme/modules/temporal/HangarSwitcher.java index c1e34a26..011148c4 100644 --- a/src/main/java/com/deeme/modules/temporal/HangarSwitcher.java +++ b/src/main/java/com/deeme/modules/temporal/HangarSwitcher.java @@ -2,14 +2,14 @@ import com.deeme.types.SharedFunctions; import com.github.manolo8.darkbot.Main; +import com.github.manolo8.darkbot.backpage.HangarManager; +import com.github.manolo8.darkbot.backpage.hangar.Hangar; import eu.darkbot.api.PluginAPI; import eu.darkbot.api.game.other.Gui; import eu.darkbot.api.managers.BackpageAPI; import eu.darkbot.api.managers.BotAPI; -import eu.darkbot.api.managers.EntitiesAPI; import eu.darkbot.api.managers.GameScreenAPI; -import eu.darkbot.api.managers.HangarAPI; import eu.darkbot.api.managers.HeroAPI; import eu.darkbot.api.utils.Inject; import eu.darkbot.shared.modules.TemporalModule; @@ -18,14 +18,14 @@ public class HangarSwitcher extends TemporalModule { protected final PluginAPI api; protected final HeroAPI heroapi; protected final BackpageAPI backpageAPI; - protected final HangarAPI hangarApi; - protected final EntitiesAPI entities; protected final Gui lostConnectionGUI; protected final Gui logout; private Integer activeHangar = null; private Integer hangarToChage = null; + private final Main main; + private final HangarManager hangarManager; private State currentStatus; private long waitinUntil = 0; @@ -51,19 +51,19 @@ private enum State { } } - public HangarSwitcher(PluginAPI api, Integer hangar) { - this(api, api.requireAPI(BotAPI.class), hangar); + public HangarSwitcher(Main m, PluginAPI api, Integer hangar) { + this(m, api, api.requireAPI(BotAPI.class), hangar); } @Inject - public HangarSwitcher(PluginAPI api, BotAPI bot, Integer hangar) { + public HangarSwitcher(Main m, PluginAPI api, BotAPI bot, Integer hangar) { super(bot); + this.main = m; + this.hangarManager = main.backpage.hangarManager; this.api = api; this.heroapi = api.getAPI(HeroAPI.class); this.backpageAPI = api.getAPI(BackpageAPI.class); - this.hangarApi = api.getAPI(HangarAPI.class); - this.entities = api.getAPI(EntitiesAPI.class); this.hangarToChage = hangar; this.checkCount = 0; @@ -127,7 +127,7 @@ public void onTickModule() { goBack(); } else { this.currentStatus = State.SWITCHING_HANGAR; - if (hangarApi.changeHangar(hangarToChage)) { + if (hangarManager.changeHangar(String.valueOf(hangarToChage))) { hangarChanged = true; this.currentStatus = State.HANGAR_CHANGED; waitinUntil = System.currentTimeMillis() + 10000; @@ -138,7 +138,7 @@ public void onTickModule() { this.activeHangar = null; } } - } else if (!heroapi.isAttacking() && !SharedFunctions.hasAttacker(heroapi, entities, heroapi)) { + } else if (!heroapi.isAttacking() && !SharedFunctions.hasAttacker(heroapi, main)) { disconnect(); } else { goBack(); @@ -177,8 +177,12 @@ private void disconnect() { private void updateHangarActive() { this.currentStatus = State.LOADING_HANGARS; try { - hangarApi.updateHangarList(); - activeHangar = hangarApi.getCurrentHangarId(); + hangarManager.updateHangarList(); + activeHangar = hangarManager.getHangarList().getData().getRet().getHangars().stream() + .filter(Hangar::isActive) + .map(Hangar::getHangarId) + .findFirst() + .orElse(null); } catch (Exception ignored) { waitinUntil = System.currentTimeMillis() + 20000; activeHangar = null; diff --git a/src/main/java/com/deeme/tasks/WeeklySchedule.java b/src/main/java/com/deeme/tasks/WeeklySchedule.java index 575767ed..dee58e34 100644 --- a/src/main/java/com/deeme/tasks/WeeklySchedule.java +++ b/src/main/java/com/deeme/tasks/WeeklySchedule.java @@ -135,7 +135,7 @@ public void onTickTask() { if (!profileToUse.hangarId.equals(activeHangar)) { if (isDisconnect()) { if (botApi.getModule().getClass() != HangarSwitcher.class) { - botApi.setModule(new HangarSwitcher(api, profileToUse.hangarId)); + botApi.setModule(new HangarSwitcher(main, api, profileToUse.hangarId)); } this.activeHangar = null; } else if (botApi.getModule().getClass() != DisconnectModule.class) { diff --git a/src/main/java/com/deeme/types/SharedFunctions.java b/src/main/java/com/deeme/types/SharedFunctions.java index cb5909fb..d164583f 100644 --- a/src/main/java/com/deeme/types/SharedFunctions.java +++ b/src/main/java/com/deeme/types/SharedFunctions.java @@ -52,11 +52,6 @@ public static boolean hasAttacker(Ship assaulted, Main main) { return ship != null; } - public static boolean hasAttacker(Ship assaulted, EntitiesAPI entities, HeroAPI hero) { - Ship ship = getAttacker(assaulted, entities.getShips(), hero); - return ship != null; - } - public static boolean isNpcByName(ConfigAPI config, String name) { ConfigSetting> configSetting = config.requireConfig("loot.npc_infos"); if (configSetting.getValue() != null) { diff --git a/src/main/resources/plugin.json b/src/main/resources/plugin.json index b4cb3c09..99b55449 100644 --- a/src/main/resources/plugin.json +++ b/src/main/resources/plugin.json @@ -1,7 +1,7 @@ { "name": "DmPlugin", "author": "Dm94Dani", - "version": "1.7.27", + "version": "1.7.26", "minVersion": "1.13.17 beta 111", "supportedVersion": "1.120", "basePackage": "com.deeme", From 1f7f740117b615bbb987a43078805d37a9e5731c Mon Sep 17 00:00:00 2001 From: Dm94 Date: Sun, 16 Apr 2023 16:56:27 +0200 Subject: [PATCH 3/3] v1.7.27 - Removed PVPLog - Improved Auto Best Ability --- pom.xml | 5 - .../java/com/deeme/behaviours/PVPLog.java | 319 ------------------ .../bestability/AutoBestAbility.java | 15 +- src/main/java/com/deeme/tasks/Discord.java | 2 +- src/main/resources/plugin.json | 7 +- 5 files changed, 15 insertions(+), 333 deletions(-) delete mode 100644 src/main/java/com/deeme/behaviours/PVPLog.java diff --git a/pom.xml b/pom.xml index e4a13126..d2cbfc87 100644 --- a/pom.xml +++ b/pom.xml @@ -23,11 +23,6 @@ - - com.google.code.gson - gson - 2.8.9 - eu.darkbot DarkBot diff --git a/src/main/java/com/deeme/behaviours/PVPLog.java b/src/main/java/com/deeme/behaviours/PVPLog.java deleted file mode 100644 index a9dd2ad7..00000000 --- a/src/main/java/com/deeme/behaviours/PVPLog.java +++ /dev/null @@ -1,319 +0,0 @@ -package com.deeme.behaviours; - -import com.deeme.types.VerifierChecker; -import com.google.gson.Gson; - -import eu.darkbot.api.PluginAPI; -import eu.darkbot.api.extensions.Behavior; -import eu.darkbot.api.extensions.Feature; -import eu.darkbot.api.extensions.Task; -import eu.darkbot.api.game.entities.Player; -import eu.darkbot.api.game.items.Item; -import eu.darkbot.api.game.items.ItemCategory; -import eu.darkbot.api.game.other.Lockable; -import eu.darkbot.api.managers.AuthAPI; -import eu.darkbot.api.managers.EntitiesAPI; -import eu.darkbot.api.managers.HeroAPI; -import eu.darkbot.api.managers.HeroItemsAPI; -import eu.darkbot.api.managers.RepairAPI; -import eu.darkbot.api.managers.StatsAPI; -import eu.darkbot.api.utils.Inject; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -@Feature(name = "PVPLog", description = "Create a log of the PVP battles") -public class PVPLog implements Behavior, Task { - public final Path battleLogFolder = Paths.get("battlelog"); - private Player target = null; - - protected final PluginAPI api; - protected final StatsAPI stats; - protected final HeroAPI hero; - protected final RepairAPI repair; - protected final HeroItemsAPI items; - protected Collection players; - - private Gson gson; - - // Global Data - private int mapID = 0; - private long initialTime = 0; - private boolean win = false; - private int deaths = 0; - - // Our Data - private String shipId = ""; - private int maxHp = 0; - private int initialHP = 0; - private int maxShield = 0; - private int initialShield = 0; - private int initialHull = 0; - private String initialLaser = ""; - private String initialRocket = ""; - private int initialConfig = 0; - private String initialFormation = ""; - private int initialSpeed = 0; - private boolean hasPet = false; - - // Enemy Data - private int enemyId = 0; - private String enemyShipType = ""; - private int enemyMaxHp = 0; - private int enemyInitialHP = 0; - private int enemyMaxShield = 0; - private int enemyInitialShield = 0; - private int enemyInitialHull = 0; - - // Batle Data - private boolean battleStart = false; - ArrayList battleData = new ArrayList(); - - Map lastOurData = new HashMap<>(); - Map lastEnemyData = new HashMap<>(); - - private ArrayList saveQueue = new ArrayList(); - - public PVPLog(PluginAPI api) { - this(api, api.requireAPI(HeroAPI.class), - api.requireAPI(StatsAPI.class), - api.requireAPI(RepairAPI.class), - api.requireAPI(AuthAPI.class), - api.requireAPI(HeroItemsAPI.class)); - } - - @Inject - public PVPLog(PluginAPI api, HeroAPI hero, StatsAPI stats, RepairAPI repair, AuthAPI auth, HeroItemsAPI items) { - if (!Arrays.equals(VerifierChecker.class.getSigners(), getClass().getSigners())) - throw new SecurityException(); - VerifierChecker.checkAuthenticity(auth); - - this.api = api; - this.hero = hero; - this.stats = stats; - this.repair = repair; - this.items = items; - this.gson = new Gson(); - - EntitiesAPI entities = api.getAPI(EntitiesAPI.class); - this.players = entities.getPlayers(); - - try { - if (!Files.exists(battleLogFolder)) { - Files.createDirectory(battleLogFolder); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Override - public void onTickTask() { - saveData(); - } - - @Override - public void onTickBehavior() { - if (hero.getMap() != null && hero.getMap().isGG()) { - return; - } - try { - if (stats.getPing() > 1 && hero.getMap() != null) { - mapID = hero.getMap().getId(); - - if (hero.isAttacking() && hero.getLocalTarget() != null - && hero.getLocalTarget().getEntityInfo().isEnemy() - && !hero.getLocalTarget().getEntityInfo().getUsername().contains("Saturn")) { - battleStart = true; - if (enemyId != hero.getLocalTarget().getId()) { - setInitialEnemyData(); - } - addBattleData(); - } else if (hero.getTarget() != null) { - setInitialEnemyData(); - } else { - resetData(); - setOwnInitialData(); - } - } else { - resetData(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - private Player getEnemy() { - Lockable enemy = hero.getLocalTarget(); - if (enemy != null && enemy.getHealth() != null) { - return players.stream() - .filter(s -> (enemy.getId() == s.getId())) - .findAny().orElse(null); - } - - return null; - } - - private void setOwnInitialData() { - if (hero.getHealth() != null) { - shipId = hero.getShipType(); - maxHp = hero.getHealth().getMaxHp(); - initialHP = hero.getHealth().getHp(); - maxShield = hero.getHealth().getMaxShield(); - initialShield = hero.getHealth().getShield(); - initialHull = hero.getHealth().getHull(); - initialLaser = hero.getLaser() != null ? hero.getLaser().getId() : ""; - initialRocket = hero.getRocket() != null ? hero.getRocket().getId() : ""; - initialConfig = hero.getConfiguration() != null ? hero.getConfiguration().ordinal() : 0; - initialFormation = hero.getFormation() != null ? hero.getFormation().getId() : ""; - initialSpeed = hero.getSpeed(); - hasPet = hero.hasPet(); - } - } - - private void setInitialEnemyData() { - target = getEnemy(); - if (target != null) { - enemyId = target.getId(); - enemyShipType = target.getShipType(); - enemyMaxHp = target.getHealth().getMaxHp(); - enemyInitialHP = target.getHealth().getHp(); - enemyMaxShield = target.getHealth().getMaxShield(); - enemyInitialShield = target.getHealth().getShield(); - enemyInitialHull = target.getHealth().getHull(); - } - } - - private void addBattleData() { - Map ourData = new HashMap<>(); - ourData.put("hp", hero.getHealth().getHp()); - ourData.put("shield", hero.getHealth().getShield()); - ourData.put("hull", hero.getHealth().getHull()); - ourData.put("laser", hero.getLaser() != null ? hero.getLaser().getId() : ""); - ourData.put("rocket", hero.getRocket() != null ? hero.getRocket().getId() : ""); - ourData.put("config", hero.getConfiguration() != null ? hero.getConfiguration().ordinal() : 0); - ourData.put("formation", hero.getFormation() != null ? hero.getFormation().getId() : ""); - ourData.put("speed", hero.getSpeed()); - ourData.put("pet", hero.hasPet()); - ourData.put("effects", hero.getEffects().toString()); - ourData.put("items", getOurSpecialItems()); - - Map enemyData = new HashMap<>(); - enemyData.put("hp", target.getHealth().getHp()); - enemyData.put("shield", target.getHealth().getShield()); - enemyData.put("hull", target.getHealth().getHull()); - enemyData.put("effects", target.getEffects().toString()); - enemyData.put("formation", target.getFormation() != null ? target.getFormation().getId() : ""); - enemyData.put("speed", target.getSpeed()); - enemyData.put("pet", target.hasPet()); - - if (!lastOurData.equals(ourData) && !lastEnemyData.equals(enemyData)) { - Map globalDetails = new HashMap<>(); - globalDetails.put("time", System.currentTimeMillis()); - globalDetails.put("ourData", ourData); - globalDetails.put("enemyData", enemyData); - battleData.add(globalDetails); - } - - lastOurData = ourData; - lastEnemyData = enemyData; - } - - private Map getOurSpecialItems() { - Map ourItems = new HashMap<>(); - - List usableItems = items.getItems(ItemCategory.SPECIAL_ITEMS).stream().filter(Item::isUsable) - .filter(Item::isAvailable) - .collect(Collectors.toList()); - for (Item item : usableItems) { - try { - if (item.lastUseTime() != 0) { - ourItems.put(item.getId(), item.getTimer()); - } - } catch (Exception e) { - System.err.println(e.getMessage()); - } - } - - return ourItems; - } - - private void resetData() { - target = null; - if (battleStart || !battleData.isEmpty()) { - if (deaths == repair.getDeathAmount()) { - win = true; - } - insertToQueue(); - battleStart = false; - } - battleData.clear(); - enemyId = 0; - initialTime = System.currentTimeMillis(); - deaths = repair.getDeathAmount(); - win = false; - } - - private void insertToQueue() { - Map ownInitialData = new HashMap<>(); - ownInitialData.put("shipId", shipId); - ownInitialData.put("maxHp", maxHp); - ownInitialData.put("initialHP", initialHP); - ownInitialData.put("maxShield", maxShield); - ownInitialData.put("initialShield", initialShield); - ownInitialData.put("initialHull", initialHull); - ownInitialData.put("initialLaser", initialLaser); - ownInitialData.put("initialRocket", initialRocket); - ownInitialData.put("initialConfig", initialConfig); - ownInitialData.put("initialFormation", initialFormation); - ownInitialData.put("initialSpeed", initialSpeed); - ownInitialData.put("hasPet", hasPet); - - Map enemyInitialData = new HashMap<>(); - enemyInitialData.put("enemyShipTipe", enemyShipType); - enemyInitialData.put("enemyMaxHp", enemyMaxHp); - enemyInitialData.put("enemyInitialHP", enemyInitialHP); - enemyInitialData.put("enemyMaxShield", enemyMaxShield); - enemyInitialData.put("enemyInitialShield", enemyInitialShield); - enemyInitialData.put("enemyInitialHull", enemyInitialHull); - - Map globalDetails = new HashMap<>(); - globalDetails.put("date", initialTime); - globalDetails.put("endDate", System.currentTimeMillis()); - globalDetails.put("mapID", mapID); - globalDetails.put("battleWon", win); - globalDetails.put("battleData", battleData); - globalDetails.put("ownInitialData", ownInitialData); - globalDetails.put("enemyInitialData", enemyInitialData); - - saveQueue.add(gson.toJson(globalDetails)); - } - - private void saveData() { - try { - if (saveQueue.size() > 0) { - String data = saveQueue.get(0); - saveQueue.remove(0); - - File f = new File("battlelog", System.currentTimeMillis() + ".json"); - Writer writer = new FileWriter(f); - writer.write(data); - writer.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/src/main/java/com/deeme/behaviours/bestability/AutoBestAbility.java b/src/main/java/com/deeme/behaviours/bestability/AutoBestAbility.java index 3708781d..9bd588c0 100644 --- a/src/main/java/com/deeme/behaviours/bestability/AutoBestAbility.java +++ b/src/main/java/com/deeme/behaviours/bestability/AutoBestAbility.java @@ -198,10 +198,6 @@ private Ability getBestAbility() { return Ability.GOLIATH_X_FROZEN_CLAW; } else if (isAvailable(Ability.VENOM)) { return Ability.VENOM; - } else if (isAvailable(Ability.SOLARIS_INC)) { - return Ability.SOLARIS_INC; - } else if (isAvailable(Ability.SOLARIS_PLUS_INCINERATE_PLUS)) { - return Ability.SOLARIS_PLUS_INCINERATE_PLUS; } else if (isAvailable(Ability.TARTARUS_RAPID_FIRE)) { return Ability.TARTARUS_RAPID_FIRE; } else if (isAvailable(Ability.DISRUPTOR_SHIELD_DISARRAY)) { @@ -214,6 +210,12 @@ private Ability getBestAbility() { return Ability.ZEPHYR_TBR; } else if (isAvailable(Ability.HOLO_ENEMY_REVERSAL)) { return Ability.HOLO_ENEMY_REVERSAL; + } else if (isInRange()) { + if (isAvailable(Ability.SOLARIS_INC)) { + return Ability.SOLARIS_INC; + } else if (isAvailable(Ability.SOLARIS_PLUS_INCINERATE_PLUS)) { + return Ability.SOLARIS_PLUS_INCINERATE_PLUS; + } } } @@ -226,6 +228,11 @@ private boolean shoulFocusDamage() { && target.getHealth().getHp() >= this.config.minHealthToUseDamage); } + private boolean isInRange() { + Lockable target = heroapi.getLocalTarget(); + return (target != null && target.isValid() && heroapi.distanceTo(target) < 650); + } + private boolean shoulFocusSpeed() { if (safety.state() == Escaping.ENEMY) { return true; diff --git a/src/main/java/com/deeme/tasks/Discord.java b/src/main/java/com/deeme/tasks/Discord.java index 446a56af..a1599591 100644 --- a/src/main/java/com/deeme/tasks/Discord.java +++ b/src/main/java/com/deeme/tasks/Discord.java @@ -161,7 +161,7 @@ private void sendStatistics() { best += "{" + " \"name\": \"Group size\","; if (main.guiManager.group.hasGroup()) { - best += " \"value\": \"" + main.guiManager.group.group.size + "\","; + best += " \"value\": \"" + main.guiManager.group.getMembers().size() + "\","; } else { best += " \"value\": \" No Group \","; } diff --git a/src/main/resources/plugin.json b/src/main/resources/plugin.json index 99b55449..eaea27d7 100644 --- a/src/main/resources/plugin.json +++ b/src/main/resources/plugin.json @@ -1,8 +1,8 @@ { "name": "DmPlugin", "author": "Dm94Dani", - "version": "1.7.26", - "minVersion": "1.13.17 beta 111", + "version": "1.7.27", + "minVersion": "1.120", "supportedVersion": "1.120", "basePackage": "com.deeme", "features": [ @@ -19,7 +19,6 @@ "com.deeme.tasks.ExternalChat", "com.deeme.behaviours.Others", "com.deeme.behaviours.defense.DefenseMode", - "com.deeme.behaviours.PVPLog", "com.deeme.behaviours.CustomEvents", "com.deeme.behaviours.StopButton", "com.deeme.behaviours.ProfileChanger", @@ -30,6 +29,6 @@ ], "donation": "https://www.paypal.com/donate/?business=JR2XWPSKLWN76&amount=5&no_recurring=0¤cy_code=EUR", "discord": "https://discord.gg/GPRTRRZJPw", - "download": "https://github.com/darkbot-reloaded/DmPlugin/releases/download/v1.7.26/DmPlugin.jar", + "download": "https://github.com/darkbot-reloaded/DmPlugin/releases/download/v1.7.27/DmPlugin.jar", "update": "https://raw.githubusercontent.com/darkbot-reloaded/DmPlugin/master/src/main/resources/plugin.json" }