2017-05-16 5 views
-2

Code:Wie Debuggen "Fehler: Fehler: java.util.NoSuchElementException" in Java?

int i = MobStackHandler.this.getInstance().getConfigHandler().getMobStackingRadius(); 
     List localList = MobStackHandler.this.mobList; 
     Iterator localIterator2; 
     for (Iterator localIterator1 = Bukkit.getServer().getWorlds().iterator(); localIterator1.hasNext(); localIterator2.hasNext()) 
     { 
      World localWorld = (World)localIterator1.next(); 
      localIterator2 = localWorld.getLivingEntities().iterator(); 
      LivingEntity localLivingEntity = (LivingEntity)localIterator2.next(); 
      if ((localList.contains(localLivingEntity.getType())) && (localLivingEntity.isValid())) { 
      for (Entity localEntity : localLivingEntity.getNearbyEntities(i, i, i)) { 
       if (((localEntity instanceof LivingEntity)) && (localEntity.isValid()) && (localList.contains(localEntity.getType()))) { 
       MobStackHandler.this.stackOne(localLivingEntity, (LivingEntity)localEntity, ChatColor.valueOf(MobStackHandler.this.getInstance().getConfigHandler().getMobStackColor())); 
       } 
      } 
      } 
     } 
     } 
    }.runTaskTimer(getInstance(), 40L, 40L); 
    } 

Fehler: bei com.obvious.handlers.MobStackHandler $ 1.run (MobStackHandler.java:87) ~ [:?]

+0

Warum verwenden Sie eine 'for' -Schleife über den' localIterator1'? Es würde mir mehr Sinn machen, den 'localIterator1' zuzuweisen und dann' while (localIterator1.hasNext()) {...} '. Es ist wahrscheinlich das Problem mit der Überprüfung von 'localIterator2.hasNext()' in der Schleife. – KevinO

+0

Wenn Sie Hilfe benötigen, sagen Sie uns bitte, was Zeile 87 in Ihrem Code ist? – SHG

Antwort

0

Als Oracle Doc

NoSuchElementException:

Wird von der nextElement-Methode einer Enumeration ausgelöst, um anzuzeigen, dass in der Enumeration keine Elemente mehr vorhanden sind.

Wenn Sie debuggen möchten nur Debug Iteration.

+0

Wie es sein sollte –

Verwandte Themen