13
0

Merge remote-tracking branch 'origin/master' into pagination
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-02-16 17:52:29 +01:00
Commit b6a8ab4b4f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4A63938B698948FD
6 geänderte Dateien mit 239 neuen und 48 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,91 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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.schematicsystem;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import lombok.AllArgsConstructor;
import lombok.NonNull;
import org.bukkit.entity.Player;
public class SafeSchematicNode {
public static Result setParent(@NonNull SteamwarUser user, @NonNull SchematicNode node, SchematicNode newParent) {
if(user.getId() != node.getOwner()) {
return Result.NOT_OWNER;
}
if(newParent == null) {
if(SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0)
.stream().map(SchematicNode::getName).anyMatch(s -> s.equalsIgnoreCase(node.getName()))) {
return Result.ALREADY_IN_DIRECTORY;
}
node.setParent(null);
} else {
if(!newParent.isDir()) {
return Result.NOT_A_DIR;
}
if(SchematicNode.getSchematicsAccessibleByUser(user.getId(), newParent.getId())
.stream().map(SchematicNode::getName).anyMatch(s -> s.equalsIgnoreCase(node.getName()))) {
return Result.ALREADY_IN_DIRECTORY;
}
node.setParent(newParent.getId());
}
return Result.DONE;
}
public static Result setName(@NonNull SteamwarUser user, @NonNull SchematicNode node, @NonNull String name) {
if(user.getId() != node.getOwner()) {
return Result.NOT_OWNER;
}
if(SchematicNode.invalidSchemName(new String[]{name})) {
return Result.INVALID_NAME;
}
if(SchematicNode.getSchematicsAccessibleByUser(user.getId(), node.getParent()).stream().map(SchematicNode::getName).anyMatch(s -> s.equalsIgnoreCase(name))) {
return Result.ALREADY_IN_DIRECTORY;
}
node.setName(name);
return Result.DONE;
}
@AllArgsConstructor
public enum Result {
DONE("No"),
NOT_A_DIR(SchematicSystem.PREFIX + "§cDie ausgewählte Schematic ist kein Ordner"),
ALREADY_IN_DIRECTORY(SchematicSystem.PREFIX + "§cDie Schematic gibt es bereits in diesem Ordner"),
INVALID_NAME(SchematicSystem.PREFIX + "§cDieser Name ist unzulässig"),
NOT_OWNER(SchematicSystem.PREFIX + "§cDu bist nicht der Besitzer dieser Schematic");
private final String errorMessage;
public void sendError(Player player) {
player.sendMessage(errorMessage);
}
public boolean isSuccessful() {
return this == DONE;
}
}
}

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.schematicsystem.commands; package de.steamwar.schematicsystem.commands;
import de.steamwar.inventory.*; import de.steamwar.inventory.*;
import de.steamwar.schematicsystem.SafeSchematicNode;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.sql.*; import de.steamwar.sql.*;
import org.bukkit.Material; import org.bukkit.Material;
@ -46,18 +47,19 @@ public class GUI {
inv.setItem(49, Material.AIR, "", clickType -> {}); inv.setItem(49, Material.AIR, "", clickType -> {});
} else { } else {
inv.setItem(49, Material.ANVIL, "§7Ordnereigenschaften", clickType -> { inv.setItem(49, Material.ANVIL, "§7Ordnereigenschaften", clickType -> {
info(selector.getPlayer(), parent); info(selector.getPlayer(), parent, selector);
}); });
} }
} }
}, node -> info(player, node)); }, node -> {});
selector.setCallback(node -> info(player, node, selector));
selector.setSingleDirOpen(false); selector.setSingleDirOpen(false);
selector.open(); selector.open();
} }
private static void info(Player player, SchematicNode node) { private static void info(Player player, SchematicNode node, SchematicSelector back) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
SWInventory inv = new SWInventory(player, 9, node.generateBreadcrumbs(user)); SWInventory inv = new SWInventory(player, 9 * 2, node.generateBreadcrumbs(user));
if(!node.isDir()) { if(!node.isDir()) {
inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), "§eLaden", click -> { inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), "§eLaden", click -> {
player.closeInventory(); player.closeInventory();
@ -65,6 +67,10 @@ public class GUI {
}); });
} }
inv.setItem(9, SWItem.getMaterial("LEASH"), "§eZurück", clickType -> {
back.reOpen();
});
if(node.getOwner() == user.getId()){ if(node.getOwner() == user.getId()){
if(!node.isDir() && node.getSchemtype().writeable()){ if(!node.isDir() && node.getSchemtype().writeable()){
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId()); List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
@ -79,16 +85,14 @@ public class GUI {
} }
Material mat = SWItem.getMaterial(node.getItem()); Material mat = SWItem.getMaterial(node.getItem());
inv.setItem(2, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> { inv.setItem(5, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
player.closeInventory(); changeItem(player, node, back);
changeItem(player, node);
}); });
if(!node.isDir()) { if(!node.isDir()) {
inv.setItem(3, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> { inv.setItem(6, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), node.getSchemtype().fightType(), click -> {
player.closeInventory();
changeType(player, node); changeType(player, node);
}); });
inv.setItem(4, SWItem.getMaterial("MAGENTA_GLAZED_TERRACOTTA"), "§eDownload", click -> { inv.setItem(7, SWItem.getMaterial("MAGENTA_GLAZED_TERRACOTTA"), "§eDownload", click -> {
player.closeInventory(); player.closeInventory();
SchematicCommandUtils.download(player, node); SchematicCommandUtils.download(player, node);
}); });
@ -99,44 +103,49 @@ public class GUI {
delmembers(player, node); delmembers(player, node);
}); });
skull.setName("§eMitglieder"); skull.setName("§eMitglieder");
inv.setItem(5, skull); inv.setItem(8, skull);
inv.setItem(6, Material.ARROW, "§eVerschieben", clickType -> { inv.setItem(15, Material.ARROW, "§eVerschieben", clickType -> {
SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectDirectory(), npar -> { SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectDirectory(), npar -> {
node.setParent(npar==null?null:npar.getId()); SafeSchematicNode.Result result = SafeSchematicNode.setParent(user, node, npar);
info(player, SchematicNode.getSchematicNode(node.getId())); if(result.isSuccessful()) {
info(player, SchematicNode.getSchematicNode(node.getId()), back);
} else {
result.sendError(player);
}
}); });
selector.open(); selector.open();
}); });
Material finalMat = mat; inv.setItem(16, Material.NAME_TAG, "§eUmbenennen", clickType -> {
inv.setItem(7, Material.NAME_TAG, "§eUmbenennen", clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, node.getName() + " umbenennen", node.getName()); SWAnvilInv anvilInv = new SWAnvilInv(player, node.getName() + " umbenennen", node.getName());
anvilInv.setItem(finalMat); anvilInv.setItem(mat);
anvilInv.setCallback(s -> { anvilInv.setCallback(s -> {
if (!invalidSchemName(player, new String[]{s})) { SafeSchematicNode.Result result = SafeSchematicNode.setName(user, node, s);
node.setName(s); if(result.isSuccessful()) {
info(player, node, back);
} else {
result.sendError(player);
} }
info(player, node);
}); });
anvilInv.open(); anvilInv.open();
}); });
inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cLöschen", click -> { inv.setItem(17, SWItem.getDye(1), (byte) 1, "§cLöschen", click -> {
player.closeInventory(); delete(player, node, back);
delete(player, node);
}); });
}else{ }else{
if(!node.isDir()) { if(!node.isDir()) {
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), click -> {}); inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), Collections.emptyList(), node.getSchemtype().fightType(), click -> {});
} }
SteamwarUser owneruser = SteamwarUser.get(node.getOwner()); SteamwarUser owneruser = SteamwarUser.get(node.getOwner());
SWItem skull = SWItem.getPlayerSkull(owneruser.getUserName()); SWItem skull = SWItem.getPlayerSkull(owneruser.getUserName());
skull.setName("§7von §e" + owneruser.getUserName()); skull.setName("§7von §e" + owneruser.getUserName());
inv.setItem(6, skull.getItemStack(), clickType -> {}); inv.setItem(8, skull.getItemStack(), clickType -> {});
inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cZugriff entfernen", click -> { if(NodeMember.getNodeMember(node.getId(), user.getId()) != null) {
player.closeInventory(); inv.setItem(17, SWItem.getDye(1), (byte) 1, "§cZugriff entfernen", click -> {
delete(player, node); delete(player, node, back);
}); });
}
} }
inv.setCallback(-999, click -> player.closeInventory()); inv.setCallback(-999, click -> player.closeInventory());
@ -164,21 +173,27 @@ public class GUI {
inv.open(); inv.open();
} }
private static void deleteOwn(Player p, SchematicNode schem){ private static void deleteOwn(Player p, SchematicNode schem, SchematicSelector back){
SteamwarUser user = getUser(p); SteamwarUser user = getUser(p);
SWInventory inv = new SWInventory(p, 9, schem.generateBreadcrumbs(user) + " löschen"); SWInventory inv = new SWInventory(p, 9, schem.generateBreadcrumbs(user) + " löschen");
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> { inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> {
schem.delete(); schem.delete();
p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.generateBreadcrumbs(user) + " §7gelöscht"); p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.generateBreadcrumbs(user) + " §7gelöscht");
p.closeInventory(); if(back != null) {
if(schem.isDir()) {
back.reOpenDirUp();
} else {
back.reOpen();
}
}
}); });
inv.setItem(8, SWItem.getDye(14), (byte) 14, "§cAbbruch", click -> p.closeInventory()); inv.setItem(8, SWItem.getDye(14), (byte) 14, "§cAbbruch", click -> p.closeInventory());
inv.setCallback(-999, click -> p.closeInventory()); inv.setCallback(-999, click -> p.closeInventory());
inv.open(); inv.open();
} }
private static void deleteMembership(Player p, SchematicNode schem){ private static void deleteMembership(Player p, SchematicNode schem, SchematicSelector back){
SteamwarUser user = getUser(p); SteamwarUser user = getUser(p);
SWInventory inv = new SWInventory(p, 9, schem.generateBreadcrumbs(user) + " entfernen"); SWInventory inv = new SWInventory(p, 9, schem.generateBreadcrumbs(user) + " entfernen");
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eZugriff entfernen", click -> { inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eZugriff entfernen", click -> {
@ -186,18 +201,24 @@ public class GUI {
if(member != null) if(member != null)
member.delete(); member.delete();
p.sendMessage(SchematicSystem.PREFIX + "Zugriff zu Schematic §e" + schem.generateBreadcrumbs(user) + " §7entfernt"); p.sendMessage(SchematicSystem.PREFIX + "Zugriff zu Schematic §e" + schem.generateBreadcrumbs(user) + " §7entfernt");
p.closeInventory(); if(back != null) {
if(schem.isDir()) {
back.reOpenDirUp();
} else {
back.reOpen();
}
}
}); });
inv.setItem(8, SWItem.getDye(14), (byte) 14, "§cAbbruch", click -> p.closeInventory()); inv.setItem(8, SWItem.getDye(14), (byte) 14, "§cAbbruch", click -> p.closeInventory());
inv.setCallback(-999, click -> p.closeInventory()); inv.setCallback(-999, click -> p.closeInventory());
inv.open(); inv.open();
} }
static void delete(Player p, SchematicNode schem){ static void delete(Player p, SchematicNode schem, SchematicSelector back){
if(SteamwarUser.get(p.getUniqueId()).getId() == schem.getOwner()) if(SteamwarUser.get(p.getUniqueId()).getId() == schem.getOwner())
deleteOwn(p, schem); deleteOwn(p, schem, back);
else else
deleteMembership(p, schem); deleteMembership(p, schem, back);
} }
static void delmembers(Player p, SchematicNode schem){ static void delmembers(Player p, SchematicNode schem){
@ -216,11 +237,11 @@ public class GUI {
inv.open(); inv.open();
} }
private static void changeItem(Player p, SchematicNode schem){ private static void changeItem(Player p, SchematicNode schem, SchematicSelector back){
UtilGui.openMaterialSelector(p, "Item ändern", material -> { UtilGui.openMaterialSelector(p, "Item ändern", material -> {
schem.setItem(material.name()); schem.setItem(material.name());
p.closeInventory(); p.closeInventory();
info(p, schem); info(p, schem, back);
}); });
} }
} }

