Remove unsafe performance tweaks

This commit is contained in:
Daniel Saukel 2018-08-10 21:01:07 +02:00
parent 665a5cd1d4
commit 3c1a4d728b
22 changed files with 53 additions and 330 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.erethon</groupId> <groupId>de.erethon</groupId>
<artifactId>dungeonsxl</artifactId> <artifactId>dungeonsxl</artifactId>
<version>0.16.1-SNAPSHOT</version> <version>0.16.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>DungeonsXL</name> <name>DungeonsXL</name>
<url>https://dre2n.github.io</url> <url>https://dre2n.github.io</url>

View File

@ -132,7 +132,6 @@ public class DungeonsXL extends DREPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
mainConfig.setTweaksEnabled(false);
// Save // Save
saveData(); saveData();
messageConfig.save(); messageConfig.save();

View File

@ -101,7 +101,7 @@ public class AnnouncerStartGameTask extends BukkitRunnable {
} }
for (Player player : game.getPlayers()) { for (Player player : game.getPlayers()) {
DGamePlayer.create(player, game.getWorld()); new DGamePlayer(player, game.getWorld());
} }
announcer.endStartTask(); announcer.endStartTask();

View File

@ -97,7 +97,7 @@ public class CreateCommand extends DRECommand {
MessageUtil.log(plugin, DMessage.LOG_WORLD_GENERATION_FINISHED.getMessage()); MessageUtil.log(plugin, DMessage.LOG_WORLD_GENERATION_FINISHED.getMessage());
// Tp Player // Tp Player
DEditPlayer.create(player, editWorld); new DEditPlayer(player, editWorld);
} }
} }

View File

@ -86,7 +86,7 @@ public class EditCommand extends DRECommand {
return; return;
} }
DEditPlayer.create(player, editWorld); new DEditPlayer(player, editWorld);
} }
} }

View File

@ -86,7 +86,7 @@ public class EnterCommand extends DRECommand {
joining.sendMessage(DMessage.CMD_ENTER_SUCCESS.getMessage(joining.getName(), target.getName())); joining.sendMessage(DMessage.CMD_ENTER_SUCCESS.getMessage(joining.getName(), target.getName()));
for (Player player : joining.getPlayers().getOnlinePlayers()) { for (Player player : joining.getPlayers().getOnlinePlayers()) {
DGamePlayer.create(player, game.getWorld(), game.getType()); new DGamePlayer(player, game.getWorld(), game.getType());
} }
} }

View File

@ -70,17 +70,7 @@ public class ImportCommand extends DRECommand {
MessageUtil.log(plugin, DMessage.LOG_NEW_MAP.getMessage()); MessageUtil.log(plugin, DMessage.LOG_NEW_MAP.getMessage());
MessageUtil.log(plugin, DMessage.LOG_IMPORT_WORLD.getMessage()); MessageUtil.log(plugin, DMessage.LOG_IMPORT_WORLD.getMessage());
if (!plugin.getMainConfig().areTweaksEnabled()) { FileUtil.copyDir(source, target, "playerdata", "stats");
FileUtil.copyDir(source, target, "playerdata", "stats");
} else {
new BukkitRunnable() {
@Override
public void run() {
FileUtil.copyDir(source, target, "playerdata", "stats");
}
}.runTaskAsynchronously(plugin);
}
DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), args[1]); DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), args[1]);
if (world.getEnvironment() != Environment.NORMAL) { if (world.getEnvironment() != Environment.NORMAL) {

View File

@ -97,7 +97,7 @@ public class PlayCommand extends DRECommand {
} }
new Game(dGroup, gameWorld); new Game(dGroup, gameWorld);
for (Player groupPlayer : dGroup.getPlayers().getOnlinePlayers()) { for (Player groupPlayer : dGroup.getPlayers().getOnlinePlayers()) {
DGamePlayer.create(groupPlayer, dGroup.getGameWorld()); new DGamePlayer(groupPlayer, dGroup.getGameWorld());
} }
} }

View File

