mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Replace ByteArrayUtilities code with Guava and Replace PlotGameMode with WorldEdit equivalent.
This commit is contained in:
parent
006d730185
commit
4bb45fc220
@ -7,7 +7,6 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
@ -32,6 +31,11 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.sk89q.worldedit.world.gamemode.GameModes.ADVENTURE;
|
||||||
|
import static com.sk89q.worldedit.world.gamemode.GameModes.CREATIVE;
|
||||||
|
import static com.sk89q.worldedit.world.gamemode.GameModes.SPECTATOR;
|
||||||
|
import static com.sk89q.worldedit.world.gamemode.GameModes.SURVIVAL;
|
||||||
|
|
||||||
public class BukkitPlayer extends PlotPlayer {
|
public class BukkitPlayer extends PlotPlayer {
|
||||||
|
|
||||||
private static boolean CHECK_EFFECTIVE = true;
|
private static boolean CHECK_EFFECTIVE = true;
|
||||||
@ -234,36 +238,29 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull @Override public PlotGameMode getGameMode() {
|
@NotNull @Override public com.sk89q.worldedit.world.gamemode.GameMode getGameMode() {
|
||||||
switch (this.player.getGameMode()) {
|
switch (this.player.getGameMode()) {
|
||||||
case ADVENTURE:
|
case ADVENTURE:
|
||||||
return PlotGameMode.ADVENTURE;
|
return ADVENTURE;
|
||||||
case CREATIVE:
|
case CREATIVE:
|
||||||
return PlotGameMode.CREATIVE;
|
return CREATIVE;
|
||||||
case SPECTATOR:
|
case SPECTATOR:
|
||||||
return PlotGameMode.SPECTATOR;
|
return SPECTATOR;
|
||||||
case SURVIVAL:
|
case SURVIVAL:
|
||||||
return PlotGameMode.SURVIVAL;
|
|
||||||
default:
|
default:
|
||||||
return PlotGameMode.NOT_SET;
|
return SURVIVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void setGameMode(@NotNull final PlotGameMode gameMode) {
|
@Override public void setGameMode(@NotNull final com.sk89q.worldedit.world.gamemode.GameMode gameMode) {
|
||||||
switch (gameMode) {
|
if (ADVENTURE.equals(gameMode)) {
|
||||||
case ADVENTURE:
|
|
||||||
this.player.setGameMode(GameMode.ADVENTURE);
|
this.player.setGameMode(GameMode.ADVENTURE);
|
||||||
break;
|
} else if (CREATIVE.equals(gameMode)) {
|
||||||
case CREATIVE:
|
|
||||||
this.player.setGameMode(GameMode.CREATIVE);
|
this.player.setGameMode(GameMode.CREATIVE);
|
||||||
break;
|
} else if (SPECTATOR.equals(gameMode)) {
|
||||||
case SPECTATOR:
|
|
||||||
this.player.setGameMode(GameMode.SPECTATOR);
|
this.player.setGameMode(GameMode.SPECTATOR);
|
||||||
break;
|
} else {
|
||||||
case SURVIVAL:
|
|
||||||
default:
|
|
||||||
this.player.setGameMode(GameMode.SURVIVAL);
|
this.player.setGameMode(GameMode.SURVIVAL);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +300,7 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void stopSpectating() {
|
@Override public void stopSpectating() {
|
||||||
if (getGameMode() == PlotGameMode.SPECTATOR) {
|
if (getGameMode() == SPECTATOR) {
|
||||||
this.player.setSpectatorTarget(null);
|
this.player.setSpectatorTarget(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,11 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ByteArrayUtilities;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
|
import com.google.common.primitives.Ints;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -47,8 +47,7 @@ public class Auto extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
|
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
|
||||||
return false;
|
return false;
|
||||||
} else if (player.hasPersistentMeta("grantedPlots")) {
|
} else if (player.hasPersistentMeta("grantedPlots")) {
|
||||||
int grantedPlots =
|
int grantedPlots = Ints.fromByteArray(player.getPersistentMeta("grantedPlots"));
|
||||||
ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
|
|
||||||
if (grantedPlots - diff < sizeX * sizeZ) {
|
if (grantedPlots - diff < sizeX * sizeZ) {
|
||||||
player.removePersistentMeta("grantedPlots");
|
player.removePersistentMeta("grantedPlots");
|
||||||
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
|
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
|
||||||
@ -58,8 +57,7 @@ public class Auto extends SubCommand {
|
|||||||
if (left == 0) {
|
if (left == 0) {
|
||||||
player.removePersistentMeta("grantedPlots");
|
player.removePersistentMeta("grantedPlots");
|
||||||
} else {
|
} else {
|
||||||
player.setPersistentMeta("grantedPlots",
|
player.setPersistentMeta("grantedPlots", Ints.toByteArray(left));
|
||||||
ByteArrayUtilities.integerToBytes(left));
|
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "" + left,
|
MainUtil.sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "" + left,
|
||||||
"" + (grantedPlots - left));
|
"" + (grantedPlots - left));
|
||||||
|
@ -15,6 +15,7 @@ import com.github.intellectualsites.plotsquared.plot.util.ByteArrayUtilities;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
|
import com.google.common.primitives.Ints;
|
||||||
|
|
||||||
@CommandDeclaration(command = "claim", aliases = "c",
|
@CommandDeclaration(command = "claim", aliases = "c",
|
||||||
description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING,
|
description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING,
|
||||||
@ -38,7 +39,7 @@ public class Claim extends SubCommand {
|
|||||||
if (currentPlots >= player.getAllowedPlots()) {
|
if (currentPlots >= player.getAllowedPlots()) {
|
||||||
if (player.hasPersistentMeta("grantedPlots")) {
|
if (player.hasPersistentMeta("grantedPlots")) {
|
||||||
grants =
|
grants =
|
||||||
ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
|
Ints.fromByteArray(player.getPersistentMeta("grantedPlots"));
|
||||||
if (grants <= 0) {
|
if (grants <= 0) {
|
||||||
player.removePersistentMeta("grantedPlots");
|
player.removePersistentMeta("grantedPlots");
|
||||||
return sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
|
return sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
|
||||||
@ -85,7 +86,7 @@ public class Claim extends SubCommand {
|
|||||||
player.removePersistentMeta("grantedPlots");
|
player.removePersistentMeta("grantedPlots");
|
||||||
} else {
|
} else {
|
||||||
player.setPersistentMeta("grantedPlots",
|
player.setPersistentMeta("grantedPlots",
|
||||||
ByteArrayUtilities.integerToBytes(grants - 1));
|
Ints.toByteArray(grants - 1));
|
||||||
}
|
}
|
||||||
sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
|
sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -94,7 +94,7 @@ import java.util.UUID;
|
|||||||
if (player.hasPermission("plots.admin.entry.denied")) {
|
if (player.hasPermission("plots.admin.entry.denied")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (player.getGameMode() == PlotGameMode.SPECTATOR) {
|
if (player.getGameMode() == GameModes.SPECTATOR) {
|
||||||
player.stopSpectating();
|
player.stopSpectating();
|
||||||
}
|
}
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
|
@ -8,10 +8,10 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.ByteArrayUtilities;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
|
import com.google.common.primitives.Ints;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@ -56,7 +56,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
if (array == null) {
|
if (array == null) {
|
||||||
granted = 0;
|
granted = 0;
|
||||||
} else {
|
} else {
|
||||||
granted = ByteArrayUtilities.bytesToInteger(array);
|
granted = Ints.fromByteArray(array);
|
||||||
}
|
}
|
||||||
Captions.GRANTED_PLOTS.send(player, granted);
|
Captions.GRANTED_PLOTS.send(player, granted);
|
||||||
} else { // add
|
} else { // add
|
||||||
@ -64,11 +64,11 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
if (array == null) {
|
if (array == null) {
|
||||||
amount = 1;
|
amount = 1;
|
||||||
} else {
|
} else {
|
||||||
amount = 1 + ByteArrayUtilities.bytesToInteger(array);
|
amount = 1 + Ints.fromByteArray(array);
|
||||||
}
|
}
|
||||||
boolean replace = array != null;
|
boolean replace = array != null;
|
||||||
String key = "grantedPlots";
|
String key = "grantedPlots";
|
||||||
byte[] rawData = ByteArrayUtilities.integerToBytes(amount);
|
byte[] rawData = Ints.toByteArray(amount);
|
||||||
PlotPlayer online = UUIDHandler.getPlayer(uuid);
|
PlotPlayer online = UUIDHandler.getPlayer(uuid);
|
||||||
if (online != null) {
|
if (online != null) {
|
||||||
online.setPersistentMeta(key, rawData);
|
online.setPersistentMeta(key, rawData);
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
|
|
||||||
public class GameModeFlag extends Flag<PlotGameMode> {
|
public class GameModeFlag extends Flag<GameMode> {
|
||||||
|
|
||||||
public GameModeFlag(String name) {
|
public GameModeFlag(String name) {
|
||||||
super(Captions.FLAG_CATEGORY_GAMEMODE, name);
|
super(Captions.FLAG_CATEGORY_GAMEMODE, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String valueToString(Object value) {
|
@Override public String valueToString(Object value) {
|
||||||
return ((PlotGameMode) value).getName();
|
return ((GameMode) value).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PlotGameMode parseValue(String value) {
|
@Override public GameMode parseValue(String value) {
|
||||||
switch (value.toLowerCase()) {
|
switch (value.toLowerCase()) {
|
||||||
case "survival":
|
|
||||||
case "s":
|
|
||||||
case "0":
|
|
||||||
return PlotGameMode.SURVIVAL;
|
|
||||||
case "creative":
|
case "creative":
|
||||||
case "c":
|
case "c":
|
||||||
case "1":
|
case "1":
|
||||||
return PlotGameMode.CREATIVE;
|
return GameModes.CREATIVE;
|
||||||
case "adventure":
|
case "adventure":
|
||||||
case "a":
|
case "a":
|
||||||
case "2":
|
case "2":
|
||||||
return PlotGameMode.ADVENTURE;
|
return GameModes.ADVENTURE;
|
||||||
case "spectator":
|
case "spectator":
|
||||||
case "sp":
|
case "sp":
|
||||||
case "3":
|
case "3":
|
||||||
return PlotGameMode.SPECTATOR;
|
return GameModes.SPECTATOR;
|
||||||
|
case "survival":
|
||||||
|
case "s":
|
||||||
|
case "0":
|
||||||
default:
|
default:
|
||||||
return PlotGameMode.NOT_SET;
|
return GameModes.SURVIVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,13 +15,14 @@ import com.github.intellectualsites.plotsquared.plot.util.CommentManager;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.ItemUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.world.ItemUtil;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
|
|
||||||
@ -95,9 +96,9 @@ public class PlotListener {
|
|||||||
Optional<Boolean> flyFlag = plot.getFlag(Flags.FLY);
|
Optional<Boolean> flyFlag = plot.getFlag(Flags.FLY);
|
||||||
if (flyFlag.isPresent()) {
|
if (flyFlag.isPresent()) {
|
||||||
boolean flight = player.getFlight();
|
boolean flight = player.getFlight();
|
||||||
PlotGameMode gamemode = player.getGameMode();
|
GameMode gamemode = player.getGameMode();
|
||||||
if (flight != (gamemode == PlotGameMode.CREATIVE
|
if (flight != (gamemode == GameModes.CREATIVE
|
||||||
|| gamemode == PlotGameMode.SPECTATOR)) {
|
|| gamemode == GameModes.SPECTATOR)) {
|
||||||
player.setPersistentMeta("flight",
|
player.setPersistentMeta("flight",
|
||||||
ByteArrayUtilities.booleanToBytes(player.getFlight()));
|
ByteArrayUtilities.booleanToBytes(player.getFlight()));
|
||||||
}
|
}
|
||||||
@ -105,7 +106,7 @@ public class PlotListener {
|
|||||||
player.setFlight(flyFlag.get());
|
player.setFlight(flyFlag.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Optional<PlotGameMode> gamemodeFlag = plot.getFlag(Flags.GAMEMODE);
|
Optional<GameMode> gamemodeFlag = plot.getFlag(Flags.GAMEMODE);
|
||||||
if (gamemodeFlag.isPresent()) {
|
if (gamemodeFlag.isPresent()) {
|
||||||
if (player.getGameMode() != gamemodeFlag.get()) {
|
if (player.getGameMode() != gamemodeFlag.get()) {
|
||||||
if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) {
|
if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) {
|
||||||
@ -118,7 +119,7 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Optional<PlotGameMode> guestGamemodeFlag = plot.getFlag(Flags.GUEST_GAMEMODE);
|
Optional<GameMode> guestGamemodeFlag = plot.getFlag(Flags.GUEST_GAMEMODE);
|
||||||
if (guestGamemodeFlag.isPresent()) {
|
if (guestGamemodeFlag.isPresent()) {
|
||||||
if (player.getGameMode() != guestGamemodeFlag.get() && !plot
|
if (player.getGameMode() != guestGamemodeFlag.get() && !plot
|
||||||
.isAdded(player.getUUID())) {
|
.isAdded(player.getUUID())) {
|
||||||
@ -227,7 +228,7 @@ public class PlotListener {
|
|||||||
} else {
|
} else {
|
||||||
MainUtil.sendMessage(player, StringMan
|
MainUtil.sendMessage(player, StringMan
|
||||||
.replaceAll(Captions.GAMEMODE_WAS_BYPASSED.getTranslated(), "{plot}",
|
.replaceAll(Captions.GAMEMODE_WAS_BYPASSED.getTranslated(), "{plot}",
|
||||||
plot.toString(), "{gamemode}", pw.GAMEMODE.name().toLowerCase()));
|
plot.toString(), "{gamemode}", pw.GAMEMODE.getName().toLowerCase()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,8 +259,8 @@ public class PlotListener {
|
|||||||
ByteArrayUtilities.bytesToBoolean(player.getPersistentMeta("flight")));
|
ByteArrayUtilities.bytesToBoolean(player.getPersistentMeta("flight")));
|
||||||
player.removePersistentMeta("flight");
|
player.removePersistentMeta("flight");
|
||||||
} else {
|
} else {
|
||||||
PlotGameMode gameMode = player.getGameMode();
|
GameMode gameMode = player.getGameMode();
|
||||||
if (gameMode == PlotGameMode.SURVIVAL || gameMode == PlotGameMode.ADVENTURE) {
|
if (gameMode == GameModes.SURVIVAL || gameMode == GameModes.ADVENTURE) {
|
||||||
player.setFlight(false);
|
player.setFlight(false);
|
||||||
} else if (!player.getFlight()) {
|
} else if (!player.getFlight()) {
|
||||||
player.setFlight(true);
|
player.setFlight(true);
|
||||||
|
@ -3,10 +3,11 @@ package com.github.intellectualsites.plotsquared.plot.object;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
|
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -110,11 +111,11 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
@Override public void setWeather(@NotNull PlotWeather weather) {
|
@Override public void setWeather(@NotNull PlotWeather weather) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull @Override public PlotGameMode getGameMode() {
|
@Override public @NotNull GameMode getGameMode() {
|
||||||
return PlotGameMode.NOT_SET;
|
return GameModes.SPECTATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void setGameMode(@NotNull PlotGameMode gameMode) {
|
@Override public void setGameMode(@NotNull GameMode gameMode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void setTime(long time) {
|
@Override public void setTime(long time) {
|
||||||
|
@ -14,7 +14,6 @@ import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap;
|
import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||||
@ -27,6 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ public abstract class PlotArea {
|
|||||||
public PlotLoc DEFAULT_HOME;
|
public PlotLoc DEFAULT_HOME;
|
||||||
public int MAX_BUILD_HEIGHT = 256;
|
public int MAX_BUILD_HEIGHT = 256;
|
||||||
public int MIN_BUILD_HEIGHT = 1;
|
public int MIN_BUILD_HEIGHT = 1;
|
||||||
public PlotGameMode GAMEMODE = PlotGameMode.CREATIVE;
|
public GameMode GAMEMODE = GameModes.CREATIVE;
|
||||||
private int hash;
|
private int hash;
|
||||||
private CuboidRegion region;
|
private CuboidRegion region;
|
||||||
private ConcurrentHashMap<String, Object> meta;
|
private ConcurrentHashMap<String, Object> meta;
|
||||||
@ -248,27 +249,25 @@ public abstract class PlotArea {
|
|||||||
this.MIN_BUILD_HEIGHT = config.getInt("world.min_height");
|
this.MIN_BUILD_HEIGHT = config.getInt("world.min_height");
|
||||||
|
|
||||||
switch (config.getString("world.gamemode").toLowerCase()) {
|
switch (config.getString("world.gamemode").toLowerCase()) {
|
||||||
case "survival":
|
|
||||||
case "s":
|
|
||||||
case "0":
|
|
||||||
this.GAMEMODE = PlotGameMode.SURVIVAL;
|
|
||||||
break;
|
|
||||||
case "creative":
|
case "creative":
|
||||||
case "c":
|
case "c":
|
||||||
case "1":
|
case "1":
|
||||||
this.GAMEMODE = PlotGameMode.CREATIVE;
|
this.GAMEMODE = GameModes.CREATIVE;
|
||||||
break;
|
break;
|
||||||
case "adventure":
|
case "adventure":
|
||||||
case "a":
|
case "a":
|
||||||
case "2":
|
case "2":
|
||||||
this.GAMEMODE = PlotGameMode.ADVENTURE;
|
this.GAMEMODE = GameModes.ADVENTURE;
|
||||||
break;
|
break;
|
||||||
case "spectator":
|
case "spectator":
|
||||||
case "3":
|
case "3":
|
||||||
this.GAMEMODE = PlotGameMode.SPECTATOR;
|
this.GAMEMODE = GameModes.SPECTATOR;
|
||||||
break;
|
break;
|
||||||
|
case "survival":
|
||||||
|
case "s":
|
||||||
|
case "0":
|
||||||
default:
|
default:
|
||||||
this.GAMEMODE = PlotGameMode.NOT_SET;
|
this.GAMEMODE = GameModes.SURVIVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +362,7 @@ public abstract class PlotArea {
|
|||||||
options.put("home.nonmembers", position);
|
options.put("home.nonmembers", position);
|
||||||
options.put("world.max_height", this.MAX_BUILD_HEIGHT);
|
options.put("world.max_height", this.MAX_BUILD_HEIGHT);
|
||||||
options.put("world.min_height", this.MIN_BUILD_HEIGHT);
|
options.put("world.min_height", this.MIN_BUILD_HEIGHT);
|
||||||
options.put("world.gamemode", this.GAMEMODE.name().toLowerCase());
|
options.put("world.gamemode", this.GAMEMODE.getName().toLowerCase());
|
||||||
|
|
||||||
if (this.TYPE != 0) {
|
if (this.TYPE != 0) {
|
||||||
options.put("generator.terrain", this.TERRAIN);
|
options.put("generator.terrain", this.TERRAIN);
|
||||||
|
@ -13,13 +13,13 @@ import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAre
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -438,14 +438,14 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
*
|
*
|
||||||
* @return the gamemode of the player.
|
* @return the gamemode of the player.
|
||||||
*/
|
*/
|
||||||
@NotNull public abstract PlotGameMode getGameMode();
|
public abstract @NotNull GameMode getGameMode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set this player's gameMode.
|
* Set this player's gameMode.
|
||||||
*
|
*
|
||||||
* @param gameMode the gamemode to set
|
* @param gameMode the gamemode to set
|
||||||
*/
|
*/
|
||||||
public abstract void setGameMode(@NotNull PlotGameMode gameMode);
|
public abstract void setGameMode(@NotNull GameMode gameMode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set this player's local time (ticks).
|
* Set this player's local time (ticks).
|
||||||
|
@ -1,21 +1,9 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.util;
|
package com.github.intellectualsites.plotsquared.plot.util;
|
||||||
|
|
||||||
|
import com.google.common.primitives.Ints;
|
||||||
|
|
||||||
public class ByteArrayUtilities {
|
public class ByteArrayUtilities {
|
||||||
|
|
||||||
public static byte[] integerToBytes(int i) {
|
|
||||||
byte[] bytes = new byte[4];
|
|
||||||
bytes[0] = (byte) (i >> 24);
|
|
||||||
bytes[1] = (byte) (i >> 16);
|
|
||||||
bytes[2] = (byte) (i >> 8);
|
|
||||||
bytes[3] = (byte) (i);
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int bytesToInteger(byte[] bytes) {
|
|
||||||
return (bytes[0] << 24) & 0xff000000 | (bytes[1] << 16) & 0x00ff0000
|
|
||||||
| (bytes[2] << 8) & 0x0000ff00 | (bytes[3]) & 0x000000ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean bytesToBoolean(byte[] bytes) {
|
public static boolean bytesToBoolean(byte[] bytes) {
|
||||||
return bytes[0] == 1;
|
return bytes[0] == 1;
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.util;
|
|
||||||
|
|
||||||
public enum PlotGameMode {
|
|
||||||
NOT_SET(-1, ""), SURVIVAL(0, "survival"), CREATIVE(1, "creative"), ADVENTURE(2,
|
|
||||||
"adventure"), SPECTATOR(3, "spectator");
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
PlotGameMode(int id, String name) {
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The magic-value id of the GameMode.
|
|
||||||
*
|
|
||||||
* @return the GameMode id
|
|
||||||
*/
|
|
||||||
public int getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the name of this GameMode
|
|
||||||
*
|
|
||||||
* @return the GameMode name
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user