diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java b/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java index f10e3be82..e05f82fc7 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java @@ -25,7 +25,9 @@ */ package com.plotsquared.core.plot.flag; +import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; +import com.plotsquared.core.PlotSquared; import lombok.EqualsAndHashCode; import lombok.Setter; import org.jetbrains.annotations.NotNull; @@ -128,17 +130,26 @@ public class FlagContainer { * @see #addAll(Collection) to add multiple flags */ public > void addFlag(final T flag) { - final PlotFlag oldInstance = this.flagMap.put(flag.getClass(), flag); - final PlotFlagUpdateType plotFlagUpdateType; - if (oldInstance != null) { - plotFlagUpdateType = PlotFlagUpdateType.FLAG_UPDATED; - } else { - plotFlagUpdateType = PlotFlagUpdateType.FLAG_ADDED; + try { + Preconditions.checkState(flag.getName().length() <= 64, + "flag name may not be more than 64 characters. Check: " + flag.getName()); + final PlotFlag oldInstance = this.flagMap.put(flag.getClass(), flag); + final PlotFlagUpdateType plotFlagUpdateType; + if (oldInstance != null) { + plotFlagUpdateType = PlotFlagUpdateType.FLAG_UPDATED; + } else { + plotFlagUpdateType = PlotFlagUpdateType.FLAG_ADDED; + } + if (this.plotFlagUpdateHandler != null) { + this.plotFlagUpdateHandler.handle(flag, plotFlagUpdateType); + } + this.updateSubscribers + .forEach(subscriber -> subscriber.handle(flag, plotFlagUpdateType)); + } catch (IllegalStateException e) { + PlotSquared.log( + "yo look at this dumb fuck trying to add this thicc flag lol, nah mate, ain't having none of that"); + e.printStackTrace(); } - if (this.plotFlagUpdateHandler != null) { - this.plotFlagUpdateHandler.handle(flag, plotFlagUpdateType); - } - this.updateSubscribers.forEach(subscriber -> subscriber.handle(flag, plotFlagUpdateType)); } /** diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java index 53830c8ae..513398a39 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java @@ -75,8 +75,6 @@ public abstract class PlotFlag> { flagName.append(chars[i]); } } - Preconditions.checkState(flagName.length() <= 64, - "flag name may not be more than 64 characters. Check: " + flagName.toString()); this.flagName = flagName.toString(); }