Fix issue where seed worlds lost generators with Multiverse on restart
This commit is contained in:
parent
b2f5a441e5
commit
1ef55a2b1e
|
@ -32,16 +32,24 @@ public class Panel implements HeadRequester, InventoryHolder {
|
|||
private World world;
|
||||
|
||||
/**
|
||||
* Various types of Panel that can be created.
|
||||
* Various types of Panels that can be created that use InventoryTypes.
|
||||
* <br>
|
||||
* The current list of inventories that cannot be created are:<br>
|
||||
* <blockquote>
|
||||
* {@link Type#INVENTORY}, {@link Type#HOPPER} and
|
||||
* {@link Type#DROPPER}
|
||||
* </blockquote>
|
||||
*
|
||||
* These relate to the Bukkit inventories with INVENTORY being the standard CHEST inventory.
|
||||
* See {@link org.bukkit.event.inventory.InventoryType}.
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public enum Type {
|
||||
INVENTORY,
|
||||
HOPPER,
|
||||
DROPPER
|
||||
INVENTORY, HOPPER, DROPPER
|
||||
}
|
||||
|
||||
public Panel() {}
|
||||
public Panel() {
|
||||
}
|
||||
|
||||
public Panel(String name, Map<Integer, PanelItem> items, int size, User user, PanelListener listener) {
|
||||
this(name, items, size, user, listener, Type.INVENTORY);
|
||||
|
@ -65,28 +73,27 @@ public class Panel implements HeadRequester, InventoryHolder {
|
|||
pb.getUser(), pb.getListener(), pb.getPanelType());
|
||||
}
|
||||
|
||||
protected void makePanel(String name, Map<Integer, PanelItem> items, int size, User user,
|
||||
PanelListener listener) {
|
||||
protected void makePanel(String name, Map<Integer, PanelItem> items, int size, User user, PanelListener listener) {
|
||||
this.makePanel(name, items, size, user, listener, Type.INVENTORY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.0
|
||||
*/
|
||||
protected void makePanel(String name, Map<Integer, PanelItem> items, int size, User user,
|
||||
PanelListener listener, Type type) {
|
||||
protected void makePanel(String name, Map<Integer, PanelItem> items, int size, User user, PanelListener listener,
|
||||
Type type) {
|
||||
this.name = name;
|
||||
this.items = items;
|
||||
|
||||
// Create panel
|
||||
switch (type) {
|
||||
case INVENTORY -> inventory = Bukkit.createInventory(null, fixSize(size), name);
|
||||
case HOPPER -> inventory = Bukkit.createInventory(null, InventoryType.HOPPER, name);
|
||||
case DROPPER -> inventory = Bukkit.createInventory(null, InventoryType.DROPPER, name);
|
||||
case INVENTORY -> inventory = Bukkit.createInventory(null, fixSize(size), name);
|
||||
case HOPPER -> inventory = Bukkit.createInventory(null, InventoryType.HOPPER, name);
|
||||
case DROPPER -> inventory = Bukkit.createInventory(null, InventoryType.DROPPER, name);
|
||||
}
|
||||
|
||||
// Fill the inventory and return
|
||||
for (Map.Entry<Integer, PanelItem> en: items.entrySet()) {
|
||||
for (Map.Entry<Integer, PanelItem> en : items.entrySet()) {
|
||||
if (en.getKey() < 54) {
|
||||
inventory.setItem(en.getKey(), en.getValue().getItem());
|
||||
// Get player head async
|
||||
|
@ -97,11 +104,13 @@ public class Panel implements HeadRequester, InventoryHolder {
|
|||
}
|
||||
this.listener = listener;
|
||||
// If the listener is defined, then run setup
|
||||
if (listener != null) listener.setup();
|
||||
if (listener != null)
|
||||
listener.setup();
|
||||
|
||||
// If the user is defined, then open panel immediately
|
||||
this.user = user;
|
||||
if (user != null) this.open(user);
|
||||
if (user != null)
|
||||
this.open(user);
|
||||
}
|
||||
|
||||
private int fixSize(int size) {
|
||||
|
@ -113,7 +122,8 @@ public class Panel implements HeadRequester, InventoryHolder {
|
|||
// Make sure size is a multiple of 9 and is 54 max.
|
||||
size = size + 8;
|
||||
size -= (size % 9);
|
||||
if (size > 54) size = 54;
|
||||
if (size > 54)
|
||||
size = 54;
|
||||
} else {
|
||||
return 9;
|
||||
}
|
||||
|
@ -194,12 +204,10 @@ public class Panel implements HeadRequester, InventoryHolder {
|
|||
public void setHead(PanelItem item) {
|
||||
// Update the panel item
|
||||
// Find panel item index in items and replace it once more in inventory to update it.
|
||||
this.items.entrySet().stream().
|
||||
filter(entry -> entry.getValue() == item).
|
||||
mapToInt(Map.Entry::getKey).findFirst()
|
||||
.ifPresent(index ->
|
||||
// Update item inside inventory to change icon only if item is inside panel.
|
||||
this.inventory.setItem(index, item.getItem()));
|
||||
this.items.entrySet().stream().filter(entry -> entry.getValue() == item).mapToInt(Map.Entry::getKey).findFirst()
|
||||
.ifPresent(index ->
|
||||
// Update item inside inventory to change icon only if item is inside panel.
|
||||
this.inventory.setItem(index, item.getItem()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,5 +234,4 @@ public class Panel implements HeadRequester, InventoryHolder {
|
|||
this.world = world;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -32,8 +32,12 @@ public class MultiverseCoreHook extends Hook implements WorldManagementHook {
|
|||
public void registerWorld(World world, boolean islandWorld) {
|
||||
if (islandWorld) {
|
||||
// Only register generator if one is defined in the addon (is not null)
|
||||
String generator = BentoBox.getInstance().getIWM().getAddon(world).map(gm -> gm.getDefaultWorldGenerator(world.getName(), "") != null).orElse(false) ? " -g " + BentoBox.getInstance().getName() : "";
|
||||
String cmd1 = MULTIVERSE_IMPORT + world.getName() + " " + world.getEnvironment().name().toLowerCase(Locale.ENGLISH) + generator;
|
||||
String generator = BentoBox.getInstance().getIWM().getAddon(world)
|
||||
.map(gm -> gm.getDefaultWorldGenerator(world.getName(), "") != null).orElse(false)
|
||||
? " -g " + BentoBox.getInstance().getName()
|
||||
: "";
|
||||
String cmd1 = MULTIVERSE_IMPORT + world.getName() + " "
|
||||
+ world.getEnvironment().name().toLowerCase(Locale.ENGLISH) + generator;
|
||||
String cmd2 = MULTIVERSE_SET_GENERATOR + BentoBox.getInstance().getName() + " " + world.getName();
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd1);
|
||||
if (!generator.isEmpty()) {
|
||||
|
@ -42,7 +46,8 @@ public class MultiverseCoreHook extends Hook implements WorldManagementHook {
|
|||
}
|
||||
} else {
|
||||
// Set the generator to null - this will remove any previous registration
|
||||
String cmd1 = MULTIVERSE_IMPORT + world.getName() + " " + world.getEnvironment().name().toLowerCase(Locale.ENGLISH);
|
||||
String cmd1 = MULTIVERSE_IMPORT + world.getName() + " "
|
||||
+ world.getEnvironment().name().toLowerCase(Locale.ENGLISH);
|
||||
String cmd2 = MULTIVERSE_SET_GENERATOR + "null " + world.getName();
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd1);
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd2);
|
||||
|
|
|
@ -378,6 +378,8 @@ public class AddonsManager {
|
|||
World w = gameMode.getWorldSettings().isUseOwnGenerator() ? wc.createWorld()
|
||||
: wc.generator(world.getGenerator()).createWorld();
|
||||
w.setDifficulty(Difficulty.PEACEFUL);
|
||||
// Register seed world
|
||||
plugin.getIWM().addWorld(w, gameMode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -60,15 +60,27 @@ public class IslandWorldManager {
|
|||
public void registerWorldsToMultiverse(boolean reg) {
|
||||
gameModes.values().stream().distinct().forEach(gm -> {
|
||||
registerToWorldManagementPlugins(gm.getOverWorld(), true, reg);
|
||||
registerSeedWorld(gm.getOverWorld(), reg);
|
||||
if (gm.getWorldSettings().isNetherGenerate()) {
|
||||
registerToWorldManagementPlugins(gm.getNetherWorld(), gm.getWorldSettings().isNetherIslands(), reg);
|
||||
registerSeedWorld(gm.getNetherWorld(), reg);
|
||||
}
|
||||
if (gm.getWorldSettings().isEndGenerate()) {
|
||||
registerToWorldManagementPlugins(gm.getEndWorld(), gm.getWorldSettings().isEndIslands(), reg);
|
||||
registerSeedWorld(gm.getEndWorld(), reg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void registerSeedWorld(World world, boolean reg) {
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
World seed = Bukkit.getWorld(world.getName() + "/bentobox");
|
||||
if (seed != null) {
|
||||
registerToWorldManagementPlugins(seed, true, reg);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerToWorldManagementPlugins(@NonNull World world, boolean islandWorld, boolean reg) {
|
||||
if (plugin.getHooks() == null) {
|
||||
|
@ -86,7 +98,8 @@ public class IslandWorldManager {
|
|||
|
||||
}
|
||||
|
||||
private void runTask(WorldManagementHook worldManagementHook, @NonNull World world, boolean islandWorld, boolean reg) {
|
||||
private void runTask(WorldManagementHook worldManagementHook, @NonNull World world, boolean islandWorld,
|
||||
boolean reg) {
|
||||
if (reg) {
|
||||
worldManagementHook.registerWorld(world, islandWorld);
|
||||
} else {
|
||||
|
@ -112,8 +125,8 @@ public class IslandWorldManager {
|
|||
* @return true if in a world or false if not
|
||||
*/
|
||||
public boolean inWorld(@Nullable World world) {
|
||||
return world != null && gameModes.containsKey(world) &&
|
||||
(world.getEnvironment().equals(Environment.NORMAL) || isIslandNether(world) || isIslandEnd(world));
|
||||
return world != null && gameModes.containsKey(world)
|
||||
&& (world.getEnvironment().equals(Environment.NORMAL) || isIslandNether(world) || isIslandEnd(world));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,8 +142,7 @@ public class IslandWorldManager {
|
|||
* @return List of over worlds
|
||||
*/
|
||||
public List<World> getOverWorlds() {
|
||||
return gameModes.keySet().stream().filter(w -> w.getEnvironment().equals(Environment.NORMAL))
|
||||
.toList();
|
||||
return gameModes.keySet().stream().filter(w -> w.getEnvironment().equals(Environment.NORMAL)).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,9 +151,8 @@ public class IslandWorldManager {
|
|||
* @return Map of world names and associated GameModeAddon friendly name
|
||||
*/
|
||||
public Map<String, String> getOverWorldNames() {
|
||||
return gameModes.values().stream()
|
||||
.distinct()
|
||||
.collect(Collectors.toMap(a -> a.getOverWorld().getName(), a -> a.getWorldSettings().getFriendlyName()));
|
||||
return gameModes.values().stream().distinct().collect(
|
||||
Collectors.toMap(a -> a.getOverWorld().getName(), a -> a.getWorldSettings().getFriendlyName()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,7 +186,8 @@ public class IslandWorldManager {
|
|||
WorldSettings settings = gameMode.getWorldSettings();
|
||||
World world = gameMode.getOverWorld();
|
||||
if (world == null) {
|
||||
throw new NullPointerException("Gamemode overworld object is null for " + gameMode.getDescription().getName());
|
||||
throw new NullPointerException(
|
||||
"Gamemode overworld object is null for " + gameMode.getDescription().getName());
|
||||
}
|
||||
String friendlyName = settings.getFriendlyName().isEmpty() ? world.getName() : settings.getFriendlyName();
|
||||
// Add worlds to map
|
||||
|
@ -196,12 +208,10 @@ public class IslandWorldManager {
|
|||
}
|
||||
|
||||
// Set default island settings
|
||||
plugin.getFlagsManager().getFlags().stream().
|
||||
filter(f -> f.getType().equals(Flag.Type.PROTECTION)).
|
||||
forEach(f -> settings.getDefaultIslandFlagNames().putIfAbsent(f.getID(), f.getDefaultRank()));
|
||||
plugin.getFlagsManager().getFlags().stream().
|
||||
filter(f -> f.getType().equals(Flag.Type.SETTING)).
|
||||
forEach(f -> settings.getDefaultIslandSettingNames().putIfAbsent(f.getID(), f.getDefaultRank()));
|
||||
plugin.getFlagsManager().getFlags().stream().filter(f -> f.getType().equals(Flag.Type.PROTECTION))
|
||||
.forEach(f -> settings.getDefaultIslandFlagNames().putIfAbsent(f.getID(), f.getDefaultRank()));
|
||||
plugin.getFlagsManager().getFlags().stream().filter(f -> f.getType().equals(Flag.Type.SETTING))
|
||||
.forEach(f -> settings.getDefaultIslandSettingNames().putIfAbsent(f.getID(), f.getDefaultRank()));
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
// Set world difficulty
|
||||
|
@ -232,7 +242,8 @@ public class IslandWorldManager {
|
|||
*/
|
||||
@NonNull
|
||||
public WorldSettings getWorldSettings(@NonNull World world) {
|
||||
return Objects.requireNonNull(gameModes.get(world), "Attempt to get WorldSettings for non-game world " + world.getName()).getWorldSettings();
|
||||
return Objects.requireNonNull(gameModes.get(world),
|
||||
"Attempt to get WorldSettings for non-game world " + world.getName()).getWorldSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -328,7 +339,9 @@ public class IslandWorldManager {
|
|||
* @return the worldName
|
||||
*/
|
||||
public String getWorldName(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getWorldName().toLowerCase(Locale.ENGLISH) : world.getName();
|
||||
return gameModes.containsKey(world)
|
||||
? gameModes.get(world).getWorldSettings().getWorldName().toLowerCase(Locale.ENGLISH)
|
||||
: world.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -366,7 +379,8 @@ public class IslandWorldManager {
|
|||
* @return true if world is a known and valid nether world
|
||||
*/
|
||||
public boolean isNether(@Nullable World world) {
|
||||
return world != null && (world.getEnvironment().equals(Environment.NETHER) && gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isNetherGenerate());
|
||||
return world != null && (world.getEnvironment().equals(Environment.NETHER) && gameModes.containsKey(world)
|
||||
&& gameModes.get(world).getWorldSettings().isNetherGenerate());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -376,7 +390,8 @@ public class IslandWorldManager {
|
|||
* @return true if world is a known and valid nether world
|
||||
*/
|
||||
public boolean isIslandNether(@Nullable World world) {
|
||||
return world != null && (world.getEnvironment().equals(Environment.NETHER) && gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isNetherGenerate()
|
||||
return world != null && (world.getEnvironment().equals(Environment.NETHER) && gameModes.containsKey(world)
|
||||
&& gameModes.get(world).getWorldSettings().isNetherGenerate()
|
||||
&& gameModes.get(world).getWorldSettings().isNetherIslands());
|
||||
}
|
||||
|
||||
|
@ -387,7 +402,8 @@ public class IslandWorldManager {
|
|||
* @return true if world is a known and valid end world
|
||||
*/
|
||||
public boolean isEnd(@Nullable World world) {
|
||||
return world != null && (world.getEnvironment().equals(Environment.THE_END) && gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isEndGenerate());
|
||||
return world != null && (world.getEnvironment().equals(Environment.THE_END) && gameModes.containsKey(world)
|
||||
&& gameModes.get(world).getWorldSettings().isEndGenerate());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -398,7 +414,8 @@ public class IslandWorldManager {
|
|||
* @return true if world is a known and valid nether world
|
||||
*/
|
||||
public boolean isIslandEnd(@Nullable World world) {
|
||||
return world != null && (world.getEnvironment().equals(Environment.THE_END) && gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isEndGenerate()
|
||||
return world != null && (world.getEnvironment().equals(Environment.THE_END) && gameModes.containsKey(world)
|
||||
&& gameModes.get(world).getWorldSettings().isEndGenerate()
|
||||
&& gameModes.get(world).getWorldSettings().isEndIslands());
|
||||
}
|
||||
|
||||
|
@ -431,7 +448,8 @@ public class IslandWorldManager {
|
|||
* @return true (default) if it can spawn or not
|
||||
*/
|
||||
public boolean isDragonSpawn(@Nullable World world) {
|
||||
return world == null || (!gameModes.containsKey(world) || gameModes.get(world).getWorldSettings().isDragonSpawn());
|
||||
return world == null
|
||||
|| (!gameModes.containsKey(world) || gameModes.get(world).getWorldSettings().isDragonSpawn());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -439,7 +457,8 @@ public class IslandWorldManager {
|
|||
*/
|
||||
public String getFriendlyNames() {
|
||||
StringBuilder r = new StringBuilder();
|
||||
gameModes.values().stream().distinct().forEach(n -> r.append(n.getWorldSettings().getFriendlyName()).append(", "));
|
||||
gameModes.values().stream().distinct()
|
||||
.forEach(n -> r.append(n.getWorldSettings().getFriendlyName()).append(", "));
|
||||
if (r.length() > 0) {
|
||||
r.setLength(r.length() - 2);
|
||||
}
|
||||
|
@ -454,8 +473,9 @@ public class IslandWorldManager {
|
|||
*/
|
||||
@Nullable
|
||||
public World getIslandWorld(String friendlyWorldName) {
|
||||
return gameModes.entrySet().stream().filter(e -> e.getValue().getWorldSettings().getFriendlyName().equalsIgnoreCase(friendlyWorldName)).findFirst()
|
||||
.map(Map.Entry::getKey).orElse(null);
|
||||
return gameModes.entrySet().stream()
|
||||
.filter(e -> e.getValue().getWorldSettings().getFriendlyName().equalsIgnoreCase(friendlyWorldName))
|
||||
.findFirst().map(Map.Entry::getKey).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -505,9 +525,8 @@ public class IslandWorldManager {
|
|||
* @return Friendly name or world name if world is not a game world
|
||||
*/
|
||||
public String getFriendlyName(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ?
|
||||
gameModes.get(world).getWorldSettings().getFriendlyName() :
|
||||
world.getName();
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getFriendlyName()
|
||||
: world.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -528,7 +547,8 @@ public class IslandWorldManager {
|
|||
* @return invincible visitor settings or an empty list if world is not a game world
|
||||
*/
|
||||
public List<String> getIvSettings(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getIvSettings() : Collections.emptyList();
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getIvSettings()
|
||||
: Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -552,7 +572,8 @@ public class IslandWorldManager {
|
|||
* @return GameMode: SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR. Default is SURVIVAL if world is not a game world
|
||||
*/
|
||||
public GameMode getDefaultGameMode(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getDefaultGameMode() : GameMode.SURVIVAL;
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getDefaultGameMode()
|
||||
: GameMode.SURVIVAL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -562,7 +583,8 @@ public class IslandWorldManager {
|
|||
* @return - set of entity types
|
||||
*/
|
||||
public Set<EntityType> getRemoveMobsWhitelist(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getRemoveMobsWhitelist() : Collections.emptySet();
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getRemoveMobsWhitelist()
|
||||
: Collections.emptySet();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -625,7 +647,8 @@ public class IslandWorldManager {
|
|||
*/
|
||||
@NonNull
|
||||
public List<String> getOnJoinCommands(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getOnJoinCommands() : Collections.emptyList();
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getOnJoinCommands()
|
||||
: Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -688,7 +711,8 @@ public class IslandWorldManager {
|
|||
*/
|
||||
@NonNull
|
||||
public List<String> getOnLeaveCommands(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getOnLeaveCommands() : Collections.emptyList();
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getOnLeaveCommands()
|
||||
: Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -700,7 +724,8 @@ public class IslandWorldManager {
|
|||
*/
|
||||
@NonNull
|
||||
public List<String> getOnRespawnCommands(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getOnRespawnCommands() : Collections.emptyList();
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getOnRespawnCommands()
|
||||
: Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -729,11 +754,10 @@ public class IslandWorldManager {
|
|||
* @param world - world
|
||||
* @return default rank settings for new islands.
|
||||
*/
|
||||
public Map<Flag, Integer> getDefaultIslandFlags(@NonNull World world)
|
||||
{
|
||||
return this.gameModes.containsKey(world) ?
|
||||
this.convertToFlags(this.gameModes.get(world).getWorldSettings().getDefaultIslandFlagNames()) :
|
||||
Collections.emptyMap();
|
||||
public Map<Flag, Integer> getDefaultIslandFlags(@NonNull World world) {
|
||||
return this.gameModes.containsKey(world)
|
||||
? this.convertToFlags(this.gameModes.get(world).getWorldSettings().getDefaultIslandFlagNames())
|
||||
: Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -742,7 +766,8 @@ public class IslandWorldManager {
|
|||
* @return list of hidden flags
|
||||
*/
|
||||
public List<String> getHiddenFlags(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getHiddenFlags() : Collections.emptyList();
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getHiddenFlags()
|
||||
: Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -751,11 +776,10 @@ public class IslandWorldManager {
|
|||
* @param world - world
|
||||
* @return default settings for new islands
|
||||
*/
|
||||
public Map<Flag, Integer> getDefaultIslandSettings(@NonNull World world)
|
||||
{
|
||||
return this.gameModes.containsKey(world) ?
|
||||
this.convertToFlags(this.gameModes.get(world).getWorldSettings().getDefaultIslandSettingNames()) :
|
||||
Collections.emptyMap();
|
||||
public Map<Flag, Integer> getDefaultIslandSettings(@NonNull World world) {
|
||||
return this.gameModes.containsKey(world)
|
||||
? this.convertToFlags(this.gameModes.get(world).getWorldSettings().getDefaultIslandSettingNames())
|
||||
: Collections.emptyMap();
|
||||
}
|
||||
|
||||
public boolean isUseOwnGenerator(@NonNull World world) {
|
||||
|
@ -781,7 +805,8 @@ public class IslandWorldManager {
|
|||
* @return the visitorbannedcommands
|
||||
*/
|
||||
public List<String> getVisitorBannedCommands(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getVisitorBannedCommands() : Collections.emptyList();
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getVisitorBannedCommands()
|
||||
: Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -789,7 +814,8 @@ public class IslandWorldManager {
|
|||
* @return the fallingbannedcommands
|
||||
*/
|
||||
public List<String> getFallingBannedCommands(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getFallingBannedCommands() : Collections.emptyList();
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getFallingBannedCommands()
|
||||
: Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -807,7 +833,8 @@ public class IslandWorldManager {
|
|||
* @return list
|
||||
*/
|
||||
public List<String> getGeoLimitSettings(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getGeoLimitSettings() : Collections.emptyList();
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getGeoLimitSettings()
|
||||
: Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -817,7 +844,8 @@ public class IslandWorldManager {
|
|||
* @since 1.12.0
|
||||
*/
|
||||
public List<String> getMobLimitSettings(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getMobLimitSettings() : Collections.emptyList();
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getMobLimitSettings()
|
||||
: Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -829,7 +857,6 @@ public class IslandWorldManager {
|
|||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getResetLimit() : -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the time stamp for when all player resets were zeroed
|
||||
* @param world - world
|
||||
|
@ -843,7 +870,8 @@ public class IslandWorldManager {
|
|||
* @param world - world
|
||||
*/
|
||||
public void setResetEpoch(@NonNull World world) {
|
||||
if (gameModes.containsKey(world)) gameModes.get(world).getWorldSettings().setResetEpoch(System.currentTimeMillis());
|
||||
if (gameModes.containsKey(world))
|
||||
gameModes.get(world).getWorldSettings().setResetEpoch(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -905,7 +933,8 @@ public class IslandWorldManager {
|
|||
* @since 1.9.0
|
||||
*/
|
||||
public boolean isCreateIslandOnFirstLoginEnabled(@NonNull World world) {
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isCreateIslandOnFirstLoginEnabled();
|
||||
return gameModes.containsKey(world)
|
||||
&& gameModes.get(world).getWorldSettings().isCreateIslandOnFirstLoginEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -915,7 +944,8 @@ public class IslandWorldManager {
|
|||
* @since 1.9.0
|
||||
*/
|
||||
public int getCreateIslandOnFirstLoginDelay(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getCreateIslandOnFirstLoginDelay() : 0;
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().getCreateIslandOnFirstLoginDelay()
|
||||
: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -925,7 +955,8 @@ public class IslandWorldManager {
|
|||
* @since 1.9.0
|
||||
*/
|
||||
public boolean isCreateIslandOnFirstLoginAbortOnLogout(@NonNull World world) {
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isCreateIslandOnFirstLoginAbortOnLogout();
|
||||
return gameModes.containsKey(world)
|
||||
&& gameModes.get(world).getWorldSettings().isCreateIslandOnFirstLoginAbortOnLogout();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -953,21 +984,20 @@ public class IslandWorldManager {
|
|||
* @since 1.10.0
|
||||
*/
|
||||
public boolean isTeleportPlayerToIslandUponIslandCreation(@NonNull World world) {
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isTeleportPlayerToIslandUponIslandCreation();
|
||||
return gameModes.containsKey(world)
|
||||
&& gameModes.get(world).getWorldSettings().isTeleportPlayerToIslandUponIslandCreation();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method migrates Map of String, Integer to Map of Flag, Integer.
|
||||
* @param flagNamesMap Map that contains flag names to their values.
|
||||
* @return Flag objects to their values.
|
||||
* @since 1.21
|
||||
*/
|
||||
private Map<Flag, Integer> convertToFlags(Map<String, Integer> flagNamesMap)
|
||||
{
|
||||
private Map<Flag, Integer> convertToFlags(Map<String, Integer> flagNamesMap) {
|
||||
Map<Flag, Integer> flagMap = new HashMap<>();
|
||||
flagNamesMap.forEach((key, value) ->
|
||||
this.plugin.getFlagsManager().getFlag(key).ifPresent(flag -> flagMap.put(flag, value)));
|
||||
flagNamesMap.forEach(
|
||||
(key, value) -> this.plugin.getFlagsManager().getFlag(key).ifPresent(flag -> flagMap.put(flag, value)));
|
||||
return flagMap;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue