From d84b3b0c01679dcc97ee617391bf4076f74358e4 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 19 Jan 2022 00:33:22 -0500 Subject: [PATCH] Added to SpigotPlayer the ability to enable flying and to check to see if the player is flying. This is to prepare for mine effects. --- docs/changelog_v3.3.x.md | 2 +- .../prison/spigot/game/SpigotPlayer.java | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 7f1027a2c..2211381ec 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,7 +16,7 @@ These build logs represent the work that has been going on within prison. # 3.2.11-alpha.17 2022-01-18 - +* **Added to SpigotPlayer the ability to enable flying and to check to see if the player is flying. This is to prepare for mine effects.** * **Considering adding heads support to prison. Added a few parts, but they are not functional.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayer.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayer.java index b479d3f60..601356849 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayer.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayer.java @@ -36,6 +36,7 @@ import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.inventory.Inventory; import tech.mcprison.prison.internal.scoreboard.Scoreboard; +import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotUtil; import tech.mcprison.prison.spigot.block.SpigotBlock; @@ -634,6 +635,53 @@ public PlayerCachePlayerData getPlayerCachePlayerData() { return PlayerCache.getInstance().getOnlinePlayer( this ); } + public boolean enableFlying( Mine mine, float flightSpeed ) { + boolean enabled = false; + + if ( mine.isInMineExact( getLocation() ) ) { + // Within mine: + + // save the current mine reference in the player's object: +// this.lastEffectsMine = mine; + + if ( getWrapper() != null ) { + org.bukkit.entity.Player bukkitPlayer = getWrapper(); + + bukkitPlayer.setAllowFlight( true ); + bukkitPlayer.setFlySpeed( flightSpeed ); + enabled = true; + } + } + + return enabled; + } + +// public Mine getEffectsMine() { +// Mine effectsMine = null; +// +// if ( lastEffectsMine != null ) { +// +// if ( !lastEffectsMine.isInMineExact( getLocation() ) ) { +// lastEffectsMine = null; +// +// // cancel all effects for player +// } +// effectsMine = lastEffectsMine; +// } +// return effectsMine; +// } + + public boolean isFlying() { + boolean flying = false; + + if ( getWrapper() != null ) { + org.bukkit.entity.Player bukkitPlayer = getWrapper(); + + flying = bukkitPlayer.isFlying(); + } + return flying; + } + @Override public boolean isSneaking() { boolean sneaking = false;