@ -50,7 +50,7 @@ public class SaveCommand extends DRECommand {
if (editWorld != null) { if (editWorld != null) {
BackupMode backupMode = mainConfig.getBackupMode(); BackupMode backupMode = mainConfig.getBackupMode();
if (backupMode == BackupMode.ON_SAVE || backupMode == BackupMode.ON_DISABLE_AND_SAVE) { if (backupMode == BackupMode.ON_SAVE || backupMode == BackupMode.ON_DISABLE_AND_SAVE) {
editWorld.getResource().backup(mainConfig.areTweaksEnabled()); editWorld.getResource().backup();
} }
editWorld.save(); editWorld.save();

View File

@ -92,7 +92,7 @@ public class TestCommand extends DRECommand {
return; return;
} }
Game game = new Game(new DGroup(player, dungeon), GameTypeDefault.TEST, instance); Game game = new Game(new DGroup(player, dungeon), GameTypeDefault.TEST, instance);
DGamePlayer.create(player, game.getWorld(), GameTypeDefault.TEST); new DGamePlayer(player, game.getWorld(), GameTypeDefault.TEST);
} }
} }

View File

@ -159,7 +159,6 @@ public enum DMessage implements Message {
GROUP_KICKED_PLAYER("Group_KickedPlayer", "&4&v1&6 kicked the player &4&v2&6 from the group &4&v3&6."), GROUP_KICKED_PLAYER("Group_KickedPlayer", "&4&v1&6 kicked the player &4&v2&6 from the group &4&v3&6."),
GROUP_PLAYER_JOINED("Group_PlayerJoined", "&6Player &4&v1&6 has joined the group!"), GROUP_PLAYER_JOINED("Group_PlayerJoined", "&6Player &4&v1&6 has joined the group!"),
GROUP_WAVE_FINISHED("Group_WaveFinished", "&6Your group finished wave no. &4&v1&6. The next one is going to start in &4&v2&6 seconds."), GROUP_WAVE_FINISHED("Group_WaveFinished", "&6Your group finished wave no. &4&v1&6. The next one is going to start in &4&v2&6 seconds."),
LOG_DISABLED_TWEAKS("Log_DisabledTweaks", "&4Disabled performance tweaks because there is no support for this server software."),
LOG_ERROR_DUNGEON_SETUP("Log_Error_DungeonSetup", "&4The setup of dungeon &6&v1&4 is incorrect. See https://github.com/DRE2N/DungeonsXL/wiki/dungeon-configuration for reference."), LOG_ERROR_DUNGEON_SETUP("Log_Error_DungeonSetup", "&4The setup of dungeon &6&v1&4 is incorrect. See https://github.com/DRE2N/DungeonsXL/wiki/dungeon-configuration for reference."),
LOG_ERROR_MOB_ENCHANTMENT("Log_Error_MobEnchantment", "&4An error occurred while loading mob.yml: Enchantment &6&v1&4 doesn't exist!"), LOG_ERROR_MOB_ENCHANTMENT("Log_Error_MobEnchantment", "&4An error occurred while loading mob.yml: Enchantment &6&v1&4 doesn't exist!"),
LOG_ERROR_MOBTYPE("Log_Error_MobType", "&4Error at loading mob.yml: Mob &6&v1&4 doesn't exist!"), LOG_ERROR_MOBTYPE("Log_Error_MobType", "&4Error at loading mob.yml: Mob &6&v1&4 doesn't exist!"),

View File

@ -94,7 +94,6 @@ public class MainConfig extends DREConfig {
/* Performance */ /* Performance */
private int maxInstances = 10; private int maxInstances = 10;
private boolean tweaksEnabled = false;
/* Secure Mode */ /* Secure Mode */
private boolean secureModeEnabled = false; private boolean secureModeEnabled = false;
@ -346,20 +345,6 @@ public class MainConfig extends DREConfig {
this.maxInstances = maxInstances; this.maxInstances = maxInstances;
} }
/**
* @return if the performance tweaks are enabled
*/
public boolean areTweaksEnabled() {
return tweaksEnabled;
}
/**
* @param enabled if the performance tweaks are enabled
*/
public void setTweaksEnabled(boolean enabled) {
tweaksEnabled = enabled;
}
/** /**
* @return if the secure mode is enabled * @return if the secure mode is enabled
*/ */
@ -526,10 +511,6 @@ public class MainConfig extends DREConfig {
config.set("maxInstances", maxInstances); config.set("maxInstances", maxInstances);
} }
if (!config.contains("tweaksEnabled")) {
config.set("tweaksEnabled", tweaksEnabled);
}
if (!config.contains("secureMode.enabled")) { if (!config.contains("secureMode.enabled")) {
config.set("secureMode.enabled", secureModeEnabled); config.set("secureMode.enabled", secureModeEnabled);
} }
@ -659,15 +640,6 @@ public class MainConfig extends DREConfig {
maxInstances = config.getInt("maxInstances"); maxInstances = config.getInt("maxInstances");
} }
if (config.contains("tweaksEnabled")) {
if (Internals.isAtLeast(Internals.v1_9_R1)) {
tweaksEnabled = config.getBoolean("tweaksEnabled");
} else {
tweaksEnabled = false;
MessageUtil.log(DMessage.LOG_DISABLED_TWEAKS.getMessage());
}
}
if (config.contains("secureMode.enabled")) { if (config.contains("secureMode.enabled")) {
secureModeEnabled = config.getBoolean("secureMode.enabled"); secureModeEnabled = config.getBoolean("secureMode.enabled");
} }

