Skip to content

Commit

Permalink
Fixes issue with Level not being referenced correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Nov 12, 2018
1 parent c70f5cf commit 1e07223
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 35 deletions.
31 changes: 0 additions & 31 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
14 changes: 12 additions & 2 deletions src/main/java/bentobox/addon/challenges/ChallengesAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -41,13 +42,14 @@ public void onEnable() {
// 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 -> {
Expand All @@ -57,10 +59,18 @@ public void onEnable() {
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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private ChallengeResult checkInventory() {

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();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/addon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: ${version}

authors: tastybento

softdepend: AcidIsland, BSkyBlock
softdepend: AcidIsland, BSkyBlock, Level

permissions:
bskyblock.challenges:
Expand Down

0 comments on commit 1e07223

Please sign in to comment.