forked from dm94/DmPlugin
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dm94:master' into master
- Loading branch information
Showing
27 changed files
with
118 additions
and
459 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
src/main/java/com/deeme/behaviours/bestrocket/SupportedRockets.java
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
src/main/java/com/deeme/behaviours/urgentdetector/UrgentDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/deeme/behaviours/urgentdetector/UrgentDetectorConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ""; | ||
} |
Oops, something went wrong.