Fixes issue with Level not being referenced correctly.

https://github.com/BentoBoxWorld/addon-challenges/issues/26
This commit is contained in:
tastybento 2018-11-12 10:24:18 -08:00
parent c70f5cf2f3
commit 1e07223d61
4 changed files with 14 additions and 35 deletions

31
pom.xml
View File

@ -63,11 +63,6 @@
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
@ -209,30 +204,4 @@
</plugins>
</build>
<profiles>
<profile>
<id>sonar</id>
<properties>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>tastybento-github</sonar.organization>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.1.1168</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -17,6 +17,7 @@ public class ChallengesAddon extends Addon {
private ChallengesManager challengesManager;
private String permissionPrefix = "addon";
private FreshSqueezedChallenges importManager;
private boolean hooked;
@Override
public void onLoad() {
@ -41,13 +42,14 @@ public class ChallengesAddon extends Addon {
// Register commands - run one tick later to allow all addons to load
// AcidIsland hook in
getServer().getScheduler().runTask(getPlugin(), () -> {
this.getPlugin().getAddonsManager().getAddonByName("AcidIsland").ifPresent(a -> {
CompositeCommand acidIslandCmd = getPlugin().getCommandsManager().getCommand("ai");
if (acidIslandCmd != null) {
new ChallengesCommand(this, acidIslandCmd);
CompositeCommand acidCmd = getPlugin().getCommandsManager().getCommand("acid");
new Challenges(this, acidCmd);
hooked = true;
}
});
this.getPlugin().getAddonsManager().getAddonByName("BSkyBlock").ifPresent(a -> {
@ -57,10 +59,18 @@ public class ChallengesAddon extends Addon {
new ChallengesCommand(this, bsbIslandCmd);
CompositeCommand bsbAdminCmd = getPlugin().getCommandsManager().getCommand("bsbadmin");
new Challenges(this, bsbAdminCmd);
hooked = true;
}
});
});
// If the add-on never hooks in, then it is useless
if (!hooked) {
logError("Challenges could not hook into AcidIsland or BSkyBlock so will not do anything!");
}
// Try to find Level addon and if it does not exist, display a warning
if (!getAddonByName("Level").isPresent()) {
logWarning("Level add-on not found so level challenges will not work!");
}
// Done
}

View File

@ -151,7 +151,7 @@ public class TryToComplete {
private ChallengeResult checkLevel() {
// Check if the level addon is installed or not
long level = addon.getAddonByName("BentoBox-Level")
long level = addon.getAddonByName("Level")
.map(l -> ((Level)l).getIslandLevel(world, user.getUniqueId())).orElse(0L);
if (level >= challenge.getReqIslandlevel()) {
return new ChallengeResult().setMeetsRequirements();

View File

@ -4,7 +4,7 @@ version: ${version}
authors: tastybento
softdepend: AcidIsland, BSkyBlock
softdepend: AcidIsland, BSkyBlock, Level
permissions:
bskyblock.challenges: