daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest Jun 21st, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Save New Duplicate & Edit Just Text Twitter
  3. >
  4. public final class SchematicHelper {
  5.  
  6.     private static final String TITLE_MESSAGE = color("&a&lBrawo!");
  7.     private static final String SUBTITLE_MESSAGE = color("&bOsiagnales: &3{LVL} &alvl &bGeneratora!");
  8.  
  9.     private static boolean pasteSchematic(File schematicFile, Location location, boolean withAir) {
  10.         try {
  11.             // TODO PAMIETAC O UMIESZCZENIU SCHEMATICOW
  12.             Vector pasteLocation = new Vector(location.getX(), location.getY(), location.getZ());
  13.             World pasteWorld = new BukkitWorld(location.getWorld());
  14.             WorldData pasteWorldData = pasteWorld.getWorldData();
  15.  
  16.             Clipboard clipboard = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(schematicFile)).read(pasteWorldData);
  17.             ClipboardHolder clipboardHolder = new ClipboardHolder(clipboard, pasteWorldData);
  18.             EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(pasteWorld, -1);
  19.  
  20.             Operation operation = clipboardHolder.createPaste(editSession, pasteWorldData).to(pasteLocation).ignoreAirBlocks(!withAir).build();
  21.             Operations.completeLegacy(operation);
  22.            
  23.             return true;
  24.         } catch (IOException | MaxChangedBlocksException e) {
  25.             return false;
  26.         }
  27.     }
  28.  
  29.     public static void generatorCheck(Generator generator) {
  30.         Player player = Bukkit.getPlayer(generator.getOwner());
  31.         Location generatorCorner = generator.getLocation().clone().add(3.0D, -3.0D, -3.0D);
  32.  
  33.         for (int lvl = 2; lvl <= 5; lvl++) {
  34.             if (generator.getLvl() != lvl) {
  35.                 continue;
  36.             }
  37.  
  38.             File schemFile = new File(FajnyCraftGeneratory.getInst().getDataFolder(), "schematics/" + generator.getType().toString().toLowerCase() + (lvl - 1) + ".schematic");
  39.             SchematicHelper.pasteSchematic(schemFile, generatorCorner, true);
  40.             player.sendTitle(TITLE_MESSAGE, StringUtils.replace(SUBTITLE_MESSAGE, "{LVL}", Integer.toString(lvl)), 10, 80, 10);
  41.             player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 3.0F, 1.0F);
  42.             CoreDecoder.encode(generator);
  43.  
  44.             break;
  45.         }
  46.     }
  47.  
  48.     public static String color(String message) {
  49.         return ChatColor.translateAlternateColorCodes('&', message);
  50.     }
  51.  
  52.     private SchematicHelper() {}
  53.  
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top