How could I improve this code?

Discussion in 'Plugin Development' started by flyingtacoz, May 28, 2013.

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

    flyingtacoz

    I run a small Skyblock server, and my server tends to hang or freeze for a bit whenever someone restarts their Skyblock island. It acts like a big worldedit just took place.
    This is the code that deletes their island, does anyone have any ideas on what I can add or modify to this code to make it perform better?

    Code:
      public void deleteIsland(String playerName, World world) {
        if (hasIsland(playerName)) {
          Island island = getPlayerIsland(playerName);
          for (int x = island.x - 50; x < island.x + 50; x++) {
            for (int y = 200 - 200; y < world.getMaxHeight(); y++)
              for (int z = island.z - 50; z < island.z + 50; z++) {
                Block block = world.getBlockAt(x, y, z);
                if (block.getTypeId() != 0)
                  block.setTypeId(0);
              }
          }
          this.playerIslands.remove(playerName);
        }
      }
     
  2. Offline

    ZeusAllMighty11

Thread Status:
Not open for further replies.

Share This Page