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


Java Material类代码示例

本文整理汇总了Java中org.bukkit.Material的典型用法代码示例。如果您正苦于以下问题:Java Material类的具体用法?Java Material怎么用?Java Material使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onInventoryClick1

import org.bukkit.Material; //导入依赖的package包/类
@EventHandler
public void onInventoryClick1(InventoryClickEvent event) {
	Player player = (Player) event.getWhoClicked();
	ItemStack is = event.getCurrentItem();
	if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
		if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Menu - Page 1")) {
			event.setCancelled(true);
               for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {   
               Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
               Location location = player.getLocation();
               if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport to " + ChatColor.GREEN + targetPlayer.getName()))) {
                   player.closeInventory();
                   player.teleport(targetPlayer);
           		player.sendMessage(ChatColor.YELLOW + "You've teleported to " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + "!");
           		player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
           		player.playEffect(location, Effect.ENDER_SIGNAL, 1);
           		targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
               }
               }
           }
	}
}
 
开发者ID:SlamTheHam,项目名称:UltraCore,代码行数:23,代码来源:Events.java

示例2: call

import org.bukkit.Material; //导入依赖的package包/类
@Override
public void call(Event event) {
	if (event instanceof InventoryClickEvent) {
		final InventoryClickEvent ice = (InventoryClickEvent) event;

		if (ice.getCurrentItem().getType() == Material.BOWL) {

			final int slot = ice.getSlot();

			if (!slotsChosen.containsKey(slot)) {
				slotsChosen.put(slot, 1);
			} else {
				slotsChosen.put(slot, slotsChosen.get(slot) + 1);
			}

			if (getStackChance() >= 100.0) {
				callback(true);
			}
		}
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:22,代码来源:InventoryTweaksB.java

示例3: onExecute

import org.bukkit.Material; //导入依赖的package包/类
@Override
public void onExecute(String[] args, CommandSender sender) {
    Player player = (Player) sender;
    Faction faction = getSenderFactionOrFromArg(sender, args, 1);
    if (faction == null) {
        return;
    }

    if (!faction.isAdmin(player)) {
        ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_PERMISSION.getMessage());
        return;
    }

    ItemStack item = player.getInventory().getItemInMainHand();
    if (item == null || item.getType() != Material.BANNER) {
        displayHelp(player);
        return;
    }

    faction.setBanner(item);
    faction.sendMessage(FMessage.CMD_SET_BANNER_SUCCESS.getMessage(), player, faction);
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:23,代码来源:SetBannerCommand.java

示例4: handleFreeze

import org.bukkit.Material; //导入依赖的package包/类
private void handleFreeze(Player player, Rune rune) {
	Player target = Utility.getTargetPlayer(player, 10);
	if(target == null || !Utility.canAttack(player, target)) {
		return;
	}
	
	LineEffect eff = new LineEffect(plugin.getEffectManager());
	eff.setEntity(player);
	eff.setTargetEntity(target);
	eff.particle = ParticleEffect.SNOW_SHOVEL;
	eff.start();
	target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 6));
	target.playSound(target.getLocation(), Sound.ENTITY_SNOWMAN_DEATH, 1F, 1F);
	
	player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
	player.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_RUNE_APPLY.toString()
		.replaceAll("%s", rune.getName()));
	target.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_FROZEN.toString()
			.replaceAll("%s", player.getName()));
	finish(player, false);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:22,代码来源:RuneManager.java

示例5: onBlockClick

import org.bukkit.Material; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void onBlockClick(PlayerInteractEvent evt, Block bk, boolean rightClick) {
    if (!canTrigger() || MetadataManager.updateCooldownSilently(evt.getPlayer(), "lazerBk", 2))
        return;

    int y = getGateLocation().getBlockY();
    Block above = bk.getRelative(BlockFace.UP);
    if (isPuzzle(bk, y, Material.WOOL) && above.getType() == Material.AIR && rightClick) {
        above.setType(Material.DIODE_BLOCK_OFF);
        above.setData((byte) 0);
    }

    // Remove the next
    if (isPuzzle(bk, y + 1, Material.DIODE_BLOCK_OFF)) {
        if (!rightClick) {
            bk.setType(Material.AIR);
            return;
        }

        bk.setData((byte) (bk.getData() >= 3 ? 0 : bk.getData() + 1));
        evt.setCancelled(true);
    }
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:25,代码来源:LazerPuzzle.java

示例6: createSkullItemStack

import org.bukkit.Material; //导入依赖的package包/类
public static ItemStack createSkullItemStack(String uuid, String textureValue, String textureSignature) {

		WrappedGameProfile wrappedProfile = new WrappedGameProfile(UUID.fromString(uuid), null);
		wrappedProfile.getProperties().put("textures", new WrappedSignedProperty("textures", textureValue, textureSignature));

		ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
		SkullMeta sm = (SkullMeta) skull.getItemMeta();

		Field profileField = null;
		try {
			profileField = sm.getClass().getDeclaredField("profile");
			profileField.setAccessible(true);
			profileField.set(sm, wrappedProfile.getHandle());
		} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
			e1.printStackTrace();
		}

		skull.setItemMeta(sm);
		return skull;
	}
 
