From d5e7f82c5b70c4dc3aa55d64457edc301dbba32b Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 24 Dec 2020 09:42:56 +0100 Subject: [PATCH] Improve GUI --- SpigotCore_14/src/de/steamwar/inventory/SWItem_14.java | 2 ++ .../src/de/steamwar/inventory/SWListInv.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/SpigotCore_14/src/de/steamwar/inventory/SWItem_14.java b/SpigotCore_14/src/de/steamwar/inventory/SWItem_14.java index f1438fb..ae1d5ef 100644 --- a/SpigotCore_14/src/de/steamwar/inventory/SWItem_14.java +++ b/SpigotCore_14/src/de/steamwar/inventory/SWItem_14.java @@ -27,6 +27,8 @@ class SWItem_14 { private SWItem_14(){} static Material getMaterial(String material) { + if("CAULDRON_ITEM".equals(material)) + return Material.CAULDRON; try{ return Material.valueOf(material); }catch(IllegalArgumentException e){ diff --git a/SpigotCore_Main/src/de/steamwar/inventory/SWListInv.java b/SpigotCore_Main/src/de/steamwar/inventory/SWListInv.java index f43ffd8..107a3b2 100644 --- a/SpigotCore_Main/src/de/steamwar/inventory/SWListInv.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SWListInv.java @@ -33,6 +33,7 @@ public class SWListInv extends SWInventory { private final List> elements; private final Map customItems = new HashMap<>(); + private final boolean dynamicSize; private ListCallback callback; private int page; private boolean opened = false; @@ -46,6 +47,7 @@ public class SWListInv extends SWInventory { callback = c; elements = l; page = 0; + this.dynamicSize = dynamicSize; } @Override @@ -55,7 +57,7 @@ public class SWListInv extends SWInventory { callbacks.clear(); setCallback(-999, (ClickType click) -> player.closeInventory()); - if(elements.size() > 54){ + if(sizeBiggerMax()){ if(page != 0) setItem(45, SWItem.getDye(10), (byte)10, "§eSeite zurück", (ClickType click) -> { page--; @@ -73,7 +75,7 @@ public class SWListInv extends SWInventory { } int ipageLimit = elements.size() - page*45; - if(ipageLimit > 45 && elements.size() > 54){ + if(ipageLimit > 45 && sizeBiggerMax()){ ipageLimit = 45; } int i = page*45; @@ -133,6 +135,10 @@ public class SWListInv extends SWInventory { } return schemList; } + + private boolean sizeBiggerMax(){ + return dynamicSize ? elements.size() > 45 : elements.size() > 54; + } private static int dynamicSize(int size){ return (size>45) ? 54 : (size + 9-size%9); -- 2.39.5