use of com.leonardobishop.quests.common.player.questprogressfile.TaskProgress in project Quests by LMBishop.
the class FarmingCertainTaskType method onBlockBreak.
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
if (!(event.getBlock().getState().getBlockData() instanceof Ageable)) {
return;
}
QPlayer qPlayer = plugin.getPlayerManager().getPlayer(event.getPlayer().getUniqueId());
if (qPlayer == null) {
return;
}
Ageable crop = (Ageable) event.getBlock().getState().getBlockData();
if (crop.getAge() != crop.getMaximumAge()) {
return;
}
for (Quest quest : super.getRegisteredQuests()) {
if (qPlayer.hasStartedQuest(quest)) {
QuestProgress questProgress = qPlayer.getQuestProgressFile().getQuestProgress(quest);
for (Task task : quest.getTasksOfType(super.getType())) {
if (!TaskUtils.validateWorld(event.getPlayer(), task))
continue;
TaskProgress taskProgress = questProgress.getTaskProgress(task.getId());
if (taskProgress.isCompleted()) {
continue;
}
if (matchBlock(task, event.getBlock())) {
int brokenBlocksNeeded = (int) task.getConfigValue("amount");
int progressBlocksBroken;
if (taskProgress.getProgress() == null) {
progressBlocksBroken = 0;
} else {
progressBlocksBroken = (int) taskProgress.getProgress();
}
taskProgress.setProgress(progressBlocksBroken + 1);
if (((int) taskProgress.getProgress()) >= brokenBlocksNeeded) {
taskProgress.setCompleted(true);
}
}
}
}
}
}
use of com.leonardobishop.quests.common.player.questprogressfile.TaskProgress in project Quests by LMBishop.
the class FarmingTaskType method onBlockBreak.
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
if (!(event.getBlock().getState().getBlockData() instanceof Ageable)) {
return;
}
QPlayer qPlayer = plugin.getPlayerManager().getPlayer(event.getPlayer().getUniqueId());
if (qPlayer == null) {
return;
}
Ageable crop = (Ageable) event.getBlock().getState().getBlockData();
if (crop.getAge() != crop.getMaximumAge()) {
return;
}
for (Quest quest : super.getRegisteredQuests()) {
if (qPlayer.hasStartedQuest(quest)) {
QuestProgress questProgress = qPlayer.getQuestProgressFile().getQuestProgress(quest);
for (Task task : quest.getTasksOfType(super.getType())) {
if (!TaskUtils.validateWorld(event.getPlayer(), task))
continue;
TaskProgress taskProgress = questProgress.getTaskProgress(task.getId());
if (taskProgress.isCompleted()) {
continue;
}
int brokenBlocksNeeded = (int) task.getConfigValue("amount");
int progressBlocksBroken;
if (taskProgress.getProgress() == null) {
progressBlocksBroken = 0;
} else {
progressBlocksBroken = (int) taskProgress.getProgress();
}
taskProgress.setProgress(progressBlocksBroken + 1);
if (((int) taskProgress.getProgress()) >= brokenBlocksNeeded) {
taskProgress.setCompleted(true);
}
}
}
}
}
use of com.leonardobishop.quests.common.player.questprogressfile.TaskProgress in project Quests by LMBishop.
the class MythicMobsKillingType method onMobKill.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMobKill(MythicMobDeathEvent event) {
Entity killer = event.getKiller();
Entity mob = event.getEntity();
if (mob == null || mob instanceof Player) {
return;
}
if (killer == null) {
return;
}
String mobName = event.getMobType().getInternalName();
double level = event.getMobLevel();
QPlayer qPlayer = plugin.getPlayerManager().getPlayer(killer.getUniqueId());
if (qPlayer == null) {
return;
}
for (Quest quest : super.getRegisteredQuests()) {
if (qPlayer.hasStartedQuest(quest)) {
QuestProgress questProgress = qPlayer.getQuestProgressFile().getQuestProgress(quest);
for (Task task : quest.getTasksOfType(super.getType())) {
if (!TaskUtils.validateWorld(killer.getWorld().getName(), task))
continue;
TaskProgress taskProgress = questProgress.getTaskProgress(task.getId());
if (taskProgress.isCompleted()) {
continue;
}
String configName = (String) task.getConfigValue("name");
int minMobLevel = (int) task.getConfigValue("min-level", -1);
int requiredLevel = (int) task.getConfigValue("level", -1);
if (!mobName.equals(configName) || level < minMobLevel) {
return;
}
if (requiredLevel != -1 && level != requiredLevel) {
return;
}
int mobKillsNeeded = (int) task.getConfigValue("amount");
int progressKills;
if (taskProgress.getProgress() == null) {
progressKills = 0;
} else {
progressKills = (int) taskProgress.getProgress();
}
taskProgress.setProgress(progressKills + 1);
if (((int) taskProgress.getProgress()) >= mobKillsNeeded) {
taskProgress.setCompleted(true);
}
}
}
}
}
use of com.leonardobishop.quests.common.player.questprogressfile.TaskProgress in project Quests by LMBishop.
the class FabledSkyblockLevelTaskType method onIslandLevel.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onIslandLevel(IslandLevelChangeEvent event) {
List<UUID> members = new ArrayList<>();
members.add(event.getIsland().getOwnerUUID());
members.addAll(event.getIsland().getCoopPlayers().keySet());
for (UUID member : members) {
QPlayer qPlayer = plugin.getPlayerManager().getPlayer(member);
if (qPlayer == null) {
continue;
}
for (Quest quest : super.getRegisteredQuests()) {
if (qPlayer.hasStartedQuest(quest)) {
QuestProgress questProgress = qPlayer.getQuestProgressFile().getQuestProgress(quest);
for (Task task : quest.getTasksOfType(super.getType())) {
TaskProgress taskProgress = questProgress.getTaskProgress(task.getId());
if (taskProgress.isCompleted()) {
continue;
}
int islandValueNeeded = (int) task.getConfigValue("level");
taskProgress.setProgress(event.getLevel().getLevel());
if (((double) taskProgress.getProgress()) >= islandValueNeeded) {
taskProgress.setCompleted(true);
}
}
}
}
}
}
use of com.leonardobishop.quests.common.player.questprogressfile.TaskProgress in project Quests by LMBishop.
the class MythicMobsKillingType method handle.
private void handle(LivingEntity killer, Entity mob, String mobName, double level) {
if (killer == null) {
return;
}
if (mob == null || mob instanceof Player) {
return;
}
QPlayer qPlayer = plugin.getPlayerManager().getPlayer(killer.getUniqueId());
if (qPlayer == null) {
return;
}
for (Quest quest : super.getRegisteredQuests()) {
if (qPlayer.hasStartedQuest(quest)) {
QuestProgress questProgress = qPlayer.getQuestProgressFile().getQuestProgress(quest);
for (Task task : quest.getTasksOfType(super.getType())) {
if (!TaskUtils.validateWorld(killer.getWorld().getName(), task))
continue;
TaskProgress taskProgress = questProgress.getTaskProgress(task.getId());
if (taskProgress.isCompleted()) {
continue;
}
String configName = (String) task.getConfigValue("name");
int minMobLevel = (int) task.getConfigValue("min-level", -1);
int requiredLevel = (int) task.getConfigValue("level", -1);
if (!mobName.equals(configName) || level < minMobLevel) {
return;
}
if (requiredLevel != -1 && level != requiredLevel) {
return;
}
int mobKillsNeeded = (int) task.getConfigValue("amount");
int progressKills;
if (taskProgress.getProgress() == null) {
progressKills = 0;
} else {
progressKills = (int) taskProgress.getProgress();
}
taskProgress.setProgress(progressKills + 1);
if (((int) taskProgress.getProgress()) >= mobKillsNeeded) {
taskProgress.setCompleted(true);
}
}
}
}
}
Aggregations