Port reserved flags

This commit is contained in:
Alexander Söderberg 2020-02-16 17:40:42 +01:00
parent 4dce805978
commit 49344da749
21 changed files with 143 additions and 52 deletions

View File

@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.bukkit.listeners;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
@ -118,7 +118,7 @@ public class EntitySpawnListener implements Listener {
}
return;
}
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
event.setCancelled(true);
}
switch (entity.getType()) {

View File

@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ExplosionFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UntrustedVisitFlag;
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
@ -1106,7 +1107,7 @@ import java.util.regex.Pattern;
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER);
@ -1806,7 +1807,7 @@ import java.util.regex.Pattern;
e.setCancelled(true);
}
} else {
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
e.setCancelled(true);
@ -2272,7 +2273,7 @@ import java.util.regex.Pattern;
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER);
@ -2334,7 +2335,7 @@ import java.util.regex.Pattern;
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER);
@ -2731,7 +2732,7 @@ import java.util.regex.Pattern;
if (victim instanceof Hanging) { // hanging
if (plot != null && (plot.getFlag(Flags.HANGING_BREAK, false) || plot
.isAdded(plotPlayer.getUUID()))) {
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
return false;
@ -2899,7 +2900,7 @@ import java.util.regex.Pattern;
event.setCancelled(true);
return;
}
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER);

View File

