fixed hammer not being initialized in onEnable, fixed method signature to match event type in blocklistener, fixed conditional always being entered and thus failing tool-check
This commit is contained in:
parent
babf7e66a3
commit
747efa0ed3
2 changed files with 14 additions and 5 deletions
|
@ -3,18 +3,21 @@ package lightling.gibsoniacraft;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import lightling.gibsoniacraft.crafting.Excavator;
|
||||
import lightling.gibsoniacraft.crafting.Hammer;
|
||||
import lightling.gibsoniacraft.util.BlockListener;
|
||||
import lightling.gibsoniacraft.util.PlayerInteractListener;
|
||||
|
||||
public final class GibsoniaCraft extends JavaPlugin {
|
||||
|
||||
private Excavator excavatorClass;
|
||||
private Hammer hammerClass;
|
||||
private PlayerInteractListener pListener;
|
||||
private BlockListener bListener;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
excavatorClass = new Excavator(this);
|
||||
hammerClass = new Hammer(this);
|
||||
pListener = new PlayerInteractListener(this);
|
||||
bListener = new BlockListener(this);
|
||||
}
|
||||
|
|
|
@ -26,13 +26,15 @@ import org.bukkit.enchantments.Enchantment;
|
|||
*/
|
||||
public class BlockListener implements Listener
|
||||
{
|
||||
GibsoniaCraft gcPlugin;
|
||||
public BlockListener(GibsoniaCraft plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
gcPlugin = plugin;
|
||||
gcPlugin.getServer().getPluginManager().registerEvents(this, gcPlugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void Break(GibsoniaCraft plugin, BlockBreakEvent bbEvent)
|
||||
public void Break(BlockBreakEvent bbEvent)
|
||||
{
|
||||
// Grab current tool information
|
||||
Player player = bbEvent.getPlayer();
|
||||
|
@ -43,15 +45,19 @@ public class BlockListener implements Listener
|
|||
if (player != null && (player instanceof Player))
|
||||
{
|
||||
if (player.isSneaking())
|
||||
{
|
||||
return;
|
||||
if (!ToolUtil.IsExcavator(itemType) || !ToolUtil.IsHammer(itemType))
|
||||
}
|
||||
if (!ToolUtil.IsExcavator(itemType) && !ToolUtil.IsHammer(itemType))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Get blockface information via the player listener
|
||||
Block block = bbEvent.getBlock();
|
||||
String pName = player.getName();
|
||||
PlayerInteractListener pListener = plugin.GetPlayerInteractListener();
|
||||
PlayerInteractListener pListener = gcPlugin.GetPlayerInteractListener();
|
||||
BlockFace blockFace = pListener.GetFaceByName(pName);
|
||||
|
||||
// getDurability deprecated, must now go through meta information
|
||||
|
|
Reference in a new issue