Search in sources :

Example 1 with Pugmas20UserService

use of gg.projecteden.nexus.models.pugmas20.Pugmas20UserService in project Nexus by ProjectEdenGG.

the class AdventChests method onAdventChestOpen.

// Advent Methods & Listeners
@EventHandler
public void onAdventChestOpen(PlayerInteractEvent event) {
    if (event.getHand() != EquipmentSlot.HAND)
        return;
    if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK))
        return;
    if (isNullOrAir(event.getClickedBlock()))
        return;
    Player player = event.getPlayer();
    if (!Pugmas20.isAtPugmas(player))
        return;
    Block block = event.getClickedBlock();
    if (!block.getType().equals(Material.CHEST))
        return;
    AdventChest adventChest = getAdventChest(block.getLocation());
    if (adventChest == null)
        return;
    event.setCancelled(true);
    if (!Quests.hasRoomFor(player, 1)) {
        PlayerUtils.send(player, Quests.fullInvError_open);
        return;
    }
    Pugmas20UserService service = new Pugmas20UserService();
    Pugmas20User user = service.get(player);
    int chestDay = adventChest.getDay();
    LocalDate now = LocalDate.now();
    int today = LocalDate.now().getDayOfMonth();
    if (isBeforePugmas(now))
        return;
    if (isPastPugmas(now))
        return;
    boolean waypoint = !user.getLocatedDays().contains(chestDay);
    user.getLocatedDays().add(chestDay);
    service.save(user);
    boolean openChest = false;
    String reason = "";
    if (user.getFoundDays().contains(chestDay))
        reason = alreadyFound;
    else {
        if (isSecondChance(now))
            if (chestDay != 25 || user.getFoundDays().size() == 24)
                openChest = true;
            else
                reason = openPrevious;
        else if (chestDay == today)
            openChest = true;
        else {
            reason = wrongDay + " (" + AdventChests.getAdventChest(today).getDistrict().getName() + " District)";
        }
    }
    if (!openChest) {
        reason = reason.replaceAll("<day>", String.valueOf(today));
        user.sendMessage(reason);
        if (waypoint)
            user.sendMessage(PREFIX + "Chest &e#" + chestDay + " &3saved as a waypoint");
        return;
    }
    user.getFoundDays().add(chestDay);
    service.save(user);
    giveAdventHead(player, chestDay);
}
Also used : Pugmas20User(gg.projecteden.nexus.models.pugmas20.Pugmas20User) Player(org.bukkit.entity.Player) Pugmas20UserService(gg.projecteden.nexus.models.pugmas20.Pugmas20UserService) Block(org.bukkit.block.Block) AdventChest(gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest) LocalDate(java.time.LocalDate) EventHandler(org.bukkit.event.EventHandler)

Example 2 with Pugmas20UserService

use of gg.projecteden.nexus.models.pugmas20.Pugmas20UserService in project Nexus by ProjectEdenGG.

the class Pugmas20 method npcParticles.

private void npcParticles() {
    Pugmas20UserService service = new Pugmas20UserService();
    Particle particle = Particle.VILLAGER_HAPPY;
    Tasks.repeatAsync(0, TickTime.SECOND.x(2), () -> {
        for (Player player : worldguard().getPlayersInRegion(region)) {
            Pugmas20User user = service.get(player);
            for (Integer npcId : user.getNextStepNPCs()) {
                NPC npc = CitizensUtils.getNPC(npcId);
                if (npc.isSpawned()) {
                    Location loc = npc.getEntity().getLocation().add(0, 1, 0);
                    new ParticleBuilder(particle).location(loc).offset(.25, .5, .25).count(10).receivers(player).spawn();
                }
            }
        }
    });
}
Also used : Particle(org.bukkit.Particle) Pugmas20User(gg.projecteden.nexus.models.pugmas20.Pugmas20User) NPC(net.citizensnpcs.api.npc.NPC) QuestNPC(gg.projecteden.nexus.features.events.y2020.pugmas20.models.QuestNPC) Player(org.bukkit.entity.Player) Pugmas20UserService(gg.projecteden.nexus.models.pugmas20.Pugmas20UserService) ParticleBuilder(com.destroystokyo.paper.ParticleBuilder) Location(org.bukkit.Location) LocationUtils.getCenteredLocation(gg.projecteden.nexus.utils.LocationUtils.getCenteredLocation)

Example 3 with Pugmas20UserService

use of gg.projecteden.nexus.models.pugmas20.Pugmas20UserService in project Nexus by ProjectEdenGG.

the class Pugmas20 method onTeleport.

// @EventHandler
public void onTeleport(PlayerTeleportEvent event) {
    Pugmas20UserService service = new Pugmas20UserService();
    if (isAtPugmas(event.getFrom()) && !isAtPugmas(event.getTo())) {
        Pugmas20User user = service.get(event.getPlayer());
        user.storeInventory();
        service.save(user);
    }
    if (isAtPugmas(event.getTo()) && !isAtPugmas(event.getFrom())) {
        Tasks.wait(TickTime.SECOND, () -> {
            if (isAtPugmas(event.getPlayer())) {
                Pugmas20User user = service.get(event.getPlayer());
                user.applyInventory();
                service.save(user);
            }
        });
    }
}
Also used : Pugmas20User(gg.projecteden.nexus.models.pugmas20.Pugmas20User) Pugmas20UserService(gg.projecteden.nexus.models.pugmas20.Pugmas20UserService)

Example 4 with Pugmas20UserService

