mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
67 lines
2.9 KiB
Diff
67 lines
2.9 KiB
Diff
From 7197feebf806f4be952a0d70efc4b3bd6bcb1493 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 | 17 ++++++++++++++---
|
|
.../java/net/pl3x/purpur/PurpurWorldConfig.java | 7 +++++++
|
|
2 files changed, 21 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
index a69a69859..ea4144371 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -85,6 +85,8 @@ public abstract class EntityHuman extends EntityLiving {
|
|
// CraftBukkit end
|
|
|
|
// Purpur start
|
|
+ private javax.script.ScriptEngine scriptEngine = new javax.script.ScriptEngineManager().getEngineByName("rhino");
|
|
+
|
|
public void setAfk(boolean setAfk){
|
|
}
|
|
|
|
@@ -1713,9 +1715,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) Math.round((Double) scriptEngine.eval(world.purpurConfig.playerDeathExpDropEquation));
|
|
+ } catch (Exception 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 a053ac84c..54208a018 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -126,6 +126,13 @@ public class PurpurWorldConfig {
|
|
tridentLoyaltyVoidReturnHeight = getDouble("gameplay-mechanics.trident-loyalty-void-return-height", tridentLoyaltyVoidReturnHeight);
|
|
}
|
|
|
|
+ public String playerDeathExpDropEquation = "expLevel * 7";
|
|
+ public int playerDeathExpDropMax = 100;
|
|
+ private void playerDeathExpSettings() {
|
|
+ playerDeathExpDropEquation = getString("gameplay-mechanics.player.exp-dropped-on-death.equation", playerDeathExpDropEquation);
|
|
+ playerDeathExpDropMax = getInt("gameplay-mechanics.player.exp-dropped-on-death.maximum", playerDeathExpDropMax);
|
|
+ }
|
|
+
|
|
public int playerSpawnInvulnerableTicks = 60;
|
|
public boolean playerInvulnerableWhileAcceptingResourcePack = false;
|
|
private void playerInvulnerabilities() {
|
|
--
|
|
2.26.2
|
|
|