本文整理汇总了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);
}
}
示例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;
}
示例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"));
}
}
}
示例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);
}
}
}
}
示例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);
}
示例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!");
}
}
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例10: isChest
public static boolean isChest(Material material) {
return material == Material.CHEST || material == Material.TRAPPED_CHEST;
}
示例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);
}
示例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);
}
}
}
}