From 76dc60194db8e3b0d845d659bc84c14a8291a061 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Sat, 17 Aug 2019 19:17:01 -0400 Subject: [PATCH] Added an invalid world name check. --- .../plotsquared/plot/commands/Setup.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Setup.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Setup.java index 19e94c6f5..7b21352e2 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Setup.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Setup.java @@ -16,8 +16,8 @@ import com.github.intellectualsites.plotsquared.plot.util.SetupUtils; import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import lombok.*; - import org.jetbrains.annotations.Nullable; + import java.util.*; import java.util.Map.Entry; @@ -288,6 +288,11 @@ import java.util.Map.Entry; MainUtil.sendMessage(player, "&cYou need to choose a world name!"); return false; } + if (!d(args[0])) { + MainUtil.sendMessage(player, + "Non [a-z0-9_.-] character in the world name: " + args[0]); + return false; + } if (WorldUtil.IMP.isWorld(args[0])) { if (PlotSquared.get().hasPlotArea(args[0])) { MainUtil.sendMessage(player, "&cThat world name is already taken!"); @@ -317,6 +322,11 @@ import java.util.Map.Entry; return false; } + private static boolean d(String s) { + return s.chars().allMatch((i) -> { + return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 48 && i <= 57 || i == 46; + }); + } private static final class StepPickGenerator extends SetupStep { @Getter private String generator;