Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ItemStack is = new ItemStack(Material.valueOf(args[0].toUpperCase()));
- int x1 = Math.min(pos1.getBlockX(), pos2.getBlockX());
- int y1 = Math.min(pos1.getBlockY(), pos2.getBlockY());
- int z1 = Math.min(pos1.getBlockZ(), pos2.getBlockZ());
- int x2 = Math.max(pos1.getBlockX(), pos2.getBlockX());
- int y2 = Math.max(pos1.getBlockY(), pos2.getBlockY());
- int z2 = Math.max(pos1.getBlockZ(), pos2.getBlockZ());
- HashMap<UUID, Chunk> lastchunk = new HashMap<UUID, Chunk>();
- HashMap<UUID, Integer> lastx = new HashMap<UUID, Integer>();
- HashMap<UUID, Integer> lasty = new HashMap<UUID, Integer>();
- HashMap<UUID, Integer> lastz = new HashMap<UUID, Integer>();
- HashMap<UUID, Integer> repeat = new HashMap<UUID, Integer>();
- repeat.put(player.getUniqueId(), 0);
- lastx.put(player.getUniqueId(), x1);
- lasty.put(player.getUniqueId(), y1);
- lastz.put(player.getUniqueId(), z1);
- lastchunk.put(player.getUniqueId(), null);
- TaskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(), new Runnable() {
- @Override
- public void run() {
- List<Location> setblocks = new ArrayList<Location>();
- for(int x = lastx.get(player.getUniqueId()); x <= x2; x++) {
- for(int y = lasty.get(player.getUniqueId()); y <= y2; y++) {
- for(int z = lastz.get(player.getUniqueId()); z <= z2; z++) {
- Location location = new Location(pos1.getWorld(), x, y, z);
- if(repeat.get(player.getUniqueId()) == 0) {
- repeat.put(player.getUniqueId(), 1);
- setblocks.add(location);
- lastchunk.put(player.getUniqueId(), location.getChunk());
- } else if(lastchunk.get(player.getUniqueId()).equals(location.getChunk())) {
- setblocks.add(location);
- } else {
- lastchunk.put(player.getUniqueId(), location.getChunk());
- lastx.put(player.getUniqueId(), x1 + setblocks.size() + 1);
- lasty.put(player.getUniqueId(), y1 + setblocks.size() + 1);
- lastz.put(player.getUniqueId(), z1 + setblocks.size() + 1);
- x = x2 + 1;
- y = y2 + 1;
- z = z2 + 1;
- for(Location settlocation : setblocks) {
- settlocation.getBlock().setType(is.getType());
- }
- }
- if(lastz.get(player.getUniqueId()) > z2) {
- if(setblocks.size() > 0) {
- for(Location lset : setblocks) {
- lset.getBlock().setType(is.getType());
- }
- }
- lastx.remove(player.getUniqueId());
- lasty.remove(player.getUniqueId());
- lastz.remove(player.getUniqueId());
- lastchunk.remove(player.getUniqueId());
- player.sendMessage(Msg.prefix + "§aDie Blöcke wurden erfolgreich gesetzt!");
- Bukkit.getScheduler().cancelTask(TaskID);
- }
- }
- }
- }
- }
- }, 1, 10);
Advertisement
Add Comment
Please, Sign In to add comment