diff --git a/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java b/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java
index f7b71e4..d4e85a2 100644
--- a/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java
+++ b/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java
@@ -27,6 +27,7 @@ public class PacketIdManager {
public static final byte TABLIST_NAME = 0x02;
public static final byte PREPARE_SCHEM = 0x03;
public static final byte BAUMEMBER_UPDATE = 0x04;
+ public static final byte EXECUTE_COMMAND = 0x05;
//0x1(X) Bungee Inventory
public static final byte INVENTORY_PACKET = 0x10;
public static final byte INVENTORY_CALLBACK_PACKET = 0x11;
diff --git a/SpigotCore_Main/src/de/steamwar/comms/packets/ExecuteCommandPacket.java b/SpigotCore_Main/src/de/steamwar/comms/packets/ExecuteCommandPacket.java
new file mode 100644
index 0000000..bede2b2
--- /dev/null
+++ b/SpigotCore_Main/src/de/steamwar/comms/packets/ExecuteCommandPacket.java
@@ -0,0 +1,47 @@
+/*
+ This file is a part of the SteamWar software.
+
+ Copyright (C) 2021 SteamWar.de-Serverteam
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+package de.steamwar.comms.packets;
+
+import com.google.common.io.ByteArrayDataOutput;
+import de.steamwar.comms.PacketIdManager;
+import de.steamwar.sql.SteamwarUser;
+import org.bukkit.entity.Player;
+
+public class ExecuteCommandPacket extends SpigotPacket {
+
+ private final SteamwarUser user;
+ private final String command;
+
+ public ExecuteCommandPacket(Player player, String command) {
+ this.user = SteamwarUser.get(player.getUniqueId());
+ this.command = command;
+ }
+
+ @Override
+ public int getName() {
+ return PacketIdManager.EXECUTE_COMMAND;
+ }
+
+ @Override
+ public void writeVars(ByteArrayDataOutput out) {
+ out.writeInt(user.getId());
+ out.writeUTF(command);
+ }
+}
diff --git a/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelector.java b/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelector.java
index 90e96d4..6a98371 100644
--- a/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelector.java
+++ b/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelector.java
@@ -228,10 +228,14 @@ public class SchematicSelector {
SWAnvilInv inv = new SWAnvilInv(player, Core.MESSAGE.parse("SCHEM_SELECTOR_CREATE_DIR_TITLE", player));
inv.setItem(Material.CHEST);
inv.setCallback(s -> {
- if(injectable.onFolderCreate(this, s)) {
- SchematicNode.createSchematicDirectory(user.getId(), s, parent==null?0:parent.getId());
- openList(parent);
+ if(!SchematicNode.invalidSchemName(new String[] {s})) {
+ if(injectable.onFolderCreate(this, s)) {
+ SchematicNode.createSchematicDirectory(user.getId(), s, parent==null?0:parent.getId());
+ openList(parent);
+ }
+ return;
}
+ player.closeInventory();
});
inv.open();
}
diff --git a/SpigotCore_Main/src/de/steamwar/sql/Punishment.java b/SpigotCore_Main/src/de/steamwar/sql/Punishment.java
index 0e2bc5b..85ec258 100644
--- a/SpigotCore_Main/src/de/steamwar/sql/Punishment.java
+++ b/SpigotCore_Main/src/de/steamwar/sql/Punishment.java
@@ -27,6 +27,7 @@ import java.sql.SQLException;
import java.sql.Timestamp;
import java.time.format.DateTimeFormatter;
import java.util.*;
+import java.util.function.Consumer;
public class Punishment {
@@ -50,6 +51,16 @@ public class Punishment {
}, user);
}
+ public static boolean isPunished(SteamwarUser user, Punishment.PunishmentType type, Consumer callback) {
+ Punishment punishment = Punishment.getPunishmentOfPlayer(user.getId(), type);
+ if(punishment == null || punishment.isCurrent()) {
+ return false;
+ } else {
+ callback.accept(punishment);
+ return true;
+ }
+ }
+
private final Timestamp startTime;
private Timestamp endTime;
private final PunishmentType type;
diff --git a/SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java
index d888e5e..4d31c7c 100644
--- a/SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java
+++ b/SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java
@@ -22,7 +22,6 @@ package de.steamwar.sql;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.core.Core;
import de.steamwar.core.WorldEditWrapper;
-import de.steamwar.inventory.SWItem;
import org.bukkit.entity.Player;
import java.io.ByteArrayInputStream;
@@ -508,9 +507,6 @@ public class SchematicNode {
}
public void delete() {
- if (isDir()) {
- getSchematicNodeInNode(getId()).forEach(SchematicNode::delete);
- }
deleteNode.update(id);
}
@@ -604,4 +600,28 @@ public class SchematicNode {
list.remove("//copy");
return list;
}
+
+ private static final List FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public"));
+ public static boolean invalidSchemName(String[] layers) {
+ for (String layer : layers) {
+ if (layer.isEmpty()) {
+ return true;
+ }
+ if (layer.contains("/") ||
+ layer.contains("\\") ||
+ layer.contains("<") ||
+ layer.contains(">") ||
+ layer.contains("^") ||
+ layer.contains("°") ||
+ layer.contains("'") ||
+ layer.contains("\"") ||
+ layer.contains(" ")) {
+ return true;
+ }
+ if(FORBIDDEN_NAMES.contains(layer.toLowerCase())) {
+ return true;
+ }
+ }
+ return false;
+ }
}