mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fixes #1171
This commit is contained in:
parent
ae5e15e434
commit
5b103d49c0
@ -172,7 +172,12 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
public void setFlight(boolean fly) {
|
||||
this.player.setAllowFlight(fly);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getFlight() {
|
||||
return player.getAllowFlight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMusic(Location location, int id) {
|
||||
//noinspection deprecation
|
||||
|
@ -112,7 +112,12 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
|
||||
@Override
|
||||
public void setFlight(boolean fly) {}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getFlight() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMusic(Location location, int id) {}
|
||||
|
||||
|
@ -324,6 +324,8 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
||||
*/
|
||||
public abstract void setFlight(boolean fly);
|
||||
|
||||
public abstract boolean getFlight();
|
||||
|
||||
/**
|
||||
* Play music at a location for the player.
|
||||
* @param location where to play the music
|
||||
|
@ -15,4 +15,11 @@ public class ByteArrayUtilities {
|
||||
return (bytes[0]<<24)&0xff000000|(bytes[1]<<16)&0x00ff0000|(bytes[2]<<8)&0x0000ff00|(bytes[3])&0x000000ff;
|
||||
}
|
||||
|
||||
public static boolean bytesToBoolean(byte[] bytes) {
|
||||
return bytes[0] == 1;
|
||||
}
|
||||
|
||||
public static byte[] booleanToBytes(boolean b) {
|
||||
return new byte[] {(byte)(b ? 1 : 0)};
|
||||
}
|
||||
}
|
||||
|
@ -11,16 +11,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.CommentManager;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.PlotGameMode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -94,7 +85,10 @@ public class PlotListener {
|
||||
}
|
||||
Optional<Boolean> flyFlag = plot.getFlag(Flags.FLY);
|
||||
if (flyFlag.isPresent()) {
|
||||
player.setFlight(flyFlag.get());
|
||||
if (flyFlag.get() != player.getFlight()) {
|
||||
player.setPersistentMeta("flight", ByteArrayUtilities.booleanToBytes(player.getFlight()));
|
||||
player.setFlight(flyFlag.get());
|
||||
}
|
||||
}
|
||||
Optional<Long> timeFlag = plot.getFlag(Flags.TIME);
|
||||
if (timeFlag.isPresent()) {
|
||||
@ -204,9 +198,13 @@ public class PlotListener {
|
||||
}
|
||||
}
|
||||
if (plot.getFlag(Flags.FLY).isPresent()) {
|
||||
PlotGameMode gamemode = player.getGameMode();
|
||||
if (gamemode == PlotGameMode.SURVIVAL || (gamemode == PlotGameMode.ADVENTURE)) {
|
||||
player.setFlight(false);
|
||||
if (player.hasPersistentMeta("flight")) {
|
||||
player.setFlight(ByteArrayUtilities.bytesToBoolean(player.getPersistentMeta("flight")));
|
||||
} else {
|
||||
PlotGameMode gameMode = player.getGameMode();
|
||||
if (gameMode == PlotGameMode.SURVIVAL || gameMode == PlotGameMode.ADVENTURE) {
|
||||
player.setFlight(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plot.getFlag(Flags.TIME).isPresent()) {
|
||||
|
@ -167,7 +167,13 @@ public class SpongePlayer extends PlotPlayer {
|
||||
this.player.offer(Keys.IS_FLYING, fly);
|
||||
this.player.offer(Keys.CAN_FLY, fly);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getFlight() {
|
||||
Optional<Boolean> flying = player.get(Keys.CAN_FLY);
|
||||
return flying.isPresent() && flying.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMusic(Location location, int id) {
|
||||
switch (id) {
|
||||
|
Loading…
Reference in New Issue
Block a user