Fixed flowers dropping after chest is opened
This commit is contained in:
parent
cb5b0a3c83
commit
27d7226712
@ -3,10 +3,15 @@ package mineplex.core.treasure.animation;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Skull;
|
import org.bukkit.block.Skull;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
|
||||||
import mineplex.core.common.MaterialData;
|
import mineplex.core.common.MaterialData;
|
||||||
import mineplex.core.common.skin.SkinData;
|
import mineplex.core.common.skin.SkinData;
|
||||||
@ -16,7 +21,7 @@ import mineplex.core.treasure.BlockInfo;
|
|||||||
import mineplex.core.treasure.Treasure;
|
import mineplex.core.treasure.Treasure;
|
||||||
import mineplex.core.treasure.TreasureType;
|
import mineplex.core.treasure.TreasureType;
|
||||||
|
|
||||||
public class BlockChangeAnimation extends Animation
|
public class BlockChangeAnimation extends Animation implements Listener
|
||||||
{
|
{
|
||||||
private static final int MAX_RADIUS = 4;
|
private static final int MAX_RADIUS = 4;
|
||||||
|
|
||||||
@ -31,6 +36,7 @@ public class BlockChangeAnimation extends Animation
|
|||||||
_currentRadius = 0;
|
_currentRadius = 0;
|
||||||
_blockInfoList = blockInfoList;
|
_blockInfoList = blockInfoList;
|
||||||
_chests = chests;
|
_chests = chests;
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, treasure.getTreasureManager().getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -302,7 +308,7 @@ public class BlockChangeAnimation extends Animation
|
|||||||
@Override
|
@Override
|
||||||
protected void onFinish()
|
protected void onFinish()
|
||||||
{
|
{
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte getDirection(Block block)
|
private byte getDirection(Block block)
|
||||||
@ -344,4 +350,18 @@ public class BlockChangeAnimation extends Animation
|
|||||||
return BlockFace.SOUTH;
|
return BlockFace.SOUTH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onFlowerDrop(BlockPhysicsEvent event)
|
||||||
|
{
|
||||||
|
for (Block block : _chests)
|
||||||
|
{
|
||||||
|
if (event.getBlock().equals(block))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getBlock().setType(Material.AIR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user