From f39623c279406a9f755bcff1229560b12430267a Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Mon, 20 Jan 2014 22:38:04 +0100 Subject: [PATCH] Bit of Alchemy cleanup --- .../skills/AlchemyBrewCheckTask.java | 1 + .../runnables/skills/AlchemyBrewTask.java | 5 ++-- .../skills/alchemy/AlchemyPotionBrewer.java | 29 ++++++++----------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java index 054c23e36..c098af995 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java @@ -33,6 +33,7 @@ public class AlchemyBrewCheckTask extends BukkitRunnable { Alchemy.brewingStandMap.get(brewingStand).cancelBrew(); } } + if (!Alchemy.brewingStandMap.containsKey(brewingStand) && AlchemyPotionBrewer.isValidBrew(player, newInventory)) { Alchemy.brewingStandMap.put(brewingStand, new AlchemyBrewTask(brewingStand, player)); } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java index e63abe934..54da7d9e9 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.runnables.skills; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BrewingStand; @@ -42,7 +41,7 @@ public class AlchemyBrewTask extends BukkitRunnable { } McMMOPlayerCatalysisEvent event = new McMMOPlayerCatalysisEvent(player, catalysis); - Bukkit.getPluginManager().callEvent(event); + mcMMO.p.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { brewSpeed = catalysis; } @@ -82,7 +81,7 @@ public class AlchemyBrewTask extends BukkitRunnable { private void finish() { McMMOPlayerBrewEvent event = new McMMOPlayerBrewEvent(player, brewingStand); - Bukkit.getPluginManager().callEvent(event); + mcMMO.p.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { AlchemyPotionBrewer.finishBrewing(brewingStand, player, false); diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java index bba415bf2..0f4cde55e 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.alchemy; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BrewingStand; @@ -219,22 +218,6 @@ public final class AlchemyPotionBrewer { return false; } - private static void scheduleCheck(Player player, BrewingStand brewingStand) { - Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new AlchemyBrewCheckTask(player, brewingStand)); - } - - private static void scheduleUpdate(Inventory inventory) { - for (HumanEntity humanEntity : inventory.getViewers()) { - if (humanEntity instanceof Player) { - scheduleUpdate((Player) humanEntity); - } - } - } - - private static void scheduleUpdate(Player player) { - Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new PlayerUpdateInventoryTask(player)); - } - public static void handleInventoryClick(InventoryClickEvent event) { Player player = event.getWhoClicked() instanceof Player ? (Player) event.getWhoClicked() : null; BrewingStand brewingStand = (BrewingStand) event.getInventory().getHolder(); @@ -355,4 +338,16 @@ public final class AlchemyPotionBrewer { return; } } + + private static void scheduleCheck(Player player, BrewingStand brewingStand) { + new AlchemyBrewCheckTask(player, brewingStand).runTask(mcMMO.p); + } + + private static void scheduleUpdate(Inventory inventory) { + for (HumanEntity humanEntity : inventory.getViewers()) { + if (humanEntity instanceof Player) { + new PlayerUpdateInventoryTask((Player) humanEntity).runTask(mcMMO.p); + } + } + } }