Fix double death error by rearranging death event sequence
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
534b16b153
Commit
53901654a9
@ -100,7 +100,7 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
|||||||
@Override
|
@Override
|
||||||
public Listener newHandSwapRecorder() {
|
public Listener newHandSwapRecorder() {
|
||||||
return new Listener() {
|
return new Listener() {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onItemSwap(PlayerSwapHandItemsEvent e){
|
public void onItemSwap(PlayerSwapHandItemsEvent e){
|
||||||
if(Recording.isNotSent(e.getPlayer()))
|
if(Recording.isNotSent(e.getPlayer()))
|
||||||
return;
|
return;
|
||||||
|
@ -20,15 +20,12 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.utils.FightUI;
|
import de.steamwar.fightsystem.utils.FightUI;
|
||||||
import de.steamwar.fightsystem.utils.SWSound;
|
import de.steamwar.fightsystem.utils.SWSound;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -36,41 +33,42 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class IngameDeath implements Listener {
|
public class IngameDeath implements Listener {
|
||||||
|
|
||||||
public IngameDeath() {
|
public IngameDeath() {
|
||||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.Ingame, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.Ingame, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler
|
||||||
public void handlePlayerDeath(PlayerDeathEvent event) {
|
public void broadcastDeath(PlayerDeathEvent event) {
|
||||||
event.setDeathMessage(null);
|
onPlayerEnd(event.getEntity(), fightPlayer -> {
|
||||||
|
FightUI.addSubtitle("UI_PLAYER_DEATH", fightPlayer.getTeam().getPrefix(), fightPlayer.getPlayer().getName());
|
||||||
Player player = event.getEntity();
|
|
||||||
FightTeam team = Fight.getPlayerTeam(player);
|
|
||||||
|
|
||||||
if(team == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
FightUI.addSubtitle("UI_PLAYER_DEATH", team.getPrefix(), player.getName());
|
|
||||||
Fight.playSound(SWSound.ENTITY_WITHER_DEATH.getSound(), 100.0F, 1.0F);
|
Fight.playSound(SWSound.ENTITY_WITHER_DEATH.getSound(), 100.0F, 1.0F);
|
||||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> team.getFightPlayer(player).setOut());
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler
|
||||||
|
public void broadcastQuit(PlayerQuitEvent event) {
|
||||||
|
onPlayerEnd(event.getPlayer(), fightPlayer -> FightUI.addSubtitle("UI_PLAYER_LEAVE", fightPlayer.getTeam().getPrefix(), fightPlayer.getPlayer().getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void handlePlayerDeath(PlayerDeathEvent event) {
|
||||||
|
onPlayerEnd(event.getEntity(), FightPlayer::setOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
event.setQuitMessage(null);
|
onPlayerEnd(event.getPlayer(), FightPlayer::setOut);
|
||||||
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
private void onPlayerEnd(Player player, Consumer<FightPlayer> withLivingPlayer) {
|
||||||
FightTeam team = Fight.getPlayerTeam(player);
|
FightPlayer fightPlayer = Fight.getFightPlayer(player);
|
||||||
if(team == null)
|
if(fightPlayer == null || !fightPlayer.isLiving())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FightPlayer fightPlayer = team.getFightPlayer(player);
|
withLivingPlayer.accept(fightPlayer);
|
||||||
if(!fightPlayer.isLiving())
|
|
||||||
return;
|
|
||||||
|
|
||||||
FightUI.addSubtitle("UI_PLAYER_LEAVE", team.getPrefix(), player.getName());
|
|
||||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> team.getFightPlayer(player).setOut());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||||
import org.bukkit.event.inventory.CraftItemEvent;
|
import org.bukkit.event.inventory.CraftItemEvent;
|
||||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||||
@ -81,7 +82,12 @@ public class Permanent implements Listener {
|
|||||||
REntity.playerJoins(player);
|
REntity.playerJoins(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void handlePlayerDeath(PlayerDeathEvent event) {
|
||||||
|
event.setDeathMessage(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void handlePlayerLeave(PlayerQuitEvent event) {
|
public void handlePlayerLeave(PlayerQuitEvent event) {
|
||||||
event.setQuitMessage(null);
|
event.setQuitMessage(null);
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ public class Recording implements Listener {
|
|||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onPlayerMove(PlayerMoveEvent e){
|
public void onPlayerMove(PlayerMoveEvent e){
|
||||||
if(isNotSent(e.getPlayer()))
|
if(isNotSent(e.getPlayer()))
|
||||||
return;
|
return;
|
||||||
@ -141,15 +141,12 @@ public class Recording implements Listener {
|
|||||||
GlobalRecorder.getInstance().entityMoves(e.getPlayer());
|
GlobalRecorder.getInstance().entityMoves(e.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler
|
||||||
public void onPlayerDeath(PlayerDeathEvent e){
|
public void onPlayerDeath(PlayerDeathEvent e) {
|
||||||
if(isNotSent(e.getEntity()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
GlobalRecorder.getInstance().entityDespawns(e.getEntity());
|
GlobalRecorder.getInstance().entityDespawns(e.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent e){
|
public void onPlayerQuit(PlayerQuitEvent e){
|
||||||
if(isNotSent(e.getPlayer()))
|
if(isNotSent(e.getPlayer()))
|
||||||
return;
|
return;
|
||||||
@ -157,13 +154,13 @@ public class Recording implements Listener {
|
|||||||
GlobalRecorder.getInstance().entityDespawns(e.getPlayer());
|
GlobalRecorder.getInstance().entityDespawns(e.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onBlockPhysics(BlockPhysicsEvent e){
|
public void onBlockPhysics(BlockPhysicsEvent e){
|
||||||
if(FlatteningWrapper.impl.doRecord(e))
|
if(FlatteningWrapper.impl.doRecord(e))
|
||||||
GlobalRecorder.getInstance().blockChange(e.getBlock());
|
GlobalRecorder.getInstance().blockChange(e.getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onSneak(PlayerToggleSneakEvent e){
|
public void onSneak(PlayerToggleSneakEvent e){
|
||||||
if(isNotSent(e.getPlayer()))
|
if(isNotSent(e.getPlayer()))
|
||||||
return;
|
return;
|
||||||
@ -171,7 +168,7 @@ public class Recording implements Listener {
|
|||||||
GlobalRecorder.getInstance().playerSneak(e.getPlayer(), e.isSneaking());
|
GlobalRecorder.getInstance().playerSneak(e.getPlayer(), e.isSneaking());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onAnimation(PlayerAnimationEvent e){
|
public void onAnimation(PlayerAnimationEvent e){
|
||||||
if(isNotSent(e.getPlayer()))
|
if(isNotSent(e.getPlayer()))
|
||||||
return;
|
return;
|
||||||
@ -180,7 +177,7 @@ public class Recording implements Listener {
|
|||||||
GlobalRecorder.getInstance().entityAnimation(e.getPlayer(), AIR);
|
GlobalRecorder.getInstance().entityAnimation(e.getPlayer(), AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onEntityDamage(EntityDamageEvent e) {
|
public void onEntityDamage(EntityDamageEvent e) {
|
||||||
if(e.getEntityType() != EntityType.PLAYER)
|
if(e.getEntityType() != EntityType.PLAYER)
|
||||||
return;
|
return;
|
||||||
@ -195,7 +192,7 @@ public class Recording implements Listener {
|
|||||||
GlobalRecorder.getInstance().setOnFire(p, false);
|
GlobalRecorder.getInstance().setOnFire(p, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onEntityCombust(EntityCombustEvent e) {
|
public void onEntityCombust(EntityCombustEvent e) {
|
||||||
if(e.getEntityType() != EntityType.PLAYER)
|
if(e.getEntityType() != EntityType.PLAYER)
|
||||||
return;
|
return;
|
||||||
@ -207,7 +204,7 @@ public class Recording implements Listener {
|
|||||||
GlobalRecorder.getInstance().setOnFire(p, false);
|
GlobalRecorder.getInstance().setOnFire(p, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onTNTSpawn(EntitySpawnEvent e){
|
public void onTNTSpawn(EntitySpawnEvent e){
|
||||||
if(e.getEntityType() != EntityType.PRIMED_TNT)
|
if(e.getEntityType() != EntityType.PRIMED_TNT)
|
||||||
return;
|
return;
|
||||||
@ -215,7 +212,7 @@ public class Recording implements Listener {
|
|||||||
GlobalRecorder.getInstance().tntSpawn(e.getEntity());
|
GlobalRecorder.getInstance().tntSpawn(e.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onExplosion(EntityExplodeEvent e){
|
public void onExplosion(EntityExplodeEvent e){
|
||||||
if(e.getEntityType() != EntityType.PRIMED_TNT)
|
if(e.getEntityType() != EntityType.PRIMED_TNT)
|
||||||
return;
|
return;
|
||||||
@ -226,7 +223,7 @@ public class Recording implements Listener {
|
|||||||
GlobalRecorder.getInstance().sound(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), SWSound.ENTITY_GENERIC_EXPLODE, "BLOCKS", 4.0F, (1.0F + (random.nextFloat() - random.nextFloat()) * 0.2F) * 0.7F);
|
GlobalRecorder.getInstance().sound(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), SWSound.ENTITY_GENERIC_EXPLODE, "BLOCKS", 4.0F, (1.0F + (random.nextFloat() - random.nextFloat()) * 0.2F) * 0.7F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onItem(PlayerItemHeldEvent e){
|
public void onItem(PlayerItemHeldEvent e){
|
||||||
if(isNotSent(e.getPlayer()))
|
if(isNotSent(e.getPlayer()))
|
||||||
return;
|
return;
|
||||||
@ -234,7 +231,7 @@ public class Recording implements Listener {
|
|||||||
GlobalRecorder.getInstance().item(e.getPlayer(), disarmNull(e.getPlayer().getInventory().getItem(e.getNewSlot())), "MAINHAND");
|
GlobalRecorder.getInstance().item(e.getPlayer(), disarmNull(e.getPlayer().getInventory().getItem(e.getNewSlot())), "MAINHAND");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onProjectileSpawn(ProjectileLaunchEvent e){
|
public void onProjectileSpawn(ProjectileLaunchEvent e){
|
||||||
if(e.getEntityType() == EntityType.FIREBALL)
|
if(e.getEntityType() == EntityType.FIREBALL)
|
||||||
GlobalRecorder.getInstance().fireballSpawn(e.getEntity());
|
GlobalRecorder.getInstance().fireballSpawn(e.getEntity());
|
||||||
@ -242,7 +239,7 @@ public class Recording implements Listener {
|
|||||||
GlobalRecorder.getInstance().arrowSpawn(e.getEntity());
|
GlobalRecorder.getInstance().arrowSpawn(e.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onInventoryClick(InventoryClickEvent e){
|
public void onInventoryClick(InventoryClickEvent e){
|
||||||
Player player = (Player) e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
if(isNotSent(player))
|
if(isNotSent(player))
|
||||||
|
@ -25,7 +25,6 @@ import de.steamwar.fightsystem.states.FightState;
|
|||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ public class Shutdown implements Listener {
|
|||||||
new StateDependentListener(ArenaMode.AntiEvent, FightState.All, this);
|
new StateDependentListener(ArenaMode.AntiEvent, FightState.All, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
if(Config.replayserver())
|
if(Config.replayserver())
|
||||||
return;
|
return;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren