diff --git a/plugin.yml b/plugin.yml index 857b6e3..338d221 100755 --- a/plugin.yml +++ b/plugin.yml @@ -1,5 +1,5 @@ name: KitchenSink -version: 0.7.2 +version: 0.9.1 author: Travis Watkins main: nu.nerd.kitchensink.KitchenSink softdepend: [WorldGuard, bPermissions, ProtocolLib] @@ -132,4 +132,4 @@ commands: description: Change the note a noteblock plays. permission: kitchensink.noteblocks usage: | - /note [#/b] [high] \ No newline at end of file + /note [#/b] [high] diff --git a/pom.xml b/pom.xml index bd4f300..42f2644 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 nu.nerd KitchenSink - 0.9.0 + 0.9.1 jar KitchenSink diff --git a/src/nu/nerd/kitchensink/KitchenSink.java b/src/nu/nerd/kitchensink/KitchenSink.java index eb8ee26..5715fe5 100644 --- a/src/nu/nerd/kitchensink/KitchenSink.java +++ b/src/nu/nerd/kitchensink/KitchenSink.java @@ -35,6 +35,7 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitTask; +import org.bukkit.util.BlockIterator; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; @@ -43,6 +44,7 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; +import org.bukkit.entity.minecart.HopperMinecart; public class KitchenSink extends JavaPlugin { @@ -213,7 +215,7 @@ public void run() { for (Minecart minecart : world.getEntitiesByClass(Minecart.class)) { if (minecart.isEmpty()) { if (config.SAFE_SPECIAL_CARTS) { - if (minecart instanceof StorageMinecart || minecart instanceof PoweredMinecart) { + if (minecart instanceof StorageMinecart || minecart instanceof PoweredMinecart || minecart instanceof HopperMinecart) { continue; } } @@ -590,8 +592,7 @@ public boolean onCommand(CommandSender sender, Command command, String name, Str if (sender instanceof Player) { if (config.SAFE_PORTALS) { Player player = (Player) sender; - List lineOfSight = player.getLastTwoTargetBlocks(null, 20); - Block block = (lineOfSight.size() == 2) ? lineOfSight.get(1) : null; + Block block = getTargetBlock(player); if (block != null && block.getType() == Material.OBSIDIAN) { nextPortal = block.getLocation(); sender.sendMessage( @@ -1136,4 +1137,16 @@ public String dictFormat(String format, Hashtable values) { return String.format(convFormat.toString(), valueList.toArray()); } + + public static Block getTargetBlock(LivingEntity entity) { + BlockIterator iterator = new BlockIterator(entity.getLocation(), entity.getEyeHeight()); + Block result; + while (iterator.hasNext()) { + result = iterator.next(); + if (!result.getType().equals(Material.AIR)) { + return result; + } + } + return null; + } } diff --git a/src/nu/nerd/kitchensink/KitchenSinkListener.java b/src/nu/nerd/kitchensink/KitchenSinkListener.java index 54770df..6d87afe 100644 --- a/src/nu/nerd/kitchensink/KitchenSinkListener.java +++ b/src/nu/nerd/kitchensink/KitchenSinkListener.java @@ -547,6 +547,7 @@ public void onPortalCreate(PortalCreateEvent event) { && block.getLocation().getBlockZ() == plugin.nextPortal.getBlockZ()) { allowed = true; plugin.nextPortal = null; + break; } } }