本文整理汇总了Java中org.bukkit.event.block.BlockPistonRetractEvent.isSticky方法的典型用法代码示例。如果您正苦于以下问题:Java BlockPistonRetractEvent.isSticky方法的具体用法?Java BlockPistonRetractEvent.isSticky怎么用?Java BlockPistonRetractEvent.isSticky使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.block.BlockPistonRetractEvent
的用法示例。
在下文中一共展示了BlockPistonRetractEvent.isSticky方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
/**
* Should cover even more clever implementations involving sticky pistons to game things.
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPistonRetract(BlockPistonRetractEvent event) {
if (!event.isSticky()) return; // only care about stick business.
Block source = event.getBlock();
debug("Piston event from {0}", source.getLocation());
Block extension = event.getBlock().getRelative(event.getDirection());
for (Block b : event.getBlocks()) {
Block next = b.getRelative(event.getDirection());
if (next.equals(source) || next.equals(extension)) {
continue;
}
plugin.getTracking().trackBreak(next.getLocation());
}
plugin.getTracking().trackBreak(source.getLocation());
if (!source.equals(extension)) {
plugin.getTracking().trackBreak(extension.getLocation());
}
}
示例2: onBlockPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
/**
* Filters BlockPistonRetractEvent.
* <p>Will filter as block removing the old position, and placing a block in the new position.</p>
*
* <p>Applies to: block, block place and block break.<p/>
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
Match match = Cardinal.getMatch(event.getWorld());
if (match == null || !event.isSticky()) {
return;
}
Collection<AppliedRegion> regions = get(match, ApplyType.BLOCK, ApplyType.BLOCK_PLACE, ApplyType.BLOCK_BREAK);
for (Block block : event.getBlocks()) {
if (!tryPistonMove(regions, block, event)) {
event.setCancelled(true);
return;
}
}
}
示例3: onBlockPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
/**
* Monitor BlockPistonRetract events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if (!EventUtils.shouldProcessEvent(event.getBlock(), false)) {
return;
}
if (!event.isSticky()) {
return;
}
Block movedBlock = event.getRetractLocation().getBlock();
// Needed only because under some circumstances Minecraft doesn't move the block
new StickyPistonTrackerTask(event.getDirection(), event.getBlock(), movedBlock).runTaskLater(plugin, 2);
}
示例4: onPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onPistonRetract(BlockPistonRetractEvent e) {
// Workaround start - BlockPistonEvent's are sometime called multiple times
if(!pistonUtil.canRetract(e.getBlock())) {
return;
}
pistonUtil.retract(e.getBlock());
// Workaround end
Block blockMoving = e.getRetractLocation().getBlock();
if(!e.isSticky() || !plugin.isWhitelisted(blockMoving.getType()) || !plugin.isWorldWhitelisted(e.getBlock().getWorld())) {
return;
}
plugin.unBlackList(blockMoving);
plugin.blackList(blockMoving.getRelative(e.getDirection().getOppositeFace()));
}
示例5: onPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPistonRetract(final BlockPistonRetractEvent event) {
if (!reinforcementManager.isWorldActive(event.getBlock().getLocation().getWorld().getName())) {
return;
}
if (!event.isSticky()) {
return;
}
final BlockFace direction = event.getDirection();
final Block block = event.getBlock().getRelative(direction, 2);
Location location = block.getLocation();
if (!reinforcementManager.isReinforced(block.getLocation())) {
return;
}
if (!pistonsMoveReinforcedBlocks) {
event.setCancelled(true);
return;
}
reinforcementManager.moveReinforcement(location, direction.getOppositeFace());
}
示例6: oreGinPistonPull
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
/**
* Stop Piston from pulling an OreGin or it's light
*/
@EventHandler
public void oreGinPistonPull(BlockPistonRetractEvent event)
{
MaterialData materialData = event.getBlock().getState().getData();
BlockFace blockFace;
Block movedBlock;
if (materialData instanceof PistonBaseMaterial)
{
blockFace = ((PistonBaseMaterial) materialData).getFacing();
movedBlock = event.getBlock().getRelative(blockFace, 2);
if (event.isSticky() && movedBlock != null)
{
if (oreGinMan.machineExistsAt(movedBlock.getLocation())
|| oreGinMan.oreGinLightExistsAt(movedBlock.getLocation()))
{
event.setCancelled(true);
}
}
}
}
示例7: onBlockPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if(!this.tracker.isEnabled(event.getBlock().getWorld())) return;
if(event.isSticky()) {
Block newBlock = event.getBlock().getRelative(event.getDirection());
Block oldBlock = newBlock.getRelative(event.getDirection());
Player player = this.tracker.getPlacer(oldBlock);
if(player != null) {
this.tracker.setPlacer(oldBlock, null);
this.tracker.setPlacer(newBlock, player);
}
}
}
示例8: onPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent e) {
if (e.isSticky()) {
for (Block b : e.getBlocks()) {
if (BlockStorage.hasBlockInfo(b)) {
e.setCancelled(true);
return;
}
}
}
}
示例9: onBlockPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if (plugin.getChestSettings().allowDestroyBy(AttackType.PISTON)) {
return;
}
if (event.isSticky() && isProtected(event.getBlock())) {
event.setCancelled(true);
}
}
示例10: onPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onPistonRetract(final BlockPistonRetractEvent event) {
if (!event.isSticky())
return;
// TODO: piston detection
}
示例11: pistonRetractCheck
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler
public void pistonRetractCheck(BlockPistonRetractEvent event) {
if (!event.isSticky()) return;
Block item = event.getRetractLocation().getBlock();
if (item.getType() == Material.EMERALD_BLOCK ||
item.getType() == Material.DIAMOND_BLOCK) {
event.setCancelled(true);
}
}
示例12: onPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPistonRetract(final BlockPistonRetractEvent event)
{
if (this.isActive(BlockShift.class, event.getBlock().getWorld()))
{
BlockState retractedBlock = event.getRetractLocation().getBlock().getState();
BlockState pistonHead = event.getBlock().getRelative(event.getDirection()).getState();
BlockState newPistonHead = pistonHead.getBlock().getState();
if (retractedBlock.getType().isSolid())
{
newPistonHead.setType(retractedBlock.getType());
newPistonHead.setData(retractedBlock.getData());
}
else
{
newPistonHead.setType(AIR);
}
BlockShift action = this.set(BlockShift.class, pistonHead, newPistonHead);
action.setRetract();
this.logAction(action);
if (event.isSticky() && retractedBlock.getType().isSolid()) // TODO missing retractable blocks?
{
action = this.set(BlockShift.class, retractedBlock, null);
action.setNewBlock(AIR);
action.setRetract();
this.logAction(action);
}
}
}
示例13: onPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPistonRetract(BlockPistonRetractEvent event) {
if (event.isSticky()) {
for (Block block : event.getBlocks()) {
if (core.contains(block) && partOfObjective(block)) {
event.setCancelled(true);
}
}
}
}
示例14: onBlockPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler (ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if (event.isSticky()) {
Location loc = event.getRetractLocation();
if (! loc.getBlock().isEmpty() && Util.getQuadtree(loc).contains(loc)) {
event.setCancelled(true);
return;
}
}
}
示例15: onBlockPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPistonRetract(final BlockPistonRetractEvent event)
{
if (!event.isSticky())
{
return;
}
final Block block = event.getRetractLocation().getBlock();
if (antib.getSettings().getData().getBlacklist().getPiston(block.getType()))
{
event.setCancelled(true);
}
}