diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java index c605b95..fac69a7 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java @@ -126,6 +126,10 @@ class GUI { p.closeInventory(); changeType(p, schem); }); + inv.setItem(5, SWItem.getMaterial("MAGENTA_GLAZED_TERRACOTTA"), "§eDownload", click -> { + p.closeInventory(); + SchematicCommand.download(p, schem); + }); inv.setItem(6, SWItem.getMaterial("SKULL_ITEM"), "§eMitglieder", click -> { p.closeInventory(); delmembers(p, schem); diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index af2ed7c..8014119 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -64,6 +64,9 @@ public class SchematicCommand implements CommandExecutor { case "delmember": delmember(player, args); break; + case "download": + download(player, args); + break; default: help(player); } @@ -281,6 +284,13 @@ public class SchematicCommand implements CommandExecutor { } player.spigot().sendMessage(type); + if(SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())){ + TextComponent download = new TextComponent("§eDownload Schematic"); + download.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eGeneriere Downloadlink"))); + download.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem download " + schematic.getSchemName())); + player.spigot().sendMessage(download); + } + List checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId()); for(int i = checkedSchematics.size() -1; i >= 0; i--) { if(checkedSchematics.get(i).getSchemName().equals(schematic.getSchemName()) && @@ -308,6 +318,28 @@ public class SchematicCommand implements CommandExecutor { } } + private void download(Player player, String[] args){ + if(args.length < 2){ + help(player); + return; + } + + Schematic schematic = getSchem(player, args[1]); + if(schematic == null) + return; + + download(player, schematic); + } + + static void download(Player player, Schematic schematic){ + if(schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()){ + player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!"); + return; + } + + player.sendMessage(DownloadSchematic.getLink(schematic)); + } + private void addmember(Player player, String[] args){ if(args.length < 3){ help(player); @@ -400,6 +432,7 @@ public class SchematicCommand implements CommandExecutor { player.sendMessage("§8/§eschem changetype §8[§7Schematic§8] - §7Ändert die Art deiner Schematic"); player.sendMessage("§8/§eschem delete §8[§7Schematic§8] - §7Löscht eine Schematic"); player.sendMessage("§8/§eschem info §8[§7Schematic§8] - §7Zeigt dir Informationen zur Schematic"); + player.sendMessage("§8/§eschem download §8[§7Schematic§8] - §7Gibt dir einen Downloadlink (1 min gültig)"); player.sendMessage("§8/§eschem addmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Fügt einen Spieler zu einer Schematic hinzu"); player.sendMessage("§8/§eschem delmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic"); }