mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 21:48:43 +01:00
NPE fixes
This commit is contained in:
parent
231372956d
commit
02e738e840
@ -24,6 +24,7 @@ import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
||||
import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
@ -164,6 +165,7 @@ public class PlayCommand extends BRCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
new Game(dGroup, dGroup.getGameWorld());
|
||||
if (dGroup.getGameWorld().getLobbyLocation() == null) {
|
||||
for (Player groupPlayer : dGroup.getPlayers()) {
|
||||
new DGamePlayer(groupPlayer, dGroup.getGameWorld());
|
||||
|
@ -58,10 +58,16 @@ public class Game {
|
||||
public Game(DGroup dGroup) {
|
||||
dGroups.add(dGroup);
|
||||
started = false;
|
||||
fetchRules();
|
||||
|
||||
plugin.getGames().add(this);
|
||||
}
|
||||
|
||||
public Game(DGroup dGroup, GameWorld world) {
|
||||
this(dGroup);
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public Game(DGroup dGroup, GameType type, GameWorld world) {
|
||||
this(new ArrayList<>(Arrays.asList(dGroup)), type, world);
|
||||
}
|
||||
@ -71,6 +77,7 @@ public class Game {
|
||||
this.type = type;
|
||||
this.world = world;
|
||||
this.started = true;
|
||||
fetchRules();
|
||||
|
||||
plugin.getGames().add(this);
|
||||
}
|
||||
@ -196,13 +203,15 @@ public class Game {
|
||||
finalRules.apply(floorConfig);
|
||||
}
|
||||
|
||||
if (getDungeon() != null) {
|
||||
if (dungeonConfig != null) {
|
||||
finalRules.apply(dungeonConfig.getDefaultValues());
|
||||
}
|
||||
|
||||
finalRules.apply(plugin.getMainConfig().getDefaultWorldConfig());
|
||||
|
||||
finalRules.apply(GameRules.DEFAULT_VALUES);
|
||||
|
||||
rules = finalRules;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@ -363,10 +362,8 @@ public class GameRules {
|
||||
/**
|
||||
* @return the objects to get passed to another player of the group when this player leaves
|
||||
*/
|
||||
public CopyOnWriteArrayList<Material> getSecureObjects() {
|
||||
CopyOnWriteArrayList<Material> tmpSecureObjects = new CopyOnWriteArrayList<>();
|
||||
tmpSecureObjects.addAll(secureObjects);
|
||||
return tmpSecureObjects;
|
||||
public List<Material> getSecureObjects() {
|
||||
return secureObjects;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
|
@ -191,14 +191,15 @@ public class DPortal extends GlobalProtection {
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.ERROR_DUNGEON_NOT_EXIST, DGroup.getByPlayer(player).getMapName()));
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_DUNGEON_NOT_EXIST.getMessage(DGroup.getByPlayer(player).getMapName()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (game != null) {
|
||||
game.setWorld(target);
|
||||
if (game == null) {
|
||||
game = new Game(dGroup);
|
||||
}
|
||||
|
||||
game.setWorld(target);
|
||||
dGroup.setGameWorld(target);
|
||||
|
||||
new DGamePlayer(player, target);
|
||||
|
@ -83,7 +83,12 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
public DGamePlayer(Player player, World world) {
|
||||
super(player, world);
|
||||
|
||||
GameRules rules = Game.getByWorld(world).getRules();
|
||||
Game game = Game.getByWorld(world);
|
||||
if (game == null) {
|
||||
game = new Game(DGroup.getByPlayer(player));
|
||||
}
|
||||
|
||||
GameRules rules = game.getRules();
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
if (!rules.getKeepInventoryOnEnter()) {
|
||||
|
@ -42,6 +42,8 @@ import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -76,7 +78,7 @@ public class GameWorld {
|
||||
private Location locStart;
|
||||
private boolean isPlaying = false;
|
||||
private int id;
|
||||
private CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<>();
|
||||
private List<Material> secureObjects = new ArrayList<>();
|
||||
private CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<>();
|
||||
|
||||
private CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<>();
|
||||
@ -244,7 +246,7 @@ public class GameWorld {
|
||||
/**
|
||||
* @return the secureObjects
|
||||
*/
|
||||
public CopyOnWriteArrayList<Material> getSecureObjects() {
|
||||
public List<Material> getSecureObjects() {
|
||||
return secureObjects;
|
||||
}
|
||||
|
||||
@ -252,7 +254,7 @@ public class GameWorld {
|
||||
* @param secureObjects
|
||||
* the secureObjects to set
|
||||
*/
|
||||
public void setSecureObjects(CopyOnWriteArrayList<Material> secureObjects) {
|
||||
public void setSecureObjects(List<Material> secureObjects) {
|
||||
this.secureObjects = secureObjects;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user