本文整理匯總了Java中org.bukkit.entity.Item類的典型用法代碼示例。如果您正苦於以下問題:Java Item類的具體用法?Java Item怎麽用?Java Item使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Item類屬於org.bukkit.entity包,在下文中一共展示了Item類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: PlaceCheckDoor
import org.bukkit.entity.Item; //導入依賴的package包/類
@EventHandler
public void PlaceCheckDoor(BlockPlaceEvent e) {
if(ConfigPatch.AntiInfSuagrenable){
if(e.isCancelled()){
Player p = e.getPlayer();
List<Entity> entities = p.getNearbyEntities(2, 2, 2);
for(int i=0;i<entities.size();i++){
Entity ent = entities.get(i);
if(ent.getType() == EntityType.DROPPED_ITEM){
Item item = (Item)ent;
if(item.getItemStack().getType() == Material.SUGAR_CANE||item.getItemStack().getType() == Material.CACTUS){
ent.remove();
}
}
}
}
}
}
示例2: checkPedestal
import org.bukkit.entity.Item; //導入依賴的package包/類
private void checkPedestal(Block pedestal)
{
Item item = AncientAltarListener.findItem(pedestal);
if(item == null)
{
abort();
} else
{
particles.add(pedestal.getLocation().add(0.5D, 1.5D, 0.5D));
items.add(AncientAltarListener.fixItemStack(item.getItemStack(), item.getCustomName()));
pedestal.getWorld().playSound(pedestal.getLocation(), Sound.ENTITY_ENDERMEN_TELEPORT, 5F, 2.0F);
try
{
ParticleEffect.ENCHANTMENT_TABLE.display(pedestal.getLocation().add(0.5D, 1.5D, 0.5D), 0.3F, 0.2F, 0.3F, 0.0F, 16);
ParticleEffect.CRIT_MAGIC.display(pedestal.getLocation().add(0.5D, 1.5D, 0.5D), 0.3F, 0.2F, 0.3F, 0.0F, 8);
}
catch(Exception e)
{
e.printStackTrace();
}
item.remove();
pedestal.removeMetadata("item_placed", SlimefunStartup.instance);
}
}
示例3: grenadeEvent
import org.bukkit.entity.Item; //導入依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler
public void grenadeEvent(PlayerInteractEvent e){
final Player p = e.getPlayer();
if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
if(p.getItemInHand().hasItemMeta()){
if(p.getItemInHand().getItemMeta().getLore() == null) return;
if(p.getItemInHand().getItemMeta().getLore().contains(ChatColor.GRAY + "Grenade I")){
p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() - 4));
final Item grenade = p.getWorld().dropItem(p.getEyeLocation(), new ItemStack(Material.CLAY_BALL));
grenade.setVelocity(p.getEyeLocation().getDirection().normalize().multiply(0.8D));
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
public void run(){
p.getWorld().createExplosion(grenade.getLocation().getX(), grenade.getLocation().getY(),
grenade.getLocation().getZ(), 3, false, false);
grenade.remove();
}
},30L);
}
}
}
}
示例4: handleItemDespawn
import org.bukkit.entity.Item; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void handleItemDespawn(final EntityDespawnInVoidEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof Item)) return;
ItemStack stack = ((Item) entity).getItemStack();
PlayerId playerId = this.droppedWools.remove(entity);
if (playerId == null) return;
ParticipantState player = PGM.getMatchManager().getParticipantState(playerId);
if (player == null) return;
if(isDestroyableWool(stack, player.getParty())) {
giveWoolDestroyRaindrops(player, ((Wool) stack.getData()).getColor());
}
}
示例5: playerInteract
import org.bukkit.entity.Item; //導入依賴的package包/類
@EventHandler
public void playerInteract(final PlayerInteractEvent event) {
if(event.getAction() == Action.PHYSICAL
|| !(Gizmos.gizmoMap.get(event.getPlayer()) instanceof GunGizmo)
|| event.getItem() == null || event.getItem().getType() != this.getIcon()) return;
final Player player = event.getPlayer();
RaindropUtil.giveRaindrops(Users.playerId(player), -1, new RaindropResult() {
@Override
public void run() {
if(success) {
Vector velocity = player.getLocation().getDirection().multiply(1.75D);
Item item = player.getWorld().dropItem(event.getPlayer().getEyeLocation(), new ItemStack(Material.GHAST_TEAR));
item.setVelocity(velocity);
item.setTicksLived((5 * 60 * 20) - (5 * 20)); // 5 minutes - 5 seconds
items.put(item, player.getUniqueId());
} else {
player.sendMessage(ChatColor.RED + LobbyTranslations.get().t("gizmo.gun.empty", player));
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 1f, 1f);
}
}
}, null, false, true, false);
}
示例6: run
import org.bukkit.entity.Item; //導入依賴的package包/類
@Override
public void run() {
for(Item item : Bukkit.getWorlds().get(0).getEntitiesByClass(Item.class)) {
if(item.getItemStack().getType() != Material.GHAST_TEAR) continue;
UUID skip = Gizmos.gunGizmo.items.get(item);
for(Entity entity : item.getNearbyEntities(0.5d, 0.5d, 0.5d)) {
if(entity instanceof Player && !entity.getUniqueId().equals(skip)) {
Player player = (Player) entity;
if(player.hasPermission("gizmo.immunity")) continue;
player.damage(0d, item);
Gizmos.gunGizmo.gifts.add(player.getUniqueId());
item.remove();
break;
}
}
if(item.getTicksLived() >= 6000) item.remove();
}
}
示例7: craft
import org.bukkit.entity.Item; //導入依賴的package包/類
public boolean craft(Player crafter) {
// TODO Block crafting operation when not allowed for player
String spell = getSpell();
if (spell != null) {
ItemStack tome = SpellTome.getSpellTome(spell, crafter);
Location spawnLoc = block.getLocation().add(0.5, 1.5, 0.5);
spawnLoc.getWorld().spawnParticle(Particle.ENCHANTMENT_TABLE, spawnLoc, 40);
for (Entry<Item, BukkitRunnable> entry : items.entrySet()) {
Item item = entry.getKey();
item.remove();
entry.getValue().cancel();
}
book.setCustomNameVisible(false);
new BukkitRunnable() {
public void run() {
book.setItemStack(tome);
book.setGlowing(false);
book.setPickupDelay(0);
book.getWorld().playSound(book.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
}
}.runTaskLater(MystiCraft.getInstance(), 32);
return true;
} else {
return false;
}
}
示例8: onItemPickUpEvent
import org.bukkit.entity.Item; //導入依賴的package包/類
@EventHandler
public void onItemPickUpEvent(PlayerPickupItemEvent event) {
final Game game;
if ((game = this.controller.getGameFromPlayer(event.getPlayer())) != null) {
for (final Item item : game.getArena().getBoostItemHandler().getDroppedItems()) {
final BoostItem boostItem;
if (item.equals(event.getItem()) && ((boostItem = game.getArena().getBoostItemHandler().getBoostFromItem(item)) != null)) {
try {
new FastSound("NOTE_PLING", 2.0, 2.0).play(event.getPlayer().getLocation(), event.getPlayer());
} catch (final InterPreter19Exception e) {
Bukkit.getLogger().log(Level.WARNING, "Failed to play sound.", e);
}
game.getArena().getBoostItemHandler().removeItem(event.getItem());
boostItem.apply(event.getPlayer());
event.setCancelled(true);
event.getItem().remove();
}
}
}
}
示例9: run
import org.bukkit.entity.Item; //導入依賴的package包/類
@Override
public void run(Game game) {
final Arena arena = game.getArena();
if (this.rate == Spawnrate.NONE)
return;
if (this.bumper <= 0) {
if (game.getPlayers().isEmpty()) {
this.clearGroundItems();
this.bumper = 40;
return;
}
for (final Item item : this.getLDroppedItems().keySet().toArray(new Item[this.getLDroppedItems().size()])) {
if (item.isDead() || item.getTicksLived() > 1000) {
item.remove();
this.getLDroppedItems().remove(item);
}
}
if (this.getRandom().nextInt(100) < this.rate.getSpawnChance()) {
if (this.getLDroppedItems().size() < this.rate.getMaxAmount()) {
this.spawnRandomItem(arena);
}
}
this.bumper = 40;
}
this.bumper--;
}
示例10: run
import org.bukkit.entity.Item; //導入依賴的package包/類
/**
* Clean the cache
*/
@Override
public void run()
{
long currentTime = System.currentTimeMillis();
List<Map.Entry<Chunk, Long>> temp = new ArrayList<>();
temp.addAll(this.lastChunkCleanUp.entrySet());
for (Map.Entry<Chunk, Long> entry : temp)
{
Chunk chunk = entry.getKey();
if (!chunk.isLoaded() || (currentTime - entry.getValue() <= 60000))
continue;
for (Entity entity : chunk.getEntities())
if (!(entity instanceof Item || entity instanceof HumanEntity || entity instanceof Minecart))
entity.remove();
this.lastChunkCleanUp.remove(chunk);
}
}
示例11: onPlace
import org.bukkit.entity.Item; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlace(BlockPlaceEvent e) {
if (!cm.isAntiPlaceDoorDupe) {
return;
}
// 判斷手裏的物品是否為門
if (e.getItemInHand().getType() == Material.WOOD_DOOR || e.getItemInHand().getType() == Material.IRON_DOOR) {
// 清理所在區塊的甘蔗掉落物
for (Entity entity : e.getPlayer().getLocation().getChunk().getEntities()) {
if (entity instanceof Item) {
Material itemType = ((Item) entity).getItemStack().getType();
if (itemType == Material.SUGAR_CANE || itemType == Material.CACTUS) {
entity.remove();
}
}
}
}
}
示例12: play
import org.bukkit.entity.Item; //導入依賴的package包/類
public void play(TOAUser u){
if (!canUse(u)) return;
if (isInCooldown(u, getName())) return;
int lvl = u.getUserData().getLvl();
for (int x = 0; x < r.nextInt(4) + 2; x++) {
final Item d1 = u.getLoc().getWorld().dropItemNaturally(u.getLoc(), new ItemStack(Material.IRON_SWORD));
d1.setVelocity(u.getPlayer().getVelocity().multiply(2));
plugin.getServer().getScheduler().runTaskTimer(plugin, () -> {
World w = d1.getLocation().getWorld();
w.getNearbyEntities(d1.getLocation(), 1, 1, 1).stream()
.filter(en -> !en.getType().equals(EntityType.PLAYER)).forEach(en -> {
if (en instanceof Monster) ((Monster) en).damage(40 + (lvl * 0.7));
d1.remove();
});
}, 0, 20);
}
cool.setOnCooldown(getName());
}
示例13: onInteract
import org.bukkit.entity.Item; //導入依賴的package包/類
@EventHandler
public void onInteract(PlayerInteractEvent e) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (e.getClickedBlock().getType() == Material.CAULDRON) {
if (e.getClickedBlock().getLocation().add(0, -1, 0).getBlock().getType() == Material.DIAMOND_BLOCK) {
Item item = e.getPlayer().getWorld().dropItem(e.getClickedBlock().getLocation().add(0.5, 2, 0.5), e.getPlayer().getEquipment().getItemInMainHand());
item.setMetadata("item-owner", new FixedMetadataValue(NationZ.plugin, e.getPlayer().getUniqueId().toString()));
item.setVelocity(new Vector(0, 0, 0));
item.setCustomName(item.getName());
item.setCustomNameVisible(true);
e.getPlayer().getEquipment().setItemInMainHand(null);
e.setCancelled(true);
}
}
}
}
示例14: compare
import org.bukkit.entity.Item; //導入依賴的package包/類
@Override
public Relation compare(final EntityData e, final ItemType i) {
if (e instanceof Item)
return Relation.get(i.isOfType(((Item) e).getItemStack()));
if (e instanceof ThrownPotion)
return Relation.get(i.isOfType(Material.POTION.getId(), PotionEffectUtils.guessData((ThrownPotion) e)));
if (Skript.classExists("org.bukkit.entity.WitherSkull") && e instanceof WitherSkull)
return Relation.get(i.isOfType(Material.SKULL_ITEM.getId(), (short) 1));
if (entityMaterials.containsKey(e.getType()))
return Relation.get(i.isOfType(entityMaterials.get(e.getType()).getId(), (short) 0));
for (final Entry<Class<? extends Entity>, Material> m : entityMaterials.entrySet()) {
if (m.getKey().isAssignableFrom(e.getType()))
return Relation.get(i.isOfType(m.getValue().getId(), (short) 0));
}
return Relation.NOT_EQUAL;
}
示例15: onItemDrop
import org.bukkit.entity.Item; //導入依賴的package包/類
@EventHandler
public void onItemDrop(PlayerDropItemEvent event)
{
System.out.println("Item drop");
Item item = event.getItemDrop();
ItemStack stack = item.getItemStack();
Location location = item.getLocation();
Player player = event.getPlayer();
String playerName = player == null ? "null" : player.getName();
DropItemObsel obsel = new DropItemObsel(
new Date().getTime(),
stack.getType().toString(),
stack.getAmount(),
stack.getData().getData(),
location.getBlockX(),
location.getBlockY(),
location.getBlockZ(),
location.getWorld().getName(),
playerName);
JSONObselManager.getInstance().addObsel(obsel);
}