Add player death exp control options

This commit is contained in:
William Blake Galbreath
2019-12-26 22:10:22 -06:00
parent b3c97cc371
commit 3ba70d25fb
2 changed files with 66 additions and 0 deletions

View File

@@ -410,6 +410,15 @@ fluid-tick-events
* **default**: true
* **description**: Fire plugin events when fluids tick
player
* exp-dropped-on-death
* equation
- **default:** expLevel * 7
- **description:** How much exp to drop on death. Available NMS variables are `expLevel`, `expTotal`, and `exp`.
* maximum
- **default:** 100
- **description:** Maximum amount of exp value to drop on death
cat-spawns
~~~~~~~~~~
* delay

View File

@@ -0,0 +1,57 @@
From b59febc90f454a5677b347cc7c27ed630ebab1ca Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Thu, 26 Dec 2019 22:08:37 -0600
Subject: [PATCH] Add player death exp control options
---
.../java/net/minecraft/server/EntityHuman.java | 15 ++++++++++++---
.../java/net/pl3x/purpur/PurpurWorldConfig.java | 7 +++++++
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 3957daf75..6e60a1608 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -1858,9 +1858,18 @@ public abstract class EntityHuman extends EntityLiving {
@Override
protected int getExpValue(EntityHuman entityhuman) {
if (!this.world.getGameRules().getBoolean(GameRules.KEEP_INVENTORY) && !this.isSpectator()) {
- int i = this.expLevel * 7;
-
- return i > 100 ? 100 : i;
+ // Purpur start
+ int toDrop;
+ try {
+ scriptEngine.eval("expLevel = " + expLevel);
+ scriptEngine.eval("expTotal = " + expTotal);
+ scriptEngine.eval("exp = " + exp);
+ toDrop = (int) scriptEngine.eval(world.purpurConfig.playerDeathExpDropEquation);
+ } catch (ScriptException ignore) {
+ toDrop = expLevel * 7;
+ }
+ return Math.min(toDrop, world.purpurConfig.playerDeathExpDropMax);
+ // Purpur end
} else {
return 0;
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index a2c81fad3..a0bf56284 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -149,6 +149,13 @@ public class PurpurWorldConfig {
hayBlockFallDamage = getBoolean("hay-block-fall-damage", hayBlockFallDamage);
}
+ public String playerDeathExpDropEquation = "expLevel * 7";
+ public int playerDeathExpDropMax = 100;
+ private void playerSettings() {
+ playerDeathExpDropEquation = getString("player.exp-dropped-on-death.equation", playerDeathExpDropEquation);
+ playerDeathExpDropMax = getInt("player.exp-dropped-on-death.maximum", playerDeathExpDropMax);
+ }
+
public int catSpawnDelay = 1200;
public boolean catSpawnDisableSwampHut = false;
public int catSpawnSwampHutScanRange = 16;
--
2.24.0