diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java index 25a5711..0046164 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java @@ -25,14 +25,10 @@ import lombok.AllArgsConstructor; import lombok.NonNull; import org.bukkit.entity.Player; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - public class SafeSchematicNode { public static Result setParent(@NonNull SteamwarUser user, @NonNull SchematicNode node, SchematicNode newParent) { - if(user.getId() != node.getId()) { + if(user.getId() != node.getOwner()) { return Result.NOT_OWNER; } if(newParent == null) { @@ -58,11 +54,11 @@ public class SafeSchematicNode { } public static Result setName(@NonNull SteamwarUser user, @NonNull SchematicNode node, @NonNull String name) { - if(user.getId() != node.getId()) { + if(user.getId() != node.getOwner()) { return Result.NOT_OWNER; } - if(invalidSchemName(name)) { + if(SchematicNode.invalidSchemName(new String[]{name})) { return Result.INVALID_NAME; } @@ -74,28 +70,6 @@ public class SafeSchematicNode { return Result.DONE; } - private static final List FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public")); - public static boolean invalidSchemName(String name) { - if (name.isEmpty()) { - return true; - } - if(name.length() > 64) { - return true; - } - if (name.contains("/") || - name.contains("\\") || - name.contains("<") || - name.contains(">") || - name.contains("^") || - name.contains("°") || - name.contains("'") || - name.contains("\"") || - name.contains(" ")) { - return true; - } - return FORBIDDEN_NAMES.contains(name.toLowerCase()); - } - @AllArgsConstructor public enum Result { DONE("No"), @@ -104,7 +78,7 @@ public class SafeSchematicNode { INVALID_NAME(SchematicSystem.PREFIX + "§cDieser Name ist unzulässig"), NOT_OWNER(SchematicSystem.PREFIX + "§cDu bist nicht der Besitzer dieser Schematic"); - private String errorMessage; + private final String errorMessage; public void sendError(Player player) { player.sendMessage(errorMessage);