From 1423f864c6128b2de8b75037ea73288f198ecc76 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 21 Jul 2022 12:24:38 +0200 Subject: [PATCH 1/4] Hotfix: Error Messages --- .../src/de/steamwar/schematicsystem/SafeSchematicNode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java index a91ce52..ec0c117 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java @@ -79,7 +79,7 @@ public class SafeSchematicNode { NOT_OWNER; public void sendError(Player player) { - SchematicSystem.MESSAGE.send("SAFE_SCHEMATIC_NODE_" + this.name(), player); + SchematicSystem.MESSAGE.send("SAFE_NODE_" + this.name(), player); } public boolean isSuccessful() { From 1f9d04c8ae7fa8bc95094b964170ac7ba3b4d4e0 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 5 Aug 2022 12:58:24 +0200 Subject: [PATCH 2/4] Download Command --- .../src/SchematicSystem.properties | 3 + .../src/SchematicSystem_de.properties | 3 + .../schematicsystem/SchematicSystem.java | 3 +- .../commands/DownloadCommand.java | 65 +++++++++++++++++++ .../commands/SchematicCommandHelp.java | 3 +- 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java diff --git a/SchematicSystem_Core/src/SchematicSystem.properties b/SchematicSystem_Core/src/SchematicSystem.properties index 23e437a..c5bb454 100644 --- a/SchematicSystem_Core/src/SchematicSystem.properties +++ b/SchematicSystem_Core/src/SchematicSystem.properties @@ -144,6 +144,7 @@ HELP_VIEW_3=§8/§7schem §elist public §8- §7Shows all public schematics HELP_VIEW_4=§8/§7schem §esearch §8[§7keyword§8] - §7Searches for matching schematics HELP_VIEW_5=§8/§7schem §eload §8[§7schematic§8] - §7Loads a schematic HELP_VIEW_6=§8/§7schem §edownload §8[§7schematic§8] - §7Gives you a download link (valid for 1 min) +HELP_VIEW_7=§8/§7download §8- §7Gives you a download link for your current Clipboard (valid for 1 min) HELP_EDIT=Save & Edit HELP_EDIT_HOVER=Modification of schematics and folders HELP_EDIT_1=§8/§7schem §esave §8[§7schematic§8] - §7Saves your clipboard as a schematic @@ -210,3 +211,5 @@ SAFE_NODE_NOT_A_DIR=§cThe selected Schematic is not a folder SAFE_NODE_ALREADY_IN_DIRECTORY=§cThe schematic is already available in this folder SAFE_NODE_INVALID_NAME=§cThis name is illegal SAFE_NODE_NOT_OWNER=§cYou are not the owner of this schematic + +DOWNLOAD_ERROR=§cAn error occurred while uploading the schematic diff --git a/SchematicSystem_Core/src/SchematicSystem_de.properties b/SchematicSystem_Core/src/SchematicSystem_de.properties index 7f7e534..9846864 100644 --- a/SchematicSystem_Core/src/SchematicSystem_de.properties +++ b/SchematicSystem_Core/src/SchematicSystem_de.properties @@ -131,6 +131,7 @@ HELP_VIEW_3=§8/§7schem §elist public §8- §7Zeigt alle Public-Schematics HELP_VIEW_4=§8/§7schem §esearch §8[§7Stichwort§8] - §7Sucht nach passenden Schematics HELP_VIEW_5=§8/§7schem §eload §8[§7Schematic§8] - §7Lädt eine Schematic HELP_VIEW_6=§8/§7schem §edownload §8[§7Schematic§8] - §7Gibt dir einen Downloadlink (1 min gültig) +HELP_VIEW_7=§8/§7download §8- §7Gibt dir einen Downloadlink von deinem Clipboard (1 min gültig) HELP_EDIT=Speichern & Bearbeiten HELP_EDIT_HOVER=Modifizierung von Schematics und Ordnern HELP_EDIT_1=§8/§7schem §esave §8[§7Schematic§8] - §7Speichert dein Clipboard als Schematic @@ -193,3 +194,5 @@ SAFE_NODE_NOT_A_DIR=§cDie ausgewählte Schematic ist kein Ordner SAFE_NODE_ALREADY_IN_DIRECTORY=§cDie Schematic gibt es bereits in diesem Ordner SAFE_NODE_INVALID_NAME=§cDieser Name ist unzulässig SAFE_NODE_NOT_OWNER=§cDu bist nicht der Besitzer dieser Schematic + +DOWNLOAD_ERROR=§cFehler beim Hochladen deines Clipboards diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java index 8cec6d8..844fc99 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java @@ -19,8 +19,8 @@ package de.steamwar.schematicsystem; -import de.steamwar.core.Core; import de.steamwar.message.Message; +import de.steamwar.schematicsystem.commands.DownloadCommand; import de.steamwar.schematicsystem.commands.SchematicCommand; import org.bukkit.plugin.java.JavaPlugin; @@ -34,6 +34,7 @@ public class SchematicSystem extends JavaPlugin { instance = this; new SchematicCommand(); + new DownloadCommand(); } public static SchematicSystem getInstance() { diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java new file mode 100644 index 0000000..62ca934 --- /dev/null +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java @@ -0,0 +1,65 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +package de.steamwar.schematicsystem.commands; + +import de.steamwar.command.SWCommand; +import de.steamwar.schematicsystem.SchematicSystem; +import de.steamwar.sql.NoClipboardException; +import de.steamwar.sql.SchematicNode; +import de.steamwar.sql.SchematicType; +import de.steamwar.sql.SteamwarUser; +import org.bukkit.entity.Player; + +import java.io.IOException; + +public class DownloadCommand extends SWCommand { + public DownloadCommand() { + super("download", "/download"); + } + + @Register(help = true) + public void genericCommand(Player player, String... args) { + SteamwarUser user = SteamwarUser.get(player); + SchematicNode copyNode = SchematicNode.getSchematicNode(user.getId(), "/copy", 0); + boolean newSchem = false; + if(copyNode == null) { + copyNode = SchematicNode.createSchematicNode(user.getId(), "/copy", 0, SchematicType.Normal.toDB(), ""); + newSchem = true; + } + + try { + copyNode.saveFromPlayer(player); + } catch (IOException e) { + SchematicSystem.MESSAGE.send("DOWNLOAD_ERROR", player); + if(newSchem) { + copyNode.delete(); + } + throw new SecurityException(e); + } catch (NoClipboardException e) { + SchematicSystem.MESSAGE.send("COMMAND_SAVE_CLIPBOARD_EMPTY", player); + if(newSchem) { + copyNode.delete(); + } + return; + } + + SchematicCommandUtils.download(player, copyNode); + } +} diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandHelp.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandHelp.java index fc2dc0d..f843dfc 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandHelp.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommandHelp.java @@ -55,7 +55,8 @@ public class SchematicCommandHelp { "HELP_VIEW_3", "HELP_VIEW_4", "HELP_VIEW_5", - "HELP_VIEW_6" + "HELP_VIEW_6", + "HELP_VIEW_7" }), BEARBEITUNG("HELP_EDIT", "HELP_EDIT_HOVER", new String[]{ "HELP_EDIT_1", From 5fda841f27782dca77001c8f8dbfadcfbcaf4914 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 5 Aug 2022 12:58:38 +0200 Subject: [PATCH 3/4] Wrong name --- .../de/steamwar/schematicsystem/commands/DownloadCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java index 62ca934..08e8ea3 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java @@ -37,10 +37,10 @@ public class DownloadCommand extends SWCommand { @Register(help = true) public void genericCommand(Player player, String... args) { SteamwarUser user = SteamwarUser.get(player); - SchematicNode copyNode = SchematicNode.getSchematicNode(user.getId(), "/copy", 0); + SchematicNode copyNode = SchematicNode.getSchematicNode(user.getId(), "//copy", 0); boolean newSchem = false; if(copyNode == null) { - copyNode = SchematicNode.createSchematicNode(user.getId(), "/copy", 0, SchematicType.Normal.toDB(), ""); + copyNode = SchematicNode.createSchematicNode(user.getId(), "//copy", 0, SchematicType.Normal.toDB(), ""); newSchem = true; } From 996303b97a7838b6de8c7f39db45b4f792d750c2 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 5 Aug 2022 13:40:44 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=E2=80=9ESchematicSystem=5FCore/src/Schemat?= =?UTF-8?q?icSystem.properties=E2=80=9C=20=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SchematicSystem_Core/src/SchematicSystem.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SchematicSystem_Core/src/SchematicSystem.properties b/SchematicSystem_Core/src/SchematicSystem.properties index c5bb454..bb175b7 100644 --- a/SchematicSystem_Core/src/SchematicSystem.properties +++ b/SchematicSystem_Core/src/SchematicSystem.properties @@ -144,7 +144,7 @@ HELP_VIEW_3=§8/§7schem §elist public §8- §7Shows all public schematics HELP_VIEW_4=§8/§7schem §esearch §8[§7keyword§8] - §7Searches for matching schematics HELP_VIEW_5=§8/§7schem §eload §8[§7schematic§8] - §7Loads a schematic HELP_VIEW_6=§8/§7schem §edownload §8[§7schematic§8] - §7Gives you a download link (valid for 1 min) -HELP_VIEW_7=§8/§7download §8- §7Gives you a download link for your current Clipboard (valid for 1 min) +HELP_VIEW_7=§8/§7download §8- §7Gives you a download link for your current clipboard (valid for 1 min) HELP_EDIT=Save & Edit HELP_EDIT_HOVER=Modification of schematics and folders HELP_EDIT_1=§8/§7schem §esave §8[§7schematic§8] - §7Saves your clipboard as a schematic