13
0

Add error messages #129

Zusammengeführt
Chaoscaot hat 4 Commits von cmd_framework_update nach master 2022-08-22 18:44:17 +02:00 zusammengeführt
4 geänderte Dateien mit 106 neuen und 84 gelöschten Zeilen
Nur Änderungen aus Commit 8642eb4564 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -82,7 +82,10 @@ UTIL_SUBMIT_DIRECT_DONE=§aThe Schematic will be reviewed in a timely manner
UTIL_SUBMIT_EXTEND=§eExtend Schematic UTIL_SUBMIT_EXTEND=§eExtend Schematic
UTIL_SUBMIT_EXTEND_DONE=§aThe preparation server is starting UTIL_SUBMIT_EXTEND_DONE=§aThe preparation server is starting
COMMAND_NOT_FOLDER=This is a schematic and not a folder COMMAND_INVALID_NODE=§cInvalid Schematic
COMMAND_NOT_OWN=§cYou can only use this command on your own Schematic
COMMAND_MUST_DIR=§cYou can only use this command on a directory
COMMAND_MUST_SCHEM=§cYou can only use this command on a Schematic
COMMAND_ENTER_NAME=Insert name COMMAND_ENTER_NAME=Insert name
COMMAND_PUNISHMENT_NO_SAVE_EXTERNAL=§cYou can not make schematics on other build server COMMAND_PUNISHMENT_NO_SAVE_EXTERNAL=§cYou can not make schematics on other build server
COMMAND_PUNISHMENT_NO_SAVE=§cSchematics cannot be made on this build COMMAND_PUNISHMENT_NO_SAVE=§cSchematics cannot be made on this build
@ -94,7 +97,6 @@ COMMAND_SAVE_ERROR=§cError while saving the Schematic
COMMAND_SAVE_DONE=Schematic §e{0} §7stored COMMAND_SAVE_DONE=Schematic §e{0} §7stored
COMMAND_SAVE_OVERWRITE=Schematic §e{0} §7overwritten COMMAND_SAVE_OVERWRITE=Schematic §e{0} §7overwritten
COMMAND_ADD_PUNISH=§cYou may not add anyone to your schematics: §f§l{0} COMMAND_ADD_PUNISH=§cYou may not add anyone to your schematics: §f§l{0}
COMMAND_ADD_NOT_OWNER=§cYou can only add someone to your own stuff
COMMAND_ADD_USER_PUNISHED=§c{0} must not be added to schematics COMMAND_ADD_USER_PUNISHED=§c{0} must not be added to schematics
COMMAND_ADD_OWN=§cSo please: This is your own Schematic! COMMAND_ADD_OWN=§cSo please: This is your own Schematic!
COMMAND_ADD_PUBLIC=§cFor public requests please contact the moderator COMMAND_ADD_PUBLIC=§cFor public requests please contact the moderator
@ -103,7 +105,6 @@ COMMAND_ADD_ADDED=You now have access to the Schematic §e{0} §7of §e{1}
COMMAND_ADD_NONE=§cNo player has been added COMMAND_ADD_NONE=§cNo player has been added
COMMAND_ADD_ONE=§7The player §e{0} was added to the schematic COMMAND_ADD_ONE=§7The player §e{0} was added to the schematic
COMMAND_ADD_MANY=§7The players §e{0} were added to the schematic COMMAND_ADD_MANY=§7The players §e{0} were added to the schematic
COMMAND_DELMEM_NOT_OWN=§cYou can only remove someone on your own stuff
COMMAND_DELMEM_DONE=The player §e{0} §7no longer has access to the Schematic §e{1} COMMAND_DELMEM_DONE=The player §e{0} §7no longer has access to the Schematic §e{1}
COMMAND_DELMEM_DELETED=§cYou now no longer have access to the Schematic §e{0} §7of §e{1} COMMAND_DELMEM_DELETED=§cYou now no longer have access to the Schematic §e{0} §7of §e{1}
COMMAND_SEARCH_NOT_A_PLAYER=§cThe player §e{0} §cdoes not exists COMMAND_SEARCH_NOT_A_PLAYER=§cThe player §e{0} §cdoes not exists
@ -111,20 +112,14 @@ COMMAND_LOCKREPLAY=Replays of fights with {0} can no longer be viewed from now o
COMMAND_REPLACE_COLOR_OFF=In fights {0} pink blocks are not replaced COMMAND_REPLACE_COLOR_OFF=In fights {0} pink blocks are not replaced
COMMAND_REPLACE_COLOR_ON=In fights {0} pink blocks are replaced COMMAND_REPLACE_COLOR_ON=In fights {0} pink blocks are replaced
COMMAND_DIR_DONE=§7Directory §e{0} §7created COMMAND_DIR_DONE=§7Directory §e{0} §7created
COMMAND_CHANGE_TYPE_NOT_OWNER=§cYou can only submit your own schematics
COMMAND_CHANGE_TYPE_SELECT=§eSelect type COMMAND_CHANGE_TYPE_SELECT=§eSelect type
COMMAND_MOVE_NOT_OWN=§cYou can only move your own shematics
COMMAND_MOVE_RECURSIVE=§cThis only gives mistakes, trust me COMMAND_MOVE_RECURSIVE=§cThis only gives mistakes, trust me
COMMAND_MOVE_DONE=§7The schematic can now be found under §e{0} COMMAND_MOVE_DONE=§7The schematic can now be found under §e{0}
COMMAND_RENAME_NOT_OWN=§cYou can only do that with your own schematics
COMMAND_RENAME_DONE=§7The schematic is now called §e{0} COMMAND_RENAME_DONE=§7The schematic is now called §e{0}
COMMAND_ADD_TEAM_NOT_OWN=§cYou can only do that with your own schematics
COMMAND_ADD_TEAM_NOT_IN_TEAM=§cYou are not in any team COMMAND_ADD_TEAM_NOT_IN_TEAM=§cYou are not in any team
COMMAND_DEL_TEAM_NOT_OWN=§cYou can only do that with your own schematics
COMMAND_DEL_TEAM_NOT_IN_TEAM=§cYou are not in any team COMMAND_DEL_TEAM_NOT_IN_TEAM=§cYou are not in any team
COMMAND_DEL_TEAM_NONE=§7No player was removed COMMAND_DEL_TEAM_NONE=§7No player was removed
COMMAND_DEL_TEAM_DONE=§7The player §e{0} §7were removed from the Schematic COMMAND_DEL_TEAM_DONE=§7The player §e{0} §7were removed from the Schematic
COMMAND_CLEAR_MEMBER_NOT_OWN=§cYou can only do that with your own schematics
COMMAND_CLEAR_MEMBER_DONE=§7All players were removed from the Schematic COMMAND_CLEAR_MEMBER_DONE=§7All players were removed from the Schematic
COMMAND_DEL_ALL_MEMBER=§e{0} §7has been removed from §e{1} §7Schematics COMMAND_DEL_ALL_MEMBER=§e{0} §7has been removed from §e{1} §7Schematics
COMMAND_PUBLIC_ON=§aYou are now the public user COMMAND_PUBLIC_ON=§aYou are now the public user

Datei anzeigen

@ -69,7 +69,10 @@ UTIL_SUBMIT_DIRECT_DONE=§aDie Schematic wird zeitnah überprüft
UTIL_SUBMIT_EXTEND=§eSchematic ausfahren UTIL_SUBMIT_EXTEND=§eSchematic ausfahren
UTIL_SUBMIT_EXTEND_DONE=§aDer Vorbereitungsserver wird gestartet UTIL_SUBMIT_EXTEND_DONE=§aDer Vorbereitungsserver wird gestartet
COMMAND_NOT_FOLDER=Das ist eine Schematic und kein Ordner COMMAND_INVALID_NODE=§cDie Schematic konnte nicht gefunden werden
COMMAND_NOT_OWN=§cDas darfst du nur bei deinen eigenen Schematics machen
COMMAND_MUST_DIR=§cDu musst einen Ordner angeben
COMMAND_MUST_SCHEM=§cDu musst eine Schematic angeben
COMMAND_ENTER_NAME=Namen eingeben COMMAND_ENTER_NAME=Namen eingeben
COMMAND_PUNISHMENT_NO_SAVE_EXTERNAL=§cDu kannst nicht auf anderen Baus Schematics machen COMMAND_PUNISHMENT_NO_SAVE_EXTERNAL=§cDu kannst nicht auf anderen Baus Schematics machen
COMMAND_PUNISHMENT_NO_SAVE=§cAuf diesem Bau können keine Schematics gemacht werden COMMAND_PUNISHMENT_NO_SAVE=§cAuf diesem Bau können keine Schematics gemacht werden
@ -81,7 +84,6 @@ COMMAND_SAVE_ERROR=§cFehler beim Speichern der Schematic
COMMAND_SAVE_DONE=Schematic §e{0} §7gespeichert COMMAND_SAVE_DONE=Schematic §e{0} §7gespeichert
COMMAND_SAVE_OVERWRITE=Schematic §e{0} §7überschrieben COMMAND_SAVE_OVERWRITE=Schematic §e{0} §7überschrieben
COMMAND_ADD_PUNISH=§cDu darfst niemanden auf deine Schematics hinzufügen: §f§l{0} COMMAND_ADD_PUNISH=§cDu darfst niemanden auf deine Schematics hinzufügen: §f§l{0}
COMMAND_ADD_NOT_OWNER=§cDu kannst nur auf deine eigenen Sachen jemanden hinzufügen
COMMAND_ADD_USER_PUNISHED=§c{0} darf nicht auf Schematics hinzugefügt werden COMMAND_ADD_USER_PUNISHED=§c{0} darf nicht auf Schematics hinzugefügt werden
COMMAND_ADD_OWN=§cAlso bitte: Das ist deine eigene Schematic! COMMAND_ADD_OWN=§cAlso bitte: Das ist deine eigene Schematic!
COMMAND_ADD_PUBLIC=§cFür Public-Anträge bitte bei der Moderation melden COMMAND_ADD_PUBLIC=§cFür Public-Anträge bitte bei der Moderation melden
@ -90,7 +92,6 @@ COMMAND_ADD_ADDED=Du hast nun Zugriff auf die Schematic §e{0} §7von §e{1}
COMMAND_ADD_NONE=§cEs wurde kein Spieler hinzugefügt COMMAND_ADD_NONE=§cEs wurde kein Spieler hinzugefügt
COMMAND_ADD_ONE=§7Der Spieler §e{0} wurde auf die Schematic hinzugefügt COMMAND_ADD_ONE=§7Der Spieler §e{0} wurde auf die Schematic hinzugefügt
COMMAND_ADD_MANY=§7Die Spieler §e{0} wurden auf die Schematic hinzugefügt COMMAND_ADD_MANY=§7Die Spieler §e{0} wurden auf die Schematic hinzugefügt
COMMAND_DELMEM_NOT_OWN=§cDu kannst nur auf deine eigenen Sachen jemanden entfernen
COMMAND_DELMEM_DONE=Der Spieler §e{0} §7hat nun keinen Zugriff mehr auf die Schematic §e{1} COMMAND_DELMEM_DONE=Der Spieler §e{0} §7hat nun keinen Zugriff mehr auf die Schematic §e{1}
COMMAND_DELMEM_DELETED=§cDu hast nun keinen Zugriff mehr auf die Schematic §e{0} §7von §e{1} COMMAND_DELMEM_DELETED=§cDu hast nun keinen Zugriff mehr auf die Schematic §e{0} §7von §e{1}
COMMAND_SEARCH_NOT_A_PLAYER=§cDer Spieler §e{0} §cexistiert nicht COMMAND_SEARCH_NOT_A_PLAYER=§cDer Spieler §e{0} §cexistiert nicht
@ -98,20 +99,14 @@ COMMAND_LOCKREPLAY=Replays von Kämpfen mit {0} können ab sofort nicht mehr bet
COMMAND_REPLACE_COLOR_OFF=In Kämpfen {0} werden pinke Blöcke nicht ersetzt COMMAND_REPLACE_COLOR_OFF=In Kämpfen {0} werden pinke Blöcke nicht ersetzt
COMMAND_REPLACE_COLOR_ON=In Kämpfen {0} werden pinke Blöcke ersetzt COMMAND_REPLACE_COLOR_ON=In Kämpfen {0} werden pinke Blöcke ersetzt
COMMAND_DIR_DONE=§7Ordner §e{0} §7erstellt COMMAND_DIR_DONE=§7Ordner §e{0} §7erstellt
COMMAND_CHANGE_TYPE_NOT_OWNER=§cDu kannst nur deine eigenen Schematics einsenden
COMMAND_CHANGE_TYPE_SELECT=§eTyp auswählen COMMAND_CHANGE_TYPE_SELECT=§eTyp auswählen
COMMAND_MOVE_NOT_OWN=§cDu kannst nur deine eigenen Schems verschieben
COMMAND_MOVE_RECURSIVE=§cDas gibt nur Fehler, vertrau mir COMMAND_MOVE_RECURSIVE=§cDas gibt nur Fehler, vertrau mir
COMMAND_MOVE_DONE=§7Die Schematic ist nun unter §e{0} §7zu finden COMMAND_MOVE_DONE=§7Die Schematic ist nun unter §e{0} §7zu finden
COMMAND_RENAME_NOT_OWN=§cDas kannst du nur bei deinen eigenen Schems machen
COMMAND_RENAME_DONE=§7Die Schematic heist nun §e{0} COMMAND_RENAME_DONE=§7Die Schematic heist nun §e{0}
COMMAND_ADD_TEAM_NOT_OWN=§cDas kannst du nur bei deinen eigenen Schems machen
COMMAND_ADD_TEAM_NOT_IN_TEAM=§cDu bist in keinem Team COMMAND_ADD_TEAM_NOT_IN_TEAM=§cDu bist in keinem Team
COMMAND_DEL_TEAM_NOT_OWN=§cDas kannst du nur bei deinen eigenen Schems machen
COMMAND_DEL_TEAM_NOT_IN_TEAM=§cDu bist in keinem Team COMMAND_DEL_TEAM_NOT_IN_TEAM=§cDu bist in keinem Team
COMMAND_DEL_TEAM_NONE=§7Es wurde kein Spieler entfernt COMMAND_DEL_TEAM_NONE=§7Es wurde kein Spieler entfernt
COMMAND_DEL_TEAM_DONE=§7Der Spieler §e{0} §7wurden von der Schematic entfernt COMMAND_DEL_TEAM_DONE=§7Der Spieler §e{0} §7wurden von der Schematic entfernt
COMMAND_CLEAR_MEMBER_NOT_OWN=§cDas kannst du nur bei deinen eigenen Schems machen
COMMAND_CLEAR_MEMBER_DONE=§7Alle Spieler wurden von der Schematic entfernt COMMAND_CLEAR_MEMBER_DONE=§7Alle Spieler wurden von der Schematic entfernt
COMMAND_DEL_ALL_MEMBER=§e{0} §7wurde von §e{1} §7Schematics entfernt COMMAND_DEL_ALL_MEMBER=§e{0} §7wurde von §e{1} §7Schematics entfernt
COMMAND_PUBLIC_ON=§aDu bist nun der Public User COMMAND_PUBLIC_ON=§aDu bist nun der Public User

