Merge remote-tracking branch 'origin/development' into development

This commit is contained in:
Brianna 2019-08-23 12:31:03 -04:00
commit e21515bda5
3 changed files with 18 additions and 3 deletions

View File

@ -4,7 +4,7 @@ stages:
variables:
name: "UltimateStacker"
path: "/builds/$CI_PROJECT_PATH"
version: "1.9.4"
version: "1.9.5"
build:
stage: build

View File

@ -6,6 +6,7 @@ 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.Server;
import org.bukkit.Sound;
import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler;
@ -41,7 +42,10 @@ 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;
if (Methods.isMaterialBlacklisted(itemStack.getType()))
if (instance.isServerVersionAtLeast(ServerVersion.V1_13) && Methods.isMaterialBlacklisted(itemStack.getType()))
max = new ItemStack(itemStack.getType()).getMaxStackSize();
if (!instance.isServerVersionAtLeast(ServerVersion.V1_13) && Methods.isMaterialBlacklisted(itemStack.getType(), itemStack.getData().getData()))
max = new ItemStack(itemStack.getType()).getMaxStackSize();
if (max == -1) max = 1;

View File

@ -88,13 +88,24 @@ public class Methods {
|| !blacklist.isEmpty() && blacklist.contains(type.name());
}
public static boolean isMaterialBlacklisted(Material type, byte data) {
List<String> whitelist = Setting.ITEM_WHITELIST.getStringList();
List<String> blacklist = Setting.ITEM_BLACKLIST.getStringList();
String combined = type.toString() + ":" + data;
return !whitelist.isEmpty() && !whitelist.contains(combined)
|| !blacklist.isEmpty() && blacklist.contains(combined);
}
public static void updateItemAmount(Item item, ItemStack itemStack, int newAmount) {
UltimateStacker plugin = UltimateStacker.getInstance();
Material material = itemStack.getType();
String name = Methods.convertToInvisibleString("IS") +
compileItemName(itemStack, newAmount);
boolean blacklisted = isMaterialBlacklisted(itemStack.getType());
boolean blacklisted = UltimateStacker.getInstance().isServerVersionAtLeast(ServerVersion.V1_13) ?
isMaterialBlacklisted(itemStack.getType()) : isMaterialBlacklisted(itemStack.getType(), itemStack.getData().getData());
if (newAmount > 32 && !blacklisted) {
item.setMetadata("US_AMT", new FixedMetadataValue(plugin, newAmount));