Fix player respawn location after exhausting all lives in dungeon; resolves #341

This commit is contained in:
Daniel Saukel 2018-06-20 21:48:03 +02:00
parent b65b4df8cc
commit 2b825e13e5
3 changed files with 23 additions and 10 deletions

View File

@ -48,17 +48,17 @@ If you want to learn how to use DungeonsXL step by step, please have a look at t
## Compatibility
### Server
DungeonsXL works with 1.8.8 and higher. However, support for 1.12.x / 1.11.x / 1.10.x / 1.9.x has a higher priority than support for 1.8.8. Old builds that support older versions are unusable for production environments. See [here](../../wiki/legacy-support) for detailed information. Some cosmetic features require the Spigot API and will therefore not work with CraftBukkit.
DungeonsXL works with 1.8.8 and higher. However, support for 1.13 / 1.12.x / 1.11.x / 1.10.x / 1.9.x has a higher priority than support for 1.8.8. Old builds that support older versions are unusable for production environments. See [here](../../wiki/legacy-support) for detailed information. Some cosmetic features require the Spigot API and will therefore not work with CraftBukkit.
### Building information and dependencies
Building DungeonsXL from source requires [Apache Maven](https://maven.apache.org/).
Maven automatically fetches all dependencies and builds DungeonsXL; just run _build.bat_ or enter the command _mvn clean install_.
#### DRECommons
[DRECommons](https://github.com/DRE2N/DRECommons) is a util library for common tasks. DungeonsXL contains DRECommons 4.2.
[DRECommons](https://github.com/DRE2N/DRECommons) is a util library for common tasks. DungeonsXL contains DRECommons 4.2.1.
#### Caliburn API
[Caliburn](https://github.com/DRE2N/CaliburnAPI) is an API to read custom items and mobs from config files. DungeonsXL contains Caliburn Beta 0.4.1.
[Caliburn](https://github.com/DRE2N/CaliburnAPI) is an API to read custom items and mobs from config files. DungeonsXL contains Caliburn Beta 0.4.2.
### Java
Make sure that your server uses Java 8 or higher.
@ -69,6 +69,7 @@ Supported.
### Known incompatibilities
* Towny
* Corpses
* PerWorldInventory
Many incompatibilities can be fixed with [PerWorldPlugins](http://dev.bukkit.org/bukkit-plugins/perworldplugins/) ([fork for 1.8+](https://www.spigotmc.org/resources/perworldplugins-unofficial-update-version.6454/)).
Try to add the incompatible plugins only to the worlds where you need them.

View File

@ -77,7 +77,7 @@
<dependency>
<groupId>de.erethon</groupId>
<artifactId>caliburn</artifactId>
<version>0.4.1</version>
<version>0.4.2</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -32,10 +32,12 @@ import java.io.File;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.scheduler.BukkitRunnable;
/**
* Represents a player in the non-DXL worlds of the server.
@ -322,7 +324,23 @@ public class DGlobalPlayer implements PlayerWrapper {
* Respawns the player at his old position before he was in a dungeon
*/
public void reset(boolean keepInventory) {
final Location tpLoc = data.getOldLocation().getWorld() != null ? data.getOldLocation() : Bukkit.getWorlds().get(0).getSpawnLocation();
if (player.isDead()) {
new BukkitRunnable() {
@Override
public void run() {
PlayerUtil.respawn(player);
reset(tpLoc, keepInventory);
}
}.runTaskLater(plugin, 1L);
} else {
reset(tpLoc, keepInventory);
}
}
private void reset(Location tpLoc, boolean keepInventory) {
try {
PlayerUtil.secureTeleport(player, tpLoc);
if (!keepInventory) {
while (data.getOldInventory().size() > 36) {
data.getOldInventory().remove(36);
@ -348,12 +366,6 @@ public class DGlobalPlayer implements PlayerWrapper {
player.addPotionEffects(data.getOldPotionEffects());
}
if (data.getOldLocation().getWorld() != null) {
PlayerUtil.secureTeleport(player, data.getOldLocation());
} else {
PlayerUtil.secureTeleport(player, Bukkit.getWorlds().get(0).getSpawnLocation());
}
} catch (NullPointerException exception) {
exception.printStackTrace();
player.setHealth(0);