Merge several fixes

This commit is contained in:
Daniel Saukel 2016-12-24 03:07:33 +01:00 committed by GitHub
commit 2c11cfe9ba
21 changed files with 200 additions and 230 deletions

View File

@ -8,6 +8,6 @@
<parent> <parent>
<groupId>io.github.dre2n</groupId> <groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId> <artifactId>dungeonsxl</artifactId>
<version>0.15.3-SNAPSHOT</version> <version>0.15.3</version>
</parent> </parent>
</project> </project>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>io.github.dre2n</groupId> <groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId> <artifactId>dungeonsxl</artifactId>
<version>0.15.3-SNAPSHOT</version> <version>0.15.3</version>
</parent> </parent>
<build> <build>
<resources> <resources>

View File

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

View File

@ -97,9 +97,10 @@ public class PlayCommand extends BRCommand {
} }
if (dGroup.getMapName() == null) { if (dGroup.getMapName() == null) {
dGroup.setMapName(mapName);
if (multiFloor) { if (multiFloor) {
dGroup.setDungeonName(identifier); dGroup.setDungeon(plugin.getDungeons().getByName(identifier));
} else {
dGroup.setDungeon(mapName);
} }
} else { } else {

View File

@ -60,6 +60,7 @@ public class RenameCommand extends BRCommand {
resource.setName(args[2]); resource.setName(args[2]);
resource.getFolder().renameTo(new File(DungeonsXL.MAPS, args[2])); resource.getFolder().renameTo(new File(DungeonsXL.MAPS, args[2]));
resource.getSignData().updateFile(resource);
for (Dungeon dungeon : plugin.getDungeons().getDungeons()) { for (Dungeon dungeon : plugin.getDungeons().getDungeons()) {
DungeonConfig dConfig = dungeon.getConfig(); DungeonConfig dConfig = dungeon.getConfig();
@ -93,14 +94,16 @@ public class RenameCommand extends BRCommand {
boolean changed = false; boolean changed = false;
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections()) { for (GlobalProtection protection : plugin.getGlobalProtections().getProtections()) {
if (protection instanceof GroupSign) { if (protection instanceof GroupSign) {
if (((GroupSign) protection).getMapName().equals(args[1])) { Dungeon dungeon = ((GroupSign) protection).getDungeon();
((GroupSign) protection).setMapName(args[2]); if (dungeon.getName().equals(args[1])) {
dungeon.setName(args[2]);
changed = true; changed = true;
} }
} else if (protection instanceof GameSign) { } else if (protection instanceof GameSign) {
if (((GameSign) protection).getMapName().equals(args[1])) { Dungeon dungeon = ((GameSign) protection).getDungeon();
((GameSign) protection).setMapName(args[2]); if (dungeon.getName().equals(args[1])) {
dungeon.setName(args[2]);
changed = true; changed = true;
} }
} }

View File

@ -19,6 +19,7 @@ package io.github.dre2n.dungeonsxl.config;
import io.github.dre2n.dungeonsxl.sign.DSign; import io.github.dre2n.dungeonsxl.sign.DSign;
import io.github.dre2n.dungeonsxl.world.DEditWorld; import io.github.dre2n.dungeonsxl.world.DEditWorld;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -58,6 +59,10 @@ public class SignData {
return file; return file;
} }
public void updateFile(DResourceWorld resource) {
file = new File(resource.getFolder(), "DXLData.data");
}
/* Actions */ /* Actions */
/** /**
* Applies all signs from the file to the DEditWorld. * Applies all signs from the file to the DEditWorld.

View File

@ -18,7 +18,11 @@ package io.github.dre2n.dungeonsxl.dungeon;
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.world.DResourceWorld;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/** /**
* Represents a dungeon. * Represents a dungeon.
@ -31,19 +35,23 @@ public class Dungeon {
private String name; private String name;
private DungeonConfig config; private DungeonConfig config;
private DResourceWorld map;
/**
* Real dungeon
*/
public Dungeon(File file) { public Dungeon(File file) {
this.name = file.getName().replaceAll(".yml", ""); name = file.getName().replaceAll(".yml", "");
this.config = new DungeonConfig(file); config = new DungeonConfig(file);
map = config.getStartFloor();
} }
public Dungeon(String name) { /**
this.name = name; * Artificial dungeon
*/
File file = new File(DungeonsXL.DUNGEONS, name + ".yml"); public Dungeon(DResourceWorld resource) {
if (file.exists()) { name = resource.getName();
this.config = new DungeonConfig(file); map = resource;
}
} }
/** /**
@ -53,6 +61,14 @@ public class Dungeon {
return name; return name;
} }
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/** /**
* @return the config * @return the config
*/ */
@ -67,11 +83,55 @@ public class Dungeon {
return config != null; return config != null;
} }
/**
* @return
* the floors of the dungeon
*/
public List<DResourceWorld> 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 * @return false if there are setup errors
*/ */
public boolean isSetupCorrect() { public boolean isSetupCorrect() {
for (DResourceWorld resource : DungeonsXL.getInstance().getDWorlds().getResources()) {
if (resource.getName().equals(name)) {
return false;
}
}
return config.getStartFloor() != null && config.getEndFloor() != null; 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");
}
} }

View File

@ -76,7 +76,7 @@ public class Dungeons {
* @return the Dungeon that has the name * @return the Dungeon that has the name
*/ */
public Dungeon loadDungeon(String name) { public Dungeon loadDungeon(String name) {
Dungeon dungeon = new Dungeon(name); Dungeon dungeon = new Dungeon(Dungeon.getFileFromName(name));
dungeons.add(dungeon); dungeons.add(dungeon);
return dungeon; return dungeon;
} }

View File

@ -203,8 +203,8 @@ public class DPortal extends GlobalProtection {
} }
} }
if (target == null && dGroup.getMapName() != null) { if (target == null && dGroup.getDungeon() != null) {
DResourceWorld resource = plugin.getDWorlds().getResourceByName(dGroup.getMapName()); DResourceWorld resource = dGroup.getDungeon().getMap();
if (resource != null) { if (resource != null) {
target = resource.instantiateAsGameWorld(); target = resource.instantiateAsGameWorld();
dGroup.setGameWorld(target); dGroup.setGameWorld(target);

View File

@ -21,7 +21,9 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon; import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.game.Game; 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.player.DGroup;
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@ -48,31 +50,24 @@ public class GameSign extends GlobalProtection {
// Variables // Variables
private Game[] games; private Game[] games;
private boolean multiFloor; private Dungeon dungeon;
private String dungeonName;
private String mapName;
private int maxGroupsPerGame; private int maxGroupsPerGame;
private Block startSign; private Block startSign;
private int directionX = 0, directionZ = 0; private int directionX = 0, directionZ = 0;
private int verticalSigns; private int verticalSigns;
private Set<Block> blocks; private Set<Block> 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); super(startSign.getWorld(), id);
this.startSign = startSign; this.startSign = startSign;
games = new Game[maxGames]; games = new Game[maxGames];
this.setMultiFloor(multiFloor); dungeon = plugin.getDungeons().getByName(identifier);
if (multiFloor) { if (dungeon == null) {
dungeonName = identifier; DResourceWorld resource = plugin.getDWorlds().getResourceByName(identifier);
Dungeon dungeon = plugin.getDungeons().getByName(identifier); if (resource != null) {
if (dungeon != null) { dungeon = new Dungeon(resource);
mapName = dungeon.getConfig().getStartFloor().getName();
} else {
mapName = "invalid";
} }
} else {
mapName = identifier;
} }
this.maxGroupsPerGame = maxGroupsPerGame; this.maxGroupsPerGame = maxGroupsPerGame;
verticalSigns = (int) Math.ceil((float) (1 + maxGroupsPerGame) / 4); 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() { public Dungeon getDungeon() {
return multiFloor; return dungeon;
} }
/** /**
* @param multiFloor * @param dungeon
* the multiFloor to set * the dungeon to set
*/ */
public void setMultiFloor(boolean multiFloor) { public void setDungeon(Dungeon dungeon) {
this.multiFloor = multiFloor; this.dungeon = dungeon;
}
/**
* @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;
} }
/** /**
@ -266,17 +231,9 @@ public class GameSign extends GlobalProtection {
config.set(preString + ".x", startSign.getX()); config.set(preString + ".x", startSign.getX());
config.set(preString + ".y", startSign.getY()); config.set(preString + ".y", startSign.getY());
config.set(preString + ".z", startSign.getZ()); config.set(preString + ".z", startSign.getZ());
config.set(preString + ".dungeon", dungeon.getName());
if (isMultiFloor()) {
config.set(preString + ".dungeon", dungeonName);
} else {
config.set(preString + ".dungeon", mapName);
}
config.set(preString + ".maxGames", games.length); config.set(preString + ".maxGames", games.length);
config.set(preString + ".maxGroupsPerGame", maxGroupsPerGame); config.set(preString + ".maxGroupsPerGame", maxGroupsPerGame);
config.set(preString + ".multiFloor", isMultiFloor());
} }
/* Statics */ /* Statics */
@ -361,7 +318,7 @@ public class GameSign extends GlobalProtection {
/* SUBJECT TO CHANGE*/ /* SUBJECT TO CHANGE*/
@Deprecated @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(); World world = startSign.getWorld();
int direction = startSign.getData(); int direction = startSign.getData();
int x = startSign.getX(), y = startSign.getY(), z = startSign.getZ(); 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); 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; return sign;
} }
@ -513,8 +470,7 @@ public class GameSign extends GlobalProtection {
if (topSign.getLine(0).equals(NEW_GAME)) { if (topSign.getLine(0).equals(NEW_GAME)) {
Game game = new Game(dGroup); Game game = new Game(dGroup);
dGroup.setDungeonName(gameSign.dungeonName); dGroup.setDungeon(gameSign.dungeon);
dGroup.setMapName(gameSign.mapName);
gameSign.games[column] = game; gameSign.games[column] = game;
gameSign.update(); gameSign.update();

View File

@ -171,13 +171,9 @@ public class GlobalProtections {
String mapName = data.getString(preString + ".dungeon"); String mapName = data.getString(preString + ".dungeon");
int maxGames = data.getInt(preString + ".maxGames"); int maxGames = data.getInt(preString + ".maxGames");
int maxGroupsPerGame = data.getInt(preString + ".maxGroupsPerGame"); 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")); 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)); } while (data.contains(preString));
@ -195,13 +191,9 @@ public class GlobalProtections {
String mapName = data.getString(preString + ".dungeon"); String mapName = data.getString(preString + ".dungeon");
int maxGroups = data.getInt(preString + ".maxGroups"); int maxGroups = data.getInt(preString + ".maxGroups");
int maxPlayersPerGroup = data.getInt(preString + ".maxPlayersPerGroup"); 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")); 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)); } while (data.contains(preString));
} }

View File

@ -21,6 +21,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.config.DMessages; import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon; import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.player.DGroup; import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@ -47,31 +48,24 @@ public class GroupSign extends GlobalProtection {
// Variables // Variables
private DGroup[] dGroups; private DGroup[] dGroups;
private boolean multiFloor; private Dungeon dungeon;
private String dungeonName;
private String mapName;
private int maxPlayersPerGroup; private int maxPlayersPerGroup;
private Block startSign; private Block startSign;
private int directionX = 0, directionZ = 0; private int directionX = 0, directionZ = 0;
private int verticalSigns; private int verticalSigns;
private Set<Block> blocks; private Set<Block> 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); super(startSign.getWorld(), id);
this.startSign = startSign; this.startSign = startSign;
dGroups = new DGroup[maxGroups]; dGroups = new DGroup[maxGroups];
this.setMultiFloor(multiFloor); dungeon = plugin.getDungeons().getByName(identifier);
if (multiFloor) { if (dungeon == null) {
dungeonName = identifier; DResourceWorld resource = plugin.getDWorlds().getResourceByName(identifier);
Dungeon dungeon = plugin.getDungeons().getByName(identifier); if (resource != null) {
if (dungeon != null) { dungeon = new Dungeon(resource);
mapName = dungeon.getConfig().getStartFloor().getName();
} else {
mapName = "invalid";
} }
} else {
mapName = identifier;
} }
this.maxPlayersPerGroup = maxPlayersPerGroup; this.maxPlayersPerGroup = maxPlayersPerGroup;
verticalSigns = (int) Math.ceil((float) (1 + maxPlayersPerGroup) / 4); 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() { public Dungeon getDungeon() {
return multiFloor; return dungeon;
} }
/** /**
* @param multiFloor * @param dungeon
* the multiFloor to set * the dungeon to set
*/ */
public void setMultiFloor(boolean multiFloor) { public void setDungeon(Dungeon dungeon) {
this.multiFloor = multiFloor; this.dungeon = dungeon;
}
/**
* @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;
} }
/** /**
@ -265,17 +229,9 @@ public class GroupSign extends GlobalProtection {
config.set(preString + ".x", startSign.getX()); config.set(preString + ".x", startSign.getX());
config.set(preString + ".y", startSign.getY()); config.set(preString + ".y", startSign.getY());
config.set(preString + ".z", startSign.getZ()); config.set(preString + ".z", startSign.getZ());
config.set(preString + ".dungeon", dungeon.getName());
if (isMultiFloor()) {
config.set(preString + ".dungeon", dungeonName);
} else {
config.set(preString + ".dungeon", mapName);
}
config.set(preString + ".maxGroups", dGroups.length); config.set(preString + ".maxGroups", dGroups.length);
config.set(preString + ".maxPlayersPerGroup", maxPlayersPerGroup); config.set(preString + ".maxPlayersPerGroup", maxPlayersPerGroup);
config.set(preString + ".multiFloor", isMultiFloor());
} }
/* Statics */ /* Statics */
@ -342,7 +298,7 @@ public class GroupSign extends GlobalProtection {
/* SUBJECT TO CHANGE */ /* SUBJECT TO CHANGE */
@Deprecated @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(); World world = startSign.getWorld();
int direction = startSign.getData(); int direction = startSign.getData();
int x = startSign.getX(), y = startSign.getY(), z = startSign.getZ(); 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); 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; return sign;
} }
@ -476,12 +432,7 @@ public class GroupSign extends GlobalProtection {
Sign topSign = (Sign) topBlock.getState(); Sign topSign = (Sign) topBlock.getState();
if (topSign.getLine(0).equals(NEW_GROUP)) { if (topSign.getLine(0).equals(NEW_GROUP)) {
if (groupSign.isMultiFloor()) { groupSign.dGroups[column] = new DGroup(player, groupSign.dungeon);
groupSign.dGroups[column] = new DGroup(player, groupSign.dungeonName, groupSign.isMultiFloor());
} else {
groupSign.dGroups[column] = new DGroup(player, groupSign.mapName, groupSign.isMultiFloor());
}
groupSign.update(); groupSign.update();
} else if (topSign.getLine(0).equals(JOIN_GROUP)) { } else if (topSign.getLine(0).equals(JOIN_GROUP)) {

View File

@ -66,18 +66,20 @@ public class BlockListener implements Listener {
} }
@EventHandler @EventHandler
public void onBreakWithSignOnIt(BlockBreakEvent event){ public void onBreakWithSignOnIt(BlockBreakEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
Player player = event.getPlayer(); Player player = event.getPlayer();
Block blockAbove = block.getRelative(BlockFace.UP); Block blockAbove = block.getRelative(BlockFace.UP);
//get the above block and return if there is nothing //get the above block and return if there is nothing
if(blockAbove == null) if (blockAbove == null) {
return; return;
}
//return if above block is not a sign //return if above block is not a sign
if(blockAbove.getType() != Material.SIGN_POST && blockAbove.getType() != Material.WALL_SIGN) if (blockAbove.getType() != Material.SIGN_POST && blockAbove.getType() != Material.WALL_SIGN) {
return; return;
}
//let onBreak() method to handle the sign //let onBreak() method to handle the sign
BlockBreakEvent bbe = new BlockBreakEvent(blockAbove, player); BlockBreakEvent bbe = new BlockBreakEvent(blockAbove, player);
@ -156,21 +158,15 @@ public class BlockListener implements Listener {
if (data.length >= 2 && data.length <= 3) { if (data.length >= 2 && data.length <= 3) {
int maxObjects = NumberUtil.parseInt(data[0]); int maxObjects = NumberUtil.parseInt(data[0]);
int maxMembersPerObject = NumberUtil.parseInt(data[1]); 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 (maxObjects > 0 && maxMembersPerObject > 0) {
if (lines[1].equalsIgnoreCase("Game")) { 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); event.setCancelled(true);
} }
} else if (lines[1].equalsIgnoreCase("Group")) { } 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); event.setCancelled(true);
} }
} }

View File

@ -509,9 +509,9 @@ public class DGamePlayer extends DInstancePlayer {
if (getDGroup() != null) { if (getDGroup() != null) {
if (!dGroup.isEmpty()) { if (!dGroup.isEmpty()) {
if (dGroup.finishIfMembersFinished()) { /*if (dGroup.finishIfMembersFinished()) {
return; return;
} }*/
// Give secure objects to other players // Give secure objects to other players
int i = 0; int i = 0;
@ -787,7 +787,6 @@ public class DGamePlayer extends DInstancePlayer {
Game game = dGroup.getGameWorld().getGame(); Game game = dGroup.getGameWorld().getGame();
dGroup.removeUnplayedFloor(dGroup.getGameWorld().getResource(), false); dGroup.removeUnplayedFloor(dGroup.getGameWorld().getResource(), false);
dGroup.setMapName(newFloor.getName());
DGameWorld gameWorld = null; DGameWorld gameWorld = null;
if (newFloor != null) { if (newFloor != null) {

View File

@ -58,8 +58,6 @@ public class DGroup {
private List<UUID> players = new ArrayList<>(); private List<UUID> players = new ArrayList<>();
private List<UUID> invitedPlayers = new ArrayList<>(); private List<UUID> invitedPlayers = new ArrayList<>();
private Dungeon dungeon; private Dungeon dungeon;
private String dungeonName;
private String mapName;
private List<DResourceWorld> unplayedFloors = new ArrayList<>(); private List<DResourceWorld> unplayedFloors = new ArrayList<>();
private DGameWorld gameWorld; private DGameWorld gameWorld;
private boolean playing; private boolean playing;
@ -87,14 +85,17 @@ public class DGroup {
floorCount = 0; floorCount = 0;
} }
@Deprecated
public DGroup(Player player, String identifier, boolean multiFloor) { public DGroup(Player player, String identifier, boolean multiFloor) {
this("Group_" + plugin.getDGroups().size(), player, identifier, multiFloor); this("Group_" + plugin.getDGroups().size(), player, identifier, multiFloor);
} }
@Deprecated
public DGroup(String name, Player player, String identifier, boolean multiFloor) { public DGroup(String name, Player player, String identifier, boolean multiFloor) {
this(name, player, new ArrayList<Player>(), identifier, multiFloor); this(name, player, new ArrayList<Player>(), identifier, multiFloor);
} }
@Deprecated
public DGroup(String name, Player captain, List<Player> players, String identifier, boolean multiFloor) { public DGroup(String name, Player captain, List<Player> players, String identifier, boolean multiFloor) {
plugin.getDGroups().add(this); plugin.getDGroups().add(this);
this.name = name; this.name = name;
@ -115,19 +116,51 @@ public class DGroup {
dungeon = plugin.getDungeons().getByName(identifier); dungeon = plugin.getDungeons().getByName(identifier);
if (multiFloor && dungeon != null) { if (multiFloor && dungeon != null) {
dungeonName = dungeon.getName(); // Real dungeon
mapName = dungeon.getConfig().getStartFloor().getName();
unplayedFloors = dungeon.getConfig().getFloors(); unplayedFloors = dungeon.getConfig().getFloors();
} else { } else {
mapName = identifier; // Artificial dungeon
dungeon = new Dungeon(identifier); DResourceWorld resource = plugin.getDWorlds().getResourceByName(identifier);
dungeon = new Dungeon(resource);
} }
playing = false; playing = false;
floorCount = 0; 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<Player>(), dungeon);
}
public DGroup(String name, Player captain, List<Player> 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 // Getters and setters
/** /**
* @return the name; formatted * @return the name; formatted
@ -391,13 +424,11 @@ public class DGroup {
public void setDungeon(String name) { public void setDungeon(String name) {
dungeon = plugin.getDungeons().getByName(name); dungeon = plugin.getDungeons().getByName(name);
if (dungeon != null) { if (dungeon != null) {
dungeonName = dungeon.getName();
mapName = dungeon.getConfig().getStartFloor().getName();
unplayedFloors = dungeon.getConfig().getFloors(); unplayedFloors = dungeon.getConfig().getFloors();
} else { } else {
mapName = name; DResourceWorld resource = plugin.getDWorlds().getResourceByName(name);
dungeon = new Dungeon(name); dungeon = new Dungeon(resource);
} }
} }
@ -405,38 +436,14 @@ public class DGroup {
* @return the dungeonName * @return the dungeonName
*/ */
public String getDungeonName() { public String getDungeonName() {
return dungeonName; return dungeon.getName();
}
/**
* 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 if the group is playing * @return if the group is playing
*/ */
public String getMapName() { public String getMapName() {
return mapName; return gameWorld == null ? null : gameWorld.getName();
}
/**
* 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;
}
} }
/** /**
@ -716,11 +723,11 @@ public class DGroup {
MessageUtil.sendTitleMessage(player, title, subtitle, rules.getTitleFadeIn(), rules.getTitleShow(), rules.getTitleFadeOut()); MessageUtil.sendTitleMessage(player, title, subtitle, rules.getTitleFadeIn(), rules.getTitleShow(), rules.getTitleFadeOut());
} else if (dungeonName != null) { } else if (!getDungeonName().equals(getMapName())) {
MessageUtil.sendTitleMessage(player, "&b&l" + dungeonName.replaceAll("_", " "), "&4&l" + mapName.replaceAll("_", " ")); MessageUtil.sendTitleMessage(player, "&b&l" + getDungeonName().replaceAll("_", " "), "&4&l" + getMapName().replaceAll("_", " "));
} else { } else {
MessageUtil.sendTitleMessage(player, "&4&l" + mapName.replaceAll("_", " ")); MessageUtil.sendTitleMessage(player, "&4&l" + getMapName().replaceAll("_", " "));
} }
if (rules.getActionBar() != null) { if (rules.getActionBar() != null) {

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>io.github.dre2n</groupId> <groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId> <artifactId>dungeonsxl</artifactId>
<version>0.15.3-SNAPSHOT</version> <version>0.15.3</version>
</parent> </parent>
<build> <build>
<plugins> <plugins>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>io.github.dre2n</groupId> <groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId> <artifactId>dungeonsxl</artifactId>
<version>0.15.3-SNAPSHOT</version> <version>0.15.3</version>
</parent> </parent>
<build> <build>
<plugins> <plugins>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>io.github.dre2n</groupId> <groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId> <artifactId>dungeonsxl</artifactId>
<version>0.15.3-SNAPSHOT</version> <version>0.15.3</version>
</parent> </parent>
<build> <build>
<plugins> <plugins>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>io.github.dre2n</groupId> <groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId> <artifactId>dungeonsxl</artifactId>
<version>0.15.3-SNAPSHOT</version> <version>0.15.3</version>
</parent> </parent>
<build> <build>
<plugins> <plugins>

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>io.github.dre2n</groupId> <groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId> <artifactId>dungeonsxl</artifactId>
<version>0.15.3-SNAPSHOT</version> <version>0.15.3</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>DungeonsXL</name> <name>DungeonsXL</name>
<url>https://dre2n.github.io</url> <url>https://dre2n.github.io</url>
@ -36,7 +36,7 @@
<dependency> <dependency>
<groupId>io.github.dre2n</groupId> <groupId>io.github.dre2n</groupId>
<artifactId>commons</artifactId> <artifactId>commons</artifactId>
<version>1.0.4</version> <version>1.0.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.github.dre2n</groupId> <groupId>io.github.dre2n</groupId>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>io.github.dre2n</groupId> <groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId> <artifactId>dungeonsxl</artifactId>
<version>0.15.3-SNAPSHOT</version> <version>0.15.3</version>
</parent> </parent>
<build> <build>
<finalName>dungeonsxl-${project.version}${buildNo}</finalName> <finalName>dungeonsxl-${project.version}${buildNo}</finalName>