Fix a bunch of compile errors

This commit is contained in:
Alexander Söderberg 2020-02-18 16:19:08 +01:00
parent b22482ccda
commit 4dd946fba3
13 changed files with 25 additions and 39 deletions

View File

@ -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.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Caption; import com.github.intellectualsites.plotsquared.plot.config.Caption;
import com.github.intellectualsites.plotsquared.plot.config.Captions; 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.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@ -168,15 +167,6 @@ import java.util.UUID;
sendConsoleMessage(caption.getTranslated()); 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. * Gets the PlotSquared class.
* *

View File

@ -2,7 +2,8 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions; 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.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; 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) { @Override public boolean set(PlotPlayer player, Plot plot, String desc) {
if (desc.isEmpty()) { if (desc.isEmpty()) {
plot.removeFlag(Flags.DESCRIPTION); plot.removeFlag(DescriptionFlag.class);
MainUtil.sendMessage(player, Captions.DESC_UNSET); MainUtil.sendMessage(player, Captions.DESC_UNSET);
return true; return true;
} }
boolean result = FlagManager.addPlotFlag(plot, Flags.DESCRIPTION, desc); boolean result = plot.setFlag(GlobalFlagContainer.getInstance().getFlag(DescriptionFlag.class).createFlagInstance(desc));
if (!result) { if (!result) {
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED); MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
return false; return false;

View File

@ -115,7 +115,7 @@ public class Info extends SubCommand {
"&cAmount: &6" + plot.getDenied().size(), "&cAmount: &6" + plot.getDenied().size(),
"&8Click to view a list of denied players")); "&8Click to view a list of denied players"));
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cFlags", "&cFlags", 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(); inv.openInventory();
return true; return true;
} }

View File

@ -378,18 +378,11 @@ public class ListCmd extends SubCommand {
Captions.PLOT_INFO_MEMBERS.getTranslated() Captions.PLOT_INFO_MEMBERS.getTranslated()
.replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers())))) .replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers()))))
.color("$1"); .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 + "") message.text("[").color("$3").text(i + "")
.command("/plot visit " + plot.getArea() + ";" + plot.getId()) .command("/plot visit " + plot.getArea() + ";" + plot.getId())
.tooltip("/plot visit " + plot.getArea() + ";" + plot.getId()).color("$1") .tooltip("/plot visit " + plot.getArea() + ";" + plot.getId()).color("$1")
.text("]").color("$3").text(" " + plot.toString()) .text("]").color("$3").text(" " + plot.toString())
.tooltip(trusted, members, flags) .tooltip(trusted, members)
.command("/plot info " + plot.getArea() + ";" + plot.getId()).color(color) .command("/plot info " + plot.getArea() + ";" + plot.getId()).color(color)
.text(" - ").color("$2"); .text(" - ").color("$2");
String prefix = ""; String prefix = "";

View File

@ -85,10 +85,8 @@ import java.util.concurrent.CompletableFuture;
new DebugRoadRegen(); new DebugRoadRegen();
new Trust(); new Trust();
new DebugExec(); new DebugExec();
// new FlagCmd();
new FlagCommand(); new FlagCommand();
new Target(); new Target();
new DebugFixFlags();
new Move(); new Move();
new Condense(); new Condense();
new Copy(); new Copy();

View File

