ClassCastException with entities

Discussion in 'Plugin Development' started by thebiologist13, May 1, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    thebiologist13

    Hello Everyone!

    I am at a loss as to why this would happen to one of the users of my plugin. I have a sync task that iterates through a ConcurrentHashMap< UUID, SpawnableEntity > where SpawnableEntity is just a class of mine with entity info. However it throws a ClassCastException when I try to get the next element in the keyset iterator with .next(). It says Integer cannot be cast to UUID.

    The afflicted code:
    Code:java
    1. // "s" is another instance of a class holding data in my plugin
    2. // and .getMobs() returns a ConcurrentHashMap< UUID, SpawnableEntity >
    3. Iterator<UUID>spMobs=s.getMobs().keySet().iterator();
    4. while (spMobs.hasNext()) {
    5. UUID spId=spMobs.next(); //The offending line
    6. //After this there is just a few lines dealing with the UUID I got.
    7. }

    Full code is here on line 1037 if you need to see it: https://github.com/thebiologist13/C...com/github/thebiologist13/CustomSpawners.java

    Thanks in advance!
    ~thebiologist13
     
  2. Offline

    Tirelessly

    Show the rest of the lines
     
  3. Offline

    thebiologist13

    Tirelessly
    Code:java
    1. Iterator<UUID> spMobs = s.getMobs().keySet().iterator();
    2. while (spMobs.hasNext()) {
    3.  
    4. UUID spId = spMobs.next();
    5.  
    6. Entity e = getEntityFromWorld(spId, s.getLoc().getWorld());
    7.  
    8. if (e == null) {
    9. s.removeMob(spId);
    10. continue;
    11. }
    12.  
    13.  
    14. //This will untrack mobs if they are too far from the spawner.
    15. if(s.isTrackNearby()) {
    16. if(e.getLocation().distanceSquared(s.getLoc()) >= Math.pow(s.getRadius(), 2)) {
    17. s.removeMob(spId);
    18. }
    19. }
    20.  
    21. }

    Few more methods are in here from my various classes, all the source is on Github from the link in my previous post.

    Thanks!
    ~thebiologist13
     
  4. Offline

    Tirelessly

    thebiologist13 Not sure. I googled the problem a bit and couldn't find much.
     
Thread Status:
Not open for further replies.

Share This Page