mirror of
https://github.com/SunNetservers/MiniGames.git
synced 2025-01-31 08:49:34 +01:00
Restores player health upon arena exit
This commit is contained in:
parent
d101c7ed02
commit
2ec15c69c7
@ -36,6 +36,7 @@ public abstract class AbstractPlayerEntryState implements PlayerEntryState {
|
||||
private final boolean originalInvulnerable;
|
||||
private final boolean originalIsSwimming;
|
||||
private final boolean originalCollideAble;
|
||||
private final double originalHealth;
|
||||
private final Collection<PotionEffect> originalPotionEffects;
|
||||
|
||||
/**
|
||||
@ -52,6 +53,7 @@ public abstract class AbstractPlayerEntryState implements PlayerEntryState {
|
||||
this.originalInvulnerable = player.isInvulnerable();
|
||||
this.originalIsSwimming = player.isSwimming();
|
||||
this.originalCollideAble = player.isCollidable();
|
||||
this.originalHealth = player.getHealth();
|
||||
|
||||
// Store and clear potion effects
|
||||
this.originalPotionEffects = getPlayer().getActivePotionEffects();
|
||||
@ -72,11 +74,13 @@ public abstract class AbstractPlayerEntryState implements PlayerEntryState {
|
||||
* @param originalIsSwimming <p>Whether the player was swimming before entering the arena</p>
|
||||
* @param originalCollideAble <p>Whether the player was collide-able before entering the arena</p>
|
||||
* @param originalPotionEffects <p>The potion effects applied to the player when joining</p>
|
||||
* @param originalHealth <p>The health of the player when joining the arena</p>
|
||||
*/
|
||||
public AbstractPlayerEntryState(@NotNull UUID playerId, Location entryLocation,
|
||||
public AbstractPlayerEntryState(@NotNull UUID playerId, @NotNull Location entryLocation,
|
||||
boolean originalIsFlying, GameMode originalGameMode, boolean originalAllowFlight,
|
||||
boolean originalInvulnerable, boolean originalIsSwimming,
|
||||
boolean originalCollideAble, Collection<PotionEffect> originalPotionEffects) {
|
||||
boolean originalCollideAble, @NotNull Collection<PotionEffect> originalPotionEffects,
|
||||
double originalHealth) {
|
||||
this.playerId = playerId;
|
||||
this.entryLocation = entryLocation;
|
||||
this.originalIsFlying = originalIsFlying;
|
||||
@ -86,6 +90,7 @@ public abstract class AbstractPlayerEntryState implements PlayerEntryState {
|
||||
this.originalIsSwimming = originalIsSwimming;
|
||||
this.originalCollideAble = originalCollideAble;
|
||||
this.originalPotionEffects = originalPotionEffects;
|
||||
this.originalHealth = originalHealth;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -115,6 +120,7 @@ public abstract class AbstractPlayerEntryState implements PlayerEntryState {
|
||||
player.addPotionEffect(potionEffect);
|
||||
}
|
||||
removeMenuItem(player);
|
||||
player.setHealth(originalHealth);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -149,6 +155,7 @@ public abstract class AbstractPlayerEntryState implements PlayerEntryState {
|
||||
data.put("originalIsSwimming", this.originalIsSwimming);
|
||||
data.put("originalCollideAble", this.originalCollideAble);
|
||||
data.put("originalPotionEffects", this.originalPotionEffects);
|
||||
data.put("originalHealth", this.originalHealth);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -49,15 +49,16 @@ public class DropperPlayerEntryState extends AbstractPlayerEntryState {
|
||||
* @param horizontalVelocity <p>The horizontal velocity of the player before entering the arena</p>
|
||||
* @param originalCollideAble <p>Whether the player was collide-able before entering the arena</p>
|
||||
* @param originalPotionEffects <p>The potion effects applied to the player when joining</p>
|
||||
* @param originalHealth <p>The health of the player when joining the arena</p>
|
||||
*/
|
||||
public DropperPlayerEntryState(@NotNull UUID playerId, Location entryLocation,
|
||||
public DropperPlayerEntryState(@NotNull UUID playerId, @NotNull Location entryLocation,
|
||||
boolean originalIsFlying, GameMode originalGameMode, boolean originalAllowFlight,
|
||||
boolean originalInvulnerable, boolean originalIsSwimming,
|
||||
float originalFlySpeed, float horizontalVelocity,
|
||||
DropperArenaGameMode arenaGameMode, boolean originalCollideAble,
|
||||
Collection<PotionEffect> originalPotionEffects) {
|
||||
@NotNull DropperArenaGameMode arenaGameMode, boolean originalCollideAble,
|
||||
@NotNull Collection<PotionEffect> originalPotionEffects, double originalHealth) {
|
||||
super(playerId, entryLocation, originalIsFlying, originalGameMode, originalAllowFlight,
|
||||
originalInvulnerable, originalIsSwimming, originalCollideAble, originalPotionEffects);
|
||||
originalInvulnerable, originalIsSwimming, originalCollideAble, originalPotionEffects, originalHealth);
|
||||
this.originalFlySpeed = originalFlySpeed;
|
||||
this.horizontalVelocity = horizontalVelocity;
|
||||
this.arenaGameMode = arenaGameMode;
|
||||
@ -128,10 +129,12 @@ public class DropperPlayerEntryState extends AbstractPlayerEntryState {
|
||||
boolean originalCollideAble = getBoolean(data, "originalCollideAble");
|
||||
Collection<PotionEffect> originalPotionEffect =
|
||||
(Collection<PotionEffect>) data.getOrDefault("originalPotionEffects", new ArrayList<>());
|
||||
double originalHealth = ((Number) data.get("originalHealth")).doubleValue();
|
||||
|
||||
return new DropperPlayerEntryState(playerId, entryLocation, originalIsFlying,
|
||||
originalGameMode, originalAllowFlight, originalInvulnerable, originalIsSwimming,
|
||||
originalFlySpeed, horizontalVelocity, arenaGameMode, originalCollideAble, originalPotionEffect);
|
||||
originalFlySpeed, horizontalVelocity, arenaGameMode, originalCollideAble, originalPotionEffect,
|
||||
originalHealth);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,13 +39,15 @@ public class ParkourPlayerEntryState extends AbstractPlayerEntryState {
|
||||
* @param originalIsSwimming <p>Whether the player was swimming before entering the arena</p>
|
||||
* @param originalCollideAble <p>Whether the player was collide-able before entering the arena</p>
|
||||
* @param originalPotionEffects <p>The potion effects applied to the player when joining</p>
|
||||
* @param originalHealth <p>The health of the player when joining the arena</p>
|
||||
*/
|
||||
public ParkourPlayerEntryState(@NotNull UUID playerId, Location entryLocation,
|
||||
boolean originalIsFlying, GameMode originalGameMode, boolean originalAllowFlight,
|
||||
boolean originalInvulnerable, boolean originalIsSwimming,
|
||||
boolean originalCollideAble, Collection<PotionEffect> originalPotionEffects) {
|
||||
boolean originalCollideAble, Collection<PotionEffect> originalPotionEffects,
|
||||
double originalHealth) {
|
||||
super(playerId, entryLocation, originalIsFlying, originalGameMode, originalAllowFlight,
|
||||
originalInvulnerable, originalIsSwimming, originalCollideAble, originalPotionEffects);
|
||||
originalInvulnerable, originalIsSwimming, originalCollideAble, originalPotionEffects, originalHealth);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -77,9 +79,11 @@ public class ParkourPlayerEntryState extends AbstractPlayerEntryState {
|
||||
boolean originalCollideAble = getBoolean(data, "originalCollideAble");
|
||||
Collection<PotionEffect> originalPotionEffect =
|
||||
(Collection<PotionEffect>) data.getOrDefault("originalPotionEffects", new ArrayList<>());
|
||||
double originalHealth = ((Number) data.get("originalHealth")).doubleValue();
|
||||
|
||||
return new ParkourPlayerEntryState(playerId, entryLocation, originalIsFlying, originalGameMode,
|
||||
originalAllowFlight, originalInvulnerable, originalIsSwimming, originalCollideAble, originalPotionEffect);
|
||||
originalAllowFlight, originalInvulnerable, originalIsSwimming, originalCollideAble,
|
||||
originalPotionEffect, originalHealth);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user