@ -1,6 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.database; 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.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotCluster; 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 com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -150,7 +151,7 @@ public interface AbstractDB {
* @param plot Plot Object * @param plot Plot Object
* @param flags flags to set * @param flags flags to set
*/ */
void setFlags(Plot plot, HashMap<Flag<?>, Object> flags); void setFlags(Plot plot, Collection<PlotFlag<?, ?>> flags);
/** /**
* Renames a cluster to the given name. * Renames a cluster to the given name.

View File

@ -4,8 +4,7 @@ import com.github.intellectualsites.plotsquared.configuration.ConfigurationSecti
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.config.Storage; import com.github.intellectualsites.plotsquared.plot.config.Storage;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.object.BlockLoc; import com.github.intellectualsites.plotsquared.plot.object.BlockLoc;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
@ -30,6 +29,7 @@ import java.sql.Timestamp;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -1991,7 +1991,7 @@ import java.util.concurrent.atomic.AtomicInteger;
addPlotTask(newPlot, null); addPlotTask(newPlot, null);
} }
@Override public void setFlags(final Plot plot, HashMap<Flag<?>, Object> flags) { @Override public void setFlags(final Plot plot, Collection<PlotFlag<?, ?>> flags) {
final String flag_string = FlagManager.toString(flags); final String flag_string = FlagManager.toString(flags);
addPlotTask(plot, new UniqueStatement("setFlags") { addPlotTask(plot, new UniqueStatement("setFlags") {
@Override public void set(PreparedStatement statement) throws SQLException { @Override public void set(PreparedStatement statement) throws SQLException {

View File

@ -173,7 +173,7 @@ import java.util.Map;
* @return The flag instance, if it exists in this container, else null. * @return The flag instance, if it exists in this container, else null.
*/ */
@Nullable public <V, T extends PlotFlag<V, ?>> T queryLocal( @Nullable public <V, T extends PlotFlag<V, ?>> T queryLocal(
final Class<? extends T> flagClass) { final Class<?> flagClass) {
final PlotFlag<?, ?> localFlag = this.flagMap.get(flagClass); final PlotFlag<?, ?> localFlag = this.flagMap.get(flagClass);
if (localFlag == null) { if (localFlag == null) {
return null; return null;

View File

@ -288,8 +288,7 @@ public abstract class HybridUtils {
result.add(whenDone.value.data_sd); result.add(whenDone.value.data_sd);
result.add(whenDone.value.air_sd); result.add(whenDone.value.air_sd);
result.add(whenDone.value.variety_sd); result.add(whenDone.value.variety_sd);
origin.setFlag(GlobalFlagContainer.getInstance().getFlag(AnalysisFlag.class), origin.setFlag(GlobalFlagContainer.getInstance().getFlag(AnalysisFlag.class).createFlagInstance(result));
result);
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }

View File

@ -153,7 +153,7 @@ public class Plot {
/** /**
* Plot flag container * Plot flag container
*/ */
@Getter(AccessLevel.PROTECTED) private FlagContainer flagContainer; @Getter private FlagContainer flagContainer;
/** /**
* Constructor for a new plot. * Constructor for a new plot.
@ -1105,9 +1105,9 @@ public class Plot {
return true; return true;
} }
public <V> boolean setFlag(Class<? extends PlotFlag<V, ?>> flag, String value) { public boolean setFlag(Class<?> flag, String value) {
try { try {
this.setFlag(GlobalFlagContainer.getInstance().getFlag(flag).parse(value)); this.setFlag(GlobalFlagContainer.getInstance().getFlagErased(flag).parse(value));
} catch (final Exception e) { } catch (final Exception e) {
return false; return false;
} }

View File

@ -1,7 +1,7 @@
package com.github.intellectualsites.plotsquared.plot.object.worlds; package com.github.intellectualsites.plotsquared.plot.object.worlds;
import com.github.intellectualsites.plotsquared.plot.config.Captions; 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.BlockLoc;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
@ -37,7 +37,7 @@ public class SinglePlot extends Plot {
} }
public SinglePlot(PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members, public SinglePlot(PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members,
HashSet<UUID> denied, String alias, BlockLoc position, Collection<Flag> flags, HashSet<UUID> denied, String alias, BlockLoc position, Collection<PlotFlag<?, ?>> flags,
PlotArea area, boolean[] merged, long timestamp, int temp) { PlotArea area, boolean[] merged, long timestamp, int temp) {
super(id, owner, trusted, members, denied, alias, position, flags, area, merged, timestamp, super(id, owner, trusted, members, denied, alias, position, flags, area, merged, timestamp,
temp); temp);

View File

@ -4,6 +4,7 @@ import com.github.intellectualsites.plotsquared.configuration.ConfigurationSecti
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Configuration; import com.github.intellectualsites.plotsquared.plot.config.Configuration;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode; 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.generator.GridPlotWorld;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
@ -167,9 +168,12 @@ public class SinglePlotArea extends GridPlotWorld {
return p; return p;
} }
PlotSettings s = p.getSettings(); PlotSettings s = p.getSettings();
final FlagContainer oldContainer = p.getFlagContainer();
p = new SinglePlot(p.getId(), p.owner, p.getTrusted(), p.getMembers(), p.getDenied(), 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); s.alias, s.getPosition(), null, this, s.merged, p.getTimestamp(), p.temp);
p.getSettings().flags = s.flags; p.setFlagContainer(oldContainer);
return p; return p;
} }

View File

@ -307,7 +307,7 @@ public class ExpireManager {
} }
}, () -> { }, () -> {
newPlot.setFlag(GlobalFlagContainer.getInstance() newPlot.setFlag(GlobalFlagContainer.getInstance()
.getFlag(AnalysisFlag.class), changed.asList()); .getFlag(AnalysisFlag.class).createFlagInstance(changed.asList()));
TaskManager.runTaskLaterAsync(task, 20); TaskManager.runTaskLaterAsync(task, 20);
}); });
} }