Add Player Warden Warning API (#8470)
This commit is contained in:
parent
4a3ae59535
commit
a7df847aad
|
@ -0,0 +1,70 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: dawon <dawon@dawon.eu>
|
||||
Date: Sat, 15 Oct 2022 00:46:32 +0200
|
||||
Subject: [PATCH] Add Player Warden Warning API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index ecb8b4cf48c7d6151ffec92bc6855d1fc57a2b51..1e27b9de47f111b9c000243214e22890e323f7fc 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -2844,6 +2844,59 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
* @param silent whether sound should be silenced
|
||||
*/
|
||||
void showElderGuardian(boolean silent);
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the player's cooldown in ticks until the next Warden warning can occur.
|
||||
+ *
|
||||
+ * @return ticks until next Warden warning can occur. 0 means there is no cooldown left.
|
||||
+ */
|
||||
+ int getWardenWarningCooldown();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the player's cooldown in ticks until next Warden warning can occur.
|
||||
+ *
|
||||
+ * @param cooldown ticks until next Warden warning can occur. 0 means there is no cooldown left. Values less than 0 are set to 0.
|
||||
+ */
|
||||
+ void setWardenWarningCooldown(int cooldown);
|
||||
+
|
||||
+ /**
|
||||
+ * Returns time since last Warden warning in ticks.
|
||||
+ *
|
||||
+ * @return ticks since last Warden warning
|
||||
+ */
|
||||
+ int getWardenTimeSinceLastWarning();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets time since last Warden warning in ticks.
|
||||
+ *
|
||||
+ * @param time ticks since last Warden warning
|
||||
+ */
|
||||
+ void setWardenTimeSinceLastWarning(int time);
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the player's current Warden warning level.
|
||||
+ *
|
||||
+ * @return current Warden warning level
|
||||
+ */
|
||||
+ int getWardenWarningLevel();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the player's Warden warning level.
|
||||
+ * <p>
|
||||
+ * <b>Note:</b> This will not actually spawn the Warden.
|
||||
+ * Even if the warning level is over threshold, the player still needs to activate a Shrieker in order to summon the Warden.
|
||||
+ *
|
||||
+ * @param warningLevel player's Warden warning level. The warning level is internally limited to valid values.
|
||||
+ */
|
||||
+ void setWardenWarningLevel(int warningLevel);
|
||||
+
|
||||
+ /**
|
||||
+ * Increases the player's Warden warning level if possible and not on cooldown.
|
||||
+ * <p>
|
||||
+ * <b>Note:</b> This will not actually spawn the Warden.
|
||||
+ * Even if the warning level is over threshold, the player still needs to activate a Shrieker in order to summon the Warden.
|
||||
+ */
|
||||
+ void increaseWardenWarningLevel();
|
||||
// Paper end
|
||||
|
||||
@NotNull
|
|
@ -0,0 +1,57 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: dawon <dawon@dawon.eu>
|
||||
Date: Sat, 15 Oct 2022 00:46:57 +0200
|
||||
Subject: [PATCH] Add Player Warden Warning API
|
||||
|
||||
== AT ==
|
||||
public net.minecraft.world.entity.player.Player wardenSpawnTracker
|
||||
public net.minecraft.world.entity.monster.warden.WardenSpawnTracker ticksSinceLastWarning
|
||||
public net.minecraft.world.entity.monster.warden.WardenSpawnTracker cooldownTicks
|
||||
public net.minecraft.world.entity.monster.warden.WardenSpawnTracker increaseWarningLevel()V
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 66830ccee464083879f79db4111e08fecee417ec..a5220a4e514865c70700527bcd2f941d852564c0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2941,6 +2941,41 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void showElderGuardian(boolean silent) {
|
||||
if (getHandle().connection != null) getHandle().connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.GUARDIAN_ELDER_EFFECT, silent ? 0F : 1F));
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public int getWardenWarningCooldown() {
|
||||
+ return this.getHandle().wardenSpawnTracker.cooldownTicks;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setWardenWarningCooldown(int cooldown) {
|
||||
+ this.getHandle().wardenSpawnTracker.cooldownTicks = Math.max(cooldown, 0);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getWardenTimeSinceLastWarning() {
|
||||
+ return this.getHandle().wardenSpawnTracker.ticksSinceLastWarning;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setWardenTimeSinceLastWarning(int time) {
|
||||
+ this.getHandle().wardenSpawnTracker.ticksSinceLastWarning = time;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getWardenWarningLevel() {
|
||||
+ return this.getHandle().wardenSpawnTracker.getWarningLevel();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setWardenWarningLevel(int warningLevel) {
|
||||
+ this.getHandle().wardenSpawnTracker.setWarningLevel(warningLevel);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void increaseWardenWarningLevel() {
|
||||
+ this.getHandle().wardenSpawnTracker.increaseWarningLevel();
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
public Player.Spigot spigot()
|
Loading…
Reference in New Issue