Remove Code Duplication
Dieser Commit ist enthalten in:
Ursprung
8ab93315ce
Commit
a51f03826c
@ -162,6 +162,18 @@ public class Kit {
|
||||
public void preview(Player player){
|
||||
SWInventory inv = new SWInventory(player, 54, name);
|
||||
|
||||
preview(inv, inventory, armor, effects);
|
||||
|
||||
inv.setCallback(-999, (click) -> player.closeInventory());
|
||||
inv.setItem(45, SWItem.getDye(10), (byte)10, "§aKit wählen", (click) -> {
|
||||
Commands.kit(player, name);
|
||||
player.closeInventory();
|
||||
});
|
||||
inv.setItem(53, SWItem.getDye(1), (byte)1, "§cZurück", (click) -> GUI.kitSelection(player));
|
||||
inv.open();
|
||||
}
|
||||
|
||||
public static void preview(SWInventory inv, ItemStack[] inventory, ItemStack[] armor, Collection<PotionEffect> effects) {
|
||||
//36 = Inventargröße
|
||||
for(int i = 0; i < 36; i++){
|
||||
if(inventory[i] == null)
|
||||
@ -191,13 +203,5 @@ public class Kit {
|
||||
pos--;
|
||||
}
|
||||
}
|
||||
|
||||
inv.setCallback(-999, (click) -> player.closeInventory());
|
||||
inv.setItem(45, SWItem.getDye(10), (byte)10, "§aKit wählen", (click) -> {
|
||||
Commands.kit(player, name);
|
||||
player.closeInventory();
|
||||
});
|
||||
inv.setItem(53, SWItem.getDye(1), (byte)1, "§cZurück", (click) -> GUI.kitSelection(player));
|
||||
inv.open();
|
||||
}
|
||||
}
|
||||
|
@ -99,24 +99,7 @@ public class PersonalKitCreator extends BasicListener {
|
||||
public static void preview(Player player, PersonalKit kit){
|
||||
SWInventory inv = new SWInventory(player, 54, kit.getName());
|
||||
|
||||
//36 = Inventargröße
|
||||
for(int i = 0; i < 36; i++){
|
||||
if(kit.getInventory()[i] == null)
|
||||
continue;
|
||||
SWItem item = new SWItem();
|
||||
item.setItemStack(kit.getInventory()[i]);
|
||||
inv.setItem(i, item);
|
||||
}
|
||||
|
||||
if(kit.getArmor() != null){
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(kit.getArmor()[i] == null)
|
||||
continue;
|
||||
SWItem item = new SWItem();
|
||||
item.setItemStack(kit.getArmor()[i]);
|
||||
inv.setItem(36 + i, item);
|
||||
}
|
||||
}
|
||||
Kit.preview(inv, kit.getInventory(), kit.getArmor(), null);
|
||||
|
||||
inv.setItem(45, Material.LEATHER_CHESTPLATE, "§aKit benutzen", clickType -> useKit(player, kit));
|
||||
inv.setItem(49, SWItem.getMaterial("WOOD_AXE"), "§7Kit bearbeiten", clickType -> openKitCreator(player, kit));
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren