Bit of Alchemy cleanup

This commit is contained in:
TfT_02 2014-01-20 22:38:04 +01:00
parent 520f5cb116
commit f39623c279
3 changed files with 15 additions and 20 deletions

View File

@ -33,6 +33,7 @@ public class AlchemyBrewCheckTask extends BukkitRunnable {
Alchemy.brewingStandMap.get(brewingStand).cancelBrew(); Alchemy.brewingStandMap.get(brewingStand).cancelBrew();
} }
} }
if (!Alchemy.brewingStandMap.containsKey(brewingStand) && AlchemyPotionBrewer.isValidBrew(player, newInventory)) { if (!Alchemy.brewingStandMap.containsKey(brewingStand) && AlchemyPotionBrewer.isValidBrew(player, newInventory)) {
Alchemy.brewingStandMap.put(brewingStand, new AlchemyBrewTask(brewingStand, player)); Alchemy.brewingStandMap.put(brewingStand, new AlchemyBrewTask(brewingStand, player));
} }

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables.skills; package com.gmail.nossr50.runnables.skills;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BrewingStand; import org.bukkit.block.BrewingStand;
@ -42,7 +41,7 @@ public class AlchemyBrewTask extends BukkitRunnable {
} }
McMMOPlayerCatalysisEvent event = new McMMOPlayerCatalysisEvent(player, catalysis); McMMOPlayerCatalysisEvent event = new McMMOPlayerCatalysisEvent(player, catalysis);
Bukkit.getPluginManager().callEvent(event); mcMMO.p.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
brewSpeed = catalysis; brewSpeed = catalysis;
} }
@ -82,7 +81,7 @@ public class AlchemyBrewTask extends BukkitRunnable {
private void finish() { private void finish() {
McMMOPlayerBrewEvent event = new McMMOPlayerBrewEvent(player, brewingStand); McMMOPlayerBrewEvent event = new McMMOPlayerBrewEvent(player, brewingStand);
Bukkit.getPluginManager().callEvent(event); mcMMO.p.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
AlchemyPotionBrewer.finishBrewing(brewingStand, player, false); AlchemyPotionBrewer.finishBrewing(brewingStand, player, false);

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.alchemy;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BrewingStand; import org.bukkit.block.BrewingStand;
@ -219,22 +218,6 @@ public final class AlchemyPotionBrewer {
return false; 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) { public static void handleInventoryClick(InventoryClickEvent event) {
Player player = event.getWhoClicked() instanceof Player ? (Player) event.getWhoClicked() : null; Player player = event.getWhoClicked() instanceof Player ? (Player) event.getWhoClicked() : null;
BrewingStand brewingStand = (BrewingStand) event.getInventory().getHolder(); BrewingStand brewingStand = (BrewingStand) event.getInventory().getHolder();
@ -355,4 +338,16 @@ public final class AlchemyPotionBrewer {
return; 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);
}
}
}
} }