Skip to content

Commit

Permalink
Update To BentoBox 1.1
Browse files Browse the repository at this point in the history
Use new approach to hooking addons into game-mode.
  • Loading branch information
BONNe committed Jan 23, 2019
1 parent 53da2d6 commit ca32c53
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 53 deletions.
14 changes: 1 addition & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,7 @@
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>bskyblock</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>acidisland</artifactId>
<version>1.0</version>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
56 changes: 16 additions & 40 deletions src/main/java/world/bentobox/challenges/ChallengesAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.bukkit.Bukkit;

import world.bentobox.acidisland.AcidIsland;
import world.bentobox.bentobox.api.configuration.Config;
import world.bentobox.challenges.commands.ChallengesCommand;
import world.bentobox.challenges.commands.admin.Challenges;
Expand Down Expand Up @@ -75,45 +74,22 @@ public void onEnable() {
// Challenge import setup
this.importManager = new ChallengesImportManager(this);


// Integrate into AcidIsland.
if (this.settings.getDisabledGameModes().isEmpty() ||
!this.settings.getDisabledGameModes().contains("AcidIsland"))
{
this.getPlugin().getAddonsManager().getAddonByName("AcidIsland").ifPresent(
addon -> {
AcidIsland acidIsland = (AcidIsland) addon;

new Challenges(this,
this.getPlugin().getCommandsManager().getCommand(
acidIsland.getSettings().getAdminCommand()));

new ChallengesCommand(this,
this.getPlugin().getCommandsManager().getCommand(
acidIsland.getSettings().getIslandCommand()));

this.hooked = true;
});
}

// Integrate into BSkyBlock.
if (this.settings.getDisabledGameModes().isEmpty() ||
!this.settings.getDisabledGameModes().contains("BSkyBlock"))
{
this.getPlugin().getAddonsManager().getAddonByName("BSkyBlock").ifPresent(
addon -> {
// BSkyBlock skyBlock = (BSkyBlock) addon;
// SkyBlock addon cannot change commands ;(

new Challenges(this,
this.getPlugin().getCommandsManager().getCommand("bsbadmin"));

new ChallengesCommand(this,
this.getPlugin().getCommandsManager().getCommand("island"));

this.hooked = true;
});
}
this.getPlugin().getAddonsManager().getGameModeAddons().forEach(gameModeAddon -> {
if (!this.settings.getDisabledGameModes().contains(gameModeAddon.getDescription().getName()))
{
if (gameModeAddon.getPlayerCommand().isPresent())
{
new ChallengesCommand(this, gameModeAddon.getPlayerCommand().get());
this.hooked = true;
}

if (gameModeAddon.getAdminCommand().isPresent())
{
new Challenges(this, gameModeAddon.getAdminCommand().get());
this.hooked = true;
}
}
});

if (this.hooked) {
// Try to find Level addon and if it does not exist, display a warning
Expand Down

0 comments on commit ca32c53

Please sign in to comment.