#94: Resolved all errors due to changes

This commit is contained in:
Daniel Saukel 2016-06-23 18:22:47 +02:00
parent 8bb9fe0eac
commit 141a35f5e7
30 changed files with 493 additions and 733 deletions

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.config.MessageConfig;
import io.github.dre2n.commons.javaplugin.BRPlugin; import io.github.dre2n.commons.javaplugin.BRPlugin;
import io.github.dre2n.commons.javaplugin.BRPluginSettings; 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.announcer.Announcers;
import io.github.dre2n.dungeonsxl.command.*; import io.github.dre2n.dungeonsxl.command.*;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
@ -53,8 +52,6 @@ import io.github.dre2n.dungeonsxl.task.SecureModeTask;
import io.github.dre2n.dungeonsxl.task.UpdateTask; import io.github.dre2n.dungeonsxl.task.UpdateTask;
import io.github.dre2n.dungeonsxl.task.WorldUnloadTask; import io.github.dre2n.dungeonsxl.task.WorldUnloadTask;
import io.github.dre2n.dungeonsxl.trigger.TriggerTypes; 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.Worlds; import io.github.dre2n.dungeonsxl.world.Worlds;
import io.github.dre2n.itemsxl.ItemsXL; import io.github.dre2n.itemsxl.ItemsXL;
import java.io.File; import java.io.File;
@ -204,10 +201,7 @@ public class DungeonsXL extends BRPlugin {
dGroups.clear(); dGroups.clear();
// Delete Worlds // Delete Worlds
GameWorld.deleteAll(); worlds.deleteAllInstances();
gameWorlds.clear();
EditWorld.deleteAll();
editWorlds.clear();
// Disable listeners // Disable listeners
HandlerList.unregisterAll(this); HandlerList.unregisterAll(this);
@ -272,38 +266,17 @@ public class DungeonsXL extends BRPlugin {
public void saveData() { public void saveData() {
protections.saveAll(); protections.saveAll();
DSavePlayer.save(); DSavePlayer.save();
for (EditWorld editWorld : editWorlds) { worlds.saveAll();
editWorld.save();
}
} }
public void loadAll() { public void loadAll() {
protections.loadAll(); protections.loadAll();
dPlayers.loadAll(); dPlayers.loadAll();
DSavePlayer.load(); DSavePlayer.load();
checkWorlds(); worlds.check();
} }
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);
}
}
}
/* Getters and loaders */ /* Getters and loaders */
/** /**

View File

@ -24,6 +24,7 @@ import io.github.dre2n.dungeonsxl.player.DEditPlayer;
import io.github.dre2n.dungeonsxl.player.DGamePlayer; import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DPermissions; import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.EditWorld; import io.github.dre2n.dungeonsxl.world.EditWorld;
import io.github.dre2n.dungeonsxl.world.ResourceWorld;
import java.io.File; import java.io.File;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
@ -66,9 +67,8 @@ public class CreateCommand extends BRCommand {
MessageUtil.log(plugin, DMessages.LOG_GENERATE_NEW_WORLD.getMessage()); MessageUtil.log(plugin, DMessages.LOG_GENERATE_NEW_WORLD.getMessage());
// Create World // Create World
EditWorld editWorld = new EditWorld(); ResourceWorld resource = new ResourceWorld(name);
editWorld.generate(); EditWorld editWorld = resource.generate();
editWorld.setMapName(name);
editWorld.save(); editWorld.save();
editWorld.delete(); editWorld.delete();
@ -88,9 +88,8 @@ public class CreateCommand extends BRCommand {
MessageUtil.log(plugin, DMessages.LOG_GENERATE_NEW_WORLD.getMessage()); MessageUtil.log(plugin, DMessages.LOG_GENERATE_NEW_WORLD.getMessage());
// Create World // Create World
EditWorld editWorld = new EditWorld(); ResourceWorld resource = new ResourceWorld(name);
editWorld.generate(); EditWorld editWorld = resource.generate();
editWorld.setMapName(name);
// MSG Done // MSG Done
MessageUtil.log(plugin, DMessages.LOG_WORLD_GENERATION_FINISHED.getMessage()); 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.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DEditPlayer; 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.DGroup;
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
import io.github.dre2n.dungeonsxl.player.DPermissions; import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.EditWorld; import io.github.dre2n.dungeonsxl.world.EditWorld;
import io.github.dre2n.dungeonsxl.world.ResourceWorld;
import io.github.dre2n.dungeonsxl.world.Worlds;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -34,6 +37,7 @@ import org.bukkit.entity.Player;
public class EditCommand extends BRCommand { public class EditCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
Worlds worlds = plugin.getWorlds();
public EditCommand() { public EditCommand() {
setCommand("edit"); setCommand("edit");
@ -46,18 +50,24 @@ public class EditCommand extends BRCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender; Player player = (Player) sender;
String mapName = args[1]; 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;
}
ResourceWorld resource = worlds.getResourceByName(mapName);
EditWorld 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()); MessageUtil.sendMessage(player, DMessages.ERROR_NO_PERMISSIONS.getMessage());
return; return;
} }
if (dPlayer != null) { if (dPlayer instanceof DInstancePlayer) {
MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage()); MessageUtil.sendMessage(player, DMessages.ERROR_LEAVE_DUNGEON.getMessage());
return; return;
} }
@ -67,13 +77,7 @@ public class EditCommand extends BRCommand {
return; return;
} }
if (editWorld == null) {
MessageUtil.sendMessage(player, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(mapName));
return;
}
new DEditPlayer(player, editWorld.getWorld()); new DEditPlayer(player, editWorld.getWorld());
} }
} }

View File

@ -68,7 +68,7 @@ public class EnterCommand extends BRCommand {
} }
if (joining == null) { 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)) { if (joining.getCaptain() != captain && !DPermissions.hasPermission(sender, DPermissions.BYPASS)) {

View File

@ -58,7 +58,7 @@ public class EscapeCommand extends BRCommand {
} }
if (editWorld.getWorld().getPlayers().isEmpty()) { if (editWorld.getWorld().getPlayers().isEmpty()) {
editWorld.deleteNoSave(); editWorld.delete(false);
} }
} else { } else {

View File

@ -17,12 +17,13 @@
package io.github.dre2n.dungeonsxl.command; package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.commons.command.BRCommand; 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.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL; import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DPermissions; import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.EditWorld; import io.github.dre2n.dungeonsxl.world.ResourceWorld;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
/** /**
@ -44,8 +45,16 @@ public class InviteCommand extends BRCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
if (EditWorld.addInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]))) { ResourceWorld resource = plugin.getWorlds().getResourceByName(args[2]);
MessageUtil.sendMessage(sender, DMessages.CMD_INVITE_SUCCESS.getMessage(args[1], 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 { } else {
MessageUtil.sendMessage(sender, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(args[2])); MessageUtil.sendMessage(sender, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(args[2]));

View File

@ -26,6 +26,7 @@ import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.player.DPermissions; import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.EditWorld; import io.github.dre2n.dungeonsxl.world.EditWorld;
import io.github.dre2n.dungeonsxl.world.GameWorld; import io.github.dre2n.dungeonsxl.world.GameWorld;
import io.github.dre2n.dungeonsxl.world.Worlds;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -37,6 +38,7 @@ import org.bukkit.entity.Player;
public class ListCommand extends BRCommand { public class ListCommand extends BRCommand {
DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
Worlds worlds = plugin.getWorlds();
public ListCommand() { public ListCommand() {
setCommand("list"); setCommand("list");
@ -61,10 +63,10 @@ public class ListCommand extends BRCommand {
mapList.add(file.getName()); mapList.add(file.getName());
} }
ArrayList<String> loadedList = new ArrayList<>(); ArrayList<String> loadedList = new ArrayList<>();
for (EditWorld editWorld : plugin.getEditWorlds()) { for (EditWorld editWorld : worlds.getEditWorlds()) {
loadedList.add(editWorld.getWorld().getWorldFolder().getName()); loadedList.add(editWorld.getWorld().getWorldFolder().getName());
} }
for (GameWorld gameWorld : plugin.getGameWorlds()) { for (GameWorld gameWorld : worlds.getGameWorlds()) {
loadedList.add(gameWorld.getWorld().getWorldFolder().getName()); loadedList.add(gameWorld.getWorld().getWorldFolder().getName());
} }
ArrayList<String> toSend = new ArrayList<>(); ArrayList<String> toSend = new ArrayList<>();
@ -130,7 +132,7 @@ public class ListCommand extends BRCommand {
for (String map : toSend) { for (String map : toSend) {
boolean invited = false; boolean invited = false;
if (sender instanceof Player) { 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); MessageUtil.sendMessage(sender, "&b" + map + "&7 | &e" + invited);

View File

@ -50,7 +50,7 @@ public class MainCommand extends BRCommand {
int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length; int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length;
int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length; int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size(); int loaded = plugin.getWorlds().getEditWorlds().size() + plugin.getWorlds().getGameWorlds().size();
int players = plugin.getDPlayers().getDGamePlayers().size(); int players = plugin.getDPlayers().getDGamePlayers().size();
Internals internals = CompatibilityHandler.getInstance().getInternals(); Internals internals = CompatibilityHandler.getInstance().getInternals();
String vault = ""; String vault = "";

View File

@ -24,7 +24,6 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.config.WorldConfig; import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.player.DPermissions; import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.EditWorld; import io.github.dre2n.dungeonsxl.world.EditWorld;
import java.io.File;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -63,10 +62,10 @@ public class MsgCommand extends BRCommand {
try { try {
int id = NumberUtil.parseInt(args[1]); 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) { if (args.length == 2) {
String msg = confreader.getMsg(id, true); String msg = config.getMsg(id, true);
if (msg != null) { if (msg != null) {
MessageUtil.sendMessage(player, ChatColor.WHITE + msg); MessageUtil.sendMessage(player, ChatColor.WHITE + msg);
@ -89,7 +88,7 @@ public class MsgCommand extends BRCommand {
if (splitMsg.length > 1) { if (splitMsg.length > 1) {
msg = splitMsg[1]; msg = splitMsg[1];
String old = confreader.getMsg(id, false); String old = config.getMsg(id, false);
if (old == null) { if (old == null) {
MessageUtil.sendMessage(player, DMessages.CMD_MSG_ADDED.getMessage(String.valueOf(id))); 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))); MessageUtil.sendMessage(player, DMessages.CMD_MSG_UPDATED.getMessage(String.valueOf(id)));
} }
confreader.setMsg(msg, id); config.setMsg(msg, id);
confreader.save(); config.save();
} else { } else {
MessageUtil.sendMessage(player, DMessages.ERROR_MSG_FORMAT.getMessage()); MessageUtil.sendMessage(player, DMessages.ERROR_MSG_FORMAT.getMessage());

View File

@ -84,7 +84,7 @@ public class PlayCommand extends BRCommand {
} }
} }
if (!multiFloor && !EditWorld.exists(identifier)) { if (!multiFloor && !plugin.getWorlds().exists(identifier)) {
MessageUtil.sendMessage(player, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(identifier)); MessageUtil.sendMessage(player, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(identifier));
return; return;
} }

View File

@ -51,7 +51,7 @@ public class ReloadCommand extends BRCommand {
int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length; int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length;
int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length; int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size(); int loaded = plugin.getWorlds().getEditWorlds().size() + plugin.getWorlds().getGameWorlds().size();
int players = plugin.getDPlayers().getDGamePlayers().size(); int players = plugin.getDPlayers().getDGamePlayers().size();
Internals internals = CompatibilityHandler.getInstance().getInternals(); Internals internals = CompatibilityHandler.getInstance().getInternals();
String vault = ""; String vault = "";

View File

@ -17,12 +17,13 @@
package io.github.dre2n.dungeonsxl.command; package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.commons.command.BRCommand; 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.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL; import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DPermissions; import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.EditWorld; import io.github.dre2n.dungeonsxl.world.ResourceWorld;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
/** /**
@ -44,12 +45,15 @@ public class UninviteCommand extends BRCommand {
@Override @Override
public void onExecute(String[] args, CommandSender sender) { public void onExecute(String[] args, CommandSender sender) {
if (EditWorld.removeInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]), args[1])) { ResourceWorld resource = plugin.getWorlds().getResourceByName(args[2]);
MessageUtil.sendMessage(sender, DMessages.CMD_UNINVITE_SUCCESS.getMessage(args[1], args[2])); if (resource == null) {
} else {
MessageUtil.sendMessage(sender, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(args[2])); 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

@ -28,6 +28,7 @@ import io.github.dre2n.dungeonsxl.sign.DSign;
import io.github.dre2n.dungeonsxl.sign.MobSign; import io.github.dre2n.dungeonsxl.sign.MobSign;
import io.github.dre2n.dungeonsxl.trigger.ProgressTrigger; import io.github.dre2n.dungeonsxl.trigger.ProgressTrigger;
import io.github.dre2n.dungeonsxl.world.GameWorld; import io.github.dre2n.dungeonsxl.world.GameWorld;
import io.github.dre2n.dungeonsxl.world.ResourceWorld;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -77,9 +78,10 @@ public class Game {
dGroups.add(dGroup); dGroups.add(dGroup);
started = false; started = false;
world = new GameWorld(); // TO DO world = new GameWorld();
ResourceWorld resource = plugin.getWorlds().getResourceByName(worldName);
dGroup.setGameWorld(world); dGroup.setGameWorld(world);
world.load(worldName); resource.instantiateAsGameWorld();
fetchRules(); fetchRules();
} }

View File

@ -186,7 +186,7 @@ public class DPortal extends GlobalProtection {
} }
if (target == null && dGroup.getMapName() != null) { if (target == null && dGroup.getMapName() != null) {
target = new GameWorld(dGroup.getMapName()); target = plugin.getWorlds().getResourceByName(dGroup.getMapName()).instantiateAsGameWorld();//TO DO
dGroup.setGameWorld(target); dGroup.setGameWorld(target);
} }

View File

@ -469,7 +469,7 @@ public class GameSign extends GlobalProtection {
return false; return false;
} }
if (plugin.getGameWorlds().size() >= plugin.getMainConfig().getMaxInstances()) { if (plugin.getWorlds().getGameWorlds().size() >= plugin.getMainConfig().getMaxInstances()) {
MessageUtil.sendMessage(player, DMessages.ERROR_TOO_MANY_INSTANCES.getMessage()); MessageUtil.sendMessage(player, DMessages.ERROR_TOO_MANY_INSTANCES.getMessage());
return true; return true;
} }

View File

@ -231,7 +231,7 @@ public class BlockListener implements Listener {
} }
if (dsign.check()) { if (dsign.check()) {
editWorld.checkSign(block); editWorld.registerSign(block);
editWorld.getSigns().add(block); editWorld.getSigns().add(block);
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_SIGN_CREATED)); MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_SIGN_CREATED));

View File

@ -285,7 +285,7 @@ public class PlayerListener implements Listener {
} }
// Class Signs // Class Signs
for (Sign classSign : gameWorld.getSignClass()) { for (Sign classSign : gameWorld.getClassesSigns()) {
if (classSign != null) { if (classSign != null) {
if (classSign.getLocation().distance(clickedBlock.getLocation()) < 1) { if (classSign.getLocation().distance(clickedBlock.getLocation()) < 1) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
@ -538,7 +538,7 @@ public class PlayerListener implements Listener {
} }
if (dGroup.getGameWorld() == null) { if (dGroup.getGameWorld() == null) {
dGroup.setGameWorld(new GameWorld(DGroup.getByPlayer(player).getMapName())); dGroup.setGameWorld(plugin.getWorlds().getResourceByName(DGroup.getByPlayer(player).getMapName()).instantiateAsGameWorld());// TO DO
dGroup.getGameWorld().setTutorial(true); dGroup.getGameWorld().setTutorial(true);
} }
@ -578,7 +578,7 @@ public class PlayerListener implements Listener {
continue; continue;
} }
if (plugin.getGameWorlds().size() >= config.getMaxInstances()) { if (plugin.getWorlds().getGameWorlds().size() >= config.getMaxInstances()) {
event.setResult(PlayerLoginEvent.Result.KICK_FULL); event.setResult(PlayerLoginEvent.Result.KICK_FULL);
event.setKickMessage(DMessages.ERROR_TOO_MANY_TUTORIALS.getMessage()); event.setKickMessage(DMessages.ERROR_TOO_MANY_TUTORIALS.getMessage());
} }

View File

@ -39,6 +39,7 @@ import io.github.dre2n.dungeonsxl.reward.DLootInventory;
import io.github.dre2n.dungeonsxl.reward.Reward; import io.github.dre2n.dungeonsxl.reward.Reward;
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger; import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
import io.github.dre2n.dungeonsxl.world.GameWorld; import io.github.dre2n.dungeonsxl.world.GameWorld;
import io.github.dre2n.dungeonsxl.world.ResourceWorld;
import java.io.File; import java.io.File;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -698,8 +699,14 @@ public class DGamePlayer extends DInstancePlayer {
dGroup.removeUnplayedFloor(dGroup.getMapName()); dGroup.removeUnplayedFloor(dGroup.getMapName());
dGroup.setMapName(newFloor); dGroup.setMapName(newFloor);
GameWorld gameWorld = new GameWorld(newFloor);
ResourceWorld resource = plugin.getWorlds().getResourceByName(newFloor);
GameWorld gameWorld = null;
if (resource != null) {
gameWorld = resource.instantiateAsGameWorld();
}
dGroup.setGameWorld(gameWorld); dGroup.setGameWorld(gameWorld);
for (Player player : dGroup.getPlayers()) { for (Player player : dGroup.getPlayers()) {
DGamePlayer dPlayer = getByPlayer(player); DGamePlayer dPlayer = getByPlayer(player);
dPlayer.setWorld(gameWorld.getWorld()); dPlayer.setWorld(gameWorld.getWorld());

View File

@ -34,7 +34,6 @@ import io.github.dre2n.dungeonsxl.requirement.Requirement;
import io.github.dre2n.dungeonsxl.reward.Reward; import io.github.dre2n.dungeonsxl.reward.Reward;
import io.github.dre2n.dungeonsxl.task.TimeIsRunningTask; import io.github.dre2n.dungeonsxl.task.TimeIsRunningTask;
import io.github.dre2n.dungeonsxl.world.GameWorld; import io.github.dre2n.dungeonsxl.world.GameWorld;
import io.github.dre2n.dungeonsxl.world.Worlds;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
@ -422,7 +421,7 @@ public class DGroup {
* the name to set * the name to set
*/ */
public void setMapName(String name) { public void setMapName(String name) {
if (Worlds.exists(name)) { if (plugin.getWorlds().exists(name)) {
mapName = name; mapName = name;
} }
} }

