Skip to content

Commit

Permalink
Add 2 new variables in ChallengesAddon:
Browse files Browse the repository at this point in the history
- economyProvided that indicate if there exist any EconomyPlugin.
- levelProvided that indicate if level addon is enabled.
  • Loading branch information
BONNe committed Jan 23, 2019
1 parent d3bf5a1 commit c3b87da
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/main/java/world/bentobox/challenges/ChallengesAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public class ChallengesAddon extends Addon {

private boolean hooked;

/**
* This indicate if economy plugin exists.
*/
private boolean economyProvided;

/**
* This indicate if level addon exists.
*/
private boolean levelProvided;

// ---------------------------------------------------------------------
// Section: Constants
Expand Down Expand Up @@ -93,10 +102,19 @@ public void onEnable() {

if (this.hooked) {
// Try to find Level addon and if it does not exist, display a warning
if (!this.getAddonByName("Level").isPresent()) {

this.levelProvided = this.getAddonByName("Level").isPresent();

if (!this.levelProvided) {
this.logWarning("Level add-on not found so level challenges will not work!");
}

this.economyProvided = this.getPlugin().getVault().isPresent() && this.getPlugin().getVault().get().hook();

if (!this.economyProvided) {
this.logWarning("Economy plugin not found so money options will not work!");
}

// Register the reset listener
this.registerListener(new ResetListener(this));
// Register the autosave listener.
Expand Down Expand Up @@ -185,4 +203,24 @@ public Settings getChallengesSettings()
{
return this.settings;
}


/**
*
* @return economyProvided variable.
*/
public boolean isEconomyProvided()
{
return economyProvided;
}


/**
*
* @return levelProvided variable.
*/
public boolean isLevelProvided()
{
return levelProvided;
}
}

0 comments on commit c3b87da

Please sign in to comment.