mirror of
https://github.com/songoda/UltimateStacker.git
synced 2025-01-25 00:31:21 +01:00
fix
This commit is contained in:
parent
40ae065e7f
commit
c15a80f66b
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user