Skip to content

Commit ca2dedf

Browse files
committed
Fix bug where flags are not read correctly
1 parent 9c369da commit ca2dedf

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

multiworld-bukkit/src/main/java/com/dev7ex/multiworld/world/DefaultWorldConfiguration.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public void add(@NotNull final BukkitWorldHolder worldHolder) {
5050
super.getFileConfiguration().set(worldHolder.getName() + "." + WorldProperty.END_WORLD.getStoragePath(), worldHolder.getEndWorldName());
5151
super.getFileConfiguration().set(worldHolder.getName() + "." + WorldProperty.NETHER_WORLD.getStoragePath(), worldHolder.getNetherWorldName());
5252
super.getFileConfiguration().set(worldHolder.getName() + "." + WorldProperty.NORMAL_WORLD.getStoragePath(), worldHolder.getNormalWorldName());
53+
super.getFileConfiguration().set(worldHolder.getName() + "." + WorldProperty.RECEIVE_ACHIEVEMENTS.getStoragePath(), worldHolder.isReceiveAchievements());
5354
super.getFileConfiguration().set(worldHolder.getName() + "." + WorldProperty.WHITELIST.getStoragePath(), Collections.emptyList());
5455
super.getFileConfiguration().set(worldHolder.getName() + "." + WorldProperty.WHITELIST_ENABLED.getStoragePath(), worldHolder.isWhitelistEnabled());
5556
super.saveFile();
@@ -176,7 +177,7 @@ public void removeUnusableProperties(@NotNull final String worldName) {
176177

177178
for (final String property : super.getFileConfiguration().getSection(worldName).getKeys()) {
178179
if (WorldProperty.fromStoragePath(property).isPresent()) {
179-
continue;
180+
continue;
180181
}
181182
super.getFileConfiguration().set(worldName + "." + property, null);
182183
}
@@ -198,16 +199,29 @@ public void updateFlag(@NotNull final BukkitWorldHolder worldHolder, @NotNull fi
198199
public void write(@NotNull final BukkitWorldHolder worldHolder, @NotNull final ParsedMap<WorldProperty, Object> worldData) {
199200
for (final WorldProperty property : worldData.keySet()) {
200201
switch (property) {
201-
case CREATOR_NAME: case TYPE: case GAME_MODE: case DIFFICULTY: case END_WORLD: case NETHER_WORLD: case NORMAL_WORLD:
202+
case CREATOR_NAME:
203+
case TYPE:
204+
case GAME_MODE:
205+
case DIFFICULTY:
206+
case END_WORLD:
207+
case NETHER_WORLD:
208+
case NORMAL_WORLD:
202209
super.getFileConfiguration().set(worldHolder.getName() + "." + property.getStoragePath(), worldData.getString(property));
203210
break;
204211

205212
case CREATION_TIMESTAMP:
206213
super.getFileConfiguration().set(worldHolder.getName() + "." + property.getStoragePath(), worldData.getLong(property));
207214
break;
208215

209-
case PVP_ENABLED: case SPAWN_ANIMALS: case SPAWN_MONSTERS: case SPAWN_ENTITIES:
210-
case WHITELIST_ENABLED: case END_PORTAL_ACCESSIBLE: case NETHER_PORTAL_ACCESSIBLE: case LOAD_AUTO:
216+
case PVP_ENABLED:
217+
case SPAWN_ANIMALS:
218+
case SPAWN_MONSTERS:
219+
case SPAWN_ENTITIES:
220+
case WHITELIST_ENABLED:
221+
case END_PORTAL_ACCESSIBLE:
222+
case NETHER_PORTAL_ACCESSIBLE:
223+
case LOAD_AUTO:
224+
case RECEIVE_ACHIEVEMENTS:
211225
super.getFileConfiguration().set(worldHolder.getName() + "." + property.getStoragePath(), worldData.getBoolean(property));
212226
break;
213227

@@ -221,7 +235,7 @@ public void write(@NotNull final BukkitWorldHolder worldHolder, @NotNull final P
221235

222236
@Override
223237
public void write(@NotNull final BukkitWorldHolder worldHolder, @NotNull final WorldProperty property, @NotNull final Object value) {
224-
if (value instanceof Boolean booleanValue) {
238+
if (value instanceof final Boolean booleanValue) {
225239
super.getFileConfiguration().set(worldHolder.getName() + "." + property.getStoragePath(), booleanValue);
226240

227241
} else if ((value instanceof final String stringValue) && (stringValue.equalsIgnoreCase("true") || (stringValue.equalsIgnoreCase("false")))) {
@@ -251,6 +265,7 @@ public BukkitWorldHolder getWorldHolder(@NotNull final String name) {
251265
.setEndPortalAccessible(super.getFileConfiguration().getBoolean(name + "." + WorldProperty.END_PORTAL_ACCESSIBLE.getStoragePath(), true))
252266
.setNetherPortalAccessible(super.getFileConfiguration().getBoolean(name + "." + WorldProperty.NETHER_PORTAL_ACCESSIBLE.getStoragePath(), true))
253267
.setEndWorldName(super.getFileConfiguration().getString(name + "." + WorldProperty.END_WORLD.getStoragePath()))
268+
.setReceiveAchievements(super.getFileConfiguration().getBoolean(name + "." + WorldProperty.RECEIVE_ACHIEVEMENTS.getStoragePath()))
254269
.setNetherWorldName(super.getFileConfiguration().getString(name + "." + WorldProperty.NETHER_WORLD.getStoragePath()))
255270
.setNormalWorldName(super.getFileConfiguration().getString(name + "." + WorldProperty.NORMAL_WORLD.getStoragePath()))
256271
.setWhitelist(super.getFileConfiguration().getStringList(name + "." + WorldProperty.WHITELIST.getStoragePath()))

multiworld-bukkit/src/main/java/com/dev7ex/multiworld/world/DefaultWorldManager.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public void createWorld(@NotNull final String creatorName, @NotNull final String
173173
.setLoaded(false)
174174
.setSpawnAnimals(defaultProperties.getBoolean(WorldDefaultProperty.SPAWN_ANIMALS))
175175
.setSpawnMonsters(defaultProperties.getBoolean(WorldDefaultProperty.SPAWN_MONSTERS))
176+
.setSpawnEntities(defaultProperties.getBoolean(WorldDefaultProperty.SPAWN_ENTITIES))
176177
.setEndPortalAccessible(defaultProperties.getBoolean(WorldDefaultProperty.END_PORTAL_ACCESSIBLE))
177178
.setNetherPortalAccessible(defaultProperties.getBoolean(WorldDefaultProperty.NETHER_PORTAL_ACCESSIBLE))
178179
.setEndWorldName(defaultProperties.getString(WorldDefaultProperty.END_WORLD))
@@ -225,11 +226,13 @@ public void createWorld(@NotNull final String creatorName, @NotNull final String
225226
.setLoaded(false)
226227
.setSpawnAnimals(defaultProperties.getBoolean(WorldDefaultProperty.SPAWN_ANIMALS))
227228
.setSpawnMonsters(defaultProperties.getBoolean(WorldDefaultProperty.SPAWN_MONSTERS))
229+
.setSpawnEntities(defaultProperties.getBoolean(WorldDefaultProperty.SPAWN_ENTITIES))
228230
.setEndPortalAccessible(defaultProperties.getBoolean(WorldDefaultProperty.END_PORTAL_ACCESSIBLE))
229231
.setNetherPortalAccessible(defaultProperties.getBoolean(WorldDefaultProperty.NETHER_PORTAL_ACCESSIBLE))
230232
.setEndWorldName(defaultProperties.getString(WorldDefaultProperty.END_WORLD))
231233
.setNetherWorldName(defaultProperties.getString(WorldDefaultProperty.NETHER_WORLD))
232234
.setNormalWorldName(defaultProperties.getString(WorldDefaultProperty.NORMAL_WORLD))
235+
.setReceiveAchievements(defaultProperties.getBoolean(WorldDefaultProperty.RECEIVE_ACHIEVEMENTS))
233236
.setWhitelist(new ArrayList<>())
234237
.setWhitelistEnabled(defaultProperties.getBoolean(WorldDefaultProperty.WHITELIST_ENABLED))
235238
.build();
@@ -276,11 +279,13 @@ public void createWorld(@NotNull final String creatorName, @NotNull final String
276279
.setLoaded(false)
277280
.setSpawnAnimals(defaultProperties.getBoolean(WorldDefaultProperty.SPAWN_ANIMALS))
278281
.setSpawnMonsters(defaultProperties.getBoolean(WorldDefaultProperty.SPAWN_MONSTERS))
282+
.setSpawnEntities(defaultProperties.getBoolean(WorldDefaultProperty.SPAWN_ENTITIES))
279283
.setEndPortalAccessible(defaultProperties.getBoolean(WorldDefaultProperty.END_PORTAL_ACCESSIBLE))
280284
.setNetherPortalAccessible(defaultProperties.getBoolean(WorldDefaultProperty.NETHER_PORTAL_ACCESSIBLE))
281285
.setEndWorldName(defaultProperties.getString(WorldDefaultProperty.END_WORLD))
282286
.setNetherWorldName(defaultProperties.getString(WorldDefaultProperty.NETHER_WORLD))
283287
.setNormalWorldName(defaultProperties.getString(WorldDefaultProperty.NORMAL_WORLD))
288+
.setReceiveAchievements(defaultProperties.getBoolean(WorldDefaultProperty.RECEIVE_ACHIEVEMENTS))
284289
.setWhitelist(new ArrayList<>())
285290
.setWhitelistEnabled(defaultProperties.getBoolean(WorldDefaultProperty.WHITELIST_ENABLED))
286291
.build();
@@ -363,11 +368,13 @@ public void importWorld(@NotNull final String creatorName, @NotNull final String
363368
.setLoaded(false)
364369
.setSpawnAnimals(defaultProperties.getBoolean(WorldDefaultProperty.SPAWN_ANIMALS))
365370
.setSpawnMonsters(defaultProperties.getBoolean(WorldDefaultProperty.SPAWN_MONSTERS))
371+
.setSpawnEntities(defaultProperties.getBoolean(WorldDefaultProperty.SPAWN_ENTITIES))
366372
.setEndPortalAccessible(defaultProperties.getBoolean(WorldDefaultProperty.END_PORTAL_ACCESSIBLE))
367373
.setNetherPortalAccessible(defaultProperties.getBoolean(WorldDefaultProperty.NETHER_PORTAL_ACCESSIBLE))
368374
.setEndWorldName(defaultProperties.getString(WorldDefaultProperty.END_WORLD))
369375
.setNetherWorldName(defaultProperties.getString(WorldDefaultProperty.NETHER_WORLD))
370376
.setNormalWorldName(defaultProperties.getString(WorldDefaultProperty.NORMAL_WORLD))
377+
.setReceiveAchievements(defaultProperties.getBoolean(WorldDefaultProperty.RECEIVE_ACHIEVEMENTS))
371378
.setWhitelist(Collections.emptyList())
372379
.setWhitelistEnabled(defaultProperties.getBoolean(WorldDefaultProperty.WHITELIST_ENABLED))
373380
.build();
@@ -439,7 +446,10 @@ public void unloadWorld(@NotNull final String creatorName, @NotNull final String
439446
player.sendMessage(this.pluginConfiguration.getString("messages.commands.unload.chunk-teleport")
440447
.replaceAll("%prefix%", this.pluginConfiguration.getPrefix())
441448
.replaceAll("%world_name%", name));
442-
player.teleport(Bukkit.getWorld(MultiWorldPlugin.getInstance().getConfiguration().getString("settings.defaults.normal-world")).getSpawnLocation());
449+
player.teleport(Bukkit.getWorld(MultiWorldPlugin.getInstance()
450+
.getConfiguration()
451+
.getString("settings.defaults.normal-world"))
452+
.getSpawnLocation());
443453
}
444454

445455
commandSender.sendMessage(this.pluginConfiguration.getString("messages.commands.unload.chunk-starting")

0 commit comments

Comments
 (0)