13
0

Merge pull request 'Add Punishments' (#100) from punishments into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #100
Reviewed-by: Lixfel <lixfel@steamwar.de>
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Chaoscaot 2022-01-29 15:06:49 +01:00
Commit 4bd2e6e779
2 geänderte Dateien mit 42 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SchematicSelector;
import de.steamwar.providers.BauServerInfo;
import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.sql.*;
import net.md_5.bungee.api.ChatColor;
@ -147,11 +148,18 @@ public class SchematicCommand extends SWCommand {
@Register("save")
@Register("s")
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("/")) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu must auch einen Namen für die Schematic nach dem Ordner angeben");
return;
}
SteamwarUser user = getUser(player);
if (name.startsWith("/")) name = name.substring(1);
String[] layers = name.split("/");
if (invalidSchemName(player, layers)) return;
@ -199,12 +207,21 @@ public class SchematicCommand extends SWCommand {
@Register("addmember")
public void addMember(Player player, SchematicNode node, SteamwarUser... targets) {
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()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nur auf deine eigenen Sachen jemanden hinzufügen.");
return;
}
List<SteamwarUser> added = new ArrayList<>();
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()) {
player.sendMessage(SchematicSystem.PREFIX + "§cAlso bitte: Das ist deine eigene Schematic!");
continue;

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.schematicsystem.commands;
import de.steamwar.comms.packets.PrepareSchemPacket;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.providers.BauServerInfo;
import de.steamwar.schematicsystem.AutoCheckResult;
import de.steamwar.schematicsystem.CheckSchemType;
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<String> FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public"));
private SchematicCommandUtils() {}
private SchematicCommandUtils() {
}
public static boolean invalidSchemName(Player player, String[] layers) {
for (String layer : layers) {
@ -296,6 +298,14 @@ public class SchematicCommandUtils {
}
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()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst keine Ordner Laden");
return;
@ -315,6 +325,11 @@ public class SchematicCommandUtils {
public static void download(Player player, SchematicNode node) {
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()) {
player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!");
return;
@ -326,6 +341,11 @@ public class SchematicCommandUtils {
public static void changeType(Player player, SchematicNode node, SchematicType type, SchematicCommand.Extend extend) {
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()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nur deine eigenen Schematics einsenden.");
return;