Search in sources :

Example 1 with AdventPresent

use of gg.projecteden.nexus.models.pugmas21.Advent21Config.AdventPresent 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 2 with AdventPresent

use of gg.projecteden.nexus.models.pugmas21.Advent21Config.AdventPresent in project Nexus by ProjectEdenGG.

the class Advent method onClickPresent.

@EventHandler
public void onClickPresent(PlayerInteractEvent event) {
    final Player player = event.getPlayer();
    if (event.getHand() != EquipmentSlot.HAND)
        return;
    if (!Pugmas21.isAtPugmas(player))
        return;
    final Block block = event.getClickedBlock();
    if (block == null)
        return;
    if (block.getType() != Material.BARRIER)
        return;
    if (Pugmas21.isPastPugmas())
        return;
    final Advent21Config adventConfig = new Advent21ConfigService().get0();
    final AdventPresent present = adventConfig.get(block.getLocation());
    if (present == null)
        return;
    new Pugmas21UserService().edit(player, user -> user.advent().tryCollect(present));
}
Also used : Player(org.bukkit.entity.Player) Pugmas21UserService(gg.projecteden.nexus.models.pugmas21.Pugmas21UserService) Advent21Config(gg.projecteden.nexus.models.pugmas21.Advent21Config) Advent21ConfigService(gg.projecteden.nexus.models.pugmas21.Advent21ConfigService) Block(org.bukkit.block.Block) AdventPresent(gg.projecteden.nexus.models.pugmas21.Advent21Config.AdventPresent) EventHandler(org.bukkit.event.EventHandler)

Aggregations

AdventPresent (gg.projecteden.nexus.models.pugmas21.Advent21Config.AdventPresent)2 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)1 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)1 Advent21Config (gg.projecteden.nexus.models.pugmas21.Advent21Config)1 Advent21ConfigService (gg.projecteden.nexus.models.pugmas21.Advent21ConfigService)1 Pugmas21UserService (gg.projecteden.nexus.models.pugmas21.Pugmas21UserService)1 Block (org.bukkit.block.Block)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1