@@ -78,23 +78,32 @@ public static void loadPortals(){
78
78
blockType = Material .PORTAL ;
79
79
}
80
80
81
- ConfigurationSection portalArgs = portalConfigSection .getConfigurationSection ("portalArgs" );
82
- Set <String > argsSet = portalArgs .getKeys (true );
81
+ ConfigurationSection portalArgsConf = portalConfigSection .getConfigurationSection ("portalArgs" );
83
82
84
- ArrayList <PortalArg > extraData = new ArrayList <PortalArg >();
83
+ ArrayList <PortalArg > extraData = new ArrayList <>();
85
84
86
- for (Object argName : argsSet .toArray ()){
87
- if (portalArgs .isString (argName .toString ())){
88
- extraData .add (new PortalArg (argName .toString (), portalArgs .getString (argName .toString ())));
85
+ if (portalArgsConf != null ) {
86
+ Set <String > argsSet = portalArgsConf .getKeys (true );
87
+
88
+ for (Object argName : argsSet .toArray ()){
89
+ if (portalArgsConf .isString (argName .toString ())){
90
+ extraData .add (new PortalArg (argName .toString (), portalArgsConf .getString (argName .toString ())));
91
+ }
89
92
}
90
93
}
91
94
95
+
96
+
92
97
String worldName = portalData .getConfig ().getString (portal .toString () + ".world" );
98
+
93
99
World world = Bukkit .getWorld (worldName );
94
100
Location pos1 = new Location (world , portalData .getConfig ().getInt (portal .toString () + ".pos1.X" ), portalData .getConfig ().getInt (portal .toString () + ".pos1.Y" ), portalData .getConfig ().getInt (portal .toString () + ".pos1.Z" ));
95
101
Location pos2 = new Location (world , portalData .getConfig ().getInt (portal .toString () + ".pos2.X" ), portalData .getConfig ().getInt (portal .toString () + ".pos2.Y" ), portalData .getConfig ().getInt (portal .toString () + ".pos2.Z" ));
96
102
97
- Portals [portalId ] = new AdvancedPortal (portal .toString (), blockType , pos1 , pos2 , worldName );
103
+ PortalArg [] portalArgs = new PortalArg [extraData .size ()];
104
+ extraData .toArray (portalArgs );
105
+
106
+ Portals [portalId ] = new AdvancedPortal (portal .toString (), blockType , pos1 , pos2 , worldName , portalArgs );
98
107
99
108
Portals [portalId ].bungee = portalConfigSection .getString ("bungee" );
100
109
@@ -346,28 +355,28 @@ public static boolean activate(Player player, String portalName) {
346
355
return false ;
347
356
}
348
357
349
- public static boolean activate (Player player , AdvancedPortal portalName ) {
358
+ public static boolean activate (Player player , AdvancedPortal portal ) {
350
359
351
360
// add other variables or filter code here, or somehow have a way to register them
352
361
353
- if (portalData . getConfig (). getString ( portalName + ". bungee" ) != null ){
362
+ if (portal . bungee != null ){
354
363
if (ShowBungeeMessage ){
355
- player .sendMessage ("\u00A7 a[\u00A7 eAdvancedPortals\u00A7 a] Attempting to warp to \u00A7 e" + portalData . getConfig (). getString ( portalName + ". bungee" ) + "\u00A7 a." );
364
+ player .sendMessage ("\u00A7 a[\u00A7 eAdvancedPortals\u00A7 a] Attempting to warp to \u00A7 e" + portal . bungee + "\u00A7 a." );
356
365
}
357
366
ByteArrayDataOutput out = ByteStreams .newDataOutput ();
358
367
out .writeUTF ("Connect" );
359
- out .writeUTF (portalData . getConfig (). getString ( portalName + ". bungee" ) );
368
+ out .writeUTF (portal . bungee );
360
369
player .sendPluginMessage (plugin , "BungeeCord" , out .toByteArray ());
361
370
return false ;
362
371
363
372
}
364
373
else {
365
374
boolean showFailMessage = true ;
366
375
367
- if (portalData . getConfig (). getString ( portalName + ".portalArgs. command.1" ) != null ){
376
+ if (portal . getArg ( " command.1" ) != null ){
368
377
showFailMessage = false ;
369
378
int commandLine = 1 ;
370
- String command = portalData .getConfig ().getString (portalName + ".portalArgs.command." + commandLine );
379
+ String command = portal . getArg ( "command." + commandLine ); // portalData.getConfig().getString(portal. portalName+ ".portalArgs.command." + commandLine);
371
380
do {
372
381
// (?i) makes the search case insensitive
373
382
command = command .replaceAll ("@player" , player .getName ());
@@ -402,22 +411,21 @@ else if(command.startsWith("^")){
402
411
else {
403
412
player .performCommand (command );
404
413
}
405
- command = portalData . getConfig (). getString ( portalName + ".portalArgs. command." + ++commandLine );
414
+ command = portal . getArg ( " command." + ++commandLine );
406
415
}while (command != null );
407
416
}
408
-
409
- if (portalData . getConfig (). getString ( portalName + ".destination" ) != null ){
417
+ plugin . getLogger (). info ( portal . portalName + ":" + portal . destiation );
418
+ if (portal . destiation != null ){
410
419
ConfigAccessor configDesti = new ConfigAccessor (plugin , "Destinations.yml" );
411
- String destiName = portalData .getConfig ().getString (portalName + ".destination" );
412
- String permission = portalData .getConfig ().getString (portalName + ".portalArgs.permission" );
420
+ String permission = portal .getArg ("permission" );
413
421
if (permission == null || (permission != null && player .hasPermission (permission )) || player .isOp ()){
414
- if (configDesti .getConfig ().getString (destiName + ".world" ) != null ){
415
- boolean warped = Destination .warp (player , destiName );
422
+ if (configDesti .getConfig ().getString (portal . destiation + ".world" ) != null ){
423
+ boolean warped = Destination .warp (player , portal . destiation );
416
424
return warped ;
417
425
}
418
426
else {
419
427
player .sendMessage ("\u00A7 c[\u00A7 7AdvancedPortals\u00A7 c] The destination you are currently attempting to warp to doesnt exist!" );
420
- plugin .getLogger ().log (Level .SEVERE , "The portal '" + portalName + "' has just had a warp "
428
+ plugin .getLogger ().log (Level .SEVERE , "The portal '" + portal . portalName + "' has just had a warp "
421
429
+ "attempt and either the data is corrupt or that destination listed doesn't exist!" );
422
430
return false ;
423
431
}
@@ -448,7 +456,7 @@ else if(command.startsWith("^")){
448
456
else {
449
457
if (showFailMessage ) {
450
458
player .sendMessage ("\u00A7 c[\u00A7 7AdvancedPortals\u00A7 c] The portal you are trying to use doesn't have a destination!" );
451
- plugin .getLogger ().log (Level .SEVERE , "The portal '" + portalName + "' has just had a warp "
459
+ plugin .getLogger ().log (Level .SEVERE , "The portal '" + portal . portalName + "' has just had a warp "
452
460
+ "attempt and either the data is corrupt or portal doesn't exist!" );
453
461
}
454
462
return false ;
0 commit comments