Finalize PlotArea.java

This commit is contained in:
Alexander Söderberg 2020-02-18 14:42:05 +01:00
parent 7f42cbb67f
commit 2fe00ef284

View File

@ -2,11 +2,9 @@ package com.github.intellectualsites.plotsquared.plot.object;
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection; import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
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.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer; import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer;
import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException; import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer; import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
@ -321,12 +319,11 @@ public abstract class PlotArea {
} }
} }
try { try {
this.DEFAULT_FLAGS = parseFlags(flags); this.getFlagContainer().addAll(parseFlags(flags));
} catch (Exception e) { } catch (FlagParseException e) {
e.printStackTrace(); e.printStackTrace();
PlotSquared.debug("&cInvalid default flags for " + this.worldname + ": " + StringMan PlotSquared.debug("&cInvalid default flags for " + this.worldname + ": " + StringMan
.join(flags, ",")); .join(flags, ","));
this.DEFAULT_FLAGS = new HashMap<>();
} }
this.SPAWN_EGGS = config.getBoolean("event.spawn.egg"); this.SPAWN_EGGS = config.getBoolean("event.spawn.egg");
this.SPAWN_CUSTOM = config.getBoolean("event.spawn.custom"); this.SPAWN_CUSTOM = config.getBoolean("event.spawn.custom");
@ -626,8 +623,6 @@ public abstract class PlotArea {
* Session only plot metadata (session is until the server stops). * Session only plot metadata (session is until the server stops).
* <br> * <br>
* For persistent metadata use the flag system * For persistent metadata use the flag system
*
* @see FlagManager
*/ */
public void setMeta(@NotNull final String key, @Nullable final Object value) { public void setMeta(@NotNull final String key, @Nullable final Object value) {
if (this.meta == null) { if (this.meta == null) {
@ -957,7 +952,7 @@ public abstract class PlotArea {
return null; return null;
} }
public static Collection<PlotFlag<?, ?>> parseFlags(List<String> flagStrings) { public static Collection<PlotFlag<?, ?>> parseFlags(List<String> flagStrings) throws FlagParseException {
final Collection<PlotFlag<?, ?>> flags = new ArrayList<>(); final Collection<PlotFlag<?, ?>> flags = new ArrayList<>();
for (final String key : flagStrings) { for (final String key : flagStrings) {
final String[] split; final String[] split;
@ -968,12 +963,7 @@ public abstract class PlotArea {
} }
final PlotFlag<?, ?> flagInstance = GlobalFlagContainer.getInstance().getFlagFromString(split[0]); final PlotFlag<?, ?> flagInstance = GlobalFlagContainer.getInstance().getFlagFromString(split[0]);
if (flagInstance != null) { if (flagInstance != null) {
try { flags.add(flagInstance.parse(split[1]));
flags.add(flagInstance.parse(split[1]));
} catch (final FlagParseException e) {
Captions.FLAG_PARSE_EXCEPTION
.send(ConsolePlayer.getConsole(), e.getFlag().getName(), e.getValue(), e.getErrorMessage());
}
} }
} }
return flags; return flags;