开发者ID:RoboTricker,项目名称:Transport-Pipes,代码行数:21,代码来源:InventoryUtils.java

示例7: onItemSpawn

import org.bukkit.Material; //导入依赖的package包/类
/**
 * Chance to drop a diamond when a player breaks a flower
 *
 * @param event Event
 */
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
    if (event.getEntityType() != EntityType.DROPPED_ITEM)
        return;

    if (event.getEntity().hasMetadata("playerDrop"))
        return;

    if (event.getEntity().getItemStack().getType() != Material.YELLOW_FLOWER
            && event.getEntity().getItemStack().getType() != Material.RED_ROSE
            && (event.getEntity().getItemStack().getType() != Material.DOUBLE_PLANT
                || (event.getEntity().getItemStack().getDurability() > 1 && event.getEntity().getItemStack().getDurability() < 4)))
        return;

    if (this.random.nextDouble() <= (double) this.moduleConfiguration.get("chance"))
        event.getEntity().getWorld().dropItemNaturally(event.getLocation(), Meta.addMeta(new ItemStack(Material.DIAMOND, (int) this.moduleConfiguration.get("diamonds"))));

    event.setCancelled(true);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:26,代码来源:DiamondFlowerModule.java

示例8: isNearWood

import org.bukkit.Material; //导入依赖的package包/类
public boolean isNearWood(Block block, int range)
{
    if(range <= 0)
        return false;

    for(BlockFace face : this.faces)
    {
        Block block1 = block.getRelative(face);

        if(block1.getType() == Material.LOG || block1.getType() == Material.LOG_2)
            return true;
        else if((block1.getType() == Material.LEAVES || block1.getType() == Material.LEAVES_2) && this.isNearWood(block1, range-1))
            return true;
    }

    return false;
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:18,代码来源:FastTreeModule.java

示例9: spawnZombie

import org.bukkit.Material; //导入依赖的package包/类
private void spawnZombie() {
    Location center = new Location(Parties.getPartyWorld(), -74.5, 76, 30);
    Zombie z = center.getWorld().spawn(Utils.scatter(center, 4, 0, 4), Zombie.class);
    z.setCustomNameVisible(true);
    z.setCustomName(ChatColor.RED + "Piñata");

    z.getEquipment().setHelmet(ItemManager.createSkull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZn"
                    + "QubmV0L3RleHR1cmUvM2IyNTI2NmQ0MGNlY2Q5M2QwNTMxNTZlNGE0YTc4NDE0MGQwMzQyNTVjNzIxY2MzNzVkMWMzNjQ4MzQyYjZmZCJ9fX0",
            "Pinata Skull", "He doesn't want to party anymore."));
    z.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    z.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    z.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
    z.getEquipment().setItemInMainHand(ItemManager.createItem(Material.STICK, ChatColor.RED + "Pinata Bat", ChatColor.DARK_PURPLE + "Stop hitting me!"));
    z.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(40);
    z.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(.4F);
    z.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE).setBaseValue(6);
    z.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(1);
    z.setSilent(true);
    z.setGlowing(true);
    getScheduler().runTaskLater(z::remove, 1200L); // Remove zombie in 1 minute.
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:22,代码来源:Pinata.java

示例10: isApplicableFor

