From cc144f9be606b9450eaed733d1b9f51247e10f98 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 19 Dec 2019 07:18:11 +0100 Subject: [PATCH] Setting Item and adding option for chat based system --- .../schematicsystem/commands/GUI.java | 2 +- .../commands/SchematicCommand.java | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java index 9d6ba9e..fac69a7 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java @@ -126,7 +126,7 @@ class GUI { p.closeInventory(); changeType(p, schem); }); - inv.setItem(5, SWItem.getMaterial(""), "§eDownload", click -> { + inv.setItem(5, SWItem.getMaterial("MAGENTA_GLAZED_TERRACOTTA"), "§eDownload", click -> { p.closeInventory(); SchematicCommand.download(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 7e00414..cf5bad3 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(type); + } + 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,19 @@ 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!"); @@ -409,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"); }