Schemnodes Schematic System #93
@ -19,15 +19,9 @@
|
|||||||
|
|
||||||
package de.steamwar.schematicsystem.commands;
|
package de.steamwar.schematicsystem.commands;
|
||||||
|
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.*;
|
||||||
import de.steamwar.inventory.SWInventory;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
|
||||||
import de.steamwar.inventory.SWListInv;
|
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.*;
|
||||||
import de.steamwar.util.SchematicSelector;
|
|
||||||
import de.steamwar.util.SchematicSelectorInjectable;
|
|
||||||
import de.steamwar.util.UtilGui;
|
|
||||||
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;
|
||||||
|
@ -22,8 +22,10 @@ package de.steamwar.schematicsystem.commands;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.comms.packets.PrepareSchemPacket;
|
import de.steamwar.comms.packets.PrepareSchemPacket;
|
||||||
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import de.steamwar.inventory.SchematicSelector;
|
||||||
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;
|
||||||
@ -34,6 +36,7 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
|
|||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -165,6 +168,24 @@ public class SchematicCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Register("save")
|
||||||
|
@Register("s")
|
||||||
|
public void saveSchem(Player player) {
|
||||||
|
SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectSchematicNode(), schematicNode -> {
|
||||||
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
if(schematicNode.isDir()) {
|
||||||
|
SWAnvilInv anvilInv = new SWAnvilInv(player, "Namen eingeben");
|
||||||
|
anvilInv.setCallback(s -> saveSchem(player, schematicNode.generateBreadcrumbs(user) + s));
|
||||||
|
anvilInv.setItem(Material.CAULDRON);
|
||||||
|
anvilInv.open();
|
||||||
|
} else {
|
||||||
|
saveSchem(player, schematicNode.generateBreadcrumbs(user));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
selector.setSingleDirOpen(false);
|
||||||
|
selector.open();
|
||||||
|
}
|
||||||
|
|
||||||
@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) {
|
||||||
@ -355,7 +376,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type.writeable()) {
|
if (type.writeable()) {
|
||||||
node.setType(type.toDB());
|
node.setSchemtype(type);
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§aSchematictyp geändert");
|
player.sendMessage(SchematicSystem.PREFIX + "§aSchematictyp geändert");
|
||||||
} else if (type.fightType()) {
|
} else if (type.fightType()) {
|
||||||
if (node.getSchemtype().check()) {
|
if (node.getSchemtype().check()) {
|
||||||
@ -552,7 +573,6 @@ public class SchematicCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final TypeMapper<SchematicNode> schematicCommandTypeMapper = nodeTypeMapper();
|
|
||||||
private final TypeMapper<SchematicNode> publicCommandTypeMapper = publicNodeTypeMapper();
|
private final TypeMapper<SchematicNode> publicCommandTypeMapper = publicNodeTypeMapper();
|
||||||
|
|
||||||
@Mapper("publicMapper")
|
@Mapper("publicMapper")
|
||||||
@ -560,7 +580,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
return new TypeMapper<SchematicNode>() {
|
return new TypeMapper<SchematicNode>() {
|
||||||
@Override
|
@Override
|
||||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||||
return getNodeTabcomplete(SteamwarUser.get(0), strings, s);
|
return SchematicNode.getNodeTabcomplete(SteamwarUser.get(0), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -575,7 +595,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
return new TypeMapper<NodeMember>() {
|
return new TypeMapper<NodeMember>() {
|
||||||
@Override
|
@Override
|
||||||
public NodeMember map(CommandSender commandSender, String[] previousArguments, String s) {
|
public NodeMember map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
SchematicNode node = schematicCommandTypeMapper.map(commandSender, previousArguments, previousArguments[previousArguments.length - 1]);
|
SchematicNode node = SchematicNode.getNodeFromPath(getUser((Player) commandSender), previousArguments[previousArguments.length - 1]);
|
||||||
SteamwarUser user = SteamwarUser.get(s);
|
SteamwarUser user = SteamwarUser.get(s);
|
||||||
return NodeMember.getNodeMember(node.getId(), user.getId());
|
return NodeMember.getNodeMember(node.getId(), user.getId());
|
||||||
}
|
}
|
||||||
@ -583,7 +603,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
SchematicNode node = schematicCommandTypeMapper.map(commandSender, strings, strings[strings.length - 1]);
|
SchematicNode node = SchematicNode.getNodeFromPath(getUser((Player) commandSender), strings[strings.length - 1]);
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -598,14 +618,14 @@ public class SchematicCommand extends SWCommand {
|
|||||||
return new TypeMapper<SchematicNode>() {
|
return new TypeMapper<SchematicNode>() {
|
||||||
@Override
|
@Override
|
||||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||||
List<String> list = schematicCommandTypeMapper.tabCompletes(commandSender, strings, s);
|
List<String> list = SchematicNode.getNodeTabcomplete(getUser((Player) commandSender), s);
|
||||||
list.removeIf(s1 -> !s1.endsWith("/"));
|
list.removeIf(s1 -> !s1.endsWith("/"));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
|
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
SchematicNode result = schematicCommandTypeMapper.map(commandSender, previousArguments, s);
|
SchematicNode result = SchematicNode.getNodeFromPath(getUser((Player) commandSender), s);
|
||||||
if (result == null || !result.isDir()) {
|
if (result == null || !result.isDir()) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
@ -642,7 +662,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
return new TypeMapper<String>() {
|
return new TypeMapper<String>() {
|
||||||
@Override
|
@Override
|
||||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||||
List<String> list = getNodeTabcomplete(getUser((Player) commandSender), strings, s);
|
List<String> list = SchematicNode.getNodeTabcomplete(getUser((Player) commandSender), s);
|
||||||
list.removeIf(s1 -> !s1.endsWith("/"));
|
list.removeIf(s1 -> !s1.endsWith("/"));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -654,21 +674,6 @@ public class SchematicCommand extends SWCommand {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassMapper(SchematicNode.class)
|
|
||||||
public TypeMapper<SchematicNode> nodeTypeMapper() {
|
|
||||||
return new TypeMapper<SchematicNode>() {
|
|
||||||
@Override
|
|
||||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
|
||||||
return getNodeTabcomplete(getUser((Player) commandSender), strings, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
|
|
||||||
return SchematicNode.getNodeFromPath(getUser((Player) commandSender), s);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@ClassMapper(SchematicType.class)
|
@ClassMapper(SchematicType.class)
|
||||||
public TypeMapper<SchematicType> typeTypeMapper() {
|
public TypeMapper<SchematicType> typeTypeMapper() {
|
||||||
return new TypeMapper<SchematicType>() {
|
return new TypeMapper<SchematicType>() {
|
||||||
|
@ -61,7 +61,7 @@ public class SchematicCommandHelp {
|
|||||||
}),
|
}),
|
||||||
BEARBEITUNG("Bearbeitungsbefehle", "Modifizierung von Schematics und Ordnern", new String[]{
|
BEARBEITUNG("Bearbeitungsbefehle", "Modifizierung von Schematics und Ordnern", new String[]{
|
||||||
"§8/§eschem save §8[§7Schematic§8] - §7Speichert dein Clipboard als Schematic",
|
"§8/§eschem save §8[§7Schematic§8] - §7Speichert dein Clipboard als Schematic",
|
||||||
"§8/§eschem mkdir §8[§7Ordner§8] - §7Erstelle einen Leeren Ordner",
|
"§8/§eschem ordner §8[§7Ordner§8] - §7Erstelle einen Leeren Ordner",
|
||||||
"§8/§eschem move §8[§7Schematic§8] [§7Neuer Pfad§8] - §7Verschiebe eine Schematic",
|
"§8/§eschem move §8[§7Schematic§8] [§7Neuer Pfad§8] - §7Verschiebe eine Schematic",
|
||||||
"§8/§eschem rename §8[§7Schematic§8] [§7Neuer Name§8] - §7Gib der Schematic einen neuen Namen",
|
"§8/§eschem rename §8[§7Schematic§8] [§7Neuer Name§8] - §7Gib der Schematic einen neuen Namen",
|
||||||
"§8/§eschem changetype §8[§7Schematic§8] - §7Ändert die Art deiner Schematic",
|
"§8/§eschem changetype §8[§7Schematic§8] - §7Ändert die Art deiner Schematic",
|
||||||
|
@ -40,26 +40,6 @@ public class SchematicCommandUtils {
|
|||||||
private SchematicCommandUtils() {
|
private SchematicCommandUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getNodeTabcomplete(SteamwarUser user, String[] strings, String s) {
|
|
||||||
List<String> list = new ArrayList<>();
|
|
||||||
boolean sws = s.startsWith("/");
|
|
||||||
if (sws) {
|
|
||||||
s = s.substring(1);
|
|
||||||
}
|
|
||||||
if (s.contains("/")) {
|
|
||||||
String preTab = s.substring(0, s.lastIndexOf("/") + 1);
|
|
||||||
SchematicNode pa = SchematicNode.getNodeFromPath(user, preTab);
|
|
||||||
if (pa == null) return Collections.emptyList();
|
|
||||||
List<SchematicNode> nodes = SchematicNode.getSchematicNodeInNode(pa);
|
|
||||||
nodes.forEach(node -> list.add((sws ? "/" : "") + node.generateBreadcrumbs(user)));
|
|
||||||
} else {
|
|
||||||
List<SchematicNode> nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0);
|
|
||||||
nodes.forEach(node -> list.add((sws ? "/" : "") + node.getName() + (node.isDir() ? "/" : "")));
|
|
||||||
}
|
|
||||||
list.remove("//copy");
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean invalidSchemName(Player player, String[] layers) {
|
public static boolean invalidSchemName(Player player, String[] layers) {
|
||||||
for (String layer : layers) {
|
for (String layer : layers) {
|
||||||
if (layer.isEmpty()) {
|
if (layer.isEmpty()) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren