Search in sources :

Example 21 with Permission

use of gg.projecteden.nexus.framework.commands.models.annotations.Permission 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 22 with Permission

use of gg.projecteden.nexus.framework.commands.models.annotations.Permission in project Nexus by ProjectEdenGG.

the class Pugmas21Command method advent_config.

@Path("advent config set <day>")
@Permission(Group.ADMIN)
void advent_config(@Arg(min = 1, max = 25) int day) {
    final Block block = getTargetBlockRequired();
    if (block.getType() != Material.BARRIER)
        error("You must be looking at a barrier");
    adventConfig.set(day, block.getLocation());
    adventService.save(adventConfig);
    send(PREFIX + "Advent day #" + day + " configured");
}
Also used : Block(org.bukkit.block.Block) NoteBlock(org.bukkit.block.data.type.NoteBlock) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 23 with Permission

use of gg.projecteden.nexus.framework.commands.models.annotations.Permission in project Nexus by ProjectEdenGG.

the class Pugmas21Command method advent_lootOrigin.

@Path("advent config setLootOrigin")
@Permission(Group.ADMIN)
void advent_lootOrigin() {
    final Block block = getTargetBlockRequired();
    adventConfig.setLootOrigin(block.getLocation());
    adventService.save(adventConfig);
    send(PREFIX + "lootOrigin configured");
}
Also used : Block(org.bukkit.block.Block) NoteBlock(org.bukkit.block.data.type.NoteBlock) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 24 with Permission

use of gg.projecteden.nexus.framework.commands.models.annotations.Permission in project Nexus by ProjectEdenGG.

the class Pugmas21Command method advent_nearest.

@Path("advent nearest")
@Permission(Group.ADMIN)
void advent_nearest() {
    AdventPresent nearestPresent = null;
    double nearestDistance = 500;
    for (AdventPresent present : adventConfig.getPresents()) {
        double distance = present.getLocation().distance(location());
        if (distance < nearestDistance) {
            nearestDistance = distance;
            nearestPresent = present;
        }
    }
    if (nearestPresent == null)
        error("None found");
    send("Nearest: #" + nearestPresent.getDay());
}
Also used : AdventPresent(gg.projecteden.nexus.models.pugmas21.Advent21Config.AdventPresent) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 25 with Permission

use of gg.projecteden.nexus.framework.commands.models.annotations.Permission in project Nexus by ProjectEdenGG.

the class HomesCommand method fixHomeOwner.

@Async
@Permission(Group.ADMIN)
@Path("fixHomeOwner")
void fixHomeOwner() {
    AtomicInteger fixed = new AtomicInteger(0);
    List<HomeOwner> all = service.getAll();
    all.forEach(homeOwner -> {
        List<Home> collect = homeOwner.getHomes().stream().filter(home -> !homeOwner.getUuid().equals(home.getUuid())).collect(Collectors.toList());
        if (collect.isEmpty())
            return;
        fixed.getAndAdd(collect.size());
        send(PREFIX + "Fixing " + collect.size() + " homes for " + homeOwner.getNickname());
        collect.forEach(home -> home.setUuid(homeOwner.getUuid()));
        service.saveSync(homeOwner);
    });
    send(PREFIX + "Fixed " + fixed.get() + " homes");
}
Also used : Home(gg.projecteden.nexus.models.home.Home) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) MinMaxResult(gg.projecteden.utils.Utils.MinMaxResult) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) Collection(java.util.Collection) BiFunction(java.util.function.BiFunction) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) Async(gg.projecteden.annotations.Async) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) Group(gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group) Collectors(java.util.stream.Collectors) Utils(gg.projecteden.nexus.utils.Utils) OfflinePlayer(org.bukkit.OfflinePlayer) ArrayList(java.util.ArrayList) List(java.util.List) HomeOwner(gg.projecteden.nexus.models.home.HomeOwner) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) World(org.bukkit.World) Map(java.util.Map) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) Utils.getMin(gg.projecteden.nexus.utils.Utils.getMin) HomeService(gg.projecteden.nexus.models.home.HomeService) Confirm(gg.projecteden.nexus.framework.commands.models.annotations.Confirm) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HomeOwner(gg.projecteden.nexus.models.home.HomeOwner) Home(gg.projecteden.nexus.models.home.Home) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Aggregations

Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)94 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)93 Async (gg.projecteden.annotations.Async)15 JsonBuilder (gg.projecteden.nexus.utils.JsonBuilder)13 ItemStack (org.bukkit.inventory.ItemStack)13 List (java.util.List)10 CustomCommand (gg.projecteden.nexus.framework.commands.models.CustomCommand)9 Group (gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group)9 CommandEvent (gg.projecteden.nexus.framework.commands.models.events.CommandEvent)9 Arg (gg.projecteden.nexus.framework.commands.models.annotations.Arg)8 Description (gg.projecteden.nexus.framework.commands.models.annotations.Description)8 ArrayList (java.util.ArrayList)8 Nerd (gg.projecteden.nexus.models.nerd.Nerd)7 NerdService (gg.projecteden.nexus.models.nerd.NerdService)7 Utils (gg.projecteden.nexus.utils.Utils)7 HashMap (java.util.HashMap)7 BiFunction (java.util.function.BiFunction)7 Map (java.util.Map)6 Location (org.bukkit.Location)6 Aliases (gg.projecteden.nexus.framework.commands.models.annotations.Aliases)5