From 73bb925df29e234e7364498380667a11fa57d96a Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sat, 16 Jan 2016 20:55:46 +0100 Subject: [PATCH] Fix cast exceptions --- .../github/dre2n/dungeonsxl/DungeonsXL.java | 19 ++++++++++--------- .../github/dre2n/dungeonsxl/sign/MobSign.java | 9 +++++---- .../dre2n/dungeonsxl/sign/MythicMobsSign.java | 9 +++++---- .../dre2n/dungeonsxl/sign/RedstoneSign.java | 17 +++++++++-------- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/io/github/dre2n/dungeonsxl/DungeonsXL.java b/src/io/github/dre2n/dungeonsxl/DungeonsXL.java index a7eed9a3..2402792e 100644 --- a/src/io/github/dre2n/dungeonsxl/DungeonsXL.java +++ b/src/io/github/dre2n/dungeonsxl/DungeonsXL.java @@ -44,6 +44,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitTask; public class DungeonsXL extends JavaPlugin { @@ -63,9 +64,9 @@ public class DungeonsXL extends JavaPlugin { private Triggers triggers; private Dungeons dungeons; - private WorldUnloadTask worldUnloadTask; - private LazyUpdateTask lazyUpdateTask; - private UpdateTask updateTask; + private BukkitTask worldUnloadTask; + private BukkitTask lazyUpdateTask; + private BukkitTask updateTask; private CopyOnWriteArrayList inBreakMode = new CopyOnWriteArrayList(); private CopyOnWriteArrayList chatSpyers = new CopyOnWriteArrayList(); @@ -434,7 +435,7 @@ public class DungeonsXL extends JavaPlugin { /** * @return the worldUnloadTask */ - public WorldUnloadTask getWorldUnloadTask() { + public BukkitTask getWorldUnloadTask() { return worldUnloadTask; } @@ -442,13 +443,13 @@ public class DungeonsXL extends JavaPlugin { * start a new WorldUnloadTask */ public void startWorldUnloadTask(long period) { - worldUnloadTask = (WorldUnloadTask) new WorldUnloadTask().runTaskTimerAsynchronously(this, 0L, period); + worldUnloadTask = new WorldUnloadTask().runTaskTimerAsynchronously(this, 0L, period); } /** * @return the lazyUpdateTask */ - public LazyUpdateTask getLazyUpdateTask() { + public BukkitTask getLazyUpdateTask() { return lazyUpdateTask; } @@ -456,13 +457,13 @@ public class DungeonsXL extends JavaPlugin { * start a new LazyUpdateTask */ public void startLazyUpdateTask(long period) { - lazyUpdateTask = (LazyUpdateTask) new LazyUpdateTask().runTaskTimerAsynchronously(this, 0L, period); + lazyUpdateTask = new LazyUpdateTask().runTaskTimerAsynchronously(this, 0L, period); } /** * @return the updateTask */ - public UpdateTask getUpdateTask() { + public BukkitTask getUpdateTask() { return updateTask; } @@ -470,7 +471,7 @@ public class DungeonsXL extends JavaPlugin { * start a new LazyUpdateTask */ public void startUpdateTask(long period) { - updateTask = (UpdateTask) new UpdateTask().runTaskTimerAsynchronously(this, 0L, period); + updateTask = new UpdateTask().runTaskTimerAsynchronously(this, 0L, period); } /** diff --git a/src/io/github/dre2n/dungeonsxl/sign/MobSign.java b/src/io/github/dre2n/dungeonsxl/sign/MobSign.java index 8bde3361..21bf0d2e 100644 --- a/src/io/github/dre2n/dungeonsxl/sign/MobSign.java +++ b/src/io/github/dre2n/dungeonsxl/sign/MobSign.java @@ -6,6 +6,7 @@ import io.github.dre2n.dungeonsxl.util.NumberUtil; import org.bukkit.Material; import org.bukkit.block.Sign; +import org.bukkit.scheduler.BukkitTask; public class MobSign extends DSign { @@ -18,7 +19,7 @@ public class MobSign extends DSign { private int amount = 1; private boolean initialized; private boolean active; - private MobSpawnTask task; + private BukkitTask task; public MobSign(Sign sign, GameWorld gameWorld) { super(sign, gameWorld); @@ -117,7 +118,7 @@ public class MobSign extends DSign { /** * @return the task */ - public MobSpawnTask getTask() { + public BukkitTask getTask() { return task; } @@ -125,7 +126,7 @@ public class MobSign extends DSign { * @param task * the task to set */ - public void setTask(MobSpawnTask task) { + public void setTask(BukkitTask task) { this.task = task; } @@ -174,7 +175,7 @@ public class MobSign extends DSign { return; } - task = (MobSpawnTask) new MobSpawnTask(this).runTaskTimer(plugin, 0L, 20L); + task = new MobSpawnTask(this).runTaskTimer(plugin, 0L, 20L); active = true; } diff --git a/src/io/github/dre2n/dungeonsxl/sign/MythicMobsSign.java b/src/io/github/dre2n/dungeonsxl/sign/MythicMobsSign.java index b7739d93..f4b7578a 100644 --- a/src/io/github/dre2n/dungeonsxl/sign/MythicMobsSign.java +++ b/src/io/github/dre2n/dungeonsxl/sign/MythicMobsSign.java @@ -12,6 +12,7 @@ import org.bukkit.block.Sign; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitTask; public class MythicMobsSign extends DSign { @@ -24,7 +25,7 @@ public class MythicMobsSign extends DSign { private int amount = 1; private boolean initialized; private boolean active; - private MythicMobSpawnTask task; + private BukkitTask task; private Location spawnLocation; private LivingEntity mythicMob; private ArrayList mythicMobs = new ArrayList(); @@ -171,7 +172,7 @@ public class MythicMobsSign extends DSign { /** * @return the task */ - public MythicMobSpawnTask getTask() { + public BukkitTask getTask() { return task; } @@ -179,7 +180,7 @@ public class MythicMobsSign extends DSign { * @param task * the task to set */ - public void setTask(MythicMobSpawnTask task) { + public void setTask(BukkitTask task) { this.task = task; } @@ -228,7 +229,7 @@ public class MythicMobsSign extends DSign { return; } - task = (MythicMobSpawnTask) new MythicMobSpawnTask(this).runTaskTimer(plugin, 0L, 20L); + task = new MythicMobSpawnTask(this).runTaskTimer(plugin, 0L, 20L); active = true; } diff --git a/src/io/github/dre2n/dungeonsxl/sign/RedstoneSign.java b/src/io/github/dre2n/dungeonsxl/sign/RedstoneSign.java index 0b8c12f6..2f775e35 100644 --- a/src/io/github/dre2n/dungeonsxl/sign/RedstoneSign.java +++ b/src/io/github/dre2n/dungeonsxl/sign/RedstoneSign.java @@ -7,6 +7,7 @@ import io.github.dre2n.dungeonsxl.util.NumberUtil; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; +import org.bukkit.scheduler.BukkitTask; public class RedstoneSign extends DSign { @@ -15,8 +16,8 @@ public class RedstoneSign extends DSign { // Variables private boolean initialized; private boolean active; - private DelayedPowerTask enableTask; - private DelayedPowerTask disableTask; + private BukkitTask enableTask; + private BukkitTask disableTask; private Block block; private long delay = 0; private long offDelay = 0; @@ -60,7 +61,7 @@ public class RedstoneSign extends DSign { /** * @return the enableTask */ - public DelayedPowerTask getEnableTask() { + public BukkitTask getEnableTask() { return enableTask; } @@ -68,14 +69,14 @@ public class RedstoneSign extends DSign { * @param enableTask * the enableTask to set */ - public void setEnableTask(DelayedPowerTask enableTask) { + public void setEnableTask(BukkitTask enableTask) { this.enableTask = enableTask; } /** * @return the disableTask */ - public DelayedPowerTask getDisableTask() { + public BukkitTask getDisableTask() { return disableTask; } @@ -83,7 +84,7 @@ public class RedstoneSign extends DSign { * @param disableTask * the disableTask to set */ - public void setDisableTask(DelayedPowerTask disableTask) { + public void setDisableTask(BukkitTask disableTask) { this.disableTask = disableTask; } @@ -209,11 +210,11 @@ public class RedstoneSign extends DSign { } if (delay > 0) { - enableTask = (DelayedPowerTask) new DelayedPowerTask(this, true).runTaskTimer(plugin, delay, delay + offDelay); + enableTask = new DelayedPowerTask(this, true).runTaskTimer(plugin, delay, delay + offDelay); if (repeat != 1) { repeatsToDo = repeat; - disableTask = (DelayedPowerTask) new DelayedPowerTask(this, false).runTaskTimer(plugin, delay + offDelay, delay + offDelay); + disableTask = new DelayedPowerTask(this, false).runTaskTimer(plugin, delay + offDelay, delay + offDelay); } } else {