View File

@ -240,7 +240,7 @@ public class DPortal extends GlobalProtection {
dGroup.setGameWorld(target); dGroup.setGameWorld(target);
} }
DGamePlayer.create(player, target); new DGamePlayer(player, target);
} }
@Override @Override

View File

@ -1,97 +0,0 @@
/*
* Copyright (C) 2012-2018 Frank Baumann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.player;
import de.erethon.commons.chat.MessageUtil;
import de.erethon.dungeonsxl.game.GameType;
import de.erethon.dungeonsxl.world.DEditWorld;
import de.erethon.dungeonsxl.world.DGameWorld;
import de.erethon.dungeonsxl.world.DInstanceWorld;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
/**
* @author Daniel Saukel
*/
public class CreateDInstancePlayerTask extends BukkitRunnable {
public static final String BAR = "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588";
private UUID player;
private DInstanceWorld instance;
private GameType ready;
private int i = 12;
public CreateDInstancePlayerTask(Player player, DInstanceWorld instance) {
this.player = player.getUniqueId();
this.instance = instance;
}
public CreateDInstancePlayerTask(Player player, DInstanceWorld instance, GameType ready) {
this.player = player.getUniqueId();
this.instance = instance;
this.ready = ready;
}
@Override
public void run() {
Player player = Bukkit.getPlayer(this.player);
if (player == null || !player.isOnline()) {
cancel();
return;
}
if (instance.exists()) {
if (instance instanceof DGameWorld) {
DGamePlayer gamePlayer = new DGamePlayer(player, (DGameWorld) instance);
if (ready != null) {
gamePlayer.ready(ready);
}
} else if (instance instanceof DEditWorld) {
new DEditPlayer(player, (DEditWorld) instance);
}
cancel();
return;
}
StringBuilder bar = new StringBuilder(BAR);
int pos = i;
if (bar.length() - pos < 0) {
pos = bar.length();
}
bar.insert(bar.length() - pos, ChatColor.GREEN.toString());
pos = i - 2;
if (pos > 0) {
bar.insert(bar.length() - pos, ChatColor.DARK_RED.toString());
}
MessageUtil.sendActionBarMessage(player, ChatColor.DARK_RED + bar.toString());
i--;
if (i == 0) {
i = 12;
}
}
}

View File

