Asynchronous Block Remove Error

Discussion in 'Plugin Development' started by SoS_Dylan, Sep 28, 2013.

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

    SoS_Dylan

    Code:java
    1. public class walls implements Runnable {
    2. public Player player1 = null;
    3. public Location l = null;
    4. public void setPlayer(Player player) {
    5. player1 = player;
    6. }
    7. public void setLocation(Location lo) {
    8. l = lo;
    9. }
    10. @Override
    11. public void run() {
    12. Player player = player1;
    13. Location loc = l;
    14. try {
    15. Thread.sleep(5000);
    16. } catch (InterruptedException e) {
    17. e.printStackTrace();
    18. }
    19. for (int x = 0; x <= 2; x++) {
    20. for (int y = 0; y <= 3; y++) {
    21. for (int z = 0; z <= 2; z++) {
    22. if (loc.getBlock().getLocation().add(x - 1, y - 1, z - 1).getBlock().getType().equals(Material.ICE))
    23. loc.getBlock().getLocation().add(x - 1, y - 1, z - 1).getBlock().setType(Material.AIR);
    24. }
    25. }
    26. }
    27. player.sendMessage(ChatColor.AQUA + "You are no longer frozen.");
    28. }
    29. }
    30. }

    Code:
    013-09-29 00:25:11 [SEVERE] Exception in thread "Thread-36"
    2013-09-29 00:25:11 [SEVERE] java.lang.IllegalStateException: Asynchronous block remove!
    2013-09-29 00:25:11 [SEVERE] at net.minecraft.server.v1_6_R3.Block.remove(Block.java:350)
    2013-09-29 00:25:11 [SEVERE] at net.minecraft.server.v1_6_R3.Chunk.a(Chunk.java:390)
    2013-09-29 00:25:11 [SEVERE] at net.minecraft.server.v1_6_R3.World.setTypeIdAndData(World.java:351)
    2013-09-29 00:25:11 [SEVERE] at org.bukkit.craftbukkit.v1_6_R3.block.CraftBlock.setTypeId(CraftBlock.java:108)
    2013-09-29 00:25:11 [SEVERE] at org.bukkit.craftbukkit.v1_6_R3.block.CraftBlock.setType(CraftBlock.java:104)
    2013-09-29 00:25:11 [SEVERE] at me.SoSDylan.mKitPvP.Kits.Freezer$walls.run(Freezer.java:228)
    2013-09-29 00:25:11 [SEVERE] at java.lang.Thread.run(Unknown Source)
     
  2. Offline

    CubieX

    Do not access BukkitAPI methods from an async task.
    Only the main server task may do this.

    Have a look at Bukkit scheduler methods. "runTaskLater()" or whatever fits your needs.
    But use a sync one here.
     
  3. Offline

    SoS_Dylan

Thread Status:
Not open for further replies.

Share This Page