mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Make LiquidFlowFlag an enum
This commit is contained in:
parent
4a16f9c1a7
commit
0751e9cea3
@ -1372,7 +1372,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
final PlotArea fromArea = fLocation.getPlotArea();
|
final PlotArea fromArea = fLocation.getPlotArea();
|
||||||
if (fromArea != null) {
|
if (fromArea != null) {
|
||||||
final Plot plot = fromArea.getOwnedPlot(fLocation);
|
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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1391,14 +1393,16 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plot.getFlag(LiquidFlowFlag.class) && event.getBlock().isLiquid()) {
|
if (plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.ENABLED && event
|
||||||
|
.getBlock().isLiquid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!plot.getFlag(LiquidFlowFlag.class) && event.getBlock().isLiquid()) {
|
if (plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.DISABLED && event
|
||||||
|
.getBlock().isLiquid()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
|
} 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(IceFormFlag.ICE_FORM_FALSE);
|
||||||
this.addFlag(IceMeltFlag.ICE_MELT_FALSE);
|
this.addFlag(IceMeltFlag.ICE_MELT_FALSE);
|
||||||
this.addFlag(KelpGrowFlag.KELP_GROW_TRUE);
|
this.addFlag(KelpGrowFlag.KELP_GROW_TRUE);
|
||||||
this.addFlag(LiquidFlowFlag.LIQUID_FLOW_TRUE);
|
|
||||||
this.addFlag(RedstoneFlag.REDSTONE_TRUE);
|
this.addFlag(RedstoneFlag.REDSTONE_TRUE);
|
||||||
this.addFlag(ServerPlotFlag.SERVER_PLOT_FALSE);
|
this.addFlag(ServerPlotFlag.SERVER_PLOT_FALSE);
|
||||||
this.addFlag(MiscBreakFlag.MISC_BREAK_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(DenyTeleportFlag.DENY_TELEPORT_FLAG_NONE);
|
||||||
this.addFlag(TitlesFlag.TITLES_NONE);
|
this.addFlag(TitlesFlag.TITLES_NONE);
|
||||||
this.addFlag(FlyFlag.FLIGHT_FLAG_DEFAULT);
|
this.addFlag(FlyFlag.FLIGHT_FLAG_DEFAULT);
|
||||||
|
this.addFlag(LiquidFlowFlag.LIQUID_FLOW_DEFAULT);
|
||||||
|
|
||||||
// Integer flags
|
// Integer flags
|
||||||
this.addFlag(AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
|
this.addFlag(AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
|
||||||
|
@ -26,20 +26,70 @@
|
|||||||
package com.plotsquared.core.plot.flag.implementations;
|
package com.plotsquared.core.plot.flag.implementations;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
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;
|
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 class LiquidFlowFlag extends PlotFlag<LiquidFlowFlag.FlowStatus, LiquidFlowFlag> {
|
||||||
public static final LiquidFlowFlag LIQUID_FLOW_FALSE = new LiquidFlowFlag(false);
|
|
||||||
|
|
||||||
private LiquidFlowFlag(boolean value) {
|
public static final LiquidFlowFlag LIQUID_FLOW_ENABLED = new LiquidFlowFlag(FlowStatus.ENABLED);
|
||||||
super(value, Captions.FLAG_DESCRIPTION_LIQUID_FLOW);
|
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) {
|
@Override public LiquidFlowFlag parse(@NotNull final String input) {
|
||||||
return value ? LIQUID_FLOW_TRUE : LIQUID_FLOW_FALSE;
|
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 New Issue
Block a user