Datei anzeigen

@ -24,6 +24,8 @@ import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper; 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.providers.BauServerInfo;
import de.steamwar.schematicsystem.SafeSchematicNode;
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;
@ -55,6 +57,9 @@ public class SchematicCommand extends SWCommand {
Class<?> clazz = Material.class; Class<?> clazz = Material.class;
searchMapper.put("-item", SWCommandUtils.createEnumMapper((Class<Enum<?>>) clazz)); searchMapper.put("-item", SWCommandUtils.createEnumMapper((Class<Enum<?>>) clazz));
searchMapper.put("-public", null); searchMapper.put("-public", null);
searchMapper.put("-exclude", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s)));
searchMapper.put("-excludeType", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new)));
searchMapper.put("-excludeOwner", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s)));
} }
public SchematicCommand() { public SchematicCommand() {
@ -147,11 +152,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;
@ -199,12 +211,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;
@ -295,6 +316,21 @@ public class SchematicCommand extends SWCommand {
return; return;
} }
predicates.add(node -> node.getOwner() == steamwarUser.getId()); predicates.add(node -> node.getOwner() == steamwarUser.getId());
break;
case "-exclude":
predicates.add(node -> !node.getName().contains(query[finalI + 1]));
break;
case "-excludeType":
predicates.add(node -> !node.getSchemtype().name().equalsIgnoreCase(query[finalI + 1]));
break;
case "-excludeOwner":
SteamwarUser steamwarUser1 = SteamwarUser.get(query[finalI + 1]);
if (steamwarUser1 == null) {
player.sendMessage(SchematicSystem.PREFIX + "§cDer Spieler §e" + query[finalI + 1] + " §cexistiert nicht");
return;
}
predicates.add(node -> node.getOwner() != steamwarUser1.getId());
break;
} }
i++; i++;
} }
@ -397,7 +433,11 @@ public class SchematicCommand extends SWCommand {
player.sendMessage(SchematicSystem.PREFIX + "§cDas gibt nur Fehler, vertrau mir."); player.sendMessage(SchematicSystem.PREFIX + "§cDas gibt nur Fehler, vertrau mir.");
return; return;
} }
node.setParent(newNode.getId()); SafeSchematicNode.Result result = SafeSchematicNode.setParent(user, node, newNode);
if(!result.isSuccessful()) {
result.sendError(player);
return;
}
} }
player.sendMessage(SchematicSystem.PREFIX + "§7Die Schematic ist nun unter §e" + node.generateBreadcrumbs(user) + " §7zu finden"); player.sendMessage(SchematicSystem.PREFIX + "§7Die Schematic ist nun unter §e" + node.generateBreadcrumbs(user) + " §7zu finden");
} }
@ -412,7 +452,11 @@ public class SchematicCommand extends SWCommand {
if (invalidSchemName(player, new String[]{name})) { if (invalidSchemName(player, new String[]{name})) {
return; return;
} }
node.setName(name); SafeSchematicNode.Result result = SafeSchematicNode.setName(user, node, name);
if(!result.isSuccessful()) {
result.sendError(player);
return;
}
player.sendMessage(SchematicSystem.PREFIX + "§7Die Schematic heist nun §e" + node.generateBreadcrumbs(user)); player.sendMessage(SchematicSystem.PREFIX + "§7Die Schematic heist nun §e" + node.generateBreadcrumbs(user));
} }
@ -475,7 +519,21 @@ public class SchematicCommand extends SWCommand {
player.sendMessage(SchematicSystem.PREFIX + "§7Alle Spieler wurden von der Schematic entfernt"); player.sendMessage(SchematicSystem.PREFIX + "§7Alle Spieler wurden von der Schematic entfernt");
} }
@Register("togglepublic") @Register("delallmember")
public void delAllMember(Player player, SteamwarUser target) {
SteamwarUser user = getUser(player);
int i = 0;
for (NodeMember nodeMember : NodeMember.getSchematics(target.getId())) {
SchematicNode node = SchematicNode.getSchematicNode(nodeMember.getNode());
if (node.getOwner() == user.getId()) {
nodeMember.delete();
i++;
}
}
player.sendMessage(SchematicSystem.PREFIX + "§e" + target.getUserName() + " §7wurde von §e" + i + " §7Schematics entfernt");
}
@Register(value = "togglepublic", noTabComplete = true)
public void togglePublicMode(Player player) { public void togglePublicMode(Player player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if (!user.getUserGroup().isAdminGroup()) { if (!user.getUserGroup().isAdminGroup()) {

Datei anzeigen

@ -26,7 +26,6 @@ import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class SchematicCommandHelp { public class SchematicCommandHelp {
private SchematicCommandHelp() { private SchematicCommandHelp() {
} }
@ -69,6 +68,7 @@ public class SchematicCommandHelp {
"§8/§7schem §eaddmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Fügt einen Spieler zu einer Schematic hinzu", "§8/§7schem §eaddmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Fügt einen Spieler zu einer Schematic hinzu",
"§8/§7schem §edelmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic", "§8/§7schem §edelmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic",
"§8/§7schem §eclearmember §8[§7Schematic§8] - §7Entfernt alle Spieler von der Schematic", "§8/§7schem §eclearmember §8[§7Schematic§8] - §7Entfernt alle Spieler von der Schematic",
"§8/§7schem §edelallmember §8[§7Spieler§8] - §7Entfernt einen Spieler von allen deinen Schematics",
"§8/§7schem §eaddteam §8[§7Schematic§8] - §7Füge jeden aus deinem Team auf die Schematic hinzu", "§8/§7schem §eaddteam §8[§7Schematic§8] - §7Füge jeden aus deinem Team auf die Schematic hinzu",
"§8/§7schem §edelteam §8[§7Schematic§8] - §7Entferne jeden aus deinem Team von der Schematic" "§8/§7schem §edelteam §8[§7Schematic§8] - §7Entferne jeden aus deinem Team von der Schematic"
}); });

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;
@ -49,7 +50,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) {
@ -73,7 +75,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;
} }
@ -259,7 +261,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)));
@ -315,6 +317,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;
@ -334,6 +344,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;
@ -345,6 +360,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;
@ -355,7 +375,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.");
} }

Datei anzeigen

@ -5,5 +5,6 @@ depend: [SpigotCore, WorldEdit]
main: de.steamwar.schematicsystem.SchematicSystem main: de.steamwar.schematicsystem.SchematicSystem
website: steamwar.de website: steamwar.de
api-version: "1.13" api-version: "1.13"
description: Schematic-Frontend
commands: commands: