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);
}
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();
}
}
}
});
}
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);
}
});
}
}
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;
}
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);
}
}
Aggregations