1414import pl .norbit .treecuter .service .TreePlanterService ;
1515
1616import java .util .*;
17+ import java .util .logging .Logger ;
1718
1819public class Settings {
1920
@@ -68,6 +69,9 @@ public class Settings {
6869 @ Getter
6970 private static List <Material > autoPlantSapling ;
7071
72+ @ Getter
73+ private static Map <Material , List <String >> actionsTypeMap ;
74+
7175 //block worlds
7276 private static List <String > blockWorlds ;
7377
@@ -117,10 +121,20 @@ public class Settings {
117121
118122 private static List <CutShape > woodBlocks ;
119123
124+ @ Getter
125+ private static boolean actionsEnabled ;
126+ @ Getter
127+ private static List <String > actions ;
128+
120129 private Settings () {
121130 throw new IllegalStateException ("This class cannot be instantiated" );
122131 }
123132
133+
134+ public static List <String > getActions (Material material ){
135+ return actionsTypeMap .get (material );
136+ }
137+
124138 public static Optional <ItemStack > getCustomToolForKey (String key ){
125139 return woodBlocks .stream ()
126140 .filter (shape -> shape .getId ().equalsIgnoreCase (key ))
@@ -199,6 +213,9 @@ public static void loadConfig(boolean reload) {
199213 placeholderToggleOn = config .getString ("placeholder.toggle-on" );
200214 placeholderToggleOff = config .getString ("placeholder.toggle-off" );
201215
216+ actions = config .getStringList ("actions.action-list.global" );
217+ actionsEnabled = config .getBoolean ("actions.enable" );
218+
202219 acceptTools = new ArrayList <>();
203220 acceptWoodBlocks = new ArrayList <>();
204221 acceptLeavesBlocks = new ArrayList <>();
@@ -266,6 +283,7 @@ public static void loadConfig(boolean reload) {
266283
267284 ConfigurationSection section = config .getConfigurationSection ("wood-blocks" );
268285
286+
269287 if (section == null ) {
270288 javaPlugin .getLogger ().warning ("No wood blocks found in config" );
271289 }else {
@@ -282,10 +300,35 @@ public static void loadConfig(boolean reload) {
282300 }
283301 }
284302
303+ loadActionsTypes (config .getConfigurationSection ("actions.action-list.types" ));
304+
285305 if (autoPlant ) TreePlanterService .start ();
286306 else TreePlanterService .stop ();
287307 }
288308
309+ public static void loadActionsTypes (ConfigurationSection section ) {
310+ actionsTypeMap = new EnumMap <>(Material .class );
311+
312+ if (section == null ) {
313+ return ;
314+ }
315+
316+ Logger logger = TreeCuter .getInstance ().getLogger ();
317+
318+ for (String key : section .getKeys (false )) {
319+ Material material = Material .getMaterial (key .toUpperCase ());
320+
321+ if (material == null ) {
322+ logger .warning ("Wrong action material: " + key );
323+ continue ;
324+ }
325+
326+ List <String > commands = section .getStringList (key );
327+ actionsTypeMap .put (material , commands );
328+ }
329+ }
330+
331+
289332 private static CutShape getCutShape (ConfigurationSection section , String key ) {
290333 CutShape cutShape = new CutShape ();
291334 cutShape .setId (key );
0 commit comments