Search in sources :

Example 1 with Pugmas20User

use of gg.projecteden.nexus.models.pugmas20.Pugmas20User 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 Pugmas20User

use of gg.projecteden.nexus.models.pugmas20.Pugmas20User 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 Pugmas20User

use of gg.projecteden.nexus.models.pugmas20.Pugmas20User 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 Pugmas20User

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

the class Pugmas20Command method getIngotsLeft.

private int getIngotsLeft(Pugmas20User user, List<TradeBuilder> trades, OreType oreType) {
    Optional<Integer> amount = trades.stream().map(tradeBuilder -> tradeBuilder.getIngredients().iterator().next()).filter(ingredient -> ingredient.getType() == oreType.getIngot().getType()).map(ItemStack::getAmount).findFirst();
    int tokensLeft = Math.abs(Pugmas20.checkDailyTokens(user, "themines_" + oreType.name(), 0));
    int perToken = amount.orElse(0);
    return tokensLeft * perToken;
}
Also used : ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) AdventChest(gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest) Pugmas20QuestStageHelper(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.Quests.Pugmas20QuestStageHelper) TabCompleteIgnore(gg.projecteden.nexus.framework.commands.models.annotations.TabCompleteIgnore) LightTheTree(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.LightTheTree) Pugmas20.isSecondChance(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isSecondChance) PlayerUtils(gg.projecteden.nexus.utils.PlayerUtils) EventUser(gg.projecteden.nexus.models.eventuser.EventUser) QuestStage(gg.projecteden.nexus.features.events.models.QuestStage) AdventMenu(gg.projecteden.nexus.features.events.y2020.pugmas20.menu.AdventMenu) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) Pugmas20.showWaypoint(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.showWaypoint) Timespan(gg.projecteden.utils.TimeUtils.Timespan) Material(org.bukkit.Material) QuestNPC.getUnplayedToysList(gg.projecteden.nexus.features.events.y2020.pugmas20.models.QuestNPC.getUnplayedToysList) Env(gg.projecteden.utils.Env) Bukkit(org.bukkit.Bukkit) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) OreType(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.TheMines.OreType) OrnamentVendor(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.OrnamentVendor) Set(java.util.Set) HideFromHelp(gg.projecteden.nexus.framework.commands.models.annotations.HideFromHelp) Collectors(java.util.stream.Collectors) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) TradeBuilder(gg.projecteden.nexus.utils.MerchantBuilder.TradeBuilder) LocalDate(java.time.LocalDate) Optional(java.util.Optional) Pugmas20.isPastPugmas(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isPastPugmas) TheMines(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.TheMines) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) EventUserService(gg.projecteden.nexus.models.eventuser.EventUserService) PugmasTreeType(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.OrnamentVendor.PugmasTreeType) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) HashMap(java.util.HashMap) Group(gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group) MerchantNPC(gg.projecteden.nexus.features.events.y2020.pugmas20.models.Merchants.MerchantNPC) ArrayList(java.util.ArrayList) Environments(gg.projecteden.annotations.Environments) Ornament(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.OrnamentVendor.Ornament) Pugmas20User(gg.projecteden.nexus.models.pugmas20.Pugmas20User) Train(gg.projecteden.nexus.features.events.y2020.pugmas20.Train) Pugmas20UserService(gg.projecteden.nexus.models.pugmas20.Pugmas20UserService) Listener(org.bukkit.event.Listener) TeleportCause(org.bukkit.event.player.PlayerTeleportEvent.TeleportCause) Pugmas20(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20) ToyTesting(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.ToyTesting) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) District(gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest.District) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) Pugmas20.isBeforePugmas(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isBeforePugmas) Pugmas20Quest(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.Quests.Pugmas20Quest) AdventChests(gg.projecteden.nexus.features.events.y2020.pugmas20.AdventChests) NoArgsConstructor(lombok.NoArgsConstructor) Pugmas20.showWaypoint(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.showWaypoint)

Example 5 with Pugmas20User

use of gg.projecteden.nexus.models.pugmas20.Pugmas20User 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)

Aggregations

Pugmas20User (gg.projecteden.nexus.models.pugmas20.Pugmas20User)14 Pugmas20UserService (gg.projecteden.nexus.models.pugmas20.Pugmas20UserService)14 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 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)2 QuestStage (gg.projecteden.nexus.features.events.models.QuestStage)2 Pugmas20 (gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20)2 AdventChest (gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest)2 PlayerUtils (gg.projecteden.nexus.utils.PlayerUtils)2 LocalDate (java.time.LocalDate)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 NoArgsConstructor (lombok.NoArgsConstructor)2 Listener (org.bukkit.event.Listener)2 ParticleBuilder (com.destroystokyo.paper.ParticleBuilder)1 Environments (gg.projecteden.annotations.Environments)1 AdventChests (gg.projecteden.nexus.features.events.y2020.pugmas20.AdventChests)1