Skip to content
Permalink
Browse files

Don't suck air out of jukeboxes.

  • Loading branch information...
me4502 committed Nov 4, 2016
1 parent 7865c88 commit c516dbe8dba7255f1c290239477fb3b6fbd9efdc
Showing with 17 additions and 15 deletions.
  1. +17 −15 src/main/java/com/sk89q/craftbook/mechanics/pipe/Pipes.java
@@ -365,24 +365,26 @@ public void startPipe(Block block, List<ItemStack> items, boolean request) {

Jukebox juke = (Jukebox) fac.getState();

items.add(new ItemStack(juke.getPlaying()));
if (juke.getPlaying() != Material.AIR) {
items.add(new ItemStack(juke.getPlaying()));

PipeSuckEvent event = new PipeSuckEvent(block, new ArrayList<ItemStack>(items), fac);
Bukkit.getPluginManager().callEvent(event);
items.clear();
items.addAll(event.getItems());

if(!event.isCancelled()) {
visitedPipes.add(fac.getLocation());
searchNearbyPipes(block, visitedPipes, items, filters, exceptions);
}
PipeSuckEvent event = new PipeSuckEvent(block, new ArrayList<ItemStack>(items), fac);
Bukkit.getPluginManager().callEvent(event);
items.clear();
items.addAll(event.getItems());

if (!items.isEmpty()) {
for (ItemStack item : items) {
if (!ItemUtil.isStackValid(item)) continue;
block.getWorld().dropItem(BlockUtil.getBlockCentre(block), item);
if (!event.isCancelled()) {
visitedPipes.add(fac.getLocation());
searchNearbyPipes(block, visitedPipes, items, filters, exceptions);
}
} else juke.setPlaying(null);

if (!items.isEmpty()) {
for (ItemStack item : items) {
if (!ItemUtil.isStackValid(item)) continue;
block.getWorld().dropItem(BlockUtil.getBlockCentre(block), item);
}
} else juke.setPlaying(null);
}
} else {
PipeSuckEvent event = new PipeSuckEvent(block, new ArrayList<ItemStack>(items), fac);
Bukkit.getPluginManager().callEvent(event);

0 comments on commit c516dbe

Please sign in to comment.
You can’t perform that action at this time.