diff --git a/Minepacks/resources/backpacks.yml b/Minepacks/resources/backpacks.yml index 37a558f..e32feea 100644 --- a/Minepacks/resources/backpacks.yml +++ b/Minepacks/resources/backpacks.yml @@ -2,6 +2,7 @@ Items: # Example item that uses a player head BackpackHeadBlue: + Enabled: true # Use player_head if it should be a head with a custom texture. Do not use the id or the head item name of your minecraft version! Material: player_head # The texture value for the head. @@ -15,6 +16,7 @@ Items: - "Right click to open your backpack." - "Drag items on it to place them in your backpack." MinepacksLegacy: + Enabled: true Material: CARROT_STICK # Will set the damage value and unbreakable on MC versions older than 1.14 or the custom_model_data for MC 1.14 and newer Model: 1 diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/BackpacksConfig.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/BackpacksConfig.java index 3955c2a..cb9466d 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/BackpacksConfig.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/BackpacksConfig.java @@ -18,6 +18,7 @@ package at.pcgamingfreaks.Minepacks.Bukkit.Database; import at.pcgamingfreaks.Bukkit.Configuration; +import at.pcgamingfreaks.Bukkit.MCVersion; import at.pcgamingfreaks.Minepacks.Bukkit.Item.ItemConfig; import at.pcgamingfreaks.YamlFileManager; @@ -26,7 +27,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class BackpacksConfig extends Configuration { @@ -39,6 +43,17 @@ public BackpacksConfig(final @NotNull JavaPlugin plugin) loadItemConfigs(); } + @Override + protected boolean newConfigCreated() + { + if(MCVersion.isNewerOrEqualThan(MCVersion.MC_1_14)) + { + getConfigE().set("Items.MinepacksLegacy.Enabled", false); + return true; + } + return super.newConfigCreated(); + } + @Override protected void doUpgrade(@NotNull YamlFileManager oldConfig) { @@ -49,7 +64,9 @@ private void loadItemConfigs() { getYamlE().getKeysFiltered("Items\\.[^.]*\\.Material").forEach(materialKey -> { final String key = materialKey.substring(0, materialKey.length() - ".Material".length()); - try{ + try + { + if(!getConfigE().getBoolean(key + "Enabled", true)) return; final List lore = getConfigE().getStringList(key + ".Lore", new ArrayList<>(0)); final List loreFinal; if(lore.size() == 0) loreFinal = null; diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Item/ItemProducerLegacy.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Item/ItemProducerLegacy.java index 78dcd80..e98d11a 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Item/ItemProducerLegacy.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Item/ItemProducerLegacy.java @@ -33,11 +33,13 @@ private ItemProducerLegacy() { ItemStack stack = new ItemStack(config.getMaterial(), amount, (short) config.getModel()); ItemMeta meta = stack.getItemMeta(); - assert meta != null; - meta.setDisplayName(config.getDisplayName()); - meta.setUnbreakable(true); - if(config.getLore() != null) meta.setLore(config.getLore()); - stack.setItemMeta(meta); + if(meta != null) + { + meta.setDisplayName(config.getDisplayName()); + meta.setUnbreakable(true); + if(config.getLore() != null) meta.setLore(config.getLore()); + stack.setItemMeta(meta); + } return stack; } } \ No newline at end of file