From f1c7c4721a9347664205f369ed7af3d001072c50 Mon Sep 17 00:00:00 2001 From: devlrxxh Date: Sat, 6 Apr 2024 00:24:27 +0200 Subject: [PATCH] Sword isn't dropped at the end of the match anymore --- .../java/me/lrxh/practice/match/Match.java | 32 +++++++++++-------- .../me/lrxh/practice/match/MatchListener.java | 2 +- .../me/lrxh/practice/util/PlayerUtil.java | 2 -- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/java/me/lrxh/practice/match/Match.java b/src/main/java/me/lrxh/practice/match/Match.java index 42dc228..d3adcea 100644 --- a/src/main/java/me/lrxh/practice/match/Match.java +++ b/src/main/java/me/lrxh/practice/match/Match.java @@ -478,10 +478,27 @@ public void onDeath(Player dead) { if (!(state == MatchState.STARTING_ROUND || state == MatchState.PLAYING_ROUND)) { return; } - PlayerUtil.animateDeath(dead); MatchGamePlayer deadGamePlayer = getGamePlayer(dead); Player killer = PlayerUtil.getLastAttacker(dead); + + // Store snapshot of player inventory and stats + MatchSnapshot snapshot = new MatchSnapshot(dead, true); + snapshot.setPotionsMissed(deadGamePlayer.getPotionsMissed()); + snapshot.setPotionsThrown(deadGamePlayer.getPotionsThrown()); + snapshot.setLongestCombo(deadGamePlayer.getLongestCombo()); + snapshot.setTotalHits(deadGamePlayer.getHits()); + Profile loserProfile = Profile.getByUuid(deadGamePlayer.getUuid()); + if (!Practice.getInstance().getCache().getMatch(matchId).isDuel()) { + loserProfile.getKitData().get(loserProfile.getMatch().getKit()).incrementLost(); + } + dead.setItemInHand(null); + + // Add snapshot to list + snapshots.add(snapshot); + + PlayerUtil.animateDeath(dead); + if (killer != null) { PlayerUtil.sendTitle(dead, CC.translate("&cLOST!"), "&c" + killer.getName() + " &fwon the match!", 60); } @@ -503,19 +520,6 @@ public void onDeath(Player dead) { killer.playSound(killer.getLocation(), Sound.EXPLODE, 1.0f, 1.0f); } - // Store snapshot of player inventory and stats - MatchSnapshot snapshot = new MatchSnapshot(dead, true); - snapshot.setPotionsMissed(deadGamePlayer.getPotionsMissed()); - snapshot.setPotionsThrown(deadGamePlayer.getPotionsThrown()); - snapshot.setLongestCombo(deadGamePlayer.getLongestCombo()); - snapshot.setTotalHits(deadGamePlayer.getHits()); - Profile loserProfile = Profile.getByUuid(deadGamePlayer.getUuid()); - if (!Practice.getInstance().getCache().getMatch(matchId).isDuel()) { - loserProfile.getKitData().get(loserProfile.getMatch().getKit()).incrementLost(); - } - // Add snapshot to list - snapshots.add(snapshot); - PlayerUtil.setLastAttacker(dead, null); PlayerUtil.reset(dead); diff --git a/src/main/java/me/lrxh/practice/match/MatchListener.java b/src/main/java/me/lrxh/practice/match/MatchListener.java index 0871337..fce160a 100644 --- a/src/main/java/me/lrxh/practice/match/MatchListener.java +++ b/src/main/java/me/lrxh/practice/match/MatchListener.java @@ -343,13 +343,13 @@ public void onPlayerPickUpEvent(PlayerPickupItemEvent event) { public void onPlayerDeathEvent(PlayerDeathEvent event) { Player player = event.getEntity(); event.setDeathMessage(null); + event.getDrops().clear(); Profile profile = Profile.getByUuid(event.getEntity().getUniqueId()); if (profile.getMatch() != null) { Match match = profile.getMatch(); - event.getDrops().clear(); boolean aTeam = match.getParticipantA().containsPlayer(player.getUniqueId()); diff --git a/src/main/java/me/lrxh/practice/util/PlayerUtil.java b/src/main/java/me/lrxh/practice/util/PlayerUtil.java index 6381769..f59a911 100644 --- a/src/main/java/me/lrxh/practice/util/PlayerUtil.java +++ b/src/main/java/me/lrxh/practice/util/PlayerUtil.java @@ -164,8 +164,6 @@ public void teleportToSpawn(Player player) { } public void animateDeath(Player player) { - player.setItemInHand(null); - int entityId = EntityUtils.getFakeEntityId(); PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(((CraftPlayer) player).getHandle()); PacketPlayOutEntityStatus statusPacket = new PacketPlayOutEntityStatus();