Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Save New Duplicate & Edit Just Text Twitter
- >
- public final class SchematicHelper {
- private static final String TITLE_MESSAGE = color("&a&lBrawo!");
- private static final String SUBTITLE_MESSAGE = color("&bOsiagnales: &3{LVL} &alvl &bGeneratora!");
- private static boolean pasteSchematic(File schematicFile, Location location, boolean withAir) {
- try {
- // TODO PAMIETAC O UMIESZCZENIU SCHEMATICOW
- Vector pasteLocation = new Vector(location.getX(), location.getY(), location.getZ());
- World pasteWorld = new BukkitWorld(location.getWorld());
- WorldData pasteWorldData = pasteWorld.getWorldData();
- Clipboard clipboard = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(schematicFile)).read(pasteWorldData);
- ClipboardHolder clipboardHolder = new ClipboardHolder(clipboard, pasteWorldData);
- EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(pasteWorld, -1);
- Operation operation = clipboardHolder.createPaste(editSession, pasteWorldData).to(pasteLocation).ignoreAirBlocks(!withAir).build();
- Operations.completeLegacy(operation);
- return true;
- } catch (IOException | MaxChangedBlocksException e) {
- return false;
- }
- }
- public static void generatorCheck(Generator generator) {
- Player player = Bukkit.getPlayer(generator.getOwner());
- Location generatorCorner = generator.getLocation().clone().add(3.0D, -3.0D, -3.0D);
- for (int lvl = 2; lvl <= 5; lvl++) {
- if (generator.getLvl() != lvl) {
- continue;
- }
- File schemFile = new File(FajnyCraftGeneratory.getInst().getDataFolder(), "schematics/" + generator.getType().toString().toLowerCase() + (lvl - 1) + ".schematic");
- SchematicHelper.pasteSchematic(schemFile, generatorCorner, true);
- player.sendTitle(TITLE_MESSAGE, StringUtils.replace(SUBTITLE_MESSAGE, "{LVL}", Integer.toString(lvl)), 10, 80, 10);
- player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 3.0F, 1.0F);
- CoreDecoder.encode(generator);
- break;
- }
- }
- public static String color(String message) {
- return ChatColor.translateAlternateColorCodes('&', message);
- }
- private SchematicHelper() {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement