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


Java Cancellable.setCancelled方法代码示例

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


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

示例1: forbidIfInProtectedTerritory

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
private void forbidIfInProtectedTerritory(Player breaker, Block destroyed, Cancellable event, boolean destroy) {
    if (breaker == null) {
        return;
    }
    if (FPermission.hasPermission(breaker, FPermission.BUILD)) {
        return;
    }

    Region region = board.getByChunk(destroyed.getChunk());
    if (region == null || region.isNeutral()) {
        if (wildernessProtected) {
            event.setCancelled(true);
            ParsingUtil.sendMessage(breaker, (destroy ? FMessage.PROTECTION_CANNOT_DESTROY_WILDERNESS : FMessage.PROTECTION_CANNOT_BUILD_WILDERNESS).getMessage());
        }
        return;
    }

    Faction bFaction = factions.getByMember(breaker);
    Faction owner = region.getOwner();
    Relation rel = owner.getRelation(bFaction);
    if (!rel.canBuild()) {
        event.setCancelled(true);
        ParsingUtil.sendMessage(breaker, (destroy ? FMessage.PROTECTION_CANNOT_DESTROY_FACTION : FMessage.PROTECTION_CANNOT_BUILD_FACTION).getMessage(), region.getOwner());
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:26,代码来源:LandProtectionListener.java

示例2: handle

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
public void handle(String msg, CommandSender sender, Cancellable event) {
	if (Config.get().hiddenMode && !sender.hasPermission("camerastudio.use") && !sender.isOp()) return;
	
	if (msg.startsWith("/cam") || msg.startsWith("/camerastudio")) {
		
		event.setCancelled(true);
		List<String> args = Lists.newArrayList(msg.split(" "));
		
		if (args.size() > 1) {
			args.remove(0);
		}
		
		Traveller traveller = null;
		
		if (sender instanceof ConsoleCommandSender) {
			traveller = new BukkitTraveller(null);
		} else {
			Player player = (Player) sender;
			traveller = Travellers.impl().get(player.getUniqueId());
		}
		CmdCam.get().preExec(traveller, args);
	}
}
 
开发者ID:redstone,项目名称:RCameraStudio,代码行数:24,代码来源:BukkitCommandManager.java

示例3: handleCommand

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
private void handleCommand(CommandSender sender, String s, Cancellable event) {
    if (s.isEmpty()) {
        return;
    }

    if (this.plugin.getConfiguration().get(ConfigKeys.OPS_ENABLED)) {
        return;
    }

    if (s.charAt(0) == '/') {
        s = s.substring(1);
    }

    if (s.startsWith("minecraft:")) {
        s = s.substring("minecraft:".length());
    }

    if (s.equals("op") || s.startsWith("op ") || s.equals("deop") || s.startsWith("deop ")) {
        event.setCancelled(true);
        sender.sendMessage(Message.OP_DISABLED.asString(this.plugin.getLocaleManager()));
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:23,代码来源:BukkitPlatformListener.java

示例4: updatePearlHolder

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
/**
 * Updates the pearl holder
 * @param pearl The pearl to update
 * @param holder The pearl holder
 * @param event The event
 */
private void updatePearlHolder(ExilePearl pearl, InventoryHolder holder, Cancellable event) {

	if (holder instanceof Chest) {
		updatePearl(pearl, (Chest)holder);
	} else if (holder instanceof DoubleChest) {
		updatePearl(pearl, (Chest) ((DoubleChest) holder).getLeftSide());
	} else if (holder instanceof Furnace) {
		updatePearl(pearl, (Furnace) holder);
	} else if (holder instanceof Dispenser) {
		updatePearl(pearl, (Dispenser) holder);
	} else if (holder instanceof Dropper) {
		updatePearl(pearl, (Dropper) holder);
	} else if (holder instanceof Hopper) {
		updatePearl(pearl, (Hopper) holder);
	} else if (holder instanceof BrewingStand) {
		updatePearl(pearl, (BrewingStand) holder);
	} else if (holder instanceof Player) {
		updatePearl(pearl, (Player) holder);
	}else {
		event.setCancelled(true);
	}
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:29,代码来源:PlayerListener.java

示例5: checkLimits

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
private void checkLimits(Cancellable event, EntityType entityType, Location location) {
    if (entityType == null) {
        return; // Only happens on "other-plugins", i.e. EchoPet
    }
    String islandName = WorldGuardHandler.getIslandNameAt(location);
    if (islandName == null) {
        event.setCancelled(true); // Only allow spawning on active islands...
        return;
    }
    if (entityType.getEntityClass().isAssignableFrom(Ghast.class) && location.getWorld().getEnvironment() != World.Environment.NETHER) {
        // Disallow ghasts for now...
        event.setCancelled(true);
        return;
    }
    us.talabrek.ultimateskyblock.api.IslandInfo islandInfo = plugin.getIslandInfo(islandName);
    if (islandInfo == null) {
        // Disallow spawns on inactive islands
        event.setCancelled(true);
        return;
    }
    if (!plugin.getLimitLogic().canSpawn(entityType, islandInfo)) {
        event.setCancelled(true);
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:25,代码来源:SpawnEvents.java

示例6: cancelBowSpleefEntityEvent

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
private void cancelBowSpleefEntityEvent(Entity entity, Cancellable cancellable) {
	boolean isBowspleefEntity = false;
	List<MetadataValue> metadatas = entity.getMetadata(BOWSPLEEF_METADATA_KEY);
	for (MetadataValue value : metadatas) {
		if (value.getOwningPlugin() != getHeavySpleef().getPlugin()) {
			continue;
		}
		
		isBowspleefEntity = value.asBoolean();
	}
	
	if (isBowspleefEntity) {
		entity.remove();
		cancellable.setCancelled(true);
	}
}
 
开发者ID:xaniox,项目名称:HeavySpleef,代码行数:17,代码来源:FlagBowspleef.java

示例7: masterBroken

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
public MessageWithStatus masterBroken(Cancellable event, Sign sign, Player player) {
	BankSet bank = bankManager.getBank(sign.getBlock().getLocation());
	if (bank == null) return null;
	if (!bank.getOwner().equals(player.getName())) {
		if (can_override_break.check(player)) {
			return new BasicMessage("break override allowed", Status.INFO);
		} else {
			event.setCancelled(true);
			return new BasicMessage(Status.WARNING, "Cannot destroy a MondoChest which does not belong to you");
		}
	}
	// If we're here, actually delete the bank
	int num_slaves = bank.numChests();
	bankManager.removeBank(sign.getWorld().getName(), bank);
	playerManager.getState(player).setLastClickedMaster(null);
	return new BasicMessage(Status.SUCCESS,
		"removed bank and %d slave%s",
		num_slaves,
		pluralize(num_slaves)
	);
}
 
开发者ID:crast,项目名称:MondoChest,代码行数:22,代码来源:MondoListener.java

示例8: slaveBroken

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
public MessageWithStatus slaveBroken(Cancellable event, Sign sign, Player player) {
	Map<ChestManager, BankSet> slaves = bankManager.getWorldSlaves(sign.getWorld().getName());
	int removed = 0;
	for (Chest chest: slaveFinder().nearbyChests(sign)) {
		ChestManager info = new ChestManager(chest, false);
		if (slaves.containsKey(info)) {
			BankSet bs = slaves.get(info);
			if (bs.getAccess(player).canRemoveChests() || can_override_break.check(player)) {
				if (bs.removeChest(chest)) {
				    bankManager.markChanged(bs);
				}
				removed++;
			} else {
				event.setCancelled(true);
				return new BasicMessage(Status.WARNING, "No access to remove this slave sign");

			}
		}
	}
	return new BasicMessage(Status.SUCCESS, "Removed %d chests", removed);
}
 
开发者ID:crast,项目名称:MondoChest,代码行数:22,代码来源:MondoListener.java

示例9: handleExplode

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
private static void handleExplode(Cancellable evt, List<Block> blocks) {
    if (!controlExplode) return;
    
    if (explodeControlType.equalsIgnoreCase("NoBlockBreak")) {
        blocks.clear();
    }
    if (explodeControlType.equalsIgnoreCase("NoExplode")) {
        evt.setCancelled(true);
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:11,代码来源:ExplosionController.java

示例10: onCalled

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
@Override
public LuaValue onCalled(Varargs parameters) {
    LuaAccessor accessor = (LuaAccessor) parameters.arg(1);
    if (accessor.getObject() instanceof Event) {
        Event event = (Event) accessor.getObject();
        if (event instanceof Cancellable) {
            Cancellable cancellable = (Cancellable) event;
            cancellable.setCancelled(true);
        }
    }
    return LuaValue.NIL;
}
 
开发者ID:LukkitPlus,项目名称:Lukkit,代码行数:13,代码来源:EventPoint.java

示例11: cancel

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
boolean cancel(Cancellable event, @Nullable MatchPlayer actor, @Nullable BaseComponent message) {
    logger.fine("Cancel " + event + " actor=" + actor);
    event.setCancelled(true);
    if(actor != null && message != null) {
        actor.sendWarning(message, true);
    }
    return true;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:EventFilterMatchModule.java

示例12: cancelEventIfNotOwned

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
public static void cancelEventIfNotOwned(Player ply, Chunk chunk, Cancellable e) {
       if (ply.hasPermission("claimchunk.admin"))
           return;
       if (Config.getBool("protection", "blockPlayerChanges")) {
		if (!e.isCancelled()) {
			if (!canEdit(chunk.getWorld(), chunk.getX(), chunk.getZ(), ply.getUniqueId())) {
				e.setCancelled(true);
				Utils.toPlayer(ply, Config.getColor("errorColor"), Utils.getMsg("chunkNoEdit"));
			}
		}
	}
}
 
开发者ID:cjburkey01,项目名称:ClaimChunk,代码行数:13,代码来源:ChunkHelper.java

示例13: handle

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
private void handle(Cancellable event, Player player) {
    Game game = Skywars.getInstance().getGame(player);
    if (game != null) {
        if (game.isState(Game.GameState.LOBBY) || game.isState(Game.GameState.PREPARATION) || game.isState(Game.GameState.ENDING) || game.isState(Game.GameState.STARTING)) {
            event.setCancelled(true); // Cancel, game isn't active
            return;
        }

        GamePlayer gamePlayer = game.getGamePlayer(player);
        if (gamePlayer != null) {
            if (gamePlayer.isTeamClass()) {
                if (gamePlayer.getTeam().isPlayer(player)) {
                    if (!game.getPlayers().contains(gamePlayer)) {
                        event.setCancelled(true);
                    }
                }
            } else {
                if (gamePlayer.getPlayer() == player) {
                    if (!game.getPlayers().contains(gamePlayer)) {
                        event.setCancelled(true);
                    }
                }
            }
        }
    } else {
        if (Skywars.getInstance().isSingleServerMode()) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:JordanOsterberg,项目名称:SkywarsSeries,代码行数:31,代码来源:BlockInteract.java

示例14: checkLoginStatus

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
private boolean checkLoginStatus(Player player, Cancellable cancelEvent) {
    //thread-safe
    if (plugin.isInSession(player) || plugin.getConfig().getBoolean("commandOnlyProtection")) {
        return true;
    }

    if (!plugin.getConfig().getBoolean("protectAll")
            && !player.hasPermission(plugin.getName().toLowerCase() + ".protect") ) {
        //we don't need to protect this player
        return true;
    }

    cancelEvent.setCancelled(true);
    return false;
}
 
开发者ID:games647,项目名称:SecureMyAccount,代码行数:16,代码来源:PreventListener.java

示例15: handleEvent

import org.bukkit.event.Cancellable; //导入方法依赖的package包/类
private void handleEvent(Player player, Cancellable event)
{
    Flag flag = this.GetFlagInstanceAtLocation(player.getLocation(), player);
    if(flag != null)
    {
        event.setCancelled(true);
    }
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:9,代码来源:FlagDef_NoMcMMOSkills.java


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