@@ -29,6 +29,9 @@ public static VillConfig getInstance() {
2929 private final HashMap <Material , Color > poiBlockHighlightColorsMap = new HashMap <>();
3030 String error = ServerMessage .CONFIGURATION_ERROR_PREFIX .getMessage ();
3131
32+ private boolean isWhitelist ;
33+ private Set <Material > itemSet = new HashSet <>();
34+
3235 private final Logger logger = VillagerInfo .getInstance ().getVillagerInfoLogger ();
3336
3437 public void reloadVillConfig (FileConfiguration config ) {
@@ -38,6 +41,7 @@ public void reloadVillConfig(FileConfiguration config) {
3841 reloadHighlightTime (config );
3942 reloadToggles (config );
4043 reloadColors (config );
44+ reloadItemList (config );
4145 }
4246
4347 public void reloadSound (FileConfiguration config ) {
@@ -128,6 +132,19 @@ public void reloadColors(FileConfiguration config) {
128132 }
129133 }
130134
135+ public void reloadItemList (FileConfiguration config ) {
136+ isWhitelist = config .getBoolean ("whitelist" , false );
137+ for (String item : config .getStringList ("items" )) {
138+ Material material = Material .getMaterial (item );
139+ if (material != null ) {
140+ itemSet .add (material );
141+ continue ;
142+ }
143+ Logger logger = VillagerInfo .getInstance ().getVillagerInfoLogger ();
144+ logger .warning ("Invalid material in item list: " + item );
145+ }
146+ }
147+
131148 public Sound getConfiguredSound () {
132149 return configuredSound ;
133150 }
@@ -147,4 +164,8 @@ public float getConfiguredSoundVolume() {
147164 public Map <Material , Color > getPoiBlockHighlightColorsMap () {
148165 return Collections .unmodifiableMap (poiBlockHighlightColorsMap );
149166 }
167+
168+ public boolean isValidItem (Material material ) {
169+ return itemSet .contains (material ) == isWhitelist ;
170+ }
150171}
0 commit comments