本文整理汇总了Java中org.bukkit.event.block.BlockBreakEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java BlockBreakEvent.setCancelled方法的具体用法?Java BlockBreakEvent.setCancelled怎么用?Java BlockBreakEvent.setCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.block.BlockBreakEvent
的用法示例。
在下文中一共展示了BlockBreakEvent.setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
/**
* Private block breaking handling
*
* @param event Event
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event)
{
if (this.blocksOwner.containsKey(event.getBlock().getLocation()) && this.blocksOwner.get(event.getBlock().getLocation()) != event.getPlayer().getUniqueId())
{
UUID id = this.blocksOwner.get(event.getBlock().getLocation());
if (id == null || id.equals(event.getPlayer().getUniqueId()) || (this.game instanceof SurvivalTeamGame && ((SurvivalTeamGame) this.game).getPlayerTeam(id) == ((SurvivalTeamGame) this.game).getPlayerTeam(event.getPlayer().getUniqueId())))
{
this.blocksOwner.remove(event.getBlock().getLocation());
}
else if (!this.game.isPvPActivated())
{
event.getPlayer().sendMessage(ChatColor.RED + "Ce bloc appartient à " + Bukkit.getOfflinePlayer(this.blocksOwner.get(event.getBlock().getLocation())).getName() + ". Vous ne pouvez pas le casser actuellement !");
event.setCancelled(true);
}
}
}
示例2: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
/**
* Prevents blocks from being broken
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (Settings.allowAutoActivator && e.getPlayer().getName().equals("[CoFH]")) {
return;
}
if (Util.inWorld(e.getPlayer())) {
if (actionAllowed(e.getPlayer(), e.getBlock().getLocation(), SettingsFlag.BREAK_BLOCKS)) {
return;
}
// Everyone else - not allowed
Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
e.setCancelled(true);
}
}
示例3: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event)
{
Block block = event.getBlock();
if (isEventSign(block))
{
BlockState state = block.getState();
Sign sign = (Sign)state;
ItemStack stack = new ItemStack(Material.SIGN, 1);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(EVENT_SIGN_ITEM_NAME);
meta.setLore(Arrays.asList(sign.getLines()));
stack.setItemMeta(meta);
Player player = event.getPlayer();
World world = player.getWorld();
Location blockLocation = block.getLocation();
if ((player.getGameMode() != GameMode.CREATIVE) && (world.isGameRule("doTileDrops"))) {
world.dropItemNaturally(blockLocation, stack);
}
event.setCancelled(true);
block.setType(Material.AIR);
state.update();
}
}
示例4: onBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBreak(BlockBreakEvent e) {
if (e.isCancelled()) {
return;
}
if (!Utils.isInArena(e.getPlayer())) {
return;
}
if (!Utils.isArenaWorld(e.getBlock().getWorld())) {
return;
}
if (e.getPlayer().isOp()) {
return;
}
e.setCancelled(true);
}
示例5: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event) {
if (plugin.getEotwHandler().isEndOfTheWorld())
return;
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE && player.hasPermission(ProtectionListener.PROTECTION_BYPASS_PERMISSION)) {
return;
}
Block block = event.getBlock();
BlockState state = block.getState();
Block subclaimObjectBlock = null;
if (!(state instanceof Sign)) {
subclaimObjectBlock = block;
} else {
Sign sign = (Sign) state;
MaterialData signData = sign.getData();
if (signData instanceof org.bukkit.material.Sign) {
org.bukkit.material.Sign materialSign = (org.bukkit.material.Sign) signData;
subclaimObjectBlock = block.getRelative(materialSign.getAttachedFace());
}
}
if (subclaimObjectBlock != null && !this.checkSubclaimIntegrity(player, subclaimObjectBlock)) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You cannot break this subclaimed " + subclaimObjectBlock.getType().toString() + '.');
}
}
示例6: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
if (!cm.isAntiChestViewerDupe) {
return;
}
if (e.getBlock() != null && e.getBlock().getState() instanceof InventoryHolder) {
InventoryHolder inventory = (InventoryHolder) e.getBlock().getState();
// 如果容器正在使用则不允许被破坏,以防止利用漏洞刷物品
if (!inventory.getInventory().getViewers().isEmpty()) {
e.setCancelled(true);
e.getPlayer().sendMessage(i18n.tr("antiChestViewerDupeMessage"));
}
}
}
示例7: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
ArcadiaAPI api = Arcadia.getPlugin(Arcadia.class).getAPI();
if(!api.getGameManager().isAlive(event.getPlayer())) event.setCancelled(true);
if(api.getGameManager().getCurrentGame() != null) {
MaterialData materialData = new MaterialData(event.getBlock().getType(), event.getBlock().getData());
if(!api.getGameManager().getCurrentGame().breakableBlocks.contains(materialData)) {
event.setCancelled(true);
}
}
}
示例8: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent event){
if (event.getBlock().getLocation().equals(Main.getCrateChestLocation()) || event.getBlock().getLocation().equals(Main.getVoteCrateChestLocation()) || event.getBlock().getLocation().equals(Main.getReleaseCrateChestLocation())){
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + "You can not break this block!");
}
}
示例9: onBlockPlace
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
/**
* Disable block breaking near chest
*
* @param event Block break event instance
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBlockPlace(BlockBreakEvent event)
{
if (event.getBlock().getLocation().getWorld().equals(this.chestLocation.getWorld())
&& event.getBlock().getLocation().distanceSquared(this.chestLocation) < 25)
{
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + "Il n'est pas possible de casser de blocs à proximité du coffre des minerais.");
}
}
示例10: onBreakBlock
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBreakBlock(BlockBreakEvent event) {
List<Material> list = new ArrayList<Material>();
list.add(Material.RED_MUSHROOM);
list.add(Material.BROWN_MUSHROOM);
list.add(Material.YELLOW_FLOWER);
list.add(Material.RED_ROSE);
list.add(Material.LEAVES);
list.add(Material.LONG_GRASS);
list.add(Material.WEB);
if (!list.contains(event.getBlock().getType()))
event.setCancelled(true);
}
示例11: onBlockPlaceCreative
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockPlaceCreative(BlockBreakEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE && !player.hasPermission("base.command.gamemode")) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You are not allowed to be in gamemode! Setting you to default gamemode!");
player.setGameMode(GameMode.SURVIVAL);
}
}
示例12: onBlockBreakCreative
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreakCreative(BlockBreakEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE && !player.hasPermission("base.command.gamemode")) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You are not allowed to be in gamemode! Setting you to default gamemode!");
player.setGameMode(GameMode.SURVIVAL);
}
}
示例13: onPortalDestroy
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onPortalDestroy(BlockBreakEvent e) {
if (e.getBlock() == null)
return;
if(e.getBlock().getType() == Material.PORTAL) {
if(!e.getPlayer().isOp()) {
e.setCancelled(true);
}
}
}
示例14: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event) {
Player p = event.getPlayer();
if ( PermissionInterface.CheckEnabledWorld(p.getLocation())) {
Block checkBlock;
checkBlock = event.getBlock();
int craftBlockId = checkBlock.getTypeId();
Craft checkCraft = Craft.getCraft(checkBlock.getX(), checkBlock.getY(), checkBlock.getZ());
if (checkCraft != null) {
if ((craftBlockId == 46) && (p.getGameMode() != GameMode.CREATIVE)) {
p.sendMessage(ChatColor.RED + "Can't break vehicle TNT.");
event.setCancelled(true);
return;
} else if ((craftBlockId == 75) || (craftBlockId == 76) || (craftBlockId == 65) || (craftBlockId == 68) || (craftBlockId == 63) || (craftBlockId == 69) || (craftBlockId == 77) || (craftBlockId == 70) || (craftBlockId == 72) || (craftBlockId == 55) || (craftBlockId == 143) || (craftBlockId == 64) || (craftBlockId == 71)) {
int arrayX = checkBlock.getX() - checkCraft.minX;
int arrayY = checkBlock.getY() - checkCraft.minY;
int arrayZ = checkBlock.getZ() - checkCraft.minZ;
checkCraft.matrix[arrayX][arrayY][arrayZ] = -1;
if (((craftBlockId == 64) && (checkBlock.getRelative(BlockFace.UP).getTypeId() == 64)) || ((craftBlockId == 71) && (checkBlock.getRelative(BlockFace.UP).getTypeId() == 71))) {
checkBlock.getRelative(BlockFace.UP).setTypeId(0);
checkCraft.matrix[arrayX][arrayY + 1][arrayZ] = -1;
}
if (((craftBlockId == 64) && (checkBlock.getRelative(BlockFace.DOWN).getTypeId() == 64)) || ((craftBlockId == 71) && (checkBlock.getRelative(BlockFace.DOWN).getTypeId() == 71))) {
checkBlock.getRelative(BlockFace.DOWN).setTypeId(0);
checkCraft.matrix[arrayX][arrayY - 1][arrayZ] = -1;
}
for (DataBlock complexBlock : checkCraft.complexBlocks) {
if (complexBlock.locationMatches(arrayX, arrayY, arrayZ)) {
checkCraft.complexBlocks.remove(complexBlock);
break;
}
}
for (DataBlock dataBlock : checkCraft.dataBlocks) {
if (dataBlock.locationMatches(arrayX, arrayY, arrayZ)) {
checkCraft.dataBlocks.remove(dataBlock);
break;
}
}
}
}
}
}
示例15: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if (!event.getPlayer().hasPermission("mclink.build"))
event.setCancelled(true);
}