13
0

DownloadCommand #124

Zusammengeführt
Chaoscaot hat 3 Commits von dl_command nach master 2022-08-05 14:41:59 +02:00 zusammengeführt
5 geänderte Dateien mit 75 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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

Datei anzeigen

@ -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

Datei anzeigen

@ -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() {

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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);
}
}

Datei anzeigen

@ -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",