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: b75eeca0 Boost light task priority to ensure it doesnt hold up chunk loads 3d2bc848 Ensure VillagerTrades doesn't load async - fixes #3495 e470f1ef Add more information to Timing Reports f4a47db6 Improve Thread Pool usage to allow single threads for single cpu servers a4fe910f Fix sounds when using worldedit regen command 70ad51a8 Updated Upstream (Bukkit/CraftBukkit) d7cfa4fa Improve legacy format serialization more
129 lines
3.2 KiB
Diff
129 lines
3.2 KiB
Diff
From e4b28b6ed7d3e1f7f32f0397abb1068483715cc0 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Fri, 12 Jul 2019 02:09:58 -0500
|
|
Subject: [PATCH] Implement ChunkTooLargeEvent
|
|
|
|
---
|
|
.../pl3x/purpur/event/ChunkTooLargeEvent.java | 109 ++++++++++++++++++
|
|
1 file changed, 109 insertions(+)
|
|
create mode 100644 src/main/java/net/pl3x/purpur/event/ChunkTooLargeEvent.java
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/event/ChunkTooLargeEvent.java b/src/main/java/net/pl3x/purpur/event/ChunkTooLargeEvent.java
|
|
new file mode 100644
|
|
index 000000000..f9d4a42c6
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/pl3x/purpur/event/ChunkTooLargeEvent.java
|
|
@@ -0,0 +1,109 @@
|
|
+package net.pl3x.purpur.event;
|
|
+
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.World;
|
|
+import org.bukkit.event.Event;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+import org.jetbrains.annotations.Nullable;
|
|
+
|
|
+/**
|
|
+ * Called when an oversized chunk loads or saves
|
|
+ */
|
|
+public class ChunkTooLargeEvent extends Event {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private final String worldName;
|
|
+ private final World world;
|
|
+ private final int chunkX;
|
|
+ private final int chunkZ;
|
|
+ private final boolean saving;
|
|
+ private final boolean overzealous;
|
|
+
|
|
+ public ChunkTooLargeEvent(@NotNull String worldName, int chunkX, int chunkZ, boolean saving, boolean overzealous) {
|
|
+ super(!Bukkit.isPrimaryThread());
|
|
+ this.worldName = worldName;
|
|
+ this.world = Bukkit.getWorld(worldName);
|
|
+ this.chunkX = chunkX;
|
|
+ this.chunkZ = chunkZ;
|
|
+ this.saving = saving;
|
|
+ this.overzealous = overzealous;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get the world name according to the save directory
|
|
+ *
|
|
+ * @return World name
|
|
+ */
|
|
+ @NotNull
|
|
+ public String getWorldName() {
|
|
+ return worldName;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get the world
|
|
+ *
|
|
+ * @return World, or null if world not loaded
|
|
+ */
|
|
+ @Nullable
|
|
+ public World getWorld() {
|
|
+ return world;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get the X chunk coordinate
|
|
+ *
|
|
+ * @return X chunk coordinate
|
|
+ */
|
|
+ public int getChunkX() {
|
|
+ return chunkX;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get the Z chunk coordinate
|
|
+ *
|
|
+ * @return Z chunk coordinate
|
|
+ */
|
|
+ public int getChunkZ() {
|
|
+ return chunkZ;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Whether this happened during a save attempt.
|
|
+ *
|
|
+ * @return True if saving, false if loading
|
|
+ */
|
|
+ public boolean isSaving() {
|
|
+ return saving;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * If saving, was this is overzealous mode
|
|
+ *
|
|
+ * @return True if saving in overzealous mode
|
|
+ */
|
|
+ public boolean isOverzealous() {
|
|
+ return overzealous;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get the location
|
|
+ *
|
|
+ * @return Location, or null if world not loaded
|
|
+ */
|
|
+ @Nullable
|
|
+ public Location getLocation() {
|
|
+ return world == null ? null : new Location(world, chunkX << 4, 128, chunkZ << 4);
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
--
|
|
2.24.0
|
|
|