Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. package mc.uhchost.utils;
  2.  
  3. import java.io.InputStream;
  4. import java.util.Random;
  5.  
  6. import net.gravenilvec.TheBorders;
  7.  
  8. import org.bukkit.Chunk;
  9. import org.bukkit.Location;
  10. import org.bukkit.Material;
  11. import org.bukkit.World;
  12. import org.bukkit.entity.Entity;
  13. import org.bukkit.entity.Item;
  14. import org.bukkit.generator.BlockPopulator;
  15.  
  16. public class LobbyPopulator extends BlockPopulator {
  17.  
  18. public String filename = "Lobby.schematic";
  19.  
  20. public static TheBorders plugin;
  21.  
  22. public LobbyPopulator(TheBorders instance){
  23. plugin = instance;
  24. }
  25.  
  26. public static LobbyPopulator lobbyPopulator = new LobbyPopulator(plugin);
  27.  
  28. @SuppressWarnings("deprecation")
  29. @Override
  30. public void populate(World world, Random rand, Chunk chunk) {
  31.  
  32. if (chunk.getX() == 0 && chunk.getZ() == 0) {
  33. try {
  34.  
  35. InputStream is = plugin.getClass().getClassLoader().getResourceAsStream(filename);
  36. SchematicsManager man = new SchematicsManager();
  37. man.loadGzipedSchematic(is);
  38.  
  39. int width = man.getWidth();
  40. int height = man.getHeight();
  41. int length = man.getLength();
  42.  
  43. int starty = 139;
  44. int endy = starty + height;
  45.  
  46. for (int x = 0; x < width; x++) {
  47. for (int z = 0; z < length; z++) {
  48. int realX = x + chunk.getX() * 16;
  49. int realZ = z + chunk.getZ() * 16;
  50.  
  51. for (int y = starty; y <= endy && y < 255; y++) {
  52.  
  53. int rely = y - starty;
  54. int id = man.getBlockIdAt(x, rely, z);
  55. byte data = man.getMetadataAt(x, rely, z);
  56.  
  57. if(id == -82 && world.getBlockAt(realX, y, realZ) != null){
  58. world.getBlockAt(realX, y, realZ).setTypeIdAndData(174, data, true);
  59. }
  60.  
  61. if(id == -90 && world.getBlockAt(realX, y, realZ) != null){
  62. world.getBlockAt(realX, y, realZ).setTypeIdAndData(166, data, true);
  63. }
  64.  
  65. if(id == -112 && world.getBlockAt(realX, y, realZ) != null){
  66. world.getBlockAt(realX, y, realZ).setTypeIdAndData(144, data, true);
  67. }
  68.  
  69. if (id > -1 && world.getBlockAt(realX, y, realZ) != null){
  70. world.getBlockAt(realX, y, realZ).setTypeIdAndData(id, data, true);
  71. }
  72.  
  73.  
  74. }
  75. }
  76. }
  77.  
  78.  
  79.  
  80. if(world.getBlockAt(17, 175, 11).getType() == Material.AIR)
  81. world.getBlockAt(17, 175, 11).setType(Material.LADDER);
  82. if(world.getBlockAt(17, 176, 11).getType() == Material.AIR)
  83. world.getBlockAt(17, 176, 11).setType(Material.LADDER);
  84. if(world.getBlockAt(17, 177, 11).getType() == Material.AIR)
  85. world.getBlockAt(17, 177, 11).setType(Material.LADDER);
  86. if(world.getBlockAt(17, 178, 11).getType() == Material.AIR)
  87. world.getBlockAt(17, 178, 11).setType(Material.LADDER);
  88.  
  89. Location loc1 = new Location(world, 0, 130, 0);
  90. Location loc2 = new Location(world, 30, 190, 44);
  91. int minX = Math.min(loc1.getBlockX(), loc2.getBlockX());
  92. int minY = Math.min(loc1.getBlockY(), loc2.getBlockY());
  93. int minZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ());
  94. int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX());
  95. int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY());
  96. int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ());
  97.  
  98.  
  99.  
  100. for(int x = minX; x <= maxX; x++){
  101. for(int y = minY; y <= maxY; y++){
  102. for(int z = minZ; z <= maxZ; z++){
  103. for(Entity entity : world.getEntities()){
  104. if(entity instanceof Item)
  105. entity.remove();
  106. }
  107. }
  108. }
  109. }
  110.  
  111. } catch(Exception e){
  112. System.out.println("Could not read the schematic file");
  113. e.printStackTrace();
  114. }
  115. }
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement