Skip to content

Commit

Permalink
Merge branch 'dm94:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dm94 authored Sep 1, 2024
2 parents 1135c4f + 23c9497 commit 056a887
Show file tree
Hide file tree
Showing 27 changed files with 118 additions and 459 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/reviewdog.yml

This file was deleted.

6 changes: 3 additions & 3 deletions src/main/java/com/deeme/behaviours/UrgentDetectorDummy.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import java.util.Arrays;

import com.deeme.behaviours.urgentdetector.UrgentDetector;
import com.deeme.types.VerifierChecker;
import com.deeme.types.backpage.Utils;
import com.deemeplus.behaviours.urgentdetector.UrgentDetector;
import com.github.manolo8.darkbot.utils.AuthAPI;

import eu.darkbot.api.PluginAPI;
import eu.darkbot.api.extensions.Feature;
import eu.darkbot.api.managers.AuthAPI;
import eu.darkbot.api.managers.ExtensionsAPI;

@Feature(name = "Urgent Detector [PLUS]", description = "Changes profile when it detects an urgent quest")
@Feature(name = "Urgent Detector [OLD]", description = "Use the other Urgent Detector")
public class UrgentDetectorDummy extends UrgentDetector {
public UrgentDetectorDummy(PluginAPI api) throws SecurityException {
super(api);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -15,11 +16,11 @@ public class BestRocketConfig {

@Option("best_rocket.rockets_to_use_npcs")
@Dropdown(multi = true)
public Set<SupportedRockets> rocketsToUseNPCs = EnumSet.noneOf(SupportedRockets.class);
public Set<Rocket> rocketsToUseNPCs = EnumSet.noneOf(Rocket.class);

@Option("best_rocket.rockets_to_use_players")
@Dropdown(multi = true)
public Set<SupportedRockets> rocketsToUsePlayers = EnumSet.allOf(SupportedRockets.class);
public Set<Rocket> rocketsToUsePlayers = EnumSet.allOf(Rocket.class);

@Option("general.tick_stopped")
public boolean tickStopped = false;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.deeme.behaviours.urgentdetector;

import java.util.Arrays;

import com.deeme.types.VerifierChecker;
import com.deeme.types.backpage.Utils;
import com.deemeplus.modules.temporal.UrgentQuestModule;
import com.github.manolo8.darkbot.core.objects.facades.DiminishQuestMediator;

import eu.darkbot.api.PluginAPI;
import eu.darkbot.api.extensions.Feature;
import eu.darkbot.api.extensions.FeatureInfo;
import eu.darkbot.api.managers.ExtensionsAPI;
import eu.darkbot.api.config.ConfigSetting;
import eu.darkbot.api.extensions.Behavior;
import eu.darkbot.api.extensions.Configurable;
import eu.darkbot.api.managers.AuthAPI;
import eu.darkbot.api.managers.BotAPI;
import eu.darkbot.api.managers.ConfigAPI;
import eu.darkbot.shared.modules.TemporalModule;

@Feature(name = "Urgent Detector", description = "Changes profile when it detects an urgent quest")
public class UrgentDetector implements Behavior, Configurable<UrgentDetectorConfig> {
private final PluginAPI api;
private final ConfigAPI configAPI;
private final BotAPI botApi;
private final DiminishQuestMediator diminishQuestMediator;

private UrgentDetectorConfig config;

private long nextCheck = 0;

public UrgentDetector(PluginAPI api) throws SecurityException {
if (!Arrays.equals(VerifierChecker.class.getSigners(), getClass().getSigners())) {
throw new SecurityException();
}

AuthAPI auth = api.requireAPI(AuthAPI.class);

VerifierChecker.requireAuthenticity(auth);

ExtensionsAPI extensionsAPI = api.requireAPI(ExtensionsAPI.class);
FeatureInfo<?> feature = extensionsAPI.getFeatureInfo(this.getClass());
Utils.discordCheck(feature, auth.getAuthId());
Utils.showDonateDialog(feature, auth.getAuthId());

this.api = api;
this.configAPI = api.requireAPI(ConfigAPI.class);
this.botApi = api.requireAPI(BotAPI.class);
this.diminishQuestMediator = api.requireInstance(DiminishQuestMediator.class);
}

@Override
public void setConfig(ConfigSetting<UrgentDetectorConfig> arg0) {
this.config = arg0.getValue();
}

@Override
public void onTickBehavior() {
if (this.nextCheck < System.currentTimeMillis()) {
this.nextCheck = System.currentTimeMillis() + (this.config.timeToCheck * 1000);

if (this.diminishQuestMediator.isWaitAccepting() || this.diminishQuestMediator.isAccepted()) {
if (this.config.takeQuest && this.diminishQuestMediator.isWaitAccepting()) {
enableTakeUrgentQuestModule();
} else {
changeProfile();
}
}
}
}

private void enableTakeUrgentQuestModule() {
if (!(this.botApi.getModule() instanceof TemporalModule)
&& this.botApi.getModule().getClass() != UrgentQuestModule.class) {
this.botApi.setModule(
new UrgentQuestModule(this.api, this.botApi, this.diminishQuestMediator));
}
}

private void changeProfile() {
this.configAPI.setConfigProfile(config.botProfile);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.deeme.behaviours.urgentdetector;

import eu.darkbot.api.config.annotations.Configuration;
import eu.darkbot.api.config.annotations.Dropdown;
import eu.darkbot.api.config.annotations.Option;
import eu.darkbot.shared.config.ProfileNames;
import eu.darkbot.api.config.annotations.Number;

@Configuration("urgent_detector")
public class UrgentDetectorConfig {
@Option("general.next_check_time")
@Number(max = 300, step = 1)
public int timeToCheck = 5;

@Option("urgent_detector.take_quest")
public boolean takeQuest = true;

@Option("urgent_detector.bot_profile")
@Dropdown(options = ProfileNames.class)
public String botProfile = "";
}
Loading

0 comments on commit 056a887

Please sign in to comment.