mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Merge several fixes
This commit is contained in:
commit
2c11cfe9ba
@ -8,6 +8,6 @@
|
||||
<parent>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl</artifactId>
|
||||
<version>0.15.3-SNAPSHOT</version>
|
||||
<version>0.15.3</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl</artifactId>
|
||||
<version>0.15.3-SNAPSHOT</version>
|
||||
<version>0.15.3</version>
|
||||
</parent>
|
||||
<build>
|
||||
<resources>
|
||||
|
@ -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)) {
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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<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
|
||||
*/
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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<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);
|
||||
|
||||
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();
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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<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);
|
||||
|
||||
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)) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -58,8 +58,6 @@ public class DGroup {
|
||||
private List<UUID> players = new ArrayList<>();
|
||||
private List<UUID> invitedPlayers = new ArrayList<>();
|
||||
private Dungeon dungeon;
|
||||
private String dungeonName;
|
||||
private String mapName;
|
||||
private List<DResourceWorld> 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<Player>(), identifier, multiFloor);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public DGroup(String name, Player captain, List<Player> 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<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
|
||||
/**
|
||||
* @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) {
|
||||
|
@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl</artifactId>
|
||||
<version>0.15.3-SNAPSHOT</version>
|
||||
<version>0.15.3</version>
|
||||
</parent>
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl</artifactId>
|
||||
<version>0.15.3-SNAPSHOT</version>
|
||||
<version>0.15.3</version>
|
||||
</parent>
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl</artifactId>
|
||||
<version>0.15.3-SNAPSHOT</version>
|
||||
<version>0.15.3</version>
|
||||
</parent>
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl</artifactId>
|
||||
<version>0.15.3-SNAPSHOT</version>
|
||||
<version>0.15.3</version>
|
||||
</parent>
|
||||
<build>
|
||||
<plugins>
|
||||
|
4
pom.xml
4
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl</artifactId>
|
||||
<version>0.15.3-SNAPSHOT</version>
|
||||
<version>0.15.3</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>DungeonsXL</name>
|
||||
<url>https://dre2n.github.io</url>
|
||||
@ -36,7 +36,7 @@
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>commons</artifactId>
|
||||
<version>1.0.4</version>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>dungeonsxl</artifactId>
|
||||
<version>0.15.3-SNAPSHOT</version>
|
||||
<version>0.15.3</version>
|
||||
</parent>
|
||||
<build>
|
||||
<finalName>dungeonsxl-${project.version}${buildNo}</finalName>
|
||||
|
Loading…
Reference in New Issue
Block a user