Skip to content

Commit

Permalink
Add hopper carts to safe special carts and upgrade allow-portal to re…
Browse files Browse the repository at this point in the history
…move deprecated call
  • Loading branch information
slide23 committed Feb 19, 2015
1 parent 5654225 commit 222fe60
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -132,4 +132,4 @@ commands:
description: Change the note a noteblock plays.
permission: kitchensink.noteblocks
usage: |
/note <note>[#/b] [high]
/note <note>[#/b] [high]
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>nu.nerd</groupId>
<artifactId>KitchenSink</artifactId>
<version>0.9.0</version>
<version>0.9.1</version>
<packaging>jar</packaging>
<name>KitchenSink</name>
<properties>
Expand Down
19 changes: 16 additions & 3 deletions src/nu/nerd/kitchensink/KitchenSink.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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<Block> 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(
Expand Down Expand Up @@ -1136,4 +1137,16 @@ public String dictFormat(String format, Hashtable<String, Object> 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;
}
}
1 change: 1 addition & 0 deletions src/nu/nerd/kitchensink/KitchenSinkListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ public void onPortalCreate(PortalCreateEvent event) {
&& block.getLocation().getBlockZ() == plugin.nextPortal.getBlockZ()) {
allowed = true;
plugin.nextPortal = null;
break;
}
}
}
Expand Down

0 comments on commit 222fe60

Please sign in to comment.