Many Updates
Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
82fb26592c
Commit
f87bf8d902
@ -19,15 +19,9 @@
|
||||
|
||||
package de.steamwar.schematicsystem.commands;
|
||||
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.steamwar.inventory.*;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
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.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
@ -22,8 +22,10 @@ package de.steamwar.schematicsystem.commands;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.comms.packets.PrepareSchemPacket;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SchematicSelector;
|
||||
import de.steamwar.schematicsystem.AutoCheckResult;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
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.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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("s")
|
||||
public void saveSchem(Player player, @Mapper("dirStringMapper") String name) {
|
||||
@ -355,7 +376,7 @@ public class SchematicCommand extends SWCommand {
|
||||
}
|
||||
|
||||
if (type.writeable()) {
|
||||
node.setType(type.toDB());
|
||||
node.setSchemtype(type);
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§aSchematictyp geändert");
|
||||
} else if (type.fightType()) {
|
||||
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();
|
||||
|
||||
@Mapper("publicMapper")
|
||||
@ -560,7 +580,7 @@ public class SchematicCommand extends SWCommand {
|
||||
return new TypeMapper<SchematicNode>() {
|
||||
@Override
|
||||
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
|
||||
@ -575,7 +595,7 @@ public class SchematicCommand extends SWCommand {
|
||||
return new TypeMapper<NodeMember>() {
|
||||
@Override
|
||||
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);
|
||||
return NodeMember.getNodeMember(node.getId(), user.getId());
|
||||
}
|
||||
@ -583,7 +603,7 @@ public class SchematicCommand extends SWCommand {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
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) {
|
||||
return list;
|
||||
}
|
||||
@ -598,14 +618,14 @@ public class SchematicCommand extends SWCommand {
|
||||
return new TypeMapper<SchematicNode>() {
|
||||
@Override
|
||||
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("/"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
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()) {
|
||||
return null;
|
||||
} else {
|
||||
@ -642,7 +662,7 @@ public class SchematicCommand extends SWCommand {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
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("/"));
|
||||
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)
|
||||
public TypeMapper<SchematicType> typeTypeMapper() {
|
||||
return new TypeMapper<SchematicType>() {
|
||||
|
@ -61,7 +61,7 @@ public class SchematicCommandHelp {
|
||||
}),
|
||||
BEARBEITUNG("Bearbeitungsbefehle", "Modifizierung von Schematics und Ordnern", new String[]{
|
||||
"§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 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",
|
||||
|
@ -40,26 +40,6 @@ public class 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) {
|
||||
for (String layer : layers) {
|
||||
if (layer.isEmpty()) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren