Add error messages #129
@ -19,12 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.schematicsystem.commands;
|
package de.steamwar.schematicsystem.commands;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import de.steamwar.inventory.*;
|
import de.steamwar.inventory.*;
|
||||||
import de.steamwar.schematicsystem.SafeSchematicNode;
|
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.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
@ -26,6 +26,8 @@ import de.steamwar.providers.BauServerInfo;
|
|||||||
import de.steamwar.schematicsystem.SafeSchematicNode;
|
import de.steamwar.schematicsystem.SafeSchematicNode;
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.*;
|
||||||
|
import lombok.extern.log4j.Log4j;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
@ -45,11 +47,13 @@ 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.*;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
@SuppressWarnings("unused")
|
@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<>();
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
searchMapper.put("-type", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new)));
|
searchMapper.put("-type", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new)));
|
||||||
searchMapper.put("-owner", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s)));
|
searchMapper.put("-owner", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s)));
|
||||||
@ -83,33 +87,36 @@ public class SchematicCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register("list")
|
@Register("list")
|
||||||
@Register({"list", "/"})
|
@Register({"list", "/"})
|
||||||
public void schemList(Player player, @OptionalValue("1") int page) {
|
public void schemList(Player player, @OptionalValue(value = "1", onlyUINIG = true) int page) {
|
||||||
|
log.info("list / page \"{}\"", page);
|
||||||
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(getUser(player).getId(), 0), Math.max(page - 1, 0), null, SchematicListBehavior.DEFAULT);
|
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(getUser(player).getId(), 0), Math.max(page - 1, 0), null, SchematicListBehavior.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register({"list", "public"})
|
@Register({"list", "public"})
|
||||||
public void schemListPublic(Player player, @Validator("isDirValidator") @Mapper("publicDirMapper") SchematicNode node, @OptionalValue("1") int page) {
|
public void schemListPublic(Player player, @Validator("isDirValidator") @Mapper("publicDirMapper") SchematicNode node, @OptionalValue("1") int page) {
|
||||||
|
log.info("list public \"{}\" page \"{}\"", node.generateBreadcrumbs(getUser(player)), page);
|
||||||
schemList(player, node, page);
|
schemList(player, node, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register({"list", "public"})
|
@Register({"list", "public"})
|
||||||
@Register({"list", "public", "/"})
|
@Register({"list", "public", "/"})
|
||||||
public void schemListPublic(Player player, @OptionalValue("1") int page) {
|
public void schemListPublic(Player player, @OptionalValue(value = "1", onlyUINIG = true) int page) {
|
||||||
|
log.info("list public \"/\" page \"{}\"", page);
|
||||||
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(0, 0), Math.max(page - 1, 0), null, SchematicListBehavior.builder().setPublics(true).setPageCommandGen(integer -> "/schem list public " + integer).build());
|
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(0, 0), Math.max(page - 1, 0), null, SchematicListBehavior.builder().setPublics(true).setPageCommandGen(integer -> "/schem list public " + integer).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Register({"info", "public"})
|
|
||||||
public void schemInfoPublic(Player player, @Validator("isDirValidator") @Mapper("publicMapper") SchematicNode node) {
|
|
||||||
schemInfo(player, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register("list")
|
@Register("list")
|
||||||
public void schemList(Player player, @Validator("isDirValidator") @Mapper("dirMapper") SchematicNode node, @OptionalValue("1") int page) {
|
public void schemList(Player player, @Validator("isDirValidator") @Mapper("dirMapper") SchematicNode node, @OptionalValue("1") int page) {
|
||||||
|
log.info("list \"{}\" page \"{}\"", node.generateBreadcrumbs(getUser(player)), page);
|
||||||
SteamwarUser user = getUser(player);
|
SteamwarUser user = getUser(player);
|
||||||
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());
|
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({"info", "public"})
|
||||||
|
public void schemInfoPublic(Player player, @Validator("isDirValidator") @Mapper("publicMapper") SchematicNode node) {
|
||||||
|
schemInfo(player, node);
|
||||||
|
}
|
||||||
|
|
||||||
@Register({"l", "public"})
|
@Register({"l", "public"})
|
||||||
@Register({"load", "public"})
|
@Register({"load", "public"})
|
||||||
public void loadSchemPublic(Player player, @Validator("isSchemValidator") @Mapper("publicMapper") SchematicNode node) {
|
public void loadSchemPublic(Player player, @Validator("isSchemValidator") @Mapper("publicMapper") SchematicNode node) {
|
||||||
@ -713,7 +720,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
|
|
||||||
private boolean nodeNullCheck(AbstractValidator.MessageSender messageSender, SchematicNode node) {
|
private boolean nodeNullCheck(AbstractValidator.MessageSender messageSender, SchematicNode node) {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
messageSender.send("COMMAND_LIST_INVALID_NODE");
|
messageSender.send("COMMAND_INVALID_NODE");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren