mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-18 13:53:49 -07:00
PlayerDeathEvent#shouldDropExperience
This commit is contained in:
@@ -0,0 +1,62 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Shane Freeder <theboyetronic@gmail.com>
|
||||||
|
Date: Tue, 24 Dec 2019 00:35:31 +0000
|
||||||
|
Subject: [PATCH] PlayerDeathEvent#shouldDropExperience
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
|
||||||
|
index 1e97d04b..3a743430 100644
|
||||||
|
--- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
|
||||||
|
+++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
|
||||||
|
@@ -0,0 +0,0 @@
|
||||||
|
package org.bukkit.event.entity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
+
|
||||||
|
+import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent {
|
||||||
|
public List<ItemStack> getItemsToKeep() {
|
||||||
|
return itemsToKeep;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ private boolean doExpDrop;
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * @return should experience be dropped from this death
|
||||||
|
+ */
|
||||||
|
+ public boolean shouldDropExperience() {
|
||||||
|
+ return doExpDrop;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * @param doExpDrop sets if experience should be dropped from this death
|
||||||
|
+ */
|
||||||
|
+ public void setShouldDropExperience(boolean doExpDrop) {
|
||||||
|
+ this.doExpDrop = doExpDrop;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> drops, final int droppedExp, @Nullable final String deathMessage) {
|
||||||
|
@@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent {
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage) {
|
||||||
|
+ // Paper start
|
||||||
|
+ this(player, drops, droppedExp, newExp, newTotalExp, newLevel, deathMessage, player.getGameMode() != GameMode.SPECTATOR);
|
||||||
|
+ }
|
||||||
|
+ public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage, boolean doExpDrop) {
|
||||||
|
+ // Paper end
|
||||||
|
super(player, drops, droppedExp);
|
||||||
|
this.newExp = newExp;
|
||||||
|
this.newTotalExp = newTotalExp;
|
||||||
|
this.newLevel = newLevel;
|
||||||
|
this.deathMessage = deathMessage;
|
||||||
|
+ this.doExpDrop = doExpDrop; // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
--
|
@@ -0,0 +1,19 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Shane Freeder <theboyetronic@gmail.com>
|
||||||
|
Date: Tue, 24 Dec 2019 00:35:42 +0000
|
||||||
|
Subject: [PATCH] PlayerDeathEvent#shouldDropExperience
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||||
|
index ed6f1b1a3..5cd709991 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||||
|
@@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setSpectatorTarget(this); // Remove spectated target
|
||||||
|
+ if (event.shouldDropExperience()) this.dropExperience(); // Paper - drop experience
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
// CraftBukkit - Get our scores instead
|
||||||
|
--
|
Reference in New Issue
Block a user