mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-23 19:25:12 +01:00
Added defensive code to protect from null gamemode worlds
Related to https://github.com/BentoBoxWorld/addon-invSwitcher/issues/2
This commit is contained in:
parent
fd7e3e4154
commit
3f355f59d1
@ -139,11 +139,15 @@ public class IslandWorldManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a GameMode to island world manager
|
* Adds a GameMode to island world manager
|
||||||
* @param gameMode
|
* @param gameMode - game mode to add
|
||||||
|
* @throws NullPointerException - exception if the game mode overworld is null
|
||||||
*/
|
*/
|
||||||
public void addGameMode(@NonNull GameModeAddon gameMode) {
|
public void addGameMode(@NonNull GameModeAddon gameMode) throws NullPointerException {
|
||||||
WorldSettings settings = gameMode.getWorldSettings();
|
WorldSettings settings = gameMode.getWorldSettings();
|
||||||
World world = gameMode.getOverWorld();
|
World world = gameMode.getOverWorld();
|
||||||
|
if (world == null) {
|
||||||
|
throw new NullPointerException("Gamemode overworld object is null for " + gameMode.getDescription().getName());
|
||||||
|
}
|
||||||
String friendlyName = settings.getFriendlyName().isEmpty() ? world.getName() : settings.getFriendlyName();
|
String friendlyName = settings.getFriendlyName().isEmpty() ? world.getName() : settings.getFriendlyName();
|
||||||
// Add worlds to map
|
// Add worlds to map
|
||||||
gameModes.put(world, gameMode);
|
gameModes.put(world, gameMode);
|
||||||
|
Loading…
Reference in New Issue
Block a user