本文整理汇总了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;
}
}
}
示例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;
}
}
}
}
}
示例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;
}
}
}
示例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;
}
}
}
示例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;
}
}
}
示例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());
}
示例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);
}
}
示例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));
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
}
}
示例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;
}
}
}
}
示例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);
}
}
示例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;
}
}
}
}
示例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();
}
}
}
}