mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Merge branch 'features/v5/internal-updates' into features/v5/async-load
This commit is contained in:
commit
bc45b8b695
@ -1439,6 +1439,18 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onChange(BlockFromToEvent event) {
|
||||
Block from = event.getBlock();
|
||||
|
||||
// Check liquid flow flag inside of origin plot too
|
||||
final Location fLocation = BukkitUtil.getLocation(from.getLocation());
|
||||
final PlotArea fromArea = fLocation.getPlotArea();
|
||||
if (fromArea != null) {
|
||||
final Plot plot = fromArea.getOwnedPlot(fLocation);
|
||||
if (plot != null && !plot.getFlag(LiquidFlowFlag.class) && event.getBlock().isLiquid()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Block to = event.getToBlock();
|
||||
Location tLocation = BukkitUtil.getLocation(to.getLocation());
|
||||
PlotArea area = tLocation.getPlotArea();
|
||||
@ -1446,7 +1458,6 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(tLocation);
|
||||
Location fLocation = BukkitUtil.getLocation(from.getLocation());
|
||||
if (plot != null) {
|
||||
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
@ -1456,12 +1467,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!plot.getFlag(LiquidFlowFlag.class)) {
|
||||
switch (to.getType()) {
|
||||
case WATER:
|
||||
case LAVA:
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (!plot.getFlag(LiquidFlowFlag.class) && event.getBlock().isLiquid()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
|
||||
.equals(null, area.getOwnedPlot(fLocation))) {
|
||||
@ -2215,7 +2222,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Plot plot = area.getOwnedPlotAbs(location1);
|
||||
Plot plot = area.getOwnedPlot(location1);
|
||||
if (player != null) {
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
if (plot == null) {
|
||||
|
@ -143,11 +143,15 @@ public class Visit extends Command {
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
} else {
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_OTHER) && !plot
|
||||
.getFlag(UntrustedVisitFlag.class)) {
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_OTHER)) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_VISIT_OTHER);
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
if (!plot.getFlag(UntrustedVisitFlag.class) &&
|
||||
!Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_VISIT_UNTRUSTED)) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_ADMIN_VISIT_UNTRUSTED);
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
}
|
||||
confirm.run(this, () ->
|
||||
plot.teleportPlayer(player, TeleportCause.COMMAND, result -> {
|
||||
|
@ -53,6 +53,7 @@ public enum Captions implements Caption {
|
||||
PERMISSION_ADMIN_UPDATE_NOTIFICATION("plots.admin.update.notify", "static.permissions"),
|
||||
PERMISSION_ADMIN_EXIT_DENIED("plots.admin.exit.denied", "static.permissions"),
|
||||
PERMISSION_ADMIN_ENTRY_DENIED("plots.admin.entry.denied", "static.permissions"),
|
||||
PERMISSION_ADMIN_VISIT_UNTRUSTED("plots.admin.visit.untrusted", "static.permissions"),
|
||||
PERMISSION_ADMIN_ENTRY_FORCEFIELD("plots.admin.entry.forcefield", "static.permissions"),
|
||||
PERMISSION_COMMANDS_CHAT("plots.admin.command.chat", "static.permissions"),
|
||||
PERMISSION_MERGE_OTHER("plots.merge.other", "static.permissions"),
|
||||
@ -567,13 +568,15 @@ public enum Captions implements Caption {
|
||||
FLAG_CATEGORY_ENUM("Generic Enum Flags", "Flags"),
|
||||
FLAG_CATEGORY_DECIMAL("Decimal Flags", "Flags"),
|
||||
FLAG_CATEGORY_BOOLEAN("Boolean Flags", "Flags"),
|
||||
FLAG_CATEGORY_FLY("Flight Flags", "Flags"),
|
||||
FLAG_CATEGORY_MIXED("Mixed Value Flags", "Flags"),
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="Flag descriptions">
|
||||
FLAG_DESCRIPTION_ENTITY_CAP("Set to an integer value to limit the amount of entities on the plot.", "Flags"),
|
||||
FLAG_DESCRIPTION_EXPLOSION("Set to `true` to enable explosions in the plot, and `false` to disable them.", "Flags"),
|
||||
FLAG_DESCRIPTION_MUSIC("Set to a music disk ID (item name) to play the music disc inside of the plot.", "Flags"),
|
||||
FLAG_DESCRIPTION_FLIGHT("Set to `true` to enable flight within the plot when in survival or adventure mode.", "Flags"),
|
||||
FLAG_DESCRIPTION_FLIGHT("Set to `true` to enable flight within the plot when in survival or adventure mode,"
|
||||
+ " set to `default` to use the gamemode default, and `false` to disable flight entirely.", "Flags"),
|
||||
FLAG_DESCRIPTION_UNTRUSTED("Set to `false` to disallow untrusted players from visiting the plot.", "Flags"),
|
||||
FLAG_DESCRIPTION_DENY_EXIT("Set to `true` to disallow players from exiting the plot.", "Flags"),
|
||||
FLAG_DESCRIPTION_DESCRIPTION("Plot description. Supports '&' color codes.", "Flags"),
|
||||
|
@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Block
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockIgnitionFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockedCmdsFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BreakFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.CoralDryFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyExitFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyTeleportFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag;
|
||||
@ -19,7 +20,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Entit
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ExplosionFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FarewellFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FeedFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FlightFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FlyFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ForcefieldFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.GamemodeFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.GrassGrowFlag;
|
||||
@ -60,7 +61,6 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Serve
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.SnowFormFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.SnowMeltFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.SoilDryFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.CoralDryFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedAttackFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedInteractFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TimeFlag;
|
||||
@ -96,7 +96,6 @@ public final class GlobalFlagContainer extends FlagContainer {
|
||||
// Register all default flags here
|
||||
// Boolean flags
|
||||
this.addFlag(ExplosionFlag.EXPLOSION_FALSE);
|
||||
this.addFlag(FlightFlag.FLIGHT_FLAG_FALSE);
|
||||
this.addFlag(UntrustedVisitFlag.UNTRUSTED_VISIT_FLAG_TRUE);
|
||||
this.addFlag(DenyExitFlag.DENY_EXIT_FLAG_FALSE);
|
||||
this.addFlag(DescriptionFlag.DESCRIPTION_FLAG_EMPTY);
|
||||
@ -150,6 +149,7 @@ public final class GlobalFlagContainer extends FlagContainer {
|
||||
this.addFlag(WeatherFlag.PLOT_WEATHER_FLAG_OFF);
|
||||
this.addFlag(DenyTeleportFlag.DENY_TELEPORT_FLAG_NONE);
|
||||
this.addFlag(TitlesFlag.TITLES_NONE);
|
||||
this.addFlag(FlyFlag.FLIGHT_FLAG_DEFAULT);
|
||||
|
||||
// Integer flags
|
||||
this.addFlag(AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
|
||||
|
@ -1,19 +0,0 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.types.BooleanFlag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FlightFlag extends BooleanFlag<FlightFlag> {
|
||||
|
||||
public static final FlightFlag FLIGHT_FLAG_FALSE = new FlightFlag(false);
|
||||
|
||||
protected FlightFlag(final boolean value) {
|
||||
super(value, Captions.FLAG_DESCRIPTION_FLIGHT);
|
||||
}
|
||||
|
||||
@Override protected FlightFlag flagOf(@NotNull Boolean value) {
|
||||
return new FlightFlag(value);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public class FlyFlag extends PlotFlag<FlyFlag.FlyStatus, FlyFlag> {
|
||||
|
||||
public static final FlyFlag FLIGHT_FLAG_DISABLED = new FlyFlag(FlyStatus.DISABLED);
|
||||
public static final FlyFlag FLIGHT_FLAG_ENABLED = new FlyFlag(FlyStatus.ENABLED);
|
||||
public static final FlyFlag FLIGHT_FLAG_DEFAULT = new FlyFlag(FlyStatus.DEFAULT);
|
||||
|
||||
protected FlyFlag(final FlyStatus value) {
|
||||
super(value, Captions.FLAG_CATEGORY_BOOLEAN, Captions.FLAG_DESCRIPTION_FLIGHT);
|
||||
}
|
||||
|
||||
@Override public FlyFlag parse(@NotNull final String input) {
|
||||
switch (input.toLowerCase()) {
|
||||
case "true":
|
||||
case "enabled":
|
||||
case "allow":
|
||||
return FLIGHT_FLAG_ENABLED;
|
||||
case "false":
|
||||
case "disabled":
|
||||
case "disallow":
|
||||
return FLIGHT_FLAG_DISABLED;
|
||||
default:
|
||||
return FLIGHT_FLAG_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public FlyFlag merge(@NotNull final FlyStatus newValue) {
|
||||
if (newValue == FlyStatus.ENABLED || this.getValue() == FlyStatus.ENABLED) {
|
||||
return FLIGHT_FLAG_ENABLED;
|
||||
}
|
||||
return flagOf(newValue);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return this.getValue().name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override public String getExample() {
|
||||
return "true";
|
||||
}
|
||||
|
||||
@Override protected FlyFlag flagOf(@NotNull final FlyStatus value) {
|
||||
switch (value) {
|
||||
case ENABLED:
|
||||
return FLIGHT_FLAG_ENABLED;
|
||||
case DISABLED:
|
||||
return FLIGHT_FLAG_DISABLED;
|
||||
default:
|
||||
return FLIGHT_FLAG_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public Collection<String> getTabCompletions() {
|
||||
return Arrays.asList("true", "false", "default");
|
||||
}
|
||||
|
||||
public enum FlyStatus {
|
||||
ENABLED,
|
||||
DISABLED,
|
||||
DEFAULT
|
||||
}
|
||||
|
||||
}
|
@ -124,7 +124,8 @@ public class PlotListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (plot.getFlag(FlightFlag.class)) {
|
||||
final FlyFlag.FlyStatus flyStatus = plot.getFlag(FlyFlag.class);
|
||||
if (flyStatus != FlyFlag.FlyStatus.DEFAULT) {
|
||||
boolean flight = player.getFlight();
|
||||
GameMode gamemode = player.getGameMode();
|
||||
if (flight != (gamemode == GameModes.CREATIVE
|
||||
@ -132,7 +133,7 @@ public class PlotListener {
|
||||
player.setPersistentMeta("flight",
|
||||
ByteArrayUtilities.booleanToBytes(player.getFlight()));
|
||||
}
|
||||
player.setFlight(true);
|
||||
player.setFlight(flyStatus == FlyFlag.FlyStatus.ENABLED);
|
||||
}
|
||||
|
||||
final GameMode gameMode = plot.getFlag(GamemodeFlag.class);
|
||||
@ -299,7 +300,8 @@ public class PlotListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (plot.getFlag(FlightFlag.class)) {
|
||||
final FlyFlag.FlyStatus flyStatus = plot.getFlag(FlyFlag.class);
|
||||
if (flyStatus != FlyFlag.FlyStatus.DEFAULT) {
|
||||
if (player.hasPersistentMeta("flight")) {
|
||||
player.setFlight(
|
||||
ByteArrayUtilities.bytesToBoolean(player.getPersistentMeta("flight")));
|
||||
|
Loading…
Reference in New Issue
Block a user