diff --git a/bin/org/mcteam/ancientgates/commands/CommandList.class b/bin/org/mcteam/ancientgates/commands/CommandList.class index bc13f9b..f91bbe4 100644 Binary files a/bin/org/mcteam/ancientgates/commands/CommandList.class and b/bin/org/mcteam/ancientgates/commands/CommandList.class differ diff --git a/bin/org/mcteam/ancientgates/commands/CommandOpen.class b/bin/org/mcteam/ancientgates/commands/CommandOpen.class index 09558ec..77c0a31 100644 Binary files a/bin/org/mcteam/ancientgates/commands/CommandOpen.class and b/bin/org/mcteam/ancientgates/commands/CommandOpen.class differ diff --git a/bin/org/mcteam/ancientgates/commands/CommandSetFrom.class b/bin/org/mcteam/ancientgates/commands/CommandSetFrom.class index 1740b90..e0c8087 100644 Binary files a/bin/org/mcteam/ancientgates/commands/CommandSetFrom.class and b/bin/org/mcteam/ancientgates/commands/CommandSetFrom.class differ diff --git a/bin/org/mcteam/ancientgates/listeners/PluginPlayerListener.class b/bin/org/mcteam/ancientgates/listeners/PluginPlayerListener.class index e7a611f..364a815 100644 Binary files a/bin/org/mcteam/ancientgates/listeners/PluginPlayerListener.class and b/bin/org/mcteam/ancientgates/listeners/PluginPlayerListener.class differ diff --git a/plugin.yml b/plugin.yml index 2226b78..5a3ab39 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,5 +1,5 @@ name: AncientGates -version: 1.0.0 +version: 1.0.1 main: org.mcteam.ancientgates.Plugin commands: gate: diff --git a/src/org/mcteam/ancientgates/commands/CommandList.java b/src/org/mcteam/ancientgates/commands/CommandList.java index c2415d5..2c71ce2 100644 --- a/src/org/mcteam/ancientgates/commands/CommandList.java +++ b/src/org/mcteam/ancientgates/commands/CommandList.java @@ -30,6 +30,7 @@ public class CommandList extends BaseCommand { return; } + sendMessage("There are currently "+ids.size()+" gates on this server: "); sendMessage(TextUtil.implode(ids, Conf.colorSystem+", ")); } diff --git a/src/org/mcteam/ancientgates/commands/CommandOpen.java b/src/org/mcteam/ancientgates/commands/CommandOpen.java index 7d06704..d0d49ec 100644 --- a/src/org/mcteam/ancientgates/commands/CommandOpen.java +++ b/src/org/mcteam/ancientgates/commands/CommandOpen.java @@ -1,5 +1,7 @@ package org.mcteam.ancientgates.commands; +import org.bukkit.Material; + public class CommandOpen extends BaseCommand { public CommandOpen() { @@ -22,6 +24,11 @@ public class CommandOpen extends BaseCommand { sendMessage("To fix that: " + new CommandSetTo().getUseageTemplate(true, true)); } + if (gate.getFrom().getBlock().getType() != Material.AIR) { + sendMessage("The gate could not open. The from location is not air."); + return; + } + if (gate.open()) { sendMessage("The gate was opened."); } else { diff --git a/src/org/mcteam/ancientgates/commands/CommandSetFrom.java b/src/org/mcteam/ancientgates/commands/CommandSetFrom.java index b50221e..16b8877 100644 --- a/src/org/mcteam/ancientgates/commands/CommandSetFrom.java +++ b/src/org/mcteam/ancientgates/commands/CommandSetFrom.java @@ -1,5 +1,8 @@ package org.mcteam.ancientgates.commands; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.mcteam.ancientgates.Gate; public class CommandSetFrom extends BaseCommand { @@ -13,7 +16,20 @@ public class CommandSetFrom extends BaseCommand { } public void perform() { - gate.setFrom(player.getLocation()); + // The player might stand in a halfblock or a sign or whatever + // Therefore we load som extra locations and blocks + Block playerBlock = player.getLocation().getBlock(); + Block upBlock = playerBlock.getFace(BlockFace.UP); + + if (playerBlock.getType() == Material.AIR) { + gate.setFrom(playerBlock.getLocation()); + } else if (upBlock.getType() == Material.AIR) { + gate.setFrom(upBlock.getLocation()); + } else { + sendMessage("There is not enough room for a gate to open here"); + return; + } + sendMessage("From location for gate \""+gate.getId()+"\" is now where you stand."); sendMessage("Build a frame around that block and:"); sendMessage(new CommandOpen().getUseageTemplate(true, true)); diff --git a/src/org/mcteam/ancientgates/listeners/PluginPlayerListener.java b/src/org/mcteam/ancientgates/listeners/PluginPlayerListener.java index 41ef37a..675d884 100644 --- a/src/org/mcteam/ancientgates/listeners/PluginPlayerListener.java +++ b/src/org/mcteam/ancientgates/listeners/PluginPlayerListener.java @@ -7,6 +7,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerMoveEvent; import org.mcteam.ancientgates.Conf; @@ -22,11 +23,14 @@ public class PluginPlayerListener extends PlayerListener { return; } - if (event.getTo().getBlock().getType() != Material.PORTAL) { + Block blockTo = event.getTo().getBlock(); + Block blockToUp = blockTo.getFace(BlockFace.UP); + + if (blockTo.getType() != Material.PORTAL && blockToUp.getType() != Material.PORTAL) { return; } - // Ok so a player walks into a partal block + // Ok so a player walks into a portal block // Find the nearest gate! Gate nearestGate = null; Location playerLocation = event.getPlayer().getLocation();