当前位置: 首页>>代码示例>>Java>>正文


Java ChangeBlockEvent.setCancelled方法代码示例

本文整理汇总了Java中org.spongepowered.api.event.block.ChangeBlockEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java ChangeBlockEvent.setCancelled方法的具体用法?Java ChangeBlockEvent.setCancelled怎么用?Java ChangeBlockEvent.setCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.event.block.ChangeBlockEvent的用法示例。


在下文中一共展示了ChangeBlockEvent.setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBlockBurn

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockBurn(ChangeBlockEvent event) {
  if (event.getCause().root() instanceof Player) {
    return;
  }

  for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
    BlockType finalType = transaction.getFinal().getState().getType();
    if (finalType != BlockTypes.FIRE) {
      continue;
    }

    Optional<JungleRaidInstance> optInst = manager.getApplicableZone(transaction.getOriginal().getLocation().get());
    if (optInst.isPresent()) {
      JungleRaidInstance inst = optInst.get();
      if (inst.isFlagEnabled(JungleRaidFlag.NO_FIRE_SPREAD)) {
        event.setCancelled(true);
      }
      break;
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:23,代码来源:JungleRaidEffectListener.java

示例2: onBlockChange

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockChange(ChangeBlockEvent event) {
  Optional<Player> player = event.getCause().get(NamedCause.SOURCE, Player.class);
  for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
    if (manager.getApplicableZone(transaction.getOriginal().getLocation().get()).isPresent()) {
      BlockType originalType = transaction.getOriginal().getState().getType();
      BlockType finalType = transaction.getFinal().getState().getType();
      if (player.isPresent()) {
        if (!isAllowedChange(originalType, finalType)) {
          event.setCancelled(true);
          break;
        }
      } else {
        if (originalType == BlockTypes.LEVER && finalType != BlockTypes.LEVER) {
          event.setCancelled(true);
          break;
        }
      }
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:22,代码来源:GoldRushListener.java

示例3: onBlockChange

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockChange(ChangeBlockEvent event) {
  // Depends on SpongeForge#550
  if (event instanceof ExplosionEvent.Detonate) {
    return;
  }

  Optional<PluginContainer> optPluginContainer = event.getCause().first(PluginContainer.class);
  if (optPluginContainer.isPresent()) {
    return;
  }

  for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
    if (manager.getApplicableZone(transaction.getOriginal().getLocation().get()).isPresent()) {
      event.setCancelled(true);
      break;
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:20,代码来源:PatientXListener.java

示例4: onBlockBurn

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockBurn(ChangeBlockEvent event) {
  boolean isCausedByFire = isCausedbyFire(event);

  for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
    BlockType finalType = transaction.getFinal().getState().getType();
    if (!isCausedByFire && finalType != BlockTypes.FIRE) {
      continue;
    }

    if (event.getCause().first(PluginContainer.class).isPresent()) {
      continue;
    }

    if (manager.getApplicableZone(transaction.getOriginal().getLocation().get()).isPresent()) {
      event.setCancelled(true);
      break;
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:21,代码来源:CursedMineListener.java

示例5: onBlockChange

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockChange(ChangeBlockEvent event, @First Player player) {
  for (Transaction<BlockSnapshot> block : event.getTransactions()) {
    Optional<Location<World>> optLoc = block.getOriginal().getLocation();
    if (!optLoc.isPresent()) {
      continue;
    }

    if (check(player, optLoc.get())) {
      event.setCancelled(true);
      if (event.getCause().root().equals(player)) {
        player.sendMessage(Text.of(TextColors.RED, "You can't change blocks here!"));
        player.sendMessage(Text.of(TextColors.RED, "[Debug] ", optLoc.get(), " [Cause ", event.getCause(), "]"));
      }
      break;
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:19,代码来源:RegionServiceImpl.java

示例6: onChangeBlock

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
public void onChangeBlock(ChangeBlockEvent event) {
    List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
    Transaction<BlockSnapshot> first = transactions.get(0);
    BlockSnapshot original = first.getOriginal();
    Optional<World> world = SpongeMain.THIS.getServer().getWorld(original.getWorldUniqueId());
    String worldName = world.get().getName();
    Location loc = SpongeUtil.getLocation(worldName, original.getPosition());
    PlotArea area = loc.getPlotArea();
    if (area == null) {
        return;
    }
    Plot plot = area.getPlot(loc);
    if (plot == null) {
        if (!loc.isPlotArea()) {
            return;
        }
        event.setCancelled(true);
        return;
    }
    event.filter(loc1 -> !SpongeUtil.getLocation(worldName, loc1).isPlotRoad());
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:22,代码来源:MainListener.java

示例7: onBlockChanged

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockChanged(ChangeBlockEvent evt) {
    for (Transaction<BlockSnapshot> block : evt.getTransactions()) {
        BlockChangesScriptEvent event = (BlockChangesScriptEvent) clone();
        event.internal = evt;
        event.location = new LocationTag(block.getFinal().getLocation().get());
        event.new_material = new BlockTypeTag(block.getFinal().getState().getType());
        event.old_material = new BlockTypeTag(block.getOriginal().getState().getType());
        event.cancelled = evt.isCancelled();
        event.run();
        evt.setCancelled(event.cancelled);
    }
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:14,代码来源:BlockChangesScriptEvent.java

示例8: onPlayerInteractEntity

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerInteractEntity(ChangeBlockEvent event, @First Player player) {
	if (event.isCancelled()) {
		return;
	}
	event.setCancelled(this.jailInteract(player));
}
 
开发者ID:EverCraft,项目名称:EverSanctions,代码行数:8,代码来源:ESListener.java

示例9: destroyBlocks

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void destroyBlocks(ChangeBlockEvent e, @Root Living living)
{
    if (living == vehicle)
    {
        e.setCancelled(true);
    }
}
 
开发者ID:dags-,项目名称:Mounts,代码行数:9,代码来源:Mount.java

示例10: onPlayerChangeBlock

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerChangeBlock(ChangeBlockEvent event, @Root Player player)
{
	if(EssentialCmds.jailedPlayers.contains(player.getUniqueId()))
	{
		player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You may not modify blocks while in jail!"));
		event.setCancelled(true);
	}
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:10,代码来源:ChangeBlockListener.java

示例11: onBlockChange

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockChange(ChangeBlockEvent event, @First Player player) {
  for (Transaction<BlockSnapshot> block : event.getTransactions()) {
    Optional<Location<World>> optLoc = block.getOriginal().getLocation();
    if (optLoc.isPresent() && isApplicable(optLoc.get())) {
      boolean preventedFromBuilding = check(player, optLoc.get());

      // Block players that are allowed to build, otherwise send the no build message
      Text noEditMessage = Text.of(TextColors.RED, "You can't change blocks here!");
      if (!preventedFromBuilding) {
        if (player.get(Keys.GAME_MODE).orElse(GameModes.SURVIVAL) != GameModes.CREATIVE) {
          preventedFromBuilding = true;
          noEditMessage = Text.of(TextColors.RED, "You must be in creative mode to edit!");
        }
      }

      if (preventedFromBuilding) {
        if (event.getCause().root().equals(player)) {
          player.sendMessage(noEditMessage);
        }

        event.setCancelled(true);
        return;
      }
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:28,代码来源:MainWorldWrapper.java

示例12: onBlockChange

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockChange(ChangeBlockEvent event, @First Entity entity) {
  if (isApplicable(entity)) {
    for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
      if (transaction.getOriginal().getState().getType() != transaction.getFinal().getState().getType()) {
        event.setCancelled(true);
        break;
      }
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:12,代码来源:ZoneImmutableBlockListener.java

示例13: onBlockChange

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockChange(ChangeBlockEvent event, @First Player player) {
  Optional<JungleRaidInstance> optInst = manager.getApplicableZone(player);
  if (!optInst.isPresent()) {
    return;
  }

  JungleRaidInstance inst = optInst.get();
  if (inst.getState() == JungleRaidState.LOBBY) {
    event.setCancelled(true);
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:13,代码来源:JungleRaidListener.java

示例14: onBlockChange

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockChange(ChangeBlockEvent event, @First Player player) {
  if (manager.getApplicableZone(player).isPresent()) {
    for (Transaction<BlockSnapshot> block : event.getTransactions()) {
      if (block.getOriginal().getState().getType() != BlockTypes.WEB) {
        event.setCancelled(true);
        return;
      }
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:12,代码来源:FreakyFourListener.java

示例15: onChangeBlock

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
/**
 * Listens to the base change block event.
 *
 * @param event
 */
@Listener
public void onChangeBlock(final ChangeBlockEvent event) {
    Optional<Player> playerCause = event.getCause().first(Player.class);
    if (playerCause.isPresent() && Prism.getActiveWands().contains(playerCause.get().getUniqueId())) {
        // Cancel and exit event here, not supposed to place/track a block with an active wand.
        event.setCancelled(true);
        return;
    }
    for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
        if (!transaction.isValid()) {
            continue;
        }

        PrismRecordEventBuilder record = PrismRecord.create().source(event.getCause());

        BlockType original = transaction.getOriginal().getState().getType();
        BlockType finalBlock = transaction.getFinal().getState().getType();

        if (event instanceof ChangeBlockEvent.Break) {
            if (Prism.listening.BREAK &&
                    !BlockUtil.rejectBreakCombination(original, finalBlock) &&
                    !EventUtil.rejectBreakEventIdentity(original, finalBlock, event.getCause())) {
                record.brokeBlock(transaction).save();
            }
        }
        else if (event instanceof ChangeBlockEvent.Place) {
            if (Prism.listening.PLACE &&
                    !BlockUtil.rejectPlaceCombination(original, finalBlock) &&
                    !EventUtil.rejectPlaceEventIdentity(original, finalBlock, event.getCause())) {
                record.placedBlock(transaction).save();
            }
        }
        else if (event instanceof ChangeBlockEvent.Decay) {
            if (Prism.listening.DECAY) {
                record.decayedBlock(transaction).save();
            }
        }
    }
}
 
开发者ID:prism,项目名称:Prism,代码行数:45,代码来源:ChangeBlockListener.java


注:本文中的org.spongepowered.api.event.block.ChangeBlockEvent.setCancelled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。