Search in sources :

Example 1 with WorldEditUtils

use of gg.projecteden.nexus.utils.WorldEditUtils in project Nexus by ProjectEdenGG.

the class Pugmas21Command method randomizePresents.

@Path("randomizePresents")
@Permission(Group.ADMIN)
@Description("Randomizes the presents in your selection")
void randomizePresents() {
    List<Instrument> instruments = List.of(Instrument.DIDGERIDOO, Instrument.PLING);
    WorldEditUtils WEUtils = new WorldEditUtils(player());
    Region selection = WEUtils.getPlayerSelection(player());
    for (Block block : WEUtils.getBlocks(selection)) {
        if (block.getType() != Material.NOTE_BLOCK)
            continue;
        NoteBlock noteBlock = (NoteBlock) block.getBlockData();
        noteBlock.setInstrument(RandomUtils.randomElement(instruments));
        noteBlock.setNote(new Note(RandomUtils.randomInt(0, 24)));
        block.setBlockData(noteBlock);
    }
}
Also used : NoteBlock(org.bukkit.block.data.type.NoteBlock) WorldEditUtils(gg.projecteden.nexus.utils.WorldEditUtils) Note(org.bukkit.Note) Instrument(org.bukkit.Instrument) Region(com.sk89q.worldedit.regions.Region) Block(org.bukkit.block.Block) NoteBlock(org.bukkit.block.data.type.NoteBlock) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 2 with WorldEditUtils

use of gg.projecteden.nexus.utils.WorldEditUtils in project Nexus by ProjectEdenGG.

the class WorldEditUtilsCommand method clipboard.

@Path("clipboard [--build] [--async] [--entities]")
void clipboard(@Switch @Arg("false") boolean build, @Switch @Arg("false") boolean async, @Switch @Arg("false") boolean entities) {
    final WorldEditUtils utils = new WorldEditUtils(world());
    List<CompletableFuture<Void>> futures = new ArrayList<>();
    Runnable task = () -> {
        final Paster paster = utils.paster("Testing clipboard").clipboard(player()).at(location()).entities(entities);
        if (build) {
            send("Building " + (async ? "async" : "sync"));
            for (int i = 0; i < 5; i++) futures.add(paster.build());
        } else {
            send("Pasting " + (async ? "async" : "sync"));
            for (int i = 0; i < 5; i++) futures.add(paster.pasteAsync());
        }
        CompletableFutures.allOf(futures).thenRun(() -> send("done"));
    };
    if (async)
        Tasks.async(task);
    else
        task.run();
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) WorldEditUtils(gg.projecteden.nexus.utils.WorldEditUtils) ArrayList(java.util.ArrayList) Paster(gg.projecteden.nexus.utils.WorldEditUtils.Paster) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 3 with WorldEditUtils

use of gg.projecteden.nexus.utils.WorldEditUtils in project Nexus by ProjectEdenGG.

the class WorldEditUtilsCommand method rotate.

@Path("rotate [y] [x] [z]")
void rotate(int y, int x, int z) {
    final WorldEditUtils worldedit = new WorldEditUtils(player());
    worldedit.paster("Testing rotate").clipboard(worldedit.getPlayerSelection(player())).at(location()).transform(new AffineTransform().rotateY(y).rotateX(x).rotateZ(z)).pasteAsync();
}
Also used : WorldEditUtils(gg.projecteden.nexus.utils.WorldEditUtils) AffineTransform(com.sk89q.worldedit.math.transform.AffineTransform) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 4 with WorldEditUtils

use of gg.projecteden.nexus.utils.WorldEditUtils in project Nexus by ProjectEdenGG.

the class LocationCodeCommand method selection.

@Path("selection")
void selection() {
    try {
        WorldEditUtils utils = new WorldEditUtils(player());
        Region selection = utils.getPlayerSelection(player());
        if (selection == null)
            throw new IncompleteRegionException();
        Location loc = utils.toLocation(selection.getMinimumPoint());
        send(asJava(loc));
    } catch (IncompleteRegionException exception) {
        error("Incomplete region. Please select positions 1 & 2");
    }
}
Also used : WorldEditUtils(gg.projecteden.nexus.utils.WorldEditUtils) IncompleteRegionException(com.sk89q.worldedit.IncompleteRegionException) Region(com.sk89q.worldedit.regions.Region) Location(org.bukkit.Location) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 5 with WorldEditUtils

use of gg.projecteden.nexus.utils.WorldEditUtils in project Nexus by ProjectEdenGG.

the class MinigamesCommand method schemSave.

@Path("schem save <arena> <name>")
@Permission(PERMISSION_MANAGE)
void schemSave(Arena arena, String name) {
    WorldEditUtils worldedit = new WorldEditUtils(player());
    GameMode originalGameMode = player().getGameMode();
    Location originalLocation = location().clone();
    Location location = worldedit.toLocation(worldedit.getPlayerSelection(player()).getMinimumPoint());
    player().setGameMode(GameMode.SPECTATOR);
    player().teleportAsync(location);
    runCommand("mcmd /copy ;; wait 10 ;; /schem save " + (arena.getSchematicBaseName() + name) + " -f");
    Tasks.wait(20, () -> {
        player().teleportAsync(originalLocation);
        player().setGameMode(originalGameMode);
    });
    send(PREFIX + "Saved schematic " + name);
}
Also used : GameMode(org.bukkit.GameMode) WorldEditUtils(gg.projecteden.nexus.utils.WorldEditUtils) Location(org.bukkit.Location) RelativeLocation(gg.projecteden.nexus.utils.LocationUtils.RelativeLocation) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Aggregations

WorldEditUtils (gg.projecteden.nexus.utils.WorldEditUtils)18 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)14 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)5 Region (com.sk89q.worldedit.regions.Region)4 Player (com.sk89q.worldedit.entity.Player)3 Location (org.bukkit.Location)3 LocalSession (com.sk89q.worldedit.LocalSession)2 WorldEditPlugin (com.sk89q.worldedit.bukkit.WorldEditPlugin)2 Clipboard (com.sk89q.worldedit.extent.clipboard.Clipboard)2 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)2 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)2 SneakyThrows (lombok.SneakyThrows)2 ItemStack (org.bukkit.inventory.ItemStack)2 IncompleteRegionException (com.sk89q.worldedit.IncompleteRegionException)1 BukkitWorld (com.sk89q.worldedit.bukkit.BukkitWorld)1 AffineTransform (com.sk89q.worldedit.math.transform.AffineTransform)1 World (com.sk89q.worldedit.world.World)1 Description (gg.projecteden.nexus.framework.commands.models.annotations.Description)1 ItemBuilder (gg.projecteden.nexus.utils.ItemBuilder)1 RelativeLocation (gg.projecteden.nexus.utils.LocationUtils.RelativeLocation)1