Search Pageination #113
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.schematicsystem.commands;
|
||||
|
||||
import de.steamwar.inventory.*;
|
||||
import de.steamwar.schematicsystem.SafeSchematicNode;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.sql.*;
|
||||
import org.bukkit.Material;
|
||||
@ -46,18 +47,19 @@ public class GUI {
|
||||
inv.setItem(49, Material.AIR, "", clickType -> {});
|
||||
} else {
|
||||
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.open();
|
||||
}
|
||||
|
||||
private static void info(Player player, SchematicNode node) {
|
||||
private static void info(Player player, SchematicNode node, SchematicSelector back) {
|
||||
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()) {
|
||||
inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), "§eLaden", click -> {
|
||||
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.isDir() && node.getSchemtype().writeable()){
|
||||
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
|
||||
@ -79,16 +85,14 @@ public class GUI {
|
||||
}
|
||||
Material mat = SWItem.getMaterial(node.getItem());
|
||||
|
||||
inv.setItem(2, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
|
||||
player.closeInventory();
|
||||
changeItem(player, node);
|
||||
inv.setItem(5, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
|
||||
changeItem(player, node, back);
|
||||
});
|
||||
if(!node.isDir()) {
|
||||
inv.setItem(3, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
|
||||
player.closeInventory();
|
||||
inv.setItem(6, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), node.getSchemtype().fightType(), click -> {
|
||||
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();
|
||||
SchematicCommandUtils.download(player, node);
|
||||
});
|
||||
@ -99,45 +103,50 @@ public class GUI {
|
||||
delmembers(player, node);
|
||||
});
|
||||
skull.setName("§eMitglieder");
|
||||
inv.setItem(5, skull);
|
||||
inv.setItem(6, Material.ARROW, "§eVerschieben", clickType -> {
|
||||
inv.setItem(8, skull);
|
||||
inv.setItem(15, Material.ARROW, "§eVerschieben", clickType -> {
|
||||
SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectDirectory(), npar -> {
|
||||
node.setParent(npar==null?null:npar.getId());
|
||||
info(player, SchematicNode.getSchematicNode(node.getId()));
|
||||
SafeSchematicNode.Result result = SafeSchematicNode.setParent(user, node, npar);
|
||||
if(result.isSuccessful()) {
|
||||
info(player, SchematicNode.getSchematicNode(node.getId()), back);
|
||||
} else {
|
||||
result.sendError(player);
|
||||
}
|
||||
});
|
||||
selector.open();
|
||||
});
|
||||
Material finalMat = mat;
|
||||
inv.setItem(7, Material.NAME_TAG, "§eUmbenennen", clickType -> {
|
||||
inv.setItem(16, Material.NAME_TAG, "§eUmbenennen", clickType -> {
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(player, node.getName() + " umbenennen", node.getName());
|
||||
anvilInv.setItem(finalMat);
|
||||
anvilInv.setItem(mat);
|
||||
anvilInv.setCallback(s -> {
|
||||
if (!invalidSchemName(player, new String[]{s})) {
|
||||
node.setName(s);
|
||||
SafeSchematicNode.Result result = SafeSchematicNode.setName(user, node, s);
|
||||
if(result.isSuccessful()) {
|
||||
info(player, node, back);
|
||||
} else {
|
||||
result.sendError(player);
|
||||
}
|
||||
info(player, node);
|
||||
});
|
||||
anvilInv.open();
|
||||
});
|
||||
inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cLöschen", click -> {
|
||||
player.closeInventory();
|
||||
delete(player, node);
|
||||
inv.setItem(17, SWItem.getDye(1), (byte) 1, "§cLöschen", click -> {
|
||||
delete(player, node, back);
|
||||
});
|
||||
}else{
|
||||
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());
|
||||
SWItem skull = SWItem.getPlayerSkull(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 -> {
|
||||
player.closeInventory();
|
||||
delete(player, node);
|
||||
if(NodeMember.getNodeMember(node.getId(), user.getId()) != null) {
|
||||
inv.setItem(17, SWItem.getDye(1), (byte) 1, "§cZugriff entfernen", click -> {
|
||||
delete(player, node, back);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
inv.setCallback(-999, click -> player.closeInventory());
|
||||
inv.open();
|
||||
@ -164,21 +173,27 @@ public class GUI {
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void deleteOwn(Player p, SchematicNode schem){
|
||||
private static void deleteOwn(Player p, SchematicNode schem, SchematicSelector back){
|
||||
SteamwarUser user = getUser(p);
|
||||
SWInventory inv = new SWInventory(p, 9, schem.generateBreadcrumbs(user) + " löschen");
|
||||
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> {
|
||||
schem.delete();
|
||||
|
||||
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.setCallback(-999, click -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void deleteMembership(Player p, SchematicNode schem){
|
||||
private static void deleteMembership(Player p, SchematicNode schem, SchematicSelector back){
|
||||
SteamwarUser user = getUser(p);
|
||||
SWInventory inv = new SWInventory(p, 9, schem.generateBreadcrumbs(user) + " entfernen");
|
||||
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eZugriff entfernen", click -> {
|
||||
@ -186,18 +201,24 @@ public class GUI {
|
||||
if(member != null)
|
||||
member.delete();
|
||||
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.setCallback(-999, click -> p.closeInventory());
|
||||
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())
|
||||
deleteOwn(p, schem);
|
||||
deleteOwn(p, schem, back);
|
||||
else
|
||||
deleteMembership(p, schem);
|
||||
deleteMembership(p, schem, back);
|
||||
}
|
||||
|
||||
static void delmembers(Player p, SchematicNode schem){
|
||||
@ -216,11 +237,11 @@ public class GUI {
|
||||
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 -> {
|
||||
schem.setItem(material.name());
|
||||
p.closeInventory();
|
||||
info(p, schem);
|
||||
info(p, schem, back);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ 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.SafeSchematicNode;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.sql.*;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
@ -55,6 +57,9 @@ public class SchematicCommand extends SWCommand {
|
||||
Class<?> clazz = Material.class;
|
||||
searchMapper.put("-item", SWCommandUtils.createEnumMapper((Class<Enum<?>>) clazz));
|
||||
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() {
|
||||
@ -147,11 +152,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 +211,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;
|
||||
@ -295,6 +316,21 @@ public class SchematicCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
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++;
|
||||
}
|
||||
@ -397,7 +433,11 @@ public class SchematicCommand extends SWCommand {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDas gibt nur Fehler, vertrau mir.");
|
||||
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");
|
||||
}
|
||||
@ -412,7 +452,11 @@ public class SchematicCommand extends SWCommand {
|
||||
if (invalidSchemName(player, new String[]{name})) {
|
||||
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));
|
||||
}
|
||||
|
||||
@ -475,7 +519,21 @@ public class SchematicCommand extends SWCommand {
|
||||
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) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (!user.getUserGroup().isAdminGroup()) {
|
||||
|
@ -26,7 +26,6 @@ import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class 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 §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 §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 §edelteam §8[§7Schematic§8] - §7Entferne jeden aus deinem Team von der Schematic"
|
||||
});
|
||||
|
@ -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;
|
||||
@ -49,7 +50,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) {
|
||||
@ -73,7 +75,7 @@ public class SchematicCommandUtils {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen");
|
||||
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");
|
||||
return true;
|
||||
}
|
||||
@ -259,7 +261,7 @@ public class SchematicCommandUtils {
|
||||
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.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)));
|
||||
@ -315,6 +317,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;
|
||||
@ -334,6 +344,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;
|
||||
@ -345,6 +360,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;
|
||||
@ -355,7 +375,7 @@ public class SchematicCommandUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!type.isAssignable()) {
|
||||
if (!type.isAssignable()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cZu diesem Typen können keine Schematics geändert werden.");
|
||||
}
|
||||
|
||||
|
@ -5,5 +5,6 @@ depend: [SpigotCore, WorldEdit]
|
||||
main: de.steamwar.schematicsystem.SchematicSystem
|
||||
website: steamwar.de
|
||||
api-version: "1.13"
|
||||
description: Schematic-Frontend
|
||||
|
||||
commands:
|
In neuem Issue referenzieren
Einen Benutzer sperren