Fix double death error by rearranging death event sequence #328
@ -100,7 +100,7 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
||||
@Override
|
||||
public Listener newHandSwapRecorder() {
|
||||
return new Listener() {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onItemSwap(PlayerSwapHandItemsEvent e){
|
||||
if(Recording.isNotSent(e.getPlayer()))
|
||||
return;
|
||||
|
@ -20,15 +20,12 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.FightUI;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -36,41 +33,42 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class IngameDeath implements Listener {
|
||||
|
||||
public IngameDeath() {
|
||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.Ingame, this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void handlePlayerDeath(PlayerDeathEvent event) {
|
||||
event.setDeathMessage(null);
|
||||
|
||||
Player player = event.getEntity();
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
|
||||
if(team == null)
|
||||
return;
|
||||
|
||||
FightUI.addSubtitle("UI_PLAYER_DEATH", team.getPrefix(), player.getName());
|
||||
@EventHandler
|
||||
public void broadcastDeath(PlayerDeathEvent event) {
|
||||
onPlayerEnd(event.getEntity(), fightPlayer -> {
|
||||
FightUI.addSubtitle("UI_PLAYER_DEATH", fightPlayer.getTeam().getPrefix(), fightPlayer.getPlayer().getName());
|
||||
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) {
|
||||
event.setQuitMessage(null);
|
||||
onPlayerEnd(event.getPlayer(), FightPlayer::setOut);
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
if(team == null)
|
||||
private void onPlayerEnd(Player player, Consumer<FightPlayer> withLivingPlayer) {
|
||||
FightPlayer fightPlayer = Fight.getFightPlayer(player);
|
||||
if(fightPlayer == null || !fightPlayer.isLiving())
|
||||
return;
|
||||
|
||||
FightPlayer fightPlayer = team.getFightPlayer(player);
|
||||
if(!fightPlayer.isLiving())
|
||||
return;
|
||||
|
||||
FightUI.addSubtitle("UI_PLAYER_LEAVE", team.getPrefix(), player.getName());
|
||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> team.getFightPlayer(player).setOut());
|
||||
withLivingPlayer.accept(fightPlayer);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
@ -81,7 +82,12 @@ public class Permanent implements Listener {
|
||||
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) {
|
||||
event.setQuitMessage(null);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ public class Recording implements Listener {
|
||||
return packet;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerMove(PlayerMoveEvent e){
|
||||
if(isNotSent(e.getPlayer()))
|
||||
return;
|
||||
@ -141,15 +141,12 @@ public class Recording implements Listener {
|
||||
GlobalRecorder.getInstance().entityMoves(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent e) {
|
||||
if(isNotSent(e.getEntity()))
|
||||
return;
|
||||
|
||||
GlobalRecorder.getInstance().entityDespawns(e.getEntity());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent e){
|
||||
if(isNotSent(e.getPlayer()))
|
||||
return;
|
||||
@ -157,13 +154,13 @@ public class Recording implements Listener {
|
||||
GlobalRecorder.getInstance().entityDespawns(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockPhysics(BlockPhysicsEvent e){
|
||||
if(FlatteningWrapper.impl.doRecord(e))
|
||||
GlobalRecorder.getInstance().blockChange(e.getBlock());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onSneak(PlayerToggleSneakEvent e){
|
||||
if(isNotSent(e.getPlayer()))
|
||||
return;
|
||||
@ -171,7 +168,7 @@ public class Recording implements Listener {
|
||||
GlobalRecorder.getInstance().playerSneak(e.getPlayer(), e.isSneaking());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onAnimation(PlayerAnimationEvent e){
|
||||
if(isNotSent(e.getPlayer()))
|
||||
return;
|
||||
@ -180,7 +177,7 @@ public class Recording implements Listener {
|
||||
GlobalRecorder.getInstance().entityAnimation(e.getPlayer(), AIR);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent e) {
|
||||
if(e.getEntityType() != EntityType.PLAYER)
|
||||
return;
|
||||
@ -195,7 +192,7 @@ public class Recording implements Listener {
|
||||
GlobalRecorder.getInstance().setOnFire(p, false);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityCombust(EntityCombustEvent e) {
|
||||
if(e.getEntityType() != EntityType.PLAYER)
|
||||
return;
|
||||
@ -207,7 +204,7 @@ public class Recording implements Listener {
|
||||
GlobalRecorder.getInstance().setOnFire(p, false);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onTNTSpawn(EntitySpawnEvent e){
|
||||
if(e.getEntityType() != EntityType.PRIMED_TNT)
|
||||
return;
|
||||
@ -215,7 +212,7 @@ public class Recording implements Listener {
|
||||
GlobalRecorder.getInstance().tntSpawn(e.getEntity());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onExplosion(EntityExplodeEvent e){
|
||||
if(e.getEntityType() != EntityType.PRIMED_TNT)
|
||||
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);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onItem(PlayerItemHeldEvent e){
|
||||
if(isNotSent(e.getPlayer()))
|
||||
return;
|
||||
@ -234,7 +231,7 @@ public class Recording implements Listener {
|
||||
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){
|
||||
if(e.getEntityType() == EntityType.FIREBALL)
|
||||
GlobalRecorder.getInstance().fireballSpawn(e.getEntity());
|
||||
@ -242,7 +239,7 @@ public class Recording implements Listener {
|
||||
GlobalRecorder.getInstance().arrowSpawn(e.getEntity());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onInventoryClick(InventoryClickEvent e){
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
if(isNotSent(player))
|
||||
|
@ -25,7 +25,6 @@ import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
@ -35,7 +34,7 @@ public class Shutdown implements Listener {
|
||||
new StateDependentListener(ArenaMode.AntiEvent, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler
|
||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||
if(Config.replayserver())
|
||||
return;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren