Java 类org.bukkit.event.block.BlockRedstoneEvent 实例源码

项目:NavyCraft2-Lite    文件:NavyCraft_BlockListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onBlockRedstoneChange(BlockRedstoneEvent event) {
    int blockId = event.getBlock().getTypeId();
    Location loc = event.getBlock().getLocation();
    // System.out.println(blockId);

    if ((blockId == 29) || (blockId == 33)) { // piston / sticky piston (base)
        Craft craft = Craft.getCraft(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());

        if (craft != null) {
            Player p = plugin.getServer().getPlayer(craft.driverName);
            if (p != null) {
                p.sendMessage("You just did something with a piston, didn't you?");
            }
        }
    }
}
项目:NavyCraft2-Lite    文件:MoveCraft_BlockListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onBlockRedstoneChange(BlockRedstoneEvent event) {
    int blockId = event.getBlock().getTypeId();
    Location loc = event.getBlock().getLocation();
    // System.out.println(blockId);

    if ((blockId == 29) || (blockId == 33)) { // piston / sticky piston (base)
        Craft craft = Craft.getCraft(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());

        if (craft != null) {
            Player p = plugin.getServer().getPlayer(craft.driverName);
            if (p != null) {
                p.sendMessage("You just did something with a piston, didn't you?");
            }
        }
    }
}
项目:CraftBukkit    文件:BlockCommand.java   
public void doPhysics(World world, int i, int j, int k, Block block) {
    if (!world.isStatic) {
        boolean flag = world.isBlockIndirectlyPowered(i, j, k);
        int l = world.getData(i, j, k);
        boolean flag1 = (l & 1) != 0;

        // CraftBukkit start
        org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i, j, k);
        int old = flag1 ? 15 : 0;
        int current = flag ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);
        // CraftBukkit end

        if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
            world.setData(i, j, k, l | 1, 4);
            world.a(i, j, k, this, this.a(world));
        } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
            world.setData(i, j, k, l & -2, 4);
        }
    }
}
项目:civcraft    文件:BlockListener.java   
@EventHandler(priority = EventPriority.NORMAL) 
public void onBlockRedstoneEvent(BlockRedstoneEvent event) {

    bcoord.setFromLocation(event.getBlock().getLocation());

    CampBlock cb = CivGlobal.getCampBlock(bcoord);
    if (cb != null) {
        if (ItemManager.getId(event.getBlock()) == CivData.WOOD_DOOR ||
                ItemManager.getId(event.getBlock()) == CivData.IRON_DOOR) {
            event.setNewCurrent(0);
            return;
        }
    }

    if (War.isWarTime()) {
        event.setNewCurrent(0);
        return;
    }

}
项目:Almura-Server    文件:BlockCommand.java   
public void doPhysics(World world, int i, int j, int k, int l) {
    if (!world.isStatic) {
        boolean flag = world.isBlockIndirectlyPowered(i, j, k);
        int i1 = world.getData(i, j, k);
        boolean flag1 = (i1 & 1) != 0;

        // CraftBukkit start
        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        int old = flag1 ? 15 : 0;
        int current = flag ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);
        // CraftBukkit end

        if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
            world.setData(i, j, k, i1 | 1, 4);
            world.a(i, j, k, this.id, this.a(world));
        } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
            world.setData(i, j, k, i1 & -2, 4);
        }
    }
}
项目:acidisland    文件:IslandGuard.java   
/**
 * Stop redstone if team members are offline and disableOfflineRedstone is TRUE.
 * @param e
 */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockRedstone(BlockRedstoneEvent e){
    if(Settings.disableOfflineRedstone) {
        // Check world
        if (!inWorld(e.getBlock())) {
            return;
        }
        // Check if this is on an island
        Island island = plugin.getGrid().getIslandAt(e.getBlock().getLocation());
        if (island == null || island.isSpawn()) {
            return;
        }
        for(UUID member : island.getMembers()){
            if(plugin.getServer().getPlayer(member) != null) return;
        }
        e.setNewCurrent(0);
    }
}
项目:Tweakkit-Server    文件:BlockCommand.java   
public void doPhysics(World world, int i, int j, int k, Block block) {
    if (!world.isStatic) {
        boolean flag = world.isBlockIndirectlyPowered(i, j, k);
        int l = world.getData(i, j, k);
        boolean flag1 = (l & 1) != 0;

        // CraftBukkit start
        org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i, j, k);
        int old = flag1 ? 15 : 0;
        int current = flag ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);
        // CraftBukkit end

        if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
            world.setData(i, j, k, l | 1, 4);
            world.a(i, j, k, this, this.a(world));
        } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
            world.setData(i, j, k, l & -2, 4);
        }
    }
}
项目:askyblock    文件:IslandGuard.java   
/**
 * Stop redstone if team members are offline and disableOfflineRedstone is TRUE.
 * @param e
 */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockRedstone(BlockRedstoneEvent e){
    if(Settings.disableOfflineRedstone) {
        // Check world
        if (!inWorld(e.getBlock())) {
            return;
        }
        // Check if this is on an island
        Island island = plugin.getGrid().getIslandAt(e.getBlock().getLocation());
        if (island == null || island.isSpawn()) {
            return;
        }
        for(UUID member : island.getMembers()){
            if(plugin.getServer().getPlayer(member) != null) return;
        }
        e.setNewCurrent(0);
    }
}
项目:Cauldron    文件:BlockCommandBlock.java   
public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
{
    if (!p_149695_1_.isRemote)
    {
        boolean flag = p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_);
        int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_);
        boolean flag1 = (l & 1) != 0;
        // CraftBukkit start
        org.bukkit.block.Block bukkitBlock = p_149695_1_.getWorld().getBlockAt(p_149695_2_, p_149695_3_, p_149695_4_);
        int old = flag1 ? 15 : 0;
        int current = flag ? 15 : 0;
        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
        p_149695_1_.getServer().getPluginManager().callEvent(eventRedstone);
        // CraftBukkit end

        if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0))   // CraftBukkit
        {
            p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l | 1, 4);
            p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, this.tickRate(p_149695_1_));
        }
        else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0)     // CraftBukkit
        {
            p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l & -2, 4);
        }
    }
}
项目:CraftoPlugin    文件:FindRedstoneComponent.java   
@EventHandler
public void onEvent(BlockRedstoneEvent event) {
    if (!this.running) { return; }
    final Location currentLocation = event.getBlock().getLocation();

    for (Location location : this.locationSet) {
        if (location.distanceSquared(currentLocation) < this.distSqrd) {
            // Found a nearby location, so increase its activity count and return
            int count = this.locationMap.get(location);
            this.locationMap.put(location, count + 1);

            return;
        }
    }

    // Could not find any location nearby, so create an entry
    this.locationMap.put(currentLocation, 1);
    this.locationSet.add(currentLocation);
}
项目:Wayward    文件:PortcullisBlockRedstoneListener.java   
@EventHandler
public void onBlockRedstone(BlockRedstoneEvent event) {
    if (event.getBlock().getState() instanceof Sign) {
        Sign sign = (Sign) event.getBlock().getState();
        if (sign.getLine(0).equalsIgnoreCase(ChatColor.GRAY + "[portcullis]")) {
            World world = Bukkit.getServer().getWorld(sign.getLine(1));
            int x1 = Integer.parseInt(sign.getLine(2).split(",")[0]);
            int y1 = Integer.parseInt(sign.getLine(2).split(",")[1]);
            int z1 = Integer.parseInt(sign.getLine(2).split(",")[2]);
            int x2 = Integer.parseInt(sign.getLine(3).split(",")[0]);
            int y2 = Integer.parseInt(sign.getLine(3).split(",")[1]);
            int z2 = Integer.parseInt(sign.getLine(3).split(",")[2]);
            for (int x = Math.min(x1, x2); x <= Math.max(x1, x2); x++) {
                for (int y = Math.min(y1, y2); y <= Math.max(y1, y2); y++) {
                    for (int z = Math.min(z1, z2); z <= Math.max(z1, z2); z++) {
                        if (world.getBlockAt(x, y, z).getType() == Material.AIR) {
                            world.getBlockAt(x, y, z).setType(Material.IRON_FENCE);
                        } else {
                            world.getBlockAt(x, y, z).setType(Material.AIR);
                        }
                    }
                }
            }
        }
    }
}
项目:SpigotSource    文件:BlockButtonAbstract.java   
public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack, EnumDirection enumdirection, float f, float f1, float f2) {
    if (((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue()) {
        return true;
    } else {
        // CraftBukkit start
        boolean powered = ((Boolean) iblockdata.get(POWERED));
        org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
        int old = (powered) ? 15 : 0;
        int current = (!powered) ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);

        if ((eventRedstone.getNewCurrent() > 0) != (!powered)) {
            return true;
        }
        // CraftBukkit end
        world.setTypeAndData(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)), 3);
        world.b(blockposition, blockposition);
        this.a(entityhuman, world, blockposition);
        this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
        world.a(blockposition, (Block) this, this.a(world));
        return true;
    }
}
项目:SpigotSource    文件:BlockButtonAbstract.java   
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
    if (!world.isClientSide) {
        if (((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue()) {
            if (this.I) {
                this.e(iblockdata, world, blockposition);
            } else {
                // CraftBukkit start
                org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());

                BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
                world.getServer().getPluginManager().callEvent(eventRedstone);

                if (eventRedstone.getNewCurrent() > 0) {
                    return;
                }
                // CraftBukkit end
                world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false)));
                this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
                this.b(world, blockposition);
                world.b(blockposition, blockposition);
            }

        }
    }
}
项目:Zeus    文件:ZeusEventHandler.java   
@EventHandler
public void onBlockRedstoneChange(BlockRedstoneEvent evt) {
    if (!(evt.getBlock().getState() instanceof Sign))
        return;
    Sign siq = (Sign) evt.getBlock().getState();
    try {
        if (!plugin.isCommBlock(siq.getLine(0).substring(0, 5)) || plugin.isSenderPlayer(siq.getLine(0).substring(0, 5)))
            return;
    } catch (IndexOutOfBoundsException error) {}

    if (evt.getBlock().isBlockIndirectlyPowered()
            || evt.getBlock().isBlockPowered()) {

        Boolean hasRun = commandSigns.get(siq.getLocation());
        if (hasRun == null || !hasRun) {
            this.tryCommand(evt.getBlock().getState());
            commandSigns.put(siq.getLocation(), true);
        }
    }
    else {
        commandSigns.put(siq.getLocation(), false);
    }
}
项目:RahmenTests    文件:RahmenListener.java   
@EventHandler(priority=EventPriority.HIGH )
public void onBlockRedstone(BlockRedstoneEvent event) 
{
    System.out.println("  ");
    Block block = event.getBlock();
    int iBlockID = block.getTypeId();
    if (iBlockID==69 || iBlockID==77 || iBlockID==143) {  return; }
    if(event.getOldCurrent() >=1 && event.getNewCurrent() == 0 ) { return; }
    System.out.println(" plugin:  onBlockRedstone()  ");
    System.out.println("     iBlockID = " + iBlockID);
    if(plugin.itemFrame1 != null)
    {
        //  funzelt  :-)
        //ItemStack  item01 = new ItemStack( Helper.random_IntRange(2, 128) );
        //plugin.itemFrame1.setItem(item01);
    }
    if(event.getNewCurrent()>=1) {
        plugin.umschauenNachSchild(block, event);
    }
    return;
}
项目:RahmenTests    文件:main.java   
public void handleRedstoneEvent(Block block, BlockRedstoneEvent event, int delayTicks) 
{
       if (istSchild(block)) 
       {
        System.out.println(" plugin:  handleRedstoneEvent()  ");
           Sign signBlock = (Sign) block.getState();
           if (signBlock == null) {
               return;
           }
           if (signBlock.getLine(1) == null) {
               return;
           }
           String sLine1 = signBlock.getLine(1);
           System.out.println("   .getLine(0)  " + signBlock.getLine(0) );
           System.out.println("   .getLine(1)  " + sLine1 );
           System.out.println("   .getLine(2)  " + signBlock.getLine(2) );
           istAutomat(signBlock, block);
       }
}
项目:GrandVide    文件:GVEventListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockRedstone(BlockRedstoneEvent e)
{
    if (e.getBlock().getType() == Material.REDSTONE_TORCH_OFF
            || e.getBlock().getType() == Material.REDSTONE_TORCH_ON)
    {
        final Block above = e.getBlock().getRelative(BlockFace.UP);
        String[] arguments = DropperManager.getSpecialDropper(above);

        if (arguments == null)
            return;

        if (e.getOldCurrent() == 0 && e.getNewCurrent() > 0
                && !above.isBlockPowered()
                && !DropperManager.isRegistered(above))
        {
            DropperManager.register(above, arguments);
        }
        else if (e.getOldCurrent() > 0 && e.getNewCurrent() == 0
                && above.isBlockPowered()
                && DropperManager.isRegistered(above))
        {
            DropperManager.unregister(above);
        }
    }
}
项目:Craft-city    文件:BlockCommand.java   
public void doPhysics(World world, int i, int j, int k, int l) {
    if (!world.isStatic) {
        boolean flag = world.isBlockIndirectlyPowered(i, j, k);
        int i1 = world.getData(i, j, k);
        boolean flag1 = (i1 & 1) != 0;

        // CraftBukkit start
        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        int old = flag1 ? 15 : 0;
        int current = flag ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);
        // CraftBukkit end

        if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
            world.setData(i, j, k, i1 | 1, 4);
            world.a(i, j, k, this.id, this.a(world));
        } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
            world.setData(i, j, k, i1 & -2, 4);
        }
    }
}
项目:MondoChest    文件:RedstoneListener.java   
@EventHandler
public void onBlockRedstone(BlockRedstoneEvent event) {
    if (event.getOldCurrent() != 0 || event.getNewCurrent() == 0) {
        return;
    }
    Block block = event.getBlock();
    World world = block.getWorld();
    String worldName = world.getName();
    Map<BlockVector, BankSet> worldInteresting = bankInfo.get(worldName);
    if (worldInteresting == null) {
        worldInteresting = buildWorldInteresting(worldName);
        bankInfo.put(worldName, worldInteresting);
    }
    BlockVector target = new BlockVector(block.getX(), block.getY(), block.getZ());
    BankSet targetBank = worldInteresting.get(target);
    if (targetBank != null) {
        targetBank.shelveItems(world);
    }
}
项目:MachineFactory    文件:OreGinListener.java   
/**
 * Maintains the OreGin lights stable
 */
@EventHandler
public void keepLightsStable(BlockRedstoneEvent event)
{
    if (event.getBlock().getType().equals(MachineFactoryPlugin.LIGHT_ON) || event.getBlock().getType().equals(MachineFactoryPlugin.LIGHT_OFF))
    {
        if (oreGinMan.oreGinLightExistsAt(event.getBlock().getLocation()))
        {
            if (((OreGin)oreGinMan.getMachine(event.getBlock().getRelative(BlockFace.DOWN).getLocation())).getMining())
            {
                event.setNewCurrent(1);
            }
            else if (!((OreGin)oreGinMan.getMachine(event.getBlock().getRelative(BlockFace.DOWN).getLocation())).getBroken())
            {
                event.setNewCurrent(0);
            }
        }   
    }                       
}
项目:EscapeLag    文件:AntiRedstone.java   
@EventHandler
public void CheckRedstone(BlockRedstoneEvent event){
    if(ConfigOptimize.AntiRedstoneenable){
        if(event.getOldCurrent() > event.getNewCurrent()){
            return;
        }
        final Block block = event.getBlock();
        Location loc = block.getLocation();
        if(CheckedTimes.get(loc) == null){
            CheckedTimes.put(loc, 0);
        }
        CheckedTimes.put(loc, CheckedTimes.get(loc) + 1);

        if(CheckedTimes.get(loc) > ConfigOptimize.AntiRedstoneTimes){
            if(ConfigOptimize.AntiRedstoneRemoveBlockList.contains(block.getType().name())){
    Bukkit.getScheduler().runTaskLater(EscapeLag.MainThis,new Runnable(){
        public void run(){
            block.setType(Material.AIR);
        }
    },1);
                String message = ConfigOptimize.AntiRedstoneMessage;
                message = StringUtils.replace(message, "%location%", loc.toString());
                AzureAPI.bc(message);
            }
        }
    }
}
项目:NeverLag    文件:HighfrequencyRedstoneCleaner.java   
@SuppressWarnings("deprecation")
@EventHandler
// 当红石触发的时候,记录当前坐标红石事件的次数,超出阀值则清理
public void onBlockRedstone(BlockRedstoneEvent e) {
    int typeId = e.getBlock().getTypeId();
    if (!cm.redstoneRemoveType.contains(typeId)) {
        return;
    }
    final Location loc = e.getBlock().getLocation();
    if (cm.redstoneAsyncCheck) {
        asyncCheckAndRecord(loc, typeId);
    } else {
        syncCheckAndRecord(loc, typeId);
    }
}
项目:MT_Core    文件:GeneratorListener.java   
@EventHandler
public void onPower(BlockRedstoneEvent event) {
    Block block = event.getBlock();
    String chunk = block.getLocation().getChunk().getX() + ";" + block.getLocation().getChunk().getZ();

    if (!powerable.get(block.getWorld().getName()).getList(chunk).contains(block.getLocation())) {
        block.getWorld().spawnParticle(Particle.SMOKE_NORMAL, block.getLocation().add(0.5, 1, 0.5), 7, 0, 0.2, 0,
                0.03);
        event.setNewCurrent(0);
    }
}
项目:CastleGates    文件:BridgeEventHandler.java   
public void handleBlockRedstone(BlockRedstoneEvent event) {
    if ((event.getOldCurrent() != 0) == (event.getNewCurrent() != 0)) return;

    Block block = event.getBlock();

    for (BlockFace face : BridgeManager.faces) {
        Block faceBlock = block.getRelative(face);

        if(this.storage.getGearblock(new BlockCoord(faceBlock)) != null) {
            this.waitingBlocks.add(faceBlock);
        }
    }
}
项目:world-of-icerealm    文件:Mayhem.java   
@EventHandler(priority = EventPriority.NORMAL)
public void redstoneSwitch(BlockRedstoneEvent event) {

    if (event.getBlock().getLocation().getX() == (_source.getX() -1) &&
        event.getBlock().getLocation().getY() == _source.getY() &&
        event.getBlock().getLocation().getZ() == _source.getZ() && !_switchActivated) {

            _switchActivated = true;
            activateEvent();
    }       
}
项目:AnimulusLib    文件:BlockButton.java   
private boolean pressRaw()
{
    // taken from net.minecraft.server.v1_9_R1.BlockButtonAbstract

    World world = ((CraftWorld) this.location.getWorld()).getHandle();
    BlockPosition blockposition = new BlockPosition(this.location.getX(), this.location.getY(), this.location.getZ());
    IBlockData iblockdata = world.getType(blockposition);
    Block block = iblockdata.getBlock();

    if(iblockdata.get(POWERED))
        return true;

    boolean powered = iblockdata.get(POWERED);
    org.bukkit.block.Block bukkitBlock = world.getWorld()
            .getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
    int old = powered ? 15 : 0;
    int current = !powered ? 15 : 0;

    BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
    world.getServer().getPluginManager().callEvent(eventRedstone);

    if((eventRedstone.getNewCurrent() > 0 ? 1 : 0) != (powered ? 0 : 1))
        return true;

    world.setTypeAndData(blockposition, iblockdata.set(POWERED, true), 3);
    world.b(blockposition, blockposition);
    world.a(null, blockposition, getSoundEffects(), SoundCategory.BLOCKS, 0.3f, 0.3f); // null is for entity human, maybe
    // cause problems
    c(world, blockposition, iblockdata.get(FACING), block);
    world.a(blockposition, block, getPressDuration());
    return true;
}
项目:Skellett    文件:ExprRedstoneCurrent.java   
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
    if (!ScriptLoader.isCurrentEvent(BlockRedstoneEvent.class)) {
        Skript.error("You can not use New Redstone Current expression in any event but on redstone changing event!");
        return false;
    }
    time = parser.mark;
    return true;
}
项目:Skellett    文件:ExprRedstoneCurrent.java   
@Nullable
protected Integer[] get(Event e) {
    if (time == 1) {
        return new Integer[]{((BlockRedstoneEvent)e).getNewCurrent()};
    }
    return new Integer[]{((BlockRedstoneEvent)e).getOldCurrent()};
}
项目:Skellett    文件:ExprRedstoneCurrent.java   
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
    if (time == 1) {
        if (mode == ChangeMode.SET) {
            ((BlockRedstoneEvent)e).setNewCurrent(((Integer)delta[0]));
        } else if (mode == ChangeMode.ADD) {
            ((BlockRedstoneEvent)e).setNewCurrent((((BlockRedstoneEvent)e).getNewCurrent() + (Integer)delta[0]));
        } else if (mode == ChangeMode.REMOVE) {
            ((BlockRedstoneEvent)e).setNewCurrent((((BlockRedstoneEvent)e).getNewCurrent() - (Integer)delta[0]));
        } else if (mode == ChangeMode.RESET) {
            ((BlockRedstoneEvent)e).setNewCurrent(((BlockRedstoneEvent)e).getNewCurrent());
        }
    }
}
项目:CraftBukkit    文件:BlockPumpkin.java   
public void doPhysics(World world, int i, int j, int k, Block block) {
    if (block != null && block.isPowerSource()) {
        org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i, j, k);
        int power = bukkitBlock.getBlockPower();

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, power, power);
        world.getServer().getPluginManager().callEvent(eventRedstone);
    }
}
项目:CraftBukkit    文件:BlockBloodStone.java   
public void doPhysics(World world, int i, int j, int k, int l) {
    if (net.minecraft.server.Block.getById(l) != null && net.minecraft.server.Block.getById(l).isPowerSource()) {
        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        int power = block.getBlockPower();

        BlockRedstoneEvent event = new BlockRedstoneEvent(block, power, power);
        world.getServer().getPluginManager().callEvent(event);
    }
}
项目:CraftBukkit    文件:BlockButtonAbstract.java   
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) {
    int i1 = world.getData(i, j, k);
    int j1 = i1 & 7;
    int k1 = 8 - (i1 & 8);

    if (k1 == 0) {
        return true;
    } else {
        // CraftBukkit start
        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        int old = (k1 != 8) ? 15 : 0;
        int current = (k1 == 8) ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);

        if ((eventRedstone.getNewCurrent() > 0) != (k1 == 8)) {
            return true;
        }
        // CraftBukkit end

        world.setData(i, j, k, j1 + k1, 3);
        world.c(i, j, k, i, j, k);
        world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
        this.a(world, i, j, k, j1);
        world.a(i, j, k, this, this.a(world));
        return true;
    }
}
项目:CraftBukkit    文件:BlockButtonAbstract.java   
public void a(World world, int i, int j, int k, Random random) {
    if (!world.isStatic) {
        int l = world.getData(i, j, k);

        if ((l & 8) != 0) {
            if (this.a) {
                this.n(world, i, j, k);
            } else {
                // CraftBukkit start
                org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);

                BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
                world.getServer().getPluginManager().callEvent(eventRedstone);

                if (eventRedstone.getNewCurrent() > 0) {
                    return;
                }
                // CraftBukkit end
                world.setData(i, j, k, l & 7, 3);
                int i1 = l & 7;

                this.a(world, i, j, k, i1);
                world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
                world.c(i, j, k, i, j, k);
            }
        }
    }
}
项目:CraftBukkit    文件:BlockPressurePlateAbstract.java   
protected void a(World world, int i, int j, int k, int l) {
    int i1 = this.e(world, i, j, k);
    boolean flag = l > 0;
    boolean flag1 = i1 > 0;

    // CraftBukkit start - Interact Pressure Plate
    org.bukkit.World bworld = world.getWorld();
    org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();

    if (flag != flag1) {
        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bworld.getBlockAt(i, j, k), l, i1);
        manager.callEvent(eventRedstone);

        flag1 = eventRedstone.getNewCurrent() > 0;
        i1 = eventRedstone.getNewCurrent();
    }
    // CraftBukkit end

    if (l != i1) {
        world.setData(i, j, k, this.d(i1), 2);
        this.a_(world, i, j, k);
        world.c(i, j, k, i, j, k);
    }

    if (!flag1 && flag) {
        world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
    } else if (flag1 && !flag) {
        world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
    }

    if (flag1) {
        world.a(i, j, k, this, this.a(world));
    }
}
项目:Almura-Server    文件:BlockPumpkin.java   
public void doPhysics(World world, int i, int j, int k, int l) {
    if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].isPowerSource()) {
        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        int power = block.getBlockPower();

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, power, power);
        world.getServer().getPluginManager().callEvent(eventRedstone);
    }
}
项目:Almura-Server    文件:BlockBloodStone.java   
public void doPhysics(World world, int i, int j, int k, int l) {
    if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].isPowerSource()) {
        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        int power = block.getBlockPower();

        BlockRedstoneEvent event = new BlockRedstoneEvent(block, power, power);
        world.getServer().getPluginManager().callEvent(event);
    }
}
项目:Almura-Server    文件:BlockButtonAbstract.java   
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) {
    int i1 = world.getData(i, j, k);
    int j1 = i1 & 7;
    int k1 = 8 - (i1 & 8);

    if (k1 == 0) {
        return true;
    } else {
        // CraftBukkit start
        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        int old = (k1 != 8) ? 15 : 0;
        int current = (k1 == 8) ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);

        if ((eventRedstone.getNewCurrent() > 0) != (k1 == 8)) {
            return true;
        }
        // CraftBukkit end

        world.setData(i, j, k, j1 + k1, 3);
        world.g(i, j, k, i, j, k);
        world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
        this.d(world, i, j, k, j1);
        world.a(i, j, k, this.id, this.a(world));
        return true;
    }
}
项目:Almura-Server    文件:BlockButtonAbstract.java   
public void a(World world, int i, int j, int k, Random random) {
    if (!world.isStatic) {
        int l = world.getData(i, j, k);

        if ((l & 8) != 0) {
            // CraftBukkit start
            org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);

            BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
            world.getServer().getPluginManager().callEvent(eventRedstone);

            if (eventRedstone.getNewCurrent() > 0) {
                return;
            }
            // CraftBukkit end

            if (this.a) {
                this.n(world, i, j, k);
            } else {
                world.setData(i, j, k, l & 7, 3);
                int i1 = l & 7;

                this.d(world, i, j, k, i1);
                world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
                world.g(i, j, k, i, j, k);
            }
        }
    }
}
项目:Almura-Server    文件:BlockPressurePlateAbstract.java   
protected void b(World world, int i, int j, int k, int l) {
    int i1 = this.e(world, i, j, k);
    boolean flag = l > 0;
    boolean flag1 = i1 > 0;

    // CraftBukkit start - Interact Pressure Plate
    org.bukkit.World bworld = world.getWorld();
    org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();

    if (flag != flag1) {
        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bworld.getBlockAt(i, j, k), l, i1);
        manager.callEvent(eventRedstone);

        flag1 = eventRedstone.getNewCurrent() > 0;
        i1 = eventRedstone.getNewCurrent();
    }
    // CraftBukkit end

    if (l != i1) {
        world.setData(i, j, k, this.d(i1), 2);
        this.b_(world, i, j, k);
        world.g(i, j, k, i, j, k);
    }

    if (!flag1 && flag) {
        world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
    } else if (flag1 && !flag) {
        world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
    }

    if (flag1) {
        world.a(i, j, k, this.id, this.a(world));
    }
}
项目:BlockLocker    文件:BlockDestroyListener.java   
@EventHandler
public void onRedstone(BlockRedstoneEvent event) {
    if (event.getNewCurrent() == event.getOldCurrent()) {
        return;
    }

    if (isProtectedForRedstone(event.getBlock())) {
        event.setNewCurrent(event.getOldCurrent());
    }
}