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


Java Material.CHEST属性代码示例

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


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

示例1: onPlayerInteract

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event)
{
    if (this.canDoAction(event.getPlayer()))
        return;

    if (event.getItem() != null && (event.getItem().getType() == Material.ENDER_PEARL || event.getItem().getType() == Material.SNOW_BALL || event.getItem().getType() == Material.EGG || isPieceOfArmor(event.getItem())))
    {
        event.setCancelled(true);
        event.getPlayer().updateInventory();
    }

    if (event.getClickedBlock() != null && (event.getClickedBlock().getType() == Material.CHEST || event.getClickedBlock().getType() == Material.ENDER_CHEST))
    {
        event.setCancelled(true);
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:17,代码来源:PlayerProtectionListener.java

示例2: isShopBlockNearby

private boolean isShopBlockNearby(Block b) {
	if (b == null) {
		return false;
	}
	Block nearChest = null;
	if (b.getType() == Material.CHEST) {
		nearChest = getBlockNearby(b, Material.CHEST);
	} else if (b.getType() == Material.TRAPPED_CHEST) {
		nearChest = getBlockNearby(b, Material.TRAPPED_CHEST);
	}
	if (nearChest == null) {
		return false;
	}
	for (BlockFace face : BLOCKFACE) {
		Block maybeSign = nearChest.getRelative(face);
		if (maybeSign != null && Material.WALL_SIGN == maybeSign.getType()) {
			Sign sign = (Sign) maybeSign.getState();
			if (sign.getLines().length > 0 && sign.getLines()[0].contains(cm.quickshopSignFlag)) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:24,代码来源:AntiQuickShopDoubleChest.java

示例3: onPlaceChest

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlaceChest(BlockPlaceEvent e) {
	if (!cm.isAntiQuickDoubleChest) {
		return;
	}
	Block block = e.getBlock();
	if (block == null) {
		return;
	}
	Material blockType = block.getType();
	if (Material.CHEST == blockType || Material.TRAPPED_CHEST == blockType) {
		if (isShopBlockNearby(block)) {
			e.setCancelled(true);
			e.getPlayer().sendMessage(i18n.tr("antiQuickShopDoubleChest"));
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:17,代码来源:AntiQuickShopDoubleChest.java

示例4: onSupplyDropInventoryClose

@EventHandler
public void onSupplyDropInventoryClose(InventoryCloseEvent e) {
	Location loc = e.getInventory().getLocation();
	Block b = loc.getBlock();

	if (b.getType() == Material.CHEST) {

		if (core.getSupplyDropManager().isSupplyDrop(b.getLocation())) {
			if (core.getSupplyDropManager().isEmpty(loc)) {
				core.getSupplyDropManager().removeSupplyDrop(loc);
				
				b.setType(Material.AIR);
				loc.getWorld().playSound(loc, Sound.BLOCK_WOOD_BREAK, 1, 1);
			}

		}
	}
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:18,代码来源:SupplyDropListener.java

示例5: event

@EventHandler
public void event(BlockBreakEvent e) {
    new OMGBreakEvent(e, get(e.getPlayer()), e.getBlock());
    if (Area.registeredAreas.values().stream().anyMatch(a -> a.isInside(e.getBlock().getLocation())) && Area.registeredAreas.values().stream().noneMatch(a -> a.isInside(e.getBlock().getLocation()) && a.isBreakAllowed(get(e.getPlayer()).team, e.getBlock().getType()))) {
        e.setCancelled(true);
        return;
    }
    if (g.settings.isLootingOn && e.getBlock().getType() == Material.CHEST) {
        e.setCancelled(true);
        Inventory inv = ((Chest) e.getBlock().getState()).getBlockInventory();
        String lootid = inv.getTitle() == null ? "" : inv.getTitle();
        OMGLoot.LootParser lp = g.loot_contents(get(e.getPlayer()), lootid);
        if (lp != null) {
            inv.clear();
            for (int i = 0; i < inv.getSize(); i++) {
                ItemStack ii = lp.getRandom().toItem();
                if (ii != null && NBTParser.getTagCompound(ii).getByte("Undroppable") != 1)
                    e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), ii);
            }
        }
        e.getBlock().setType(Material.AIR);
        e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), new ItemStack(Material.CHEST));
    }
    if (!GameArea.isBlockInside(e.getBlock())) e.setCancelled(true);
}
 
开发者ID:BurnyDaKath,项目名称:OMGPI,代码行数:25,代码来源:BukkitEventHandler.java

示例6: onBreak

@EventHandler
public void onBreak(BlockBreakEvent event) {
    if (event.getBlock().getType() == Material.CHEST) {
        if (scannedChests.contains(((Chest) event.getBlock().getState()).getBlockInventory().getHolder())) {
            event.setCancelled(true);
            event.getPlayer().sendMessage(ChatColor.RED + "You cannot break the wool chest!");
        }
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:9,代码来源:WoolChestModule.java

示例7: onWreck

@EventHandler
public void onWreck(BlockWreckedEvent e) {
	if(e.getBlock().getType() == Material.CHEST || e.getBlock().getType() == Material.TRAPPED_CHEST) {
		e.getPlayer().sendMessage(Messages.getInstance().getPrefix() + "Je mag geen kisten breken met een WreckingBall!");
		return;
	}
	if(NexusModule.getInstance().isNexus(e.getBlock())) return;
	if(BuildModule.getInstance().isBuilding(e.getBlock())) return;
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:9,代码来源:WreckingBallListeners.java

示例8: onInteract

@EventHandler
public void onInteract(PlayerInteractEvent e) {
    final TOAUser u = TOA.getPlayer(e.getPlayer());

    if (e.getItem() != null) {
        Material m = e.getItem().getType();
        if (m == Material.WRITTEN_BOOK || m == Material.BOW || m == Material.SHEARS || m == Material.DIAMOND_SWORD) return;
        Ability.useAbility(u, e.getItem().getType());
        e.setCancelled(true);
    }

    if (!u.isOnRank(PACmd.Grupo.Builder)) {
        if (e.getClickedBlock() != null) {
            if (e.getClickedBlock().getType().equals(Material.TRAP_DOOR) || e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)
                    || e.getClickedBlock().getType().equals(Material.FENCE_GATE) || e.getClickedBlock().getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType().equals(Material.CAULDRON) || e.getClickedBlock().getRelative(BlockFace.UP).getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType() == Material.CHEST || e.getClickedBlock().getType() == Material.TRAPPED_CHEST
                    || e.getClickedBlock().getType() == Material.DROPPER || e.getClickedBlock().getType() == Material.DISPENSER
                    || e.getClickedBlock().getType() == Material.BED_BLOCK || e.getClickedBlock().getType() == Material.BED
                    || e.getClickedBlock().getType() == Material.WORKBENCH || e.getClickedBlock().getType() == Material.BREWING_STAND
                    || e.getClickedBlock().getType() == Material.ANVIL || e.getClickedBlock().getType() == Material.DARK_OAK_FENCE_GATE
                    || e.getClickedBlock().getType() == Material.SPRUCE_FENCE_GATE || e.getClickedBlock().getType() == Material.FURNACE
                    || e.getClickedBlock().getType() == Material.BURNING_FURNACE || e.getClickedBlock().getType() == Material.HOPPER
                    || e.getClickedBlock().getType() == Material.STONE_BUTTON || e.getClickedBlock().getType() == Material.WOOD_BUTTON) {
                e.setCancelled(true);
            }
        }
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:29,代码来源:GameEvents.java

示例9: getKitSelector

public static ItemStack getKitSelector()
{
    ItemStack stack = new ItemStack(Material.CHEST, 1);
    ItemMeta meta = stack.getItemMeta();

    meta.setDisplayName(ChatColor.GOLD + "Select Kit " + ChatColor.GRAY + "(Right click)");
    meta.setLore(null);

    stack.setItemMeta(meta);

    return stack;
}
 
开发者ID:WoutDev,项目名称:Mega-Walls,代码行数:12,代码来源:ItemHelper.java

示例10: isChest

public static boolean isChest(Material material) {
    return material == Material.CHEST || material == Material.TRAPPED_CHEST;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:3,代码来源:Materials.java

示例11: searchForMarkers

/**
 * Searches the map for "markers". Most of the time these are implemented as tile entities (skulls)
 *
 * @param map    the map to scan
 * @param center the center location
 * @param range  the range in where to scan
 */
public void searchForMarkers(@Nonnull Map map, @Nonnull Vector3D center, int range, @Nonnull UUID gameid) {
    World world = Bukkit.getWorld(map.getLoadedName(gameid));
    if (world == null) {
        throw new MapException("Could not find world " + map.getLoadedName(gameid) + "(" + map.getInfo().getName() + ")" + ". Is it loaded?");
    }

    List<Marker> markers = new ArrayList<>();
    List<ChestMarker> chestMarkers = new ArrayList<>();

    int startX = (int) center.getX();
    int startY = (int) center.getZ();

    int minX = Math.min(startX - range, startX + range);
    int minZ = Math.min(startY - range, startY + range);

    int maxX = Math.max(startX - range, startX + range);
    int maxZ = Math.max(startY - range, startY + range);

    for (int x = minX; x <= maxX; x += 16) {
        for (int z = minZ; z <= maxZ; z += 16) {
            Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
            for (BlockState te : chunk.getTileEntities()) {
                if (te.getType() == Material.SKULL) {
                    Skull skull = (Skull) te;
                    if (skull.getSkullType() == SkullType.PLAYER) {
                        String markerData = getMarkerData(skull);
                        if (markerData == null) continue;
                        MarkerDefinition markerDefinition = mapHandler.createMarkerDefinition(markerData);
                        markers.add(new Marker(new Vector3D(skull.getX(), skull.getY(), skull.getZ()),
                                DirectionUtil.directionToYaw(skull.getRotation()),
                                markerData, markerDefinition));
                    }
                } else if (te.getType() == Material.CHEST) {
                    Chest chest = (Chest) te;
                    String name = chest.getBlockInventory().getName();
                    ItemStack[] items = new ItemStack[chest.getBlockInventory()
                            .getStorageContents().length];
                    for (int i = 0; i < items.length; i++) {
                        ItemStack is = chest.getBlockInventory().getItem(i);
                        if (is == null) {
                            items[i] = new ItemStack(Material.AIR);
                        } else {
                            items[i] = is;
                        }
                    }
                    chestMarkers
                            .add(new ChestMarker(new Vector3D(chest.getX(), chest.getY(), chest.getZ()), name,
                                    items));
                }
            }
        }
    }

    map.setMarkers(markers);
    map.setChestMarkers(chestMarkers);
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:63,代码来源:MapScanner.java

示例12: onInteract

@EventHandler
public void onInteract(PlayerInteractEvent e) {
    PAUser u = PAServer.getUser(e.getPlayer());

    if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if (e.getItem() == null) return;
        e.setCancelled(true);
        if (Cosmetic.useCosmetic(u, e.getItem().getType())) return;

        switch (e.getItem().getType()) {
            case NETHER_STAR:
                e.setCancelled(true);
                LobbyMenu.openMenu(u, LobbyMenu.MenuType.SERVERS);
                break;
            case REDSTONE:
                e.setCancelled(true);
                u.sendMessage(PAData.LOBBY.getPrefix() + "&cNo estamos listos aún");
                //LobbyMenu.openMenu(u, LobbyMenu.MenuType.COSMETICOS);
                break;
            case WOOD_AXE:
                e.setCancelled(true);
                u.sendToServer("cons");
                break;
        }

        if (e.getClickedBlock() == null) return;
        if (e.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE) {
            e.setCancelled(true);
            u.sendMessage(PAData.LOBBY.getPrefix() + "&cActualmente estamos trabajando en esto, disculpen las molestias");
        }
    }

    if (!u.isOnRank(PACmd.Grupo.Builder)) {
        if (e.getClickedBlock() != null) {
            if (e.getClickedBlock().getType().equals(Material.TRAP_DOOR) || e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)
                    || e.getClickedBlock().getType().equals(Material.FENCE_GATE) || e.getClickedBlock().getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType().equals(Material.CAULDRON) || e.getClickedBlock().getRelative(BlockFace.UP).getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType() == Material.CHEST || e.getClickedBlock().getType() == Material.TRAPPED_CHEST
                    || e.getClickedBlock().getType() == Material.DROPPER || e.getClickedBlock().getType() == Material.DISPENSER
                    || e.getClickedBlock().getType() == Material.BED_BLOCK || e.getClickedBlock().getType() == Material.BED
                    || e.getClickedBlock().getType() == Material.WORKBENCH || e.getClickedBlock().getType() == Material.BREWING_STAND
                    || e.getClickedBlock().getType() == Material.ANVIL || e.getClickedBlock().getType() == Material.DARK_OAK_FENCE_GATE
                    || e.getClickedBlock().getType() == Material.SPRUCE_FENCE_GATE || e.getClickedBlock().getType() == Material.FURNACE
                    || e.getClickedBlock().getType() == Material.BURNING_FURNACE || e.getClickedBlock().getType() == Material.HOPPER
                    || e.getClickedBlock().getType() == Material.STONE_BUTTON || e.getClickedBlock().getType() == Material.WOOD_BUTTON) {
                e.setCancelled(true);
            }
        }
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:50,代码来源:PlayerEvents.java


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