mirror of https://github.com/taoneill/war.git
Fix fire burning after respawn
Whoever wrote the note in LoadoutResetJob about stopping fire knew what he was talking about. Sadly `git blame` shows nothing due to a refactor. However, this job was still being run in sync, therefore doing nothing. So I added a new job that is ran a tick later to clean up.
This commit is contained in:
parent
7561fd8ffb
commit
2c529f7647
|
@ -451,8 +451,16 @@ public class Warzone {
|
|||
player.setFoodLevel(20);
|
||||
player.setSaturation(team.getTeamConfig().resolveInt(TeamConfig.SATURATION));
|
||||
player.setExhaustion(0);
|
||||
player.setFireTicks(0); //this works fine here, why put it in LoudoutResetJob...? I'll keep it over there though
|
||||
player.setFallDistance(0);
|
||||
War.war.getServer().getScheduler().runTaskLater(War.war, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Stop fire here, since doing it in the same tick as death doesn't extinguish it
|
||||
player.setFireTicks(0);
|
||||
}
|
||||
|
||||
}, 1L);
|
||||
|
||||
this.preventItemHackingThroughOpenedInventory(player);
|
||||
|
||||
|
|
|
@ -351,36 +351,6 @@ public class WarEntityListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityCombust(final EntityCombustEvent event) {
|
||||
if (!War.war.isLoaded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
Team team = Team.getTeamByPlayerName(player.getName());
|
||||
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
|
||||
LoadoutSelection playerLoadoutState = null;
|
||||
|
||||
if (zone != null) {
|
||||
playerLoadoutState = zone.getLoadoutSelections().get(player.getName());
|
||||
}
|
||||
|
||||
if (team != null
|
||||
&& zone != null
|
||||
&& team.isSpawnLocation(player.getLocation())
|
||||
&& playerLoadoutState != null
|
||||
&& playerLoadoutState.isStillInSpawn()) {
|
||||
// smother out the fire that didn't burn out when you respawned
|
||||
// Stop fire (but not if you came back to spawn after leaving it a first time)
|
||||
player.setFireTicks(0);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents creatures from spawning in warzones if no creatures is active
|
||||
*
|
||||
|
|
|
@ -23,9 +23,6 @@ public class LoadoutResetJob implements Runnable {
|
|||
|
||||
public void run() {
|
||||
this.zone.equipPlayerLoadoutSelection(player, team, isFirstRespawn, isToggle);
|
||||
|
||||
// Stop fire here, since doing it in the same tick as death doesn't extinguish it
|
||||
this.player.setFireTicks(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,9 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
public class PotionEffectHelper {
|
||||
|
||||
public static void restorePotionEffects(Player player, Collection<PotionEffect> potionEffects) {
|
||||
|
||||
public static void restorePotionEffects(Player player,
|
||||
Collection<PotionEffect> potionEffects) {
|
||||
clearPotionEffects(player);
|
||||
for (PotionEffect effect : potionEffects) {
|
||||
player.addPotionEffect(effect, true);
|
||||
|
@ -15,9 +16,8 @@ public class PotionEffectHelper {
|
|||
}
|
||||
|
||||
public static void clearPotionEffects(Player player) {
|
||||
for(PotionEffect effect : player.getActivePotionEffects())
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(effect.getType(), 0, 0), true);
|
||||
for (PotionEffect effect : player.getActivePotionEffects()) {
|
||||
player.removePotionEffect(effect.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue