mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-30 22:53:39 +01:00
Merge pull request #472 from BentoBoxWorld/gamemode-enhancements
Enable main player and admin command declaration
This commit is contained in:
commit
3810ac3524
@ -1,22 +1,41 @@
|
||||
package world.bentobox.bentobox.api.addons;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
/**
|
||||
* Defines the addon as a game mode.
|
||||
* A game mode creates worlds, registers world settings and has schems in a jar folder.
|
||||
* @author tastybento, Postlovitch
|
||||
*
|
||||
* @author tastybento, Poslovitch
|
||||
*/
|
||||
public abstract class GameModeAddon extends Addon {
|
||||
|
||||
protected World islandWorld;
|
||||
@Nullable
|
||||
protected World netherWorld;
|
||||
@Nullable
|
||||
protected World endWorld;
|
||||
/**
|
||||
* Main player command. Addons can use this hook to into this command.
|
||||
* @since 1.1
|
||||
*/
|
||||
@Nullable
|
||||
protected CompositeCommand playerCommand;
|
||||
/**
|
||||
* Main admin command. Addons can use this hook to into this command.
|
||||
* @since 1.1
|
||||
*/
|
||||
@Nullable
|
||||
protected CompositeCommand adminCommand;
|
||||
|
||||
/**
|
||||
* Make the worlds for this GameMode in this method. BentoBox will call it
|
||||
@ -50,6 +69,7 @@ public abstract class GameModeAddon extends Addon {
|
||||
/**
|
||||
* @return nether world, or null if it does not exist
|
||||
*/
|
||||
@Nullable
|
||||
public World getNetherWorld() {
|
||||
return netherWorld;
|
||||
}
|
||||
@ -57,9 +77,26 @@ public abstract class GameModeAddon extends Addon {
|
||||
/**
|
||||
* @return end world, or null if it does not exist
|
||||
*/
|
||||
@Nullable
|
||||
public World getEndWorld() {
|
||||
return endWorld;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the main player command for this Game Mode Addon
|
||||
* @since 1.1
|
||||
*/
|
||||
@NonNull
|
||||
public Optional<CompositeCommand> getPlayerCommand() {
|
||||
return Optional.ofNullable(playerCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the main admin command for this Game Mode Addon
|
||||
* @since 1.1
|
||||
*/
|
||||
@NonNull
|
||||
public Optional<CompositeCommand> getAdminCommand() {
|
||||
return Optional.ofNullable(adminCommand);
|
||||
}
|
||||
}
|
||||
|
@ -239,6 +239,17 @@ public class AddonsManager {
|
||||
return addons;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of enabled game mode addons
|
||||
* @since 1.1
|
||||
*/
|
||||
public List<GameModeAddon> getGameModeAddons() {
|
||||
return getEnabledAddons().stream()
|
||||
.filter(GameModeAddon.class::isInstance)
|
||||
.map(GameModeAddon.class::cast)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of Addons that are loaded.
|
||||
* @return list of loaded Addons.
|
||||
|
Loading…
Reference in New Issue
Block a user