mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Fix end NPE; resolves #177
This commit is contained in:
parent
ac4c807da6
commit
b8bf2659d7
@ -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>
|
||||
|
@ -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 {
|
||||
|
@ -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,22 @@ 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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,6 +74,34 @@ 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
|
||||
*/
|
||||
@ -74,4 +109,15 @@ public class Dungeon {
|
||||
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;
|
||||
}
|
||||
|
@ -513,8 +513,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.dungeonName == null ? gameSign.mapName : gameSign.dungeonName);
|
||||
gameSign.games[column] = game;
|
||||
gameSign.update();
|
||||
|
||||
|
@ -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;
|
||||
@ -115,13 +113,13 @@ 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;
|
||||
@ -391,13 +389,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 +401,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 +688,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() != null) {
|
||||
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>
|
||||
|
2
pom.xml
2
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>
|
||||
|
@ -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