From 81e5c53de59ebf5d03426aca158f3ee053a7ece2 Mon Sep 17 00:00:00 2001 From: Christopher Martin Date: Thu, 13 Oct 2016 23:27:58 -0700 Subject: [PATCH] Fix for HeatControlSolidify error on reload (#600) * Fix for HeatControlSolidify error on reload * Remove unnecessary imports --- .../projectkorra/ability/FireAbility.java | 2 ++ .../firebending/HeatControlSolidify.java | 20 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/com/projectkorra/projectkorra/ability/FireAbility.java b/src/com/projectkorra/projectkorra/ability/FireAbility.java index 7548f28e..063ae12c 100644 --- a/src/com/projectkorra/projectkorra/ability/FireAbility.java +++ b/src/com/projectkorra/projectkorra/ability/FireAbility.java @@ -4,6 +4,7 @@ import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.firebending.BlazeArc; +import com.projectkorra.projectkorra.firebending.HeatControlSolidify; import com.projectkorra.projectkorra.util.Information; import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.rpg.RPGMethods; @@ -217,6 +218,7 @@ public abstract class FireAbility extends ElementalAbility { public static void stopBending() { BlazeArc.removeAllCleanup(); + HeatControlSolidify.revertAllInstances(); for (Location loc : TEMP_FIRE.keySet()) { revertTempFire(loc); } diff --git a/src/com/projectkorra/projectkorra/firebending/HeatControlSolidify.java b/src/com/projectkorra/projectkorra/firebending/HeatControlSolidify.java index 06f83a6b..c0043097 100644 --- a/src/com/projectkorra/projectkorra/firebending/HeatControlSolidify.java +++ b/src/com/projectkorra/projectkorra/firebending/HeatControlSolidify.java @@ -7,10 +7,12 @@ import com.projectkorra.projectkorra.ability.FireAbility; import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.TempBlock; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; import java.util.List; @@ -119,13 +121,27 @@ public class HeatControlSolidify extends FireAbility { @Override public void remove() { - ProjectKorra.plugin.getServer().getScheduler().scheduleSyncDelayedTask(ProjectKorra.plugin, new Runnable() { + if(Bukkit.getServer().getPluginManager().isPluginEnabled(ProjectKorra.plugin.getName())) { + revert(); + } else { + HeatControlSolidify.super.remove(); + } + } + + public void revert() { + new BukkitRunnable() { @Override public void run() { revertAll(); HeatControlSolidify.super.remove(); } - }, revertTime); + }.runTaskLater(ProjectKorra.plugin, revertTime); + } + + public static void revertAllInstances() { + for (HeatControlSolidify heatControlSolidify : getAbilities(HeatControlSolidify.class)) { + heatControlSolidify.revertAll(); + } } public void resetLocation(Location loc) {