From 364c693b8c3beb7deaf0b3a1639353b3a1b2a865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Fri, 7 Feb 2020 21:24:49 +0100 Subject: [PATCH] Commit WIP flag work. --- .../bukkit/listeners/PlayerEvents.java | 9 +- Core/build.gradle | 1 + .../plotsquared/plot/flag/FlagManager.java | 3 +- .../plotsquared/plot/flag/Flags.java | 1 - .../plotsquared/plot/flags/FlagContainer.java | 65 ++++++++++++ .../plot/flags/FlagParseException.java | 33 +++++++ .../plot/flags/GlobalFlagContainer.java | 28 ++++++ .../plotsquared/plot/flags/PlotFlag.java | 78 +++++++++++++++ .../flags/implementations/ExplosionFlag.java | 6 ++ .../plot/flags/types/BooleanFlag.java | 51 ++++++++++ .../plotsquared/plot/object/Plot.java | 99 +++++++------------ .../plotsquared/plot/object/PlotArea.java | 7 ++ .../plotsquared/plot/object/PlotSettings.java | 7 +- 13 files changed, 312 insertions(+), 76 deletions(-) create mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/FlagContainer.java create mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/FlagParseException.java create mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/GlobalFlagContainer.java create mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/PlotFlag.java create mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/ExplosionFlag.java create mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/types/BooleanFlag.java diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index 69752719f..939a9b266 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -2,13 +2,13 @@ package com.github.intellectualsites.plotsquared.bukkit.listeners; import com.destroystokyo.paper.MaterialTags; import com.github.intellectualsites.plotsquared.bukkit.BukkitMain; -import com.github.intellectualsites.plotsquared.bukkit.object.BukkitBlockUtil; import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil; 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.ExplosionFlag; import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType; import com.github.intellectualsites.plotsquared.plot.listener.PlotListener; import com.github.intellectualsites.plotsquared.plot.object.Location; @@ -31,13 +31,11 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UpdateUtility; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.item.ItemType; import io.papermc.lib.PaperLib; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.FluidCollisionMode; import org.bukkit.Material; -import org.bukkit.Tag; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -145,7 +143,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.UUID; -import java.util.function.Supplier; import java.util.regex.Pattern; /** @@ -1146,7 +1143,7 @@ import java.util.regex.Pattern; } Plot plot = area.getOwnedPlot(location); if (plot != null) { - if (Flags.EXPLOSION.isTrue(plot)) { + if (plot.getFlag(ExplosionFlag.class)) { List meta = event.getEntity().getMetadata("plot"); Plot origin; if (meta.isEmpty()) { @@ -1858,7 +1855,7 @@ import java.util.regex.Pattern; return; } Plot plot = area.getOwnedPlot(location); - if (plot == null || !plot.getFlag(Flags.EXPLOSION).orElse(false)) { + if (plot == null || !plot.getFlag(ExplosionFlag.class)) { event.setCancelled(true); } event.blockList().removeIf( diff --git a/Core/build.gradle b/Core/build.gradle index 4d57e4c86..9b60114d8 100644 --- a/Core/build.gradle +++ b/Core/build.gradle @@ -18,6 +18,7 @@ dependencies { implementation("com.squareup.okhttp3:okhttp:4.2.2") implementation("com.squareup.okio:okio:2.4.1") implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.61") + implementation("org.jetbrains:annotations:18.0.0") } sourceCompatibility = 1.8 diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/FlagManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/FlagManager.java index 51391f788..8c566742f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/FlagManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/FlagManager.java @@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.flag; import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.database.DBFunc; +import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer; import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; @@ -219,7 +220,7 @@ public class FlagManager { return true; } - public static void setPlotFlags(Plot origin, HashMap, Object> flags) { + public static void setPlotFlags(Plot origin, FlagContainer flagContainer) { for (Plot plot : origin.getConnectedPlots()) { if (flags != null && !flags.isEmpty()) { plot.getFlags().clear(); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java index 6df44dca7..5ba791212 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java @@ -43,7 +43,6 @@ public final class Flags { return Captions.FLAG_ERROR_PRICE.getTranslated(); } }; - public static final BooleanFlag EXPLOSION = new BooleanFlag("explosion"); public static final BooleanFlag GRASS_GROW = new BooleanFlag("grass-grow"); public static final BooleanFlag VINE_GROW = new BooleanFlag("vine-grow"); public static final BooleanFlag MYCEL_GROW = new BooleanFlag("mycel-grow"); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/FlagContainer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/FlagContainer.java new file mode 100644 index 000000000..28d09ec73 --- /dev/null +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/FlagContainer.java @@ -0,0 +1,65 @@ +package com.github.intellectualsites.plotsquared.plot.flags; + +import com.google.common.collect.ImmutableMap; +import lombok.EqualsAndHashCode; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +@EqualsAndHashCode(of = "flagMap") public class FlagContainer { + + private final FlagContainer parentContainer; + private final Map, PlotFlag> flagMap = new HashMap<>(); + + public FlagContainer(@Nullable final FlagContainer parentContainer) { + this.parentContainer = parentContainer; + } + + public FlagContainer getParentContainer() { + return this.parentContainer; + } + + protected Map, PlotFlag> getInternalPlotFlagMap() { + return this.flagMap; + } + + public Map, PlotFlag> getFlagMap() { + return ImmutableMap., PlotFlag>builder().putAll(this.flagMap).build(); + } + + public void addFlag(final PlotFlag flag) { + this.flagMap.put(flag.getClass(), flag); + } + + public void addAll(final Collection> flags) { + for (final PlotFlag flag : flags) { + this.addFlag(flag); + } + } + + public Collection> getRecognizedPlotFlags() { + return this.getHighestClassContainer().getFlagMap().values(); + } + + public final FlagContainer getHighestClassContainer() { + if (this.getParentContainer() != null) { + return this.getParentContainer(); + } + return this; + } + + public PlotFlag getFlag(final Class> flagClass) { + final PlotFlag flag = this.flagMap.get(flagClass); + if (flag != null) { + return (PlotFlag) flag; + } else { + if (getParentContainer() != null) { + return getParentContainer().getFlag(flagClass); + } + } + return null; + } + +} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/FlagParseException.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/FlagParseException.java new file mode 100644 index 000000000..98d6ee607 --- /dev/null +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/FlagParseException.java @@ -0,0 +1,33 @@ +package com.github.intellectualsites.plotsquared.plot.flags; + +public class FlagParseException extends Exception { + + private final PlotFlag flag; + private final String value; + + public FlagParseException(final PlotFlag flag, final String value) { + super(String.format("Failed to parse flag of type '%s'. Value '%s' was not accepted.", + flag.getName(), value)); + this.flag = flag; + this.value = value; + } + + /** + * Returns the value that caused the parse exception + * + * @return Value that failed to parse + */ + public String getValue() { + return this.value; + } + + /** + * Returns the class that threw the exception + * + * @return Flag that threw the exception + */ + public PlotFlag getFlag() { + return this.flag; + } + +} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/GlobalFlagContainer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/GlobalFlagContainer.java new file mode 100644 index 000000000..8cbfa728f --- /dev/null +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/GlobalFlagContainer.java @@ -0,0 +1,28 @@ +package com.github.intellectualsites.plotsquared.plot.flags; + +import com.github.intellectualsites.plotsquared.plot.flags.implementations.ExplosionFlag; +import lombok.Getter; + +import javax.annotation.Nonnull; + +public final class GlobalFlagContainer extends FlagContainer { + + @Getter private static final GlobalFlagContainer instance = new GlobalFlagContainer(); + + @Nonnull @Override public PlotFlag getFlag(Class> flagClass) { + final PlotFlag flag = super.getFlag(flagClass); + if (flag != null) { + return (PlotFlag) flag; + } else { + throw new IllegalStateException(String.format("Unrecognized flag '%s'. All flag types" + + " must be present in the global flag container.", flagClass.getSimpleName())); + } + } + + private GlobalFlagContainer() { + super(null); + // Register all default flags here + this.addFlag(new ExplosionFlag()); + } + +} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/PlotFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/PlotFlag.java new file mode 100644 index 000000000..a07745891 --- /dev/null +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/PlotFlag.java @@ -0,0 +1,78 @@ +package com.github.intellectualsites.plotsquared.plot.flags; + +import com.google.common.base.Preconditions; +import lombok.EqualsAndHashCode; +import org.jetbrains.annotations.NotNull; + +/** + * A plot flag is any property that can be assigned + * to a plot, that will alter its functionality in some way. + * These are user assignable in-game, or via configuration files. + * + * @param Value contained in the flag. + */ +@EqualsAndHashCode(of = "value") public abstract class PlotFlag { + + private T value; + + /** + * Construct a new flag instance. + * + * @param value Flag value + */ + protected PlotFlag(@NotNull final T value) { + this.value = Preconditions.checkNotNull(value, "flag values may not be null"); + } + + /** + * Get the flag value + * + * @return Non-nullable flag value + */ + @NotNull public final T getValue() { + return this.value; + } + + /** + * Update the flag value. + * + * @param newValue New flag value. + */ + public T setFlagValue(@NotNull final T newValue) { + return (this.value = Preconditions.checkNotNull(newValue, "flag values may not be null")); + } + + /** + * Parse a string into a flag value, and throw an exception in the case that the + * string does not represent a valid flag value. The flag value will be updated to + * the newly parsed value. + * + * @param input String to parse. + * @return Parsed value, if valid. + * @throws FlagParseException If the value could not be parsed. + */ + public abstract T parse(@NotNull final String input) throws FlagParseException; + + /** + * Merge two flag values into one and updates the flag value. + * + * @param oldValue Existing flag value. + * @param newValue New flag value. + * @return Flag containing parsed flag value. + */ + public abstract T merge(@NotNull final T oldValue, @NotNull final T newValue); + + /** + * Returns a string representation of the flag instance, that when + * passed through {@link #parse(String)} will result in an equivalent + * instance of the flag. + * + * @return String representation of the flag + */ + public abstract String toString(); + + public final String getName() { + return this.getClass().getSimpleName(); + } + +} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/ExplosionFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/ExplosionFlag.java new file mode 100644 index 000000000..362cb7d65 --- /dev/null +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/ExplosionFlag.java @@ -0,0 +1,6 @@ +package com.github.intellectualsites.plotsquared.plot.flags.implementations; + +import com.github.intellectualsites.plotsquared.plot.flags.types.BooleanFlag; + +public class ExplosionFlag extends BooleanFlag { +} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/types/BooleanFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/types/BooleanFlag.java new file mode 100644 index 000000000..f92e129cf --- /dev/null +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/types/BooleanFlag.java @@ -0,0 +1,51 @@ +package com.github.intellectualsites.plotsquared.plot.flags.types; + +import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException; +import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Locale; + +public abstract class BooleanFlag extends PlotFlag { + + private static final Collection positiveValues = Arrays.asList("1", "yes", "allow", "true"); + private static final Collection negativeValues = Arrays.asList("0", "no", "deny", "disallow", "false"); + + /** + * Construct a new flag instance. + * + * @param value Flag value + */ + protected BooleanFlag(boolean value) { + super(value); + } + + /** + * Construct a new boolean flag, with + * {@code false} as the default value. + */ + protected BooleanFlag() { + this(false); + } + + @Override public Boolean parse(@NotNull String input) throws FlagParseException { + if (positiveValues.contains(input.toLowerCase(Locale.ENGLISH))) { + return this.setFlagValue(true); + } else if (negativeValues.contains(input.toLowerCase(Locale.ENGLISH))) { + return this.setFlagValue(false); + } else { + throw new FlagParseException(this, input); + } + } + + @Override public Boolean merge(@NotNull Boolean oldValue, @NotNull Boolean newValue) { + return this.setFlagValue(oldValue || newValue); + } + + @Override public String toString() { + return this.getValue().toString(); + } + +} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java index 27b16d5a3..dd1003aec 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java @@ -1,8 +1,5 @@ package com.github.intellectualsites.plotsquared.plot.object; -import static java.util.concurrent.TimeUnit.SECONDS; - - import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Configuration; @@ -11,6 +8,8 @@ import com.github.intellectualsites.plotsquared.plot.database.DBFunc; 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.PlotFlag; import com.github.intellectualsites.plotsquared.plot.generator.SquarePlotWorld; import com.github.intellectualsites.plotsquared.plot.listener.PlotListener; import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment; @@ -39,7 +38,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockTypes; -import java.util.concurrent.TimeUnit; +import lombok.Getter; +import lombok.Setter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -62,6 +62,7 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -152,6 +153,11 @@ public class Plot { */ private Plot origin; + /** + * Plot flag container + */ + @Getter private FlagContainer flagContainer; + /** * Constructor for a new plot. * (Only changes after plot.create() will be properly set in the database) @@ -162,9 +168,7 @@ public class Plot { * @see Plot#getPlot(Location) for existing plots */ public Plot(PlotArea area, @NotNull PlotId id, UUID owner) { - this.area = area; - this.id = id; - this.owner = owner; + this(area, id, owner, 0); } /** @@ -176,8 +180,7 @@ public class Plot { * @see Plot#getPlot(Location) for existing plots */ public Plot(PlotArea area, @NotNull PlotId id) { - this.area = area; - this.id = id; + this(area, id, null, 0); } /** @@ -196,6 +199,7 @@ public class Plot { this.id = id; this.owner = owner; this.temp = temp; + this.flagContainer = new FlagContainer(area.getFlagContainer()); } /** @@ -209,7 +213,7 @@ public class Plot { * @see Plot#getPlot(Location) for existing plots */ public Plot(@NotNull PlotId id, UUID owner, HashSet trusted, HashSet members, - HashSet denied, String alias, BlockLoc position, Collection flags, + HashSet denied, String alias, BlockLoc position, Collection> flags, PlotArea area, boolean[] merged, long timestamp, int temp) { this.id = id; this.area = area; @@ -221,13 +225,14 @@ public class Plot { this.settings.setAlias(alias); this.settings.setPosition(position); this.settings.setMerged(merged); - if (flags != null) { - for (Flag flag : flags) { - this.settings.flags.put(flag, flag); - } - } this.timestamp = timestamp; this.temp = temp; + this.flagContainer = new FlagContainer(area.getFlagContainer()); + if (flags != null) { + for (PlotFlag flag : flags) { + this.flagContainer.addFlag(flag); + } + } } /** @@ -1101,30 +1106,6 @@ public class Plot { return FlagManager.removePlotFlag(this, flag); } - /** - * Gets the flag for a given key - * - * @param key Flag to get value for - */ - public Optional getFlag(Flag key) { - return FlagManager.getPlotFlag(this, key); - } - - /** - * Gets the flag for a given key - * - * @param key the flag - * @param defaultValue if the key is null, the value to return - */ - public V getFlag(Flag key, V defaultValue) { - V value = FlagManager.getPlotFlagRaw(this, key); - if (value == null) { - return defaultValue; - } else { - return value; - } - } - /** * Delete a plot (use null for the runnable if you don't need to be notified on completion) * @@ -2015,16 +1996,6 @@ public class Plot { return this.id.hashCode(); } - /** - * Gets the flags specific to this plot
- * - Does not take default flags into account
- * - * @return - */ - public HashMap, Object> getFlags() { - return this.getSettings().flags; - } - /** * Sets a flag for this plot. * @@ -2034,6 +2005,10 @@ public class Plot { FlagManager.setPlotFlags(this, flags); } + public void setFlagContainer(final FlagContainer flagContainer) { + this.flagContainer = flagContainer; + } + /** * Gets the plot alias. * - Returns an empty string if no alias is set @@ -2374,18 +2349,17 @@ public class Plot { * @param plot */ public void mergeData(Plot plot) { - HashMap, Object> flags1 = this.getFlags(); - HashMap, Object> flags2 = plot.getFlags(); - if ((!flags1.isEmpty() || !flags2.isEmpty()) && !flags1.equals(flags2)) { - boolean greater = flags1.size() > flags2.size(); + final FlagContainer flagContainer1 = this.getFlagContainer(); + final FlagContainer flagContainer2 = plot.getFlagContainer(); + if (!flagContainer1.equals(flagContainer2)) { + boolean greater = flagContainer1.getFlagMap().size() > flagContainer2.getFlagMap().size(); if (greater) { - flags1.putAll(flags2); + flagContainer1.addAll(flagContainer2.getFlagMap().values()); } else { - flags2.putAll(flags1); + flagContainer2.addAll(flagContainer1.getFlagMap().values()); } - HashMap, Object> net = (greater ? flags1 : flags2); - this.setFlags(net); - plot.setFlags(net); + this.setFlagContainer(greater ? flagContainer1 : flagContainer2); + plot.setFlagContainer(this.getFlagContainer()); } if (!this.getAlias().isEmpty()) { plot.setAlias(this.getAlias()); @@ -3150,10 +3124,6 @@ public class Plot { return true; } - public boolean hasFlag(Flag flag) { - return getFlags().containsKey(flag); - } - public boolean removeComment(PlotComment comment) { return getSettings().removeComment(comment); } @@ -3177,4 +3147,9 @@ public class Plot { public boolean getMerged(Direction direction) { return getMerged(direction.getIndex()); } + + public T getFlag(final Class> flagClass) { + return this.flagContainer.getFlag(flagClass).getValue(); + } + } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java index d0cf46d70..d96c71c7f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java @@ -8,6 +8,8 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings; 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.generator.GridPlotWorld; import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator; import com.github.intellectualsites.plotsquared.plot.util.EconHandler; @@ -28,6 +30,7 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameModes; +import lombok.Getter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -88,6 +91,10 @@ public abstract class PlotArea { private CuboidRegion region; private ConcurrentHashMap meta; private QuadMap clusters; + /** + * Area flag container + */ + @Getter private FlagContainer flagContainer = new FlagContainer(GlobalFlagContainer.getInstance()); public PlotArea(@NotNull final String worldName, @Nullable final String id, @NotNull IndependentPlotGenerator generator, @Nullable final PlotId min, diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotSettings.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotSettings.java index 8d7904690..36e140d42 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotSettings.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotSettings.java @@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.object; import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flag.Flags; +import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer; import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment; import com.google.common.collect.ImmutableList; @@ -37,12 +38,6 @@ public class PlotSettings { * @deprecated Raw access */ @Deprecated public HashMap ratings; - /** - * Flags. - * - * @deprecated Raw access - */ - @Deprecated public HashMap, Object> flags = new HashMap<>(); private List comments = null; /** * Home Position.