@ -4,8 +4,8 @@ import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
@ -36,7 +36,7 @@ import java.util.concurrent.CompletableFuture;
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_CLEAR),
Captions.NO_PLOT_PERMS);
checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER);
checkTrue(!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot) || Permissions
checkTrue(!Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot) || Permissions
.hasPermission(player, Captions.PERMISSION_CONTINUE), Captions.DONE_ALREADY_DONE);
confirm.run(this, () -> {
final long start = System.currentTimeMillis();
@ -45,11 +45,11 @@ import java.util.concurrent.CompletableFuture;
GlobalBlockQueue.IMP.addEmptyTask(() -> {
plot.removeRunning();
// If the state changes, then mark it as no longer done
if (plot.getFlag(Flags.DONE).isPresent()) {
FlagManager.removePlotFlag(plot, Flags.DONE);
if (DoneFlag.isDone(plot)) {
plot.removeFlag(DoneFlag.class);
}
if (plot.getFlag(Flags.ANALYSIS).isPresent()) {
FlagManager.removePlotFlag(plot, Flags.ANALYSIS);
if (!plot.getFlag(AnalysisFlag.class).isEmpty()) {
plot.removeFlag(AnalysisFlag.class);
}
MainUtil.sendMessage(player, Captions.CLEARING_DONE,
"" + (System.currentTimeMillis() - start));

View File

@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@ -24,7 +24,7 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
return false;
}
if (!plot.hasFlag(Flags.DONE)) {
if (!DoneFlag.isDone(plot)) {
MainUtil.sendMessage(player, Captions.DONE_NOT_DONE);
return false;
}
@ -39,7 +39,7 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
return false;
}
plot.removeFlag(Flags.DONE);
plot.removeFlag(DoneFlag.class);
MainUtil.sendMessage(player, Captions.DONE_REMOVED);
return true;
}

View File

@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
@ -29,7 +29,7 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
return false;
}
if (plot.hasFlag(Flags.DONE)) {
if (DoneFlag.isDone(plot)) {
MainUtil.sendMessage(player, Captions.DONE_ALREADY_DONE);
return false;
}
@ -59,7 +59,7 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
private void finish(Plot plot, PlotPlayer pp, boolean success) {
if (success) {
long flagValue = System.currentTimeMillis() / 1000;
plot.setFlag(Flags.DONE, flagValue);
plot.setFlag(DoneFlag.class, Long.toString(flagValue));
MainUtil.sendMessage(pp, Captions.DONE_SUCCESS);
} else {
MainUtil.sendMessage(pp, Captions.DONE_INSUFFICIENT_COMPLEXITY);

View File

@ -4,7 +4,7 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
@ -35,7 +35,7 @@ import java.net.URL;
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
return false;
}
if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!plot.getFlag(Flags.DONE).isPresent()))
if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!DoneFlag.isDone(plot)))
&& !Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) {
MainUtil.sendMessage(player, Captions.DONE_NOT_DONE);
return false;

View File

@ -41,7 +41,7 @@ import java.util.UUID;
return v2 > v1 ? 1 : -1;
});
for (final Plot plot : plots) {
if ((!Settings.Done.REQUIRED_FOR_RATINGS || plot.hasFlag(Flags.DONE))
if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(plot))
&& plot.isBasePlot() && (!plot.getLikes().containsKey(uuid))) {
plot.teleportPlayer(player, TeleportCause.COMMAND);
MainUtil.sendMessage(player, Captions.RATE_THIS);
@ -78,7 +78,7 @@ import java.util.UUID;
sendMessage(player, Captions.RATING_NOT_YOUR_OWN);
return false;
}
if (Settings.Done.REQUIRED_FOR_RATINGS && !plot.hasFlag(Flags.DONE)) {
if (Settings.Done.REQUIRED_FOR_RATINGS && !DoneFlag.isDone(plot)) {
sendMessage(player, Captions.RATING_NOT_DONE);
return false;
}

View File

@ -5,6 +5,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.PlotSquared.SortType;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
@ -186,14 +187,13 @@ public class ListCmd extends SubCommand {
}
plots = new ArrayList<>();
for (Plot plot : PlotSquared.get().getPlots()) {
Optional<String> flag = plot.getFlag(Flags.DONE);
if (flag.isPresent()) {
if (DoneFlag.isDone(plot)) {
plots.add(plot);
}
}
plots.sort((a, b) -> {
String va = "" + a.getFlags().get(Flags.DONE);
String vb = "" + b.getFlags().get(Flags.DONE);
String va = a.getFlag(DoneFlag.class);
String vb = b.getFlag(DoneFlag.class);
if (MathMan.isInteger(va)) {
if (MathMan.isInteger(vb)) {
return Integer.parseInt(vb) - Integer.parseInt(va);

View File

@ -6,7 +6,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
import com.github.intellectualsites.plotsquared.plot.object.PlotItemStack;
@ -53,7 +53,7 @@ import java.util.UUID;
});
UUID uuid = player.getUUID();
for (Plot p : plots) {
if ((!Settings.Done.REQUIRED_FOR_RATINGS || p.hasFlag(Flags.DONE)) && p
if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(p)) && p
.isBasePlot() && (!p.getRatings().containsKey(uuid)) && !p
.isAdded(uuid)) {
p.teleportPlayer(player, TeleportCause.COMMAND);
@ -91,7 +91,7 @@ import java.util.UUID;
sendMessage(player, Captions.RATING_NOT_YOUR_OWN);
return false;
}
if (Settings.Done.REQUIRED_FOR_RATINGS && !plot.hasFlag(Flags.DONE)) {
if (Settings.Done.REQUIRED_FOR_RATINGS && !DoneFlag.isDone(plot)) {
sendMessage(player, Captions.RATING_NOT_DONE);
return false;
}

View File

@ -6,13 +6,10 @@ import com.github.intellectualsites.plotsquared.plot.util.MathMan;
public final class Flags {
public static final IntegerListFlag ANALYSIS =
(IntegerListFlag) new IntegerListFlag("analysis").reserve();
public static final IntervalFlag FEED = new IntervalFlag("feed");
public static final IntervalFlag HEAL = new IntervalFlag("heal");
public static final GameModeFlag GAMEMODE = new GameModeFlag("gamemode");
public static final GameModeFlag GUEST_GAMEMODE = new GameModeFlag("guest-gamemode");
public static final StringFlag DONE = (StringFlag) new StringFlag("done").reserve();
public static final BooleanFlag REDSTONE = new BooleanFlag("redstone");
public static final BooleanFlag NOTIFY_LEAVE = new BooleanFlag("notify-leave");
public static final BooleanFlag TITLES = new BooleanFlag("titles");

View File

@ -1,7 +1,9 @@
package com.github.intellectualsites.plotsquared.plot.flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyExitFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
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.FlightFlag;
@ -12,6 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Untru
import lombok.Getter;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@ -37,6 +40,9 @@ public final class GlobalFlagContainer extends FlagContainer {
this.addFlag(GreetingFlag.GREETING_FLAG_EMPTY);
this.addFlag(FarewellFlag.FAREWELL_FLAG_EMPTY);
this.addFlag(PlotWeatherFlag.PLOT_WEATHER_FLAG_OFF);
// Internal flags
this.addFlag(new AnalysisFlag(Collections.emptyList()));
this.addFlag(new DoneFlag(""));
}
@Override public PlotFlag<?, ?> getFlagErased(Class<?> flagClass) {

View File

@ -0,0 +1,35 @@
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
import com.github.intellectualsites.plotsquared.plot.flags.InternalFlag;
import com.github.intellectualsites.plotsquared.plot.flags.types.ListFlag;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class AnalysisFlag extends ListFlag<Integer, AnalysisFlag> implements InternalFlag {
public AnalysisFlag(final List<Integer> valueList) {
super(valueList, Captions.NONE, Captions.NONE);
}
@Override public AnalysisFlag parse(@NotNull String input) throws FlagParseException {
final String[] split = input.split(",");
final List<Integer> numbers = new ArrayList<>();
for (final String element : split) {
numbers.add(Integer.parseInt(element));
}
return flagOf(numbers);
}
@Override public String getExample() {
return "";
}
@Override protected AnalysisFlag flagOf(@NotNull List<Integer> value) {
return new AnalysisFlag(value);
}
}

View File

@ -0,0 +1,44 @@
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.flags.InternalFlag;
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.jetbrains.annotations.NotNull;
public class DoneFlag extends PlotFlag<String, DoneFlag> implements InternalFlag {
/**
* Construct a new flag instance.
*
* @param value Flag value
*/
public DoneFlag(@NotNull String value) {
super(value, Captions.NONE, Captions.NONE);
}
@Override public DoneFlag parse(@NotNull String input) {
return flagOf(input);
}
@Override public DoneFlag merge(@NotNull String newValue) {
return flagOf(newValue);
}
@Override public String toString() {
return this.getValue();
}
@Override public String getExample() {
return "";
}
@Override protected DoneFlag flagOf(@NotNull String value) {
return new DoneFlag(value);
}
public static boolean isDone(final Plot plot) {
return !plot.getFlag(DoneFlag.class).isEmpty();
}
}

View File

@ -2,8 +2,8 @@ package com.github.intellectualsites.plotsquared.plot.generator;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
import com.github.intellectualsites.plotsquared.plot.listener.WEExtent;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
@ -281,7 +281,7 @@ public abstract class HybridUtils {
result.add(whenDone.value.data_sd);
result.add(whenDone.value.air_sd);
result.add(whenDone.value.variety_sd);
FlagManager.addPlotFlag(origin, Flags.ANALYSIS, result);
origin.setFlag(GlobalFlagContainer.getInstance().getFlag(AnalysisFlag.class), result);
TaskManager.runTask(whenDone);
return;
}

View File

@ -3,6 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.listener;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
@ -78,7 +79,7 @@ public class WEManager {
if (plot == null) {
plot = player.getMeta("WorldEditRegionPlot");
}
if (plot != null && (!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot)) && (
if (plot != null && (!Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot)) && (
(allowMember && plot.isAdded(uuid)) || (!allowMember && (plot.isOwner(uuid)) || plot
.getTrusted().contains(uuid))) && !(Flags.NO_WORLDEDIT.isTrue(plot))) {
for (CuboidRegion region : plot.getRegions()) {

View File

@ -9,6 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer;
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import com.github.intellectualsites.plotsquared.plot.generator.SquarePlotWorld;
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
@ -1089,20 +1090,24 @@ public class Plot {
* @param flag Flag to set
* @param value Flag value
*/
public <V> boolean setFlag(PlotFlag<V, ?> flag, Object value) {
public <V> boolean setFlag(PlotFlag<V, ?> flag, V value) {
if (flag == Flags.KEEP && ExpireManager.IMP != null) {
ExpireManager.IMP.updateExpired(this);
}
return FlagManager.addPlotFlag(this, flag, value);
}
public <V> boolean setFlag(Class<? extends PlotFlag<V, ?>> flag, V value) {
return this.setFlag(GlobalFlagContainer.getInstance().getFlag(flag), value);
}
/**
* Remove a flag from this plot
*
* @param flag the flag to remove
* @return success
*/
public boolean removeFlag(PlotFlag<?, ?> flag) {
public boolean removeFlag(Class<? extends PlotFlag<?, >> flag) {
return FlagManager.removePlotFlag(this, flag);
}

View File

@ -533,7 +533,7 @@ public abstract class PlotArea {
public int getPlotCount(@NotNull final UUID uuid) {
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
return (int) getPlotsAbs(uuid).stream().filter(plot -> !plot.hasFlag(Flags.DONE))
return (int) getPlotsAbs(uuid).stream().filter(plot -> !DoneFlag.isDone(plot))
.count();
}
return getPlotsAbs(uuid).size();

View File

@ -7,6 +7,7 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
@ -224,7 +225,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
PlotSquared.get().forEachPlotArea(value -> {
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
for (Plot plot : value.getPlotsAbs(uuid)) {
if (!plot.hasFlag(Flags.DONE)) {
if (!DoneFlag.isDone(plot)) {
count.incrementAndGet();
}
}
@ -262,7 +263,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
for (PlotArea area : PlotSquared.get().getPlotAreas(world)) {
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
count += area.getPlotsAbs(uuid).stream()
.filter(plot -> !plot.getFlag(Flags.DONE).isPresent()).count();
.filter(plot -> !DoneFlag.isDone(plot)).count();
} else {
count += area.getPlotsAbs(uuid).size();
}

View File

@ -3,6 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.util;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flag.IntegerFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import lombok.NonNull;
import lombok.experimental.UtilityClass;
@ -38,7 +39,7 @@ import lombok.experimental.UtilityClass;
}
public static boolean checkEntity(Plot plot, IntegerFlag... flags) {
if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(plot)) {
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
return true;
}
int[] mobs = null;

View File

@ -6,6 +6,8 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
@ -306,8 +308,8 @@ public class ExpireManager {
confirmation);
}
}, () -> {
FlagManager
.addPlotFlag(newPlot, Flags.ANALYSIS, changed.asList());
newPlot.setFlag(
GlobalFlagContainer.getInstance().getFlag(AnalysisFlag.class), changed.asList());
TaskManager.runTaskLaterAsync(task, 20);
});
}

View File

@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.util.expiry;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
public class PlotAnalysis {
@ -33,10 +32,9 @@ public class PlotAnalysis {
private int complexity;
public static PlotAnalysis getAnalysis(Plot plot, Settings.Auto_Clear settings) {
Optional<List<Integer>> flag = plot.getFlag(Flags.ANALYSIS);
if (flag.isPresent()) {
final List<Integer> values = plot.getFlag(AnalysisFlag.class);
if (!values.isEmpty()) {
PlotAnalysis analysis = new PlotAnalysis();
List<Integer> values = flag.get();
analysis.changes = values.get(0); // 2126
analysis.faces = values.get(1); // 90
analysis.data = values.get(2); // 0