本文整理汇总了Java中org.bukkit.event.block.BlockFromToEvent.getToBlock方法的典型用法代码示例。如果您正苦于以下问题:Java BlockFromToEvent.getToBlock方法的具体用法?Java BlockFromToEvent.getToBlock怎么用?Java BlockFromToEvent.getToBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.block.BlockFromToEvent
的用法示例。
在下文中一共展示了BlockFromToEvent.getToBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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;
}
}
}
示例3: 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));
}
}
}
}
示例4: 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);
}
}
}
}
}
示例5: 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);
}
}
}
示例6: 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);
}
}
}
}
示例7: onBlockMove
import org.bukkit.event.block.BlockFromToEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockMove(BlockFromToEvent event) {
Block block = event.getBlock(), to = event.getToBlock();
String world = block.getWorld().getUID().toString();
Integer x = to.getLocation().getChunk().getX(), z = to.getLocation().getChunk().getZ();
if (QuickChecks.isWorldChunkClaimed(serverdata.get("worldmap").get(world), x, z, "cla")) {
if (((HashMap) ((HashMap) serverdata.get("worldmap").get(world).get(x)).get(z)).containsKey("str")) {
if (block.getType().equals(WATER)) {
block.setType(STATIONARY_WATER);
} else if (block.getType().equals(LAVA)) {
block.setType(STATIONARY_LAVA);
}
event.setCancelled(true);
}
}
}
示例8: onWaterPassThrough
import org.bukkit.event.block.BlockFromToEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onWaterPassThrough(final BlockFromToEvent event) {
Block block = event.getToBlock();
Location location = block.getLocation();
if (!reinforcementManager.isWorldActive(location.getWorld().getName())) {
return;
}
if (!reinforcementManager.isReinforced(location)) {
return;
}
// If the event is caused by a dragon egg moving to a new location, simply make sure it is not teleporting into a field.
if (Material.DRAGON_EGG.equals(event.getBlock().getType())) {
Bukkit.getServer().getPluginManager().callEvent(new BlockDeinforceEvent(block, "Environment", true));
return;
}
if (!liquidsDestroyReinforcedBlocks) {
event.setCancelled(true);
return;
}
}
示例9: onBlockFromTo
import org.bukkit.event.block.BlockFromToEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onBlockFromTo(final BlockFromToEvent event) {
if (!event.isCancelled()) {
final Block block = event.getToBlock();
if ((block.getTypeId() == 75) || (block.getTypeId() == 76) || (block.getTypeId() == 65) || (block.getTypeId() == 69) || (block.getTypeId() == 77) || (block.getTypeId() == 70) || (block.getTypeId() == 72) || (block.getTypeId() == 68) || (block.getTypeId() == 63) || (block.getTypeId() == 143) || (block.getTypeId() == 55)) {
if (Craft.getCraft(block.getX(), block.getY(), block.getZ()) != null) {
// event.setCancelled(true);
block.setTypeId(8);
}
}
}
}
示例10: onFlow
import org.bukkit.event.block.BlockFromToEvent; //导入方法依赖的package包/类
@EventHandler
public void onFlow(BlockFromToEvent e){
RedProtect.get().logger.debug("RPGlobalListener - Is BlockFromToEvent event");
if (e.isCancelled()){
return;
}
Block b = e.getToBlock();
Block bfrom = e.getBlock();
RedProtect.get().logger.debug("RPGlobalListener - Is BlockFromToEvent event is to " + b.getType().name() + " from " + bfrom.getType().name());
Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
if (r != null){
return;
}
if (bfrom.isLiquid() && !RPConfig.getGlobalFlagBool(b.getWorld().getName()+".liquid-flow")){
e.setCancelled(true);
return;
}
if ((bfrom.getType().equals(Material.WATER) || bfrom.getType().equals(Material.STATIONARY_WATER))
&& !RPConfig.getGlobalFlagBool(b.getWorld().getName()+".allow-changes-of.water-flow")){
e.setCancelled(true);
return;
}
if ((bfrom.getType().equals(Material.LAVA) || bfrom.getType().equals(Material.STATIONARY_LAVA))
&& !RPConfig.getGlobalFlagBool(b.getWorld().getName()+".allow-changes-of.lava-flow")){
e.setCancelled(true);
return;
}
if (!b.isEmpty() && !RPConfig.getGlobalFlagBool(b.getWorld().getName()+".allow-changes-of.flow-damage")){
e.setCancelled(true);
}
}
示例11: onFlow
import org.bukkit.event.block.BlockFromToEvent; //导入方法依赖的package包/类
@EventHandler
public void onFlow(BlockFromToEvent e){
RedProtect.get().logger.debug("RPBlockListener - Is BlockFromToEvent event");
if (e.isCancelled()){
return;
}
Block bto = e.getToBlock();
Block bfrom = e.getBlock();
RedProtect.get().logger.debug("RPBlockListener - Is BlockFromToEvent event is to " + bto.getType().name() + " from " + bfrom.getType().name());
Region rto = RedProtect.get().rm.getTopRegion(bto.getLocation());
if (rto != null && bfrom.isLiquid() && !rto.canFlow()){
e.setCancelled(true);
return;
}
if (rto != null && !bto.isEmpty() && !rto.FlowDamage()){
e.setCancelled(true);
return;
}
//deny blocks spread in/out regions
Region rfrom = RedProtect.get().rm.getTopRegion(bfrom.getLocation());
if (rfrom != null && rto != null && rfrom != rto && !rfrom.sameLeaders(rto)){
e.setCancelled(true);
return;
}
if (rfrom == null && rto != null){
e.setCancelled(true);
}
}
示例12: onLiquidFlow
import org.bukkit.event.block.BlockFromToEvent; //导入方法依赖的package包/类
@EventHandler
public void onLiquidFlow(BlockFromToEvent event){
Block to = event.getToBlock();
Block from = event.getBlock();
if(GameManager.isPlotPart(from.getLocation())
&& !GameManager.isPlotPart(to.getLocation())){
event.setCancelled(true);
}
}
示例13: onCleanstoneGen
import org.bukkit.event.block.BlockFromToEvent; //导入方法依赖的package包/类
/**
* Removes stone generated by lava pouring onto water
*
* @param e
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onCleanstoneGen(BlockFromToEvent e) {
// Only do this in ASkyBlock world
if (!e.getBlock().getWorld().equals(ASkyBlock.getIslandWorld())) {
return;
}
// Do nothing if a new island is being created
if (plugin.isNewIsland())
return;
final Block to = e.getToBlock();
/*
plugin.getLogger().info("From material is " + e.getBlock().toString());
plugin.getLogger().info("To material is " + to.getType().toString());
plugin.getLogger().info("---------------------------------");
*/
if (Settings.acidDamage > 0) {
if (DEBUG)
plugin.getLogger().info("DEBUG: cleanstone gen " + e.getEventName());
final Material prev = to.getType();
// plugin.getLogger().info("To material was " +
// to.getType().toString());
plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
// plugin.getLogger().info("To material is after 1 tick " +
// to.getType().toString());
if ((prev.equals(Material.WATER) || prev.equals(Material.STATIONARY_WATER)) && to.getType().equals(Material.STONE)) {
to.setType(prev);
if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
to.getWorld().playSound(to.getLocation(), Sound.valueOf("FIZZ"), 1F, 2F);
} else {
to.getWorld().playSound(to.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F);
}
}
}
});
}
}
示例14: onChange
import org.bukkit.event.block.BlockFromToEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChange(BlockFromToEvent event) {
Block from = event.getBlock();
Block to = event.getToBlock();
Location tLocation = BukkitUtil.getLocation(to.getLocation());
PlotArea area = tLocation.getPlotArea();
if (area == null) {
return;
}
Plot plot = area.getOwnedPlot(tLocation);
Location fLocation = BukkitUtil.getLocation(from.getLocation());
if (plot != null) {
if (Flags.DISABLE_PHYSICS.isFalse(plot)) {
event.setCancelled(true);
return;
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
event.setCancelled(true);
return;
}
if (Flags.LIQUID_FLOW.isFalse(plot)) {
switch (to.getType()) {
case WATER:
case STATIONARY_WATER:
case LAVA:
case STATIONARY_LAVA:
event.setCancelled(true);
}
}
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
event.setCancelled(true);
}
}
示例15: onBlockFromTo
import org.bukkit.event.block.BlockFromToEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockFromTo(BlockFromToEvent event) {
if (lava.contains(event.getToBlock())){
event.setCancelled(true);
}
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 : getCore()) {
if (block.getY() < minY)
minY = block.getY();
}
if (minY - to.getY() >= leak && !this.complete) {
this.complete = true;
event.setCancelled(false);
if (this.show)
ChatUtil.getGlobalChannel().sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.RED + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_LEAKED, team.getCompleteName() + ChatColor.RED, name)));
ObjectiveCompleteEvent compEvent = new ObjectiveCompleteEvent(this, null);
Bukkit.getServer().getPluginManager().callEvent(compEvent);
}
}
}
}
}