mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-09 20:31:28 +01:00
Multiple start locations; resolves #16
This commit is contained in:
parent
973297b2cc
commit
cea08e440d
@ -381,7 +381,7 @@ public class Game {
|
||||
public void run() {
|
||||
if (teleport) {
|
||||
for (Player player : getPlayers()) {
|
||||
PlayerUtil.secureTeleport(player, world.getStartLocation());
|
||||
PlayerUtil.secureTeleport(player, world.getStartLocation(DGroup.getByPlayer(player)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -398,15 +398,7 @@ public class PlayerListener implements Listener {
|
||||
Location respawn = gamePlayer.getCheckpoint();
|
||||
|
||||
if (respawn == null) {
|
||||
respawn = dGroup.getGameWorld().getStartLocation();
|
||||
}
|
||||
|
||||
if (respawn == null) {
|
||||
respawn = dGroup.getGameWorld().getLobbyLocation();
|
||||
}
|
||||
|
||||
if (respawn == null) {
|
||||
respawn = dGroup.getGameWorld().getWorld().getSpawnLocation();
|
||||
respawn = dGroup.getGameWorld().getStartLocation(dGroup);
|
||||
}
|
||||
|
||||
// Because some plugins set another respawn point, DXL teleports a few ticks later.
|
||||
|
@ -596,11 +596,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
Location respawn = checkpoint;
|
||||
|
||||
if (respawn == null) {
|
||||
respawn = dGroup.getGameWorld().getStartLocation();
|
||||
}
|
||||
|
||||
if (respawn == null) {
|
||||
respawn = dGroup.getGameWorld().getLobbyLocation();
|
||||
respawn = dGroup.getGameWorld().getStartLocation(dGroup);
|
||||
}
|
||||
|
||||
if (respawn == null) {
|
||||
@ -693,7 +689,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
for (Player player : dGroup.getPlayers()) {
|
||||
DGamePlayer dPlayer = getByPlayer(player);
|
||||
dPlayer.setWorld(gameWorld.getWorld());
|
||||
dPlayer.setCheckpoint(dGroup.getGameWorld().getStartLocation());
|
||||
dPlayer.setCheckpoint(dGroup.getGameWorld().getStartLocation(dGroup));
|
||||
if (dPlayer.getWolf() != null) {
|
||||
dPlayer.getWolf().teleport(dPlayer.getCheckpoint());
|
||||
}
|
||||
@ -816,15 +812,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
teleportLocation = getCheckpoint();
|
||||
|
||||
if (teleportLocation == null) {
|
||||
teleportLocation = dGroup.getGameWorld().getStartLocation();
|
||||
}
|
||||
|
||||
if (teleportLocation == null) {
|
||||
teleportLocation = dGroup.getGameWorld().getLobbyLocation();
|
||||
}
|
||||
|
||||
if (teleportLocation == null) {
|
||||
teleportLocation = getWorld().getSpawnLocation();
|
||||
teleportLocation = dGroup.getGameWorld().getStartLocation(dGroup);
|
||||
}
|
||||
|
||||
// Don't forget Doge!
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.sign;
|
||||
|
||||
import io.github.dre2n.commons.util.NumberUtil;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
@ -27,10 +28,29 @@ public class StartSign extends DSign {
|
||||
|
||||
private DSignType type = DSignTypeDefault.START;
|
||||
|
||||
private int id;
|
||||
|
||||
public StartSign(Sign sign, String[] lines, GameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @return the ID
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the ID to set
|
||||
*/
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
@Override
|
||||
public boolean check() {
|
||||
return true;
|
||||
@ -38,7 +58,7 @@ public class StartSign extends DSign {
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
getGameWorld().setStartLocation(getSign().getLocation());
|
||||
id = NumberUtil.parseInt(lines[1]);
|
||||
getSign().getBlock().setType(Material.AIR);
|
||||
}
|
||||
|
||||
|
@ -29,10 +29,12 @@ import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.game.GamePlaceableBlock;
|
||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.reward.RewardChest;
|
||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
|
||||
import io.github.dre2n.dungeonsxl.sign.MobSign;
|
||||
import io.github.dre2n.dungeonsxl.trigger.MobTrigger;
|
||||
import io.github.dre2n.dungeonsxl.sign.StartSign;
|
||||
import io.github.dre2n.dungeonsxl.trigger.ProgressTrigger;
|
||||
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
|
||||
import io.github.dre2n.dungeonsxl.trigger.Trigger;
|
||||
@ -203,16 +205,31 @@ public class GameWorld {
|
||||
/**
|
||||
* @return the start location
|
||||
*/
|
||||
public Location getStartLocation() {
|
||||
return locStart;
|
||||
}
|
||||
public Location getStartLocation(DGroup dGroup) {
|
||||
int index = getGame().getDGroups().indexOf(dGroup);
|
||||
|
||||
/**
|
||||
* @param location
|
||||
* the location to start to set
|
||||
*/
|
||||
public void setStartLocation(Location location) {
|
||||
this.locStart = location;
|
||||
// Try the matching location
|
||||
for (DSign dSign : dSigns) {
|
||||
if (dSign.getType() == DSignTypeDefault.START) {
|
||||
if (((StartSign) dSign).getId() == index) {
|
||||
return dSign.getSign().getLocation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try any location
|
||||
for (DSign dSign : dSigns) {
|
||||
if (dSign.getType() == DSignTypeDefault.START) {
|
||||
return dSign.getSign().getLocation();
|
||||
}
|
||||
}
|
||||
|
||||
// Lobby location as fallback
|
||||
if (locLobby != null) {
|
||||
return locLobby;
|
||||
}
|
||||
|
||||
return world.getSpawnLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user