From d876d3722aad2922629cc5495696ab25c657987f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien?= <43724816+Aurelien30000@users.noreply.github.com> Date: Mon, 17 Jul 2023 22:30:02 +0200 Subject: [PATCH] Fix default flags registration for third parties (#4114) Co-authored-by: Leomixer17 --- .../java/com/plotsquared/core/plot/PlotArea.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java index aa24e527b..73c34cdda 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java @@ -180,8 +180,7 @@ public abstract class PlotArea implements ComponentLike { this.worldConfiguration = worldConfiguration; } - private static Collection> parseFlags(List flagStrings) { - final Collection> flags = new ArrayList<>(); + private static void parseFlags(FlagContainer flagContainer, List flagStrings) { for (final String key : flagStrings) { final String[] split; if (key.contains(";")) { @@ -193,7 +192,7 @@ public abstract class PlotArea implements ComponentLike { GlobalFlagContainer.getInstance().getFlagFromString(split[0]); if (flagInstance != null) { try { - flags.add(flagInstance.parse(split[1])); + flagContainer.addFlag(flagInstance.parse(split[1])); } catch (final FlagParseException e) { LOGGER.warn( "Failed to parse default flag with key '{}' and value '{}'. " @@ -204,9 +203,10 @@ public abstract class PlotArea implements ComponentLike { ); e.printStackTrace(); } + } else { + flagContainer.addUnknownFlag(split[0], split[1]); } } - return flags; } @NonNull @@ -405,7 +405,7 @@ public abstract class PlotArea implements ComponentLike { } } } - this.getFlagContainer().addAll(parseFlags(flags)); + parseFlags(this.getFlagContainer(), flags); ConsolePlayer.getConsole().sendMessage( TranslatableCaption.of("flags.area_flags"), TagResolver.resolver("flags", Tag.inserting(Component.text(flags.toString()))) @@ -427,7 +427,7 @@ public abstract class PlotArea implements ComponentLike { } } this.roadFlags = roadflags.size() > 0; - this.getRoadFlagContainer().addAll(parseFlags(roadflags)); + parseFlags(this.getRoadFlagContainer(), roadflags); ConsolePlayer.getConsole().sendMessage( TranslatableCaption.of("flags.road_flags"), TagResolver.resolver("flags", Tag.inserting(Component.text(roadflags.toString())))