diff --git a/pom.xml b/pom.xml
index 2e21989f..9ecd63e2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -110,6 +110,11 @@
holographicdisplaysapi
2.1.7
+
+ pl.betoncraft.betonquest
+ BetonQuest
+ 1.8.5
+
@@ -120,13 +125,17 @@
vault-repo
http://nexus.theyeticave.net/content/repositories/pub_releases
-
- dre2n-repo
- http://feuerstern.bplaced.net/repo/
-
citizens-repo
http://repo.citizensnpcs.co/
+
+ betonquest-repo
+ http://betonquest.betoncraft.pl/mvn
+
+
+ dre2n-repo
+ http://feuerstern.bplaced.net/repo/
+
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/DungeonsXL.java b/src/main/java/io/github/dre2n/dungeonsxl/DungeonsXL.java
index b4a71a66..7a669833 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/DungeonsXL.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/DungeonsXL.java
@@ -23,7 +23,6 @@ import io.github.dre2n.commons.compatibility.Version;
import io.github.dre2n.commons.config.MessageConfig;
import io.github.dre2n.commons.javaplugin.BRPlugin;
import io.github.dre2n.commons.javaplugin.BRPluginSettings;
-import io.github.dre2n.commons.util.FileUtil;
import io.github.dre2n.dungeonsxl.announcer.Announcers;
import io.github.dre2n.dungeonsxl.command.*;
import io.github.dre2n.dungeonsxl.config.DMessages;
@@ -53,8 +52,7 @@ import io.github.dre2n.dungeonsxl.task.SecureModeTask;
import io.github.dre2n.dungeonsxl.task.UpdateTask;
import io.github.dre2n.dungeonsxl.task.WorldUnloadTask;
import io.github.dre2n.dungeonsxl.trigger.TriggerTypes;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DWorlds;
import io.github.dre2n.itemsxl.ItemsXL;
import java.io.File;
import java.util.List;
@@ -100,6 +98,7 @@ public class DungeonsXL extends BRPlugin {
private DClasses dClasses;
private DMobTypes dMobTypes;
private SignScripts signScripts;
+ private DWorlds dWorlds;
private BukkitTask announcerTask;
private BukkitTask worldUnloadTask;
@@ -108,8 +107,6 @@ public class DungeonsXL extends BRPlugin {
private BukkitTask secureModeTask;
private CopyOnWriteArrayList dLootInventories = new CopyOnWriteArrayList<>();
- private CopyOnWriteArrayList editWorlds = new CopyOnWriteArrayList<>();
- private CopyOnWriteArrayList gameWorlds = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList games = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList dGroups = new CopyOnWriteArrayList<>();
@@ -149,7 +146,6 @@ public class DungeonsXL extends BRPlugin {
loadMainConfig(new File(getDataFolder(), "config.yml"));
// Load Language 2
loadMessageConfig(new File(LANGUAGES, mainConfig.getLanguage() + ".yml"));
- loadDCommands();
DPermissions.register();
loadGameTypes();
loadRequirementTypes();
@@ -164,6 +160,8 @@ public class DungeonsXL extends BRPlugin {
loadDClasses(CLASSES);
loadDMobTypes(MOBS);
loadSignScripts(SIGNS);
+ loadDWorlds(MAPS);
+ loadDCommands();
manager.registerEvents(new EntityListener(), this);
manager.registerEvents(new GUIListener(), this);
@@ -203,11 +201,8 @@ public class DungeonsXL extends BRPlugin {
dLootInventories.clear();
dGroups.clear();
- // Delete Worlds
- GameWorld.deleteAll();
- gameWorlds.clear();
- EditWorld.deleteAll();
- editWorlds.clear();
+ // Delete DWorlds
+ dWorlds.deleteAllInstances();
// Disable listeners
HandlerList.unregisterAll(this);
@@ -272,37 +267,14 @@ public class DungeonsXL extends BRPlugin {
public void saveData() {
protections.saveAll();
DSavePlayer.save();
- for (EditWorld editWorld : editWorlds) {
- editWorld.save();
- }
+ dWorlds.saveAll();
}
public void loadAll() {
protections.loadAll();
dPlayers.loadAll();
DSavePlayer.load();
- checkWorlds();
- }
-
- public void checkWorlds() {
- File serverDir = new File(".");
-
- for (File file : serverDir.listFiles()) {
- if (file.getName().contains("DXL_Edit_") && file.isDirectory()) {
- for (File dungeonFile : file.listFiles()) {
- if (dungeonFile.getName().contains(".id_")) {
- String dungeonName = dungeonFile.getName().substring(4);
- FileUtil.copyDirectory(file, new File(getDataFolder(), "/maps/" + dungeonName), EXCLUDED_FILES);
- FileUtil.deleteUnusedFiles(new File(getDataFolder(), "/maps/" + dungeonName));
- }
- }
-
- FileUtil.removeDirectory(file);
-
- } else if (file.getName().contains("DXL_Game_") && file.isDirectory()) {
- FileUtil.removeDirectory(file);
- }
- }
+ dWorlds.check();
}
/* Getters and loaders */
@@ -602,10 +574,24 @@ public class DungeonsXL extends BRPlugin {
}
/**
- * @return the worldUnloadTask
+ * @return the loaded instance of DWorlds
*/
- public BukkitTask getWorldUnloadTask() {
- return worldUnloadTask;
+ public DWorlds getDWorlds() {
+ return dWorlds;
+ }
+
+ /**
+ * load / reload a new instance of DWorlds
+ */
+ public void loadDWorlds(File folder) {
+ dWorlds = new DWorlds(MAPS);
+ }
+
+ /**
+ * @return the AnnouncerTask
+ */
+ public BukkitTask getAnnouncerTask() {
+ return announcerTask;
}
/**
@@ -618,10 +604,10 @@ public class DungeonsXL extends BRPlugin {
}
/**
- * @return the AnnouncerTask
+ * @return the worldUnloadTask
*/
- public BukkitTask getAnnouncerTask() {
- return announcerTask;
+ public BukkitTask getWorldUnloadTask() {
+ return worldUnloadTask;
}
/**
@@ -680,20 +666,6 @@ public class DungeonsXL extends BRPlugin {
return dLootInventories;
}
- /**
- * @return the editWorlds
- */
- public List getEditWorlds() {
- return editWorlds;
- }
-
- /**
- * @return the gameWorlds
- */
- public List getGameWorlds() {
- return gameWorlds;
- }
-
/**
* @return the games
*/
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/announcer/Announcer.java b/src/main/java/io/github/dre2n/dungeonsxl/announcer/Announcer.java
index 8b14126d..f867f275 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/announcer/Announcer.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/announcer/Announcer.java
@@ -96,7 +96,7 @@ public class Announcer {
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
if (dungeon != null) {
- mapName = dungeon.getConfig().getStartFloor();
+ mapName = dungeon.getConfig().getStartFloor().getName();
}
} else {
@@ -137,7 +137,7 @@ public class Announcer {
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
if (dungeon != null) {
- mapName = dungeon.getConfig().getStartFloor();
+ mapName = dungeon.getConfig().getStartFloor().getName();
}
} else {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/CreateCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/CreateCommand.java
index 3a6cc1f5..10b14973 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/CreateCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/CreateCommand.java
@@ -23,7 +23,8 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.io.File;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
@@ -50,7 +51,7 @@ public class CreateCommand extends BRCommand {
public void onExecute(String[] args, CommandSender sender) {
String name = args[1];
- if (new File(plugin.getDataFolder(), "/maps/" + name).exists()) {
+ if (new File(DungeonsXL.MAPS, name).exists()) {
MessageUtil.sendMessage(sender, DMessages.ERROR_NAME_IN_USE.getMessage(name));
return;
}
@@ -66,9 +67,9 @@ public class CreateCommand extends BRCommand {
MessageUtil.log(plugin, DMessages.LOG_GENERATE_NEW_WORLD.getMessage());
// Create World
- EditWorld editWorld = new EditWorld();
- editWorld.generate();
- editWorld.setMapName(name);
+ DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), name);
+ plugin.getDWorlds().addResource(resource);
+ DEditWorld editWorld = resource.generate();
editWorld.save();
editWorld.delete();
@@ -88,9 +89,9 @@ public class CreateCommand extends BRCommand {
MessageUtil.log(plugin, DMessages.LOG_GENERATE_NEW_WORLD.getMessage());
// Create World
- EditWorld editWorld = new EditWorld();
- editWorld.generate();
- editWorld.setMapName(name);
+ DResourceWorld resource = new DResourceWorld(plugin.getDWorlds(), name);
+ plugin.getDWorlds().addResource(resource);
+ DEditWorld editWorld = resource.generate();
// MSG Done
MessageUtil.log(plugin, DMessages.LOG_WORLD_GENERATION_FINISHED.getMessage());
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/EditCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/EditCommand.java
index 9550a356..fd880ede 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/EditCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/EditCommand.java
@@ -21,10 +21,13 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
-import io.github.dre2n.dungeonsxl.player.DGamePlayer;
+import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
+import io.github.dre2n.dungeonsxl.world.DWorlds;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -34,6 +37,7 @@ import org.bukkit.entity.Player;
public class EditCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
+ DWorlds worlds = plugin.getDWorlds();
public EditCommand() {
setCommand("edit");
@@ -46,18 +50,24 @@ public class EditCommand extends BRCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
-
String mapName = args[1];
- EditWorld editWorld = EditWorld.load(mapName);
- DGroup dGroup = DGroup.getByPlayer(player);
- DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
- if (!(EditWorld.isInvitedPlayer(mapName, player.getUniqueId(), player.getName()) || DPermissions.hasPermission(player, DPermissions.EDIT))) {
+ if (!worlds.exists(mapName)) {
+ MessageUtil.sendMessage(player, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(mapName));
+ return;
+ }
+
+ DResourceWorld resource = worlds.getResourceByName(mapName);
+ DEditWorld editWorld = resource.instantiateAsEditWorld();
+ DGroup dGroup = DGroup.getByPlayer(player);
+ DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
+
+ if (!(resource.isInvitedPlayer(player) || DPermissions.hasPermission(player, DPermissions.EDIT))) {
MessageUtil.sendMessage(player, DMessages.ERROR_NO_PERMISSIONS.getMessage());
return;
}
- if (dPlayer != null) {
+ if (dPlayer instanceof DInstancePlayer) {
MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage());
return;
}
@@ -67,13 +77,7 @@ public class EditCommand extends BRCommand {
return;
}
- if (editWorld == null) {
- MessageUtil.sendMessage(player, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(mapName));
- return;
- }
-
new DEditPlayer(player, editWorld.getWorld());
-
}
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/EnterCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/EnterCommand.java
index 9925fe09..8920bf95 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/EnterCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/EnterCommand.java
@@ -68,7 +68,7 @@ public class EnterCommand extends BRCommand {
}
if (joining == null) {
- joining = new DGroup(captain, game.getWorld().getMapName(), game.getDungeon() != null);
+ joining = new DGroup(captain, game.getWorld().getName(), game.getDungeon() != null);
}
if (joining.getCaptain() != captain && !DPermissions.hasPermission(sender, DPermissions.BYPASS)) {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/EscapeCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/EscapeCommand.java
index 63a1d265..495b6adc 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/EscapeCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/EscapeCommand.java
@@ -23,7 +23,7 @@ import io.github.dre2n.dungeonsxl.player.DEditPlayer;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -52,13 +52,13 @@ public class EscapeCommand extends BRCommand {
} else if (dPlayer != null) {
dPlayer.escape();
- EditWorld editWorld = EditWorld.getByWorld(dPlayer.getWorld());
+ DEditWorld editWorld = DEditWorld.getByWorld(dPlayer.getWorld());
if (editWorld == null) {
return;
}
if (editWorld.getWorld().getPlayers().isEmpty()) {
- editWorld.deleteNoSave();
+ editWorld.delete(false);
}
} else {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/GameCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/GameCommand.java
index 5467d651..28546129 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/GameCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/GameCommand.java
@@ -23,7 +23,7 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -52,7 +52,7 @@ public class GameCommand extends BRCommand {
return;
}
- GameWorld gameWorld = dGroup.getGameWorld();
+ DGameWorld gameWorld = dGroup.getGameWorld();
if (gameWorld == null) {
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_GAME.getMessage());
return;
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/InviteCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/InviteCommand.java
index 8f91bceb..e6b39ff8 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/InviteCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/InviteCommand.java
@@ -17,12 +17,13 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.commons.command.BRCommand;
-import io.github.dre2n.commons.util.UUIDUtil;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
+import org.bukkit.Bukkit;
+import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
/**
@@ -44,8 +45,16 @@ public class InviteCommand extends BRCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
- if (EditWorld.addInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]))) {
- MessageUtil.sendMessage(sender, DMessages.CMD_INVITE_SUCCESS.getMessage(args[1], args[2]));
+ DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[2]);
+ OfflinePlayer player = Bukkit.getOfflinePlayer(args[2]);
+
+ if (resource != null) {
+ if (player != null) {
+ MessageUtil.sendMessage(sender, DMessages.CMD_INVITE_SUCCESS.getMessage(args[1], args[2]));
+
+ } else {
+ MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_PLAYER.getMessage(args[2]));
+ }
} else {
MessageUtil.sendMessage(sender, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(args[2]));
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/LeaveCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/LeaveCommand.java
index a7470fe4..ab290a7e 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/LeaveCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/LeaveCommand.java
@@ -27,7 +27,7 @@ import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -53,8 +53,8 @@ public class LeaveCommand extends BRCommand {
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
- if (GameWorld.getByWorld(player.getWorld()) != null) {
- if (GameWorld.getByWorld(player.getWorld()).isTutorial()) {
+ if (DGameWorld.getByWorld(player.getWorld()) != null) {
+ if (DGameWorld.getByWorld(player.getWorld()).isTutorial()) {
MessageUtil.sendMessage(player, DMessages.ERROR_NO_LEAVE_IN_TUTORIAL.getMessage());
return;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/ListCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/ListCommand.java
index 81e7d338..a8bcc6c6 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/ListCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/ListCommand.java
@@ -24,8 +24,9 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
+import io.github.dre2n.dungeonsxl.world.DWorlds;
import java.io.File;
import java.util.ArrayList;
import org.bukkit.command.CommandSender;
@@ -37,6 +38,7 @@ import org.bukkit.entity.Player;
public class ListCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance();
+ DWorlds worlds = plugin.getDWorlds();
public ListCommand() {
setCommand("list");
@@ -50,21 +52,19 @@ public class ListCommand extends BRCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
- File dungeonFolder = new File(plugin.getDataFolder() + "/dungeons");
- File mapFolder = new File(plugin.getDataFolder() + "/maps");
ArrayList dungeonList = new ArrayList<>();
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
dungeonList.add(dungeon.getName());
}
ArrayList mapList = new ArrayList<>();
- for (File file : mapFolder.listFiles()) {
+ for (File file : DungeonsXL.MAPS.listFiles()) {
mapList.add(file.getName());
}
ArrayList loadedList = new ArrayList<>();
- for (EditWorld editWorld : plugin.getEditWorlds()) {
+ for (DEditWorld editWorld : worlds.getEditWorlds()) {
loadedList.add(editWorld.getWorld().getWorldFolder().getName());
}
- for (GameWorld gameWorld : plugin.getGameWorlds()) {
+ for (DGameWorld gameWorld : worlds.getGameWorlds()) {
loadedList.add(gameWorld.getWorld().getWorldFolder().getName());
}
ArrayList toSend = new ArrayList<>();
@@ -130,7 +130,7 @@ public class ListCommand extends BRCommand {
for (String map : toSend) {
boolean invited = false;
if (sender instanceof Player) {
- invited = EditWorld.isInvitedPlayer(map, ((Player) sender).getUniqueId(), sender.getName());
+ invited = worlds.getResourceByName(map).isInvitedPlayer((Player) sender);
}
MessageUtil.sendMessage(sender, "&b" + map + "&7 | &e" + invited);
@@ -139,7 +139,7 @@ public class ListCommand extends BRCommand {
case 1:
MessageUtil.sendMessage(sender, "&4Dungeon&7 | &eMap count");
for (String dungeon : toSend) {
- DungeonConfig dungeonConfig = new DungeonConfig(new File(dungeonFolder, dungeon + ".yml"));
+ DungeonConfig dungeonConfig = new DungeonConfig(new File(DungeonsXL.DUNGEONS, dungeon + ".yml"));
int count = dungeonConfig.getFloors().size() + 2;
MessageUtil.sendMessage(sender, "&b" + dungeon + "&7 | &e" + count);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/MainCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/MainCommand.java
index 0affa731..7650433d 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/MainCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/MainCommand.java
@@ -24,7 +24,6 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginManager;
@@ -48,9 +47,9 @@ public class MainCommand extends BRCommand {
public void onExecute(String[] args, CommandSender sender) {
PluginManager plugins = Bukkit.getServer().getPluginManager();
- int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length;
- int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
- int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size();
+ int maps = DungeonsXL.MAPS.listFiles().length;
+ int dungeons = DungeonsXL.DUNGEONS.listFiles().length;
+ int loaded = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size();
int players = plugin.getDPlayers().getDGamePlayers().size();
Internals internals = CompatibilityHandler.getInstance().getInternals();
String vault = "";
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/MsgCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/MsgCommand.java
index 0980abdf..99d37b66 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/MsgCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/MsgCommand.java
@@ -23,8 +23,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
-import java.io.File;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -48,7 +47,7 @@ public class MsgCommand extends BRCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
- EditWorld editWorld = EditWorld.getByWorld(player.getWorld());
+ DEditWorld editWorld = DEditWorld.getByWorld(player.getWorld());
if (editWorld == null) {
MessageUtil.sendMessage(player, DMessages.ERROR_NOT_IN_DUNGEON.getMessage());
@@ -63,10 +62,10 @@ public class MsgCommand extends BRCommand {
try {
int id = NumberUtil.parseInt(args[1]);
- WorldConfig confreader = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + editWorld.getMapName(), "config.yml"));
+ WorldConfig config = editWorld.getResource().getConfig();
if (args.length == 2) {
- String msg = confreader.getMsg(id, true);
+ String msg = config.getMsg(id, true);
if (msg != null) {
MessageUtil.sendMessage(player, ChatColor.WHITE + msg);
@@ -89,7 +88,7 @@ public class MsgCommand extends BRCommand {
if (splitMsg.length > 1) {
msg = splitMsg[1];
- String old = confreader.getMsg(id, false);
+ String old = config.getMsg(id, false);
if (old == null) {
MessageUtil.sendMessage(player, DMessages.CMD_MSG_ADDED.getMessage(String.valueOf(id)));
@@ -97,8 +96,8 @@ public class MsgCommand extends BRCommand {
MessageUtil.sendMessage(player, DMessages.CMD_MSG_UPDATED.getMessage(String.valueOf(id)));
}
- confreader.setMsg(msg, id);
- confreader.save();
+ config.setMsg(msg, id);
+ config.save();
} else {
MessageUtil.sendMessage(player, DMessages.ERROR_MSG_FORMAT.getMessage());
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/PlayCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/PlayCommand.java
index 37978851..27849e54 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/PlayCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/PlayCommand.java
@@ -27,7 +27,6 @@ import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -73,7 +72,7 @@ public class PlayCommand extends BRCommand {
Dungeon dungeon = plugin.getDungeons().getByName(args[2]);
if (dungeon != null) {
multiFloor = true;
- mapName = dungeon.getConfig().getStartFloor();
+ mapName = dungeon.getConfig().getStartFloor().getName();
} else {
displayHelp(player);
return;
@@ -84,7 +83,7 @@ public class PlayCommand extends BRCommand {
}
}
- if (!multiFloor && !EditWorld.exists(identifier)) {
+ if (!multiFloor && !plugin.getDWorlds().exists(identifier)) {
MessageUtil.sendMessage(player, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(identifier));
return;
}
@@ -108,7 +107,7 @@ public class PlayCommand extends BRCommand {
DungeonConfig config = dungeon.getConfig();
if (config != null) {
- dGroup.setMapName(config.getStartFloor());
+ dGroup.setMapName(config.getStartFloor().getName());
}
}
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/ReloadCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/ReloadCommand.java
index 0edeac21..74bbf18a 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/ReloadCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/ReloadCommand.java
@@ -49,9 +49,9 @@ public class ReloadCommand extends BRCommand {
public void onExecute(String[] args, CommandSender sender) {
PluginManager plugins = Bukkit.getServer().getPluginManager();
- int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length;
- int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
- int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size();
+ int maps = DungeonsXL.MAPS.listFiles().length;
+ int dungeons = DungeonsXL.DUNGEONS.listFiles().length;
+ int loaded = plugin.getDWorlds().getEditWorlds().size() + plugin.getDWorlds().getGameWorlds().size();
int players = plugin.getDPlayers().getDGamePlayers().size();
Internals internals = CompatibilityHandler.getInstance().getInternals();
String vault = "";
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/SaveCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/SaveCommand.java
index 37d04877..6f288749 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/SaveCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/SaveCommand.java
@@ -21,7 +21,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -44,7 +44,7 @@ public class SaveCommand extends BRCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
- EditWorld editWorld = EditWorld.getByWorld(player.getWorld());
+ DEditWorld editWorld = DEditWorld.getByWorld(player.getWorld());
if (editWorld != null) {
editWorld.save();
MessageUtil.sendMessage(player, DMessages.CMD_SAVE_SUCCESS.getMessage());
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/TestCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/TestCommand.java
index 9d5b5e21..50880655 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/TestCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/TestCommand.java
@@ -25,7 +25,7 @@ import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -60,7 +60,7 @@ public class TestCommand extends BRCommand {
return;
}
- GameWorld gameWorld = dGroup.getGameWorld();
+ DGameWorld gameWorld = dGroup.getGameWorld();
if (gameWorld == null) {
MessageUtil.sendMessage(sender, DMessages.ERROR_NOT_IN_DUNGEON.getMessage());
return;
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/UninviteCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/UninviteCommand.java
index 9730e64b..2594d2bf 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/UninviteCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/UninviteCommand.java
@@ -17,12 +17,13 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.commons.command.BRCommand;
-import io.github.dre2n.commons.util.UUIDUtil;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DPermissions;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
+import org.bukkit.Bukkit;
+import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
/**
@@ -44,12 +45,15 @@ public class UninviteCommand extends BRCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
- if (EditWorld.removeInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]), args[1])) {
- MessageUtil.sendMessage(sender, DMessages.CMD_UNINVITE_SUCCESS.getMessage(args[1], args[2]));
-
- } else {
+ DResourceWorld resource = plugin.getDWorlds().getResourceByName(args[2]);
+ if (resource == null) {
MessageUtil.sendMessage(sender, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(args[2]));
}
+
+ OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
+ if (resource.removeInvitedPlayer(player)) {
+ MessageUtil.sendMessage(sender, DMessages.CMD_UNINVITE_SUCCESS.getMessage(args[1], args[2]));
+ }
}
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/config/DMessages.java b/src/main/java/io/github/dre2n/dungeonsxl/config/DMessages.java
index abad9751..0c572d55 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/config/DMessages.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/config/DMessages.java
@@ -17,6 +17,7 @@
package io.github.dre2n.dungeonsxl.config;
import io.github.dre2n.commons.config.Messages;
+import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
@@ -185,6 +186,7 @@ public enum DMessages implements Messages {
this.message = message;
}
+ /* Getters and setters */
@Override
public String getIdentifier() {
return identifier;
@@ -205,6 +207,14 @@ public enum DMessages implements Messages {
this.message = message;
}
+ /* Actions */
+ /**
+ * Sends the message to the console.
+ */
+ public void debug() {
+ MessageUtil.log(DungeonsXL.getInstance(), getMessage());
+ }
+
/* Statics */
/**
* @param identifer
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/config/DungeonConfig.java b/src/main/java/io/github/dre2n/dungeonsxl/config/DungeonConfig.java
index af3d7e4f..8e9bc752 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/config/DungeonConfig.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/config/DungeonConfig.java
@@ -17,6 +17,9 @@
package io.github.dre2n.dungeonsxl.config;
import io.github.dre2n.commons.config.BRConfig;
+import io.github.dre2n.dungeonsxl.DungeonsXL;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
+import io.github.dre2n.dungeonsxl.world.DWorlds;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -26,11 +29,13 @@ import java.util.List;
*/
public class DungeonConfig extends BRConfig {
+ DWorlds worlds = DungeonsXL.getInstance().getDWorlds();
+
public static final int CONFIG_VERSION = 1;
- private String startFloor;
- private String endFloor;
- private List floors = new ArrayList<>();
+ private DResourceWorld startFloor;
+ private DResourceWorld endFloor;
+ private List floors = new ArrayList<>();
private int floorCount;
private boolean removeWhenPlayed;
private WorldConfig overrideValues;
@@ -48,7 +53,7 @@ public class DungeonConfig extends BRConfig {
/**
* @return the startFloor
*/
- public String getStartFloor() {
+ public DResourceWorld getStartFloor() {
return startFloor;
}
@@ -56,14 +61,14 @@ public class DungeonConfig extends BRConfig {
* @param startFloor
* the startFloor to set
*/
- public void setStartFloor(String startFloor) {
+ public void setStartFloor(DResourceWorld startFloor) {
this.startFloor = startFloor;
}
/**
* @return the endFloor
*/
- public String getEndFloor() {
+ public DResourceWorld getEndFloor() {
return endFloor;
}
@@ -71,31 +76,31 @@ public class DungeonConfig extends BRConfig {
* @param endFloor
* the endFloor to set
*/
- public void setEndFloor(String endFloor) {
+ public void setEndFloor(DResourceWorld endFloor) {
this.endFloor = endFloor;
}
/**
* @return the floors
*/
- public List getFloors() {
+ public List getFloors() {
return floors;
}
/**
- * @param gameWorld
- * the gameWorld to add
+ * @param resource
+ * the resource to add
*/
- public void addFloor(String gameWorld) {
- floors.add(gameWorld);
+ public void addFloor(DResourceWorld resource) {
+ floors.add(resource);
}
/**
- * @param gameWorld
- * the gameWorld to remove
+ * @param resource
+ * the resource to remove
*/
- public void removeFloor(String gameWorld) {
- floors.remove(gameWorld);
+ public void removeFloor(DResourceWorld resource) {
+ floors.remove(resource);
}
/**
@@ -165,18 +170,36 @@ public class DungeonConfig extends BRConfig {
defaultValues = worldConfig;
}
+ /**
+ * @param resource
+ * the DResourceWorld to check
+ * @return true if the floor is either in the list or the start / end floor.
+ */
+ public boolean containsFloor(DResourceWorld resource) {
+ return floors.contains(resource) || startFloor.equals(resource) || endFloor.equals(resource);
+ }
+
+ /**
+ * @param mapName
+ * the name of the map to check
+ * @return true if the floor is either in the list or the start / end floor.
+ */
+ public boolean containsFloor(String mapName) {
+ return containsFloor(worlds.getResourceByName(mapName));
+ }
+
@Override
public void initialize() {
if (!config.contains("floors")) {
- config.set("floors", floors);
+ config.createSection("floors");
}
if (!config.contains("startFloor")) {
- config.set("startFloor", startFloor);
+ config.set("startFloor", startFloor.getName());
}
if (!config.contains("endFloor")) {
- config.set("endFloor", endFloor);
+ config.set("endFloor", endFloor.getName());
}
if (!config.contains("floorCount")) {
@@ -201,15 +224,20 @@ public class DungeonConfig extends BRConfig {
@Override
public void load() {
if (config.contains("floors")) {
- floors = config.getStringList("floors");
+ for (String floor : config.getStringList("floors")) {
+ DResourceWorld resource = worlds.getResourceByName(floor);
+ if (resource != null) {
+ floors.add(resource);
+ }
+ }
}
if (config.contains("startFloor")) {
- startFloor = config.getString("startFloor");
+ startFloor = worlds.getResourceByName(config.getString("startFloor"));
}
if (config.contains("endFloor")) {
- endFloor = config.getString("endFloor");
+ endFloor = worlds.getResourceByName(config.getString("endFloor"));
}
if (config.contains("floorCount")) {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/config/SignData.java b/src/main/java/io/github/dre2n/dungeonsxl/config/SignData.java
new file mode 100644
index 00000000..b0d84ce0
--- /dev/null
+++ b/src/main/java/io/github/dre2n/dungeonsxl/config/SignData.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2012-2016 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 .
+ */
+package io.github.dre2n.dungeonsxl.config;
+
+import io.github.dre2n.dungeonsxl.sign.DSign;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.List;
+import org.bukkit.block.Block;
+import org.bukkit.block.Sign;
+
+/**
+ * @author Daniel Saukel
+ */
+public class SignData {
+
+ private File file;
+
+ public SignData(File file) {
+ this.file = file;
+ }
+
+ /* Getters and setters */
+ /**
+ * @return the file
+ */
+ public File getFile() {
+ return file;
+ }
+
+ /* Actions */
+ /**
+ * Applies all signs from the file to the DEditWorld.
+ * Also sets the lobby location of the DEditWorld to the location of the lobby sign if one exists.
+ *
+ * @param editWorld
+ * the DEditWorld where the signs are
+ * @throws IOException
+ */
+ public void deserializeSigns(DEditWorld editWorld) throws IOException {
+ ObjectInputStream os = new ObjectInputStream(new FileInputStream(file));
+ int length = os.readInt();
+
+ for (int i = 0; i < length; i++) {
+ int x = os.readInt();
+ int y = os.readInt();
+ int z = os.readInt();
+
+ Block block = editWorld.getWorld().getBlockAt(x, y, z);
+ editWorld.getSigns().add(block);
+
+ if (block.getState() instanceof Sign) {
+ Sign sign = (Sign) block.getState();
+ String[] lines = sign.getLines();
+
+ if (lines[0].equalsIgnoreCase("[lobby]")) {
+ editWorld.setLobbyLocation(block.getLocation());
+ }
+ }
+ }
+ }
+
+ /**
+ * Applies all signs from the file to the DGameWorld.
+ *
+ * @param gameWorld
+ * the DGameWorld where the signs are
+ * @return a Set of all DSign blocks
+ * @throws IOException
+ */
+ public void deserializeSigns(DGameWorld gameWorld) throws IOException {
+ ObjectInputStream os = new ObjectInputStream(new FileInputStream(file));
+
+ int length = os.readInt();
+ for (int i = 0; i < length; i++) {
+ int x = os.readInt();
+ int y = os.readInt();
+ int z = os.readInt();
+
+ Block block = gameWorld.getWorld().getBlockAt(x, y, z);
+ if (block.getState() instanceof Sign) {
+ DSign dSign = DSign.create((Sign) block.getState(), gameWorld);
+ gameWorld.getDSigns().add(dSign);
+ }
+ }
+
+ os.close();
+ }
+
+ /**
+ * Applies all signs from the DEditWorld to the file.
+ *
+ * @param editWorld
+ * the DEditWorld that contains the signs to serialize
+ * @throws IOException
+ */
+ public void serializeSigns(DEditWorld editWorld) throws IOException {
+ serializeSigns(editWorld.getSigns());
+ }
+
+ /**
+ * Applies all signs from the sign list to the file.
+ *
+ * @param signs
+ * the signs to serialize
+ * @throws IOException
+ */
+ public void serializeSigns(List signs) throws IOException {
+ ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
+ out.writeInt(signs.size());
+
+ for (Block sign : signs) {
+ out.writeInt(sign.getX());
+ out.writeInt(sign.getY());
+ out.writeInt(sign.getZ());
+ }
+
+ out.close();
+ }
+
+}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeon.java b/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeon.java
index 3aca5ae8..4fbcc2fd 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeon.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeon.java
@@ -36,7 +36,7 @@ public class Dungeon {
public Dungeon(String name) {
this.name = name;
- File file = new File(DungeonsXL.getInstance().getDataFolder() + "/dungeons", name + ".yml");
+ File file = new File(DungeonsXL.DUNGEONS, name + ".yml");
if (file.exists()) {
this.config = new DungeonConfig(file);
}
@@ -63,4 +63,11 @@ public class Dungeon {
return config != null;
}
+ /**
+ * @return false if there are setup errors
+ */
+ public boolean isSetupCorrect() {
+ return config.getStartFloor() == null || config.getEndFloor() == null;
+ }
+
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeons.java b/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeons.java
index 35b5fa10..2f5f8c13 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeons.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeons.java
@@ -29,14 +29,23 @@ public class Dungeons {
private List dungeons = new ArrayList<>();
public Dungeons() {
- File folder = new File(DungeonsXL.getInstance().getDataFolder() + "/dungeons");
+ this(DungeonsXL.DUNGEONS);
+ }
+ public Dungeons(File folder) {
if (!folder.exists()) {
folder.mkdir();
}
for (File file : folder.listFiles()) {
- dungeons.add(new Dungeon(file));
+ Dungeon dungeon = new Dungeon(file);
+
+ if (dungeon.isSetupCorrect()) {
+ dungeons.add(dungeon);
+
+ } else {
+ // debug
+ }
}
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupFinishFloorEvent.java b/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupFinishFloorEvent.java
index 9e94b8a6..6fab15d4 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupFinishFloorEvent.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupFinishFloorEvent.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.event.dgroup;
import io.github.dre2n.dungeonsxl.player.DGroup;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -29,10 +29,10 @@ public class DGroupFinishFloorEvent extends DGroupEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
- private GameWorld finished;
+ private DGameWorld finished;
private String next;
- public DGroupFinishFloorEvent(DGroup dGroup, GameWorld finished, String next) {
+ public DGroupFinishFloorEvent(DGroup dGroup, DGameWorld finished, String next) {
super(dGroup);
this.finished = finished;
this.next = next;
@@ -41,15 +41,15 @@ public class DGroupFinishFloorEvent extends DGroupEvent implements Cancellable {
/**
* @return the finished
*/
- public GameWorld getFinished() {
+ public DGameWorld getFinished() {
return finished;
}
/**
* @param finished
- * the name of the GameWorld to set
+ * the name of the DGameWorld to set
*/
- public void setFinished(GameWorld finished) {
+ public void setFinished(DGameWorld finished) {
this.finished = finished;
}
@@ -62,7 +62,7 @@ public class DGroupFinishFloorEvent extends DGroupEvent implements Cancellable {
/**
* @param next
- * the name of the GameWorld to set
+ * the name of the DGameWorld to set
*/
public void setNext(String next) {
this.next = next;
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupStartFloorEvent.java b/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupStartFloorEvent.java
index 16387055..162c99a6 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupStartFloorEvent.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/event/dgroup/DGroupStartFloorEvent.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.event.dgroup;
import io.github.dre2n.dungeonsxl.player.DGroup;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -29,9 +29,9 @@ public class DGroupStartFloorEvent extends DGroupEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
- private GameWorld gameWorld;
+ private DGameWorld gameWorld;
- public DGroupStartFloorEvent(DGroup dGroup, GameWorld gameWorld) {
+ public DGroupStartFloorEvent(DGroup dGroup, DGameWorld gameWorld) {
super(dGroup);
this.gameWorld = gameWorld;
}
@@ -39,7 +39,7 @@ public class DGroupStartFloorEvent extends DGroupEvent implements Cancellable {
/**
* @return the gameWorld
*/
- public GameWorld getGameWorld() {
+ public DGameWorld getGameWorld() {
return gameWorld;
}
@@ -47,7 +47,7 @@ public class DGroupStartFloorEvent extends DGroupEvent implements Cancellable {
* @param gameWorld
* the gameWorld to set
*/
- public void setGameWorld(GameWorld gameWorld) {
+ public void setGameWorld(DGameWorld gameWorld) {
this.gameWorld = gameWorld;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/event/dsign/DSignRegistrationEvent.java b/src/main/java/io/github/dre2n/dungeonsxl/event/dsign/DSignRegistrationEvent.java
index e8fccf66..75d1d0f3 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/event/dsign/DSignRegistrationEvent.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/event/dsign/DSignRegistrationEvent.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.event.dsign;
import io.github.dre2n.dungeonsxl.sign.DSign;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.block.Sign;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -31,9 +31,9 @@ public class DSignRegistrationEvent extends DSignEvent implements Cancellable {
private boolean cancelled;
private Sign sign;
- private GameWorld gameWorld;
+ private DGameWorld gameWorld;
- public DSignRegistrationEvent(Sign sign, GameWorld gameWorld, DSign dSign) {
+ public DSignRegistrationEvent(Sign sign, DGameWorld gameWorld, DSign dSign) {
super(dSign);
this.sign = sign;
this.gameWorld = gameWorld;
@@ -57,7 +57,7 @@ public class DSignRegistrationEvent extends DSignEvent implements Cancellable {
/**
* @return the gameWorld
*/
- public GameWorld getGameWorld() {
+ public DGameWorld getGameWorld() {
return gameWorld;
}
@@ -65,7 +65,7 @@ public class DSignRegistrationEvent extends DSignEvent implements Cancellable {
* @param gameWorld
* the gameWorld to set
*/
- public void setGameWorld(GameWorld gameWorld) {
+ public void setGameWorld(DGameWorld gameWorld) {
this.gameWorld = gameWorld;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldEvent.java b/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldEvent.java
index a3975162..7900de70 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldEvent.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldEvent.java
@@ -16,7 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.event.editworld;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
import org.bukkit.event.Event;
/**
@@ -24,16 +24,16 @@ import org.bukkit.event.Event;
*/
public abstract class EditWorldEvent extends Event {
- protected EditWorld editWorld;
+ protected DEditWorld editWorld;
- public EditWorldEvent(EditWorld editWorld) {
+ public EditWorldEvent(DEditWorld editWorld) {
this.editWorld = editWorld;
}
/**
* @return the editWorld
*/
- public EditWorld getEditWorld() {
+ public DEditWorld getEditWorld() {
return editWorld;
}
@@ -41,7 +41,7 @@ public abstract class EditWorldEvent extends Event {
* @param editWorld
* the editWorld to set
*/
- public void setEditWorld(EditWorld editWorld) {
+ public void setEditWorld(DEditWorld editWorld) {
this.editWorld = editWorld;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldGenerateEvent.java b/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldGenerateEvent.java
index a8f6a4de..fa705133 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldGenerateEvent.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldGenerateEvent.java
@@ -16,7 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.event.editworld;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -28,7 +28,7 @@ public class EditWorldGenerateEvent extends EditWorldEvent implements Cancellabl
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
- public EditWorldGenerateEvent(EditWorld editWorld) {
+ public EditWorldGenerateEvent(DEditWorld editWorld) {
super(editWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldSaveEvent.java b/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldSaveEvent.java
index 20e4d5c8..ef4fe71b 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldSaveEvent.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldSaveEvent.java
@@ -16,7 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.event.editworld;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -28,7 +28,7 @@ public class EditWorldSaveEvent extends EditWorldEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
- public EditWorldSaveEvent(EditWorld editWorld) {
+ public EditWorldSaveEvent(DEditWorld editWorld) {
super(editWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldUnloadEvent.java b/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldUnloadEvent.java
index 8b931508..cad8f1e3 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldUnloadEvent.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/event/editworld/EditWorldUnloadEvent.java
@@ -16,7 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.event.editworld;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -30,7 +30,7 @@ public class EditWorldUnloadEvent extends EditWorldEvent implements Cancellable
private boolean save;
- public EditWorldUnloadEvent(EditWorld editWorld, boolean save) {
+ public EditWorldUnloadEvent(DEditWorld editWorld, boolean save) {
super(editWorld);
this.save = save;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/event/gameworld/GameWorldEvent.java b/src/main/java/io/github/dre2n/dungeonsxl/event/gameworld/GameWorldEvent.java
index 2a74acc6..132c23fc 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/event/gameworld/GameWorldEvent.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/event/gameworld/GameWorldEvent.java
@@ -16,7 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.event.gameworld;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.event.Event;
/**
@@ -24,16 +24,16 @@ import org.bukkit.event.Event;
*/
public abstract class GameWorldEvent extends Event {
- protected GameWorld gameWorld;
+ protected DGameWorld gameWorld;
- public GameWorldEvent(GameWorld gameWorld) {
+ public GameWorldEvent(DGameWorld gameWorld) {
this.gameWorld = gameWorld;
}
/**
* @return the gameWorld
*/
- public GameWorld getGameWorld() {
+ public DGameWorld getGameWorld() {
return gameWorld;
}
@@ -41,7 +41,7 @@ public abstract class GameWorldEvent extends Event {
* @param gameWorld
* the gameWorld to set
*/
- public void setGameWorld(GameWorld gameWorld) {
+ public void setGameWorld(DGameWorld gameWorld) {
this.gameWorld = gameWorld;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/event/gameworld/GameWorldStartGameEvent.java b/src/main/java/io/github/dre2n/dungeonsxl/event/gameworld/GameWorldStartGameEvent.java
index 209acec7..943966b9 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/event/gameworld/GameWorldStartGameEvent.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/event/gameworld/GameWorldStartGameEvent.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.event.gameworld;
import io.github.dre2n.dungeonsxl.game.Game;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -31,7 +31,7 @@ public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellab
private Game game;
- public GameWorldStartGameEvent(GameWorld gameWorld, Game game) {
+ public GameWorldStartGameEvent(DGameWorld gameWorld, Game game) {
super(gameWorld);
this.game = game;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/event/gameworld/GameWorldUnloadEvent.java b/src/main/java/io/github/dre2n/dungeonsxl/event/gameworld/GameWorldUnloadEvent.java
index 3ad91f27..a76be98f 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/event/gameworld/GameWorldUnloadEvent.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/event/gameworld/GameWorldUnloadEvent.java
@@ -16,7 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.event.gameworld;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -29,7 +29,7 @@ public class GameWorldUnloadEvent extends GameWorldEvent implements Cancellable
private boolean cancelled;
- public GameWorldUnloadEvent(GameWorld gameWorld) {
+ public GameWorldUnloadEvent(DGameWorld gameWorld) {
super(gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/game/Game.java b/src/main/java/io/github/dre2n/dungeonsxl/game/Game.java
index 07d1fef4..b62874f7 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/game/Game.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/game/Game.java
@@ -27,7 +27,8 @@ import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.sign.DSign;
import io.github.dre2n.dungeonsxl.sign.MobSign;
import io.github.dre2n.dungeonsxl.trigger.ProgressTrigger;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -49,7 +50,7 @@ public class Game {
private List dGroups = new ArrayList<>();
private boolean started;
private GameType type = GameTypeDefault.DEFAULT;
- private GameWorld world;
+ private DGameWorld world;
private GameRules rules;
private int waveCount;
private Map gameKills = new HashMap<>();
@@ -63,7 +64,7 @@ public class Game {
plugin.getGames().add(this);
}
- public Game(DGroup dGroup, GameWorld world) {
+ public Game(DGroup dGroup, DGameWorld world) {
dGroups.add(dGroup);
started = false;
this.world = world;
@@ -77,17 +78,17 @@ public class Game {
dGroups.add(dGroup);
started = false;
- world = new GameWorld();
+ DResourceWorld resource = plugin.getDWorlds().getResourceByName(worldName);
+ world = resource.instantiateAsGameWorld();
dGroup.setGameWorld(world);
- world.load(worldName);
fetchRules();
}
- public Game(DGroup dGroup, GameType type, GameWorld world) {
+ public Game(DGroup dGroup, GameType type, DGameWorld world) {
this(new ArrayList<>(Arrays.asList(dGroup)), type, world);
}
- public Game(List dGroups, GameType type, GameWorld world) {
+ public Game(List dGroups, GameType type, DGameWorld world) {
this.dGroups = dGroups;
this.type = type;
this.world = world;
@@ -155,17 +156,17 @@ public class Game {
}
/**
- * @return the GameWorld connected to the Game
+ * @return the DGameWorld connected to the Game
*/
- public GameWorld getWorld() {
+ public DGameWorld getWorld() {
return world;
}
/**
* @param world
- * the GameWorld to connect to the Game
+ * the DGameWorld to connect to the Game
*/
- public void setWorld(GameWorld world) {
+ public void setWorld(DGameWorld world) {
this.world = world;
}
@@ -234,8 +235,8 @@ public class Game {
*
* @return the unplayed floors
*/
- public List getUnplayedFloors() {
- List unplayedFloors = new ArrayList<>();
+ public List getUnplayedFloors() {
+ List unplayedFloors = new ArrayList<>();
for (DGroup dGroup : dGroups) {
if (dGroup.getUnplayedFloors().size() < unplayedFloors.size()) {
unplayedFloors = dGroup.getUnplayedFloors();
@@ -374,7 +375,7 @@ public class Game {
}
int delay = rules.getTimeToNextWave();
- sendMessage(plugin.getMessageConfig().getMessage(DMessages.GROUP_WAVE_FINISHED, String.valueOf(waveCount), String.valueOf(delay)));
+ sendMessage(DMessages.GROUP_WAVE_FINISHED.getMessage(String.valueOf(waveCount), String.valueOf(delay)));
new BukkitRunnable() {
@Override
@@ -425,7 +426,7 @@ public class Game {
return getByDGroup(DGroup.getByPlayer(player));
}
- public static Game getByGameWorld(GameWorld gameWorld) {
+ public static Game getByGameWorld(DGameWorld gameWorld) {
for (Game game : plugin.getGames()) {
if (game.getWorld().equals(gameWorld)) {
return game;
@@ -436,7 +437,7 @@ public class Game {
}
public static Game getByWorld(World world) {
- GameWorld gameWorld = GameWorld.getByWorld(world);
+ DGameWorld gameWorld = DGameWorld.getByWorld(world);
if (gameWorld != null) {
return getByGameWorld(gameWorld);
} else {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/game/GamePlaceableBlock.java b/src/main/java/io/github/dre2n/dungeonsxl/game/GamePlaceableBlock.java
index 6f3bb96b..f2fa393b 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/game/GamePlaceableBlock.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/game/GamePlaceableBlock.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.game;
import io.github.dre2n.commons.util.NumberUtil;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Material;
@@ -254,7 +254,7 @@ public class GamePlaceableBlock {
}
// Can build
- public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gameWorld) {
+ public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, DGameWorld gameWorld) {
for (GamePlaceableBlock gamePlacableBlock : gameWorld.getPlaceableBlocks()) {
if (gamePlacableBlock.block.getFace(block) != BlockFace.SELF) {
continue;
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/game/GameRules.java b/src/main/java/io/github/dre2n/dungeonsxl/game/GameRules.java
index 686bf150..556fe5e8 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/game/GameRules.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/game/GameRules.java
@@ -16,7 +16,6 @@
*/
package io.github.dre2n.dungeonsxl.game;
-import io.github.dre2n.caliburn.item.UniversalItem;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.requirement.Requirement;
import io.github.dre2n.dungeonsxl.reward.Reward;
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/global/DPortal.java b/src/main/java/io/github/dre2n/dungeonsxl/global/DPortal.java
index 27e428fd..02b2d2dd 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/global/DPortal.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/global/DPortal.java
@@ -22,7 +22,7 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Location;
@@ -167,7 +167,7 @@ public class DPortal extends GlobalProtection {
return;
}
- GameWorld target = dGroup.getGameWorld();
+ DGameWorld target = dGroup.getGameWorld();
Game game = Game.getByDGroup(dGroup);
if (target == null && game != null) {
@@ -186,7 +186,7 @@ public class DPortal extends GlobalProtection {
}
if (target == null && dGroup.getMapName() != null) {
- target = new GameWorld(dGroup.getMapName());
+ target = plugin.getDWorlds().getResourceByName(dGroup.getMapName()).instantiateAsGameWorld();//TO DO
dGroup.setGameWorld(target);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/global/GameSign.java b/src/main/java/io/github/dre2n/dungeonsxl/global/GameSign.java
index 1d4cea42..f8adbdbb 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/global/GameSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/global/GameSign.java
@@ -65,7 +65,7 @@ public class GameSign extends GlobalProtection {
dungeonName = identifier;
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
if (dungeon != null) {
- mapName = dungeon.getConfig().getStartFloor();
+ mapName = dungeon.getConfig().getStartFloor().getName();
} else {
mapName = "invalid";
}
@@ -469,7 +469,7 @@ public class GameSign extends GlobalProtection {
return false;
}
- if (plugin.getGameWorlds().size() >= plugin.getMainConfig().getMaxInstances()) {
+ if (plugin.getDWorlds().getGameWorlds().size() >= plugin.getMainConfig().getMaxInstances()) {
MessageUtil.sendMessage(player, DMessages.ERROR_TOO_MANY_INSTANCES.getMessage());
return true;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/global/GroupSign.java b/src/main/java/io/github/dre2n/dungeonsxl/global/GroupSign.java
index fb82873a..a432c283 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/global/GroupSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/global/GroupSign.java
@@ -64,7 +64,7 @@ public class GroupSign extends GlobalProtection {
dungeonName = identifier;
Dungeon dungeon = plugin.getDungeons().getByName(identifier);
if (dungeon != null) {
- mapName = dungeon.getConfig().getStartFloor();
+ mapName = dungeon.getConfig().getStartFloor().getName();
} else {
mapName = "invalid";
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java b/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java
index dea4fc76..0fb1b361 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java
@@ -34,8 +34,8 @@ import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayers;
import io.github.dre2n.dungeonsxl.sign.DSign;
import io.github.dre2n.dungeonsxl.task.RedstoneEventTask;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -91,15 +91,15 @@ public class BlockListener implements Listener {
return;
}
- // EditWorld Signs
- EditWorld editWorld = EditWorld.getByWorld(block.getWorld());
+ // DEditWorld Signs
+ DEditWorld editWorld = DEditWorld.getByWorld(block.getWorld());
if (editWorld != null) {
editWorld.getSigns().remove(event.getBlock());
return;
}
- // Deny GameWorld block breaking
- GameWorld gameWorld = GameWorld.getByWorld(block.getWorld());
+ // Deny DGameWorld block breaking
+ DGameWorld gameWorld = DGameWorld.getByWorld(block.getWorld());
if (gameWorld != null) {
for (DSign dSign : gameWorld.getDSigns()) {
if (dSign.getSign().equals(block)) {
@@ -128,8 +128,8 @@ public class BlockListener implements Listener {
public void onPlace(BlockPlaceEvent event) {
Block block = event.getBlock();
- // Deny GameWorld Blocks
- GameWorld gameWorld = GameWorld.getByWorld(block.getWorld());
+ // Deny DGameWorld Blocks
+ DGameWorld gameWorld = DGameWorld.getByWorld(block.getWorld());
if (gameWorld == null) {
return;
}
@@ -162,7 +162,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
Block block = event.getBlock();
String[] lines = event.getLines();
- EditWorld editWorld = EditWorld.getByWorld(player.getWorld());
+ DEditWorld editWorld = DEditWorld.getByWorld(player.getWorld());
// Group Signs
if (editWorld == null) {
@@ -231,7 +231,7 @@ public class BlockListener implements Listener {
}
if (dsign.check()) {
- editWorld.checkSign(block);
+ editWorld.registerSign(block);
editWorld.getSigns().add(block);
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_SIGN_CREATED));
@@ -251,13 +251,13 @@ public class BlockListener implements Listener {
}
// Check GameWorlds
- GameWorld gameWorld = GameWorld.getByWorld(event.getBlock().getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(event.getBlock().getWorld());
if (gameWorld != null) {
event.setCancelled(true);
}
// Check EditWorlds
- EditWorld editWorld = EditWorld.getByWorld(event.getBlock().getWorld());
+ DEditWorld editWorld = DEditWorld.getByWorld(event.getBlock().getWorld());
if (editWorld != null) {
event.setCancelled(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/listener/EntityListener.java b/src/main/java/io/github/dre2n/dungeonsxl/listener/EntityListener.java
index 2668483c..669c5398 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/listener/EntityListener.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/listener/EntityListener.java
@@ -21,8 +21,8 @@ import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
@@ -52,7 +52,7 @@ public class EntityListener implements Listener {
// Remove drops from breaking Signs
@EventHandler(priority = EventPriority.HIGH)
public void onItemSpawn(ItemSpawnEvent event) {
- if (GameWorld.getByWorld(event.getLocation().getWorld()) != null) {
+ if (DGameWorld.getByWorld(event.getLocation().getWorld()) != null) {
if (event.getEntity().getItemStack().getType() == Material.SIGN) {
event.setCancelled(true);
}
@@ -63,8 +63,8 @@ public class EntityListener implements Listener {
public void onCreatureSpawn(CreatureSpawnEvent event) {
World world = event.getLocation().getWorld();
- EditWorld editWorld = EditWorld.getByWorld(world);
- GameWorld gameWorld = GameWorld.getByWorld(world);
+ DEditWorld editWorld = DEditWorld.getByWorld(world);
+ DGameWorld gameWorld = DGameWorld.getByWorld(world);
if (editWorld != null || gameWorld != null) {
switch (event.getSpawnReason()) {
@@ -83,7 +83,7 @@ public class EntityListener implements Listener {
if (event.getEntity() instanceof LivingEntity) {
LivingEntity entity = event.getEntity();
- GameWorld gameWorld = GameWorld.getByWorld(world);
+ DGameWorld gameWorld = DGameWorld.getByWorld(world);
if (gameWorld != null) {
if (gameWorld.isPlaying()) {
DMob dMob = DMob.getByEntity(entity);
@@ -98,7 +98,7 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onDamage(EntityDamageEvent event) {
World world = event.getEntity().getWorld();
- GameWorld gameWorld = GameWorld.getByWorld(world);
+ DGameWorld gameWorld = DGameWorld.getByWorld(world);
if (gameWorld == null) {
return;
@@ -138,7 +138,7 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onDamageByEntity(EntityDamageByEntityEvent event) {
World world = event.getEntity().getWorld();
- GameWorld gameWorld = GameWorld.getByWorld(world);
+ DGameWorld gameWorld = DGameWorld.getByWorld(world);
if (gameWorld == null) {
return;
@@ -223,7 +223,7 @@ public class EntityListener implements Listener {
public void onFoodLevelChange(FoodLevelChangeEvent event) {
World world = event.getEntity().getWorld();
- GameWorld gameWorld = GameWorld.getByWorld(world);
+ DGameWorld gameWorld = DGameWorld.getByWorld(world);
if (gameWorld != null) {
if (!gameWorld.isPlaying()) {
event.setCancelled(true);
@@ -234,7 +234,7 @@ public class EntityListener implements Listener {
// Zombie/skeleton combustion from the sun.
@EventHandler(priority = EventPriority.NORMAL)
public void onCombust(EntityCombustEvent event) {
- GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
if (gameWorld != null) {
event.setCancelled(true);
}
@@ -243,7 +243,7 @@ public class EntityListener implements Listener {
// Allow Other combustion
@EventHandler(priority = EventPriority.HIGH)
public void onCombustByEntity(EntityCombustByEntityEvent event) {
- GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
if (gameWorld != null) {
if (event.isCancelled()) {
event.setCancelled(false);
@@ -254,7 +254,7 @@ public class EntityListener implements Listener {
// Explosions
@EventHandler
public void onExplode(EntityExplodeEvent event) {
- GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
if (gameWorld != null) {
if (event.getEntity() instanceof LivingEntity) {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/listener/GUIListener.java b/src/main/java/io/github/dre2n/dungeonsxl/listener/GUIListener.java
index 55013ed0..c8f6fe55 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/listener/GUIListener.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/listener/GUIListener.java
@@ -19,7 +19,6 @@ package io.github.dre2n.dungeonsxl.listener;
import io.github.dre2n.commons.util.guiutil.ButtonClickEvent;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.announcer.Announcer;
-import io.github.dre2n.dungeonsxl.config.DMessages;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/listener/HangingListener.java b/src/main/java/io/github/dre2n/dungeonsxl/listener/HangingListener.java
index b15c0ce6..7ae81518 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/listener/HangingListener.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/listener/HangingListener.java
@@ -16,7 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.listener;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
@@ -28,7 +28,7 @@ public class HangingListener implements Listener {
@EventHandler
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
- GameWorld gameWorld = GameWorld.getByWorld(event.getEntity().getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
if (gameWorld != null) {
event.setCancelled(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/listener/PlayerListener.java b/src/main/java/io/github/dre2n/dungeonsxl/listener/PlayerListener.java
index 4ad92df4..91430bc3 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/listener/PlayerListener.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/listener/PlayerListener.java
@@ -42,8 +42,8 @@ import io.github.dre2n.dungeonsxl.sign.OpenDoorSign;
import io.github.dre2n.dungeonsxl.task.RespawnTask;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.trigger.UseItemTrigger;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -87,7 +87,7 @@ public class PlayerListener implements Listener {
public void onDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
- GameWorld gameWorld = GameWorld.getByWorld(player.getLocation().getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(player.getLocation().getWorld());
if (gameWorld == null) {
return;
}
@@ -149,7 +149,7 @@ public class PlayerListener implements Listener {
if (clickedBlock != null) {
// Block Enderchests
- if (GameWorld.getByWorld(player.getWorld()) != null || EditWorld.getByWorld(player.getWorld()) != null) {
+ if (DGameWorld.getByWorld(player.getWorld()) != null || DEditWorld.getByWorld(player.getWorld()) != null) {
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
if (clickedBlock.getType() == Material.ENDER_CHEST) {
if (!DPermissions.hasPermission(player, DPermissions.BYPASS)) {
@@ -167,7 +167,7 @@ public class PlayerListener implements Listener {
}
// Block Dispensers
- if (GameWorld.getByWorld(player.getWorld()) != null) {
+ if (DGameWorld.getByWorld(player.getWorld()) != null) {
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
if (clickedBlock.getType() == Material.DISPENSER) {
if (!DPermissions.hasPermission(player, DPermissions.BYPASS)) {
@@ -209,7 +209,7 @@ public class PlayerListener implements Listener {
}
// Copy/Paste a Sign and Block-info
- if (EditWorld.getByWorld(player.getWorld()) != null) {
+ if (DEditWorld.getByWorld(player.getWorld()) != null) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (item.getType() == Material.STICK) {
DEditPlayer dPlayer = DEditPlayer.getByPlayer(player);
@@ -222,7 +222,7 @@ public class PlayerListener implements Listener {
}
// Trigger UseItem Signs
- GameWorld gameWorld = GameWorld.getByWorld(player.getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(player.getWorld());
if (gameWorld != null) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
String name = null;
@@ -272,8 +272,8 @@ public class PlayerListener implements Listener {
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
if (dPlayer != null) {
- // Check GameWorld Signs
- GameWorld gameWorld = GameWorld.getByWorld(player.getWorld());
+ // Check DGameWorld Signs
+ DGameWorld gameWorld = DGameWorld.getByWorld(player.getWorld());
if (gameWorld != null) {
// Trigger InteractTrigger
@@ -285,7 +285,7 @@ public class PlayerListener implements Listener {
}
// Class Signs
- for (Sign classSign : gameWorld.getSignClass()) {
+ for (Sign classSign : gameWorld.getClassesSigns()) {
if (classSign != null) {
if (classSign.getLocation().distance(clickedBlock.getLocation()) < 1) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
@@ -360,7 +360,7 @@ public class PlayerListener implements Listener {
}
if (dPlayer instanceof DEditPlayer) {
- EditWorld editWorld = EditWorld.getByWorld(((DEditPlayer) dPlayer).getWorld());
+ DEditWorld editWorld = DEditWorld.getByWorld(((DEditPlayer) dPlayer).getWorld());
if (editWorld == null) {
return;
}
@@ -375,7 +375,7 @@ public class PlayerListener implements Listener {
} else if (dPlayer instanceof DGamePlayer) {
DGamePlayer gamePlayer = (DGamePlayer) dPlayer;
- GameWorld gameWorld = GameWorld.getByWorld(gamePlayer.getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(gamePlayer.getWorld());
if (gameWorld == null) {
return;
@@ -497,7 +497,7 @@ public class PlayerListener implements Listener {
target = dSavePlayer.getOldLocation();
}
- if (EditWorld.getByWorld(player.getWorld()) != null || GameWorld.getByWorld(player.getWorld()) != null) {
+ if (DEditWorld.getByWorld(player.getWorld()) != null || DGameWorld.getByWorld(player.getWorld()) != null) {
player.teleport(target);
}
}
@@ -538,7 +538,7 @@ public class PlayerListener implements Listener {
}
if (dGroup.getGameWorld() == null) {
- dGroup.setGameWorld(new GameWorld(DGroup.getByPlayer(player).getMapName()));
+ dGroup.setGameWorld(plugin.getDWorlds().getResourceByName(DGroup.getByPlayer(player).getMapName()).instantiateAsGameWorld());// TO DO
dGroup.getGameWorld().setTutorial(true);
}
@@ -578,7 +578,7 @@ public class PlayerListener implements Listener {
continue;
}
- if (plugin.getGameWorlds().size() >= config.getMaxInstances()) {
+ if (plugin.getDWorlds().getGameWorlds().size() >= config.getMaxInstances()) {
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
event.setKickMessage(DMessages.ERROR_TOO_MANY_TUTORIALS.getMessage());
}
@@ -646,7 +646,7 @@ public class PlayerListener implements Listener {
if (!plugin.getMainConfig().getOpenInventories() && !DPermissions.hasPermission(event.getPlayer(), DPermissions.INSECURE)) {
World world = event.getPlayer().getWorld();
- if (event.getInventory().getType() != InventoryType.CREATIVE && EditWorld.getByWorld(world) != null) {
+ if (event.getInventory().getType() != InventoryType.CREATIVE && DEditWorld.getByWorld(world) != null) {
event.setCancelled(true);
}
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/listener/WorldListener.java b/src/main/java/io/github/dre2n/dungeonsxl/listener/WorldListener.java
index e902336e..fb62ee1f 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/listener/WorldListener.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/listener/WorldListener.java
@@ -16,8 +16,8 @@
*/
package io.github.dre2n.dungeonsxl.listener;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -31,7 +31,7 @@ public class WorldListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onChunkUnload(ChunkUnloadEvent event) {
- GameWorld gameWorld = GameWorld.getByWorld(event.getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(event.getWorld());
if (gameWorld != null) {
if (gameWorld.getLoadedChunks().contains(event.getChunk())) {
event.setCancelled(true);
@@ -41,7 +41,7 @@ public class WorldListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onWeatherChange(WeatherChangeEvent event) {
- if (EditWorld.getByWorld(event.getWorld()) != null) {
+ if (DEditWorld.getByWorld(event.getWorld()) != null) {
if (event.toWeatherState()) {
event.setCancelled(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/mob/CitizensMobProvider.java b/src/main/java/io/github/dre2n/dungeonsxl/mob/CitizensMobProvider.java
index 4e5ebe1d..aac46315 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/mob/CitizensMobProvider.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/mob/CitizensMobProvider.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.mob;
import io.github.dre2n.commons.util.NumberUtil;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.HashSet;
import java.util.Set;
import net.citizensnpcs.api.CitizensAPI;
@@ -84,7 +84,7 @@ public class CitizensMobProvider implements ExternalMobProvider {
npc.spawn(location);
spawnedNPCs.add(npc);
- GameWorld gameWorld = GameWorld.getByWorld(location.getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(location.getWorld());
new DMob((LivingEntity) npc.getEntity(), gameWorld, null, mob);
}
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/mob/DMob.java b/src/main/java/io/github/dre2n/dungeonsxl/mob/DMob.java
index 5eb41673..71b6b52f 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/mob/DMob.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/mob/DMob.java
@@ -21,7 +21,7 @@ import io.github.dre2n.dungeonsxl.event.dmob.DMobSpawnEvent;
import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.trigger.MobTrigger;
import io.github.dre2n.dungeonsxl.trigger.WaveTrigger;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.Random;
import java.util.Set;
import org.bukkit.Bukkit;
@@ -41,7 +41,7 @@ public class DMob {
private String trigger;
- public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type) {
+ public DMob(LivingEntity entity, DGameWorld gameWorld, DMobType type) {
gameWorld.addDMob(this);
this.entity = entity;
@@ -64,7 +64,7 @@ public class DMob {
}
}
- public DMob(LivingEntity entity, GameWorld gameWorld, DMobType type, String trigger) {
+ public DMob(LivingEntity entity, DGameWorld gameWorld, DMobType type, String trigger) {
this(entity, gameWorld, type);
this.trigger = trigger;
}
@@ -101,7 +101,7 @@ public class DMob {
/* Actions */
public void onDeath(EntityDeathEvent event) {
LivingEntity victim = event.getEntity();
- GameWorld gameWorld = GameWorld.getByWorld(victim.getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(victim.getWorld());
String name = null;
if (gameWorld == null) {
@@ -153,7 +153,7 @@ public class DMob {
/* Statics */
public static DMob getByEntity(Entity entity) {
- GameWorld gameWorld = GameWorld.getByWorld(entity.getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(entity.getWorld());
for (DMob dMob : gameWorld.getDMobs()) {
if (dMob.entity == entity) {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/mob/DMobType.java b/src/main/java/io/github/dre2n/dungeonsxl/mob/DMobType.java
index 3b4a837d..7d9f98ed 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/mob/DMobType.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/mob/DMobType.java
@@ -20,7 +20,7 @@ import io.github.dre2n.commons.util.EnumUtil;
import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.config.DMessages;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
@@ -358,7 +358,7 @@ public class DMobType {
}
/* Actions */
- public void spawn(GameWorld gameWorld, Location loc) {
+ public void spawn(DGameWorld gameWorld, Location loc) {
if (type == null) {
return;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/player/DEditPlayer.java b/src/main/java/io/github/dre2n/dungeonsxl/player/DEditPlayer.java
index e3759f9c..78a5884e 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/player/DEditPlayer.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/player/DEditPlayer.java
@@ -20,7 +20,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerUpdateEvent;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@@ -32,7 +32,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.SignChangeEvent;
/**
- * Represents a player in an EditWorld.
+ * Represents a player in an DEditWorld.
*
* @author Daniel Saukel
*/
@@ -40,7 +40,7 @@ public class DEditPlayer extends DInstancePlayer {
private String[] linesCopy;
- public DEditPlayer(DGlobalPlayer player, EditWorld world) {
+ public DEditPlayer(DGlobalPlayer player, DEditWorld world) {
this(player.getPlayer(), world.getWorld());
}
@@ -50,7 +50,7 @@ public class DEditPlayer extends DInstancePlayer {
player.setGameMode(GameMode.CREATIVE);
clearPlayerData();
- Location teleport = EditWorld.getByWorld(world).getLobbyLocation();
+ Location teleport = DEditWorld.getByWorld(world).getLobbyLocation();
if (teleport == null) {
PlayerUtil.secureTeleport(player, world.getSpawnLocation());
} else {
@@ -95,7 +95,7 @@ public class DEditPlayer extends DInstancePlayer {
}
/**
- * Escape the EditWorld without saving.
+ * Escape the DEditWorld without saving.
*/
public void escape() {
delete();
@@ -137,7 +137,7 @@ public class DEditPlayer extends DInstancePlayer {
getSavePlayer().reset(false);
- EditWorld editWorld = EditWorld.getByWorld(getWorld());
+ DEditWorld editWorld = DEditWorld.getByWorld(getWorld());
if (editWorld != null) {
editWorld.save();
}
@@ -145,7 +145,7 @@ public class DEditPlayer extends DInstancePlayer {
@Override
public void sendMessage(String message) {
- EditWorld editWorld = EditWorld.getByWorld(getWorld());
+ DEditWorld editWorld = DEditWorld.getByWorld(getWorld());
editWorld.sendMessage(message);
for (DGlobalPlayer player : plugin.getDPlayers().getDGlobalPlayers()) {
@@ -162,7 +162,7 @@ public class DEditPlayer extends DInstancePlayer {
boolean locationValid = true;
Location teleportLocation = player.getLocation();
- EditWorld editWorld = EditWorld.getByWorld(getWorld());
+ DEditWorld editWorld = DEditWorld.getByWorld(getWorld());
if (!getPlayer().getWorld().equals(getWorld())) {
locationValid = false;
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java b/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java
index 46e12d60..0985119f 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java
@@ -23,7 +23,6 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishDungeonEvent;
-import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishFloorEvent;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupRewardEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerFinishEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
@@ -38,9 +37,11 @@ import io.github.dre2n.dungeonsxl.requirement.Requirement;
import io.github.dre2n.dungeonsxl.reward.DLootInventory;
import io.github.dre2n.dungeonsxl.reward.Reward;
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.io.File;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.ArrayList;
+import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
@@ -55,7 +56,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
/**
- * Represents a player in a GameWorld.
+ * Represents a player in a DGameWorld.
*
* @author Frank Baumann, Tobias Schmitz, Milan Albrecht, Daniel Saukel
*/
@@ -76,7 +77,7 @@ public class DGamePlayer extends DInstancePlayer {
private int initialLives = -1;
private int lives;
- public DGamePlayer(Player player, GameWorld gameWorld) {
+ public DGamePlayer(Player player, DGameWorld gameWorld) {
this(player, gameWorld.getWorld());
}
@@ -102,7 +103,7 @@ public class DGamePlayer extends DInstancePlayer {
initialLives = rules.getInitialLives();
lives = initialLives;
- Location teleport = GameWorld.getByWorld(world).getLobbyLocation();
+ Location teleport = DGameWorld.getByWorld(world).getLobbyLocation();
if (teleport == null) {
PlayerUtil.secureTeleport(player, world.getSpawnLocation());
} else {
@@ -128,7 +129,7 @@ public class DGamePlayer extends DInstancePlayer {
return false;
}
- GameWorld gameWorld = dGroup.getGameWorld();
+ DGameWorld gameWorld = dGroup.getGameWorld();
if (gameWorld == null) {
return false;
}
@@ -391,7 +392,7 @@ public class DGamePlayer extends DInstancePlayer {
dGroup.removePlayer(getPlayer(), message);
}
- GameWorld gameWorld = GameWorld.getByWorld(getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(getWorld());
Game game = Game.getByGameWorld(gameWorld);
if (game != null) {
if (finished) {
@@ -638,7 +639,7 @@ public class DGamePlayer extends DInstancePlayer {
* @param specifiedFloor
* the name of the next floor
*/
- public void finishFloor(String specifiedFloor) {
+ public void finishFloor(DResourceWorld specifiedFloor) {
MessageUtil.sendMessage(getPlayer(), DMessages.PLAYER_FINISHED_DUNGEON.getMessage());
finished = true;
@@ -680,7 +681,7 @@ public class DGamePlayer extends DInstancePlayer {
DungeonConfig dConfig = dGroup.getDungeon().getConfig();
int random = NumberUtil.generateRandomInt(0, dConfig.getFloors().size());
- String newFloor = dGroup.getUnplayedFloors().get(random);
+ DResourceWorld newFloor = dGroup.getUnplayedFloors().get(random);
if (dConfig.getFloorCount() == dGroup.getFloorCount() - 1) {
newFloor = dConfig.getEndFloor();
@@ -688,18 +689,23 @@ public class DGamePlayer extends DInstancePlayer {
newFloor = specifiedFloor;
}
- DGroupFinishFloorEvent event = new DGroupFinishFloorEvent(dGroup, dGroup.getGameWorld(), newFloor);
+ /*DGroupFinishFloorEvent event = new DGroupFinishFloorEvent(dGroup, dGroup.getGameWorld(), newFloor);
if (event.isCancelled()) {
return;
}
-
+ */
Game game = dGroup.getGameWorld().getGame();
- dGroup.removeUnplayedFloor(dGroup.getMapName());
- dGroup.setMapName(newFloor);
- GameWorld gameWorld = new GameWorld(newFloor);
+ dGroup.removeUnplayedFloor(dGroup.getGameWorld().getResource(), false);
+ dGroup.setMapName(newFloor.getName());
+
+ DGameWorld gameWorld = null;
+ if (newFloor != null) {
+ gameWorld = newFloor.instantiateAsGameWorld();
+ }
dGroup.setGameWorld(gameWorld);
+
for (Player player : dGroup.getPlayers()) {
DGamePlayer dPlayer = getByPlayer(player);
dPlayer.setWorld(gameWorld.getWorld());
@@ -788,7 +794,7 @@ public class DGamePlayer extends DInstancePlayer {
@Override
public void sendMessage(String message) {
- GameWorld gameWorld = GameWorld.getByWorld(getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(getWorld());
gameWorld.sendMessage(message);
for (DGlobalPlayer player : plugin.getDPlayers().getDGlobalPlayers()) {
@@ -814,7 +820,7 @@ public class DGamePlayer extends DInstancePlayer {
boolean kick = false;
boolean triggerAllInDistance = false;
- GameWorld gameWorld = GameWorld.getByWorld(getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(getWorld());
if (!updateSecond) {
if (!getPlayer().getWorld().equals(getWorld())) {
@@ -923,8 +929,8 @@ public class DGamePlayer extends DInstancePlayer {
return null;
}
- public static CopyOnWriteArrayList getByWorld(World world) {
- CopyOnWriteArrayList dPlayers = new CopyOnWriteArrayList<>();
+ public static List getByWorld(World world) {
+ List dPlayers = new ArrayList<>();
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
if (dPlayer.getWorld() == world) {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java b/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java
index 94c17a3a..e4720f12 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java
@@ -33,8 +33,8 @@ import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.requirement.Requirement;
import io.github.dre2n.dungeonsxl.reward.Reward;
import io.github.dre2n.dungeonsxl.task.TimeIsRunningTask;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
-import io.github.dre2n.dungeonsxl.world.Worlds;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@@ -59,13 +59,13 @@ public class DGroup {
private Dungeon dungeon;
private String dungeonName;
private String mapName;
- private List unplayedFloors = new ArrayList<>();
- private GameWorld gameWorld;
+ private List unplayedFloors = new ArrayList<>();
+ private DGameWorld gameWorld;
private boolean playing;
private int floorCount;
private List rewards = new ArrayList<>();
private BukkitTask timeIsRunningTask;
- private String nextFloor;
+ private DResourceWorld nextFloor;
public DGroup(Player player) {
this("Group_" + plugin.getDGroups().size(), player);
@@ -111,7 +111,7 @@ public class DGroup {
dungeon = plugin.getDungeons().getByName(identifier);
if (multiFloor && dungeon != null) {
dungeonName = dungeon.getName();
- mapName = dungeon.getConfig().getStartFloor();
+ mapName = dungeon.getConfig().getStartFloor().getName();
unplayedFloors = dungeon.getConfig().getFloors();
} else {
@@ -343,7 +343,7 @@ public class DGroup {
/**
* @return the gameWorld
*/
- public GameWorld getGameWorld() {
+ public DGameWorld getGameWorld() {
return gameWorld;
}
@@ -351,7 +351,7 @@ public class DGroup {
* @param gameWorld
* the gameWorld to set
*/
- public void setGameWorld(GameWorld gameWorld) {
+ public void setGameWorld(DGameWorld gameWorld) {
this.gameWorld = gameWorld;
}
@@ -380,7 +380,7 @@ public class DGroup {
dungeon = plugin.getDungeons().getByName(name);
if (dungeon != null) {
dungeonName = dungeon.getName();
- mapName = dungeon.getConfig().getStartFloor();
+ mapName = dungeon.getConfig().getStartFloor().getName();
unplayedFloors = dungeon.getConfig().getFloors();
} else {
@@ -422,32 +422,34 @@ public class DGroup {
* the name to set
*/
public void setMapName(String name) {
- if (Worlds.exists(name)) {
+ if (plugin.getDWorlds().exists(name)) {
mapName = name;
}
}
/**
- * @return the unplayedFloors
+ * @return the unplayed floors
*/
- public List getUnplayedFloors() {
+ public List getUnplayedFloors() {
return unplayedFloors;
}
/**
* @param unplayedFloor
- * the unplayedFloor to add
+ * the unplayed floor to add
*/
- public void addUnplayedFloor(String unplayedFloor) {
+ public void addUnplayedFloor(DResourceWorld unplayedFloor) {
unplayedFloors.add(unplayedFloor);
}
/**
* @param unplayedFloor
- * the unplayedFloor to add
+ * the unplayed floor to remove
+ * @param force
+ * remove the floor even if removeWhenPlayed is disabled
*/
- public void removeUnplayedFloor(String unplayedFloor) {
- if (getDungeon().getConfig().getRemoveWhenPlayed()) {
+ public void removeUnplayedFloor(DResourceWorld unplayedFloor, boolean force) {
+ if (getDungeon().getConfig().getRemoveWhenPlayed() || force) {
unplayedFloors.remove(unplayedFloor);
}
}
@@ -544,7 +546,7 @@ public class DGroup {
/**
* @return the next floor the group will enter
*/
- public String getNextFloor() {
+ public DResourceWorld getNextFloor() {
return nextFloor;
}
@@ -552,7 +554,7 @@ public class DGroup {
* @param floor
* the next floor to set
*/
- public void setNextFloor(String floor) {
+ public void setNextFloor(DResourceWorld floor) {
nextFloor = floor;
}
@@ -779,10 +781,10 @@ public class DGroup {
/**
* @param gameWorld
- * the GameWorld to check
- * @return a List of DGroups in this GameWorld
+ * the DGameWorld to check
+ * @return a List of DGroups in this DGameWorld
*/
- public static List getByGameWorld(GameWorld gameWorld) {
+ public static List getByGameWorld(DGameWorld gameWorld) {
List dGroups = new ArrayList<>();
for (DGroup dGroup : plugin.getDGroups()) {
if (dGroup.getGameWorld().equals(gameWorld)) {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/reward/RewardChest.java b/src/main/java/io/github/dre2n/dungeonsxl/reward/RewardChest.java
index 675ffcb0..e85f2443 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/reward/RewardChest.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/reward/RewardChest.java
@@ -21,7 +21,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import net.milkbowl.vault.item.ItemInfo;
import net.milkbowl.vault.item.Items;
import org.bukkit.Bukkit;
@@ -43,11 +43,11 @@ public class RewardChest {
// Variables
private boolean used = false;
private Chest chest;
- private GameWorld gameWorld;
+ private DGameWorld gameWorld;
private double moneyReward;
private int levelReward;
- public RewardChest(Block chest, GameWorld gameWorld, double moneyReward, int levelReward) {
+ public RewardChest(Block chest, DGameWorld gameWorld, double moneyReward, int levelReward) {
if (!(chest.getState() instanceof Chest)) {
return;
}
@@ -93,7 +93,7 @@ public class RewardChest {
/**
* @return the gameWorld
*/
- public GameWorld getGameWorld() {
+ public DGameWorld getGameWorld() {
return gameWorld;
}
@@ -101,7 +101,7 @@ public class RewardChest {
* @param gameWorld
* the gameWorld to set
*/
- public void setGameWorld(GameWorld gameWorld) {
+ public void setGameWorld(DGameWorld gameWorld) {
this.gameWorld = gameWorld;
}
@@ -227,7 +227,7 @@ public class RewardChest {
public static void onOpenInventory(InventoryOpenEvent event) {
InventoryView inventory = event.getView();
- GameWorld gameWorld = GameWorld.getByWorld(event.getPlayer().getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(event.getPlayer().getWorld());
if (gameWorld == null) {
return;
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/BlockSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/BlockSign.java
index a9341742..1351e43f 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/BlockSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/BlockSign.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -36,7 +36,7 @@ public class BlockSign extends DSign {
private byte offBlockData = 0x0;
private byte onBlockData = 0x0;
- public BlockSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public BlockSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/CheckpointSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/CheckpointSign.java
index 063f6f2d..d6e369e3 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/CheckpointSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/CheckpointSign.java
@@ -19,7 +19,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -36,7 +36,7 @@ public class CheckpointSign extends DSign {
private boolean initialized;
private CopyOnWriteArrayList done = new CopyOnWriteArrayList<>();
- public CheckpointSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public CheckpointSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/ChestSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/ChestSign.java
index cee4b114..cbdc08fa 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/ChestSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/ChestSign.java
@@ -18,7 +18,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.reward.RewardChest;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -33,7 +33,7 @@ public class ChestSign extends DSign {
private double moneyReward;
private int levelReward;
- public ChestSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public ChestSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/ChunkUpdaterSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/ChunkUpdaterSign.java
index dc248490..83cf156a 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/ChunkUpdaterSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/ChunkUpdaterSign.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -29,7 +29,7 @@ public class ChunkUpdaterSign extends DSign {
private DSignType type = DSignTypeDefault.CHUNK_UPDATER;
- public ChunkUpdaterSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public ChunkUpdaterSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/ClassesSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/ClassesSign.java
index b8f886d8..13eba0ff 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/ClassesSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/ClassesSign.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.player.DClass;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.ChatColor;
import org.bukkit.block.Sign;
@@ -30,7 +30,7 @@ public class ClassesSign extends DSign {
private DClass dClass;
- public ClassesSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public ClassesSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
dClass = plugin.getDClasses().getByName(sign.getLine(1));
}
@@ -65,7 +65,7 @@ public class ClassesSign extends DSign {
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update();
- getGameWorld().getSignClass().add(getSign());
+ getGameWorld().getClassesSigns().add(getSign());
}
@Override
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/CommandSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/CommandSign.java
index 46b9d7d1..fcb85d19 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/CommandSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/CommandSign.java
@@ -21,7 +21,7 @@ import io.github.dre2n.commandsxl.command.CCommand;
import io.github.dre2n.commandsxl.command.CCommandExecutorTask;
import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -44,7 +44,7 @@ public class CommandSign extends DSign {
private String executor;
private boolean initialized;
- public CommandSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public CommandSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/DMobSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/DMobSign.java
index ce11502c..df42f7ac 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/DMobSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/DMobSign.java
@@ -18,7 +18,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.task.MobSpawnTask;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.scheduler.BukkitTask;
@@ -40,7 +40,7 @@ public class DMobSign extends DSign implements MobSign {
private boolean active;
private BukkitTask task;
- public DMobSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public DMobSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/DSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/DSign.java
index fb1549a4..f978b45b 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/DSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/DSign.java
@@ -21,7 +21,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.dsign.DSignRegistrationEvent;
import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.trigger.Trigger;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
@@ -38,12 +38,12 @@ public abstract class DSign {
private Sign sign;
protected String[] lines;
- private GameWorld gameWorld;
+ private DGameWorld gameWorld;
// List of Triggers
private Set triggers = new HashSet<>();
- public DSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public DSign(Sign sign, String[] lines, DGameWorld gameWorld) {
this.sign = sign;
this.lines = lines;
this.gameWorld = gameWorld;
@@ -108,7 +108,7 @@ public abstract class DSign {
/**
* @return the gameWorld
*/
- public GameWorld getGameWorld() {
+ public DGameWorld getGameWorld() {
return gameWorld;
}
@@ -185,11 +185,11 @@ public abstract class DSign {
return !triggers.isEmpty();
}
- public static DSign create(Sign sign, GameWorld gameWorld) {
+ public static DSign create(Sign sign, DGameWorld gameWorld) {
return create(sign, sign.getLines(), gameWorld);
}
- public static DSign create(Sign sign, String[] lines, GameWorld gameWorld) {
+ public static DSign create(Sign sign, String[] lines, DGameWorld gameWorld) {
DSign dSign = null;
for (DSignType type : plugin.getDSigns().getDSigns()) {
@@ -198,7 +198,7 @@ public abstract class DSign {
}
try {
- Constructor extends DSign> constructor = type.getHandler().getConstructor(Sign.class, String[].class, GameWorld.class);
+ Constructor extends DSign> constructor = type.getHandler().getConstructor(Sign.class, String[].class, DGameWorld.class);
dSign = constructor.newInstance(sign, lines, gameWorld);
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/DropSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/DropSign.java
index 25e32dec..8817bd53 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/DropSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/DropSign.java
@@ -19,7 +19,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.caliburn.item.UniversalItem;
import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.task.DropItemTask;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -35,7 +35,7 @@ public class DropSign extends DSign {
private ItemStack item;
private double interval = -1;
- public DropSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public DropSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/EndSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/EndSign.java
index a9d8079b..239860fc 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/EndSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/EndSign.java
@@ -18,7 +18,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -31,7 +31,7 @@ public class EndSign extends DSign {
private DSignType type = DSignTypeDefault.END;
- public EndSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public EndSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/ExternalMobSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/ExternalMobSign.java
index 53011478..c3bdfd1d 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/ExternalMobSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/ExternalMobSign.java
@@ -20,7 +20,7 @@ import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.mob.ExternalMobPlugin;
import io.github.dre2n.dungeonsxl.mob.ExternalMobProvider;
import io.github.dre2n.dungeonsxl.task.ExternalMobSpawnTask;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
@@ -52,7 +52,7 @@ public class ExternalMobSign extends DSign implements MobSign {
private LivingEntity externalMob;
private List externalMobs = new ArrayList<>();
- public ExternalMobSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public ExternalMobSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/FloorSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/FloorSign.java
index 26464656..496cbf97 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/FloorSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/FloorSign.java
@@ -18,7 +18,8 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -31,12 +32,27 @@ public class FloorSign extends DSign {
private DSignType type = DSignTypeDefault.FLOOR;
- private String floor;
+ private DResourceWorld floor;
- public FloorSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public FloorSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
+ /**
+ * @return the next floor
+ */
+ public DResourceWorld getFloor() {
+ return floor;
+ }
+
+ /**
+ * @param floor
+ * the floor to set
+ */
+ public void setFloor(DResourceWorld floor) {
+ this.floor = floor;
+ }
+
@Override
public boolean check() {
return true;
@@ -45,7 +61,7 @@ public class FloorSign extends DSign {
@Override
public void onInit() {
if (!lines[1].isEmpty()) {
- floor = lines[1];
+ floor = plugin.getDWorlds().getResourceByName(lines[1]);
}
if (!getTriggers().isEmpty()) {
@@ -64,7 +80,7 @@ public class FloorSign extends DSign {
if (floor == null) {
getSign().setLine(2, ChatColor.DARK_GREEN + "NEXT FLOOR");
} else {
- getSign().setLine(2, ChatColor.DARK_GREEN + floor.replaceAll("_", " "));
+ getSign().setLine(2, ChatColor.DARK_GREEN + floor.getName().replaceAll("_", " "));
}
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update();
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/HologramSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/HologramSign.java
index 1ff47521..31fee962 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/HologramSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/HologramSign.java
@@ -23,7 +23,7 @@ import io.github.dre2n.commons.compatibility.CompatibilityHandler;
import io.github.dre2n.commons.compatibility.Version;
import io.github.dre2n.commons.util.EnumUtil;
import io.github.dre2n.commons.util.NumberUtil;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -39,7 +39,7 @@ public class HologramSign extends DSign {
private Hologram hologram;
- public HologramSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public HologramSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/InteractSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/InteractSign.java
index 5d8dad6f..5029d2f0 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/InteractSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/InteractSign.java
@@ -19,8 +19,8 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.task.SignUpdateTask;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.ChatColor;
@@ -35,14 +35,14 @@ public class InteractSign extends DSign {
private DSignType type = DSignTypeDefault.INTERACT;
- public InteractSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public InteractSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
@Override
public boolean check() {
Set used = new HashSet<>();
- for (Block block : EditWorld.getByWorld(getSign().getLocation().getWorld()).getSigns()) {
+ for (Block block : DEditWorld.getByWorld(getSign().getLocation().getWorld()).getSigns()) {
if (block == null) {
continue;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/LeaveSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/LeaveSign.java
index 68f879fc..c04bde0b 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/LeaveSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/LeaveSign.java
@@ -19,7 +19,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEscapeEvent;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -32,7 +32,7 @@ public class LeaveSign extends DSign {
private DSignType type = DSignTypeDefault.LEAVE;
- public LeaveSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public LeaveSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/LivesModifierSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/LivesModifierSign.java
index 5c2e73c9..9772916d 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/LivesModifierSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/LivesModifierSign.java
@@ -23,7 +23,7 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
@@ -44,7 +44,7 @@ public class LivesModifierSign extends DSign {
private int lives;
private Target target;
- public LivesModifierSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public LivesModifierSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/LobbySign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/LobbySign.java
index 8c830ed0..c01301ce 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/LobbySign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/LobbySign.java
@@ -16,7 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.sign;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -27,7 +27,7 @@ public class LobbySign extends DSign {
private DSignType type = DSignTypeDefault.LOBBY;
- public LobbySign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public LobbySign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/MessageSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/MessageSign.java
index eefef108..2e6f774c 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/MessageSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/MessageSign.java
@@ -18,7 +18,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -36,7 +36,7 @@ public class MessageSign extends DSign {
private boolean initialized;
private CopyOnWriteArrayList done = new CopyOnWriteArrayList<>();
- public MessageSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public MessageSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/OpenDoorSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/OpenDoorSign.java
index 6ecf4111..942b1272 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/OpenDoorSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/OpenDoorSign.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.BlockUtil;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -33,7 +33,7 @@ public class OpenDoorSign extends DSign {
private Block block;
- public OpenDoorSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public OpenDoorSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
@@ -95,7 +95,7 @@ public class OpenDoorSign extends DSign {
* true if the block is openable only with a sign
*/
public static boolean isProtected(Block block) {
- GameWorld gameWorld = GameWorld.getByWorld(block.getWorld());
+ DGameWorld gameWorld = DGameWorld.getByWorld(block.getWorld());
if (gameWorld != null) {
for (DSign dSign : gameWorld.getDSigns(DSignTypeDefault.OPEN_DOOR)) {
Block signBlock1 = ((OpenDoorSign) dSign).getBlock();
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/PlaceSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/PlaceSign.java
index 1668888c..a79527d6 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/PlaceSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/PlaceSign.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.game.GamePlaceableBlock;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -28,7 +28,7 @@ public class PlaceSign extends DSign {
private DSignType type = DSignTypeDefault.PLACE;
- public PlaceSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public PlaceSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/ReadySign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/ReadySign.java
index fc146470..4be6b8ef 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/ReadySign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/ReadySign.java
@@ -25,7 +25,7 @@ import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.util.ProgressBar;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -43,7 +43,7 @@ public class ReadySign extends DSign {
private double autoStart = -1;
private boolean triggered = false;
- public ReadySign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public ReadySign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
@@ -155,7 +155,7 @@ public class ReadySign extends DSign {
return;
}
- if (getGameWorld().getSignClass().isEmpty() || dPlayer.getDClass() != null) {
+ if (getGameWorld().getClassesSigns().isEmpty() || dPlayer.getDClass() != null) {
GameType forced = getGameWorld().getConfig().getForcedGameType();
dPlayer.ready(forced == null ? gameType : forced);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/RedstoneSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/RedstoneSign.java
index e82b08fd..e5ff08b8 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/RedstoneSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/RedstoneSign.java
@@ -18,7 +18,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.task.DelayedPowerTask;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
@@ -42,7 +42,7 @@ public class RedstoneSign extends DSign {
private int repeat = 1;
private int repeatsToDo = 1;
- public RedstoneSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public RedstoneSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/ScriptSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/ScriptSign.java
index 2df15f55..ae0f1c86 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/ScriptSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/ScriptSign.java
@@ -16,7 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.sign;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -29,7 +29,7 @@ public class ScriptSign extends DSign {
private String name;
- public ScriptSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public ScriptSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
name = lines[1];
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/SoundMessageSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/SoundMessageSign.java
index e7307f1d..06a92083 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/SoundMessageSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/SoundMessageSign.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -35,7 +35,7 @@ public class SoundMessageSign extends DSign {
private String msg;
private CopyOnWriteArrayList done = new CopyOnWriteArrayList<>();
- public SoundMessageSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public SoundMessageSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/StartSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/StartSign.java
index 1f435b10..77aafff9 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/StartSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/StartSign.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -30,7 +30,7 @@ public class StartSign extends DSign {
private int id;
- public StartSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public StartSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/TeleportSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/TeleportSign.java
index 9117514b..f431b45a 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/TeleportSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/TeleportSign.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -32,7 +32,7 @@ public class TeleportSign extends DSign {
private Location location;
- public TeleportSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public TeleportSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/TriggerSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/TriggerSign.java
index 52c919d1..e72e2eb4 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/TriggerSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/TriggerSign.java
@@ -19,8 +19,8 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.task.SignUpdateTask;
import io.github.dre2n.dungeonsxl.trigger.SignTrigger;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Material;
@@ -38,14 +38,14 @@ public class TriggerSign extends DSign {
private int triggerId;
private boolean initialized;
- public TriggerSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public TriggerSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
@Override
public boolean check() {
Set used = new HashSet<>();
- for (Block block : EditWorld.getByWorld(getSign().getLocation().getWorld()).getSigns()) {
+ for (Block block : DEditWorld.getByWorld(getSign().getLocation().getWorld()).getSigns()) {
if (block == null) {
continue;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/WaveSign.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/WaveSign.java
index ca17eb99..b4239816 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/WaveSign.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/WaveSign.java
@@ -18,7 +18,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Sign;
@@ -34,7 +34,7 @@ public class WaveSign extends DSign {
private double mobCountIncreaseRate;
private boolean teleport;
- public WaveSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public WaveSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/task/DelayedPowerTask.java b/src/main/java/io/github/dre2n/dungeonsxl/task/DelayedPowerTask.java
index 9520c78b..ff4a85e8 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/task/DelayedPowerTask.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/task/DelayedPowerTask.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.sign.RedstoneSign;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.scheduler.BukkitRunnable;
/**
@@ -35,7 +35,7 @@ public class DelayedPowerTask extends BukkitRunnable {
@Override
public void run() {
- if (GameWorld.getByWorld(sign.getBlock().getWorld()) == null) {
+ if (DGameWorld.getByWorld(sign.getBlock().getWorld()) == null) {
sign.getEnableTask().cancel();
sign.getDisableTask().cancel();
return;
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/task/ExternalMobSpawnTask.java b/src/main/java/io/github/dre2n/dungeonsxl/task/ExternalMobSpawnTask.java
index 6440223f..e2b0f21c 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/task/ExternalMobSpawnTask.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/task/ExternalMobSpawnTask.java
@@ -19,7 +19,7 @@ package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.mob.ExternalMobProvider;
import io.github.dre2n.dungeonsxl.sign.ExternalMobSign;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitRunnable;
@@ -40,7 +40,7 @@ public class ExternalMobSpawnTask extends BukkitRunnable {
public void run() {
if (sign.getInterval() <= 0) {
World world = sign.getSign().getWorld();
- GameWorld gameWorld = GameWorld.getByWorld(world);
+ DGameWorld gameWorld = DGameWorld.getByWorld(world);
if (gameWorld != null) {
sign.setSpawnLocation(sign.getSign().getLocation().add(0.5, 0, 0.5));
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/task/LazyUpdateTask.java b/src/main/java/io/github/dre2n/dungeonsxl/task/LazyUpdateTask.java
index a4941578..c65a777e 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/task/LazyUpdateTask.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/task/LazyUpdateTask.java
@@ -18,7 +18,7 @@ package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.scheduler.BukkitRunnable;
/**
@@ -30,7 +30,7 @@ public class LazyUpdateTask extends BukkitRunnable {
@Override
public void run() {
- for (GameWorld gameWorld : plugin.getGameWorlds()) {
+ for (DGameWorld gameWorld : plugin.getDWorlds().getGameWorlds()) {
gameWorld.update();
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/task/MobSpawnTask.java b/src/main/java/io/github/dre2n/dungeonsxl/task/MobSpawnTask.java
index 3e89bdc3..ccc4de9d 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/task/MobSpawnTask.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/task/MobSpawnTask.java
@@ -20,7 +20,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.mob.DMobType;
import io.github.dre2n.dungeonsxl.sign.DMobSign;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@@ -46,7 +46,7 @@ public class MobSpawnTask extends BukkitRunnable {
public void run() {
if (sign.getInterval() <= 0) {
World world = sign.getSign().getWorld();
- GameWorld gameWorld = GameWorld.getByWorld(world);
+ DGameWorld gameWorld = DGameWorld.getByWorld(world);
if (gameWorld != null) {
Location spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5);
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/task/RedstoneEventTask.java b/src/main/java/io/github/dre2n/dungeonsxl/task/RedstoneEventTask.java
index 4e138e48..c4ce6bd5 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/task/RedstoneEventTask.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/task/RedstoneEventTask.java
@@ -18,7 +18,7 @@ package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.block.Block;
import org.bukkit.scheduler.BukkitRunnable;
@@ -35,7 +35,7 @@ public class RedstoneEventTask extends BukkitRunnable {
@Override
public void run() {
- for (GameWorld gameWorld : DungeonsXL.getInstance().getGameWorlds()) {
+ for (DGameWorld gameWorld : DungeonsXL.getInstance().getDWorlds().getGameWorlds()) {
if (block.getWorld() == gameWorld.getWorld()) {
RedstoneTrigger.updateAll(gameWorld);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/task/WorldUnloadTask.java b/src/main/java/io/github/dre2n/dungeonsxl/task/WorldUnloadTask.java
index 84f04b3b..3fc03f6e 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/task/WorldUnloadTask.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/task/WorldUnloadTask.java
@@ -18,8 +18,8 @@ package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
-import io.github.dre2n.dungeonsxl.world.EditWorld;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DEditWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.scheduler.BukkitRunnable;
/**
@@ -31,7 +31,7 @@ public class WorldUnloadTask extends BukkitRunnable {
@Override
public void run() {
- for (GameWorld gameWorld : plugin.getGameWorlds()) {
+ for (DGameWorld gameWorld : plugin.getDWorlds().getGameWorlds()) {
if (gameWorld.getWorld().getPlayers().isEmpty()) {
if (DGamePlayer.getByWorld(gameWorld.getWorld()).isEmpty()) {
gameWorld.delete();
@@ -39,9 +39,9 @@ public class WorldUnloadTask extends BukkitRunnable {
}
}
- for (EditWorld editWorld : plugin.getEditWorlds()) {
+ for (DEditWorld editWorld : plugin.getDWorlds().getEditWorlds()) {
if (editWorld.getWorld().getPlayers().isEmpty()) {
- editWorld.delete();
+ editWorld.delete(true);
}
}
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/trigger/DistanceTrigger.java b/src/main/java/io/github/dre2n/dungeonsxl/trigger/DistanceTrigger.java
index f7b6e903..69d0f181 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/trigger/DistanceTrigger.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/trigger/DistanceTrigger.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -61,7 +61,7 @@ public class DistanceTrigger extends Trigger {
}
/* Statics */
- public static void triggerAllInDistance(Player player, GameWorld gameWorld) {
+ public static void triggerAllInDistance(Player player, DGameWorld gameWorld) {
if (!player.getLocation().getWorld().equals(gameWorld.getWorld())) {
return;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/trigger/InteractTrigger.java b/src/main/java/io/github/dre2n/dungeonsxl/trigger/InteractTrigger.java
index 4d99444d..5a3794e2 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/trigger/InteractTrigger.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/trigger/InteractTrigger.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -55,7 +55,7 @@ public class InteractTrigger extends Trigger {
}
/* Statics */
- public static InteractTrigger getOrCreate(int id, GameWorld gameWorld) {
+ public static InteractTrigger getOrCreate(int id, DGameWorld gameWorld) {
if (id == 0) {
return null;
}
@@ -66,7 +66,7 @@ public class InteractTrigger extends Trigger {
return new InteractTrigger(id, null);
}
- public static InteractTrigger getOrCreate(int id, Block block, GameWorld gameWorld) {
+ public static InteractTrigger getOrCreate(int id, Block block, DGameWorld gameWorld) {
InteractTrigger trigger = getById(id, gameWorld);
if (trigger != null) {
trigger.interactBlock = block;
@@ -75,7 +75,7 @@ public class InteractTrigger extends Trigger {
return new InteractTrigger(id, block);
}
- public static InteractTrigger getByBlock(Block block, GameWorld gameWorld) {
+ public static InteractTrigger getByBlock(Block block, DGameWorld gameWorld) {
for (Trigger uncasted : gameWorld.getTriggers(TriggerTypeDefault.INTERACT)) {
InteractTrigger trigger = (InteractTrigger) uncasted;
if (trigger.interactBlock != null) {
@@ -87,7 +87,7 @@ public class InteractTrigger extends Trigger {
return null;
}
- public static InteractTrigger getById(int id, GameWorld gameWorld) {
+ public static InteractTrigger getById(int id, DGameWorld gameWorld) {
if (id != 0) {
for (Trigger uncasted : gameWorld.getTriggers(TriggerTypeDefault.INTERACT)) {
InteractTrigger trigger = (InteractTrigger) uncasted;
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/trigger/MobTrigger.java b/src/main/java/io/github/dre2n/dungeonsxl/trigger/MobTrigger.java
index 374bbc6c..37cf0f4d 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/trigger/MobTrigger.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/trigger/MobTrigger.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
/**
* @author Frank Baumann, Daniel Saukel
@@ -50,7 +50,7 @@ public class MobTrigger extends Trigger {
}
/* Statics */
- public static MobTrigger getOrCreate(String name, GameWorld gameWorld) {
+ public static MobTrigger getOrCreate(String name, DGameWorld gameWorld) {
MobTrigger trigger = getByName(name, gameWorld);
if (trigger != null) {
return trigger;
@@ -58,7 +58,7 @@ public class MobTrigger extends Trigger {
return new MobTrigger(name);
}
- public static MobTrigger getByName(String name, GameWorld gameWorld) {
+ public static MobTrigger getByName(String name, DGameWorld gameWorld) {
for (Trigger uncasted : gameWorld.getTriggers(TriggerTypeDefault.MOB)) {
MobTrigger trigger = (MobTrigger) uncasted;
if (trigger.name.equalsIgnoreCase(name)) {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/trigger/ProgressTrigger.java b/src/main/java/io/github/dre2n/dungeonsxl/trigger/ProgressTrigger.java
index 41f552a3..d66f2d80 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/trigger/ProgressTrigger.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/trigger/ProgressTrigger.java
@@ -17,7 +17,8 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.util.HashSet;
import java.util.Set;
@@ -28,7 +29,7 @@ public class ProgressTrigger extends Trigger {
private TriggerType type = TriggerTypeDefault.PROGRESS;
- private String floor;
+ private DResourceWorld floor;
private int floorCount;
private int waveCount;
@@ -37,7 +38,7 @@ public class ProgressTrigger extends Trigger {
this.waveCount = waveCount;
}
- public ProgressTrigger(String floor) {
+ public ProgressTrigger(DResourceWorld floor) {
this.floor = floor;
}
@@ -45,7 +46,7 @@ public class ProgressTrigger extends Trigger {
/**
* @return the specific floor that must be finished
*/
- public String getFloor() {
+ public DResourceWorld getFloor() {
return floor;
}
@@ -53,7 +54,7 @@ public class ProgressTrigger extends Trigger {
* @param floor
* the specific floor to set
*/
- public void setFloor(String floor) {
+ public void setFloor(DResourceWorld floor) {
this.floor = floor;
}
@@ -106,18 +107,25 @@ public class ProgressTrigger extends Trigger {
}
/* Statics */
- public static ProgressTrigger getOrCreate(int floorCount, int waveCount, GameWorld gameWorld) {
+ public static ProgressTrigger getOrCreate(int floorCount, int waveCount, DGameWorld gameWorld) {
if (floorCount == 0 & waveCount == 0 || floorCount < 0 || waveCount < 0) {
return null;
}
return new ProgressTrigger(floorCount, waveCount);
}
- public static ProgressTrigger getOrCreate(String floor, GameWorld gameWorld) {
- return new ProgressTrigger(floor);
+ public static ProgressTrigger getOrCreate(String floor, DGameWorld gameWorld) {
+ DResourceWorld resource = plugin.getDWorlds().getResourceByName(floor);
+
+ if (resource != null) {
+ return new ProgressTrigger(resource);
+
+ } else {
+ return null;
+ }
}
- public static Set getByGameWorld(GameWorld gameWorld) {
+ public static Set getByGameWorld(DGameWorld gameWorld) {
Set toReturn = new HashSet<>();
for (Trigger trigger : gameWorld.getTriggers(TriggerTypeDefault.PROGRESS)) {
toReturn.add((ProgressTrigger) trigger);
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/trigger/RedstoneTrigger.java b/src/main/java/io/github/dre2n/dungeonsxl/trigger/RedstoneTrigger.java
index bfdf38e3..b264bd88 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/trigger/RedstoneTrigger.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/trigger/RedstoneTrigger.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -62,7 +62,7 @@ public class RedstoneTrigger extends Trigger {
}
/* Statics */
- public static RedstoneTrigger getOrCreate(Sign sign, GameWorld gameWorld) {
+ public static RedstoneTrigger getOrCreate(Sign sign, DGameWorld gameWorld) {
Block rtBlock = null;
if (sign.getBlock().getType() == Material.WALL_SIGN) {
switch (sign.getData().getData()) {
@@ -96,7 +96,7 @@ public class RedstoneTrigger extends Trigger {
return null;
}
- public static void updateAll(GameWorld gameWorld) {
+ public static void updateAll(DGameWorld gameWorld) {
for (Trigger trigger : gameWorld.getTriggers(TriggerTypeDefault.REDSTONE)) {
((RedstoneTrigger) trigger).onTrigger();
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/trigger/SignTrigger.java b/src/main/java/io/github/dre2n/dungeonsxl/trigger/SignTrigger.java
index 15e52dbf..5dc11a55 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/trigger/SignTrigger.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/trigger/SignTrigger.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
/**
* @author Frank Baumann, Daniel Saukel
@@ -52,7 +52,7 @@ public class SignTrigger extends Trigger {
}
/* Statics */
- public static SignTrigger getOrCreate(int id, GameWorld gameWorld) {
+ public static SignTrigger getOrCreate(int id, DGameWorld gameWorld) {
SignTrigger trigger = getById(id, gameWorld);
if (trigger != null) {
return trigger;
@@ -60,7 +60,7 @@ public class SignTrigger extends Trigger {
return new SignTrigger(id);
}
- public static SignTrigger getById(int id, GameWorld gameWorld) {
+ public static SignTrigger getById(int id, DGameWorld gameWorld) {
for (Trigger uncasted : gameWorld.getTriggers(TriggerTypeDefault.SIGN)) {
SignTrigger trigger = (SignTrigger) uncasted;
if (trigger.stId == id) {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/trigger/Trigger.java b/src/main/java/io/github/dre2n/dungeonsxl/trigger/Trigger.java
index 66ada342..8f40a684 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/trigger/Trigger.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/trigger/Trigger.java
@@ -21,7 +21,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerRegistrationEvent;
import io.github.dre2n.dungeonsxl.sign.DSign;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashSet;
@@ -113,11 +113,11 @@ public abstract class Trigger {
}
}
- public void register(GameWorld gameWorld) {
+ public void register(DGameWorld gameWorld) {
gameWorld.addTrigger(this);
}
- public void unregister(GameWorld gameWorld) {
+ public void unregister(DGameWorld gameWorld) {
gameWorld.removeTrigger(this);
}
@@ -185,7 +185,7 @@ public abstract class Trigger {
Method method;
try {
- method = type.getHandler().getDeclaredMethod("getOrCreate", String.class, GameWorld.class);
+ method = type.getHandler().getDeclaredMethod("getOrCreate", String.class, DGameWorld.class);
trigger = (Trigger) method.invoke(value, dSign.getGameWorld());
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/trigger/UseItemTrigger.java b/src/main/java/io/github/dre2n/dungeonsxl/trigger/UseItemTrigger.java
index 05c5b63d..03750393 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/trigger/UseItemTrigger.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/trigger/UseItemTrigger.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -58,7 +58,7 @@ public class UseItemTrigger extends Trigger {
}
/* Statics */
- public static UseItemTrigger getOrCreate(String name, GameWorld gameWorld) {
+ public static UseItemTrigger getOrCreate(String name, DGameWorld gameWorld) {
UseItemTrigger trigger = getByName(name, gameWorld);
if (trigger != null) {
return trigger;
@@ -66,7 +66,7 @@ public class UseItemTrigger extends Trigger {
return new UseItemTrigger(name);
}
- public static UseItemTrigger getByName(String name, GameWorld gameWorld) {
+ public static UseItemTrigger getByName(String name, DGameWorld gameWorld) {
for (Trigger uncasted : gameWorld.getTriggers(TriggerTypeDefault.USE_ITEM)) {
UseItemTrigger trigger = (UseItemTrigger) uncasted;
if (trigger.name.equalsIgnoreCase(name)) {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/trigger/WaveTrigger.java b/src/main/java/io/github/dre2n/dungeonsxl/trigger/WaveTrigger.java
index 1fc21c70..3c98461b 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/trigger/WaveTrigger.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/trigger/WaveTrigger.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.HashSet;
import java.util.Set;
@@ -68,14 +68,14 @@ public class WaveTrigger extends Trigger {
}
/* Statics */
- public static WaveTrigger getOrCreate(double mustKillRate, GameWorld gameWorld) {
+ public static WaveTrigger getOrCreate(double mustKillRate, DGameWorld gameWorld) {
return new WaveTrigger(mustKillRate);
}
/**
- * @return the WaveTriggers in the GameWorld
+ * @return the WaveTriggers in the DGameWorld
*/
- public static Set getByGameWorld(GameWorld gameWorld) {
+ public static Set getByGameWorld(DGameWorld gameWorld) {
Set toReturn = new HashSet<>();
for (Trigger trigger : gameWorld.getTriggers()) {
toReturn.add((WaveTrigger) trigger);
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/world/DEditWorld.java b/src/main/java/io/github/dre2n/dungeonsxl/world/DEditWorld.java
new file mode 100644
index 00000000..0919e130
--- /dev/null
+++ b/src/main/java/io/github/dre2n/dungeonsxl/world/DEditWorld.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2012-2016 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 .
+ */
+package io.github.dre2n.dungeonsxl.world;
+
+import io.github.dre2n.commons.util.FileUtil;
+import io.github.dre2n.dungeonsxl.DungeonsXL;
+import io.github.dre2n.dungeonsxl.event.editworld.EditWorldSaveEvent;
+import io.github.dre2n.dungeonsxl.event.editworld.EditWorldUnloadEvent;
+import io.github.dre2n.dungeonsxl.player.DEditPlayer;
+import java.io.File;
+import java.io.IOException;
+import java.util.concurrent.CopyOnWriteArrayList;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.block.Sign;
+import org.bukkit.entity.Player;
+
+/**
+ * @author Frank Baumann, Daniel Saukel
+ */
+public class DEditWorld extends DInstanceWorld {
+
+ static DWorlds worlds = plugin.getDWorlds();
+
+ private CopyOnWriteArrayList signs = new CopyOnWriteArrayList<>();
+
+ DEditWorld(DResourceWorld resourceWorld, File folder, World world, int id) {
+ super(resourceWorld, folder, world, id);
+ }
+
+ /* Getters and setters */
+ /**
+ * @return the signs
+ */
+ public CopyOnWriteArrayList getSigns() {
+ return signs;
+ }
+
+ /**
+ * @param sign
+ * the sign to set
+ */
+ public void setSigns(CopyOnWriteArrayList signs) {
+ this.signs = signs;
+ }
+
+ /* Actions */
+ /**
+ * Registers the block as a DSign sothat it can later be saved persistently.
+ *
+ * @param block
+ * a DSign block
+ */
+ public void registerSign(Block block) {
+ if (block.getState() instanceof Sign) {
+ Sign sign = (Sign) block.getState();
+ String[] lines = sign.getLines();
+
+ if (lines[0].equalsIgnoreCase("[lobby]")) {
+ setLobbyLocation(block.getLocation());
+ }
+ }
+ }
+
+ /**
+ * Saves the sign data and overrides the resource with the changes.
+ */
+ public void save() {
+ EditWorldSaveEvent event = new EditWorldSaveEvent(this);
+ plugin.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+
+ getWorld().save();
+
+ FileUtil.copyDirectory(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
+ FileUtil.deleteUnusedFiles(getResource().getFolder());
+
+ try {
+ getResource().getSignData().serializeSigns(signs);
+ } catch (IOException exception) {
+ }
+ }
+
+ @Override
+ public void delete() {
+ delete(true);
+ }
+
+ /**
+ * Deletes this edit instance.
+ *
+ * @param save
+ * whether this world should be saved
+ */
+ public void delete(boolean save) {
+ EditWorldUnloadEvent event = new EditWorldUnloadEvent(this, true);
+ plugin.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+
+ worlds.getInstances().remove(this);
+ for (Player player : getWorld().getPlayers()) {
+ DEditPlayer dPlayer = DEditPlayer.getByPlayer(player);
+ dPlayer.leave();
+ }
+
+ if (save) {
+ plugin.getServer().unloadWorld(getWorld(), true);
+ }
+
+ FileUtil.copyDirectory(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
+ FileUtil.deleteUnusedFiles(getResource().getFolder());
+
+ if (!save) {
+ plugin.getServer().unloadWorld(getWorld(), true);
+ }
+
+ FileUtil.removeDirectory(getFolder());
+
+ worlds.removeInstance(this);
+ }
+
+ /* Statics */
+ /**
+ * @param world
+ * the instance
+ * @return
+ * the DEditWorld that represents the world
+ */
+ public static DEditWorld getByWorld(World world) {
+ return getByName(world.getName());
+ }
+
+ /**
+ * @param world
+ * the instance name
+ * @return
+ * the DEditWorld that represents the world
+ */
+ public static DEditWorld getByName(String name) {
+ DInstanceWorld instance = worlds.getInstanceByName(name);
+
+ if (instance instanceof DEditWorld) {
+ return (DEditWorld) instance;
+
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/world/GameWorld.java b/src/main/java/io/github/dre2n/dungeonsxl/world/DGameWorld.java
similarity index 60%
rename from src/main/java/io/github/dre2n/dungeonsxl/world/GameWorld.java
rename to src/main/java/io/github/dre2n/dungeonsxl/world/DGameWorld.java
index 9592f82f..6b592958 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/world/GameWorld.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/world/DGameWorld.java
@@ -17,18 +17,12 @@
package io.github.dre2n.dungeonsxl.world;
import io.github.dre2n.commons.util.FileUtil;
-import io.github.dre2n.commons.util.messageutil.MessageUtil;
-import io.github.dre2n.dungeonsxl.DungeonsXL;
-import io.github.dre2n.dungeonsxl.config.DungeonConfig;
-import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
-import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldLoadEvent;
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldStartGameEvent;
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldUnloadEvent;
import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.game.GamePlaceableBlock;
import io.github.dre2n.dungeonsxl.mob.DMob;
-import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.reward.RewardChest;
import io.github.dre2n.dungeonsxl.sign.DSign;
@@ -42,19 +36,12 @@ import io.github.dre2n.dungeonsxl.trigger.Trigger;
import io.github.dre2n.dungeonsxl.trigger.TriggerType;
import io.github.dre2n.dungeonsxl.trigger.TriggerTypeDefault;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
-import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
-import org.bukkit.WorldCreator;
-import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@@ -65,59 +52,29 @@ import org.bukkit.inventory.ItemStack;
/**
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
*/
-public class GameWorld {
-
- static DungeonsXL plugin = DungeonsXL.getInstance();
+public class DGameWorld extends DInstanceWorld {
// Variables
private boolean tutorial;
-
- private CopyOnWriteArrayList placeableBlocks = new CopyOnWriteArrayList<>();
- private World world;
- private String mapName;
- private Location locLobby;
private boolean isPlaying = false;
- private int id;
- private List secureObjects = new ArrayList<>();
- private CopyOnWriteArrayList loadedChunks = new CopyOnWriteArrayList<>();
- private CopyOnWriteArrayList signClass = new CopyOnWriteArrayList<>();
+ // TO DO: Which lists actually need to be CopyOnWriteArrayLists?
+ private CopyOnWriteArrayList placeableBlocks = new CopyOnWriteArrayList<>();
+ private List secureObjects = new CopyOnWriteArrayList<>();
+ private CopyOnWriteArrayList loadedChunks = new CopyOnWriteArrayList<>();
+ private CopyOnWriteArrayList classesSigns = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList dMobs = new CopyOnWriteArrayList<>();
- // TODO: Killed mobs
private CopyOnWriteArrayList rewardChests = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList dSigns = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList triggers = new CopyOnWriteArrayList<>();
- private WorldConfig worldConfig;
- public GameWorld() {
- plugin.getGameWorlds().add(this);
-
- // ID
- id = -1;
- int i = -1;
- while (id == -1) {
- i++;
- boolean exist = false;
- for (GameWorld gameWorld : plugin.getGameWorlds()) {
- if (gameWorld.id == i) {
- exist = true;
- break;
- }
- }
- if (!exist) {
- id = i;
- }
- }
- }
-
- public GameWorld(String name) {
- this();
- load(name);
+ DGameWorld(DResourceWorld resourceWorld, File folder, World world, int id) {
+ super(resourceWorld, folder, world, id);
}
/**
* @return
- * the Game connected to the GameWorld
+ * the Game connected to the DGameWorld
*/
public Game getGame() {
for (Game game : plugin.getGames()) {
@@ -138,70 +95,25 @@ public class GameWorld {
/**
* @param tutorial
- * if the GameWorld is the tutorial
+ * if the DGameWorld is the tutorial
*/
public void setTutorial(boolean tutorial) {
this.tutorial = tutorial;
}
/**
- * @return the placeableBlocks
+ * @return the isPlaying
*/
- public CopyOnWriteArrayList getPlaceableBlocks() {
- return placeableBlocks;
+ public boolean isPlaying() {
+ return isPlaying;
}
/**
- * @param placeableBlocks
- * the placeableBlocks to set
+ * @param isPlaying
+ * the isPlaying to set
*/
- public void setPlaceableBlocks(CopyOnWriteArrayList placeableBlocks) {
- this.placeableBlocks = placeableBlocks;
- }
-
- /**
- * @return the world
- */
- public World getWorld() {
- return world;
- }
-
- /**
- * @param world
- * the world to set
- */
- public void setWorld(World world) {
- this.world = world;
- }
-
- /**
- * @return the mapName
- */
- public String getMapName() {
- return mapName;
- }
-
- /**
- * @param mapName
- * the mapName to set
- */
- public void setMapName(String mapName) {
- this.mapName = mapName;
- }
-
- /**
- * @return the location of the lobby
- */
- public Location getLobbyLocation() {
- return locLobby;
- }
-
- /**
- * @param location
- * the location of the lobby to set
- */
- public void setLobbyLocation(Location location) {
- this.locLobby = location;
+ public void setPlaying(boolean isPlaying) {
+ this.isPlaying = isPlaying;
}
/**
@@ -227,41 +139,26 @@ public class GameWorld {
}
// Lobby location as fallback
- if (locLobby != null) {
- return locLobby;
+ if (getLobbyLocation() != null) {
+ return getLobbyLocation();
}
- return world.getSpawnLocation();
+ return getWorld().getSpawnLocation();
}
/**
- * @return the isPlaying
+ * @return the placeableBlocks
*/
- public boolean isPlaying() {
- return isPlaying;
+ public CopyOnWriteArrayList getPlaceableBlocks() {
+ return placeableBlocks;
}
/**
- * @param isPlaying
- * the isPlaying to set
+ * @param placeableBlocks
+ * the placeableBlocks to set
*/
- public void setPlaying(boolean isPlaying) {
- this.isPlaying = isPlaying;
- }
-
- /**
- * @return the id
- */
- public int getId() {
- return id;
- }
-
- /**
- * @param id
- * the id to set
- */
- public void setId(int id) {
- this.id = id;
+ public void setPlaceableBlocks(CopyOnWriteArrayList placeableBlocks) {
+ this.placeableBlocks = placeableBlocks;
}
/**
@@ -295,18 +192,18 @@ public class GameWorld {
}
/**
- * @return the signClass
+ * @return the classes signs
*/
- public CopyOnWriteArrayList getSignClass() {
- return signClass;
+ public CopyOnWriteArrayList getClassesSigns() {
+ return classesSigns;
}
/**
- * @param signClass
- * the signClass to set
+ * @param classes signs
+ * the classes signs to set
*/
- public void setSignClass(CopyOnWriteArrayList signClass) {
- this.signClass = signClass;
+ public void setClasses(CopyOnWriteArrayList signs) {
+ classesSigns = signs;
}
/**
@@ -438,31 +335,11 @@ public class GameWorld {
}
/**
- * @return the worldConfig
- */
- public WorldConfig getConfig() {
- if (worldConfig == null) {
- return plugin.getMainConfig().getDefaultWorldConfig();
- }
-
- return worldConfig;
- }
-
- /**
- * @param worldConfig
- * the worldConfig to set
- */
- public void setConfig(WorldConfig worldConfig) {
- this.worldConfig = worldConfig;
- }
-
- /**
- * @return the Dungeon that contains the GameWorld
+ * @return the Dungeon that contains the DGameWorld
*/
public Dungeon getDungeon() {
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
- DungeonConfig dungeonConfig = dungeon.getConfig();
- if (dungeonConfig.getFloors().contains(mapName) || dungeonConfig.getStartFloor().equals(mapName) || dungeonConfig.getEndFloor().equals(mapName)) {
+ if (dungeon.getConfig().containsFloor(getResource())) {
return dungeon;
}
}
@@ -470,13 +347,9 @@ public class GameWorld {
return null;
}
- public void checkSign(Block block) {
- if (block.getState() instanceof Sign) {
- Sign sign = (Sign) block.getState();
- dSigns.add(DSign.create(sign, this));
- }
- }
-
+ /**
+ * Set up the instance for the game
+ */
public void startGame() {
GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, getGame());
plugin.getServer().getPluginManager().callEvent(event);
@@ -508,12 +381,10 @@ public class GameWorld {
}
}
- public void sendMessage(String message) {
- for (DGamePlayer dPlayer : DGamePlayer.getByWorld(world)) {
- MessageUtil.sendMessage(dPlayer.getPlayer(), message);
- }
- }
-
+ /**
+ * Delete this instance.
+ */
+ @Override
public void delete() {
GameWorldUnloadEvent event = new GameWorldUnloadEvent(this);
plugin.getServer().getPluginManager().callEvent(event);
@@ -522,12 +393,16 @@ public class GameWorld {
return;
}
- plugin.getGameWorlds().remove(this);
- plugin.getServer().unloadWorld(world, true);
- File dir = new File("DXL_Game_" + id);
- FileUtil.removeDirectory(dir);
+ plugin.getDWorlds().getInstances().remove(this);
+ plugin.getServer().unloadWorld(getWorld(), true);
+ FileUtil.removeDirectory(getFolder());
+
+ worlds.removeInstance(this);
}
+ /**
+ * Ongoing updates
+ */
public void update() {
if (getWorld() == null) {
return;
@@ -542,6 +417,7 @@ public class GameWorld {
continue;
}
}
+
for (Entity player : spider.getNearbyEntities(10, 10, 10)) {
if (player.getType() == EntityType.PLAYER) {
spider.setTarget((LivingEntity) player);
@@ -551,86 +427,21 @@ public class GameWorld {
}
}
- public void load(String name) {
- GameWorldLoadEvent event = new GameWorldLoadEvent(name);
- plugin.getServer().getPluginManager().callEvent(event);
-
- if (event.isCancelled()) {
- return;
- }
-
- File file = new File(plugin.getDataFolder(), "/maps/" + name);
-
- if (file.exists()) {
- mapName = name;
-
- // Unload empty editWorlds
- for (EditWorld editWorld : plugin.getEditWorlds()) {
- if (editWorld.getWorld().getPlayers().isEmpty()) {
- editWorld.delete();
- }
- }
-
- // Config einlesen
- worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + mapName, "config.yml"));
-
- // Secure Objects
- secureObjects = worldConfig.getSecureObjects();
-
- if (Bukkit.getWorld("DXL_Game_" + id) == null) {
-
- // World
- FileUtil.copyDirectory(file, new File("DXL_Game_" + id), DungeonsXL.EXCLUDED_FILES);
-
- // Id File
- File idFile = new File("DXL_Game_" + id + "/.id_" + name);
- try {
- idFile.createNewFile();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- world = plugin.getServer().createWorld(WorldCreator.name("DXL_Game_" + id));
-
- ObjectInputStream os;
- try {
- os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder() + "/maps/" + mapName + "/DXLData.data")));
-
- int length = os.readInt();
- for (int i = 0; i < length; i++) {
- int x = os.readInt();
- int y = os.readInt();
- int z = os.readInt();
- Block block = world.getBlockAt(x, y, z);
- checkSign(block);
- }
-
- os.close();
-
- } catch (FileNotFoundException exception) {
- MessageUtil.log(plugin, "Could not find any sign data for the world \"" + name + "\"!");
-
- } catch (IOException exception) {
- exception.printStackTrace();
- }
- }
- }
- }
-
/* Statics */
- public static GameWorld getByWorld(World world) {
- for (GameWorld gameWorld : plugin.getGameWorlds()) {
- if (gameWorld.getWorld() != null && gameWorld.getWorld().equals(world)) {
- return gameWorld;
- }
- }
+ /**
+ * @param world
+ * the instance
+ * @return
+ * the EditWorld that represents the world
+ */
+ public static DGameWorld getByWorld(World world) {
+ DInstanceWorld instance = plugin.getDWorlds().getInstanceByName(world.getName());
- return null;
- }
+ if (instance instanceof DGameWorld) {
+ return (DGameWorld) instance;
- public static void deleteAll() {
- for (GameWorld gameWorld : plugin.getGameWorlds()) {
- gameWorld.delete();
+ } else {
+ return null;
}
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/world/DInstanceWorld.java b/src/main/java/io/github/dre2n/dungeonsxl/world/DInstanceWorld.java
new file mode 100644
index 00000000..d770f93f
--- /dev/null
+++ b/src/main/java/io/github/dre2n/dungeonsxl/world/DInstanceWorld.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2012-2016 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 .
+ */
+package io.github.dre2n.dungeonsxl.world;
+
+import io.github.dre2n.commons.util.messageutil.MessageUtil;
+import io.github.dre2n.dungeonsxl.DungeonsXL;
+import io.github.dre2n.dungeonsxl.config.WorldConfig;
+import io.github.dre2n.dungeonsxl.player.DGamePlayer;
+import java.io.File;
+import java.io.IOException;
+import org.bukkit.Location;
+import org.bukkit.World;
+
+/**
+ * @author Daniel Saukel
+ */
+public abstract class DInstanceWorld {
+
+ protected static DungeonsXL plugin = DungeonsXL.getInstance();
+ protected static DWorlds worlds = plugin.getDWorlds();
+
+ public static String ID_FILE_PREFIX = ".id_";
+
+ private DResourceWorld resourceWorld;
+ private File folder;
+ private World world;
+ private File idFile;
+ private int id;
+ private Location lobby;
+
+ DInstanceWorld(DResourceWorld resourceWorld, File folder, World world, int id) {
+ this.resourceWorld = resourceWorld;
+ this.folder = folder;
+ this.world = world;
+ this.id = id;
+
+ worlds.addInstance(this);
+ }
+
+ /* Getters and setters */
+ /**
+ * @return the name of the DResourceWorld
+ */
+ public String getName() {
+ return resourceWorld.getName();
+ }
+
+ /**
+ * @return the WorldConfig
+ */
+ public WorldConfig getConfig() {
+ return resourceWorld.getConfig();
+ }
+
+ /**
+ * @return the DResourceWorld of that this world is an instance
+ */
+ public DResourceWorld getResource() {
+ return resourceWorld;
+ }
+
+ /**
+ * @return the folder of the instance
+ */
+ public File getFolder() {
+ return folder;
+ }
+
+ /**
+ * @return the instance
+ */
+ public World getWorld() {
+ return world;
+ }
+
+ /**
+ * @return the file that stores the ID
+ */
+ public File getIdFile() {
+ return idFile;
+ }
+
+ /**
+ * @return the unique ID
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @return the location where the player spawns
+ */
+ public Location getLobbyLocation() {
+ return lobby;
+ }
+
+ /**
+ * @param lobby
+ * the spawn location to set
+ */
+ public void setLobbyLocation(Location lobby) {
+ this.lobby = lobby;
+ }
+
+ /* Actions */
+ /**
+ * Sends a message to all players in the instance.
+ *
+ * @param message
+ * the message to send
+ */
+ public void sendMessage(String message) {
+ for (DGamePlayer dPlayer : DGamePlayer.getByWorld(world)) {
+ MessageUtil.sendMessage(dPlayer.getPlayer(), message);
+ }
+ }
+
+ /**
+ * @return the ID file
+ */
+ public void generateIdFile() {
+ try {
+ idFile = new File(getFolder(), ID_FILE_PREFIX + getName());
+ idFile.createNewFile();
+ } catch (IOException exception) {
+ exception.printStackTrace();
+ }
+ }
+
+ /* Abstracts */
+ /**
+ * Deletes this instance.
+ */
+ public abstract void delete();
+
+}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/world/DResourceWorld.java b/src/main/java/io/github/dre2n/dungeonsxl/world/DResourceWorld.java
new file mode 100644
index 00000000..3e3e9a5a
--- /dev/null
+++ b/src/main/java/io/github/dre2n/dungeonsxl/world/DResourceWorld.java
@@ -0,0 +1,245 @@
+/*
+ * Copyright (C) 2012-2016 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 .
+ */
+package io.github.dre2n.dungeonsxl.world;
+
+import io.github.dre2n.commons.util.FileUtil;
+import io.github.dre2n.dungeonsxl.DungeonsXL;
+import io.github.dre2n.dungeonsxl.config.SignData;
+import io.github.dre2n.dungeonsxl.config.WorldConfig;
+import io.github.dre2n.dungeonsxl.player.DEditPlayer;
+import java.io.File;
+import java.io.IOException;
+import org.bukkit.Bukkit;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.World;
+import org.bukkit.WorldCreator;
+import org.bukkit.WorldType;
+
+/**
+ * This class represents unloaded worlds.
+ *
+ * @author Daniel Saukel
+ */
+public class DResourceWorld {
+
+ DungeonsXL plugin = DungeonsXL.getInstance();
+ DWorlds worlds;
+
+ private File folder;
+ private WorldConfig config;
+ private SignData signData;
+
+ public DResourceWorld(DWorlds worlds, String name) {
+ this.worlds = worlds;
+
+ folder = new File(DungeonsXL.MAPS, name);
+ if (!folder.exists()) {
+ folder.mkdir();
+ }
+
+ File signDataFile = new File(folder, "DXLData.data");
+ if (!signDataFile.exists()) {
+ try {
+ signDataFile.createNewFile();
+
+ } catch (IOException exception) {
+ exception.printStackTrace();
+ }
+ }
+
+ signData = new SignData(signDataFile);
+ }
+
+ public DResourceWorld(DWorlds worlds, File folder) {
+ this.worlds = worlds;
+
+ this.folder = folder;
+
+ File configFile = new File(folder, "config.yml");
+ if (configFile.exists()) {
+ config = new WorldConfig(configFile);
+ }
+
+ File signData = new File(folder, "DXLData.data");
+ if (signData.exists()) {
+ this.signData = new SignData(signData);
+ }
+ }
+
+ /* Getters and setters */
+ /**
+ * @return the folder that stores the world
+ */
+ public File getFolder() {
+ return folder;
+ }
+
+ /**
+ * @return the name of the world
+ */
+ public String getName() {
+ return folder.getName();
+ }
+
+ /**
+ * @param name
+ * the name to set
+ */
+ public void setName(String name) {
+ folder.renameTo(new File(folder.getParentFile(), name));
+ }
+
+ /**
+ * @return the WorldConfig
+ */
+ public WorldConfig getConfig() {
+ return config;
+ }
+
+ /**
+ * @return the DXLData.data file
+ */
+ public SignData getSignData() {
+ return signData;
+ }
+
+ /**
+ * @param player
+ * the player to invite
+ */
+ public void addInvitedPlayer(OfflinePlayer player) {
+ if (config == null) {
+ config = new WorldConfig();
+ }
+
+ config.addInvitedPlayer(player.getUniqueId().toString());
+ config.save();
+ }
+
+ /**
+ * @param player
+ * the player to uninvite
+ */
+ public boolean removeInvitedPlayer(OfflinePlayer player) {
+ if (config == null) {
+ return false;
+ }
+
+ config.removeInvitedPlayers(player.getUniqueId().toString(), player.getName().toLowerCase());
+ config.save();
+
+ DEditPlayer editPlayer = DEditPlayer.getByName(player.getName());
+ if (editPlayer != null) {
+ if (DEditWorld.getByWorld(editPlayer.getWorld()).getResource() == this) {
+ editPlayer.leave();
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * @param player
+ * the player to check
+ */
+ public boolean isInvitedPlayer(OfflinePlayer player) {
+ if (config == null) {
+ return false;
+ }
+
+ return config.getInvitedPlayers().contains(player.getName().toLowerCase()) || config.getInvitedPlayers().contains(player.getUniqueId().toString());
+ }
+
+ /* Actions */
+ /**
+ * @param game
+ * whether the instance is a DGameWorld
+ * @return an instance of this world
+ */
+ public DInstanceWorld instantiate(boolean game) {
+ int id = worlds.generateId();
+ String name = worlds.generateName(game);
+ File instanceFolder = new File(Bukkit.getWorldContainer(), name);
+ FileUtil.copyDirectory(folder, instanceFolder, DungeonsXL.EXCLUDED_FILES);
+
+ if (Bukkit.getWorld(name) != null) {
+ return null;
+ }
+
+ World world = plugin.getServer().createWorld(WorldCreator.name(name));
+
+ DInstanceWorld instance = null;
+ try {
+ if (game) {
+ instance = new DGameWorld(this, instanceFolder, world, id);
+ signData.deserializeSigns((DGameWorld) instance);
+
+ } else {
+ instance = new DEditWorld(this, instanceFolder, world, id);
+ signData.deserializeSigns((DEditWorld) instance);
+ }
+
+ } catch (IOException exception) {
+ exception.printStackTrace();
+ }
+
+ return instance;
+ }
+
+ /**
+ * @return an instance of this world
+ */
+ public DEditWorld instantiateAsEditWorld() {
+ return (DEditWorld) instantiate(false);
+ }
+
+ /**
+ * @return an instance of this world
+ */
+ public DGameWorld instantiateAsGameWorld() {
+ return (DGameWorld) instantiate(true);
+ }
+
+ /**
+ * Generate a new DResourceWorld.
+ *
+ * @return the automatically created DEditWorld instance
+ */
+ public DEditWorld generate() {
+ String name = worlds.generateName(false);
+ WorldCreator creator = WorldCreator.name(name);
+ creator.type(WorldType.FLAT);
+ creator.generateStructures(false);
+
+ /*EditWorldGenerateEvent event = new EditWorldGenerateEvent(this);
+ plugin.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ */
+ int id = worlds.generateId();
+ File folder = new File(Bukkit.getWorldContainer(), name);
+ World world = plugin.getServer().createWorld(creator);
+
+ DEditWorld editWorld = new DEditWorld(this, folder, world, id);
+ editWorld.generateIdFile();
+
+ return editWorld;
+ }
+
+}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/world/DWorlds.java b/src/main/java/io/github/dre2n/dungeonsxl/world/DWorlds.java
new file mode 100644
index 00000000..de509047
--- /dev/null
+++ b/src/main/java/io/github/dre2n/dungeonsxl/world/DWorlds.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright (C) 2012-2016 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 .
+ */
+package io.github.dre2n.dungeonsxl.world;
+
+import io.github.dre2n.commons.util.FileUtil;
+import io.github.dre2n.commons.util.NumberUtil;
+import io.github.dre2n.dungeonsxl.DungeonsXL;
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+import org.bukkit.Bukkit;
+
+/**
+ * @author Daniel Saukel
+ */
+public class DWorlds {
+
+ private Set resources = new HashSet<>();
+ private Set instances = new HashSet<>();
+
+ public DWorlds(File folder) {
+ for (File file : folder.listFiles()) {
+ if (file.isDirectory()) {
+ resources.add(new DResourceWorld(this, file));
+ }
+ }
+ }
+
+ /* Getters and setters */
+ /**
+ * @return the DResourceWorld that has this name
+ */
+ public DResourceWorld getResourceByName(String name) {
+ for (DResourceWorld world : resources) {
+ if (world.getName().equals(name)) {
+ return world;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @return the DInstanceWorld that has this name
+ */
+ public DInstanceWorld getInstanceByName(String name) {
+ String[] splitted = name.split("_");
+ if (splitted.length != 3) {
+ return null;
+ }
+
+ return getInstanceById(NumberUtil.parseInt(splitted[2], -1));
+ }
+
+ /**
+ * @return the DInstanceWorld that has this ID
+ */
+ public DInstanceWorld getInstanceById(int id) {
+ for (DInstanceWorld world : instances) {
+ if (world.getId() == id) {
+ return world;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @return the ResourceWorlds in the maps folder
+ */
+ public Set getResources() {
+ return resources;
+ }
+
+ /**
+ * @param resource
+ * the DResourceWorld to add
+ */
+ public void addResource(DResourceWorld resource) {
+ resources.add(resource);
+ }
+
+ /**
+ * @param resource
+ * the DResourceWorld to remove
+ */
+ public void removeResource(DResourceWorld resource) {
+ resources.remove(resource);
+ }
+
+ /**
+ * @return the loaded InstanceWorlds in the world container
+ */
+ public Set getInstances() {
+ return instances;
+ }
+
+ /**
+ * @param instance
+ * the DInstanceWorld to add
+ */
+ public void addInstance(DInstanceWorld instance) {
+ instances.add(instance);
+ }
+
+ /**
+ * @param instance
+ * the DInstanceWorld to remove
+ */
+ public void removeInstance(DInstanceWorld instance) {
+ instances.remove(instance);
+ }
+
+ /**
+ * @return the loaded GameWorlds
+ */
+ public Set getGameWorlds() {
+ Set gameWorlds = new HashSet<>();
+ for (DInstanceWorld instance : instances) {
+ if (instance instanceof DGameWorld) {
+ gameWorlds.add((DGameWorld) instance);
+ }
+ }
+ return gameWorlds;
+ }
+
+ /**
+ * @return the loaded EditWorlds
+ */
+ public Set getEditWorlds() {
+ Set editWorlds = new HashSet<>();
+ for (DInstanceWorld instance : instances) {
+ if (instance instanceof DGameWorld) {
+ editWorlds.add((DEditWorld) instance);
+ }
+ }
+ return editWorlds;
+ }
+
+ /**
+ * @param name
+ * the name of the map; can either be the resource name or the instance name
+ * @return
+ * if a map with this name exists
+ */
+ public boolean exists(String name) {
+ for (DResourceWorld resource : resources) {
+ if (resource.getName().equalsIgnoreCase(name)) {
+ return true;
+ }
+ }
+
+ for (DInstanceWorld instance : instances) {
+ if (instance.getFolder().getName().equalsIgnoreCase(name)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Check world container for old, remaining instances and delete them.
+ */
+ public void check() {
+ for (File file : Bukkit.getWorldContainer().listFiles()) {
+ if (file.getName().startsWith("DXL_Edit_") && file.isDirectory()) {
+ for (File mapFile : file.listFiles()) {
+ if (mapFile.getName().startsWith(".id_")) {
+ String name = mapFile.getName().substring(4);
+
+ FileUtil.copyDirectory(file, new File(DungeonsXL.MAPS, name), DungeonsXL.EXCLUDED_FILES);
+ FileUtil.deleteUnusedFiles(new File(DungeonsXL.MAPS, name));
+
+ FileUtil.removeDirectory(file);
+ }
+ }
+
+ } else if (file.getName().startsWith("DXL_Game_") && file.isDirectory()) {
+ FileUtil.removeDirectory(file);
+ }
+ }
+ }
+
+ /**
+ * Clean up all instances.
+ */
+ public void deleteAllInstances() {
+ for (DInstanceWorld instance : instances) {
+ instance.delete();
+ }
+ }
+
+ /**
+ * Saves all EditWorlds.
+ */
+ public void saveAll() {
+ for (DEditWorld editWorld : getEditWorlds()) {
+ editWorld.save();
+ }
+ }
+
+ /**
+ * @return an ID for the instance
+ */
+ public int generateId() {
+ int id = 0;
+ for (DInstanceWorld instance : instances) {
+ if (instance.getId() >= id) {
+ id = instance.getId() + 1;
+ }
+ }
+ return id;
+ }
+
+ /**
+ * @return a name for the instance
+ *
+ * @param game
+ * whether the instance is a DGameWorld
+ */
+ public String generateName(boolean game) {
+ return "DXL_" + (game ? "Game" : "Edit") + "_" + generateId();
+ }
+
+}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/world/EditWorld.java b/src/main/java/io/github/dre2n/dungeonsxl/world/EditWorld.java
deleted file mode 100644
index 66a10a31..00000000
--- a/src/main/java/io/github/dre2n/dungeonsxl/world/EditWorld.java
+++ /dev/null
@@ -1,481 +0,0 @@
-/*
- * Copyright (C) 2012-2016 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 .
- */
-package io.github.dre2n.dungeonsxl.world;
-
-import io.github.dre2n.commons.util.FileUtil;
-import io.github.dre2n.commons.util.messageutil.MessageUtil;
-import io.github.dre2n.dungeonsxl.DungeonsXL;
-import io.github.dre2n.dungeonsxl.config.WorldConfig;
-import io.github.dre2n.dungeonsxl.event.editworld.EditWorldGenerateEvent;
-import io.github.dre2n.dungeonsxl.event.editworld.EditWorldLoadEvent;
-import io.github.dre2n.dungeonsxl.event.editworld.EditWorldSaveEvent;
-import io.github.dre2n.dungeonsxl.event.editworld.EditWorldUnloadEvent;
-import io.github.dre2n.dungeonsxl.player.DGamePlayer;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.UUID;
-import java.util.concurrent.CopyOnWriteArrayList;
-import org.bukkit.Location;
-import org.bukkit.World;
-import org.bukkit.WorldCreator;
-import org.bukkit.WorldType;
-import org.bukkit.block.Block;
-import org.bukkit.block.Sign;
-import org.bukkit.entity.Player;
-
-/**
- * @author Frank Baumann, Daniel Saukel
- */
-public class EditWorld {
-
- static DungeonsXL plugin = DungeonsXL.getInstance();
-
- // Variables
- private World world;
- private String owner;
- private String name;
- private String mapName;
- private int id;
- private Location lobby;
- private CopyOnWriteArrayList invitedPlayers = new CopyOnWriteArrayList<>();
- private CopyOnWriteArrayList signs = new CopyOnWriteArrayList<>();
-
- public EditWorld() {
- plugin.getEditWorlds().add(this);
-
- // ID
- id = -1;
- int i = -1;
- while (id == -1) {
- i++;
- boolean exist = false;
- for (EditWorld editWorld : plugin.getEditWorlds()) {
- if (editWorld.id == i) {
- exist = true;
- break;
- }
- }
- if (!exist) {
- id = i;
- }
- }
-
- name = "DXL_Edit_" + id;
- }
-
- /**
- * @return the world
- */
- public World getWorld() {
- return world;
- }
-
- /**
- * @param world
- * the world to set
- */
- public void setWorld(World world) {
- this.world = world;
- }
-
- /**
- * @return the owner
- */
- public String getOwner() {
- return owner;
- }
-
- /**
- * @param owner
- * the owner to set
- */
- public void setOwner(String owner) {
- this.owner = owner;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name
- * the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return the mapName
- */
- public String getMapName() {
- return mapName;
- }
-
- /**
- * @param mapName
- * the mapName to set
- */
- public void setMapName(String mapName) {
- this.mapName = mapName;
- }
-
- /**
- * @return the id
- */
- public int getId() {
- return id;
- }
-
- /**
- * @param id
- * the id to set
- */
- public void setId(int id) {
- this.id = id;
- }
-
- /**
- * @return the location of the lobby
- */
- public Location getLobbyLocation() {
- return lobby;
- }
-
- /**
- * @param lobby
- * the lobby to set
- */
- public void setLobby(Location lobby) {
- this.lobby = lobby;
- }
-
- /**
- * @return the invitedPlayers
- */
- public CopyOnWriteArrayList getInvitedPlayers() {
- return invitedPlayers;
- }
-
- /**
- * @param invitedPlayers
- * the invitedPlayers to set
- */
- public void setInvitedPlayers(CopyOnWriteArrayList invitedPlayers) {
- this.invitedPlayers = invitedPlayers;
- }
-
- /**
- * @return the signs
- */
- public CopyOnWriteArrayList getSigns() {
- return signs;
- }
-
- /**
- * @param sign
- * the sign to set
- */
- public void setSigns(CopyOnWriteArrayList signs) {
- this.signs = signs;
- }
-
- public void generate() {
- WorldCreator creator = WorldCreator.name(name);
- creator.type(WorldType.FLAT);
- creator.generateStructures(false);
-
- EditWorldGenerateEvent event = new EditWorldGenerateEvent(this);
- plugin.getServer().getPluginManager().callEvent(event);
-
- if (event.isCancelled()) {
- return;
- }
-
- world = plugin.getServer().createWorld(creator);
- }
-
- public void save() {
- EditWorldSaveEvent event = new EditWorldSaveEvent(this);
- plugin.getServer().getPluginManager().callEvent(event);
-
- if (event.isCancelled()) {
- return;
- }
-
- world.save();
-
- File dir = new File("DXL_Edit_" + id);
- FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName), DungeonsXL.EXCLUDED_FILES);
- FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
-
- try {
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(plugin.getDataFolder(), "/maps/" + mapName + "/DXLData.data")));
- out.writeInt(signs.size());
- for (Block sign : signs) {
- out.writeInt(sign.getX());
- out.writeInt(sign.getY());
- out.writeInt(sign.getZ());
- }
- out.close();
-
- } catch (IOException exception) {
- }
- }
-
- public void checkSign(Block block) {
- if (block.getState() instanceof Sign) {
- Sign sign = (Sign) block.getState();
- String[] lines = sign.getLines();
-
- if (lines[0].equalsIgnoreCase("[lobby]")) {
- lobby = block.getLocation();
- }
- }
- }
-
- public void delete() {
- EditWorldUnloadEvent event = new EditWorldUnloadEvent(this, true);
- plugin.getServer().getPluginManager().callEvent(event);
-
- if (event.isCancelled()) {
- return;
- }
-
- plugin.getEditWorlds().remove(this);
- for (Player player : world.getPlayers()) {
- DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
- dPlayer.leave();
- }
-
- plugin.getServer().unloadWorld(world, true);
- File dir = new File("DXL_Edit_" + id);
- FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName), DungeonsXL.EXCLUDED_FILES);
- FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
- FileUtil.removeDirectory(dir);
- }
-
- public void deleteNoSave() {
- EditWorldUnloadEvent event = new EditWorldUnloadEvent(this, false);
- plugin.getServer().getPluginManager().callEvent(event);
-
- if (event.isCancelled()) {
- return;
- }
-
- plugin.getEditWorlds().remove(this);
- for (Player player : world.getPlayers()) {
- DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
- dPlayer.leave();
- }
-
- File dir = new File("DXL_Edit_" + id);
- FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName), DungeonsXL.EXCLUDED_FILES);
- FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
- plugin.getServer().unloadWorld(world, true);
- FileUtil.removeDirectory(dir);
- }
-
- public void sendMessage(String message) {
- for (DGamePlayer dPlayer : DGamePlayer.getByWorld(world)) {
- MessageUtil.sendMessage(dPlayer.getPlayer(), message);
- }
- }
-
- /* Statics */
- public static EditWorld getByWorld(World world) {
- for (EditWorld editWorld : plugin.getEditWorlds()) {
- if (editWorld.world.equals(world)) {
- return editWorld;
- }
- }
-
- return null;
- }
-
- public static EditWorld getByName(String name) {
- for (EditWorld editWorld : plugin.getEditWorlds()) {
- if (editWorld.mapName.equalsIgnoreCase(name)) {
- return editWorld;
- }
- }
-
- return null;
- }
-
- public static void deleteAll() {
- for (EditWorld editWorld : plugin.getEditWorlds()) {
- editWorld.delete();
- }
- }
-
- public static EditWorld load(String name) {
- EditWorldLoadEvent event = new EditWorldLoadEvent(name);
- plugin.getServer().getPluginManager().callEvent(event);
-
- if (event.isCancelled()) {
- return null;
- }
-
- for (EditWorld editWorld : plugin.getEditWorlds()) {
-
- if (editWorld.mapName.equalsIgnoreCase(name)) {
- return editWorld;
- }
- }
-
- File file = new File(plugin.getDataFolder(), "/maps/" + name);
-
- if (file.exists()) {
- EditWorld editWorld = new EditWorld();
- editWorld.mapName = name;
- // World
- FileUtil.copyDirectory(file, new File("DXL_Edit_" + editWorld.id), DungeonsXL.EXCLUDED_FILES);
-
- // Id File
- File idFile = new File("DXL_Edit_" + editWorld.id + "/.id_" + name);
- try {
- idFile.createNewFile();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- editWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Edit_" + editWorld.id));
-
- try {
- ObjectInputStream os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder(), "/maps/" + editWorld.mapName + "/DXLData.data")));
- int length = os.readInt();
- for (int i = 0; i < length; i++) {
- int x = os.readInt();
- int y = os.readInt();
- int z = os.readInt();
- Block block = editWorld.world.getBlockAt(x, y, z);
- editWorld.checkSign(block);
- editWorld.signs.add(block);
- }
- os.close();
-
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return editWorld;
- }
-
- return null;
- }
-
- public static boolean exists(String name) {
- // Cheack Loaded EditWorlds
- for (EditWorld editWorld : plugin.getEditWorlds()) {
- if (editWorld.mapName.equalsIgnoreCase(name)) {
- return true;
- }
- }
-
- // Cheack Unloaded Worlds
- File file = new File(plugin.getDataFolder(), "/maps/" + name);
-
- if (file.exists()) {
- return true;
- }
-
- return false;
- }
-
- // Invite
- public static boolean addInvitedPlayer(String editWorldName, UUID uuid) {
- if (!exists(editWorldName)) {
- return false;
- }
-
- File file = new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml");
- if (!file.exists()) {
- try {
- file.createNewFile();
-
- } catch (IOException exception) {
- exception.printStackTrace();
- return false;
- }
- }
- WorldConfig config = new WorldConfig(file);
- config.addInvitedPlayer(uuid.toString());
- config.save();
-
- return true;
- }
-
- public static boolean removeInvitedPlayer(String editWorldName, UUID uuid, String name) {
- if (!exists(editWorldName)) {
- return false;
- }
-
- File file = new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml");
- if (!file.exists()) {
- return false;
- }
- WorldConfig config = new WorldConfig(file);
- config.removeInvitedPlayers(uuid.toString(), name.toLowerCase());
- config.save();
-
- // Kick Player
- EditWorld editWorld = EditWorld.getByName(editWorldName);
- if (editWorld != null) {
- DGamePlayer player = DGamePlayer.getByName(name);
-
- if (player != null) {
- if (editWorld.world.getPlayers().contains(player.getPlayer())) {
- player.leave();
- }
- }
- }
-
- return true;
- }
-
- public static boolean isInvitedPlayer(String editWorldName, UUID uuid, String name) {
- if (!exists(editWorldName)) {
- return false;
- }
-
- File file = new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml");
- if (!file.exists()) {
- return false;
- }
-
- WorldConfig config = new WorldConfig(file);
- // get player from both a 0.9.1 and lower and 0.9.2 and higher file
- if (config.getInvitedPlayers().contains(name.toLowerCase()) || config.getInvitedPlayers().contains(uuid.toString())) {
- return true;
-
- } else {
- return false;
- }
- }
-
-}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/world/Worlds.java b/src/main/java/io/github/dre2n/dungeonsxl/world/Worlds.java
deleted file mode 100644
index e9d822f0..00000000
--- a/src/main/java/io/github/dre2n/dungeonsxl/world/Worlds.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2012-2016 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 .
- */
-package io.github.dre2n.dungeonsxl.world;
-
-import java.io.File;
-import java.util.Set;
-
-/**
- * @author Daniel Saukel
- */
-public class Worlds {
-
- /*private Set resourceWorlds;
-
- public Worlds(File folder) {
- for (File file : folder.listFiles()) {
- resourceWorlds.add(new ResourceWorld());
- }
- }*/
-
- @Deprecated
- public static boolean exists(String name) {
- for (File world : io.github.dre2n.dungeonsxl.DungeonsXL.MAPS.listFiles()) {
- if (world.isDirectory() && world.getName().equalsIgnoreCase(name)) {
- return true;
- }
- }
-
- return false;
- }
-
-}
diff --git a/src/test/java/io/github/dre2n/dungeonsxl/listener/DGroupListener.java b/src/test/java/io/github/dre2n/dungeonsxl/listener/DGroupListener.java
index 4fe7f009..3e3c1c90 100644
--- a/src/test/java/io/github/dre2n/dungeonsxl/listener/DGroupListener.java
+++ b/src/test/java/io/github/dre2n/dungeonsxl/listener/DGroupListener.java
@@ -61,13 +61,13 @@ public class DGroupListener implements Listener {
@EventHandler
public void onStartFloor(DGroupStartFloorEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
- MessageUtil.log(plugin, "GameWorld: " + event.getGameWorld().getMapName());
+ MessageUtil.log(plugin, "GameWorld: " + event.getGameWorld().getName());
}
@EventHandler
public void onFinishFloor(DGroupFinishFloorEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
- MessageUtil.log(plugin, "Finished: " + event.getFinished().getMapName());
+ MessageUtil.log(plugin, "Finished: " + event.getFinished().getName());
MessageUtil.log(plugin, "Next: " + event.getNext());
}
diff --git a/src/test/java/io/github/dre2n/dungeonsxl/sign/CustomSign.java b/src/test/java/io/github/dre2n/dungeonsxl/sign/CustomSign.java
index 05636da9..9e6ce200 100644
--- a/src/test/java/io/github/dre2n/dungeonsxl/sign/CustomSign.java
+++ b/src/test/java/io/github/dre2n/dungeonsxl/sign/CustomSign.java
@@ -16,7 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.sign;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
@@ -27,7 +27,7 @@ public class CustomSign extends DSign {
private DSignType type = DSignTypeCustom.CUSTOM;
- public CustomSign(Sign sign, String[] lines, GameWorld gameWorld) {
+ public CustomSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
diff --git a/src/test/java/io/github/dre2n/dungeonsxl/trigger/CustomTrigger.java b/src/test/java/io/github/dre2n/dungeonsxl/trigger/CustomTrigger.java
index 2f72acc4..57bb5bf8 100644
--- a/src/test/java/io/github/dre2n/dungeonsxl/trigger/CustomTrigger.java
+++ b/src/test/java/io/github/dre2n/dungeonsxl/trigger/CustomTrigger.java
@@ -17,7 +17,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
-import io.github.dre2n.dungeonsxl.world.GameWorld;
+import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@@ -28,7 +28,7 @@ import org.bukkit.entity.Player;
*/
public class CustomTrigger extends Trigger {
- private static Map> triggers = new HashMap<>();
+ private static Map> triggers = new HashMap<>();
private TriggerType type = TriggerTypeCustom.CUSTOM;
@@ -55,7 +55,7 @@ public class CustomTrigger extends Trigger {
}
@Override
- public void register(GameWorld gameWorld) {
+ public void register(DGameWorld gameWorld) {
if (!hasTriggers(gameWorld)) {
ArrayList list = new ArrayList<>();
list.add(this);
@@ -67,7 +67,7 @@ public class CustomTrigger extends Trigger {
}
@Override
- public void unregister(GameWorld gameWorld) {
+ public void unregister(DGameWorld gameWorld) {
if (hasTriggers(gameWorld)) {
triggers.get(gameWorld).remove(this);
}
@@ -78,7 +78,7 @@ public class CustomTrigger extends Trigger {
return type;
}
- public static CustomTrigger getOrCreate(String value, GameWorld gameWorld) {
+ public static CustomTrigger getOrCreate(String value, DGameWorld gameWorld) {
if (triggers.containsKey(gameWorld)) {
for (CustomTrigger trigger : triggers.get(gameWorld)) {
if (trigger.value.equals(value)) {
@@ -90,7 +90,7 @@ public class CustomTrigger extends Trigger {
return new CustomTrigger(value);
}
- public static boolean hasTriggers(GameWorld gameWorld) {
+ public static boolean hasTriggers(DGameWorld gameWorld) {
return !triggers.isEmpty() && triggers.containsKey(gameWorld);
}