Guest User

Untitled

a guest
Apr 10th, 2020
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. ItemStack is = new ItemStack(Material.valueOf(args[0].toUpperCase()));
  2.  
  3. int x1 = Math.min(pos1.getBlockX(), pos2.getBlockX());
  4. int y1 = Math.min(pos1.getBlockY(), pos2.getBlockY());
  5. int z1 = Math.min(pos1.getBlockZ(), pos2.getBlockZ());
  6.  
  7. int x2 = Math.max(pos1.getBlockX(), pos2.getBlockX());
  8. int y2 = Math.max(pos1.getBlockY(), pos2.getBlockY());
  9. int z2 = Math.max(pos1.getBlockZ(), pos2.getBlockZ());
  10.  
  11. HashMap<UUID, Chunk> lastchunk = new HashMap<UUID, Chunk>();
  12. HashMap<UUID, Integer> lastx = new HashMap<UUID, Integer>();
  13. HashMap<UUID, Integer> lasty = new HashMap<UUID, Integer>();
  14. HashMap<UUID, Integer> lastz = new HashMap<UUID, Integer>();
  15.  
  16. HashMap<UUID, Integer> repeat = new HashMap<UUID, Integer>();
  17.  
  18. repeat.put(player.getUniqueId(), 0);
  19.  
  20. lastx.put(player.getUniqueId(), x1);
  21. lasty.put(player.getUniqueId(), y1);
  22. lastz.put(player.getUniqueId(), z1);
  23. lastchunk.put(player.getUniqueId(), null);
  24.  
  25. TaskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(), new Runnable() {
  26.  
  27. @Override
  28. public void run() {
  29. List<Location> setblocks = new ArrayList<Location>();
  30. for(int x = lastx.get(player.getUniqueId()); x <= x2; x++) {
  31. for(int y = lasty.get(player.getUniqueId()); y <= y2; y++) {
  32. for(int z = lastz.get(player.getUniqueId()); z <= z2; z++) {
  33. Location location = new Location(pos1.getWorld(), x, y, z);
  34. if(repeat.get(player.getUniqueId()) == 0) {
  35. repeat.put(player.getUniqueId(), 1);
  36. setblocks.add(location);
  37. lastchunk.put(player.getUniqueId(), location.getChunk());
  38. } else if(lastchunk.get(player.getUniqueId()).equals(location.getChunk())) {
  39. setblocks.add(location);
  40. } else {
  41. lastchunk.put(player.getUniqueId(), location.getChunk());
  42. lastx.put(player.getUniqueId(), x1 + setblocks.size() + 1);
  43. lasty.put(player.getUniqueId(), y1 + setblocks.size() + 1);
  44. lastz.put(player.getUniqueId(), z1 + setblocks.size() + 1);
  45. x = x2 + 1;
  46. y = y2 + 1;
  47. z = z2 + 1;
  48. for(Location settlocation : setblocks) {
  49. settlocation.getBlock().setType(is.getType());
  50. }
  51. }
  52. if(lastz.get(player.getUniqueId()) > z2) {
  53. if(setblocks.size() > 0) {
  54. for(Location lset : setblocks) {
  55. lset.getBlock().setType(is.getType());
  56. }
  57. }
  58.  
  59. lastx.remove(player.getUniqueId());
  60. lasty.remove(player.getUniqueId());
  61. lastz.remove(player.getUniqueId());
  62. lastchunk.remove(player.getUniqueId());
  63. player.sendMessage(Msg.prefix + "§aDie Blöcke wurden erfolgreich gesetzt!");
  64. Bukkit.getScheduler().cancelTask(TaskID);
  65. }
  66. }
  67. }
  68. }
  69. }
  70. }, 1, 10);
Advertisement
Add Comment
Please, Sign In to add comment