diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java index 48a01d8..43c9797 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java @@ -10,8 +10,7 @@ import de.steamwar.fightsystem.kit.KitManager; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -class Commands { - +public class Commands { private Commands(){} private static void errNoTeam(Player p){ @@ -176,7 +175,7 @@ class Commands { fightTeam.removePlayer(target); } - static void kit(Player p, String kitName){ + public static void kit(Player p, String kitName){ if(checkSetup(p)) return; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/GUI.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/GUI.java index 6f39df1..04b50dd 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/GUI.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/GUI.java @@ -82,10 +82,7 @@ public class GUI { iconList.add(new Pair<>(new SWItem(Material.LEATHER_CHESTPLATE, k.getName(), null, !k.isMemberAllowed(), null), k)); } - SWListInv inv = new SWListInv<>(p, "Kitauswahl", (ClickType click, Kit k) -> { - Commands.kit(p, k.getName()); - p.closeInventory(); - }, iconList); + SWListInv inv = new SWListInv<>(p, "Kitauswahl", (ClickType click, Kit k) -> k.preview(p), iconList); inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.open(); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/kit/Kit.java b/FightSystem_Main/src/de/steamwar/fightsystem/kit/Kit.java index f508ba2..8b03792 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/kit/Kit.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/kit/Kit.java @@ -1,11 +1,16 @@ package de.steamwar.fightsystem.kit; +import de.steamwar.fightsystem.commands.Commands; +import de.steamwar.fightsystem.commands.GUI; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import java.util.Collection; +import java.util.Iterator; import java.util.Objects; public class Kit { @@ -70,4 +75,47 @@ public class Kit { section.set("MemberAllowed", memberAllowed); section.set("Effects", effects); } + + /** + * Opens a kit preview with the options to go back to kit selection or to select the kit. + * @param player + */ + public void preview(Player player){ + SWInventory inv = new SWInventory(player, 54, name); + + //36 = Inventargröße + for(int i = 0; i < 36; i++){ + SWItem item = new SWItem(); + item.setItemStack(inventory[i]); + inv.setItem(i, item); + } + + if(armor != null){ + for(int i = 0; i < 4; i++){ + SWItem item = new SWItem(); + item.setItemStack(armor[i]); + inv.setItem(36 + i, item); + } + } + + if(effects != null){ + Iterator it = effects.iterator(); + int pos = 44; + while(it.hasNext()){ + PotionEffect effect = it.next(); + SWItem item = new SWItem(SWItem.getMaterial("POTION"), effect.getType().getName()); + inv.setItem(pos, item); + pos--; + } + } + + inv.setCallback(-999, (click) -> GUI.kitSelection(player)); + inv.addCloseCallback((click) -> GUI.kitSelection(player)); + inv.setItem(45, SWItem.getDye(10), (byte)10, "§aKit wählen", (click) -> { + Commands.kit(player, name); + player.closeInventory(); + }); + inv.setItem(53, SWItem.getDye(14), (byte)14, "§cZurück", (click) -> GUI.kitSelection(player)); + inv.open(); + } }