本文整理汇总了Java中org.bukkit.Material.ENDER_PEARL属性的典型用法代码示例。如果您正苦于以下问题:Java Material.ENDER_PEARL属性的具体用法?Java Material.ENDER_PEARL怎么用?Java Material.ENDER_PEARL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.ENDER_PEARL属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: isInteractableItem
/**
* checks if this item is interactable
*/
public static boolean isInteractableItem(ItemStack item) {
if (item == null || item.getType() == Material.AIR) {
return false;
}
if (item.getType().isBlock()) {
return true;
}
if (item.getType() == Material.REDSTONE || item.getType() == Material.WATER_BUCKET || item.getType() == Material.LAVA_BUCKET) {
return true;
}
if (item.getType() == Material.MONSTER_EGG) {
return true;
}
if (item.getType() == Material.EGG || item.getType() == Material.SNOW_BALL || item.getType() == Material.BOW || item.getType() == Material.ENDER_PEARL || item.getType() == Material.EYE_OF_ENDER || item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.EXP_BOTTLE || item.getType() == Material.FIREWORK_CHARGE) {
return true;
}
if (item.getType().isEdible()) {
return true;
}
return false;
}
示例3: onPlayerInteract
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) {
Block block = event.getClickedBlock();
// Don't prevent opening chests, etc, as these won't throw the Enderpearls anyway
if (block.getType().isSolid() && !(block.getState() instanceof InventoryHolder)) {
Faction factionAt = HCF.getPlugin().getFactionManager().getFactionAt(block.getLocation());
if (!(factionAt instanceof ClaimableFaction)) {
return;
}
event.setCancelled(true);
Player player = event.getPlayer();
player.setItemInHand(event.getItem()); // required to update Enderpearl count
}
}
}
示例4: run
@Override
public void run() {
ItemStack stack = player.getItemInHand();
if (stack != null && stack.getType() == Material.ENDER_PEARL) {
long remaining = timer.getRemaining(player);
net.minecraft.server.v1_7_R4.ItemStack item = ((CraftItemStack) stack).handle;
if (remaining > 0L) {
item = item.cloneItemStack();
item.c(ChatColor.LIGHT_PURPLE + "Enderpearl Cooldown" + ChatColor.GRAY + " : " + ChatColor.WHITE + DurationFormatter.getRemaining(remaining, true, true));
setFakeItem(item, player.getInventory().getHeldItemSlot());
} else {
cancel();
}
}
}
示例5: onInventoryClickEvent
@EventHandler
public void onInventoryClickEvent(InventoryClickEvent event) {
ItemStack itemStack = event.getCurrentItem();
if (itemStack != null && itemStack.getType() == Material.ENDER_PEARL) {
ItemMeta itemMeta = event.getCurrentItem().getItemMeta();
itemMeta.setDisplayName(null);
event.getCurrentItem().setItemMeta(itemMeta);
}
}
示例6: onPlayerItemHeldEvent
@EventHandler
public void onPlayerItemHeldEvent(PlayerItemHeldEvent event) {
ItemStack itemStack = event.getPlayer().getInventory().getItem(event.getPreviousSlot());
if (itemStack != null && itemStack.getType() == Material.ENDER_PEARL && itemStack.getItemMeta() != null) {
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(null);
itemStack.setItemMeta(itemMeta);
}
}
示例7: onPearl
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPearl(PlayerInteractEvent event) {
if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && event.getItem() != null && event.getItem().getType() == Material.ENDER_PEARL) {
if (this.editKits.containsKey(event.getPlayer().getUniqueId())) {
event.setCancelled(true);
}
}
}
示例8: onInteract
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onInteract(PlayerInteractEvent event) {
if ((event.getAction() == Action.RIGHT_CLICK_BLOCK) && (event.hasItem()) && (event.getItem().getType() == Material.ENDER_PEARL)) {
Block block = event.getClickedBlock();
if ((block.getType().isSolid()) && (!(block.getState() instanceof InventoryHolder))) {
event.setCancelled(true);
Player player = event.getPlayer();
player.setItemInHand(event.getItem());
}
}
}
示例9: doInteraction
public void doInteraction(Player player, ItemStack stack)
{
if (stack.getType() == Material.COMPASS)
{
this.hub.getGuiManager().openGui(player, new GuiMain(this.hub));
}
else if (stack.getType() == Material.SKULL_ITEM)
{
this.hub.getGuiManager().openGui(player, new GuiProfile(this.hub));
}
else if (stack.getType() == Material.ENDER_CHEST)
{
this.hub.getGuiManager().openGui(player, new GuiCosmetics(this.hub));
}
else if (stack.getType() == Material.GOLD_INGOT)
{
this.hub.getGuiManager().openGui(player, new GuiShop(this.hub));
}
else if (stack.getType() == Material.BARRIER && this.hub.getParkourManager().getPlayerParkour(player.getUniqueId()) != null)
{
this.hub.getParkourManager().getPlayerParkour(player.getUniqueId()).quitPlayer(player);
}
else if (stack.getType() == Material.ENDER_PEARL && this.hub.getParkourManager().getPlayerParkour(player.getUniqueId()) != null)
{
this.hub.getParkourManager().getPlayerParkour(player.getUniqueId()).failPlayer(player);
}
else if (player.getInventory().getHeldItemSlot() == 6)
{
this.hub.getServer().getScheduler().runTask(this.hub, () -> this.hub.getCosmeticManager().getGadgetManager().useSelectedCosmetic(player, stack));
}
else if (stack.getType() == Material.ELYTRA)
{
if (stack.getEnchantments().isEmpty())
{
ItemStack elytra = new ItemStack(Material.ELYTRA);
ItemMeta meta = elytra.getItemMeta();
meta.spigot().setUnbreakable(true);
elytra.setItemMeta(meta);
player.getInventory().setChestplate(elytra);
this.setInventoryToPlayer(player);
}
else
{
player.getInventory().setChestplate(null);
this.setInventoryToPlayer(player);
}
player.playSound(player.getLocation(), Sound.ENTITY_HORSE_SADDLE, 1F, 1F);
}
else if (stack.getType() == Material.FEATHER && player.isGliding() && player.getVelocity().lengthSquared() != 0)
{
if (!SamaGamesAPI.get().getPermissionsManager().hasPermission(player, "network.vip"))
{
player.sendMessage(ChatColor.RED + "Devenez VIP pour utiliser le booster.");
return;
}
Vector velocity = player.getVelocity().add(player.getLocation().getDirection().normalize().multiply(1.5D));
((CraftPlayer)player).getHandle().motX = velocity.getX();
((CraftPlayer)player).getHandle().motY = velocity.getY();
((CraftPlayer)player).getHandle().motZ = velocity.getZ();
((CraftPlayer)player).getHandle().velocityChanged = true;
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ENDERDRAGON_FLAP, 2F, 2F);
this.hub.getServer().getScheduler().runTask(this.hub, () -> SamaGamesAPI.get().getAchievementManager().getAchievementByID(5).unlock(player.getUniqueId()));
}
}
示例10: giveTitaniumKit
private void giveTitaniumKit(Player player) {
if(player.hasPermission("riots.titanium")) {
if(cooldowns.containsKey(player.getUniqueId())) {
if(cooldowns.get(player.getUniqueId()).containsKey("TitaniumKit")) {
this.closeInventory(player);
player.sendMessage(ChatColor.RED + "You cannot receive this kit for " + ChatColor.BOLD + DurationFormatUtils.formatDurationWords(cooldowns.get(player.getUniqueId()).get("TitaniumKit"), true, true) + ChatColor.RED + "!");
} else {
cooldowns.put(player.getUniqueId(), (Map<String, Long>) new AbstractMap.SimpleEntry<String, Long>("TitanKit", day * 3));
ItemStack helm = new ItemStack(Material.DIAMOND_HELMET, 1);
ItemMeta helmMeta = helm.getItemMeta();
helmMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4&lTitanium &7Kit"));
helm.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, protection);
helm.addUnsafeEnchantment(Enchantment.DURABILITY, unbreaking);
helm.setItemMeta(helmMeta);
ItemStack cp = new ItemStack(Material.DIAMOND_CHESTPLATE, 1);
ItemMeta cpMeta = cp.getItemMeta();
cpMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4&lTitanium &7Kit"));
cp.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, protection);
cp.addUnsafeEnchantment(Enchantment.DURABILITY, unbreaking);
cp.setItemMeta(cpMeta);
ItemStack legs = new ItemStack(Material.DIAMOND_LEGGINGS, 1);
ItemMeta legsMeta = legs.getItemMeta();
legsMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4&lTitanium &7Kit"));
legs.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, protection);
legs.addUnsafeEnchantment(Enchantment.DURABILITY, unbreaking);
legs.setItemMeta(legsMeta);
ItemStack booties = new ItemStack(Material.DIAMOND_BOOTS, 1);
ItemMeta bootiesMeta = booties.getItemMeta();
bootiesMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4&lTitanium &7Kit"));
booties.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, protection);
booties.addUnsafeEnchantment(Enchantment.DURABILITY, unbreaking);
booties.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 4);
booties.setItemMeta(bootiesMeta);
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1);
ItemMeta swordMeta = sword.getItemMeta();
sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, sharpness);
sword.addUnsafeEnchantment(Enchantment.DURABILITY, unbreaking);
swordMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4&lTitanium &7Kit"));
sword.setItemMeta(swordMeta);
ItemStack pearls = new ItemStack(Material.ENDER_PEARL, 16);
player.getInventory().addItem(helm);
player.getInventory().addItem(cp);
player.getInventory().addItem(legs);
player.getInventory().addItem(booties);
player.getInventory().addItem(sword);
player.getInventory().addItem(pearls);
player.updateInventory();
}
}
} else {
player.sendMessage(ChatColor.RED + "You do not have access to this kit! Purchase it at store.hcriots.net!");
}
}
示例11: onPearl
@EventHandler
public void onPearl(PlayerInteractEvent event) {
Player player = event.getPlayer();
PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);
if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && event.getItem() != null && event.getItem().getType() == Material.ENDER_PEARL) {
if (profile.getStatus() != PlayerStatus.PLAYING) {
event.setCancelled(true);
return;
}
if (profile.getCurrentMatch().getMatchStatus() == MatchStatus.STARTING) {
player.sendMessage(ChatColor.RED + "Pearl" + ChatColor.DARK_GRAY + " » " + ChatColor.GRAY + "You cannot throw an enderpearl until the match has started.");
event.setCancelled(true);
return;
}
if (profile.getEnderpearlTimer().isActive()) {
DecimalFormat format = new DecimalFormat("##.#");
String timeLeft = format.format(profile.getEnderpearlTimer().getTimeLeft() / 1000.0);
player.sendMessage(ChatColor.RED + "Pearl" + ChatColor.DARK_GRAY + " » " + ChatColor.GRAY + "You cannot throw an enderpearl for another " + ChatColor.GREEN + timeLeft + "s" + ChatColor.GRAY + ".");
event.setCancelled(true);
return;
}
profile.getEnderpearlTimer().setTimerEnd(System.currentTimeMillis() + 16000L);
new BukkitRunnable() {
public void run() {
if (player != null && player.isOnline()) {
PracticeProfile prof = ManagerHandler.getPlayerManager().getPlayerProfile(player);
if (prof == null) {
return;
}
if (prof.getStatus() == PlayerStatus.PLAYING || prof.getStatus() == PlayerStatus.FFA) {
player.sendMessage(ChatColor.RED + "Pearl" + ChatColor.DARK_GRAY + " » " + ChatColor.GRAY + "You are no longer on enderpearl cooldown.");
}
}
}
}.runTaskLater(PracticePlugin.getInstance(), 20L * 16);
}
}