mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-10-03 01:58:31 +02:00
Multi group dungeons
This commit is contained in:
parent
aa8b952c7c
commit
92b10ec50a
@ -91,12 +91,7 @@ public class CreateCommand extends BRCommand {
|
|||||||
plugin.getLogger().info(messageConfig.getMessage(Messages.LOG_WORLD_GENERATION_FINISHED));
|
plugin.getLogger().info(messageConfig.getMessage(Messages.LOG_WORLD_GENERATION_FINISHED));
|
||||||
|
|
||||||
// Tp Player
|
// Tp Player
|
||||||
if (editWorld.getLobby() == null) {
|
new DPlayer(player, editWorld.getWorld(), true);
|
||||||
new DPlayer(player, editWorld.getWorld(), editWorld.getWorld().getSpawnLocation(), true);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
new DPlayer(player, editWorld.getWorld(), editWorld.getLobby(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NAME_TO_LONG));
|
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NAME_TO_LONG));
|
||||||
|
@ -72,12 +72,7 @@ public class EditCommand extends BRCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editWorld.getLobby() == null) {
|
new DPlayer(player, editWorld.getWorld(), true);
|
||||||
new DPlayer(player, editWorld.getWorld(), editWorld.getWorld().getSpawnLocation(), true);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
new DPlayer(player, editWorld.getWorld(), editWorld.getLobby(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class GameCommand extends BRCommand {
|
|||||||
groups += (group == game.getDGroups().get(0) ? "" : "&b, &e") + group.getName();
|
groups += (group == game.getDGroups().get(0) ? "" : "&b, &e") + group.getName();
|
||||||
}
|
}
|
||||||
MessageUtil.sendMessage(sender, "&bGroups: &e" + groups);
|
MessageUtil.sendMessage(sender, "&bGroups: &e" + groups);
|
||||||
MessageUtil.sendMessage(sender, "&bGame type: &e" + game.getType());
|
MessageUtil.sendMessage(sender, "&bGame type: &e" + (game.getType() == null ? "Not started yet" : game.getType()));
|
||||||
MessageUtil.sendMessage(sender, "&bDungeon: &e" + (dGroup.getDungeonName() == null ? "N/A" : dGroup.getDungeonName()));
|
MessageUtil.sendMessage(sender, "&bDungeon: &e" + (dGroup.getDungeonName() == null ? "N/A" : dGroup.getDungeonName()));
|
||||||
MessageUtil.sendMessage(sender, "&bMap: &e" + (dGroup.getMapName() == null ? "N/A" : dGroup.getMapName()));
|
MessageUtil.sendMessage(sender, "&bMap: &e" + (dGroup.getMapName() == null ? "N/A" : dGroup.getMapName()));
|
||||||
}
|
}
|
||||||
|
@ -166,12 +166,12 @@ public class PlayCommand extends BRCommand {
|
|||||||
|
|
||||||
if (dGroup.getGameWorld().getLocLobby() == null) {
|
if (dGroup.getGameWorld().getLocLobby() == null) {
|
||||||
for (Player groupPlayer : dGroup.getPlayers()) {
|
for (Player groupPlayer : dGroup.getPlayers()) {
|
||||||
new DPlayer(groupPlayer, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getWorld().getSpawnLocation(), false);
|
new DPlayer(groupPlayer, dGroup.getGameWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (Player groupPlayer : dGroup.getPlayers()) {
|
for (Player groupPlayer : dGroup.getPlayers()) {
|
||||||
new DPlayer(groupPlayer, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getLocLobby(), false);
|
new DPlayer(groupPlayer, dGroup.getGameWorld());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class EditWorld {
|
|||||||
private int id;
|
private int id;
|
||||||
private Location lobby;
|
private Location lobby;
|
||||||
private CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<>();
|
private CopyOnWriteArrayList<String> invitedPlayers = new CopyOnWriteArrayList<>();
|
||||||
private CopyOnWriteArrayList<Block> sign = new CopyOnWriteArrayList<>();
|
private CopyOnWriteArrayList<Block> signs = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public EditWorld() {
|
public EditWorld() {
|
||||||
plugin.getEditWorlds().add(this);
|
plugin.getEditWorlds().add(this);
|
||||||
@ -188,18 +188,18 @@ public class EditWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the sign
|
* @return the signs
|
||||||
*/
|
*/
|
||||||
public CopyOnWriteArrayList<Block> getSign() {
|
public CopyOnWriteArrayList<Block> getSigns() {
|
||||||
return sign;
|
return signs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param sign
|
* @param sign
|
||||||
* the sign to set
|
* the sign to set
|
||||||
*/
|
*/
|
||||||
public void setSign(CopyOnWriteArrayList<Block> sign) {
|
public void setSigns(CopyOnWriteArrayList<Block> signs) {
|
||||||
this.sign = sign;
|
this.signs = signs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generate() {
|
public void generate() {
|
||||||
@ -231,8 +231,8 @@ public class EditWorld {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(plugin.getDataFolder(), "/maps/" + mapName + "/DXLData.data")));
|
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(plugin.getDataFolder(), "/maps/" + mapName + "/DXLData.data")));
|
||||||
out.writeInt(sign.size());
|
out.writeInt(signs.size());
|
||||||
for (Block sign : this.sign) {
|
for (Block sign : signs) {
|
||||||
out.writeInt(sign.getX());
|
out.writeInt(sign.getX());
|
||||||
out.writeInt(sign.getY());
|
out.writeInt(sign.getY());
|
||||||
out.writeInt(sign.getZ());
|
out.writeInt(sign.getZ());
|
||||||
@ -368,7 +368,7 @@ public class EditWorld {
|
|||||||
int z = os.readInt();
|
int z = os.readInt();
|
||||||
Block block = editWorld.world.getBlockAt(x, y, z);
|
Block block = editWorld.world.getBlockAt(x, y, z);
|
||||||
editWorld.checkSign(block);
|
editWorld.checkSign(block);
|
||||||
editWorld.sign.add(block);
|
editWorld.signs.add(block);
|
||||||
}
|
}
|
||||||
os.close();
|
os.close();
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ package io.github.dre2n.dungeonsxl.game;
|
|||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -30,16 +31,28 @@ public class Game {
|
|||||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
private List<DGroup> dGroups = new ArrayList<>();
|
private List<DGroup> dGroups = new ArrayList<>();
|
||||||
|
private boolean started;
|
||||||
private GameType type;
|
private GameType type;
|
||||||
|
private GameWorld world;
|
||||||
|
|
||||||
public Game(DGroup dGroup) {
|
public Game(DGroup dGroup) {
|
||||||
this.dGroups.add(dGroup);
|
dGroups.add(dGroup);
|
||||||
this.type = GameTypeDefault.DEFAULT;
|
started = false;
|
||||||
|
|
||||||
|
plugin.getGames().add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game(DGroup dGroup, GameType type) {
|
public Game(DGroup dGroup, GameType type, GameWorld world) {
|
||||||
this.dGroups.add(dGroup);
|
this(new ArrayList<>(Arrays.asList(dGroup)), type, world);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Game(List<DGroup> dGroups, GameType type, GameWorld world) {
|
||||||
|
this.dGroups = dGroups;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.world = world;
|
||||||
|
this.started = true;
|
||||||
|
|
||||||
|
plugin.getGames().add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,6 +78,21 @@ public class Game {
|
|||||||
dGroups.remove(dGroup);
|
dGroups.remove(dGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the Game has started yet
|
||||||
|
*/
|
||||||
|
public boolean hasStarted() {
|
||||||
|
return started;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param started
|
||||||
|
* set if the Game has started yet
|
||||||
|
*/
|
||||||
|
public void setStarted(boolean started) {
|
||||||
|
this.started = started;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the type
|
* @return the type
|
||||||
*/
|
*/
|
||||||
@ -80,6 +108,21 @@ public class Game {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the GameWorld connected to the Game
|
||||||
|
*/
|
||||||
|
public GameWorld getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gameWorld
|
||||||
|
* the GameWorld to connect to the Game
|
||||||
|
*/
|
||||||
|
public void setWorld(GameWorld world) {
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if the DGroup list is empty
|
* @return if the DGroup list is empty
|
||||||
*/
|
*/
|
||||||
@ -104,7 +147,7 @@ public class Game {
|
|||||||
|
|
||||||
public static Game getByGameWorld(GameWorld gameWorld) {
|
public static Game getByGameWorld(GameWorld gameWorld) {
|
||||||
for (Game game : plugin.getGames()) {
|
for (Game game : plugin.getGames()) {
|
||||||
if (game.getDGroups().get(0).getGameWorld().equals(gameWorld)) {
|
if (game.getWorld().equals(gameWorld)) {
|
||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -62,8 +63,6 @@ public class GameWorld {
|
|||||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private Game game;
|
|
||||||
|
|
||||||
private boolean tutorial;
|
private boolean tutorial;
|
||||||
|
|
||||||
private CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<>();
|
private CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<>();
|
||||||
@ -105,18 +104,17 @@ public class GameWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the game
|
* @return
|
||||||
|
* the Game connected to the GameWorld
|
||||||
*/
|
*/
|
||||||
public Game getGame() {
|
public Game getGame() {
|
||||||
|
for (Game game : plugin.getGames()) {
|
||||||
|
if (game.getWorld() == this) {
|
||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return null;
|
||||||
* @param game
|
|
||||||
* the game to set
|
|
||||||
*/
|
|
||||||
public void setGame(Game game) {
|
|
||||||
this.game = game;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -341,6 +339,10 @@ public class GameWorld {
|
|||||||
* @return the worldConfig
|
* @return the worldConfig
|
||||||
*/
|
*/
|
||||||
public WorldConfig getConfig() {
|
public WorldConfig getConfig() {
|
||||||
|
if (worldConfig == null) {
|
||||||
|
return plugin.getDefaultConfig();
|
||||||
|
}
|
||||||
|
|
||||||
return worldConfig;
|
return worldConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +376,7 @@ public class GameWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startGame() {
|
public void startGame() {
|
||||||
GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, game);
|
GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, getGame());
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
@ -472,6 +474,8 @@ public class GameWorld {
|
|||||||
// Secure Objects
|
// Secure Objects
|
||||||
gameWorld.secureObjects = gameWorld.worldConfig.getSecureObjects();
|
gameWorld.secureObjects = gameWorld.worldConfig.getSecureObjects();
|
||||||
|
|
||||||
|
if (Bukkit.getWorld("DXL_Game_" + gameWorld.id) == null) {
|
||||||
|
|
||||||
// World
|
// World
|
||||||
FileUtil.copyDirectory(file, new File("DXL_Game_" + gameWorld.id), DungeonsXL.EXCLUDED_FILES);
|
FileUtil.copyDirectory(file, new File("DXL_Game_" + gameWorld.id), DungeonsXL.EXCLUDED_FILES);
|
||||||
|
|
||||||
@ -506,6 +510,7 @@ public class GameWorld {
|
|||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return gameWorld;
|
return gameWorld;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import io.github.dre2n.commons.util.BlockUtil;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||||
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
@ -162,28 +163,48 @@ public class DPortal extends GlobalProtection {
|
|||||||
* the player to teleport into his dungeon
|
* the player to teleport into his dungeon
|
||||||
*/
|
*/
|
||||||
public void teleport(Player player) {
|
public void teleport(Player player) {
|
||||||
DGroup dgroup = DGroup.getByPlayer(player);
|
DGroup dGroup = DGroup.getByPlayer(player);
|
||||||
|
|
||||||
if (dgroup == null) {
|
if (dGroup == null) {
|
||||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_JOIN_GROUP));
|
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_JOIN_GROUP));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dgroup.getGameWorld() == null) {
|
GameWorld target = dGroup.getGameWorld();
|
||||||
dgroup.setGameWorld(GameWorld.load(DGroup.getByPlayer(player).getMapName()));
|
Game game = Game.getByDGroup(dGroup);
|
||||||
|
|
||||||
|
if (target == null && game != null) {
|
||||||
|
target = game.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dgroup.getGameWorld() == null) {
|
if (target == null) {
|
||||||
|
if (game != null) {
|
||||||
|
for (DGroup otherTeam : game.getDGroups()) {
|
||||||
|
if (otherTeam.getGameWorld() != null) {
|
||||||
|
target = otherTeam.getGameWorld();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target == null) {
|
||||||
|
target = GameWorld.load(dGroup.getMapName());
|
||||||
|
dGroup.setGameWorld(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target == null) {
|
||||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, DGroup.getByPlayer(player).getMapName()));
|
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, DGroup.getByPlayer(player).getMapName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dgroup.getGameWorld().getLocLobby() == null) {
|
if (game != null) {
|
||||||
new DPlayer(player, dgroup.getGameWorld().getWorld(), dgroup.getGameWorld().getWorld().getSpawnLocation(), false);
|
game.setWorld(target);
|
||||||
|
|
||||||
} else {
|
|
||||||
new DPlayer(player, dgroup.getGameWorld().getWorld(), dgroup.getGameWorld().getLocLobby(), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dGroup.setGameWorld(target);
|
||||||
|
|
||||||
|
new DPlayer(player, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -276,6 +297,10 @@ public class DPortal extends GlobalProtection {
|
|||||||
public static DPortal getByBlock(Block block) {
|
public static DPortal getByBlock(Block block) {
|
||||||
for (GlobalProtection protection : protections.getProtections(DPortal.class)) {
|
for (GlobalProtection protection : protections.getProtections(DPortal.class)) {
|
||||||
DPortal portal = (DPortal) protection;
|
DPortal portal = (DPortal) protection;
|
||||||
|
if (portal.getBlock1() == null || portal.getBlock2() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int x1 = portal.block1.getX(), y1 = portal.block1.getY(), z1 = portal.block1.getZ();
|
int x1 = portal.block1.getX(), y1 = portal.block1.getY(), z1 = portal.block1.getZ();
|
||||||
int x2 = portal.block2.getX(), y2 = portal.block2.getY(), z2 = portal.block2.getZ();
|
int x2 = portal.block2.getX(), y2 = portal.block2.getY(), z2 = portal.block2.getZ();
|
||||||
int x3 = block.getX(), y3 = block.getY(), z3 = block.getZ();
|
int x3 = block.getX(), y3 = block.getY(), z3 = block.getZ();
|
||||||
|
@ -511,7 +511,8 @@ public class GameSign extends GlobalProtection {
|
|||||||
Sign topSign = (Sign) topBlock.getState();
|
Sign topSign = (Sign) topBlock.getState();
|
||||||
|
|
||||||
if (topSign.getLine(0).equals(NEW_GAME)) {
|
if (topSign.getLine(0).equals(NEW_GAME)) {
|
||||||
gameSign.games[column] = new Game(dGroup);
|
Game game = new Game(dGroup);
|
||||||
|
gameSign.games[column] = game;
|
||||||
gameSign.update();
|
gameSign.update();
|
||||||
|
|
||||||
} else if (topSign.getLine(0).equals(JOIN_GAME)) {
|
} else if (topSign.getLine(0).equals(JOIN_GAME)) {
|
||||||
|
@ -89,18 +89,20 @@ public class BlockListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Editworld Signs
|
// EditWorld Signs
|
||||||
EditWorld editWorld = EditWorld.getByWorld(block.getWorld());
|
EditWorld editWorld = EditWorld.getByWorld(block.getWorld());
|
||||||
if (editWorld != null) {
|
if (editWorld != null) {
|
||||||
editWorld.getSign().remove(event.getBlock());
|
editWorld.getSigns().remove(event.getBlock());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deny GameWorld Blocks
|
// Deny GameWorld block breaking
|
||||||
GameWorld gameWorld = GameWorld.getByWorld(block.getWorld());
|
GameWorld gameWorld = GameWorld.getByWorld(block.getWorld());
|
||||||
if (gameWorld != null) {
|
if (gameWorld != null) {
|
||||||
for (DSign dSign : gameWorld.getDSigns()) {
|
for (DSign dSign : gameWorld.getDSigns()) {
|
||||||
if (dSign.getSign().equals(block)) {
|
if (dSign.getSign().equals(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +114,9 @@ public class BlockListener implements Listener {
|
|||||||
} else if (!gameType.canBuild()) {
|
} else if (!gameType.canBuild()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,7 +225,7 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
if (dsign.check()) {
|
if (dsign.check()) {
|
||||||
editWorld.checkSign(block);
|
editWorld.checkSign(block);
|
||||||
editWorld.getSign().add(block);
|
editWorld.getSigns().add(block);
|
||||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_SIGN_CREATED));
|
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_SIGN_CREATED));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -127,6 +127,10 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!game.hasStarted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WorldConfig config = gameWorld.getConfig();
|
WorldConfig config = gameWorld.getConfig();
|
||||||
GameType type = game.getType();
|
GameType type = game.getType();
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onDeath(PlayerDeathEvent event) {
|
public void onDeath(PlayerDeathEvent event) {
|
||||||
Player player = event.getEntity();
|
Player player = event.getEntity();
|
||||||
final DPlayer dPlayer = DPlayer.getByPlayer(player);
|
DPlayer dPlayer = DPlayer.getByPlayer(player);
|
||||||
|
|
||||||
GameWorld gameWorld = GameWorld.getByWorld(player.getLocation().getWorld());
|
GameWorld gameWorld = GameWorld.getByWorld(player.getLocation().getWorld());
|
||||||
if (gameWorld == null) {
|
if (gameWorld == null) {
|
||||||
@ -132,8 +132,7 @@ public class PlayerListener implements Listener {
|
|||||||
MessageUtil.broadcastMessage(messageConfig.getMessage(Messages.PLAYER_DEATH_KICK, player.getName()));
|
MessageUtil.broadcastMessage(messageConfig.getMessage(Messages.PLAYER_DEATH_KICK, player.getName()));
|
||||||
dPlayer.leave();
|
dPlayer.leave();
|
||||||
if (gameWorld.getConfig().getKeepInventoryOnEscape()) {
|
if (gameWorld.getConfig().getKeepInventoryOnEscape()) {
|
||||||
/*new org.bukkit.scheduler.BukkitRunnable() {public void run(){*/
|
dPlayer.applyRespawnInventory();
|
||||||
dPlayer.applyRespawnInventory();/*}}.runTaskLater(plugin, 1);*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -406,13 +405,8 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPortal(PlayerPortalEvent event) {
|
public void onPortal(PlayerPortalEvent event) {
|
||||||
Player player = event.getPlayer();
|
if (DPortal.getByLocation(event.getFrom()) != null) {
|
||||||
Location location = event.getFrom();
|
|
||||||
DPortal dPortal = DPortal.getByLocation(location);
|
|
||||||
|
|
||||||
if (dPortal != null) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
dPortal.teleport(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,9 +551,7 @@ public class PlayerListener implements Listener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dGroup.getGameWorld().getLocLobby() != null) {
|
new DPlayer(player, dGroup.getGameWorld());
|
||||||
new DPlayer(player, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getLocLobby(), false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,11 +640,14 @@ public class PlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
DLootInventory inventory = DLootInventory.getByPlayer(player);
|
DLootInventory inventory = DLootInventory.getByPlayer(player);
|
||||||
|
|
||||||
if (inventory == null) {
|
DPortal dPortal = DPortal.getByLocation(player.getEyeLocation());
|
||||||
|
//TODO: Fix chat spam
|
||||||
|
if (dPortal != null) {
|
||||||
|
dPortal.teleport(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getLocation().getBlock().getType() == Material.PORTAL) {
|
if (inventory == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,43 +76,11 @@ public class DGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DGroup(Player player, String identifier, boolean multiFloor) {
|
public DGroup(Player player, String identifier, boolean multiFloor) {
|
||||||
plugin.getDGroups().add(this);
|
this("Group_" + plugin.getDGroups().size(), player, identifier, multiFloor);
|
||||||
name = "Group_" + plugin.getDGroups().size();
|
|
||||||
|
|
||||||
captain = player;
|
|
||||||
players.add(player);
|
|
||||||
|
|
||||||
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
|
|
||||||
if (multiFloor && dungeon != null) {
|
|
||||||
dungeonName = identifier;
|
|
||||||
mapName = dungeon.getConfig().getStartFloor();
|
|
||||||
unplayedFloors = dungeon.getConfig().getFloors();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
mapName = identifier;
|
|
||||||
}
|
|
||||||
playing = false;
|
|
||||||
floorCount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DGroup(String name, Player player, String identifier, boolean multiFloor) {
|
public DGroup(String name, Player player, String identifier, boolean multiFloor) {
|
||||||
plugin.getDGroups().add(this);
|
this(name, player, new CopyOnWriteArrayList<>(Arrays.asList(player)), identifier, multiFloor);
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
captain = player;
|
|
||||||
players.add(player);
|
|
||||||
|
|
||||||
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
|
|
||||||
if (multiFloor && dungeon != null) {
|
|
||||||
dungeonName = identifier;
|
|
||||||
mapName = dungeon.getConfig().getStartFloor();
|
|
||||||
unplayedFloors = dungeon.getConfig().getFloors();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
mapName = identifier;
|
|
||||||
}
|
|
||||||
playing = false;
|
|
||||||
floorCount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@ -491,8 +459,6 @@ public class DGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gameWorld.setGame(game);
|
|
||||||
|
|
||||||
DGroupStartFloorEvent event = new DGroupStartFloorEvent(this, gameWorld);
|
DGroupStartFloorEvent event = new DGroupStartFloorEvent(this, gameWorld);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
@ -500,7 +466,13 @@ public class DGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
playing = true;
|
playing = true;
|
||||||
|
|
||||||
|
if (gameWorld != null) {
|
||||||
|
if (!gameWorld.isPlaying()) {
|
||||||
gameWorld.startGame();
|
gameWorld.startGame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
floorCount++;
|
floorCount++;
|
||||||
|
|
||||||
for (Player player : getPlayers()) {
|
for (Player player : getPlayers()) {
|
||||||
|
@ -92,12 +92,17 @@ public class DPlayer extends DGlobalPlayer {
|
|||||||
private int initialLives = -1;
|
private int initialLives = -1;
|
||||||
private int lives;
|
private int lives;
|
||||||
|
|
||||||
public DPlayer(Player player, World world, Location teleport, boolean editing) {
|
public DPlayer(Player player, GameWorld gameWorld) {
|
||||||
|
this(player, gameWorld.getWorld(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public DPlayer(Player player, World world, boolean editing) {
|
||||||
super(player);
|
super(player);
|
||||||
|
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
|
||||||
double health = ((Damageable) player).getHealth();
|
double health = player.getHealth();
|
||||||
|
|
||||||
if (!Version.andHigher(Version.MC1_9).contains(CompatibilityHandler.getInstance().getVersion())) {
|
if (!Version.andHigher(Version.MC1_9).contains(CompatibilityHandler.getInstance().getVersion())) {
|
||||||
savePlayer = new DSavePlayer(player.getName(), player.getUniqueId(), player.getLocation(), player.getInventory().getContents(), player.getInventory().getArmorContents(), null, player.getLevel(),
|
savePlayer = new DSavePlayer(player.getName(), player.getUniqueId(), player.getLocation(), player.getInventory().getContents(), player.getInventory().getArmorContents(), null, player.getLevel(),
|
||||||
@ -109,9 +114,11 @@ public class DPlayer extends DGlobalPlayer {
|
|||||||
}
|
}
|
||||||
this.editing = editing;
|
this.editing = editing;
|
||||||
|
|
||||||
|
Location teleport;
|
||||||
if (this.editing) {
|
if (this.editing) {
|
||||||
this.getPlayer().setGameMode(GameMode.CREATIVE);
|
this.getPlayer().setGameMode(GameMode.CREATIVE);
|
||||||
clearPlayerData();
|
clearPlayerData();
|
||||||
|
teleport = EditWorld.getByWorld(world).getLobby();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
WorldConfig worldConfig = GameWorld.getByWorld(world).getConfig();
|
WorldConfig worldConfig = GameWorld.getByWorld(world).getConfig();
|
||||||
@ -124,9 +131,15 @@ public class DPlayer extends DGlobalPlayer {
|
|||||||
}
|
}
|
||||||
initialLives = worldConfig.getInitialLives();
|
initialLives = worldConfig.getInitialLives();
|
||||||
lives = initialLives;
|
lives = initialLives;
|
||||||
|
teleport = GameWorld.getByWorld(world).getLocLobby();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerUtil.secureTeleport(this.getPlayer(), teleport);
|
if (teleport == null) {
|
||||||
|
PlayerUtil.secureTeleport(player, world.getSpawnLocation());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
PlayerUtil.secureTeleport(player, teleport);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearPlayerData() {
|
public void clearPlayerData() {
|
||||||
@ -496,13 +509,11 @@ public class DPlayer extends DGlobalPlayer {
|
|||||||
|
|
||||||
// Belohnung
|
// Belohnung
|
||||||
if (gameWorld.getGame() != null) {
|
if (gameWorld.getGame() != null) {
|
||||||
if (gameWorld.getGame().getType().hasRewards()) {
|
|
||||||
if (finished) {
|
if (finished) {
|
||||||
if (gameWorld.getGame() != null) {
|
if (gameWorld.getGame().getType().hasRewards()) {
|
||||||
for (Reward reward : gameWorld.getConfig().getRewards()) {
|
for (Reward reward : gameWorld.getConfig().getRewards()) {
|
||||||
reward.giveTo(getPlayer());
|
reward.giveTo(getPlayer());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
addTreasure();
|
addTreasure();
|
||||||
|
|
||||||
@ -576,20 +587,7 @@ public class DPlayer extends DGlobalPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ready() {
|
public void ready() {
|
||||||
ready = true;
|
ready(GameTypeDefault.DEFAULT);
|
||||||
|
|
||||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
|
||||||
|
|
||||||
if (dGroup == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dGroup.isPlaying()) {
|
|
||||||
dGroup.startGame(new Game(dGroup));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
respawn();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ready(GameType gameType) {
|
public void ready(GameType gameType) {
|
||||||
@ -601,13 +599,23 @@ public class DPlayer extends DGlobalPlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dGroup.isPlaying()) {
|
Game game = Game.getByGameWorld(dGroup.getGameWorld());
|
||||||
dGroup.startGame(new Game(dGroup, gameType));
|
if (game == null) {
|
||||||
|
game = new Game(dGroup, gameType, dGroup.getGameWorld());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
game.setType(gameType);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DGroup gameGroup : game.getDGroups()) {
|
||||||
|
if (!gameGroup.isPlaying()) {
|
||||||
|
gameGroup.startGame(game);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
respawn();
|
respawn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void respawn() {
|
public void respawn() {
|
||||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
||||||
|
@ -42,7 +42,7 @@ public class InteractSign extends DSign {
|
|||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
Set<Integer> used = new HashSet<>();
|
Set<Integer> used = new HashSet<>();
|
||||||
for (Block block : EditWorld.getByWorld(getSign().getLocation().getWorld()).getSign()) {
|
for (Block block : EditWorld.getByWorld(getSign().getLocation().getWorld()).getSigns()) {
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,11 @@ package io.github.dre2n.dungeonsxl.sign;
|
|||||||
|
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||||
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -96,8 +98,10 @@ public class ReadySign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
for (DPlayer dPlayer : plugin.getDPlayers().getDPlayers()) {
|
for (DGroup dGroup : Game.getByGameWorld(getGameWorld()).getDGroups()) {
|
||||||
ready(dPlayer);
|
for (Player player : dGroup.getPlayers()) {
|
||||||
|
ready(DPlayer.getByPlayer(player));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +115,8 @@ public class ReadySign extends DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getGameWorld().getSignClass().isEmpty() || dPlayer.getDClass() != null) {
|
if (getGameWorld().getSignClass().isEmpty() || dPlayer.getDClass() != null) {
|
||||||
dPlayer.ready(gameType);
|
GameType forced = getGameWorld().getConfig().getForcedGameType();
|
||||||
|
dPlayer.ready(forced == null ? gameType : forced);
|
||||||
MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getMessageConfig().getMessage(Messages.PLAYER_READY));
|
MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getMessageConfig().getMessage(Messages.PLAYER_READY));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,7 +45,7 @@ public class TriggerSign extends DSign {
|
|||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
Set<Integer> used = new HashSet<>();
|
Set<Integer> used = new HashSet<>();
|
||||||
for (Block block : EditWorld.getByWorld(getSign().getLocation().getWorld()).getSign()) {
|
for (Block block : EditWorld.getByWorld(getSign().getLocation().getWorld()).getSigns()) {
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user