本文整理汇总了Java中org.bukkit.event.block.BlockFromToEvent类的典型用法代码示例。如果您正苦于以下问题:Java BlockFromToEvent类的具体用法?Java BlockFromToEvent怎么用?Java BlockFromToEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockFromToEvent类属于org.bukkit.event.block包,在下文中一共展示了BlockFromToEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WaterFowLimitor
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
@EventHandler
public void WaterFowLimitor(BlockFromToEvent event) {
if(ConfigOptimize.WaterFlowLimitorenable == true){
Block block = event.getBlock();
Chunk chunk = block.getChunk();
if (block.getType() == Material.STATIONARY_WATER || block.getType() == Material.STATIONARY_LAVA) {
if(CheckFast(block.getChunk())){
if(CheckedTimes.get(chunk) == null){
CheckedTimes.put(chunk, 0);
}
CheckedTimes.put(chunk, CheckedTimes.get(chunk) + 1);
if(CheckedTimes.get(chunk) > ConfigOptimize.WaterFlowLimitorPerChunkTimes){
event.setCancelled(true);
}
}else{
ChunkLastTime.put(block.getChunk(), System.currentTimeMillis());
}
}
}
}
示例2: onBlockFromTo
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onBlockFromTo(BlockFromToEvent e) {
if (!cm.antiWaterfall) {
return;
}
Block to = e.getToBlock();
if (to == null) {
return;
}
if (e.getToBlock().getLocation().getBlockY() <= 63) {
return;
}
if (isAirBottom(to, cm.antiWaterfallHeight)) {
e.setCancelled(true);
}
}
示例3: onBlockFromTo
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event)
{
Location location = event.getBlock().getLocation();
if(this.previousLocation != null && location.equals(this.previousLocation))
{
if(!this.previousWasCancelled) return;
event.setCancelled(true);
return;
}
Flag flag = this.GetFlagInstanceAtLocation(location, null);
boolean cancel = (flag != null);
this.previousLocation = location;
this.previousWasCancelled = cancel;
if(cancel)
{
event.setCancelled(true);
}
}
示例4: onGeneratingThings
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
/**
* Prevent gaming using water/lava generators.
*
* Add other generators as you become aware.
*
* Credit for basic generator detector to fireblast709 (https://bukkit.org/threads/blocking-cobblestone-generators.120924/)
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onGeneratingThings(BlockFromToEvent event) {
Block root = event.getBlock();
Block block = event.getToBlock();
Material type = event.getBlock().getType();
Material mirror1 = (Material.WATER == type || Material.STATIONARY_WATER == type) ? Material.LAVA : Material.WATER;
Material mirror2 = (Material.WATER == type || Material.STATIONARY_WATER == type) ? Material.STATIONARY_LAVA : Material.STATIONARY_WATER;
for (BlockFace face : faces) {
Block check = block.getRelative(face, 1);
Block check2 = root.getRelative(face, 1);
if (mirror1 == check.getType() || mirror2 == check.getType() ||
mirror1 == check2.getType() || mirror2 == check2.getType()) {
plugin.getTracking().trackBreak(block.getLocation());
plugin.getTracking().trackBreak(check.getLocation());
plugin.getTracking().trackBreak(check2.getLocation());
debug("Generating something at union of {0} and {1}/{2}", block, check, check2);
return;
}
}
}
示例5: detectLeak
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void detectLeak(BlockFromToEvent event) {
if (this.isLeaked() || !this.getDetector().contains(event.getToBlock())) {
return;
}
Material newType = event.getBlock().getType();
if (this.getLiquid().accepts(newType)) {
CoreLeakEvent leakEvent = new CoreLeakEvent(this.game.getPlugin(), this);
this.game.getPlugin().getEventBus().publish(leakEvent);
if (!leakEvent.isCanceled()) {
// the core has leaked
this.leak(null, // We don't know the competitor
null); // We don't know the player
}
}
}
示例6: onBlockFromTo
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
/**
* Checks if lava has reached the leak distance below this core.
*
* @param event The event.
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) {
Match match = Cardinal.getMatch(event.getWorld());
if (match == null) {
return;
}
Block to = event.getToBlock();
Material type = event.getBlock().getType();
if (type.equals(Material.STATIONARY_LAVA) || type.equals(Material.LAVA)) {
Core core = getClosestCore(match, to.getLocation().clone());
if (core != null && !core.isComplete()) {
int distance = getBottom(core) - to.getY();
if (distance >= core.getLeak()) {
core.setComplete(true);
Channels.getGlobalChannel(Cardinal.getMatchThread(match)).sendMessage(new LocalizedComponentBuilder(
ChatConstant.getConstant("objective.core.completed"),
new TeamComponent(core.getOwner()),
Components.setColor(core.getComponent(), ChatColor.RED)).color(ChatColor.RED).build());
Bukkit.getPluginManager().callEvent(new ObjectiveCompleteEvent(core, null));
}
}
}
}
示例7: onLiquidFlowOtherLand
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
@EventHandler
public void onLiquidFlowOtherLand(final BlockFromToEvent event) {
Chunk fromChunk = event.getBlock().getLocation().getChunk();
Chunk toChunk = event.getToBlock().getLocation().getChunk();
RegionData fromLand = CubitBukkitPlugin.inst().getRegionManager().praseRegionData(fromChunk.getWorld(),
fromChunk.getX(), fromChunk.getZ());
RegionData toLand = CubitBukkitPlugin.inst().getRegionManager().praseRegionData(toChunk.getWorld(),
toChunk.getX(), toChunk.getZ());
if (toLand.getLandType() == LandTypes.NOTYPE) {
return;
}
if (fromLand.getLandType() == LandTypes.SERVER && toLand.getLandType() == LandTypes.SERVER) {
return;
}
if (!CubitBukkitPlugin.inst().getRegionManager().hasLandPermission(toLand, fromLand.getOwnersUUID()[0])) {
event.setCancelled(true);
}
}
示例8: onBlockFromTo
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockFromTo(BlockFromToEvent event) {
if (!event.isCancelled()) {
Block to = event.getToBlock();
Block from = event.getBlock();
if (CoreObjective.getClosestCore(to.getX(), to.getY(), to.getZ()).equals(this)) {
if ((from.getType().equals(Material.LAVA) || from.getType().equals(Material.STATIONARY_LAVA)) && to.getType().equals(Material.AIR)) {
double minY = 256;
for (Block block : getBlocks()) {
if (block.getY() < minY)
minY = block.getY();
}
if (minY - to.getY() >= leak && !this.complete) {
this.complete = true;
event.setCancelled(false);
if (this.show) ChatUtils.getGlobalChannel().sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.RED + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_LEAKED, team.getCompleteName() + ChatColor.RED, ChatColor.DARK_AQUA + name + ChatColor.RED)));
FireworkUtil.spawnFirework(event.getBlock().getLocation(), event.getBlock().getWorld(), MiscUtils.convertChatColorToColor(team.getColor()));
ObjectiveCompleteEvent compEvent = new ObjectiveCompleteEvent(this, null);
Bukkit.getServer().getPluginManager().callEvent(compEvent);
}
}
}
}
}
示例9: onBlockFromTo
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBlockFromTo (BlockFromToEvent spreadEvent)
{
//always allow fluids to flow straight down
if(spreadEvent.getFace() == BlockFace.DOWN) return;
//don't track in worlds where claims are not enabled
if(!GriefPrevention.instance.claimsEnabledForWorld(spreadEvent.getBlock().getWorld())) return;
//where to?
Block toBlock = spreadEvent.getToBlock();
Location toLocation = toBlock.getLocation();
Claim toClaim = this.dataStore.getClaimAt(toLocation, false, lastSpreadClaim);
//if into a land claim, it must be from the same land claim
if(toClaim != null)
{
this.lastSpreadClaim = toClaim;
if(!toClaim.contains(spreadEvent.getBlock().getLocation(), false, false))
{
spreadEvent.setCancelled(true);
}
}
}
示例10: onBlockFromTo
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
/**
* Handles liquid flowing
*
* @param e an event indicating that a liquid has flown
* @see BlockFromToEvent
* @since 2.2.1
*/
@EventHandler
public void onBlockFromTo(BlockFromToEvent e) {
Location from = e.getBlock().getLocation();
Location to = e.getToBlock().getLocation();
for (Arena arena : ArenaManager.getInstance().getArenas()) {
for (Plot plot : arena.getPlots()) {
Region boundary = plot.getBoundary();
if (boundary == null)
continue;
if (boundary.isInside(from) != boundary.isInside(to))
//checks if the source flows/goes out of the boundary and vice versa
e.setCancelled(true);
}
}
}
示例11: onBlockFromTo
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockFromTo(final BlockFromToEvent event) {
if (event.isCancelled())
return;
final Block block = event.getBlock();
if (!block.getType().equals(Material.STATIONARY_WATER) && !block.getType().equals(Material.STATIONARY_LAVA))
return;
// Ok so water/lava starts flowing within a portal frame
// Find the nearest gate!
final WorldCoord blockCoord = new WorldCoord(block);
final Gate nearestGate = Gates.gateFromPortal(blockCoord);
if (nearestGate != null) {
event.setCancelled(true);
}
}
示例12: onLiquidFlow
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
/**
* Prevents liquid flowing over the beacon beam
* @param event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onLiquidFlow(final BlockFromToEvent event) {
World world = event.getBlock().getWorld();
if (!world.equals(getBeaconzWorld())) {
return;
}
// Only bother with horizontal flows
if (event.getToBlock().getX() != event.getBlock().getX() || event.getToBlock().getZ() != event.getBlock().getZ()) {
BeaconObj beacon = getRegister().getBeaconAt(event.getToBlock().getX(),event.getToBlock().getZ());
if (beacon != null && beacon.getY() < event.getToBlock().getY()) {
event.setCancelled(true);
return;
}
// Stop flows outside of the game area
Game game = getGameMgr().getGame(event.getBlock().getLocation());
if (game == null) {
event.setCancelled(true);
return;
}
}
}
示例13: onChange
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onChange(final BlockFromToEvent e) {
final Block b = e.getToBlock();
final Location loc = BukkitUtil.getLocation(b.getLocation());
if (PlotSquared.isPlotWorld(loc.getWorld())) {
if (MainUtil.isPlotRoad(loc)) {
e.setCancelled(true);
}
else {
Plot plot = MainUtil.getPlot(loc);
if (FlagManager.isPlotFlagTrue(plot, "disable-physics")) {
e.setCancelled(true);
}
}
}
}
示例14: blockFlow
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
@EventHandler
public void blockFlow(BlockFromToEvent event) {
Location source = event.getBlock().getLocation();
Tribe sourceGroup = TribeProtect.getBlockOwnership(source);
Location spread = event.getToBlock().getLocation();
Tribe spreadGroup = TribeProtect.getBlockOwnership(spread);
//if spreadgroup == null, allow
//if sourcegroup == null, do not allow where spreadgroup != null
if (!sourceGroup.isValid()) {
if (!spreadGroup.isValid()) return;
else event.setCancelled(true);
} else {
if (!spreadGroup.isValid()) return;
else {
if (!sourceGroup.equals(spreadGroup))
event.setCancelled(true);
}
}
}
示例15: handleWaterFlow
import org.bukkit.event.block.BlockFromToEvent; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void handleWaterFlow(BlockFromToEvent event, BlockState toState, BlockState fromState)
{
Material material = toState.getType();
if (material == WATER || material == STATIONARY_WATER)
{
this.waterFlowFormSource(event.getToBlock());
}
else if (material == LAVA || material == STATIONARY_LAVA && toState.getRawData() < 3)
{
this.log(LavaWaterForm.class, toState, COBBLESTONE);
}
else if (material == AIR || isNonFluidProofBlock(material))
{
this.waterFlowForm(event);
this.waterFlowFormSource(event.getToBlock());
this.logFlow(material == AIR ? WaterFlow.class : WaterBreak.class, toState, WATER, fromState);
}
}