aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/me/fatpigsarefat/quests/quests/tasktypes/types/DistancefromTaskType.java83
-rw-r--r--src/main/resources/config.yml33
2 files changed, 116 insertions, 0 deletions
diff --git a/src/main/java/me/fatpigsarefat/quests/quests/tasktypes/types/DistancefromTaskType.java b/src/main/java/me/fatpigsarefat/quests/quests/tasktypes/types/DistancefromTaskType.java
new file mode 100644
index 00000000..3c8fe64f
--- /dev/null
+++ b/src/main/java/me/fatpigsarefat/quests/quests/tasktypes/types/DistancefromTaskType.java
@@ -0,0 +1,83 @@
+package me.fatpigsarefat.quests.quests.tasktypes.types;
+
+import me.fatpigsarefat.quests.Quests;
+import me.fatpigsarefat.quests.player.QPlayer;
+import me.fatpigsarefat.quests.player.questprogressfile.QuestProgress;
+import me.fatpigsarefat.quests.player.questprogressfile.QuestProgressFile;
+import me.fatpigsarefat.quests.player.questprogressfile.TaskProgress;
+import me.fatpigsarefat.quests.quests.Quest;
+import me.fatpigsarefat.quests.quests.Task;
+import me.fatpigsarefat.quests.quests.tasktypes.ConfigValue;
+import me.fatpigsarefat.quests.quests.tasktypes.TaskType;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerMoveEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public final class DistancefromTaskType extends TaskType {
+
+ private List<ConfigValue> creatorConfigValues = new ArrayList<>();
+
+ public DistancefromTaskType() {
+ super("distancefrom", "fatpigsarefat", "Distance yourself from a set of co-ordinates.");
+ this.creatorConfigValues.add(new ConfigValue("x", true, "X position."));
+ this.creatorConfigValues.add(new ConfigValue("y", true, "Y position."));
+ this.creatorConfigValues.add(new ConfigValue("z", true, "Z position."));
+ this.creatorConfigValues.add(new ConfigValue("world", true, "Name of world."));
+ this.creatorConfigValues.add(new ConfigValue("distance", true, "Distance the player needs to be from the co-ordinates."));
+ }
+
+ @Override
+ public List<ConfigValue> getCreatorConfigValues() {
+ return creatorConfigValues;
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
+ public void onMove(PlayerMoveEvent event) {
+ if (event.getFrom().getBlockX() == event.getTo().getBlockX() && event.getFrom().getBlockZ() == event.getTo().getBlockZ()) {
+ return;
+ }
+
+ Player player = event.getPlayer();
+
+ QPlayer qPlayer = Quests.getPlayerManager().getPlayer(player.getUniqueId());
+ QuestProgressFile questProgressFile = qPlayer.getQuestProgressFile();
+
+ for (Quest quest : super.getRegisteredQuests()) {
+ if (questProgressFile.hasStartedQuest(quest)) {
+ QuestProgress questProgress = questProgressFile.getQuestProgress(quest);
+
+ for (Task task : quest.getTasksOfType(super.getType())) {
+ TaskProgress taskProgress = questProgress.getTaskProgress(task.getId());
+
+ if (taskProgress.isCompleted()) {
+ continue;
+ }
+
+ int x = (int) task.getConfigValue("x");
+ int y = (int) task.getConfigValue("y");
+ int z = (int) task.getConfigValue("z");
+ String worldString = (String) task.getConfigValue("world");
+ int distance = (int) task.getConfigValue("distance");
+
+ World world = Bukkit.getWorld(worldString);
+ if (world == null) {
+ return;
+ }
+
+ Location location = new Location(world, x, y, z);
+ if (player.getWorld().equals(world) && player.getLocation().distance(location) > distance) {
+ taskProgress.setCompleted(true);
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index a293351d..e5318fa5 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -578,6 +578,39 @@ quests:
enabled: true
time: 1440
+ distancefrom1:
+ tasks:
+ distancefrom:
+ type: "distancefrom"
+ x: 0
+ y: 0
+ z: 0
+ world: "world"
+ distance: 10000
+ display:
+ name: "&cExplorer"
+ lore-normal:
+ - "&7This quest requires you to:"
+ - "&7 - Walk 10km away from the coords 0,0."
+ - ""
+ - "&7Rewards:"
+ - "&7 - $500 added to your in-game balance."
+ lore-started:
+ - ""
+ - "&7Your current progression:"
+ - "&7 - {distancefrom:progress}m/10000m walked."
+ type: "STICK"
+ rewards:
+ - "eco give {player} 100"
+ options:
+ category: "medium"
+ requires:
+ - ""
+ repeatable: true
+ cooldown:
+ enabled: true
+ time: 1440
+
mining2:
tasks:
mining: