Skip to content

Commit

Permalink
Sword isn't dropped at the end of the match anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
Devlrxxh committed Apr 5, 2024
1 parent fdc608d commit f1c7c47
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
32 changes: 18 additions & 14 deletions src/main/java/me/lrxh/practice/match/Match.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/lrxh/practice/match/MatchListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/me/lrxh/practice/util/PlayerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f1c7c47

Please sign in to comment.