diff --git a/SchematicSystem_Core/src/SchematicSystem.properties b/SchematicSystem_Core/src/SchematicSystem.properties index 9932bdd..60acc26 100644 --- a/SchematicSystem_Core/src/SchematicSystem.properties +++ b/SchematicSystem_Core/src/SchematicSystem.properties @@ -118,6 +118,8 @@ COMMAND_SAVE_CLIPBOARD_EMPTY=§cYour clipboard is empty COMMAND_SAVE_ERROR=§cError while saving the Schematic COMMAND_SAVE_DONE=Schematic §e{0} §7stored COMMAND_SAVE_OVERWRITE=Schematic §e{0} §7overwritten +COMMAND_SAVE_OVERWRITE_CONFIRM=§cThe Schematic §e{0} §calready exists. Do you want to overwrite it? §e*click* +COMMAND_SAVE_OVERWRITE_CONFIRM_HOVER=§eOverwrite Schematic COMMAND_ADD_PUNISH=§cYou may not add anyone to your schematics: §f§l{0} COMMAND_ADD_USER_PUNISHED=§c{0} must not be added to schematics COMMAND_ADD_OWN=§cSo please: This is your own Schematic! diff --git a/SchematicSystem_Core/src/SchematicSystem_de.properties b/SchematicSystem_Core/src/SchematicSystem_de.properties index 465b0f7..e3c1d9a 100644 --- a/SchematicSystem_Core/src/SchematicSystem_de.properties +++ b/SchematicSystem_Core/src/SchematicSystem_de.properties @@ -103,6 +103,8 @@ COMMAND_SAVE_CLIPBOARD_EMPTY=§cDein Clipboard ist leer COMMAND_SAVE_ERROR=§cFehler beim Speichern der Schematic COMMAND_SAVE_DONE=Schematic §e{0} §7gespeichert COMMAND_SAVE_OVERWRITE=Schematic §e{0} §7überschrieben +COMMAND_SAVE_OVERWRITE_CONFIRM=§cDie Schematic §e{0} §7existiert bereits. Möchtest du sie überschreiben? §e*klick* +COMMAND_SAVE_OVERWRITE_CONFIRM_HOVER=§eSchematic überschreiben COMMAND_ADD_PUNISH=§cDu darfst niemanden auf deine Schematics hinzufügen: §f§l{0} COMMAND_ADD_USER_PUNISHED=§c{0} darf nicht auf Schematics hinzugefügt werden COMMAND_ADD_OWN=§cAlso bitte: Das ist deine eigene Schematic! diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index 1d752f2..84e388e 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -148,11 +148,11 @@ public class SchematicCommand extends SWCommand { SteamwarUser user = SteamwarUser.get(player.getUniqueId()); if(schematicNode == null || schematicNode.isDir()) { SWAnvilInv anvilInv = new SWAnvilInv(player, SchematicSystem.MESSAGE.parse("COMMAND_ENTER_NAME", player)); - anvilInv.setCallback(s -> saveSchem(player, schematicNode==null?s:(schematicNode.generateBreadcrumbs() + s))); + anvilInv.setCallback(s -> saveSchem(player, schematicNode==null?s:(schematicNode.generateBreadcrumbs() + s), true)); anvilInv.setItem(Material.CAULDRON); anvilInv.open(); } else { - saveSchem(player, schematicNode.generateBreadcrumbs()); + saveSchem(player, schematicNode.generateBreadcrumbs(), true); } }); selector.setSingleDirOpen(false); @@ -161,7 +161,7 @@ public class SchematicCommand extends SWCommand { @Register("save") @Register("s") - public void saveSchem(Player player, @Mapper("dirStringMapper") String name) { + public void saveSchem(Player player, @Mapper("stringMapper") String name, @OptionalValue("false") boolean overwrite) { SteamwarUser user = getUser(player); if(BauServerInfo.isBauServer() && BauServerInfo.getOwnerId() != user.getId() && (Punishment.isPunished(user, Punishment.PunishmentType.NoSchemReceiving, punishment -> @@ -187,6 +187,9 @@ public class SchematicCommand extends SWCommand { } else if (!node.getSchemtype().writeable() || node.getOwner() != user.getId()) { SchematicSystem.MESSAGE.send("COMMAND_SAVE_NO_OVERWRITE", player); return; + } else if(!overwrite) { + SchematicSystem.MESSAGE.send("COMMAND_SAVE_OVERWRITE_CONFIRM", player, SchematicSystem.MESSAGE.parse("COMMAND_SAVE_OVERWRITE_CONFIRM_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem s " + name + " true"), node.generateBreadcrumbs()); + return; } } @@ -759,6 +762,21 @@ public class SchematicCommand extends SWCommand { }; } + @Mapper("stringMapper") + public TypeMapper stringMapper() { + return new TypeMapper() { + @Override + public List tabCompletes(CommandSender commandSender, String[] strings, String s) { + return SchematicNode.getNodeTabcomplete(getUser((Player) commandSender), s); + } + + @Override + public String map(CommandSender commandSender, String[] previousArguments, String s) { + return s; + } + }; + } + @ClassMapper(SchematicType.class) public TypeMapper typeTypeMapper() { return new TypeMapper() {