mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-02-23 02:52:38 +01:00
Add option to disable items
This commit is contained in:
parent
7c21e9bfc4
commit
975cfb5af6
@ -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
|
||||
|
@ -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<String> lore = getConfigE().getStringList(key + ".Lore", new ArrayList<>(0));
|
||||
final List<String> loreFinal;
|
||||
if(lore.size() == 0) loreFinal = null;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user