mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 08:57:44 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: cc477e6a Force Plugins that use delayed tasks for init back in their place 597263fd Don't skip full player connection tick when dead e2c23475 Revert loaded entity list (#3304) fa87db6b Move another NetworkManager util into the inner class (#3303) 841c7d18 Make loaded entity list logic more consistent (#3301) 36f34f01 Updated Upstream (Bukkit/CraftBukkit) 5ca5f131 Rebuild all patches using the new rebuild pattern 1ccff6fa Add villager reputation API 5c0bfffa Speed up rebuilding patches and reduce diff f37381ea Optimize Network Manager to not need synchronization 8f9df2ed Anti Xray cleanup 878c66f1 No-Tick view distance implementation - Closes #3196 b87743c1 Stop copy-on-write operations for updating light data 97a9c972 Optimize isOutsideRange to use distance maps b4e629a2 Use distance map to optimise entity tracker / Misc Utils d80d1517 Optimize Entity Ticking to Loaded Chunks only 31d7686d Add item slot helper methods for various inventories (#3221) 75e1e3b3 Mob Goal API c7bc393a Revert "Don't flush packet queue off main thread" 1abd2bd2 Don't flush packet queue off main thread a4ed58a9 Clean up Direct Memory Region Files Fix for different Java versions 55e35019 Set cap on JDK per-thread native byte buffer cache b5101f4f Cleanup Region Files Direct Memory on close 81e655d7 Optimize Voxel Shape Merging ed9fc11f Sync position on teleportation 9c326fce Nanothing to see here 3e9fc24b Attempt to fix FastLogin maybe
78 lines
2.0 KiB
Diff
78 lines
2.0 KiB
Diff
From f7117483a092158d2028933b04c54d53a637b7b8 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] Add moon phase API
|
|
|
|
---
|
|
src/main/java/net/pl3x/purpur/MoonPhase.java | 36 ++++++++++++++++++++
|
|
src/main/java/org/bukkit/World.java | 10 ++++++
|
|
2 files changed, 46 insertions(+)
|
|
create mode 100644 src/main/java/net/pl3x/purpur/MoonPhase.java
|
|
|
|
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 00000000..f5ad98c6
|
|
--- /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 421ad6a9..a9a274a9 100644
|
|
--- a/src/main/java/org/bukkit/World.java
|
|
+++ b/src/main/java/org/bukkit/World.java
|
|
@@ -3244,6 +3244,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.
|
|
*
|
|
--
|
|
2.24.0
|
|
|