View File

@ -65,7 +65,7 @@ public class ClassesSign extends DSign {
getSign().setLine(3, ChatColor.DARK_BLUE + "############"); getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update(); getSign().update();
getGameWorld().getSignClass().add(getSign()); getGameWorld().getClassesSigns().add(getSign());
} }
@Override @Override

View File

@ -155,7 +155,7 @@ public class ReadySign extends DSign {
return; return;
} }
if (getGameWorld().getSignClass().isEmpty() || dPlayer.getDClass() != null) { if (getGameWorld().getClassesSigns().isEmpty() || dPlayer.getDClass() != null) {
GameType forced = getGameWorld().getConfig().getForcedGameType(); GameType forced = getGameWorld().getConfig().getForcedGameType();
dPlayer.ready(forced == null ? gameType : forced); dPlayer.ready(forced == null ? gameType : forced);
} }

View File

@ -30,7 +30,7 @@ public class LazyUpdateTask extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
for (GameWorld gameWorld : plugin.getGameWorlds()) { for (GameWorld gameWorld : plugin.getWorlds().getGameWorlds()) {
gameWorld.update(); gameWorld.update();
} }

View File

@ -35,7 +35,7 @@ public class RedstoneEventTask extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
for (GameWorld gameWorld : DungeonsXL.getInstance().getGameWorlds()) { for (GameWorld gameWorld : DungeonsXL.getInstance().getWorlds().getGameWorlds()) {
if (block.getWorld() == gameWorld.getWorld()) { if (block.getWorld() == gameWorld.getWorld()) {
RedstoneTrigger.updateAll(gameWorld); RedstoneTrigger.updateAll(gameWorld);
} }

View File

@ -31,7 +31,7 @@ public class WorldUnloadTask extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
for (GameWorld gameWorld : plugin.getGameWorlds()) { for (GameWorld gameWorld : plugin.getWorlds().getGameWorlds()) {
if (gameWorld.getWorld().getPlayers().isEmpty()) { if (gameWorld.getWorld().getPlayers().isEmpty()) {
if (DGamePlayer.getByWorld(gameWorld.getWorld()).isEmpty()) { if (DGamePlayer.getByWorld(gameWorld.getWorld()).isEmpty()) {
gameWorld.delete(); gameWorld.delete();
@ -39,9 +39,9 @@ public class WorldUnloadTask extends BukkitRunnable {
} }
} }
for (EditWorld editWorld : plugin.getEditWorlds()) { for (EditWorld editWorld : plugin.getWorlds().getEditWorlds()) {
if (editWorld.getWorld().getPlayers().isEmpty()) { if (editWorld.getWorld().getPlayers().isEmpty()) {
editWorld.delete(); editWorld.delete(true);
} }
} }
} }

View File

@ -17,27 +17,14 @@
package io.github.dre2n.dungeonsxl.world; package io.github.dre2n.dungeonsxl.world;
import io.github.dre2n.commons.util.FileUtil; 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.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.event.editworld.EditWorldGenerateEvent;
import io.github.dre2n.dungeonsxl.event.editworld.EditWorldLoadEvent;
import io.github.dre2n.dungeonsxl.event.editworld.EditWorldSaveEvent; import io.github.dre2n.dungeonsxl.event.editworld.EditWorldSaveEvent;
import io.github.dre2n.dungeonsxl.event.editworld.EditWorldUnloadEvent; import io.github.dre2n.dungeonsxl.event.editworld.EditWorldUnloadEvent;
import io.github.dre2n.dungeonsxl.player.DGamePlayer; import io.github.dre2n.dungeonsxl.player.DEditPlayer;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -45,148 +32,17 @@ import org.bukkit.entity.Player;
/** /**
* @author Frank Baumann, Daniel Saukel * @author Frank Baumann, Daniel Saukel
*/ */
public class EditWorld { public class EditWorld extends InstanceWorld {
static DungeonsXL plugin = DungeonsXL.getInstance(); static Worlds worlds = plugin.getWorlds();
// Variables
private World world;
private String owner;
private String name;
private String mapName;
private int id;
private Location lobby;
private CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<Block> signs = new CopyOnWriteArrayList<>(); private CopyOnWriteArrayList<Block> signs = new CopyOnWriteArrayList<>();
public EditWorld() { EditWorld(ResourceWorld resourceWorld, File folder, World world, int id) {
plugin.getEditWorlds().add(this); super(resourceWorld, folder, world, id);
// ID
id = -1;
int i = -1;
while (id == -1) {
i++;
boolean exist = false;
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.id == i) {
exist = true;
break;
}
}
if (!exist) {
id = i;
}
}
name = "DXL_Edit_" + id;
}
/**
* @return the world
*/
public World getWorld() {
return world;
}
/**
* @param world
* the world to set
*/
public void setWorld(World world) {
this.world = world;
}
/**
* @return the owner
*/
public String getOwner() {
return owner;
}
/**
* @param owner
* the owner to set
*/
public void setOwner(String owner) {
this.owner = owner;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the mapName
*/
public String getMapName() {
return mapName;
}
/**
* @param mapName
* the mapName to set
*/
public void setMapName(String mapName) {
this.mapName = mapName;
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the location of the lobby
*/
public Location getLobbyLocation() {
return lobby;
}
/**
* @param lobby
* the lobby to set
*/
public void setLobby(Location lobby) {
this.lobby = lobby;
}
/**
* @return the invitedPlayers
*/
public CopyOnWriteArrayList<String> getInvitedPlayers() {
return invitedPlayers;
}
/**
* @param invitedPlayers
* the invitedPlayers to set
*/
public void setInvitedPlayers(CopyOnWriteArrayList<String> invitedPlayers) {
this.invitedPlayers = invitedPlayers;
} }
/* Getters and setters */
/** /**
* @return the signs * @return the signs
*/ */
@ -202,21 +58,27 @@ public class EditWorld {
this.signs = signs; this.signs = signs;
} }
public void generate() { /* Actions */
WorldCreator creator = WorldCreator.name(name); /**
creator.type(WorldType.FLAT); * Registers the block as a DSign sothat it can later be saved persistently.
creator.generateStructures(false); *
* @param block
* a DSign block
*/
public void registerSign(Block block) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
String[] lines = sign.getLines();
EditWorldGenerateEvent event = new EditWorldGenerateEvent(this); if (lines[0].equalsIgnoreCase("[lobby]")) {
plugin.getServer().getPluginManager().callEvent(event); setLobbyLocation(block.getLocation());
}
if (event.isCancelled()) {
return;
} }
world = plugin.getServer().createWorld(creator);
} }
/**
* Saves the sign data and overrides the resource with the changes.
*/
public void save() { public void save() {
EditWorldSaveEvent event = new EditWorldSaveEvent(this); EditWorldSaveEvent event = new EditWorldSaveEvent(this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
@ -225,38 +87,29 @@ public class EditWorld {
return; return;
} }
world.save(); getWorld().save();
File dir = new File("DXL_Edit_" + id); FileUtil.copyDirectory(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName), DungeonsXL.EXCLUDED_FILES); FileUtil.deleteUnusedFiles(getResource().getFolder());
FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
try { try {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(plugin.getDataFolder(), "/maps/" + mapName + "/DXLData.data"))); getResource().getSignData().serializeSigns(signs);
out.writeInt(signs.size());
for (Block sign : signs) {
out.writeInt(sign.getX());
out.writeInt(sign.getY());
out.writeInt(sign.getZ());
}
out.close();
} catch (IOException exception) { } catch (IOException exception) {
} }
} }
public void checkSign(Block block) { @Override
if (block.getState() instanceof Sign) { public void delete() {
Sign sign = (Sign) block.getState(); delete(true);
String[] lines = sign.getLines();
if (lines[0].equalsIgnoreCase("[lobby]")) {
lobby = block.getLocation();
}
}
} }
public void delete() { /**
* Deletes this edit instance.
*
* @param save
* whether this world should be saved
*/
public void delete(boolean save) {
EditWorldUnloadEvent event = new EditWorldUnloadEvent(this, true); EditWorldUnloadEvent event = new EditWorldUnloadEvent(this, true);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
@ -264,217 +117,51 @@ public class EditWorld {
return; return;
} }
plugin.getEditWorlds().remove(this); worlds.getInstances().remove(this);
for (Player player : world.getPlayers()) { for (Player player : getWorld().getPlayers()) {
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player); DEditPlayer dPlayer = DEditPlayer.getByPlayer(player);
dPlayer.leave(); dPlayer.leave();
} }
plugin.getServer().unloadWorld(world, true); if (save) {
File dir = new File("DXL_Edit_" + id); plugin.getServer().unloadWorld(getWorld(), true);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName), DungeonsXL.EXCLUDED_FILES);
FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.removeDirectory(dir);
}
public void deleteNoSave() {
EditWorldUnloadEvent event = new EditWorldUnloadEvent(this, false);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
} }
plugin.getEditWorlds().remove(this); FileUtil.copyDirectory(getFolder(), getResource().getFolder(), DungeonsXL.EXCLUDED_FILES);
for (Player player : world.getPlayers()) { FileUtil.deleteUnusedFiles(getResource().getFolder());
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
dPlayer.leave(); if (!save) {
plugin.getServer().unloadWorld(getWorld(), true);
} }
File dir = new File("DXL_Edit_" + id); FileUtil.removeDirectory(getFolder());
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName), DungeonsXL.EXCLUDED_FILES);
FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
plugin.getServer().unloadWorld(world, true);
FileUtil.removeDirectory(dir);
}
public void sendMessage(String message) {
for (DGamePlayer dPlayer : DGamePlayer.getByWorld(world)) {
MessageUtil.sendMessage(dPlayer.getPlayer(), message);
}
} }
/* Statics */ /* Statics */
/**
* @param world
* the instance
* @return
* the EditWorld that represents the world
*/
public static EditWorld getByWorld(World world) { public static EditWorld getByWorld(World world) {
for (EditWorld editWorld : plugin.getEditWorlds()) { return getByName(world.getName());
if (editWorld.world.equals(world)) {
return editWorld;
}
}
return null;
} }
/**
* @param world
* the instance name
* @return
* the EditWorld that represents the world
*/
public static EditWorld getByName(String name) { public static EditWorld getByName(String name) {
for (EditWorld editWorld : plugin.getEditWorlds()) { InstanceWorld instance = worlds.getInstanceByName(name);
if (editWorld.mapName.equalsIgnoreCase(name)) {
return editWorld;
}
}
return null; if (instance instanceof EditWorld) {
} return (EditWorld) instance;
public static void deleteAll() {
for (EditWorld editWorld : plugin.getEditWorlds()) {
editWorld.delete();
}
}
public static EditWorld load(String name) {
EditWorldLoadEvent event = new EditWorldLoadEvent(name);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return null;
}
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.mapName.equalsIgnoreCase(name)) {
return editWorld;
}
}
File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) {
EditWorld editWorld = new EditWorld();
editWorld.mapName = name;
// World
FileUtil.copyDirectory(file, new File("DXL_Edit_" + editWorld.id), DungeonsXL.EXCLUDED_FILES);
// Id File
File idFile = new File("DXL_Edit_" + editWorld.id + "/.id_" + name);
try {
idFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
editWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Edit_" + editWorld.id));
try {
ObjectInputStream os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder(), "/maps/" + editWorld.mapName + "/DXLData.data")));
int length = os.readInt();
for (int i = 0; i < length; i++) {
int x = os.readInt();
int y = os.readInt();
int z = os.readInt();
Block block = editWorld.world.getBlockAt(x, y, z);
editWorld.checkSign(block);
editWorld.signs.add(block);
}
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return editWorld;
}
return null;
}
public static boolean exists(String name) {
// Cheack Loaded EditWorlds
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.mapName.equalsIgnoreCase(name)) {
return true;
}
}
// Cheack Unloaded Worlds
File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) {
return true;
}
return false;
}
// Invite
public static boolean addInvitedPlayer(String editWorldName, UUID uuid) {
if (!exists(editWorldName)) {
return false;
}
File file = new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException exception) {
exception.printStackTrace();
return false;
}
}
WorldConfig config = new WorldConfig(file);
config.addInvitedPlayer(uuid.toString());
config.save();
return true;
}
public static boolean removeInvitedPlayer(String editWorldName, UUID uuid, String name) {
if (!exists(editWorldName)) {
return false;
}
File file = new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml");
if (!file.exists()) {
return false;
}
WorldConfig config = new WorldConfig(file);
config.removeInvitedPlayers(uuid.toString(), name.toLowerCase());
config.save();
// Kick Player
EditWorld editWorld = EditWorld.getByName(editWorldName);
if (editWorld != null) {
DGamePlayer player = DGamePlayer.getByName(name);
if (player != null) {
if (editWorld.world.getPlayers().contains(player.getPlayer())) {
player.leave();
}
}
}
return true;
}
public static boolean isInvitedPlayer(String editWorldName, UUID uuid, String name) {
if (!exists(editWorldName)) {
return false;
}
File file = new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml");
if (!file.exists()) {
return false;
}
WorldConfig config = new WorldConfig(file);
// get player from both a 0.9.1 and lower and 0.9.2 and higher file
if (config.getInvitedPlayers().contains(name.toLowerCase()) || config.getInvitedPlayers().contains(uuid.toString())) {
return true;
} else { } else {
return false; return null;
} }
} }