use of gg.projecteden.nexus.models.pugmas20.Pugmas20UserService in project Nexus by ProjectEdenGG.

the class LightTheTree method onArmorStandInteract.

@EventHandler
public void onArmorStandInteract(PlayerInteractAtEntityEvent event) {
    if (EquipmentSlot.HAND != event.getHand())
        return;
    Player player = event.getPlayer();
    if (!isAtPugmas(player))
        return;
    Entity entity = event.getRightClicked();
    if (entity.getType() != EntityType.ARMOR_STAND)
        return;
    if (!isAtPugmas(entity.getLocation(), "minerskit"))
        return;
    event.setCancelled(true);
    Pugmas20UserService service = new Pugmas20UserService();
    Pugmas20User user = service.get(player);
    if (Arrays.asList(QuestStage.NOT_STARTED, QuestStage.STARTED, QuestStage.STEP_ONE, QuestStage.STEP_TWO).contains(user.getLightTreeStage()))
        return;
    if (!Quests.hasRoomFor(player, TheMines.getMinersPickaxe(), TheMines.getMinersSieve())) {
        user.sendMessage(Quests.fullInvError_obtain);
        Quests.sound_villagerNo(player);
        return;
    }
    boolean gavePickaxe = false, gaveSieve = false;
    if (!player.getInventory().contains(TheMines.getMinersPickaxe())) {
        PlayerUtils.giveItem(player, TheMines.getMinersPickaxe());
        gavePickaxe = true;
    }
    if (!player.getInventory().contains(TheMines.getMinersSieve())) {
        PlayerUtils.giveItem(player, TheMines.getMinersSieve());
        gaveSieve = true;
    }
    if (gavePickaxe || gaveSieve) {
        String pickName = "&3&l" + stripColor(TheMines.getMinersPickaxe().getItemMeta().getDisplayName());
        String sieveName = "&3&l" + stripColor(TheMines.getMinersSieve().getItemMeta().getDisplayName());
        String obtained = Pugmas20.PREFIX + " You have obtained a ";
        if (gavePickaxe && gaveSieve)
            user.sendMessage(obtained + pickName + " and a " + sieveName);
        else if (gavePickaxe)
            user.sendMessage(obtained + pickName);
        else
            user.sendMessage(obtained + sieveName);
        Quests.sound_obtainItem(player);
    }
}
Also used : Pugmas20User(gg.projecteden.nexus.models.pugmas20.Pugmas20User) Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) Pugmas20UserService(gg.projecteden.nexus.models.pugmas20.Pugmas20UserService) EventHandler(org.bukkit.event.EventHandler)

Example 5 with Pugmas20UserService

use of gg.projecteden.nexus.models.pugmas20.Pugmas20UserService in project Nexus by ProjectEdenGG.

the class OrnamentVendor method onItemFrameInteract.

@EventHandler
public void onItemFrameInteract(PlayerInteractAtEntityEvent event) {
    if (EquipmentSlot.HAND != event.getHand())
        return;
    Player player = event.getPlayer();
    if (!isAtPugmas(player))
        return;
    Entity entity = event.getRightClicked();
    if (entity.getType() != EntityType.ITEM_FRAME)
        return;
    if (!isAtPugmas(entity.getLocation(), "lumberjacksaxe"))
        return;
    event.setCancelled(true);
    Pugmas20UserService service = new Pugmas20UserService();
    Pugmas20User user = service.get(player);
    if (user.getOrnamentVendorStage() == QuestStage.NOT_STARTED)
        return;
    if (!player.getInventory().contains(getLumberjacksAxe())) {
        if (Quests.hasRoomFor(player, getLumberjacksAxe())) {
            PlayerUtils.giveItem(player, getLumberjacksAxe());
            Quests.sound_obtainItem(player);
            user.sendMessage(Pugmas20.PREFIX + " You have obtained a &3&l" + stripColor(lumberjacksAxe.getItemMeta().getDisplayName()));
        } else {
            Quests.sound_villagerNo(player);
            user.sendMessage(Quests.fullInvError_obtain);
        }
    }
}
Also used : Pugmas20User(gg.projecteden.nexus.models.pugmas20.Pugmas20User) Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) Pugmas20UserService(gg.projecteden.nexus.models.pugmas20.Pugmas20UserService) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Pugmas20User (gg.projecteden.nexus.models.pugmas20.Pugmas20User)13 Pugmas20UserService (gg.projecteden.nexus.models.pugmas20.Pugmas20UserService)13 Player (org.bukkit.entity.Player)9 EventHandler (org.bukkit.event.EventHandler)7 Location (org.bukkit.Location)3 Block (org.bukkit.block.Block)3 Entity (org.bukkit.entity.Entity)3 ParticleBuilder (com.destroystokyo.paper.ParticleBuilder)1 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)1 QuestStage (gg.projecteden.nexus.features.events.models.QuestStage)1 Pugmas20 (gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20)1 Pugmas20.location (gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.location)1 AdventChest (gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest)1 QuestNPC (gg.projecteden.nexus.features.events.y2020.pugmas20.models.QuestNPC)1 ConfirmationMenu (gg.projecteden.nexus.features.menus.MenuUtils.ConfirmationMenu)1 ArenaManager (gg.projecteden.nexus.features.minigames.managers.ArenaManager)1 MatchManager (gg.projecteden.nexus.features.minigames.managers.MatchManager)1 Match (gg.projecteden.nexus.features.minigames.models.Match)1 MatchStartEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MatchStartEvent)1 EventUser (gg.projecteden.nexus.models.eventuser.EventUser)1