org.bukkit.event.block.BlockRedstoneEvent Java Examples

The following examples show how to use org.bukkit.event.block.BlockRedstoneEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LWCBlockListener.java    From Modern-LWC with MIT License 6 votes vote down vote up
@EventHandler
public void onBlockRedstoneChange(BlockRedstoneEvent event) {
    if (!LWC.ENABLED) {
        return;
    }

    LWC lwc = plugin.getLWC();
    Block block = event.getBlock();

    if (block == null) {
        return;
    }

    Protection protection = lwc.findProtection(block.getLocation());

    if (protection == null) {
        return;
    }

    LWCRedstoneEvent evt = new LWCRedstoneEvent(event, protection);
    lwc.getModuleLoader().dispatchEvent(evt);

    if (evt.isCancelled()) {
        event.setNewCurrent(event.getOldCurrent());
    }
}
 
Example #2
Source File: BlockListener.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
@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;
	}

}
 
Example #3
Source File: IslandGuard.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Stop redstone if team members are offline and disableOfflineRedstone is TRUE.
 * @param e - event
 */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockRedstone(final 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);
    }
}
 
Example #4
Source File: RedstoneControlListener.java    From NyaaUtils with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockRedstoneEvent(BlockRedstoneEvent event) {
    if (!plugin.cfg.redstoneControl) {
        return;
    }

    Block block = event.getBlock();
    Lightable blockData = redstoneTorch.getIfPresent(block.getLocation());
    if (blockData != null) {
        if (block.getBlockData().getClass() != blockData.getClass()) return;
        event.setNewCurrent(blockData.isLit() ? 15 : 0);
    }
}
 
Example #5
Source File: TriggerListener.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onBlockRedstone(final BlockRedstoneEvent event) {
    new BukkitRunnable() {
        @Override
        public void run() {
            GameWorld gameWorld = plugin.getGameWorld(event.getBlock().getWorld());
            if (gameWorld != null) {
                RedstoneTrigger.updateAll((DGameWorld) gameWorld);
            }
        }
    }.runTaskLater(plugin, 1L);
}
 
Example #6
Source File: BlockButtonAbstract.java    From Carbon with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
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;
	}
}
 
Example #7
Source File: BlockButtonAbstract.java    From Carbon with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
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);
			}
		}
	}
}
 
Example #8
Source File: LWCRedstoneEvent.java    From Modern-LWC with MIT License 4 votes vote down vote up
public LWCRedstoneEvent(BlockRedstoneEvent event, Protection protection) {
    super(ModuleLoader.Event.REDSTONE);

    this.event = event;
    this.protection = protection;
}
 
Example #9
Source File: LWCRedstoneEvent.java    From Modern-LWC with MIT License 4 votes vote down vote up
public BlockRedstoneEvent getEvent() {
    return event;
}
 
Example #10
Source File: WorldFreeze.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler
public void onBlockRedstone(BlockRedstoneEvent event) {
    if (!match.isRunning()) {
        event.setNewCurrent(event.getOldCurrent());
    }
}