@@ -44,7 +44,7 @@ public class RsNPC extends PluginBase {
4444 new ThreadPoolExecutor .DiscardPolicy ());
4545 public static final Random RANDOM = new Random ();
4646
47- public static final String VERSION = "2.5.2 " ;
47+ public static final String VERSION = "2.5.3-SNAPSHOT " ;
4848
4949 private static RsNPC rsNPC ;
5050
@@ -194,38 +194,47 @@ private void loadLanguage() {
194194 }
195195
196196 private void loadNpcs () {
197- File [] files = (new File (getDataFolder () + "/Npcs" )).listFiles ();
198- if (files != null ) {
199- for (File file : files ) {
200- if (!file .isFile () && file .getName ().endsWith (".yml" )) {
201- continue ;
202- }
203- String npcName = file .getName ().split ("\\ ." )[0 ];
204- Config config ;
205- try {
206- config = new Config (file , Config .YAML );
207- }catch (Exception e ) {
208- this .getLogger ().error (this .getLanguage ().translateString ("plugin.load.NPC.loadConfigError" , npcName ), e );
209- continue ;
210- }
211- RsNpcConfig rsNpcConfig ;
212- try {
213- rsNpcConfig = new RsNpcConfig (npcName , config );
214- } catch (Exception e ) {
215- this .getLogger ().error (this .getLanguage ().translateString ("plugin.load.NPC.loadError" , npcName ), e );
216- continue ;
217- }
218- this .npcs .put (npcName , rsNpcConfig );
219- this .getLogger ().info (this .getLanguage ().translateString ("plugin.load.NPC.loadComplete" , rsNpcConfig .getName ()));
220- }
221- }
197+ File npcsFolder = new File (getDataFolder () + "/Npcs" );
198+ loadNpcsFromDirectory (npcsFolder );
222199 this .getServer ().getScheduler ().scheduleDelayedTask (this , () -> {
223200 for (RsNpcConfig config : this .npcs .values ()) {
224201 config .checkEntity ();
225202 }
226203 }, 1 );
227204 }
228205
206+ private void loadNpcsFromDirectory (File directory ) {
207+ if (!directory .exists () || !directory .isDirectory ()) {
208+ return ;
209+ }
210+ File [] files = directory .listFiles ();
211+ if (files != null ) {
212+ for (File file : files ) {
213+ if (file .isDirectory ()) {
214+ loadNpcsFromDirectory (file );
215+ } else if (file .isFile () && file .getName ().endsWith (".yml" )) {
216+ String npcName = file .getName ().split ("\\ ." )[0 ];
217+ Config config ;
218+ try {
219+ config = new Config (file , Config .YAML );
220+ }catch (Exception e ) {
221+ this .getLogger ().error (this .getLanguage ().translateString ("plugin.load.NPC.loadConfigError" , npcName ), e );
222+ continue ;
223+ }
224+ RsNpcConfig rsNpcConfig ;
225+ try {
226+ rsNpcConfig = new RsNpcConfig (npcName , config );
227+ } catch (Exception e ) {
228+ this .getLogger ().error (this .getLanguage ().translateString ("plugin.load.NPC.loadError" , npcName ), e );
229+ continue ;
230+ }
231+ this .npcs .put (npcName , rsNpcConfig );
232+ this .getLogger ().info (this .getLanguage ().translateString ("plugin.load.NPC.loadComplete" , rsNpcConfig .getName ()));
233+ }
234+ }
235+ }
236+ }
237+
229238 /**
230239 * 加载内置皮肤
231240 */
0 commit comments