mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-08 03:21:32 +01:00
Added blacklist/ability to hide holograms for blacklisted items.
This commit is contained in:
parent
e401ffeb9c
commit
16548d8922
@ -5,6 +5,7 @@ import com.songoda.ultimatestacker.utils.Methods;
|
||||
import com.songoda.ultimatestacker.utils.ServerVersion;
|
||||
import com.songoda.ultimatestacker.utils.settings.Setting;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -39,10 +40,8 @@ public class ItemListeners implements Listener {
|
||||
int specific = instance.getItemFile().getConfig().getInt("Items." + itemStack.getType().name() + ".Max Stack Size");
|
||||
int max = specific == -1 && new ItemStack(itemStack.getType()).getMaxStackSize() != 1 ? maxItemStackSize : specific;
|
||||
|
||||
List<String> whitelist = Setting.ITEM_WHITELIST.getStringList();
|
||||
if (!whitelist.isEmpty() && !whitelist.contains(itemStack.getType().name())) {
|
||||
if (Methods.isMaterialBlacklisted(itemStack.getType()))
|
||||
max = new ItemStack(itemStack.getType()).getMaxStackSize();
|
||||
}
|
||||
|
||||
if (max == -1) max = 1;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.songoda.ultimatestacker.utils;
|
||||
|
||||
import com.songoda.lootables.loot.Drop;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.utils.settings.Setting;
|
||||
import org.bukkit.*;
|
||||
@ -14,7 +13,10 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class Methods {
|
||||
@ -41,6 +43,13 @@ public class Methods {
|
||||
Methods.updateItemAmount(item, itemStack, amount);
|
||||
}
|
||||
|
||||
public static boolean isMaterialBlacklisted(Material type) {
|
||||
List<String> whitelist = Setting.ITEM_WHITELIST.getStringList();
|
||||
List<String> blacklist = Setting.ITEM_BLACKLIST.getStringList();
|
||||
return !whitelist.isEmpty() && !whitelist.contains(type.name())
|
||||
|| !blacklist.isEmpty() && blacklist.contains(type.name());
|
||||
}
|
||||
|
||||
public static void updateItemAmount(Item item, ItemStack itemStack, int newAmount) {
|
||||
UltimateStacker plugin = UltimateStacker.getInstance();
|
||||
Material material = itemStack.getType();
|
||||
@ -55,12 +64,13 @@ public class Methods {
|
||||
itemStack.setAmount(newAmount);
|
||||
}
|
||||
|
||||
if (plugin.getItemFile().getConfig().getBoolean("Items." + material + ".Has Hologram")
|
||||
&& Setting.ITEM_HOLOGRAMS.getBoolean()) {
|
||||
if (newAmount == 1 && !Setting.ITEM_HOLOGRAM_SINGLE.getBoolean()) return;
|
||||
item.setCustomName(name);
|
||||
item.setCustomNameVisible(true);
|
||||
}
|
||||
if ((isMaterialBlacklisted(itemStack.getType()) && !Setting.ITEM_HOLOGRAM_BLACKLIST.getBoolean())
|
||||
|| !plugin.getItemFile().getConfig().getBoolean("Items." + material + ".Has Hologram")
|
||||
|| !Setting.ITEM_HOLOGRAMS.getBoolean()
|
||||
|| newAmount == 1 && !Setting.ITEM_HOLOGRAM_SINGLE.getBoolean()) return;
|
||||
|
||||
item.setCustomName(name);
|
||||
item.setCustomNameVisible(true);
|
||||
}
|
||||
|
||||
public static int getActualItemAmount(Item item) {
|
||||
|
@ -142,6 +142,9 @@ public enum Setting {
|
||||
"Should holograms be displayed above items when there is only a single",
|
||||
"item in the stack?"),
|
||||
|
||||
ITEM_HOLOGRAM_BLACKLIST("Items.Show Holograms For Blacklisted Items", true,
|
||||
"Should items that are blacklisted display holograms?"),
|
||||
|
||||
MAX_STACK_ITEMS("Items.Max Stack Size", 512,
|
||||
"The max stack size for items.",
|
||||
"Currently this can only be set to a max of 120."),
|
||||
@ -154,10 +157,17 @@ public enum Setting {
|
||||
"This is added only because it looks smoother in game. This is only visual and",
|
||||
"doesn't actually effect the item."),
|
||||
|
||||
ITEM_BLACKLIST("Items.Blacklist", Collections.singletonList("EGG"),
|
||||
"Items included in this list will stack to normal amounts.",
|
||||
"Material list: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html",
|
||||
"Leave this empty by using \"blacklist: []\" if you do not wish to disable",
|
||||
"stacking for any items."),
|
||||
|
||||
ITEM_WHITELIST("Items.Whitelist", new ArrayList(),
|
||||
"Items included in this whitelist will be stacked.",
|
||||
"Material list: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html",
|
||||
"Leave this empty by using \"whitelist: []\" if you want everything to be stacked."),
|
||||
"Leave this empty by using \"whitelist: []\" if you want everything to be stacked.",
|
||||
"Items not in this list will act as if they are blacklisted."),
|
||||
|
||||
SHOW_STACK_SIZE_SINGLE("Items.Show Stack Size For Single", false,
|
||||
"When enabled stack sizes for a stack with a single item will",
|
||||
|
Loading…
Reference in New Issue
Block a user