SteamWar/SpigotCore
Archiviert
13
0

Merge remote-tracking branch 'origin/master'
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2022-01-03 00:28:48 +01:00
Commit a9a8a83c46
5 geänderte Dateien mit 90 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -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;

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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);
}
}

Datei anzeigen

@ -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();
}

Datei anzeigen

@ -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<Punishment> 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;

Datei anzeigen

@ -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<String> 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;
}
}