import org.bukkit.Material; //导入依赖的package包/类
@Override
public boolean isApplicableFor(Player player) {
    ItemStack helmet = player.getInventory().getHelmet();
    if (helmet == null || helmet.getType() != Material.GOLD_HELMET)
        return false;

    ItemStack chestplate = player.getInventory().getChestplate();
    if (chestplate == null || chestplate.getType() != Material.GOLD_CHESTPLATE)
        return false;

    ItemStack leggings = player.getInventory().getLeggings();
    if (leggings == null || leggings.getType() != Material.GOLD_LEGGINGS)
        return false;

    ItemStack boots = player.getInventory().getBoots();
    return !(boots == null || boots.getType() != Material.GOLD_BOOTS);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:18,代码来源:BardClass.java

示例11: onAttack

import org.bukkit.Material; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
	if(event.isCancelled()) return;
	if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
	{
		Player player = (Player)event.getDamager();
		ItemStack mainItem = player.getInventory().getItemInMainHand();
		LivingEntity enemy = (LivingEntity)event.getEntity();

		Random rand = new Random();
		
		if(mainItem.getType() == Material.GOLD_AXE)
		{
			enemy.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 480, 2, false));
			enemy.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 480, 0, false));
           	enemy.getLocation().getWorld().playSound(enemy.getLocation(), Sound.ENTITY_WITHER_SPAWN, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:21,代码来源:StarBattleaxeWither.java

示例12: testMaterialData

import org.bukkit.Material; //导入依赖的package包/类
@Test
public void testMaterialData() throws InputException {
    Class[] inputTypes = {MaterialData.class};
    String[] input = {"diamond_spade:24"};

    Object[] output = InputFormatter.getTypesFromInput(inputTypes, Arrays.asList(input), null);

    // First let's make sure we didn't lose anything, or get anything
    assertEquals(inputTypes.length, output.length);

    // Next let's make sure everything is the right type
    for (Object object : output) {
        assertTrue(object instanceof MaterialData);
    }

    // Finally, let's make sure the values are correct
    assertSame(((MaterialData) output[0]).getItemType(), Material.DIAMOND_SPADE);
}
 
开发者ID:zachbr,项目名称:Debuggery,代码行数:19,代码来源:InputFormatterTest.java

示例13: TreeGrowChecker

import org.bukkit.Material; //导入依赖的package包/类
@EventHandler
public void TreeGrowChecker(StructureGrowEvent event) {
    if (ConfigPatch.safetyBonemeal) {
    	if(event.isFromBonemeal() == false) {
    		return;
    	}
    	List<BlockState> blocks = event.getBlocks();
    	int bs = blocks.size();
    	for(int i = 0;i<bs;i++){
    		Block block = blocks.get(i).getBlock();
    		if(block.getType() != Material.AIR && block.getType() != Material.SAPLING && block.getType() != event.getLocation().getBlock().getRelative(BlockFace.DOWN).getType()){
    			event.setCancelled(true);
                if (event.getPlayer() != null) {
                    AzureAPI.log(event.getPlayer(), "§c这棵树生长区域有方块阻挡,请不要尝试利用骨粉BUG!");
                    return;
                }
    		}
    	}
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:21,代码来源:BonemealDupePatch.java

示例14: onFurnaceSmelt

import org.bukkit.Material; //导入依赖的package包/类
/**
 * Handles the action of smelting all items at once, exploding the furnace, and dropping the smelted items on the
 * ground.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onFurnaceSmelt(FurnaceSmeltEvent event) {
  ItemStack resultItem = event.getResult();
  final Material result = resultItem.getType();
  //TODO: Verify that the "smelting amount" contains any extra ingredients
  final int amount = ((Furnace) event.getBlock().getState()).getInventory().getSmelting().getAmount();

  event.getSource().setType(Material.AIR);
  resultItem.setType(Material.AIR);

  Block block = event.getBlock();
  block.setType(Material.AIR);
  Location location = block.getLocation().add(0.5, 0.5, 0.5);
  World world = location.getWorld();
  world.createExplosion(location, 7);
  world.dropItem(location, new ItemStack(result, amount));
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:24,代码来源:Overcook.java

示例15: onRepair

import org.bukkit.Material; //导入依赖的package包/类
@EventHandler
public void onRepair(final PrepareAnvilRepairEvent e) {
    if (e.getInventory().getContents() == null) {
        return;
    }
    for (final ItemStack itemStack : e.getInventory().getContents()) {
        if (!itemStack.hasItemMeta()) {
            return;
        }
        if (!itemStack.getItemMeta().hasLore()) {
            return;
        }
        if (itemStack.getItemMeta().getLore() == null) {
            return;
        }
        for (final String lore : itemStack.getItemMeta().getLore()) {
            final String fixedLore = ChatColor.stripColor(lore.toLowerCase());
            if (fixedLore.contains("no repair") || fixedLore.contains("unrepairable") || fixedLore.contains("norepair") || fixedLore.contains("nofix") || fixedLore.contains("no fix")) {
                e.setCancelled(true);
                e.setResult(new ItemStack(Material.AIR));
                e.getRepairer().closeInventory();
                ((Player)e.getRepairer()).sendMessage(ChatColor.RED + "This item cannot be repaired.");
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:27,代码来源:UnRepairableListener.java


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