use of gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isBeforePugmas 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);
}
use of gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isBeforePugmas 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);
}
use of gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isBeforePugmas 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");
}
use of gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isBeforePugmas 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");
}
use of gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isBeforePugmas 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;
}
Aggregations