Skip to content

Commit

Permalink
Added to SpigotPlayer the ability to enable flying and to check to se…
Browse files Browse the repository at this point in the history
…e if the player is flying. This is to prepare for mine effects.
  • Loading branch information
rbluer committed Jan 19, 2022
1 parent 5e50940 commit d84b3b0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/changelog_v3.3.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d84b3b0

Please sign in to comment.