Add 2 new variables in ChallengesAddon:

- economyProvided that indicate if there exist any EconomyPlugin.
- levelProvided that indicate if level addon is enabled.
This commit is contained in:
BONNe 2019-01-23 21:34:40 +02:00
parent d3bf5a157f
commit c3b87da88e
1 changed files with 39 additions and 1 deletions

View File

@ -28,6 +28,15 @@ public class ChallengesAddon extends Addon {
private boolean hooked; private boolean hooked;
/**
* This indicate if economy plugin exists.
*/
private boolean economyProvided;
/**
* This indicate if level addon exists.
*/
private boolean levelProvided;
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Section: Constants // Section: Constants
@ -93,10 +102,19 @@ public class ChallengesAddon extends Addon {
if (this.hooked) { if (this.hooked) {
// Try to find Level addon and if it does not exist, display a warning // 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.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 // Register the reset listener
this.registerListener(new ResetListener(this)); this.registerListener(new ResetListener(this));
// Register the autosave listener. // Register the autosave listener.
@ -185,4 +203,24 @@ public class ChallengesAddon extends Addon {
{ {
return this.settings; return this.settings;
} }
/**
*
* @return economyProvided variable.
*/
public boolean isEconomyProvided()
{
return economyProvided;
}
/**
*
* @return levelProvided variable.
*/
public boolean isLevelProvided()
{
return levelProvided;
}
} }