@@ -20,6 +20,41 @@ public class CommandItem {
2020 private final Map <String , List <CommandEntry >> commands ;
2121 private final AutoGiveConfig autoGive ;
2222 private final AutoCleanupConfig autoCleanup ;
23+ private final ConsumableConfig consumable ;
24+
25+ public static class ConsumableConfig {
26+ private final boolean enabled ;
27+ private final String mode ; // COUNT, PROBABILITY, RANGE, PROBABILITY_RANGE
28+ private final int amount ;
29+ private final double probability ;
30+ private final int minAmount ;
31+ private final int maxAmount ;
32+
33+ public ConsumableConfig (ConfigurationSection config ) {
34+ if (config == null ) {
35+ this .enabled = false ;
36+ this .mode = "COUNT" ;
37+ this .amount = 1 ;
38+ this .probability = 1.0 ;
39+ this .minAmount = 1 ;
40+ this .maxAmount = 1 ;
41+ } else {
42+ this .enabled = config .getBoolean ("enabled" , false );
43+ this .mode = config .getString ("mode" , "COUNT" ).toUpperCase ();
44+ this .amount = config .getInt ("amount" , 1 );
45+ this .probability = config .getDouble ("probability" , 1.0 );
46+ this .minAmount = config .getInt ("min-amount" , 1 );
47+ this .maxAmount = config .getInt ("max-amount" , 1 );
48+ }
49+ }
50+
51+ public boolean isEnabled () { return enabled ; }
52+ public String getMode () { return mode ; }
53+ public int getAmount () { return amount ; }
54+ public double getProbability () { return probability ; }
55+ public int getMinAmount () { return minAmount ; }
56+ public int getMaxAmount () { return maxAmount ; }
57+ }
2358
2459 public static class AutoGiveConfig {
2560 private final boolean join ;
@@ -103,6 +138,7 @@ public CommandItem(String id, ConfigurationSection config) {
103138 this .commands = new HashMap <>();
104139 this .autoGive = new AutoGiveConfig (config .getConfigurationSection ("auto-give" ));
105140 this .autoCleanup = new AutoCleanupConfig (config .getConfigurationSection ("auto-cleanup" ));
141+ this .consumable = new ConsumableConfig (config .getConfigurationSection ("consumable" ));
106142
107143 // 加载命令
108144 ConfigurationSection commandsSection = config .getConfigurationSection ("commands" );
@@ -160,6 +196,10 @@ public AutoCleanupConfig getAutoCleanup() {
160196 return autoCleanup ;
161197 }
162198
199+ public ConsumableConfig getConsumable () {
200+ return consumable ;
201+ }
202+
163203 public ItemStack createItemStack () {
164204 ItemStack item = new ItemStack (material );
165205 ItemMeta meta = item .getItemMeta ();
0 commit comments