From 4dd946fba31e496de417d8d7db39e3869f5ee70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Tue, 18 Feb 2020 16:19:08 +0100 Subject: [PATCH] Fix a bunch of compile errors --- .../intellectualsites/plotsquared/api/PlotAPI.java | 10 ---------- .../plotsquared/plot/commands/Desc.java | 7 ++++--- .../plotsquared/plot/commands/Info.java | 2 +- .../plotsquared/plot/commands/ListCmd.java | 9 +-------- .../plotsquared/plot/commands/MainCommand.java | 2 -- .../plotsquared/plot/database/AbstractDB.java | 5 +++-- .../plotsquared/plot/database/SQLManager.java | 6 +++--- .../plotsquared/plot/flags/FlagContainer.java | 2 +- .../plotsquared/plot/generator/HybridUtils.java | 3 +-- .../plotsquared/plot/object/Plot.java | 6 +++--- .../plotsquared/plot/object/worlds/SinglePlot.java | 4 ++-- .../plotsquared/plot/object/worlds/SinglePlotArea.java | 6 +++++- .../plotsquared/plot/util/expiry/ExpireManager.java | 2 +- 13 files changed, 25 insertions(+), 39 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/api/PlotAPI.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/api/PlotAPI.java index 9d9676c4b..7e7b4dc73 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/api/PlotAPI.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/api/PlotAPI.java @@ -4,7 +4,6 @@ import com.github.intellectualsites.plotsquared.configuration.file.YamlConfigura import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.config.Caption; import com.github.intellectualsites.plotsquared.plot.config.Captions; -import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; @@ -168,15 +167,6 @@ import java.util.UUID; sendConsoleMessage(caption.getTranslated()); } - /** - * Registers a flag for use in plots. - * - * @param flag the flag to register - */ - public void addFlag(Flag flag) { - Flags.registerFlag(flag); - } - /** * Gets the PlotSquared class. * diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Desc.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Desc.java index 8e812fd6f..bb9b544de 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Desc.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Desc.java @@ -2,7 +2,8 @@ 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.flag.FlagManager; +import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer; +import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag; import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.util.MainUtil; @@ -14,11 +15,11 @@ public class Desc extends SetCommand { @Override public boolean set(PlotPlayer player, Plot plot, String desc) { if (desc.isEmpty()) { - plot.removeFlag(Flags.DESCRIPTION); + plot.removeFlag(DescriptionFlag.class); MainUtil.sendMessage(player, Captions.DESC_UNSET); return true; } - boolean result = FlagManager.addPlotFlag(plot, Flags.DESCRIPTION, desc); + boolean result = plot.setFlag(GlobalFlagContainer.getInstance().getFlag(DescriptionFlag.class).createFlagInstance(desc)); if (!result) { MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED); return false; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java index e45faff75..f957f0bbc 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java @@ -115,7 +115,7 @@ public class Info extends SubCommand { "&cAmount: &6" + plot.getDenied().size(), "&8Click to view a list of denied players")); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cFlags", "&cFlags", - "&cAmount: &6" + plot.getFlags().size(), "&8Click to view a list of plot flags")); + "&cAmount: &6" + plot.getFlagContainer().getFlagMap().size(), "&8Click to view a list of plot flags")); inv.openInventory(); return true; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java index a04a7c4a2..8cc0c722b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java @@ -378,18 +378,11 @@ public class ListCmd extends SubCommand { Captions.PLOT_INFO_MEMBERS.getTranslated() .replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers())))) .color("$1"); - String strFlags = StringMan.join(plot.getFlags().values(), ","); - if (strFlags.isEmpty()) { - strFlags = Captions.NONE.getTranslated(); - } - PlotMessage flags = new PlotMessage().text(Captions.color( - Captions.PLOT_INFO_FLAGS.getTranslated().replaceAll("%flags%", strFlags))) - .color("$1"); message.text("[").color("$3").text(i + "") .command("/plot visit " + plot.getArea() + ";" + plot.getId()) .tooltip("/plot visit " + plot.getArea() + ";" + plot.getId()).color("$1") .text("]").color("$3").text(" " + plot.toString()) - .tooltip(trusted, members, flags) + .tooltip(trusted, members) .command("/plot info " + plot.getArea() + ";" + plot.getId()).color(color) .text(" - ").color("$2"); String prefix = ""; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java index c754ed78a..4189d1a66 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java @@ -85,10 +85,8 @@ import java.util.concurrent.CompletableFuture; new DebugRoadRegen(); new Trust(); new DebugExec(); - // new FlagCmd(); new FlagCommand(); new Target(); - new DebugFixFlags(); new Move(); new Condense(); new Copy(); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java index e20d54caa..41d2eabf1 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java @@ -1,6 +1,6 @@ package com.github.intellectualsites.plotsquared.plot.database; -import com.github.intellectualsites.plotsquared.plot.flag.Flag; +import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag; import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotCluster; @@ -9,6 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment; import org.jetbrains.annotations.NotNull; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -150,7 +151,7 @@ public interface AbstractDB { * @param plot Plot Object * @param flags flags to set */ - void setFlags(Plot plot, HashMap, Object> flags); + void setFlags(Plot plot, Collection> flags); /** * Renames a cluster to the given name. diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java index cf229e316..430dd1680 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java @@ -4,8 +4,7 @@ import com.github.intellectualsites.plotsquared.configuration.ConfigurationSecti import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Storage; -import com.github.intellectualsites.plotsquared.plot.flag.Flag; -import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; +import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag; import com.github.intellectualsites.plotsquared.plot.object.BlockLoc; import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.PlotArea; @@ -30,6 +29,7 @@ import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -1991,7 +1991,7 @@ import java.util.concurrent.atomic.AtomicInteger; addPlotTask(newPlot, null); } - @Override public void setFlags(final Plot plot, HashMap, Object> flags) { + @Override public void setFlags(final Plot plot, Collection> flags) { final String flag_string = FlagManager.toString(flags); addPlotTask(plot, new UniqueStatement("setFlags") { @Override public void set(PreparedStatement statement) throws SQLException { 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 index 3773a27be..a8d930425 100644 --- 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 @@ -173,7 +173,7 @@ import java.util.Map; * @return The flag instance, if it exists in this container, else null. */ @Nullable public > T queryLocal( - final Class flagClass) { + final Class flagClass) { final PlotFlag localFlag = this.flagMap.get(flagClass); if (localFlag == null) { return null; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java index 5d80a944d..ab2ee6199 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java @@ -288,8 +288,7 @@ public abstract class HybridUtils { result.add(whenDone.value.data_sd); result.add(whenDone.value.air_sd); result.add(whenDone.value.variety_sd); - origin.setFlag(GlobalFlagContainer.getInstance().getFlag(AnalysisFlag.class), - result); + origin.setFlag(GlobalFlagContainer.getInstance().getFlag(AnalysisFlag.class).createFlagInstance(result)); TaskManager.runTask(whenDone); return; } 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 b7aa94329..2d46090d5 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 @@ -153,7 +153,7 @@ public class Plot { /** * Plot flag container */ - @Getter(AccessLevel.PROTECTED) private FlagContainer flagContainer; + @Getter private FlagContainer flagContainer; /** * Constructor for a new plot. @@ -1105,9 +1105,9 @@ public class Plot { return true; } - public boolean setFlag(Class> flag, String value) { + public boolean setFlag(Class flag, String value) { try { - this.setFlag(GlobalFlagContainer.getInstance().getFlag(flag).parse(value)); + this.setFlag(GlobalFlagContainer.getInstance().getFlagErased(flag).parse(value)); } catch (final Exception e) { return false; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java index b143b755b..c5207ca0a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java @@ -1,7 +1,7 @@ package com.github.intellectualsites.plotsquared.plot.object.worlds; import com.github.intellectualsites.plotsquared.plot.config.Captions; -import com.github.intellectualsites.plotsquared.plot.flag.Flag; +import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag; import com.github.intellectualsites.plotsquared.plot.object.BlockLoc; import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Plot; @@ -37,7 +37,7 @@ public class SinglePlot extends Plot { } public SinglePlot(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) { super(id, owner, trusted, members, denied, alias, position, flags, area, merged, timestamp, temp); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java index 85b6ac7fd..f5e620266 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java @@ -4,6 +4,7 @@ import com.github.intellectualsites.plotsquared.configuration.ConfigurationSecti import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.config.Configuration; import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode; +import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer; import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld; import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Plot; @@ -167,9 +168,12 @@ public class SinglePlotArea extends GridPlotWorld { return p; } PlotSettings s = p.getSettings(); + + final FlagContainer oldContainer = p.getFlagContainer(); p = new SinglePlot(p.getId(), p.owner, p.getTrusted(), p.getMembers(), p.getDenied(), s.alias, s.getPosition(), null, this, s.merged, p.getTimestamp(), p.temp); - p.getSettings().flags = s.flags; + p.setFlagContainer(oldContainer); + return p; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java index c5caf28c8..9861ed143 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java @@ -307,7 +307,7 @@ public class ExpireManager { } }, () -> { newPlot.setFlag(GlobalFlagContainer.getInstance() - .getFlag(AnalysisFlag.class), changed.asList()); + .getFlag(AnalysisFlag.class).createFlagInstance(changed.asList())); TaskManager.runTaskLaterAsync(task, 20); }); }