mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: b8372fc0 Improve handling of indestructable blocks a2a06640 Add moon phase API 47f71aea Fix SpawnChangeEvent not firing for all use-cases b6c860f2 Don't require FACING data 0c1716a1 Add #setMaxPlayers API 02aed275 [CI-SKIP] Require dependencies script (#4172) 1ccc1c67 Add smithing item helpers 20d9ec6b Fix MC-197271 e9287056 [CI-SKIP] Update issue templates with notices
70 lines
1.8 KiB
Diff
70 lines
1.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Sat, 1 Feb 2020 22:22:07 -0600
|
|
Subject: [PATCH] MoonPhase API
|
|
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/MoonPhase.java b/src/main/java/net/pl3x/purpur/MoonPhase.java
|
|
new file mode 100644
|
|
index 000000000..f5ad98c62
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/pl3x/purpur/MoonPhase.java
|
|
@@ -0,0 +1,36 @@
|
|
+package net.pl3x.purpur;
|
|
+
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+import java.util.HashMap;
|
|
+import java.util.Map;
|
|
+
|
|
+public enum MoonPhase {
|
|
+ FULL_MOON(0L),
|
|
+ WANING_GIBBOUS(1L),
|
|
+ LAST_QUARTER(2L),
|
|
+ WANING_CRESCENT(3L),
|
|
+ NEW_MOON(4L),
|
|
+ WAXING_CRESCENT(5L),
|
|
+ FIRST_QUARTER(6L),
|
|
+ WAXING_GIBBOUS(7L);
|
|
+
|
|
+ private final long day;
|
|
+
|
|
+ MoonPhase(long day) {
|
|
+ this.day = day;
|
|
+ }
|
|
+
|
|
+ private static final Map<Long, MoonPhase> BY_DAY = new HashMap<>();
|
|
+
|
|
+ static {
|
|
+ for (MoonPhase phase : values()) {
|
|
+ BY_DAY.put(phase.day, phase);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public static MoonPhase getPhase(long day) {
|
|
+ return BY_DAY.get(day % 8L);
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
|
index e827e1a6f..2685dfa18 100644
|
|
--- a/src/main/java/org/bukkit/World.java
|
|
+++ b/src/main/java/org/bukkit/World.java
|
|
@@ -3466,6 +3466,16 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
|
@NotNull
|
|
public List<Raid> getRaids();
|
|
|
|
+ // Purpur start
|
|
+ /**
|
|
+ * Get the moon phase of the world at the current time
|
|
+ *
|
|
+ * @return Current moon phase
|
|
+ */
|
|
+ @NotNull
|
|
+ net.pl3x.purpur.MoonPhase getMoonPhase();
|
|
+ // Purpur end
|
|
+
|
|
/**
|
|
* Get the {@link DragonBattle} associated with this world.
|
|
*
|