Search in sources :

Example 1 with Pugmas20.showWaypoint

use of gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.showWaypoint 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 Pugmas20.showWaypoint

use of gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.showWaypoint in project Nexus by ProjectEdenGG.

the class AdventChests method onDistrictEnter.

@EventHandler
public void onDistrictEnter(PlayerEnteredRegionEvent event) {
    Player player = event.getPlayer();
    if (!Pugmas20.isAtPugmas(player))
        return;
    Location loc = player.getLocation();
    if (!event.getRegion().getId().matches(District.getRegion() + ".*"))
        return;
    District district = District.of(loc);
    if (district != District.UNKNOWN)
        ActionBarUtils.sendActionBar(player, "&a&lEntering " + district.getName() + " District");
}
Also used : Player(org.bukkit.entity.Player) District(gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest.District) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 3 with Pugmas20.showWaypoint

use of gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.showWaypoint in project Nexus by ProjectEdenGG.

the class AdventChests method onDistrictExit.

@EventHandler
public void onDistrictExit(PlayerLeavingRegionEvent event) {
    Player player = event.getPlayer();
    if (!Pugmas20.isAtPugmas(player))
        return;
    Location loc = player.getLocation();
    if (!event.getRegion().getId().matches(District.getRegion() + ".*"))
        return;
    District district = District.of(loc);
    if (district != District.UNKNOWN)
        ActionBarUtils.sendActionBar(player, "&c&lExiting " + district.getName() + " District");
}
Also used : Player(org.bukkit.entity.Player) District(gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest.District) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 4 with Pugmas20.showWaypoint

use of gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.showWaypoint 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 Pugmas20.showWaypoint

use of gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.showWaypoint in project Nexus by ProjectEdenGG.

the class ToyTesting method onClickGameSkull.

@EventHandler
public void onClickGameSkull(PlayerInteractEvent event) {
    if (!EquipmentSlot.HAND.equals(event.getHand()))
        return;
    Player player = event.getPlayer();
    if (!Pugmas20.isAtPugmas(player))
        return;
    Block block = event.getClickedBlock();
    if (isNullOrAir(block))
        return;
    Toy toy = Toy.of(block.getLocation());
    if (toy == null)
        return;
    Predicate<String> isStarted = name -> MatchManager.get(ArenaManager.get(name)).isStarted();
    if (toy.equals(Toy.BATTLESHIP)) {
        if (isStarted.test("AlphaVsOmega")) {
            PlayerUtils.send(player, error);
            return;
        }
    } else if (toy.equals(Toy.MASTERMIND)) {
        if (isStarted.test("MasterMind")) {
            PlayerUtils.send(player, error);
            return;
        }
    }
    Pugmas20UserService service = new Pugmas20UserService();
    Pugmas20User user = service.get(player);
    List<String> lore = new ArrayList<>();
    if (user.getToyTestingStage() != QuestStage.NOT_STARTED)
        lore.addAll(List.of("", "&fUse &c/pugmas toys &fto", "&freturn to this location"));
    ConfirmationMenu.builder().title("Play " + camelCase(toy) + "?").confirmLore(lore).onConfirm(e -> PlayerUtils.runCommandAsOp(player, toy.getCommand())).open(player);
}
Also used : Getter(lombok.Getter) Pugmas20.location(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.location) Player(org.bukkit.entity.Player) Match(gg.projecteden.nexus.features.minigames.models.Match) ArrayList(java.util.ArrayList) EventHandler(org.bukkit.event.EventHandler) PlayerUtils(gg.projecteden.nexus.utils.PlayerUtils) ArenaManager(gg.projecteden.nexus.features.minigames.managers.ArenaManager) Block(org.bukkit.block.Block) Location(org.bukkit.Location) QuestStage(gg.projecteden.nexus.features.events.models.QuestStage) MaterialTag(gg.projecteden.nexus.utils.MaterialTag) BiConsumer(java.util.function.BiConsumer) Pugmas20User(gg.projecteden.nexus.models.pugmas20.Pugmas20User) PlayerInteractEvent(org.bukkit.event.player.PlayerInteractEvent) Pugmas20UserService(gg.projecteden.nexus.models.pugmas20.Pugmas20UserService) WorldGuardUtils(gg.projecteden.nexus.utils.WorldGuardUtils) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ConfirmationMenu(gg.projecteden.nexus.features.menus.MenuUtils.ConfirmationMenu) Listener(org.bukkit.event.Listener) Predicate(java.util.function.Predicate) StringUtils.camelCase(gg.projecteden.nexus.utils.StringUtils.camelCase) Pugmas20(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20) MatchStartEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchStartEvent) List(java.util.List) Nullables.isNullOrAir(gg.projecteden.nexus.utils.Nullables.isNullOrAir) MatchManager(gg.projecteden.nexus.features.minigames.managers.MatchManager) AllArgsConstructor(lombok.AllArgsConstructor) Collections(java.util.Collections) NoArgsConstructor(lombok.NoArgsConstructor) Pugmas20User(gg.projecteden.nexus.models.pugmas20.Pugmas20User) Player(org.bukkit.entity.Player) Pugmas20UserService(gg.projecteden.nexus.models.pugmas20.Pugmas20UserService) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Player (org.bukkit.entity.Player)4 EventHandler (org.bukkit.event.EventHandler)4 AdventChest (gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest)3 District (gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest.District)3 Pugmas20User (gg.projecteden.nexus.models.pugmas20.Pugmas20User)3 Pugmas20UserService (gg.projecteden.nexus.models.pugmas20.Pugmas20UserService)3 Location (org.bukkit.Location)3 QuestStage (gg.projecteden.nexus.features.events.models.QuestStage)2 Pugmas20 (gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20)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 Block (org.bukkit.block.Block)2 Listener (org.bukkit.event.Listener)2 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)1 Environments (gg.projecteden.annotations.Environments)1 AdventChests (gg.projecteden.nexus.features.events.y2020.pugmas20.AdventChests)1 Pugmas20.isBeforePugmas (gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isBeforePugmas)1