This commit is contained in:
Brianna O'Keefe 2018-11-10 01:02:59 -05:00
parent 40ae065e7f
commit c15a80f66b
2 changed files with 7 additions and 8 deletions

View File

@ -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();

View File

@ -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();
}