View File

@ -17,18 +17,14 @@
package io.github.dre2n.dungeonsxl.world; package io.github.dre2n.dungeonsxl.world;
import io.github.dre2n.commons.util.FileUtil; 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.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DungeonConfig; 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.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.GameWorldStartGameEvent;
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldUnloadEvent; import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldUnloadEvent;
import io.github.dre2n.dungeonsxl.game.Game; import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.game.GamePlaceableBlock; import io.github.dre2n.dungeonsxl.game.GamePlaceableBlock;
import io.github.dre2n.dungeonsxl.mob.DMob; 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.player.DGroup;
import io.github.dre2n.dungeonsxl.reward.RewardChest; import io.github.dre2n.dungeonsxl.reward.RewardChest;
import io.github.dre2n.dungeonsxl.sign.DSign; import io.github.dre2n.dungeonsxl.sign.DSign;
@ -42,19 +38,12 @@ import io.github.dre2n.dungeonsxl.trigger.Trigger;
import io.github.dre2n.dungeonsxl.trigger.TriggerType; import io.github.dre2n.dungeonsxl.trigger.TriggerType;
import io.github.dre2n.dungeonsxl.trigger.TriggerTypeDefault; import io.github.dre2n.dungeonsxl.trigger.TriggerTypeDefault;
import java.io.File; 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.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -65,54 +54,26 @@ import org.bukkit.inventory.ItemStack;
/** /**
* @author Frank Baumann, Milan Albrecht, Daniel Saukel * @author Frank Baumann, Milan Albrecht, Daniel Saukel
*/ */
public class GameWorld { public class GameWorld extends InstanceWorld {
static DungeonsXL plugin = DungeonsXL.getInstance(); static DungeonsXL plugin = DungeonsXL.getInstance();
// Variables // Variables
private boolean tutorial; private boolean tutorial;
private CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<>();
private World world;
private String mapName;
private Location locLobby;
private boolean isPlaying = false; 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<>(); private CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<>();
// TODO: Killed mobs
private CopyOnWriteArrayList<RewardChest> rewardChests = new CopyOnWriteArrayList<>(); private CopyOnWriteArrayList<RewardChest> rewardChests = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<>(); private CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<>();
private CopyOnWriteArrayList<Trigger> triggers = new CopyOnWriteArrayList<>(); private CopyOnWriteArrayList<Trigger> triggers = new CopyOnWriteArrayList<>();
private WorldConfig worldConfig;
public GameWorld() { GameWorld(ResourceWorld resourceWorld, File folder, World world, int id) {
plugin.getGameWorlds().add(this); super(resourceWorld, folder, world, id);
// 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);
} }
/** /**
@ -145,63 +106,18 @@ public class GameWorld {
} }
/** /**
* @return the placeableBlocks * @return the isPlaying
*/ */
public CopyOnWriteArrayList<GamePlaceableBlock> getPlaceableBlocks() { public boolean isPlaying() {
return placeableBlocks; return isPlaying;
} }
/** /**
* @param placeableBlocks * @param isPlaying
* the placeableBlocks to set * the isPlaying to set
*/ */
public void setPlaceableBlocks(CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks) { public void setPlaying(boolean isPlaying) {
this.placeableBlocks = placeableBlocks; this.isPlaying = isPlaying;
}
/**
* @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;
} }
/** /**
@ -227,41 +143,26 @@ public class GameWorld {
} }
// Lobby location as fallback // Lobby location as fallback
if (locLobby != null) { if (getLobbyLocation() != null) {
return locLobby; return getLobbyLocation();
} }
return world.getSpawnLocation(); return getWorld().getSpawnLocation();
} }
/** /**
* @return the isPlaying * @return the placeableBlocks
*/ */
public boolean isPlaying() { public CopyOnWriteArrayList<GamePlaceableBlock> getPlaceableBlocks() {
return isPlaying; return placeableBlocks;
} }
/** /**
* @param isPlaying * @param placeableBlocks
* the isPlaying to set * the placeableBlocks to set
*/ */
public void setPlaying(boolean isPlaying) { public void setPlaceableBlocks(CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks) {
this.isPlaying = isPlaying; this.placeableBlocks = placeableBlocks;
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(int id) {
this.id = id;
} }
/** /**
@ -295,18 +196,18 @@ public class GameWorld {
} }
/** /**
* @return the signClass * @return the classes signs
*/ */
public CopyOnWriteArrayList<Sign> getSignClass() { public CopyOnWriteArrayList<Sign> getClassesSigns() {
return signClass; return classesSigns;
} }
/** /**
* @param signClass * @param classes signs
* the signClass to set * the classes signs to set
*/ */
public void setSignClass(CopyOnWriteArrayList<Sign> signClass) { public void setClasses(CopyOnWriteArrayList<Sign> signs) {
this.signClass = signClass; classesSigns = signs;
} }
/** /**
@ -437,32 +338,13 @@ public class GameWorld {
return mobCount; return mobCount;
} }
/**
* @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 GameWorld
*/ */
public Dungeon getDungeon() { public Dungeon getDungeon() {
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) { for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
DungeonConfig dungeonConfig = dungeon.getConfig(); DungeonConfig dungeonConfig = dungeon.getConfig();
if (dungeonConfig.getFloors().contains(mapName) || dungeonConfig.getStartFloor().equals(mapName) || dungeonConfig.getEndFloor().equals(mapName)) { if (dungeonConfig.getFloors().contains(getName()) || dungeonConfig.getStartFloor().equals(getName()) || dungeonConfig.getEndFloor().equals(getName())) {
return dungeon; return dungeon;
} }
} }
@ -470,13 +352,9 @@ public class GameWorld {
return null; return null;
} }
public void checkSign(Block block) { /**
if (block.getState() instanceof Sign) { * Set up the instance for the game
Sign sign = (Sign) block.getState(); */
dSigns.add(DSign.create(sign, this));
}
}
public void startGame() { public void startGame() {
GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, getGame()); GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, getGame());
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
@ -508,12 +386,10 @@ public class GameWorld {
} }
} }
public void sendMessage(String message) { /**
for (DGamePlayer dPlayer : DGamePlayer.getByWorld(world)) { * Delete this instance.
MessageUtil.sendMessage(dPlayer.getPlayer(), message); */
} @Override
}
public void delete() { public void delete() {
GameWorldUnloadEvent event = new GameWorldUnloadEvent(this); GameWorldUnloadEvent event = new GameWorldUnloadEvent(this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
@ -522,12 +398,14 @@ public class GameWorld {
return; return;
} }
plugin.getGameWorlds().remove(this); plugin.getWorlds().getInstances().remove(this);
plugin.getServer().unloadWorld(world, true); plugin.getServer().unloadWorld(getWorld(), true);
File dir = new File("DXL_Game_" + id); FileUtil.removeDirectory(getFolder());
FileUtil.removeDirectory(dir);
} }
/**
* Ongoing updates
*/
public void update() { public void update() {
if (getWorld() == null) { if (getWorld() == null) {
return; return;
@ -542,6 +420,7 @@ public class GameWorld {
continue; continue;
} }
} }
for (Entity player : spider.getNearbyEntities(10, 10, 10)) { for (Entity player : spider.getNearbyEntities(10, 10, 10)) {
if (player.getType() == EntityType.PLAYER) { if (player.getType() == EntityType.PLAYER) {
spider.setTarget((LivingEntity) player); spider.setTarget((LivingEntity) player);
@ -551,86 +430,21 @@ public class GameWorld {
} }
} }
public void load(String name) {
GameWorldLoadEvent event = new GameWorldLoadEvent(name);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) {
mapName = name;
// Unload empty editWorlds
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.getWorld().getPlayers().isEmpty()) {
editWorld.delete();
}
}
// Config einlesen
worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + mapName, "config.yml"));
// Secure Objects
secureObjects = worldConfig.getSecureObjects();
if (Bukkit.getWorld("DXL_Game_" + id) == null) {
// World
FileUtil.copyDirectory(file, new File("DXL_Game_" + id), DungeonsXL.EXCLUDED_FILES);
// Id File
File idFile = new File("DXL_Game_" + id + "/.id_" + name);
try {
idFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
world = plugin.getServer().createWorld(WorldCreator.name("DXL_Game_" + id));
ObjectInputStream os;
try {
os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder() + "/maps/" + mapName + "/DXLData.data")));
int length = os.readInt();
for (int i = 0; i < length; i++) {
int x = os.readInt();
int y = os.readInt();
int z = os.readInt();
Block block = world.getBlockAt(x, y, z);
checkSign(block);
}
os.close();
} catch (FileNotFoundException exception) {
MessageUtil.log(plugin, "Could not find any sign data for the world \"" + name + "\"!");
} catch (IOException exception) {
exception.printStackTrace();
}
}
}
}
/* Statics */ /* Statics */
/**
* @param world
* the instance
* @return
* the EditWorld that represents the world
*/
public static GameWorld getByWorld(World world) { public static GameWorld getByWorld(World world) {
for (GameWorld gameWorld : plugin.getGameWorlds()) { InstanceWorld instance = plugin.getWorlds().getInstanceByName(world.getName());
if (gameWorld.getWorld() != null && gameWorld.getWorld().equals(world)) {
return gameWorld;
}
}
return null; if (instance instanceof GameWorld) {
} return (GameWorld) instance;
public static void deleteAll() { } else {
for (GameWorld gameWorld : plugin.getGameWorlds()) { return null;
gameWorld.delete();
} }
} }

