Strange Crashes from Plugin

Discussion in 'Plugin Development' started by thebiologist13, Dec 23, 2012.

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

    thebiologist13

    Hi Everyone!

    My plugin is causing a very peculiar problem in my server. A friend and I will play for a while, but occasionally when one of us dies or disconnects and re-connects, chunks stop loading, chat stops, you cannot interact with the world, etc. However, the server doesn't disconnect us. Sometimes the other person is unaffected entirely. Adding to the strangeness is how server reloads (restarts too), client reloads, and even server computer restarts do not stop the problem!

    A theory I have as to why this is happening is how my plugin changes all of a spawner's NBT information (since NBT is saved to the world). Could changing the NBT on a spawner cause this to happen when the spawner is loaded in a chunk?

    Here is the code I use to set spawner NBT:
    Code:java
    1. /**
    2.  * Sets the NBT of a TileEntityMobSpawner to what you specify.
    3.  *
    4.  * @param b The block that is a TileEntityMobSpawner to set the NBT to.
    5.  * @param n The NBTTagCompound containing the information to be set.
    6.  * @throws NotTileEntityException when the given block is not a tile entity.
    7.  */
    8. public void setTileEntityMobSpawnerNBT(Block b, NBTTagCompound n) throws NotTileEntityException {
    9. if(!isTileEntity(b)) {
    10. NotTileEntityException ex = new NotTileEntityException("Parameter block is not a tile entity.");
    11. ex.fillInStackTrace();
    12. throw ex;
    13. }
    14.  
    15. CraftWorld cw = (CraftWorld) b.getWorld();
    16. TileEntityMobSpawner te = (TileEntityMobSpawner) cw.getTileEntityAt(b.getX(), b.getY(), b.getZ());
    17.  
    18. te.a(n);
    19. }
    20.  
    21. /**
    22.  * Finds whether a block is a tile entity or not.
    23.  *
    24.  * @param b The block to test.
    25.  * @return True if the block is a tile entity.
    26.  */
    27. public boolean isTileEntity(Block b) {
    28. CraftWorld w = (CraftWorld) b.getWorld();
    29. TileEntity e = w.getTileEntityAt(b.getX(), b.getY(), b.getZ());
    30.  
    31. if(e != null)
    32. return true;
    33.  
    34. return false;
    35. }

    Thanks in Advance! :D
    ~thebiologist13
     
  2. Offline

    fireblast709

    My guess is that your original NBTTag is incorrect, so it causes errors while updating them
     
  3. Offline

    thebiologist13

    Ok, any ideas to which tags could cause the crash? I do sometimes put in tags that are not relevant to the entity being spawned for a convenience in the code. For example, the "Color" tag might be assigned to a skeleton spawner. I also don't include the spawner tile entity ID or entity position tags most of the time.

    Thanks!
    ~thebiologist13
     
  4. Offline

    fireblast709

    How do you get NBTTagCompound n?
     
Thread Status:
Not open for further replies.

Share This Page