diff --git a/src/main/java/com/songoda/ultimatestacker/UltimateStacker.java b/src/main/java/com/songoda/ultimatestacker/UltimateStacker.java index 2c366ba..a59b4d9 100644 --- a/src/main/java/com/songoda/ultimatestacker/UltimateStacker.java +++ b/src/main/java/com/songoda/ultimatestacker/UltimateStacker.java @@ -112,11 +112,9 @@ public class UltimateStacker extends JavaPlugin { mobFile.saveConfig(); for (Material value : Material.values()) { - if (!value.isBlock()) { itemFile.getConfig().addDefault("Items." + value.name() + ".Has Hologram", true); itemFile.getConfig().addDefault("Items." + value.name() + ".Max Stack Size", -1); itemFile.getConfig().addDefault("Items." + value.name() + ".Display Name", TextComponent.formatText(value.name().toLowerCase().replace("_", " "), true)); - } } itemFile.getConfig().options().copyDefaults(true); itemFile.saveConfig(); diff --git a/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java b/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java index 283fd76..3a0fa79 100644 --- a/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java +++ b/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java @@ -63,8 +63,11 @@ public class StackingTask extends BukkitRunnable { if (entityO.isCustomNameVisible() && !entityO.getCustomName().contains(TextComponent.convertToInvisibleString("IS")) || item.hasItemMeta() && item.getItemMeta().hasDisplayName()) continue; - if (item.getMaxStackSize() != maxItemStackSize && item.getMaxStackSize() != 1 && (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName())) - setMax(item, false); + int specific = instance.getItemFile().getConfig().getInt("Items." + item.getType().name() + ".Max Stack Size"); + int max = specific == -1 ? maxItemStackSize : specific; + + if (item.getMaxStackSize() != max && item.getMaxStackSize() != 1 && (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName())) + setMax(item, max, false); int size = item.getAmount(); @@ -136,12 +139,10 @@ public class StackingTask extends BukkitRunnable { } } - public ItemStack setMax(ItemStack item, boolean reset) { + public ItemStack setMax(ItemStack item, int max, boolean reset) { try { - int specific = instance.getItemFile().getConfig().getInt("Items." + item.getType().name() + ".Max Stack Size"); - int maxItemStackSize = specific == -1 ? instance.getConfig().getInt("Item.Max Stack Size") : specific; Object objItemStack = methodGetItem.invoke(methodAsNMSCopy.invoke(null, item)); - fieldMaxStackSize.set(objItemStack, reset ? new ItemStack(item.getType()).getMaxStackSize() : maxItemStackSize); + fieldMaxStackSize.set(objItemStack, reset ? new ItemStack(item.getType()).getMaxStackSize() : max); } catch (ReflectiveOperationException e) { e.printStackTrace(); }