mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 17:37:42 +01:00
Move more options to per-world section (still more to come)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
From ce25ea0e468fcae7a6ca9bbae69b59ff67d15877 Mon Sep 17 00:00:00 2001
|
||||
From a390a1f62e35af6c5f9a78ec938aa7e609cc196e Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 30 Nov 2019 03:30:17 -0600
|
||||
Subject: [PATCH] Add sleep options
|
||||
@@ -9,7 +9,7 @@ Subject: [PATCH] Add sleep options
|
||||
2 files changed, 29 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
index 3c9f180960..3957daf751 100644
|
||||
index 3c9f180960..e1301d3170 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
@@ -14,6 +14,11 @@ import java.util.OptionalInt;
|
||||
@@ -40,10 +40,10 @@ index 3c9f180960..3957daf751 100644
|
||||
+ private ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName("JavaScript");
|
||||
+
|
||||
+ private boolean unableToSleepRightNow() {
|
||||
+ if (world.purpurConfig.sleepOnlyWithCondition) {
|
||||
+ if (world.purpurConfig.playerSleepOnlyWithCondition) {
|
||||
+ try {
|
||||
+ scriptEngine.eval("time = " + world.getDayTime());
|
||||
+ return !(Boolean) scriptEngine.eval(world.purpurConfig.sleepCondition);
|
||||
+ return !(Boolean) scriptEngine.eval(world.purpurConfig.playerSleepCondition);
|
||||
+ } catch (ScriptException ignore) {
|
||||
+ }
|
||||
+ }
|
||||
@@ -73,18 +73,18 @@ index 3c9f180960..3957daf751 100644
|
||||
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW);
|
||||
}
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index 4cfdd5c81c..0b01e5c7cd 100644
|
||||
index 04b6723322..bb95f4322c 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -182,6 +182,13 @@ public class PurpurWorldConfig {
|
||||
idleTimeoutBroadcastBack = ChatColor.translateAlternateColorCodes('&', getString("idle-timeout.broadcast.back", idleTimeoutBroadcastBack));
|
||||
elytraDamagePerTridentBoost = getInt("elytra.damage-per-boost.trident", elytraDamagePerTridentBoost);
|
||||
}
|
||||
|
||||
+ public boolean sleepOnlyWithCondition = false;
|
||||
+ public String sleepCondition = "time >= 12541 && time <= 23458";
|
||||
+ private void sleepSettings() {
|
||||
+ sleepOnlyWithCondition = getBoolean("sleep.only-with-condition", sleepOnlyWithCondition);
|
||||
+ sleepCondition = getString("sleep.condition", sleepCondition);
|
||||
+ public boolean playerSleepOnlyWithCondition = false;
|
||||
+ public String playerSleepCondition = "time >= 12541 && time <= 23458";
|
||||
+ private void playerSettings() {
|
||||
+ playerSleepOnlyWithCondition = getBoolean("player.sleep.only-with-condition", playerSleepOnlyWithCondition);
|
||||
+ playerSleepCondition = getString("player.sleep.condition", playerSleepCondition);
|
||||
+ }
|
||||
+
|
||||
public int chickenEggsHatchWhenDespawnedMax = 0;
|
||||
|
||||
Reference in New Issue
Block a user