2019-06-14 04:27:40 +02:00
|
|
|
From fb78151fa68d3a9ab9cb2cf3659a02595560a03b Mon Sep 17 00:00:00 2001
|
2018-01-14 23:36:24 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sun, 14 Jan 2018 17:31:37 -0500
|
|
|
|
Subject: [PATCH] PlayerNaturallySpawnCreaturesEvent
|
|
|
|
|
|
|
|
This event can be used for when you want to exclude a certain player
|
|
|
|
from triggering monster spawns on a server.
|
|
|
|
|
|
|
|
Also a highly more effecient way to blanket block spawns in a world
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PlayerNaturallySpawnCreaturesEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PlayerNaturallySpawnCreaturesEvent.java
|
|
|
|
new file mode 100644
|
2019-06-06 17:36:57 +02:00
|
|
|
index 000000000..112a0dbf5
|
2018-01-14 23:36:24 +01:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/PlayerNaturallySpawnCreaturesEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,64 @@
|
2018-01-14 23:36:24 +01:00
|
|
|
+package com.destroystokyo.paper.event.entity;
|
|
|
|
+
|
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+import org.bukkit.event.Cancellable;
|
|
|
|
+import org.bukkit.event.Event;
|
|
|
|
+import org.bukkit.event.HandlerList;
|
|
|
|
+import org.bukkit.event.player.PlayerEvent;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2018-01-14 23:36:24 +01:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Fired when the server is calculating what chunks to try to spawn monsters in every Monster Spawn Tick event
|
|
|
|
+ */
|
|
|
|
+public class PlayerNaturallySpawnCreaturesEvent extends PlayerEvent implements Cancellable {
|
|
|
|
+ private byte radius;
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public PlayerNaturallySpawnCreaturesEvent(@NotNull Player player, byte radius) {
|
2018-01-14 23:36:24 +01:00
|
|
|
+ super(player);
|
|
|
|
+ this.radius = radius;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return The radius of chunks around this player to be included in natural spawn selection
|
|
|
|
+ */
|
|
|
|
+ public byte getSpawnRadius() {
|
|
|
|
+ return radius;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param radius The radius of chunks around this player to be included in natural spawn selection
|
|
|
|
+ */
|
|
|
|
+ public void setSpawnRadius(byte radius) {
|
|
|
|
+ this.radius = radius;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-01-14 23:36:24 +01:00
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-01-14 23:36:24 +01:00
|
|
|
+ public static HandlerList getHandlerList() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean cancelled = false;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return If this players chunks will be excluded from natural spawns
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isCancelled() {
|
|
|
|
+ return cancelled;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param cancel true if you wish to cancel this event, and not include this players chunks for natural spawning
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void setCancelled(boolean cancel) {
|
|
|
|
+ cancelled = cancel;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
--
|
2019-03-20 01:28:15 +01:00
|
|
|
2.21.0
|
2018-01-14 23:36:24 +01:00
|
|
|
|