Ömm input = minimaler und maximaler punkt, ich dfange mit dem minimum an und höre beim maximum auf.
Keine probleme mit sand / gravel da dieser von unten nach oben schicht für schicht gesetzt wird.
Ich habe dafür aktuell neue commands erstellt, bin aber noch nicht zufrieden mit der arbeitsweise..
Werde es morgen überarbeiten damit der server es in einer akzeptablen zeit hinbekommt.
Imoment siet es so aus:
/** * Sets all the blocks inside a region to a certain block type. * * @param region * @param pattern * @return number of blocks affected * @throws MaxChangedBlocksException */ public int setBlocks(Region region, Pattern pattern, LocalSession session, LocalPlayer player, EditSession editSession) throws MaxChangedBlocksException { BlockScheduler bs = new BlockScheduler(region, pattern, session, player, editSession); int tmp = Bukkit.getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("WorldEdit"), bs, 0, 5); bs.setID(tmp); return tmp; } private class BlockList { public int x, y, z; public BlockList(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } } private class BlockScheduler implements Runnable { private int id = 0; private Region region; private Pattern pattern; private LocalSession session; private LocalPlayer player; private EditSession editSession; private long count = 0; private ArrayList<BlockList> bl = new ArrayList<BlockList>(); public BlockScheduler(Region region, Pattern pattern, LocalSession session, LocalPlayer player, EditSession editSession) throws MaxChangedBlocksException { this.region = region; this.pattern = pattern; this.session = session; this.player = player; this.editSession = editSession; Vector min = region.getMinimumPoint(); Vector max = region.getMaximumPoint(); int minX = min.getBlockX(); int minY = min.getBlockY(); int minZ = min.getBlockZ(); int maxX = max.getBlockX(); int maxY = max.getBlockY(); int maxZ = max.getBlockZ(); for (int x = minX; x <= maxX; ++x) { for (int y = minY; y <= maxY; ++y) { for (int z = minZ; z <= maxZ; ++z) { bl.add(new BlockList(x, y, z)); } } } } public void setID(int id) { this.id = id; } @Override public void run() { for(int tick = 0; tick <= 1000; tick++) { if (bl.size() <= 0) { finish(); return; } BlockList bl = this.bl.get(0); Vector pt = new Vector(bl.x, bl.y, bl.z); world.checkLoadedChunk(pt); if (region.getWorld().setBlock(pt, pattern.next(pt), true)) { ++count; } this.bl.remove(0); } if (this.bl.size() <= 0) { finish(); return; } } public void finish() { player.printDebug("Es wurden " + count + " Bl\u00F6cke ge\u00E4ndert."); Bukkit.getScheduler().cancelTask(id); } }
@Command(
aliases = { "/settime" },
usage = "<block>",
desc = "Set all the blocks inside the selection to a block",
min = 1,
max = 1
)
@CommandPermissions("worldedit.region.settime")
@Logging(REGION)
public void settime(CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException {
Pattern pattern = we.getBlockPattern(player, args.getString(0));
int affected;
affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern, session, player, editSession);
player.print(affected + " was the Thread ID.");
}
@Command(
aliases = { "/cancel" },
usage = "<id>",
desc = "Cancel a Task",
min = 1,
max = 1
)
@CommandPermissions("worldedit.region.cancel")
@Logging(REGION)
public void cancel(CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException {
int id = args.getInteger(0);
Bukkit.getScheduler().cancelTask(id);
player.print(id + " was canceled.");
}
Alles anzeigen
//TODO:
selbstgeschriebene Liste die mit einem long arbeitet
Eine statische liste die alle SetTime befehler hinereinander abarbeitet.
Einen befehl hinzufügen, der denn stand der prozedur abfragt
Einen befehl hinzufügen, der anzeigt wieviele prozesse
Kleiner