@@ -97,7 +97,11 @@ public void onBeatUpAngel(EntityDamageByEntityEvent event) {
9797 } else {
9898 l = getRandomLocation (t .getWorld ());
9999 }
100- plugin .getServer ().getScheduler ().scheduleSyncDelayedTask (plugin , () -> p .teleport (l ), 1L );
100+ if (l != null ) {
101+ plugin .getServer ().getScheduler ().scheduleSyncDelayedTask (plugin , () -> p .teleport (l ), 1L );
102+ } else {
103+ plugin .getMessenger ().message (p , TardisModule .MONSTERS , "NO_CONFIGURED_WORLDS" );
104+ }
101105 p .addPotionEffect (new PotionEffect (PotionEffectType .NAUSEA , 300 , 5 , true , false ));
102106 if (TARDISWeepingAngels .angelsCanSteal ()) {
103107 stealKey (p );
@@ -111,14 +115,17 @@ private Location getRandomLocation(World w) {
111115 // is this world an allowable world? - we don't want Nether or TARDIS worlds
112116 if (!angel_tp_worlds .contains (w )) {
113117 // get a random teleport world
114- w = angel_tp_worlds .get (TARDISConstants .RANDOM .nextInt (angel_tp_worlds .size ()));
118+ w = !angel_tp_worlds .isEmpty () ? angel_tp_worlds .get (TARDISConstants .RANDOM .nextInt (angel_tp_worlds .size ())) : null ;
119+ }
120+ if (w != null ) {
121+ Chunk [] chunks = w .getLoadedChunks ();
122+ Chunk c = chunks [TARDISConstants .RANDOM .nextInt (chunks .length )];
123+ int x = c .getX () * 16 + TARDISConstants .RANDOM .nextInt (16 );
124+ int z = c .getZ () * 16 + TARDISConstants .RANDOM .nextInt (16 );
125+ int y = w .getHighestBlockYAt (x , z );
126+ return new Location (w , x , y + 1 , z ).add (0.5d , 0 , 0.5d );
115127 }
116- Chunk [] chunks = w .getLoadedChunks ();
117- Chunk c = chunks [TARDISConstants .RANDOM .nextInt (chunks .length )];
118- int x = c .getX () * 16 + TARDISConstants .RANDOM .nextInt (16 );
119- int z = c .getZ () * 16 + TARDISConstants .RANDOM .nextInt (16 );
120- int y = w .getHighestBlockYAt (x , z );
121- return new Location (w , x , y + 1 , z ).add (0.5d , 0 , 0.5d );
128+ return null ;
122129 }
123130
124131 private Location getSpecificLocation () {
0 commit comments