aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authornicuch <nicuch100@gmail.com>2020-01-12 10:31:27 +0200
committernicuch <nicuch100@gmail.com>2020-01-12 10:31:27 +0200
commita54bf34c41a2ceb1e8bf5e7be2957892df0c8ce9 (patch)
tree6ae58224ca37d2f23bc0484420b332628319022f /src/main/java
parent9025b3b760a25e98466128cd09cd456c037cfc9c (diff)
The javadoc says that method getKiller() should return a player entity or null.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/leonardobishop/quests/Quests.java12
-rw-r--r--src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java4
-rw-r--r--src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingCertainTaskType.java11
-rw-r--r--src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingTaskType.java11
-rw-r--r--src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MythicMobsKillingType.java2
-rw-r--r--src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlayerkillingTaskType.java13
6 files changed, 12 insertions, 41 deletions
diff --git a/src/main/java/com/leonardobishop/quests/Quests.java b/src/main/java/com/leonardobishop/quests/Quests.java
index 7ec6d52d..add72bc0 100644
--- a/src/main/java/com/leonardobishop/quests/Quests.java
+++ b/src/main/java/com/leonardobishop/quests/Quests.java
@@ -130,7 +130,7 @@ public class Quests extends JavaPlugin {
this.getLogger().log(Level.INFO, "Metrics started. This can be disabled at /plugins/bStats/config.yml.");
}
- questsConfigLoader = new QuestsConfigLoader(Quests.this);
+ questsConfigLoader = new QuestsConfigLoader(this);
Bukkit.getScheduler().runTask(this, () -> {
taskTypeManager.registerTaskType(new MiningTaskType());
@@ -171,11 +171,11 @@ public class Quests extends JavaPlugin {
reloadQuests();
if (!questsConfigLoader.getBrokenFiles().isEmpty()) {
- Quests.this.getLogger().warning("Quests has failed to load the following files:");
+ this.getLogger().warning("Quests has failed to load the following files:");
for (Map.Entry<String, QuestsConfigLoader.ConfigLoadError> entry : questsConfigLoader.getBrokenFiles().entrySet()) {
- Quests.this.getLogger().warning(" - " + entry.getKey() + ": " + entry.getValue().getMessage());
+ this.getLogger().warning(" - " + entry.getKey() + ": " + entry.getValue().getMessage());
}
- Quests.this.getLogger().warning(ChatColor.GRAY.toString() + ChatColor.ITALIC + "If this is your first time using Quests, please delete the Quests folder and RESTART (not reload!) the server.");
+ this.getLogger().warning(ChatColor.GRAY.toString() + ChatColor.ITALIC + "If this is your first time using Quests, please delete the Quests folder and RESTART (not reload!) the server.");
}
for (Player player : Bukkit.getOnlinePlayers()) {
@@ -196,7 +196,7 @@ public class Quests extends JavaPlugin {
continue;
}
QuestProgressFile questProgressFile = qPlayer.getQuestProgressFile();
- for (Map.Entry<String, Quest> entry : Quests.this.getQuestManager().getQuests().entrySet()) {
+ for (Map.Entry<String, Quest> entry : this.getQuestManager().getQuests().entrySet()) {
Quest quest = entry.getValue();
QuestProgress questProgress = questProgressFile.getQuestProgress(quest);
if (questProgressFile.hasStartedQuest(quest)) {
@@ -216,7 +216,7 @@ public class Quests extends JavaPlugin {
}
}, 10 * 20L, 10 * 20L); //Data is saved every 10 seconds in case of crash; the player data is also saved when the player leaves the server
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
- updater = new Updater(Quests.this);
+ updater = new Updater(this);
updater.check();
});
}
diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java
index 2cc52557..a6cc2fd2 100644
--- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java
+++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java
@@ -45,9 +45,9 @@ public final class InventoryTaskType extends TaskType {
Bukkit.getScheduler().runTaskLater(Quests.get(), () -> this.checkInventory(event.getPlayer()), 1L);
}
- @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
+ @EventHandler(priority = EventPriority.MONITOR/*, ignoreCancelled = true*/)
public void onInventoryClick(InventoryInteractEvent event) {
- Bukkit.getScheduler().runTaskLater(Quests.get(), () -> checkInventory((Player) event.getWhoClicked()), 1L);
+ Bukkit.getScheduler().runTaskLater(Quests.get(), () -> checkInventory((Player) event.getWhoClicked()), 1L); //Still some work to do as it doesn't really work
}
@SuppressWarnings("deprecation")
diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingCertainTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingCertainTaskType.java
index 2c80bfe9..5059c9c4 100644
--- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingCertainTaskType.java
+++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingCertainTaskType.java
@@ -40,22 +40,13 @@ public final class MobkillingCertainTaskType extends TaskType {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMobKill(EntityDeathEvent event) {
- Entity killer = event.getEntity().getKiller();
+ Player killer = event.getEntity().getKiller();
Entity mob = event.getEntity();
if (mob == null || mob instanceof Player) {
return;
}
- if (killer instanceof Projectile) {
- ProjectileSource source = ((Projectile) killer).getShooter();
- if (source == null)
- return;
- if (source instanceof Player)
- killer = (Entity) source;
- else return;
- }
-
if (killer == null) {
return;
}
diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingTaskType.java
index d4e286de..03da5903 100644
--- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingTaskType.java
+++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingTaskType.java
@@ -35,22 +35,13 @@ public final class MobkillingTaskType extends TaskType {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMobKill(EntityDeathEvent event) {
- Entity killer = event.getEntity().getKiller(); //The killer is an entity, and projectiles counts as entities too.
+ Player killer = event.getEntity().getKiller(); //The killer is a player
Entity mob = event.getEntity();
if (mob == null || mob instanceof Player) {
return;
}
- if (killer instanceof Projectile) {
- ProjectileSource source = ((Projectile) killer).getShooter();
- if (source == null)
- return;
- if (source instanceof Player)
- killer = (Entity) source;
- else return;
- }
-
if (killer == null) {
return;
}
diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MythicMobsKillingType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MythicMobsKillingType.java
index 9f356480..695df8fd 100644
--- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MythicMobsKillingType.java
+++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MythicMobsKillingType.java
@@ -44,7 +44,7 @@ public final class MythicMobsKillingType extends TaskType {
return;
}
- if (killer instanceof Projectile) {
+ if (killer instanceof Projectile) { //killer can be a projectile
ProjectileSource source = ((Projectile) killer).getShooter();
if (source == null)
return;
diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlayerkillingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlayerkillingTaskType.java
index b24bf867..a04871f8 100644
--- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlayerkillingTaskType.java
+++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlayerkillingTaskType.java
@@ -11,11 +11,9 @@ import com.leonardobishop.quests.quests.tasktypes.ConfigValue;
import com.leonardobishop.quests.quests.tasktypes.TaskType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
-import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDeathEvent;
-import org.bukkit.projectiles.ProjectileSource;
import java.util.ArrayList;
import java.util.List;
@@ -37,22 +35,13 @@ public final class PlayerkillingTaskType extends TaskType {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMobKill(EntityDeathEvent event) {
- Entity killer = event.getEntity().getKiller();
+ Player killer = event.getEntity().getKiller();
Entity mob = event.getEntity();
if (!(mob instanceof Player)) {
return;
}
- if (killer instanceof Projectile) {
- ProjectileSource source = ((Projectile) killer).getShooter();
- if (source == null)
- return;
- if (source instanceof Player)
- killer = (Entity) source;
- else return;
- }
-
if (killer == null) {
return;
}