Merge pull request #97 from DRE2N/world-rewrite

World system rewrite; see #94
This commit is contained in:
Daniel Saukel 2016-06-30 19:58:15 +02:00 committed by GitHub
commit a9db93c86b
105 changed files with 1556 additions and 1245 deletions

17
pom.xml
View File

@ -110,6 +110,11 @@
<artifactId>holographicdisplaysapi</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>pl.betoncraft.betonquest</groupId>
<artifactId>BetonQuest</artifactId>
<version>1.8.5</version>
</dependency>
</dependencies>
<repositories>
<repository>
@ -120,13 +125,17 @@
<id>vault-repo</id>
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
</repository>
<repository>
<id>dre2n-repo</id>
<url>http://feuerstern.bplaced.net/repo/</url>
</repository>
<repository>
<id>citizens-repo</id>
<url>http://repo.citizensnpcs.co/</url>
</repository>
<repository>
<id>betonquest-repo</id>
<url>http://betonquest.betoncraft.pl/mvn</url>
</repository>
<repository>
<id>dre2n-repo</id>
<url>http://feuerstern.bplaced.net/repo/</url>
</repository>
</repositories>
</project>

View File

@ -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<DLootInventory> dLootInventories = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<EditWorld> editWorlds = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<GameWorld> gameWorlds = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<Game> games = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<DGroup> 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<EditWorld> getEditWorlds() {
return editWorlds;
}
/**
* @return the gameWorlds
*/
public List<GameWorld> getGameWorlds() {
return gameWorlds;
}
/**
* @return the games
*/

View File

@ -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 {

View File

@ -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());

View File

@ -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());
}
}

View File

@ -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)) {

View File

@ -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 {

View File

@ -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;

View File

@ -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,9 +45,17 @@ public class InviteCommand extends BRCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
if (EditWorld.addInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]))) {
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]));
}

View File

@ -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;
}

View File

@ -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<String> dungeonList = new ArrayList<>();
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
dungeonList.add(dungeon.getName());
}
ArrayList<String> mapList = new ArrayList<>();
for (File file : mapFolder.listFiles()) {
for (File file : DungeonsXL.MAPS.listFiles()) {
mapList.add(file.getName());
}
ArrayList<String> 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<String> 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);
}

View File

@ -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 = "";

View File

@ -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());

View File

@ -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());
}
}
}

View File

@ -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 = "";

View File

@ -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());

View File

@ -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;

View File

@ -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]));
}
}
}

View File

@ -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

View File

@ -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<String> floors = new ArrayList<>();
private DResourceWorld startFloor;
private DResourceWorld endFloor;
private List<DResourceWorld> 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<String> getFloors() {
public List<DResourceWorld> 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")) {

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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<Block> 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();
}
}

View File

@ -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;
}
}

View File

