Skip to content

Commit a590ed7

Browse files
committed
Added ItemStack Options
Added the ability to change the name tag into some other item stack. Supports changing the material, stack size, and custom model data.
1 parent 9ceaa8c commit a590ed7

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

src/main/java/adhdmc/simpleprefixes/gui/chest/PrefixMenu.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private List<String> getPlayerPrefixOptions(Player p) {
8080
// TODO: Everything within this section should be configurable.
8181
private ItemStack generatePrefixItem(Player player, Prefix prefix) {
8282
boolean unlocked = RequirementUtil.getInstance().isEarnedPrefix(player, prefix);
83-
ItemStack item = (unlocked) ? new ItemStack(Material.NAME_TAG) : new ItemStack(Material.BARRIER);
83+
ItemStack item = (unlocked) ? prefix.itemStack : new ItemStack(Material.BARRIER);
8484
ItemMeta meta = item.getItemMeta();
8585
assert prefix.displayName != null;
8686
assert prefix.prefix != null;

src/main/java/adhdmc/simpleprefixes/prefix/Prefix.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import adhdmc.simpleprefixes.SimplePrefixes;
44
import adhdmc.simpleprefixes.config.PrefixConfig;
55
import adhdmc.simpleprefixes.util.Message;
6+
import org.bukkit.Material;
67
import org.bukkit.configuration.ConfigurationSection;
8+
import org.bukkit.inventory.ItemStack;
9+
import org.bukkit.inventory.meta.ItemMeta;
710

811
import java.util.*;
912

@@ -18,6 +21,7 @@ public class Prefix {
1821
public final boolean verifyAlways;
1922
public final boolean showWhenLocked;
2023
public final List<String> requirements;
24+
public final ItemStack itemStack;
2125

2226
private Prefix(String prefixId) {
2327
ConfigurationSection config = PrefixConfig.getInstance().getPrefixConfig().getConfigurationSection(prefixId);
@@ -29,6 +33,22 @@ private Prefix(String prefixId) {
2933
this.showWhenLocked = config.getBoolean("show-when-locked", true);
3034
this.requirements = Collections.unmodifiableList(config.getStringList("requirements"));
3135
this.description = Collections.unmodifiableList(config.getStringList("description"));
36+
37+
ConfigurationSection configItem = config.getConfigurationSection("item");
38+
if (configItem == null) {
39+
this.itemStack = new ItemStack(Material.NAME_TAG);
40+
return;
41+
}
42+
ItemStack itemStack;
43+
Material material = Material.getMaterial(configItem.getString("material", "NAME_TAG"));
44+
int count = configItem.getInt("count", 1);
45+
itemStack = material == null ? new ItemStack(Material.NAME_TAG, count) : new ItemStack(material, count);
46+
if (configItem.isInt("custom-model-data")) {
47+
ItemMeta meta = itemStack.getItemMeta();
48+
meta.setCustomModelData(configItem.getInt("custom-model-data"));
49+
itemStack.setItemMeta(meta);
50+
}
51+
this.itemStack = itemStack;
3252
}
3353

3454
public static void populatePrefixes() {

src/main/resources/prefixes.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,14 @@ wither_hunter:
3636
prefix: "<white>[<black>Wither Hunter</black>]</white>"
3737
show-when-locked: false
3838
requirements:
39-
- "advancement minecraft:nether/summon_wither"
39+
- "advancement minecraft:nether/summon_wither"
40+
custom_model_data:
41+
display-name: "<aqua>Bucket Mobs!</aqua>"
42+
description:
43+
- "If you have SimpleBucketMobs' resource pack"
44+
- "then this is an Enderman Bucket!"
45+
prefix: "<white>[<aqua>Simple Bucket Mobs</aqua>]</white>"
46+
item:
47+
material: BUCKET
48+
count: 2
49+
custom-model-data: 22000

0 commit comments

Comments
 (0)