mirror of
https://github.com/taoneill/war.git
synced 2025-01-07 00:08:25 +01:00
Fix #840, keep health in bounds with attributes
This commit is contained in:
parent
5c992c95ee
commit
13e5d38277
14
war/pom.xml
14
war/pom.xml
@ -54,6 +54,12 @@
|
|||||||
<tag>HEAD</tag>
|
<tag>HEAD</tag>
|
||||||
<url>https://github.com/taoneill/war</url>
|
<url>https://github.com/taoneill/war</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>cma-repo</id>
|
||||||
|
<url>ftp://ftp.cmastudios.me/srv/ftp/maven</url>
|
||||||
|
</repository>
|
||||||
|
</distributionManagement>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -93,6 +99,12 @@
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
<extensions>
|
||||||
|
<extension>
|
||||||
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
|
<artifactId>wagon-ftp</artifactId>
|
||||||
|
</extension>
|
||||||
|
</extensions>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
@ -117,7 +129,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.9.4-R0.1-SNAPSHOT</version>
|
<version>1.12-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.kitteh</groupId>
|
<groupId>org.kitteh</groupId>
|
||||||
|
@ -26,6 +26,9 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
|
import org.bukkit.attribute.AttributeInstance;
|
||||||
|
import org.bukkit.attribute.AttributeModifier;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
@ -445,14 +448,26 @@ public class Warzone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleRespawn(final Team team, final Player player) {
|
private void handleRespawn(final Team team, final Player player) {
|
||||||
|
// first, wipe inventory to disable attribute modifications
|
||||||
|
this.preventItemHackingThroughOpenedInventory(player);
|
||||||
|
player.getInventory().clear();
|
||||||
|
|
||||||
|
// clear potion effects
|
||||||
|
PotionEffectHelper.clearPotionEffects(player);
|
||||||
|
|
||||||
// Fill hp
|
// Fill hp
|
||||||
player.setRemainingAir(player.getMaximumAir());
|
player.setRemainingAir(player.getMaximumAir());
|
||||||
player.setMaxHealth(20);
|
AttributeInstance ai = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
||||||
player.setHealth(player.getMaxHealth());
|
for (AttributeModifier mod : ai.getModifiers()) {
|
||||||
|
ai.removeModifier(mod);
|
||||||
|
}
|
||||||
|
ai.setBaseValue(20.0);
|
||||||
|
player.setHealth(ai.getValue());
|
||||||
player.setFoodLevel(20);
|
player.setFoodLevel(20);
|
||||||
player.setSaturation(team.getTeamConfig().resolveInt(TeamConfig.SATURATION));
|
player.setSaturation(team.getTeamConfig().resolveInt(TeamConfig.SATURATION));
|
||||||
player.setExhaustion(0);
|
player.setExhaustion(0);
|
||||||
player.setFallDistance(0);
|
player.setFallDistance(0);
|
||||||
|
player.setFireTicks(0);
|
||||||
War.war.getServer().getScheduler().runTaskLater(War.war, new Runnable() {
|
War.war.getServer().getScheduler().runTaskLater(War.war, new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -463,24 +478,20 @@ public class Warzone {
|
|||||||
|
|
||||||
}, 1L);
|
}, 1L);
|
||||||
|
|
||||||
this.preventItemHackingThroughOpenedInventory(player);
|
|
||||||
|
|
||||||
player.setLevel(0);
|
player.setLevel(0);
|
||||||
player.setExp(0);
|
player.setExp(0);
|
||||||
player.setAllowFlight(false);
|
player.setAllowFlight(false);
|
||||||
player.setFlying(false);
|
player.setFlying(false);
|
||||||
|
|
||||||
player.getInventory().clear();
|
|
||||||
|
|
||||||
this.setKillCount(player.getName(), 0);
|
this.setKillCount(player.getName(), 0);
|
||||||
|
|
||||||
if (player.getGameMode() != GameMode.SURVIVAL) {
|
if (player.getGameMode() != GameMode.SURVIVAL) {
|
||||||
// Players are always in survival mode in warzones
|
// Players are always in survival mode in warzones
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear potion effects
|
|
||||||
PotionEffectHelper.clearPotionEffects(player);
|
|
||||||
|
|
||||||
String potionEffect = team.getTeamConfig().resolveString(TeamConfig.APPLYPOTION);
|
String potionEffect = team.getTeamConfig().resolveString(TeamConfig.APPLYPOTION);
|
||||||
if (!potionEffect.isEmpty()) {
|
if (!potionEffect.isEmpty()) {
|
||||||
@ -628,7 +639,8 @@ public class Warzone {
|
|||||||
|
|
||||||
this.playerInvFromInventoryStash(playerInv, originalState);
|
this.playerInvFromInventoryStash(playerInv, originalState);
|
||||||
player.setGameMode(originalState.getGamemode());
|
player.setGameMode(originalState.getGamemode());
|
||||||
player.setHealth(Math.max(Math.min(originalState.getHealth(), 20.0D), 0.0D));
|
double maxH = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||||
|
player.setHealth(Math.max(Math.min(originalState.getHealth(), maxH), 0.0D));
|
||||||
player.setExhaustion(originalState.getExhaustion());
|
player.setExhaustion(originalState.getExhaustion());
|
||||||
player.setSaturation(originalState.getSaturation());
|
player.setSaturation(originalState.getSaturation());
|
||||||
player.setFoodLevel(originalState.getFoodLevel());
|
player.setFoodLevel(originalState.getFoodLevel());
|
||||||
|
Loading…
Reference in New Issue
Block a user