@ -43,7 +43,7 @@ public class DEditPlayer extends DInstancePlayer {
private String[] linesCopy; private String[] linesCopy;
private DEditWorld editWorld; private DEditWorld editWorld;
public DEditPlayer(final Player player, DEditWorld world) { public DEditPlayer(Player player, DEditWorld world) {
super(player, world.getWorld()); super(player, world.getWorld());
editWorld = world; editWorld = world;
@ -72,13 +72,6 @@ public class DEditPlayer extends DInstancePlayer {
} }
} }
/**
* @param player the represented Player
* @param editWorld the player's EditWorld
*/
public static void create(Player player, DEditWorld editWorld) {
new CreateDInstancePlayerTask(player, editWorld).runTaskTimer(DungeonsXL.getInstance(), 0L, 5L);
}
/* Getters and setters */ /* Getters and setters */
/** /**

View File

@ -111,21 +111,11 @@ public class DGamePlayer extends DInstancePlayer {
} }
} }
/** public DGamePlayer(Player player, DGameWorld world, GameType ready) {
* @param player the represented Player this(player, world);
* @param gameWorld the player's GameWorld if (ready != null) {
*/ ready(ready);
public static void create(Player player, DGameWorld gameWorld) { }
create(player, gameWorld, null);
}
/**
* @param player the represented Player
* @param gameWorld the player's GameWorld
* @param ready Any GameType if the player will be ready from the beginning null if the player will not be ready from the beginning
*/
public static void create(Player player, DGameWorld gameWorld, GameType ready) {
new CreateDInstancePlayerTask(player, gameWorld, ready).runTaskTimer(DungeonsXL.getInstance(), 0L, 5L);
} }
/* Getters and setters */ /* Getters and setters */

View File

@ -399,7 +399,7 @@ public class DGlobalPlayer implements PlayerWrapper {
DGameWorld gameWorld = dungeon.getMap().instantiateAsGameWorld(true); DGameWorld gameWorld = dungeon.getMap().instantiateAsGameWorld(true);
dGroup.setGameWorld(gameWorld); dGroup.setGameWorld(gameWorld);
new Game(dGroup, gameWorld).setTutorial(true); new Game(dGroup, gameWorld).setTutorial(true);
DGamePlayer.create(player, gameWorld); new DGamePlayer(player, gameWorld);
} }
} }

View File

@ -1,41 +0,0 @@
/*
* Copyright (C) 2012-2018 Frank Baumann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.world;
import de.erethon.commons.misc.FileUtil;
import de.erethon.dungeonsxl.DungeonsXL;
import java.io.File;
import org.bukkit.scheduler.BukkitRunnable;
/**
* @author Daniel Saukel
*/
public class BackupResourceTask extends BukkitRunnable {
private DResourceWorld resource;
public BackupResourceTask(DResourceWorld resource) {
this.resource = resource;
}
@Override
public void run() {
File target = new File(DungeonsXL.BACKUPS, resource.getName() + "-" + System.currentTimeMillis());
FileUtil.copyDir(resource.getFolder(), target);
}
}

View File

@ -27,7 +27,6 @@ import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.scheduler.BukkitRunnable;
/** /**
* A raw resource world instance to edit the dungeon map. There is never more than one DEditWorld per DResourceWorld. * A raw resource world instance to edit the dungeon map. There is never more than one DEditWorld per DResourceWorld.
@ -116,19 +115,8 @@ public class DEditWorld extends DInstanceWorld {
getWorld().save(); getWorld().save();
if (!plugin.getMainConfig().areTweaksEnabled()) { FileUtil.copyDir(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
FileUtil.copyDir(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES); DWorldCache.deleteUnusedFiles(getResource().getFolder());
DWorldCache.deleteUnusedFiles(getResource().getFolder());
} else {
new BukkitRunnable() {
@Override
public void run() {
FileUtil.copyDir(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
DWorldCache.deleteUnusedFiles(getResource().getFolder());
}
}.runTaskAsynchronously(plugin);
}
getResource().getSignData().serializeSigns(signs); getResource().getSignData().serializeSigns(signs);
} }
@ -153,36 +141,17 @@ public class DEditWorld extends DInstanceWorld {
kickAllPlayers(); kickAllPlayers();
if (!plugin.getMainConfig().areTweaksEnabled()) { if (save) {
if (save) { Bukkit.unloadWorld(getWorld(), true);
Bukkit.unloadWorld(getWorld(), true);
}
FileUtil.copyDir(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
DWorldCache.deleteUnusedFiles(getResource().getFolder());
if (!save) {
Bukkit.unloadWorld(getWorld(), true);
}
FileUtil.removeDir(getFolder());
worlds.removeInstance(this);
} else {
final DEditWorld editWorld = this;
new BukkitRunnable() {
@Override
public void run() {
if (save) {
Bukkit.unloadWorld(getWorld(), true);
}
FileUtil.copyDir(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
DWorldCache.deleteUnusedFiles(getResource().getFolder());
if (!save) {
Bukkit.unloadWorld(getWorld(), true);
}
FileUtil.removeDir(getFolder());
worlds.removeInstance(editWorld);
}
}.runTaskAsynchronously(plugin);
} }
FileUtil.copyDir(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
DWorldCache.deleteUnusedFiles(getResource().getFolder());
if (!save) {
Bukkit.unloadWorld(getWorld(), true);
}
FileUtil.removeDir(getFolder());
worlds.removeInstance(this);
} }
/* Statics */ /* Statics */