View File

@ -16,27 +16,34 @@
*/ */
package io.github.dre2n.dungeonsxl.world; 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.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.WorldConfig; 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.Location;
import org.bukkit.World; import org.bukkit.World;
/** /**
* @author Daniel Saukel * @author Daniel Saukel
*/ */
public class InstanceWorld { public abstract class InstanceWorld {
DungeonsXL plugin = DungeonsXL.getInstance(); protected static DungeonsXL plugin = DungeonsXL.getInstance();
public static String ID_FILE_PREFIX = ".id_"; public static String ID_FILE_PREFIX = ".id_";
private ResourceWorld resourceWorld; private ResourceWorld resourceWorld;
private File folder;
private World world; private World world;
private File idFile;
private int id; private int id;
private Location lobby; private Location lobby;
InstanceWorld(ResourceWorld resourceWorld, World world, int id) { InstanceWorld(ResourceWorld resourceWorld, File folder, World world, int id) {
this.resourceWorld = resourceWorld; this.resourceWorld = resourceWorld;
this.folder = folder;
this.world = world; this.world = world;
this.id = id; this.id = id;
} }
@ -56,6 +63,20 @@ public class InstanceWorld {
return resourceWorld.getConfig(); return resourceWorld.getConfig();
} }
/**
* @return the ResourceWorld of that this world is an instance
*/
public ResourceWorld getResource() {
return resourceWorld;
}
/**
* @return the folder of the instance
*/
public File getFolder() {
return folder;
}
/** /**
* @return the instance * @return the instance
*/ */
@ -63,6 +84,13 @@ public class InstanceWorld {
return world; return world;
} }
/**
* @return the file that stores the ID
*/
public File getIdFile() {
return idFile;
}
/** /**
* @return the unique ID * @return the unique ID
*/ */
@ -85,11 +113,35 @@ public class InstanceWorld {
this.lobby = lobby; this.lobby = lobby;
} }
/* Actions */
/** /**
* @return the ResourceWorld of that this world is an instance * Sends a message to all players in the instance.
*
* @param message
* the message to send
*/ */
public ResourceWorld getResource() { public void sendMessage(String message) {
return resourceWorld; 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

@ -20,11 +20,14 @@ import io.github.dre2n.commons.util.FileUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL; import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.SignData; import io.github.dre2n.dungeonsxl.config.SignData;
import io.github.dre2n.dungeonsxl.config.WorldConfig; import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
/** /**
* This class represents unloaded worlds. * This class represents unloaded worlds.
@ -34,11 +37,31 @@ import org.bukkit.WorldCreator;
public class ResourceWorld { public class ResourceWorld {
DungeonsXL plugin = DungeonsXL.getInstance(); DungeonsXL plugin = DungeonsXL.getInstance();
Worlds worlds = plugin.getWorlds();
private File folder; private File folder;
private WorldConfig config; private WorldConfig config;
private SignData signData; private SignData signData;
public ResourceWorld(String name) {
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 ResourceWorld(File folder) { public ResourceWorld(File folder) {
this.folder = folder; this.folder = folder;
@ -90,6 +113,53 @@ public class ResourceWorld {
return signData; 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 (EditWorld.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 */ /* Actions */
/** /**
* @param game * @param game
@ -97,8 +167,8 @@ public class ResourceWorld {
* @return an instance of this world * @return an instance of this world
*/ */
public InstanceWorld instantiate(boolean game) { public InstanceWorld instantiate(boolean game) {
int id = plugin.getWorlds().getInstances().size(); int id = worlds.generateId();
String name = "DXL_" + (game ? "Game" : "Edit") + "_" + id; String name = worlds.generateName(game);
File instanceFolder = new File(Bukkit.getWorldContainer(), name); File instanceFolder = new File(Bukkit.getWorldContainer(), name);
FileUtil.copyDirectory(folder, instanceFolder, DungeonsXL.EXCLUDED_FILES); FileUtil.copyDirectory(folder, instanceFolder, DungeonsXL.EXCLUDED_FILES);
@ -108,19 +178,14 @@ public class ResourceWorld {
World world = plugin.getServer().createWorld(WorldCreator.name(name)); World world = plugin.getServer().createWorld(WorldCreator.name(name));
File idFile = new File(name, InstanceWorld.ID_FILE_PREFIX + getName()); InstanceWorld instance = null;
try {
idFile.createNewFile();
} catch (IOException exception) {
exception.printStackTrace();
}
InstanceWorld instance = new InstanceWorld(this, world, id);
try { try {
if (game) { if (game) {
new GameWorld(this, instanceFolder, world, id);
signData.deserializeSigns((GameWorld) instance); signData.deserializeSigns((GameWorld) instance);
} else { } else {
new EditWorld(this, instanceFolder, world, id);
signData.deserializeSigns((EditWorld) instance); signData.deserializeSigns((EditWorld) instance);
} }
@ -145,4 +210,32 @@ public class ResourceWorld {
return (GameWorld) instantiate(true); return (GameWorld) instantiate(true);
} }
/**
* Generate a new ResourceWorld.
*
* @return the automatically created EditWorld instance
*/
public EditWorld 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);
EditWorld editWorld = new EditWorld(this, folder, world, id);
editWorld.generateIdFile();
return editWorld;
}
} }

View File

@ -16,9 +16,13 @@
*/ */
package io.github.dre2n.dungeonsxl.world; package io.github.dre2n.dungeonsxl.world;
import io.github.dre2n.commons.util.FileUtil;
import io.github.dre2n.commons.util.NumberUtil; import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import java.io.File; import java.io.File;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.bukkit.Bukkit;
/** /**
* @author Daniel Saukel * @author Daniel Saukel
@ -89,4 +93,116 @@ public class Worlds {
return instances; return instances;
} }
/**
* @return the loaded GameWorlds
*/
public Set<GameWorld> getGameWorlds() {
Set<GameWorld> gameWorlds = new HashSet<>();
for (InstanceWorld instance : instances) {
if (instance instanceof GameWorld) {
gameWorlds.add((GameWorld) instance);
}
}
return gameWorlds;
}
/**
* @return the loaded EditWorlds
*/
public Set<EditWorld> getEditWorlds() {
Set<EditWorld> editWorlds = new HashSet<>();
for (InstanceWorld instance : instances) {
if (instance instanceof GameWorld) {
editWorlds.add((EditWorld) 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 (ResourceWorld resource : resources) {
if (resource.getName().equalsIgnoreCase(name)) {
return true;
}
}
for (InstanceWorld 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 (InstanceWorld instance : instances) {
instance.delete();
}
}
/**
* Saves all EditWorlds.
*/
public void saveAll() {
for (EditWorld editWorld : getEditWorlds()) {
editWorld.save();
}
}
/**
* @return an ID for the instance
*/
public int generateId() {
int id = 0;
for (InstanceWorld 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 GameWorld
*/
public String generateName(boolean game) {
return "DXL_" + (game ? "Game" : "Edit") + "_" + generateId();
}
} }

View File

@ -61,13 +61,13 @@ public class DGroupListener implements Listener {
@EventHandler @EventHandler
public void onStartFloor(DGroupStartFloorEvent event) { public void onStartFloor(DGroupStartFloorEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "=="); MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "GameWorld: " + event.getGameWorld().getMapName()); MessageUtil.log(plugin, "GameWorld: " + event.getGameWorld().getName());
} }
@EventHandler @EventHandler
public void onFinishFloor(DGroupFinishFloorEvent event) { public void onFinishFloor(DGroupFinishFloorEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "=="); MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "Finished: " + event.getFinished().getMapName()); MessageUtil.log(plugin, "Finished: " + event.getFinished().getName());
MessageUtil.log(plugin, "Next: " + event.getNext()); MessageUtil.log(plugin, "Next: " + event.getNext());
} }