Skip to content

Commit

Permalink
Merge pull request #78 from OneLiteFeatherNET/bugfix/plotsquared-reds…
Browse files Browse the repository at this point in the history
…tone-clock-flag

Fix redstone clock flag for plotsquared
  • Loading branch information
TheMeinerLP authored Jul 4, 2024
2 parents 988d326 + 3ccb565 commit ced0049
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import net.onelitefeather.antiredstoneclockremastered.api.AbstractPlotsquaredSupport;
import org.bukkit.Bukkit;
Expand All @@ -12,19 +13,16 @@
public final class PlotSquaredModernSupport extends AbstractPlotsquaredSupport {
@Override
public void init() {
GlobalFlagContainer.getInstance().addFlag(new RedstoneClockFlag(false));
GlobalFlagContainer.getInstance().addFlag(RedstoneClockFlag.REDSTONE_CLOCK_FALSE);
}

@Override
public boolean isAllowedPlot(@NotNull Location location) {
var plotArea = PlotSquared.get().getPlotAreaManager().getPlotArea(BukkitUtil.adapt(location));
if (plotArea != null) {
var flag = plotArea.getFlagContainer().getFlag(RedstoneClockFlag.class);
if (flag != null) {
return !flag.getValue();
}
}
return false;
if (plotArea == null) return false;
Plot plot = plotArea.getPlot(BukkitUtil.adapt(location));
if (plot == null) return false;
return plot.getFlag(RedstoneClockFlag.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
import org.checkerframework.checker.nullness.qual.NonNull;

public final class RedstoneClockFlag extends BooleanFlag<RedstoneClockFlag> {

public static final RedstoneClockFlag REDSTONE_CLOCK_TRUE = new RedstoneClockFlag(true);
public static final RedstoneClockFlag REDSTONE_CLOCK_FALSE = new RedstoneClockFlag(false);

protected RedstoneClockFlag(boolean value) {
super(value, StaticCaption.of("Set to `false` to disable RedstoneClock in the plot."));
}

@Override
protected RedstoneClockFlag flagOf(@NonNull Boolean value) {
return new RedstoneClockFlag(value);
return value ? REDSTONE_CLOCK_TRUE : REDSTONE_CLOCK_FALSE;
}
}

0 comments on commit ced0049

Please sign in to comment.