mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-10 04:41:04 +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() {
|
public void run() {
|
||||||
if (teleport) {
|
if (teleport) {
|
||||||
for (Player player : getPlayers()) {
|
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();
|
Location respawn = gamePlayer.getCheckpoint();
|
||||||
|
|
||||||
if (respawn == null) {
|
if (respawn == null) {
|
||||||
respawn = dGroup.getGameWorld().getStartLocation();
|
respawn = dGroup.getGameWorld().getStartLocation(dGroup);
|
||||||
}
|
|
||||||
|
|
||||||
if (respawn == null) {
|
|
||||||
respawn = dGroup.getGameWorld().getLobbyLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (respawn == null) {
|
|
||||||
respawn = dGroup.getGameWorld().getWorld().getSpawnLocation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because some plugins set another respawn point, DXL teleports a few ticks later.
|
// 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;
|
Location respawn = checkpoint;
|
||||||
|
|
||||||
if (respawn == null) {
|
if (respawn == null) {
|
||||||
respawn = dGroup.getGameWorld().getStartLocation();
|
respawn = dGroup.getGameWorld().getStartLocation(dGroup);
|
||||||
}
|
|
||||||
|
|
||||||
if (respawn == null) {
|
|
||||||
respawn = dGroup.getGameWorld().getLobbyLocation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (respawn == null) {
|
if (respawn == null) {
|
||||||
@ -693,7 +689,7 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
for (Player player : dGroup.getPlayers()) {
|
for (Player player : dGroup.getPlayers()) {
|
||||||
DGamePlayer dPlayer = getByPlayer(player);
|
DGamePlayer dPlayer = getByPlayer(player);
|
||||||
dPlayer.setWorld(gameWorld.getWorld());
|
dPlayer.setWorld(gameWorld.getWorld());
|
||||||
dPlayer.setCheckpoint(dGroup.getGameWorld().getStartLocation());
|
dPlayer.setCheckpoint(dGroup.getGameWorld().getStartLocation(dGroup));
|
||||||
if (dPlayer.getWolf() != null) {
|
if (dPlayer.getWolf() != null) {
|
||||||
dPlayer.getWolf().teleport(dPlayer.getCheckpoint());
|
dPlayer.getWolf().teleport(dPlayer.getCheckpoint());
|
||||||
}
|
}
|
||||||
@ -816,15 +812,7 @@ public class DGamePlayer extends DInstancePlayer {
|
|||||||
teleportLocation = getCheckpoint();
|
teleportLocation = getCheckpoint();
|
||||||
|
|
||||||
if (teleportLocation == null) {
|
if (teleportLocation == null) {
|
||||||
teleportLocation = dGroup.getGameWorld().getStartLocation();
|
teleportLocation = dGroup.getGameWorld().getStartLocation(dGroup);
|
||||||
}
|
|
||||||
|
|
||||||
if (teleportLocation == null) {
|
|
||||||
teleportLocation = dGroup.getGameWorld().getLobbyLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (teleportLocation == null) {
|
|
||||||
teleportLocation = getWorld().getSpawnLocation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't forget Doge!
|
// Don't forget Doge!
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -27,10 +28,29 @@ public class StartSign extends DSign {
|
|||||||
|
|
||||||
private DSignType type = DSignTypeDefault.START;
|
private DSignType type = DSignTypeDefault.START;
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
|
||||||
public StartSign(Sign sign, String[] lines, GameWorld gameWorld) {
|
public StartSign(Sign sign, String[] lines, GameWorld gameWorld) {
|
||||||
super(sign, lines, 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
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
return true;
|
return true;
|
||||||
@ -38,7 +58,7 @@ public class StartSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
getGameWorld().setStartLocation(getSign().getLocation());
|
id = NumberUtil.parseInt(lines[1]);
|
||||||
getSign().getBlock().setType(Material.AIR);
|
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.game.GamePlaceableBlock;
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
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.reward.RewardChest;
|
||||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
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.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.ProgressTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.Trigger;
|
import io.github.dre2n.dungeonsxl.trigger.Trigger;
|
||||||
@ -203,16 +205,31 @@ public class GameWorld {
|
|||||||
/**
|
/**
|
||||||
* @return the start location
|
* @return the start location
|
||||||
*/
|
*/
|
||||||
public Location getStartLocation() {
|
public Location getStartLocation(DGroup dGroup) {
|
||||||
return locStart;
|
int index = getGame().getDGroups().indexOf(dGroup);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// Try the matching location
|
||||||
* @param location
|
for (DSign dSign : dSigns) {
|
||||||
* the location to start to set
|
if (dSign.getType() == DSignTypeDefault.START) {
|
||||||
*/
|
if (((StartSign) dSign).getId() == index) {
|
||||||
public void setStartLocation(Location location) {
|
return dSign.getSign().getLocation();
|
||||||
this.locStart = location;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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