From 6f65ef6c3cb577213eb39769c4faf2ec735c337a Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 20 Aug 2020 19:54:58 +0200 Subject: [PATCH] Implementation of deleting access to schem Signed-off-by: Lixfel --- .../schematicsystem/commands/GUI.java | 28 ++++++++++++++++++- .../commands/SchematicCommand.java | 5 ---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java index 48ccd64..8eb529a 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java @@ -38,7 +38,7 @@ class GUI { inv.open(); } - static void delete(Player p, Schematic schem){ + private static void deleteOwn(Player p, Schematic schem){ SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " löschen"); inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> { schem.remove(); @@ -57,6 +57,27 @@ class GUI { inv.open(); } + private static void deleteMembership(Player p, Schematic schem){ + SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " entfernen"); + inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eZugriff entfernen", click -> { + schem.remove(); + SchematicMember member = SchematicMember.getSchemMemberFromDB(schem.getSchemName(), schem.getSchemID(), SteamwarUser.get(p.getUniqueId()).getId()); + member.remove(); + p.sendMessage(SchematicSystem.PREFIX + "Zugriff zu Schematic §e" + schem.getSchemName() + " §7entfernt"); + p.closeInventory(); + }); + inv.setItem(8, SWItem.getDye(14), (byte) 14, "§cAbbruch", click -> p.closeInventory()); + inv.setCallback(-999, click -> p.closeInventory()); + inv.open(); + } + + static void delete(Player p, Schematic schem){ + if(SteamwarUser.get(p.getUniqueId()).getId() == schem.getSchemOwner()) + deleteOwn(p, schem); + else + deleteMembership(p, schem); + } + static void delmembers(Player p, Schematic schem){ List> members = new LinkedList<>(); for(SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())){ @@ -146,6 +167,11 @@ class GUI { headmeta.setDisplayName("§7von §e" + owneruser.getUserName()); owner.setItemMeta(headmeta); inv.setItem(6, owner); + + inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cZugriff entfernen", click -> { + p.closeInventory(); + delete(p, schem); + }); } inv.setCallback(-999, click -> p.closeInventory()); diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index 945b1e8..61633e3 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -162,11 +162,6 @@ public class SchematicCommand implements CommandExecutor { if(schematic == null) return; - if(SteamwarUser.get(player.getUniqueId()).getId() != schematic.getSchemOwner()){ - player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nur deine eigenen Schematics löschen"); - return; - } - GUI.delete(player, schematic); } -- 2.39.5