1
1
package cc .carm .plugin .userprefix .manager ;
2
2
3
+ import cc .carm .lib .easyplugin .gui .configuration .GUIActionConfiguration ;
3
4
import cc .carm .lib .mineconfiguration .bukkit .data .ItemConfig ;
4
5
import cc .carm .lib .mineconfiguration .bukkit .source .CraftSectionWrapper ;
5
6
import cc .carm .plugin .userprefix .Main ;
@@ -57,7 +58,7 @@ public void loadConfiguredPrefixes() {
57
58
if (files .size () > 0 ) {
58
59
for (File file : files ) {
59
60
try {
60
- PrefixConfig prefix = adPrefix (file );
61
+ PrefixConfig prefix = addPrefix (file );
61
62
Main .debugging ("完成前缀加载 " + prefix .getIdentifier () + " : " + prefix .getName ());
62
63
loaded .put (prefix .getIdentifier (), prefix );
63
64
} catch (Exception ex ) {
@@ -78,6 +79,7 @@ public void loadDefaultPrefix() {
78
79
PluginConfig .DEFAULT_PREFIX .CONTENT .getNotNull (),
79
80
PluginConfig .DEFAULT_PREFIX .WEIGHT .getNotNull (),
80
81
null ,
82
+ readActions (PluginConfig .DEFAULT_PREFIX .ACTIONS .get ()),
81
83
PluginConfig .DEFAULT_PREFIX .ITEM .NOT_USING .getNotNull (),
82
84
PluginConfig .DEFAULT_PREFIX .ITEM .USING .get (),
83
85
null
@@ -122,10 +124,11 @@ protected File getStorageFolder() {
122
124
}
123
125
}
124
126
125
- public static @ NotNull PrefixConfig adPrefix (@ NotNull File file ) throws Exception {
127
+ public static @ NotNull PrefixConfig addPrefix (@ NotNull File file ) throws Exception {
126
128
FileConfiguration configuration = YamlConfiguration .loadConfiguration (file );
127
129
String identifier = configuration .getString ("identifier" );
128
- if (identifier == null ) throw new Exception ("配置文件 " + file .getAbsolutePath () + " 中没有配置前缀的唯一标识。" );
130
+ if (identifier == null )
131
+ throw new Exception ("配置文件 " + file .getAbsolutePath () + " 中没有配置前缀的唯一标识。" );
129
132
130
133
String name = configuration .getString ("name" );
131
134
if (name == null ) throw new Exception ("配置文件 " + file .getAbsolutePath () + " 中没有配置前缀的显示名称。" );
@@ -135,6 +138,7 @@ protected File getStorageFolder() {
135
138
configuration .getString ("content" , "&r" ),
136
139
configuration .getInt ("weight" , 1 ),
137
140
configuration .getString ("permission" ),
141
+ readActions (configuration .getStringList ("actions" )),
138
142
readItem (
139
143
configuration .getConfigurationSection ("item.has-perm" ),
140
144
new ItemConfig (Material .STONE , name , Arrays .asList (" " , "§a➥ 点击切换到该前缀" ))
@@ -151,5 +155,9 @@ protected static ItemConfig readItem(@Nullable ConfigurationSection section, @Nu
151
155
else return ItemConfig .deserialize (CraftSectionWrapper .of (section ));
152
156
}
153
157
158
+ protected static List <GUIActionConfiguration > readActions (@ NotNull List <String > strings ) {
159
+ return strings .stream ().map (GUIActionConfiguration ::deserialize ).filter (Objects ::nonNull ).collect (Collectors .toList ());
160
+ }
161
+
154
162
155
163
}
0 commit comments