Enable main player and admin command declaration

See https://github.com/BentoBoxWorld/BentoBox/issues/448
This commit is contained in:
tastybento 2019-01-15 19:33:53 -08:00
parent 3a9e969a86
commit 7d08a0db5a
2 changed files with 35 additions and 0 deletions

View File

@ -1,8 +1,11 @@
package world.bentobox.bentobox.api.addons; package world.bentobox.bentobox.api.addons;
import java.util.Optional;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.util.Util; import world.bentobox.bentobox.util.Util;
@ -17,6 +20,14 @@ public abstract class GameModeAddon extends Addon {
protected World islandWorld; protected World islandWorld;
protected World netherWorld; protected World netherWorld;
protected World endWorld; protected World endWorld;
/**
* Main player command. Addons can use this hook to into this command.
*/
protected CompositeCommand playerCommand;
/**
* Main admin command. Addons can use this hook to into this command.
*/
protected CompositeCommand adminCommand;
/** /**
* Make the worlds for this GameMode in this method. BentoBox will call it * Make the worlds for this GameMode in this method. BentoBox will call it
@ -61,5 +72,17 @@ public abstract class GameModeAddon extends Addon {
return endWorld; return endWorld;
} }
/**
* @return the main player command for this Game Mode Addon
*/
public Optional<CompositeCommand> getPlayerCommand() {
return Optional.ofNullable(playerCommand);
}
/**
* @return the main admin command for this Game Mode Addon
*/
public Optional<CompositeCommand> getAdminCommand() {
return Optional.ofNullable(adminCommand);
}
} }

View File

@ -239,6 +239,18 @@ public class AddonsManager {
return addons; return addons;
} }
/**
* @return List of enabled game mode addons
* @since 1.1
*/
public List<GameModeAddon> getGameModeAddons() {
return addons.stream()
.filter(addon -> addon.getState().equals(Addon.State.ENABLED))
.filter(GameModeAddon.class::isInstance)
.map(GameModeAddon.class::cast)
.collect(Collectors.toList());
}
/** /**
* Gets the list of Addons that are loaded. * Gets the list of Addons that are loaded.
* @return list of loaded Addons. * @return list of loaded Addons.