mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-23 08:31:34 +01:00
Provided better documentation around when flags should be declared.
Protects against null worlds. Related to https://github.com/BentoBoxWorld/AcidIsland/issues/53
This commit is contained in:
parent
6bbe9a3f2a
commit
38248bad29
@ -39,7 +39,8 @@ public abstract class GameModeAddon extends Addon {
|
||||
|
||||
/**
|
||||
* Make the worlds for this GameMode in this method. BentoBox will call it
|
||||
* after onLoad() and before onEnable().
|
||||
* after onLoad() and before onEnable(). Do not register flags in this method.
|
||||
* They ,ust be registered afterwards in onEnable()
|
||||
* {@link #islandWorld} must be created and assigned,
|
||||
* {@link #netherWorld} and {@link #endWorld} are optional and may be null.
|
||||
*/
|
||||
|
@ -155,11 +155,16 @@ public class Flag implements Comparable<Flag> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the status of this flag for locations outside of island spaces for a specific world
|
||||
* Set the status of this flag for locations outside of island spaces for a specific world.
|
||||
* World must exist and be registered before this method can be called.
|
||||
* @param defaultSetting - true means it is allowed. false means it is not allowed
|
||||
*/
|
||||
public void setDefaultSetting(World world, boolean defaultSetting) {
|
||||
WorldSettings ws = BentoBox.getInstance().getIWM().getWorldSettings(world);
|
||||
if (ws == null ) {
|
||||
BentoBox.getInstance().logError("Attempt to set default world setting for unregistered world. Register flags in onEnable.");
|
||||
return;
|
||||
}
|
||||
ws.getWorldFlags().put(getID(), defaultSetting);
|
||||
// Save config file
|
||||
BentoBox.getInstance().getIWM().getAddon(world).ifPresent(GameModeAddon::saveWorldSettings);
|
||||
|
Loading…
Reference in New Issue
Block a user