13
0

Safe Schematic Node #105

Zusammengeführt
Chaoscaot hat 5 Commits von safe_node nach master 2022-01-29 15:08:33 +01:00 zusammengeführt
2 geänderte Dateien mit 42 neuen und 5 gelöschten Zeilen
Nur Änderungen aus Commit c4132ebda1 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -25,6 +25,7 @@ import de.steamwar.command.TypeMapper;
import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SchematicSelector; import de.steamwar.inventory.SchematicSelector;
import de.steamwar.schematicsystem.SafeSchematicNode; import de.steamwar.schematicsystem.SafeSchematicNode;
import de.steamwar.providers.BauServerInfo;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.sql.*; import de.steamwar.sql.*;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
@ -148,11 +149,18 @@ public class SchematicCommand extends SWCommand {
@Register("save") @Register("save")
@Register("s") @Register("s")
public void saveSchem(Player player, @Mapper("dirStringMapper") String name) { public void saveSchem(Player player, @Mapper("dirStringMapper") String name) {
SteamwarUser user = getUser(player);
if(BauServerInfo.isBauServer() && BauServerInfo.getOwnerId() != user.getId() &&
(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemReceiving, punishment ->
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nicht auf anderen Baus Schematics machen")) ||
Punishment.isPunished(SteamwarUser.get(BauServerInfo.getOwnerId()), Punishment.PunishmentType.NoSchemSharing, punishment ->
player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Bau können keine Schematics gemacht werden")))) {
return;
}
if (name.endsWith("/")) { if (name.endsWith("/")) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu must auch einen Namen für die Schematic nach dem Ordner angeben"); player.sendMessage(SchematicSystem.PREFIX + "§cDu must auch einen Namen für die Schematic nach dem Ordner angeben");
return; return;
} }
SteamwarUser user = getUser(player);
if (name.startsWith("/")) name = name.substring(1); if (name.startsWith("/")) name = name.substring(1);
String[] layers = name.split("/"); String[] layers = name.split("/");
if (invalidSchemName(player, layers)) return; if (invalidSchemName(player, layers)) return;
@ -200,12 +208,21 @@ public class SchematicCommand extends SWCommand {
@Register("addmember") @Register("addmember")
public void addMember(Player player, SchematicNode node, SteamwarUser... targets) { public void addMember(Player player, SchematicNode node, SteamwarUser... targets) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
if(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst niemanden auf deine Schematics hinzufügen: §f§l" + punishment.getReason()))) {
return;
}
if (node.getOwner() != user.getId()) { if (node.getOwner() != user.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nur auf deine eigenen Sachen jemanden hinzufügen."); player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nur auf deine eigenen Sachen jemanden hinzufügen.");
return; return;
} }
List<SteamwarUser> added = new ArrayList<>(); List<SteamwarUser> added = new ArrayList<>();
for (SteamwarUser target: targets) { for (SteamwarUser target: targets) {
if(Punishment.isPunished(target,
Punishment.PunishmentType.NoSchemReceiving,
punishment -> player.sendMessage(SchematicSystem.PREFIX + "§c" + target.getUserName() + " darf nicht auf Schematics hinzugefügt werden."))) {
continue;
}
if (user.getId() == target.getId()) { if (user.getId() == target.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cAlso bitte: Das ist deine eigene Schematic!"); player.sendMessage(SchematicSystem.PREFIX + "§cAlso bitte: Das ist deine eigene Schematic!");
continue; continue;

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.schematicsystem.commands;
import de.steamwar.comms.packets.PrepareSchemPacket; import de.steamwar.comms.packets.PrepareSchemPacket;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.providers.BauServerInfo;
import de.steamwar.schematicsystem.AutoCheckResult; import de.steamwar.schematicsystem.AutoCheckResult;
import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.CheckSchemType;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
@ -45,7 +46,8 @@ public class SchematicCommandUtils {
private static final List<Player> PUBLIC_TOGGLED = new ArrayList<>(); private static final List<Player> PUBLIC_TOGGLED = new ArrayList<>();
private static final List<String> FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public")); private static final List<String> FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public"));
private SchematicCommandUtils() {} private SchematicCommandUtils() {
}
public static boolean invalidSchemName(Player player, String[] layers) { public static boolean invalidSchemName(Player player, String[] layers) {
for (String layer : layers) { for (String layer : layers) {
@ -296,6 +298,14 @@ public class SchematicCommandUtils {
} }
public static void loadSchem(Player player, SchematicNode node) { public static void loadSchem(Player player, SchematicNode node) {
SteamwarUser user = getUser(player);
if(BauServerInfo.isBauServer() && BauServerInfo.getOwnerId() != user.getId() &&
(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment ->
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst hier keine Schematics laden")) ||
Punishment.isPunished(SteamwarUser.get(BauServerInfo.getOwnerId()), Punishment.PunishmentType.NoSchemReceiving, punishment ->
player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Bau können keine Schematics geladen werden")))) {
return;
}
if (node.isDir()) { if (node.isDir()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst keine Ordner Laden"); player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst keine Ordner Laden");
return; return;
@ -315,6 +325,11 @@ public class SchematicCommandUtils {
public static void download(Player player, SchematicNode node) { public static void download(Player player, SchematicNode node) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
if (Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> {
player.sendMessage(SchematicSystem.PREFIX + "§cDu darf keine Schematics Downloaden: §f§l" + punishment.getReason());
})) {
return;
}
if (node.getOwner() != user.getId()) { if (node.getOwner() != user.getId()) {
player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!"); player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!");
return; return;
@ -326,6 +341,11 @@ public class SchematicCommandUtils {
public static void changeType(Player player, SchematicNode node, SchematicType type, SchematicCommand.Extend extend) { public static void changeType(Player player, SchematicNode node, SchematicType type, SchematicCommand.Extend extend) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
if (Punishment.isPunished(user,
Punishment.PunishmentType.NoSchemSubmitting,
punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darf keine Schematics einsenden: §f§l: " + punishment.getReason()))) {
return;
}
if (node.getOwner() != user.getId()) { if (node.getOwner() != user.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nur deine eigenen Schematics einsenden."); player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nur deine eigenen Schematics einsenden.");
return; return;