mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Merge branch 'v5' into reformat
This commit is contained in:
commit
e7216d4aef
3 changed files with 66 additions and 13 deletions
|
@ -1367,8 +1367,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||
final PlotArea fromArea = fLocation.getPlotArea();
|
||||
if (fromArea != null) {
|
||||
final Plot plot = fromArea.getOwnedPlot(fLocation);
|
||||
if (plot != null && !plot.getFlag(LiquidFlowFlag.class) && event.getBlock()
|
||||
.isLiquid()) {
|
||||
if (plot != null
|
||||
&& plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.DISABLED && event
|
||||
.getBlock().isLiquid()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -1387,14 +1388,16 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (plot.getFlag(LiquidFlowFlag.class) && event.getBlock().isLiquid()) {
|
||||
if (plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.ENABLED && event
|
||||
.getBlock().isLiquid()) {
|
||||
return;
|
||||
}
|
||||
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!plot.getFlag(LiquidFlowFlag.class) && event.getBlock().isLiquid()) {
|
||||
if (plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.DISABLED && event
|
||||
.getBlock().isLiquid()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
|
||||
|
|
|
@ -147,7 +147,6 @@ public final class GlobalFlagContainer extends FlagContainer {
|
|||
this.addFlag(IceFormFlag.ICE_FORM_FALSE);
|
||||
this.addFlag(IceMeltFlag.ICE_MELT_FALSE);
|
||||
this.addFlag(KelpGrowFlag.KELP_GROW_TRUE);
|
||||
this.addFlag(LiquidFlowFlag.LIQUID_FLOW_TRUE);
|
||||
this.addFlag(RedstoneFlag.REDSTONE_TRUE);
|
||||
this.addFlag(ServerPlotFlag.SERVER_PLOT_FALSE);
|
||||
this.addFlag(MiscBreakFlag.MISC_BREAK_FALSE);
|
||||
|
@ -183,6 +182,7 @@ public final class GlobalFlagContainer extends FlagContainer {
|
|||
this.addFlag(DenyTeleportFlag.DENY_TELEPORT_FLAG_NONE);
|
||||
this.addFlag(TitlesFlag.TITLES_NONE);
|
||||
this.addFlag(FlyFlag.FLIGHT_FLAG_DEFAULT);
|
||||
this.addFlag(LiquidFlowFlag.LIQUID_FLOW_DEFAULT);
|
||||
|
||||
// Integer flags
|
||||
this.addFlag(AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
|
||||
|
|
|
@ -26,20 +26,70 @@
|
|||
package com.plotsquared.core.plot.flag.implementations;
|
||||
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.plot.flag.types.BooleanFlag;
|
||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LiquidFlowFlag extends BooleanFlag<LiquidFlowFlag> {
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public static final LiquidFlowFlag LIQUID_FLOW_TRUE = new LiquidFlowFlag(true);
|
||||
public static final LiquidFlowFlag LIQUID_FLOW_FALSE = new LiquidFlowFlag(false);
|
||||
public class LiquidFlowFlag extends PlotFlag<LiquidFlowFlag.FlowStatus, LiquidFlowFlag> {
|
||||
|
||||
private LiquidFlowFlag(boolean value) {
|
||||
super(value, Captions.FLAG_DESCRIPTION_LIQUID_FLOW);
|
||||
public static final LiquidFlowFlag LIQUID_FLOW_ENABLED = new LiquidFlowFlag(FlowStatus.ENABLED);
|
||||
public static final LiquidFlowFlag LIQUID_FLOW_DISABLED =
|
||||
new LiquidFlowFlag(FlowStatus.DISABLED);
|
||||
public static final LiquidFlowFlag LIQUID_FLOW_DEFAULT = new LiquidFlowFlag(FlowStatus.DEFAULT);
|
||||
|
||||
private LiquidFlowFlag(FlowStatus value) {
|
||||
super(value, Captions.FLAG_CATEGORY_BOOLEAN, Captions.FLAG_DESCRIPTION_LIQUID_FLOW);
|
||||
}
|
||||
|
||||
@Override protected LiquidFlowFlag flagOf(@NotNull Boolean value) {
|
||||
return value ? LIQUID_FLOW_TRUE : LIQUID_FLOW_FALSE;
|
||||
@Override public LiquidFlowFlag parse(@NotNull final String input) {
|
||||
switch (input.toLowerCase()) {
|
||||
case "true":
|
||||
case "enabled":
|
||||
case "allow":
|
||||
return LIQUID_FLOW_ENABLED;
|
||||
case "false":
|
||||
case "disabled":
|
||||
case "disallow":
|
||||
return LIQUID_FLOW_DISABLED;
|
||||
default:
|
||||
return LIQUID_FLOW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public LiquidFlowFlag merge(@NotNull final FlowStatus newValue) {
|
||||
if (newValue == FlowStatus.ENABLED || this.getValue() == FlowStatus.ENABLED) {
|
||||
return LIQUID_FLOW_ENABLED;
|
||||
}
|
||||
return flagOf(newValue);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return this.getValue().name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override public String getExample() {
|
||||
return "true";
|
||||
}
|
||||
|
||||
@Override protected LiquidFlowFlag flagOf(@NotNull final FlowStatus value) {
|
||||
switch (value) {
|
||||
case ENABLED:
|
||||
return LIQUID_FLOW_ENABLED;
|
||||
case DISABLED:
|
||||
return LIQUID_FLOW_DISABLED;
|
||||
default:
|
||||
return LIQUID_FLOW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public Collection<String> getTabCompletions() {
|
||||
return Arrays.asList("true", "false", "default");
|
||||
}
|
||||
|
||||
public enum FlowStatus {
|
||||
ENABLED, DISABLED, DEFAULT
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue