13
0

Merge branch 'master' into safe_node
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

# Conflicts:
#	SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java
Dieser Commit ist enthalten in:
Chaos 2022-01-29 15:07:56 +01:00
Commit c4132ebda1
2 geänderte Dateien mit 42 neuen und 5 gelöschten Zeilen

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) {
@ -69,7 +71,7 @@ public class SchematicCommandUtils {
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen"); player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen");
return true; return true;
} }
if(FORBIDDEN_NAMES.contains(layer.toLowerCase())) { if (FORBIDDEN_NAMES.contains(layer.toLowerCase())) {
player.sendMessage(SchematicSystem.PREFIX + "§cDer Pfad darf nicht \"§l" + layer + "§c\" enthalten"); player.sendMessage(SchematicSystem.PREFIX + "§cDer Pfad darf nicht \"§l" + layer + "§c\" enthalten");
return true; return true;
} }
@ -240,7 +242,7 @@ public class SchematicCommandUtils {
base.addExtra(rename); base.addExtra(rename);
} }
TextComponent delete = new TextComponent("[" + (node.getOwner()==user.getId()?"Löschen":"Entfernen") + "] "); TextComponent delete = new TextComponent("[" + (node.getOwner() == user.getId() ? "Löschen" : "Entfernen") + "] ");
delete.setColor(ChatColor.DARK_RED); delete.setColor(ChatColor.DARK_RED);
delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " Löschen"))); delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " Löschen")));
delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + node.generateBreadcrumbs(user))); delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + node.generateBreadcrumbs(user)));
@ -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;
@ -336,7 +356,7 @@ public class SchematicCommandUtils {
return; return;
} }
if(!type.isAssignable()) { if (!type.isAssignable()) {
player.sendMessage(SchematicSystem.PREFIX + "§cZu diesem Typen können keine Schematics geändert werden."); player.sendMessage(SchematicSystem.PREFIX + "§cZu diesem Typen können keine Schematics geändert werden.");
} }