Datei anzeigen

@ -19,10 +19,7 @@
package de.steamwar.schematicsystem.commands; package de.steamwar.schematicsystem.commands;
import de.steamwar.command.AbstractTypeMapper; import de.steamwar.command.*;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
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.providers.BauServerInfo;
@ -48,6 +45,7 @@ import java.util.stream.Collectors;
import static de.steamwar.schematicsystem.commands.SchematicCommandHelp.*; import static de.steamwar.schematicsystem.commands.SchematicCommandHelp.*;
import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.*; import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.*;
@SuppressWarnings("unused")
public class SchematicCommand extends SWCommand { public class SchematicCommand extends SWCommand {
private static final Map<String, AbstractTypeMapper<CommandSender, ?>> searchMapper = new HashMap<>(); private static final Map<String, AbstractTypeMapper<CommandSender, ?>> searchMapper = new HashMap<>();
@ -65,6 +63,7 @@ public class SchematicCommand extends SWCommand {
public SchematicCommand() { public SchematicCommand() {
super("schematic", Bukkit.getPluginManager().getPlugin("Teamserver") == null ? new String[] {"schem", "/schem", "/schematic"} : new String[]{"schem"}); super("schematic", Bukkit.getPluginManager().getPlugin("Teamserver") == null ? new String[] {"schem", "/schem", "/schematic"} : new String[]{"schem"});
setMessage(SchematicSystem.MESSAGE);
} }
@Register("help") @Register("help")
@ -89,7 +88,7 @@ public class SchematicCommand extends SWCommand {
} }
@Register({"list", "public"}) @Register({"list", "public"})
public void schemListPublic(Player player, @Mapper("publicDirMapper") SchematicNode node, @OptionalValue("1") int page) { public void schemListPublic(Player player, @Validator("isDirValidator") @Mapper("publicDirMapper") SchematicNode node, @OptionalValue("1") int page) {
schemList(player, node, page); schemList(player, node, page);
} }
@ -101,34 +100,30 @@ public class SchematicCommand extends SWCommand {
@Register({"info", "public"}) @Register({"info", "public"})
public void schemInfoPublic(Player player, @Mapper("publicMapper") SchematicNode node) { public void schemInfoPublic(Player player, @Validator("isDirValidator") @Mapper("publicMapper") SchematicNode node) {
schemInfo(player, node); schemInfo(player, node);
} }
@Register("list") @Register("list")
public void schemList(Player player, @Mapper("dirMapper") SchematicNode node, @OptionalValue("1") int page) { public void schemList(Player player, @Validator("isDirValidator") @Mapper("dirMapper") SchematicNode node, @OptionalValue("1") int page) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
if (!node.isDir()) { renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), Math.max(page - 1, 0), node, SchematicListBehavior.builder().setPublics(node.getOwner() == 0).setPageCommandGen(value -> "/schem list " + (node.getOwner()==0?"public ":"") + node.generateBreadcrumbs(user) + " " + value).build());
SchematicSystem.MESSAGE.send("COMMAND_NOT_FOLDER", player);
} else {
renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), Math.max(page - 1, 0), node, SchematicListBehavior.builder().setPublics(node.getOwner() == 0).setPageCommandGen(value -> "/schem list " + (node.getOwner()==0?"public ":"") + node.generateBreadcrumbs(user) + " " + value).build());
}
} }
@Register({"l", "public"}) @Register({"l", "public"})
@Register({"load", "public"}) @Register({"load", "public"})
public void loadSchemPublic(Player player, @Mapper("publicMapper") SchematicNode node) { public void loadSchemPublic(Player player, @Validator("isSchemValidator") @Mapper("publicMapper") SchematicNode node) {
loadSchem(player, node); loadSchem(player, node);
} }
@Register("info") @Register("info")
public void schemInfo(Player player, SchematicNode node) { public void schemInfo(Player player, @ErrorMessage("COMMAND_INVALID_NODE") SchematicNode node) {
printSchemInfo(player, node); printSchemInfo(player, node);
} }
@Register("l") @Register("l")
@Register("load") @Register("load")
public void loadSchem(Player player, SchematicNode node) { public void loadSchem(Player player, @Validator("isSchemValidator") SchematicNode node) {
SchematicCommandUtils.loadSchem(player, node); SchematicCommandUtils.loadSchem(player, node);
} }
@ -206,15 +201,11 @@ public class SchematicCommand extends SWCommand {
} }
@Register("addmember") @Register("addmember")
public void addMember(Player player, SchematicNode node, SteamwarUser... targets) { public void addMember(Player player, @Validator("isOwnerValidator") SchematicNode node, SteamwarUser... targets) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
if(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> SchematicSystem.MESSAGE.send("COMMAND_ADD_PUNISH", player, punishment.getReason()))) { if(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> SchematicSystem.MESSAGE.send("COMMAND_ADD_PUNISH", player, punishment.getReason()))) {
return; return;
} }
if (node.getOwner() != user.getId()) {
SchematicSystem.MESSAGE.send("COMMAND_ADD_NOT_OWNER", player);
return;
}
List<SteamwarUser> added = new ArrayList<>(); List<SteamwarUser> added = new ArrayList<>();
for (SteamwarUser target: targets) { for (SteamwarUser target: targets) {
if(Punishment.isPunished(target, if(Punishment.isPunished(target,
@ -256,14 +247,8 @@ public class SchematicCommand extends SWCommand {
} }
@Register("delmember") @Register("delmember")
public void delMember(Player player, SchematicNode node, @Mapper("memberMapper") NodeMember member) { public void delMember(Player player, @Validator("isOwnerValidator") SchematicNode node, @Mapper("memberMapper") NodeMember member) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
SchematicSystem.MESSAGE.send("COMMAND_DELMEM_NOT_OWN", player);
return;
}
SteamwarUser target = SteamwarUser.get(member.getMember()); SteamwarUser target = SteamwarUser.get(member.getMember());
List<SchematicNode> nodes = SchematicNode.deepGet(node.getId(), node1 -> node1.getOwner() != user.getId()); List<SchematicNode> nodes = SchematicNode.deepGet(node.getId(), node1 -> node1.getOwner() != user.getId());
@ -358,18 +343,18 @@ public class SchematicCommand extends SWCommand {
} }
@Register("download") @Register("download")
public void download(Player player, SchematicNode node) { public void download(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node) {
SchematicCommandUtils.download(player, node); SchematicCommandUtils.download(player, node);
} }
@Register("lockreplay") @Register("lockreplay")
public void lockreplay(Player player, SchematicNode node) { public void lockreplay(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node) {
node.setAllowReplay(false); node.setAllowReplay(false);
SchematicSystem.MESSAGE.send("COMMAND_LOCKREPLAY", player, node.getName()); SchematicSystem.MESSAGE.send("COMMAND_LOCKREPLAY", player, node.getName());
} }
@Register("replacecolor") @Register("replacecolor")
public void replacecolor(Player player, SchematicNode node) { public void replacecolor(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node) {
boolean state = !node.replaceColor(); boolean state = !node.replaceColor();
node.setReplaceColor(state); node.setReplaceColor(state);
SchematicSystem.MESSAGE.send(state?"COMMAND_REPLACE_COLOR_ON":"COMMAND_REPLACE_COLOR_OFF", player, node.getName()); SchematicSystem.MESSAGE.send(state?"COMMAND_REPLACE_COLOR_ON":"COMMAND_REPLACE_COLOR_OFF", player, node.getName());
@ -389,12 +374,8 @@ public class SchematicCommand extends SWCommand {
} }
@Register("changetype") @Register("changetype")
public void changeType(Player player, SchematicNode node) { public void changeType(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
SchematicSystem.MESSAGE.send("COMMAND_CHANGE_TYPE_NOT_OWNER", player);
return;
}
TextComponent base = new TextComponent(); TextComponent base = new TextComponent();
SchematicType.values().forEach(type -> { SchematicType.values().forEach(type -> {
@ -412,27 +393,23 @@ public class SchematicCommand extends SWCommand {
} }
@Register("changetype") @Register("changetype")
public void changeType(Player player, SchematicNode node, SchematicType type) { public void changeType(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, SchematicType type) {
changeType(player, node, type, null); changeType(player, node, type, null);
} }
@Register("changetype") @Register("changetype")
public void changeType(Player player, SchematicNode node, SchematicType type, Extend extend) { public void changeType(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, SchematicType type, Extend extend) {
SchematicCommandUtils.changeType(player, node, type, extend); SchematicCommandUtils.changeType(player, node, type, extend);
} }
@Register("move") @Register("move")
public void moveToNull(Player player, SchematicNode node) { public void moveToNull(Player player, @Validator("isOwnerValidator") SchematicNode node) {
move(player, node, "/"); move(player, node, "/");
} }
@Register("move") @Register("move")
public void move(Player player, SchematicNode node, @Mapper("dirStringMapper") String name) { public void move(Player player, @Validator("isOwnerValidator") SchematicNode node, @Mapper("dirStringMapper") String name) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
SchematicSystem.MESSAGE.send("COMMAND_MOVE_NOT_OWN", player);
return;
}
if (name.equals("/")) { if (name.equals("/")) {
node.setParent(null); node.setParent(null);
@ -456,12 +433,8 @@ public class SchematicCommand extends SWCommand {
} }
@Register("rename") @Register("rename")
public void rename(Player player, SchematicNode node, String name) { public void rename(Player player, @Validator("isOwnerValidator") SchematicNode node, String name) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
SchematicSystem.MESSAGE.send("COMMAND_RENAME_NOT_OWN", player);
return;
}
if (invalidSchemName(player, new String[]{name})) { if (invalidSchemName(player, new String[]{name})) {
return; return;
} }
@ -474,12 +447,8 @@ public class SchematicCommand extends SWCommand {
} }
@Register("addteam") @Register("addteam")
public void addTeam(Player player, SchematicNode node) { public void addTeam(Player player, @Validator("isOwnerValidator") SchematicNode node) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
SchematicSystem.MESSAGE.send("COMMAND_ADD_TEAM_NOT_OWN", player);
return;
}
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if (team == null) { if (team == null) {
SchematicSystem.MESSAGE.send("COMMAND_ADD_TEAM_NOT_IN_TEAM", player); SchematicSystem.MESSAGE.send("COMMAND_ADD_TEAM_NOT_IN_TEAM", player);
@ -490,12 +459,8 @@ public class SchematicCommand extends SWCommand {
} }
@Register("delteam") @Register("delteam")
public void remTeam(Player player, SchematicNode node) { public void remTeam(Player player, @Validator("isOwnerValidator") SchematicNode node) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
SchematicSystem.MESSAGE.send("COMMAND_DEL_TEAM_NOT_OWN", player);
return;
}
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if (team == null) { if (team == null) {
SchematicSystem.MESSAGE.send("COMMAND_DEL_TEAM_NOT_IN_TEAM", player); SchematicSystem.MESSAGE.send("COMMAND_DEL_TEAM_NOT_IN_TEAM", player);
@ -521,13 +486,7 @@ public class SchematicCommand extends SWCommand {
} }
@Register("clearmember") @Register("clearmember")
public void clearMember(Player player, SchematicNode node) { public void clearMember(Player player, @Validator("isOwnerValidator") SchematicNode node) {
SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
SchematicSystem.MESSAGE.send("COMMAND_CLEAR_MEMBER_NOT_OWN", player);
return;
}
node.getMembers().forEach(NodeMember::delete); node.getMembers().forEach(NodeMember::delete);
SchematicSystem.MESSAGE.send("COMMAND_CLEAR_MEMBER_DONE", player); SchematicSystem.MESSAGE.send("COMMAND_CLEAR_MEMBER_DONE", player);
} }
@ -752,6 +711,79 @@ public class SchematicCommand extends SWCommand {
}; };
} }
private boolean nodeNullCheck(AbstractValidator.MessageSender messageSender, SchematicNode node) {
if (node == null) {
messageSender.send("COMMAND_LIST_INVALID_NODE");
return false;
}
return true;
}
@Validator(value = "isSchemValidator", local = true)
public TypeValidator<SchematicNode> isSchemValidator() {
return (commandSender, schematicNode, messageSender) -> {
if(!nodeNullCheck(messageSender, schematicNode)) {
return false;
}
if(schematicNode.isDir()) {
messageSender.send("COMMAND_MUST_SCHEM");
return false;
}
return true;
};
}
@Validator(value = "isDirValidator", local = true)
public TypeValidator<SchematicNode> isDirValidator() {
return (commandSender, schematicNode, messageSender) -> {
if(!nodeNullCheck(messageSender, schematicNode)) {
return false;
}
if(!schematicNode.isDir()) {
messageSender.send("COMMAND_MUST_DIR");
return false;
}
return true;
};
}
@Validator(value = "isOwnerValidator", local = true)
public TypeValidator<SchematicNode> isOwnerValidator() {
return (commandSender, schematicNode, messageSender) -> {
if(!nodeNullCheck(messageSender, schematicNode)) {
return false;
}
if(schematicNode.getOwner() != SteamwarUser.get((Player) commandSender).getId()) {
messageSender.send("COMMAND_NOT_OWN");
return false;
}
return true;
};
}
@Validator(value = "isOwnerSchematicValidator", local = true)
public TypeValidator<SchematicNode> isOwnerSchematicValidator() {
return (commandSender, schematicNode, messageSender) -> {
if(!nodeNullCheck(messageSender, schematicNode)) {
return false;
}
if(schematicNode.getOwner() != SteamwarUser.get((Player) commandSender).getId()) {
messageSender.send("COMMAND_NOT_OWN");
return false;
}
if(schematicNode.isDir()) {
messageSender.send("COMMAND_MUST_SCHEM");
return false;
}
return true;
};
}
@Override
protected void sendMessage(CommandSender sender, String message, Object[] args) {
SchematicSystem.MESSAGE.send(message, sender, args);
}
enum Extend { enum Extend {
AUSFAHREN, AUSFAHREN,
NORMAL NORMAL

Datei anzeigen

@ -46,7 +46,7 @@ import java.util.stream.Collectors;
public class SchematicCommandUtils { public class SchematicCommandUtils {
private static final int CHUNK_SIZE = 15; public static final int CHUNK_SIZE = 15;
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"));