View File

@ -69,7 +69,6 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Spider; import org.bukkit.entity.Spider;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
/** /**
* A playable resource instance. There may be any amount of DGameWorlds per DResourceWorld. * A playable resource instance. There may be any amount of DGameWorlds per DResourceWorld.
@ -488,22 +487,9 @@ public class DGameWorld extends DInstanceWorld {
kickAllPlayers(); kickAllPlayers();
if (!plugin.getMainConfig().areTweaksEnabled()) { Bukkit.unloadWorld(getWorld(), false);
Bukkit.unloadWorld(getWorld(), false); FileUtil.removeDir(getFolder());
FileUtil.removeDir(getFolder()); worlds.removeInstance(this);
worlds.removeInstance(this);
} else {
final DGameWorld gameWorld = this;
new BukkitRunnable() {
@Override
public void run() {
Bukkit.unloadWorld(getWorld(), false);
FileUtil.removeDir(getFolder());
worlds.removeInstance(gameWorld);
}
}.runTaskAsynchronously(plugin);
}
} }
/** /**

View File

@ -30,7 +30,6 @@ import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
import org.bukkit.WorldType; import org.bukkit.WorldType;
import org.bukkit.scheduler.BukkitRunnable;
/** /**
* This class represents unloaded worlds. * This class represents unloaded worlds.
@ -187,16 +186,10 @@ public class DResourceWorld {
/* Actions */ /* Actions */
/** /**
* Creates a backup of the resource * Creates a backup of the resource
*
* @param async whether the task shall be performed asyncronously
*/ */
public void backup(boolean async) { public void backup() {
BackupResourceTask task = new BackupResourceTask(this); File target = new File(DungeonsXL.BACKUPS, getName() + "-" + System.currentTimeMillis());
if (async) { FileUtil.copyDir(folder, target);
task.runTaskAsynchronously(plugin);
} else {
task.run();
}
} }
/** /**
@ -206,56 +199,34 @@ public class DResourceWorld {
public DInstanceWorld instantiate(final boolean game) { public DInstanceWorld instantiate(final boolean game) {
int id = worlds.generateId(); int id = worlds.generateId();
String name = worlds.generateName(game, id); String name = worlds.generateName(game, id);
File tempIF = new File(Bukkit.getWorldContainer(), name);
while (tempIF.exists()) { File instanceFolder = new File(Bukkit.getWorldContainer(), name);
while (instanceFolder.exists()) {
World world = Bukkit.getWorld(name); World world = Bukkit.getWorld(name);
boolean removed = false; boolean removed = false;
if (world != null && world.getPlayers().isEmpty()) { if (world != null && world.getPlayers().isEmpty()) {
Bukkit.unloadWorld(name, false); Bukkit.unloadWorld(name, false);
} }
if (world == null || world.getPlayers().isEmpty()) { if (world == null || world.getPlayers().isEmpty()) {
removed = tempIF.delete(); removed = instanceFolder.delete();
} }
if (!removed) { if (!removed) {
MessageUtil.log(plugin, "&6Warning: An unrecognized junk instance (&4" + name + "&6) has been found, but could not be deleted."); MessageUtil.log(plugin, "&6Warning: An unrecognized junk instance (&4" + name + "&6) has been found, but could not be deleted.");
id++; id++;
name = worlds.generateName(game, id); name = worlds.generateName(game, id);
tempIF = new File(Bukkit.getWorldContainer(), name); instanceFolder = new File(Bukkit.getWorldContainer(), name);
} }
} }
final File instanceFolder = tempIF; // Because Java SUCKS
final DInstanceWorld instance = game ? new DGameWorld(this, instanceFolder, id) : new DEditWorld(this, instanceFolder, id); DInstanceWorld instance = game ? new DGameWorld(this, instanceFolder, id) : new DEditWorld(this, instanceFolder, id);
if (!plugin.getMainConfig().areTweaksEnabled()) { FileUtil.copyDir(folder, instanceFolder, DungeonsXL.EXCLUDED_FILES);
FileUtil.copyDir(folder, instanceFolder, DungeonsXL.EXCLUDED_FILES); instance.world = Bukkit.createWorld(WorldCreator.name(name).environment(getWorldEnvironment()));
instance.world = Bukkit.createWorld(WorldCreator.name(name).environment(getWorldEnvironment()));
if (game) {
signData.deserializeSigns((DGameWorld) instance);
} else {
signData.deserializeSigns((DEditWorld) instance);
}
if (game) {
signData.deserializeSigns((DGameWorld) instance);
} else { } else {
new BukkitRunnable() { signData.deserializeSigns((DEditWorld) instance);
@Override
public void run() {
FileUtil.copyDir(folder, instanceFolder, DungeonsXL.EXCLUDED_FILES);
instance.world = WorldLoader.createWorld(WorldCreator.name(instanceFolder.getName()).environment(getWorldEnvironment()));
new BukkitRunnable() {
@Override
public void run() {
if (game) {
signData.deserializeSigns((DGameWorld) instance);
} else {
signData.deserializeSigns((DEditWorld) instance);
}
}
}.runTask(plugin);
}
}.runTaskAsynchronously(plugin);
} }
return instance; return instance;
@ -312,21 +283,13 @@ public class DResourceWorld {
return null; return null;
} }
if (!plugin.getMainConfig().areTweaksEnabled()) { if (!DWorldCache.RAW.exists()) {
editWorld.world = creator.createWorld(); worlds.createRaw();
editWorld.generateIdFile();
} else {
new BukkitRunnable() {
@Override
public void run() {
FileUtil.copyDir(DWorldCache.RAW, folder, DungeonsXL.EXCLUDED_FILES);
editWorld.generateIdFile();
editWorld.world = WorldLoader.createWorld(creator);
editWorld.generateIdFile();
}
}.runTaskAsynchronously(plugin);
} }
FileUtil.copyDir(DWorldCache.RAW, folder, DungeonsXL.EXCLUDED_FILES);
editWorld.generateIdFile();
editWorld.world = WorldLoader.createWorld(creator);
editWorld.generateIdFile();
return editWorld; return editWorld;
} }

View File

@ -251,7 +251,7 @@ public class DWorldCache {
HashSet<DInstanceWorld> instances = new HashSet<>(this.instances); HashSet<DInstanceWorld> instances = new HashSet<>(this.instances);
for (DInstanceWorld instance : instances) { for (DInstanceWorld instance : instances) {
if (backupMode == BackupMode.ON_DISABLE | backupMode == BackupMode.ON_DISABLE_AND_SAVE && instance instanceof DEditWorld) { if (backupMode == BackupMode.ON_DISABLE | backupMode == BackupMode.ON_DISABLE_AND_SAVE && instance instanceof DEditWorld) {
instance.getResource().backup(mainConfig.areTweaksEnabled()); instance.getResource().backup();
} }
instance.delete(); instance.delete();