@ -29,14 +29,23 @@ public class Dungeons {
private List<Dungeon> 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
}
}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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<DGroup> 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<String, Integer> 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<DGroup> dGroups, GameType type, GameWorld world) {
public Game(List<DGroup> 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<String> getUnplayedFloors() {
List<String> unplayedFloors = new ArrayList<>();
public List<DResourceWorld> getUnplayedFloors() {
List<DResourceWorld> 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 {

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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";
}

View File

@ -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);
}

View File

@ -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) {

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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;
}

View File

@ -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;

View File

@ -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<DGamePlayer> getByWorld(World world) {
CopyOnWriteArrayList<DGamePlayer> dPlayers = new CopyOnWriteArrayList<>();
public static List<DGamePlayer> getByWorld(World world) {
List<DGamePlayer> dPlayers = new ArrayList<>();
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
if (dPlayer.getWorld() == world) {

View File

@ -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<String> unplayedFloors = new ArrayList<>();
private GameWorld gameWorld;
private List<DResourceWorld> unplayedFloors = new ArrayList<>();
private DGameWorld gameWorld;
private boolean playing;
private int floorCount;
private List<Reward> 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<String> getUnplayedFloors() {
public List<DResourceWorld> 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<DGroup> getByGameWorld(GameWorld gameWorld) {
public static List<DGroup> getByGameWorld(DGameWorld gameWorld) {
List<DGroup> dGroups = new ArrayList<>();
for (DGroup dGroup : plugin.getDGroups()) {
if (dGroup.getGameWorld().equals(gameWorld)) {

View File

@ -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;

View File

@ -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);
}

View File

@ -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<DGamePlayer> done = new CopyOnWriteArrayList<>();
public CheckpointSign(Sign sign, String[] lines, GameWorld gameWorld) {
public CheckpointSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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<Trigger> 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) {

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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<Entity> externalMobs = new ArrayList<>();
public ExternalMobSign(Sign sign, String[] lines, GameWorld gameWorld) {
public ExternalMobSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}

View File

@ -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();

View File

@ -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);
}

View File

@ -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<Integer> 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;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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<Player> done = new CopyOnWriteArrayList<>();
public MessageSign(Sign sign, String[] lines, GameWorld gameWorld) {
public MessageSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}

View File

@ -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();

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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];
}

View File

@ -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<Player> done = new CopyOnWriteArrayList<>();
public SoundMessageSign(Sign sign, String[] lines, GameWorld gameWorld) {
public SoundMessageSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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<Integer> 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;
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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));

View File

@ -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();
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}
}
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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)) {

View File

@ -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<ProgressTrigger> getByGameWorld(GameWorld gameWorld) {
public static Set<ProgressTrigger> getByGameWorld(DGameWorld gameWorld) {
Set<ProgressTrigger> toReturn = new HashSet<>();
for (Trigger trigger : gameWorld.getTriggers(TriggerTypeDefault.PROGRESS)) {
toReturn.add((ProgressTrigger) trigger);

View File

@ -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();
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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)) {

View File

@ -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<WaveTrigger> getByGameWorld(GameWorld gameWorld) {
public static Set<WaveTrigger> getByGameWorld(DGameWorld gameWorld) {
Set<WaveTrigger> toReturn = new HashSet<>();
for (Trigger trigger : gameWorld.getTriggers()) {
toReturn.add((WaveTrigger) trigger);

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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<Block> 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<Block> getSigns() {
return signs;
}
/**
* @param sign
* the sign to set
*/
public void setSigns(CopyOnWriteArrayList<Block> 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;
}
}
}

View File

@ -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<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<>();
private World world;
private String mapName;
private Location locLobby;
private boolean isPlaying = false;
private int id;
private List<ItemStack> secureObjects = new ArrayList<>();
private CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<>();
// TO DO: Which lists actually need to be CopyOnWriteArrayLists?
private CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<>();
private List<ItemStack> secureObjects = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<Sign> classesSigns = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<>();
// TODO: Killed mobs
private CopyOnWriteArrayList<RewardChest> rewardChests = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<Trigger> 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<GamePlaceableBlock> getPlaceableBlocks() {
return placeableBlocks;
public boolean isPlaying() {
return isPlaying;
}
/**
* @param placeableBlocks
* the placeableBlocks to set
* @param isPlaying
* the isPlaying to set
*/
public void setPlaceableBlocks(CopyOnWriteArrayList<GamePlaceableBlock> 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<GamePlaceableBlock> 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<GamePlaceableBlock> placeableBlocks) {
this.placeableBlocks = placeableBlocks;
}
/**
@ -295,18 +192,18 @@ public class GameWorld {
}
/**
* @return the signClass
* @return the classes signs
*/
public CopyOnWriteArrayList<Sign> getSignClass() {
return signClass;
public CopyOnWriteArrayList<Sign> getClassesSigns() {
return classesSigns;
}
/**
* @param signClass
* the signClass to set
* @param classes signs
* the classes signs to set
*/
public void setSignClass(CopyOnWriteArrayList<Sign> signClass) {
this.signClass = signClass;
public void setClasses(CopyOnWriteArrayList<Sign> 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,87 +427,22 @@ 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());
if (instance instanceof DGameWorld) {
return (DGameWorld) instance;
} else {
return null;
}
public static void deleteAll() {
for (GameWorld gameWorld : plugin.getGameWorlds()) {
gameWorld.delete();
}
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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();
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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<DResourceWorld> resources = new HashSet<>();
private Set<DInstanceWorld> 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<DResourceWorld> 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<DInstanceWorld> 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<DGameWorld> getGameWorlds() {
Set<DGameWorld> gameWorlds = new HashSet<>();
for (DInstanceWorld instance : instances) {
if (instance instanceof DGameWorld) {
gameWorlds.add((DGameWorld) instance);
}
}
return gameWorlds;
}
/**
* @return the loaded EditWorlds
*/
public Set<DEditWorld> getEditWorlds() {
Set<DEditWorld> 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();
}
}

Some files were not shown because too many files have changed in this diff Show More