diff --git a/abstract/pom.xml b/abstract/pom.xml
index 9d63db57..d9e5f070 100644
--- a/abstract/pom.xml
+++ b/abstract/pom.xml
@@ -8,6 +8,6 @@
io.github.dre2n
dungeonsxl
- 0.15.3-SNAPSHOT
+ 0.15.3
diff --git a/core/pom.xml b/core/pom.xml
index 2087f4bb..8d227c85 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -8,7 +8,7 @@
io.github.dre2n
dungeonsxl
- 0.15.3-SNAPSHOT
+ 0.15.3
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/command/EnterCommand.java b/core/src/main/java/io/github/dre2n/dungeonsxl/command/EnterCommand.java
index 32ccea28..f6d2ac2e 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/command/EnterCommand.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/command/EnterCommand.java
@@ -76,7 +76,7 @@ public class EnterCommand extends BRCommand {
}
if (joining == null) {
- joining = new DGroup(captain, game.getWorld().getName(), game.getDungeon() != null);
+ joining = new DGroup(captain, game.getDungeon());
}
if (joining.getCaptain() != captain && !DPermissions.hasPermission(sender, DPermissions.BYPASS)) {
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/command/PlayCommand.java b/core/src/main/java/io/github/dre2n/dungeonsxl/command/PlayCommand.java
index cdf3b311..2a431b7a 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/command/PlayCommand.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/command/PlayCommand.java
@@ -97,9 +97,10 @@ public class PlayCommand extends BRCommand {
}
if (dGroup.getMapName() == null) {
- dGroup.setMapName(mapName);
if (multiFloor) {
- dGroup.setDungeonName(identifier);
+ dGroup.setDungeon(plugin.getDungeons().getByName(identifier));
+ } else {
+ dGroup.setDungeon(mapName);
}
} else {
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/command/RenameCommand.java b/core/src/main/java/io/github/dre2n/dungeonsxl/command/RenameCommand.java
index 4ee0d751..7070c3c7 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/command/RenameCommand.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/command/RenameCommand.java
@@ -60,6 +60,7 @@ public class RenameCommand extends BRCommand {
resource.setName(args[2]);
resource.getFolder().renameTo(new File(DungeonsXL.MAPS, args[2]));
+ resource.getSignData().updateFile(resource);
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
DungeonConfig dConfig = dungeon.getConfig();
@@ -93,14 +94,16 @@ public class RenameCommand extends BRCommand {
boolean changed = false;
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections()) {
if (protection instanceof GroupSign) {
- if (((GroupSign) protection).getMapName().equals(args[1])) {
- ((GroupSign) protection).setMapName(args[2]);
+ Dungeon dungeon = ((GroupSign) protection).getDungeon();
+ if (dungeon.getName().equals(args[1])) {
+ dungeon.setName(args[2]);
changed = true;
}
} else if (protection instanceof GameSign) {
- if (((GameSign) protection).getMapName().equals(args[1])) {
- ((GameSign) protection).setMapName(args[2]);
+ Dungeon dungeon = ((GameSign) protection).getDungeon();
+ if (dungeon.getName().equals(args[1])) {
+ dungeon.setName(args[2]);
changed = true;
}
}
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/config/SignData.java b/core/src/main/java/io/github/dre2n/dungeonsxl/config/SignData.java
index 733a2307..a40823c3 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/config/SignData.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/config/SignData.java
@@ -19,6 +19,7 @@ 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 io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -58,6 +59,10 @@ public class SignData {
return file;
}
+ public void updateFile(DResourceWorld resource) {
+ file = new File(resource.getFolder(), "DXLData.data");
+ }
+
/* Actions */
/**
* Applies all signs from the file to the DEditWorld.
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeon.java b/core/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeon.java
index 75155018..f15f9e8a 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeon.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeon.java
@@ -18,7 +18,11 @@ package io.github.dre2n.dungeonsxl.dungeon;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
/**
* Represents a dungeon.
@@ -31,19 +35,23 @@ public class Dungeon {
private String name;
private DungeonConfig config;
+ private DResourceWorld map;
+ /**
+ * Real dungeon
+ */
public Dungeon(File file) {
- this.name = file.getName().replaceAll(".yml", "");
- this.config = new DungeonConfig(file);
+ name = file.getName().replaceAll(".yml", "");
+ config = new DungeonConfig(file);
+ map = config.getStartFloor();
}
- public Dungeon(String name) {
- this.name = name;
-
- File file = new File(DungeonsXL.DUNGEONS, name + ".yml");
- if (file.exists()) {
- this.config = new DungeonConfig(file);
- }
+ /**
+ * Artificial dungeon
+ */
+ public Dungeon(DResourceWorld resource) {
+ name = resource.getName();
+ map = resource;
}
/**
@@ -53,6 +61,14 @@ public class Dungeon {
return name;
}
+ /**
+ * @param name
+ * the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
/**
* @return the config
*/
@@ -67,11 +83,55 @@ public class Dungeon {
return config != null;
}
+ /**
+ * @return
+ * the floors of the dungeon
+ */
+ public List getFloors() {
+ if (isMultiFloor()) {
+ return config.getFloors();
+ } else {
+ return new ArrayList<>(Arrays.asList(map));
+ }
+ }
+
+ /**
+ * @return
+ * the SFD map / start floor
+ */
+ public DResourceWorld getMap() {
+ return map;
+ }
+
+ /**
+ * @param map
+ * the SFD map / start floor to set
+ */
+ public void setMap(DResourceWorld map) {
+ this.map = map;
+ }
+
/**
* @return false if there are setup errors
*/
public boolean isSetupCorrect() {
+ for (DResourceWorld resource : DungeonsXL.getInstance().getDWorlds().getResources()) {
+ if (resource.getName().equals(name)) {
+ return false;
+ }
+ }
return config.getStartFloor() != null && config.getEndFloor() != null;
}
+ /* Statics */
+ /**
+ * @param name
+ * the name of the dungeon
+ * @return
+ * the file. Might not exist
+ */
+ public static File getFileFromName(String name) {
+ return new File(DungeonsXL.DUNGEONS, name + ".yml");
+ }
+
}
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeons.java b/core/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeons.java
index 638cd2ef..f4171b40 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeons.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/dungeon/Dungeons.java
@@ -76,7 +76,7 @@ public class Dungeons {
* @return the Dungeon that has the name
*/
public Dungeon loadDungeon(String name) {
- Dungeon dungeon = new Dungeon(name);
+ Dungeon dungeon = new Dungeon(Dungeon.getFileFromName(name));
dungeons.add(dungeon);
return dungeon;
}
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/global/DPortal.java b/core/src/main/java/io/github/dre2n/dungeonsxl/global/DPortal.java
index 5dab6fd2..ededdaa5 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/global/DPortal.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/global/DPortal.java
@@ -203,8 +203,8 @@ public class DPortal extends GlobalProtection {
}
}
- if (target == null && dGroup.getMapName() != null) {
- DResourceWorld resource = plugin.getDWorlds().getResourceByName(dGroup.getMapName());
+ if (target == null && dGroup.getDungeon() != null) {
+ DResourceWorld resource = dGroup.getDungeon().getMap();
if (resource != null) {
target = resource.instantiateAsGameWorld();
dGroup.setGameWorld(target);
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/global/GameSign.java b/core/src/main/java/io/github/dre2n/dungeonsxl/global/GameSign.java
index 3f98e3c3..2f7a6b2c 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/global/GameSign.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/global/GameSign.java
@@ -21,7 +21,9 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.game.Game;
+import static io.github.dre2n.dungeonsxl.global.GlobalProtection.plugin;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -48,31 +50,24 @@ public class GameSign extends GlobalProtection {
// Variables
private Game[] games;
- private boolean multiFloor;
- private String dungeonName;
- private String mapName;
+ private Dungeon dungeon;
private int maxGroupsPerGame;
private Block startSign;
private int directionX = 0, directionZ = 0;
private int verticalSigns;
private Set blocks;
- public GameSign(int id, Block startSign, String identifier, int maxGames, int maxGroupsPerGame, boolean multiFloor) {
+ public GameSign(int id, Block startSign, String identifier, int maxGames, int maxGroupsPerGame) {
super(startSign.getWorld(), id);
this.startSign = startSign;
games = new Game[maxGames];
- this.setMultiFloor(multiFloor);
- if (multiFloor) {
- dungeonName = identifier;
- Dungeon dungeon = plugin.getDungeons().getByName(identifier);
- if (dungeon != null) {
- mapName = dungeon.getConfig().getStartFloor().getName();
- } else {
- mapName = "invalid";
+ dungeon = plugin.getDungeons().getByName(identifier);
+ if (dungeon == null) {
+ DResourceWorld resource = plugin.getDWorlds().getResourceByName(identifier);
+ if (resource != null) {
+ dungeon = new Dungeon(resource);
}
- } else {
- mapName = identifier;
}
this.maxGroupsPerGame = maxGroupsPerGame;
verticalSigns = (int) Math.ceil((float) (1 + maxGroupsPerGame) / 4);
@@ -100,48 +95,18 @@ public class GameSign extends GlobalProtection {
}
/**
- * @return the multiFloor
+ * @return the dungeon
*/
- public boolean isMultiFloor() {
- return multiFloor;
+ public Dungeon getDungeon() {
+ return dungeon;
}
/**
- * @param multiFloor
- * the multiFloor to set
+ * @param dungeon
+ * the dungeon to set
*/
- public void setMultiFloor(boolean multiFloor) {
- this.multiFloor = multiFloor;
- }
-
- /**
- * @return the dungeonName
- */
- public String getDungeonName() {
- return dungeonName;
- }
-
- /**
- * @param dungeonName
- * the dungeonName to set
- */
- public void setDungeonName(String dungeonName) {
- this.dungeonName = dungeonName;
- }
-
- /**
- * @return the mapName
- */
- public String getMapName() {
- return mapName;
- }
-
- /**
- * @param mapName
- * the mapName to set
- */
- public void setMapName(String mapName) {
- this.mapName = mapName;
+ public void setDungeon(Dungeon dungeon) {
+ this.dungeon = dungeon;
}
/**
@@ -266,17 +231,9 @@ public class GameSign extends GlobalProtection {
config.set(preString + ".x", startSign.getX());
config.set(preString + ".y", startSign.getY());
config.set(preString + ".z", startSign.getZ());
-
- if (isMultiFloor()) {
- config.set(preString + ".dungeon", dungeonName);
-
- } else {
- config.set(preString + ".dungeon", mapName);
- }
-
+ config.set(preString + ".dungeon", dungeon.getName());
config.set(preString + ".maxGames", games.length);
config.set(preString + ".maxGroupsPerGame", maxGroupsPerGame);
- config.set(preString + ".multiFloor", isMultiFloor());
}
/* Statics */
@@ -361,7 +318,7 @@ public class GameSign extends GlobalProtection {
/* SUBJECT TO CHANGE*/
@Deprecated
- public static GameSign tryToCreate(Block startSign, String mapName, int maxGames, int maxGroupsPerGame, boolean multiFloor) {
+ public static GameSign tryToCreate(Block startSign, String mapName, int maxGames, int maxGroupsPerGame) {
World world = startSign.getWorld();
int direction = startSign.getData();
int x = startSign.getX(), y = startSign.getY(), z = startSign.getZ();
@@ -457,7 +414,7 @@ public class GameSign extends GlobalProtection {
block.setTypeIdAndData(68, startSign.getData(), true);
}
- GameSign sign = new GameSign(protections.generateId(GameSign.class, world), startSign, mapName, maxGames, maxGroupsPerGame, multiFloor);
+ GameSign sign = new GameSign(protections.generateId(GameSign.class, world), startSign, mapName, maxGames, maxGroupsPerGame);
return sign;
}
@@ -513,8 +470,7 @@ public class GameSign extends GlobalProtection {
if (topSign.getLine(0).equals(NEW_GAME)) {
Game game = new Game(dGroup);
- dGroup.setDungeonName(gameSign.dungeonName);
- dGroup.setMapName(gameSign.mapName);
+ dGroup.setDungeon(gameSign.dungeon);
gameSign.games[column] = game;
gameSign.update();
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/global/GlobalProtections.java b/core/src/main/java/io/github/dre2n/dungeonsxl/global/GlobalProtections.java
index a0f97a51..f617a7a1 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/global/GlobalProtections.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/global/GlobalProtections.java
@@ -171,13 +171,9 @@ public class GlobalProtections {
String mapName = data.getString(preString + ".dungeon");
int maxGames = data.getInt(preString + ".maxGames");
int maxGroupsPerGame = data.getInt(preString + ".maxGroupsPerGame");
- boolean multiFloor = false;
- if (data.contains(preString + ".multiFloor")) {
- multiFloor = data.getBoolean(preString + ".multiFloor");
- }
Block startSign = world.getBlockAt(data.getInt(preString + ".x"), data.getInt(preString + ".y"), data.getInt(preString + ".z"));
- new GameSign(id, startSign, mapName, maxGames, maxGroupsPerGame, multiFloor);
+ new GameSign(id, startSign, mapName, maxGames, maxGroupsPerGame);
}
} while (data.contains(preString));
@@ -195,13 +191,9 @@ public class GlobalProtections {
String mapName = data.getString(preString + ".dungeon");
int maxGroups = data.getInt(preString + ".maxGroups");
int maxPlayersPerGroup = data.getInt(preString + ".maxPlayersPerGroup");
- boolean multiFloor = false;
- if (data.contains(preString + ".multiFloor")) {
- multiFloor = data.getBoolean(preString + ".multiFloor");
- }
Block startSign = world.getBlockAt(data.getInt(preString + ".x"), data.getInt(preString + ".y"), data.getInt(preString + ".z"));
- new GroupSign(id, startSign, mapName, maxGroups, maxPlayersPerGroup, multiFloor);
+ new GroupSign(id, startSign, mapName, maxGroups, maxPlayersPerGroup);
}
} while (data.contains(preString));
}
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/global/GroupSign.java b/core/src/main/java/io/github/dre2n/dungeonsxl/global/GroupSign.java
index f0630ce5..4f87721e 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/global/GroupSign.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/global/GroupSign.java
@@ -21,6 +21,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -47,31 +48,24 @@ public class GroupSign extends GlobalProtection {
// Variables
private DGroup[] dGroups;
- private boolean multiFloor;
- private String dungeonName;
- private String mapName;
+ private Dungeon dungeon;
private int maxPlayersPerGroup;
private Block startSign;
private int directionX = 0, directionZ = 0;
private int verticalSigns;
private Set blocks;
- public GroupSign(int id, Block startSign, String identifier, int maxGroups, int maxPlayersPerGroup, boolean multiFloor) {
+ public GroupSign(int id, Block startSign, String identifier, int maxGroups, int maxPlayersPerGroup) {
super(startSign.getWorld(), id);
this.startSign = startSign;
dGroups = new DGroup[maxGroups];
- this.setMultiFloor(multiFloor);
- if (multiFloor) {
- dungeonName = identifier;
- Dungeon dungeon = plugin.getDungeons().getByName(identifier);
- if (dungeon != null) {
- mapName = dungeon.getConfig().getStartFloor().getName();
- } else {
- mapName = "invalid";
+ dungeon = plugin.getDungeons().getByName(identifier);
+ if (dungeon == null) {
+ DResourceWorld resource = plugin.getDWorlds().getResourceByName(identifier);
+ if (resource != null) {
+ dungeon = new Dungeon(resource);
}
- } else {
- mapName = identifier;
}
this.maxPlayersPerGroup = maxPlayersPerGroup;
verticalSigns = (int) Math.ceil((float) (1 + maxPlayersPerGroup) / 4);
@@ -99,48 +93,18 @@ public class GroupSign extends GlobalProtection {
}
/**
- * @return the multiFloor
+ * @return the dungeon
*/
- public boolean isMultiFloor() {
- return multiFloor;
+ public Dungeon getDungeon() {
+ return dungeon;
}
/**
- * @param multiFloor
- * the multiFloor to set
+ * @param dungeon
+ * the dungeon to set
*/
- public void setMultiFloor(boolean multiFloor) {
- this.multiFloor = multiFloor;
- }
-
- /**
- * @return the dungeonName
- */
- public String getDungeonName() {
- return dungeonName;
- }
-
- /**
- * @param dungeonName
- * the dungeonName to set
- */
- public void setDungeonName(String dungeonName) {
- this.dungeonName = dungeonName;
- }
-
- /**
- * @return the mapName
- */
- public String getMapName() {
- return mapName;
- }
-
- /**
- * @param mapName
- * the mapName to set
- */
- public void setMapName(String mapName) {
- this.mapName = mapName;
+ public void setDungeon(Dungeon dungeon) {
+ this.dungeon = dungeon;
}
/**
@@ -265,17 +229,9 @@ public class GroupSign extends GlobalProtection {
config.set(preString + ".x", startSign.getX());
config.set(preString + ".y", startSign.getY());
config.set(preString + ".z", startSign.getZ());
-
- if (isMultiFloor()) {
- config.set(preString + ".dungeon", dungeonName);
-
- } else {
- config.set(preString + ".dungeon", mapName);
- }
-
+ config.set(preString + ".dungeon", dungeon.getName());
config.set(preString + ".maxGroups", dGroups.length);
config.set(preString + ".maxPlayersPerGroup", maxPlayersPerGroup);
- config.set(preString + ".multiFloor", isMultiFloor());
}
/* Statics */
@@ -342,7 +298,7 @@ public class GroupSign extends GlobalProtection {
/* SUBJECT TO CHANGE */
@Deprecated
- public static GroupSign tryToCreate(Block startSign, String mapName, int maxGroups, int maxPlayersPerGroup, boolean multiFloor) {
+ public static GroupSign tryToCreate(Block startSign, String mapName, int maxGroups, int maxPlayersPerGroup) {
World world = startSign.getWorld();
int direction = startSign.getData();
int x = startSign.getX(), y = startSign.getY(), z = startSign.getZ();
@@ -438,7 +394,7 @@ public class GroupSign extends GlobalProtection {
block.setTypeIdAndData(68, startSign.getData(), true);
}
- GroupSign sign = new GroupSign(protections.generateId(GroupSign.class, world), startSign, mapName, maxGroups, maxPlayersPerGroup, multiFloor);
+ GroupSign sign = new GroupSign(protections.generateId(GroupSign.class, world), startSign, mapName, maxGroups, maxPlayersPerGroup);
return sign;
}
@@ -476,12 +432,7 @@ public class GroupSign extends GlobalProtection {
Sign topSign = (Sign) topBlock.getState();
if (topSign.getLine(0).equals(NEW_GROUP)) {
- if (groupSign.isMultiFloor()) {
- groupSign.dGroups[column] = new DGroup(player, groupSign.dungeonName, groupSign.isMultiFloor());
-
- } else {
- groupSign.dGroups[column] = new DGroup(player, groupSign.mapName, groupSign.isMultiFloor());
- }
+ groupSign.dGroups[column] = new DGroup(player, groupSign.dungeon);
groupSign.update();
} else if (topSign.getLine(0).equals(JOIN_GROUP)) {
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java b/core/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java
index 822c33eb..83bf3f73 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java
@@ -66,27 +66,29 @@ public class BlockListener implements Listener {
}
@EventHandler
- public void onBreakWithSignOnIt(BlockBreakEvent event){
+ public void onBreakWithSignOnIt(BlockBreakEvent event) {
Block block = event.getBlock();
Player player = event.getPlayer();
-
+
Block blockAbove = block.getRelative(BlockFace.UP);
//get the above block and return if there is nothing
- if(blockAbove == null)
- return;
-
+ if (blockAbove == null) {
+ return;
+ }
+
//return if above block is not a sign
- if(blockAbove.getType() != Material.SIGN_POST && blockAbove.getType() != Material.WALL_SIGN)
- return;
-
+ if (blockAbove.getType() != Material.SIGN_POST && blockAbove.getType() != Material.WALL_SIGN) {
+ return;
+ }
+
//let onBreak() method to handle the sign
BlockBreakEvent bbe = new BlockBreakEvent(blockAbove, player);
onBreak(bbe);
-
+
//follow the onBreak()
event.setCancelled(bbe.isCancelled());
}
-
+
@EventHandler(priority = EventPriority.HIGH)
public void onBreak(BlockBreakEvent event) {
Block block = event.getBlock();
@@ -156,21 +158,15 @@ public class BlockListener implements Listener {
if (data.length >= 2 && data.length <= 3) {
int maxObjects = NumberUtil.parseInt(data[0]);
int maxMembersPerObject = NumberUtil.parseInt(data[1]);
- boolean multiFloor = false;
- if (data.length == 3) {
- if (data[2].equals("+")) {
- multiFloor = true;
- }
- }
if (maxObjects > 0 && maxMembersPerObject > 0) {
if (lines[1].equalsIgnoreCase("Game")) {
- if (GameSign.tryToCreate(event.getBlock(), dungeonName, maxObjects, maxMembersPerObject, multiFloor) != null) {
+ if (GameSign.tryToCreate(event.getBlock(), dungeonName, maxObjects, maxMembersPerObject) != null) {
event.setCancelled(true);
}
} else if (lines[1].equalsIgnoreCase("Group")) {
- if (GroupSign.tryToCreate(event.getBlock(), dungeonName, maxObjects, maxMembersPerObject, multiFloor) != null) {
+ if (GroupSign.tryToCreate(event.getBlock(), dungeonName, maxObjects, maxMembersPerObject) != null) {
event.setCancelled(true);
}
}
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java b/core/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java
index f2790616..cf750b3a 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java
@@ -509,9 +509,9 @@ public class DGamePlayer extends DInstancePlayer {
if (getDGroup() != null) {
if (!dGroup.isEmpty()) {
- if (dGroup.finishIfMembersFinished()) {
+ /*if (dGroup.finishIfMembersFinished()) {
return;
- }
+ }*/
// Give secure objects to other players
int i = 0;
@@ -787,7 +787,6 @@ public class DGamePlayer extends DInstancePlayer {
Game game = dGroup.getGameWorld().getGame();
dGroup.removeUnplayedFloor(dGroup.getGameWorld().getResource(), false);
- dGroup.setMapName(newFloor.getName());
DGameWorld gameWorld = null;
if (newFloor != null) {
diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java b/core/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java
index 3fb8773d..1dda9085 100644
--- a/core/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java
+++ b/core/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java
@@ -58,8 +58,6 @@ public class DGroup {
private List players = new ArrayList<>();
private List invitedPlayers = new ArrayList<>();
private Dungeon dungeon;
- private String dungeonName;
- private String mapName;
private List unplayedFloors = new ArrayList<>();
private DGameWorld gameWorld;
private boolean playing;
@@ -87,14 +85,17 @@ public class DGroup {
floorCount = 0;
}
+ @Deprecated
public DGroup(Player player, String identifier, boolean multiFloor) {
this("Group_" + plugin.getDGroups().size(), player, identifier, multiFloor);
}
+ @Deprecated
public DGroup(String name, Player player, String identifier, boolean multiFloor) {
this(name, player, new ArrayList(), identifier, multiFloor);
}
+ @Deprecated
public DGroup(String name, Player captain, List players, String identifier, boolean multiFloor) {
plugin.getDGroups().add(this);
this.name = name;
@@ -115,19 +116,51 @@ public class DGroup {
dungeon = plugin.getDungeons().getByName(identifier);
if (multiFloor && dungeon != null) {
- dungeonName = dungeon.getName();
- mapName = dungeon.getConfig().getStartFloor().getName();
+ // Real dungeon
unplayedFloors = dungeon.getConfig().getFloors();
} else {
- mapName = identifier;
- dungeon = new Dungeon(identifier);
+ // Artificial dungeon
+ DResourceWorld resource = plugin.getDWorlds().getResourceByName(identifier);
+ dungeon = new Dungeon(resource);
}
playing = false;
floorCount = 0;
}
+ public DGroup(Player player, Dungeon dungeon) {
+ this("Group_" + plugin.getDGroups().size(), player, dungeon);
+ }
+
+ @Deprecated
+ public DGroup(String name, Player player, Dungeon dungeon) {
+ this(name, player, new ArrayList(), dungeon);
+ }
+
+ public DGroup(String name, Player captain, List players, Dungeon dungeon) {
+ plugin.getDGroups().add(this);
+ this.name = name;
+
+ DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(plugin.getDPlayers().getByPlayer(captain), true, this);
+ plugin.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ this.captain = captain.getUniqueId();
+ this.players.add(captain.getUniqueId());
+ }
+
+ for (Player player : players) {
+ if (!this.players.contains(player.getUniqueId())) {
+ addPlayer(player);
+ }
+ }
+
+ this.dungeon = dungeon;
+ playing = false;
+ floorCount = 0;
+ }
+
// Getters and setters
/**
* @return the name; formatted
@@ -391,13 +424,11 @@ public class DGroup {
public void setDungeon(String name) {
dungeon = plugin.getDungeons().getByName(name);
if (dungeon != null) {
- dungeonName = dungeon.getName();
- mapName = dungeon.getConfig().getStartFloor().getName();
unplayedFloors = dungeon.getConfig().getFloors();
} else {
- mapName = name;
- dungeon = new Dungeon(name);
+ DResourceWorld resource = plugin.getDWorlds().getResourceByName(name);
+ dungeon = new Dungeon(resource);
}
}
@@ -405,38 +436,14 @@ public class DGroup {
* @return the dungeonName
*/
public String getDungeonName() {
- return dungeonName;
- }
-
- /**
- * Will fail if there is no dungeon with this name.
- *
- * @param dungeonName
- * the dungeonName to set
- */
- public void setDungeonName(String dungeonName) {
- if (plugin.getDungeons().getByName(name) != null) {
- this.dungeonName = dungeonName;
- }
+ return dungeon.getName();
}
/**
* @return if the group is playing
*/
public String getMapName() {
- return mapName;
- }
-
- /**
- * Will fail if there is no resource world with this name.
- *
- * @param name
- * the name to set
- */
- public void setMapName(String name) {
- if (plugin.getDWorlds().exists(name)) {
- mapName = name;
- }
+ return gameWorld == null ? null : gameWorld.getName();
}
/**
@@ -716,11 +723,11 @@ public class DGroup {
MessageUtil.sendTitleMessage(player, title, subtitle, rules.getTitleFadeIn(), rules.getTitleShow(), rules.getTitleFadeOut());
- } else if (dungeonName != null) {
- MessageUtil.sendTitleMessage(player, "&b&l" + dungeonName.replaceAll("_", " "), "&4&l" + mapName.replaceAll("_", " "));
+ } else if (!getDungeonName().equals(getMapName())) {
+ MessageUtil.sendTitleMessage(player, "&b&l" + getDungeonName().replaceAll("_", " "), "&4&l" + getMapName().replaceAll("_", " "));
} else {
- MessageUtil.sendTitleMessage(player, "&4&l" + mapName.replaceAll("_", " "));
+ MessageUtil.sendTitleMessage(player, "&4&l" + getMapName().replaceAll("_", " "));
}
if (rules.getActionBar() != null) {
diff --git a/craftbukkit_1_10_R1/pom.xml b/craftbukkit_1_10_R1/pom.xml
index 765c3506..78eec1a4 100644
--- a/craftbukkit_1_10_R1/pom.xml
+++ b/craftbukkit_1_10_R1/pom.xml
@@ -8,7 +8,7 @@
io.github.dre2n
dungeonsxl
- 0.15.3-SNAPSHOT
+ 0.15.3
diff --git a/craftbukkit_1_11_R1/pom.xml b/craftbukkit_1_11_R1/pom.xml
index 566f88e7..0dfdf7ff 100644
--- a/craftbukkit_1_11_R1/pom.xml
+++ b/craftbukkit_1_11_R1/pom.xml
@@ -8,7 +8,7 @@
io.github.dre2n
dungeonsxl
- 0.15.3-SNAPSHOT
+ 0.15.3
diff --git a/craftbukkit_1_9_R1/pom.xml b/craftbukkit_1_9_R1/pom.xml
index 267153b2..05ac4f13 100644
--- a/craftbukkit_1_9_R1/pom.xml
+++ b/craftbukkit_1_9_R1/pom.xml
@@ -8,7 +8,7 @@
io.github.dre2n
dungeonsxl
- 0.15.3-SNAPSHOT
+ 0.15.3
diff --git a/craftbukkit_1_9_R2/pom.xml b/craftbukkit_1_9_R2/pom.xml
index 7dea5a47..fa5685e8 100644
--- a/craftbukkit_1_9_R2/pom.xml
+++ b/craftbukkit_1_9_R2/pom.xml
@@ -8,7 +8,7 @@
io.github.dre2n
dungeonsxl
- 0.15.3-SNAPSHOT
+ 0.15.3
diff --git a/pom.xml b/pom.xml
index 0c0fc981..361235a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
io.github.dre2n
dungeonsxl
- 0.15.3-SNAPSHOT
+ 0.15.3
pom
DungeonsXL
https://dre2n.github.io
@@ -36,7 +36,7 @@
io.github.dre2n
commons
- 1.0.4
+ 1.0.5
io.github.dre2n
diff --git a/shade/pom.xml b/shade/pom.xml
index b58c6961..e146a9fd 100644
--- a/shade/pom.xml
+++ b/shade/pom.xml
@@ -8,7 +8,7 @@
io.github.dre2n
dungeonsxl
- 0.15.3-SNAPSHOT
+ 0.15.3
dungeonsxl-${project.version}${buildNo}