9
9
import java .util .*;
10
10
11
11
public class Acl extends FileConfigure {
12
-
12
+ public boolean default_enchant = true ;
13
+ public boolean default_repair = true ;
13
14
public static class list implements ISerializable {
14
15
@ Serializable
15
16
boolean enchant = true ;
@@ -41,6 +42,12 @@ protected JavaPlugin getPlugin() {
41
42
public void deserialize (ConfigurationSection config ) {
42
43
aclMap .clear ();
43
44
for (String key : config .getKeys (false )) {
45
+ if (key .equals ("default" )) {
46
+ ConfigurationSection Default = config .getConfigurationSection (key );
47
+ this .default_enchant = Default .getBoolean ("enchant" , this .default_enchant );
48
+ this .default_repair = Default .getBoolean ("repair" , this .default_repair );
49
+ continue ;
50
+ }
44
51
if (!config .isConfigurationSection (key )) continue ;
45
52
list list = new list ();
46
53
list .deserialize (config .getConfigurationSection (key ));
@@ -54,6 +61,9 @@ public void serialize(ConfigurationSection config) {
54
61
for (String key : tmp ) { // clear section
55
62
config .set (key , null );
56
63
}
64
+ ConfigurationSection Default = config .createSection ("default" );
65
+ Default .set ("enchant" , this .default_enchant );
66
+ Default .set ("repair" , this .default_repair );
57
67
58
68
for (Map .Entry <String , list > pair : aclMap .entrySet ()) {
59
69
ConfigurationSection section = config .createSection (pair .getKey ());
@@ -64,23 +74,23 @@ public void serialize(ConfigurationSection config) {
64
74
public boolean canEnchant (List <String > lore ) {
65
75
for (String s : lore ) {
66
76
if (aclMap .containsKey (ChatColor .stripColor (s ))) {
67
- if (aclMap .get (ChatColor .stripColor (s )).enchant != plugin . cfg . acl_default_enchant ) {
77
+ if (aclMap .get (ChatColor .stripColor (s )).enchant != this . default_enchant ) {
68
78
return aclMap .get (ChatColor .stripColor (s )).enchant ;
69
79
}
70
80
}
71
81
}
72
- return plugin . cfg . acl_default_enchant ;
82
+ return this . default_enchant ;
73
83
74
84
}
75
85
76
86
public boolean canRepair (List <String > lore ) {
77
87
for (String s : lore ) {
78
88
if (aclMap .containsKey (ChatColor .stripColor (s ))) {
79
- if (aclMap .get (ChatColor .stripColor (s )).repair != plugin . cfg . acl_default_repair ) {
89
+ if (aclMap .get (ChatColor .stripColor (s )).repair != this . default_repair ) {
80
90
return aclMap .get (ChatColor .stripColor (s )).repair ;
81
91
}
82
92
}
83
93
}
84
- return plugin . cfg . acl_default_repair ;
94
+ return this . default_repair ;
85
95
}
86
96
}
0 commit comments