本文整理匯總了Java中org.bukkit.entity.ItemFrame.getItem方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemFrame.getItem方法的具體用法?Java ItemFrame.getItem怎麽用?Java ItemFrame.getItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.entity.ItemFrame
的用法示例。
在下文中一共展示了ItemFrame.getItem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkItemFrameRotate
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void checkItemFrameRotate(PlayerInteractEntityEvent event) {
if(event.getRightClicked() instanceof ItemFrame) {
ItemFrame itemFrame = (ItemFrame) event.getRightClicked();
if(itemFrame.getItem() != null) {
// If frame contains an item, right-click will rotate it, which is handled as a "use" event
this.handleUse(event, getHangingBlockState(itemFrame), this.match.getParticipant(event.getPlayer()));
} else if(event.getPlayer().getItemInHand() != null) {
// If the frame is empty and it's right clicked with an item, this will place the item in the frame,
// which is handled as a "place" event, with the placed item as the block material
BlockState blockState = BlockStateUtils.cloneWithMaterial(itemFrame.getLocation().getBlock(),
event.getPlayer().getItemInHand().getData());
this.handleHangingPlace(event, blockState, event.getPlayer());
}
}
}
示例2: handleClick
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
private void handleClick(final Player player, final Craftomat craftomat) {
CraftomatListener.debug("handleClick", player.getName() + " is interacting with craftomat " + craftomat.getId() + " (valid: " + craftomat.isValid() + ")");
if (!craftomat.isValid()) { return; }
ItemFrame frame = craftomat.getItemFrame().get();
if (frame.getItem() != null && !frame.getItem().getType().equals(Material.AIR)) {
// Craftomat contains an item!
//CraftoMessenger.sendFailure(player, "Zurzeit können noch keine Items am Craftomaten umgewandelt werden!");
craftomat.startRotation(player);
return;
}
else {
Optional<CraftoPlayer> craftoPlayer = CraftoPlayer.getPlayer(player);
if (!craftoPlayer.isPresent()) { CraftoMessenger.sendFailure(player, Messages.PLAYER_INSTANCE_NOT_FOUND); return; }
Optional<Account> account = this.module.getAccount(craftoPlayer.get());
if (!account.isPresent()) { CraftoMessenger.sendFailure(player, "Du musst dir erst noch ein Bankkonto zulegen!"); return; }
this.loginProgress.put(player.getUniqueId(), new StringBuilder(4));
this.loginMenu.show(player);
}
}
示例3: removeMod
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public ItemStack removeMod(final Player player, final ItemFrame frame) {
// Get the mod slot.
final ModInfo info = getModFromFrame(frame);
if (info == null || !mods.contains(info))
return null;
// Get the item.
final ItemStack item = frame.getItem();
// If the material is special, do stuff.
final PortalModifier modifier = PortalModifier.get(item.getType());
if (modifier != null && !modifier.onRemove(player, this, info, item))
return null;
// Clear the item.
info.item = null;
frame.setItem(null);
// Clear the configuration.
info.flags.clear();
// And return the item.
return item;
}
示例4: onPlayerInteractItemFrame
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
@EventHandler(priority = HIGHEST, ignoreCancelled = true)
public void onPlayerInteractItemFrame(PlayerInteractEntityEvent ev) {
if (!(ev.getRightClicked() instanceof ItemFrame)) return;
ItemFrame f = (ItemFrame) ev.getRightClicked();
if (f.getItem() == null || f.getItem().getType() == Material.AIR) return;
ExhibitionFrame fr = ExhibitionFrame.fromItemFrame(f);
if (fr.isSet()) {
new Message(I18n.format("user.exhibition.looking_at")).append(fr.getItemInFrame()).send(ev.getPlayer());
ev.getPlayer().sendMessage(I18n.format("user.exhibition.provided_by", fr.getOwnerName()));
for (String line : fr.getDescriptions()) {
ev.getPlayer().sendMessage(line);
}
ev.setCancelled(true);
}
}
示例5: onPlayerHitItemFrame
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
@EventHandler(priority = HIGHEST, ignoreCancelled = true)
public void onPlayerHitItemFrame(EntityDamageByEntityEvent ev) {
if (!(ev.getEntity() instanceof ItemFrame)) return;
ItemFrame f = (ItemFrame) ev.getEntity();
if (f.getItem() == null || f.getItem().getType() == Material.AIR) return;
if (ExhibitionFrame.fromItemFrame(f).isSet()) {
ev.setCancelled(true);
if (ev.getDamager() instanceof Player) {
ev.getDamager().sendMessage(I18n.format("user.exhibition.frame_protected"));
}
}
}
示例6: onItemFrameBreak
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
@EventHandler(priority = HIGHEST, ignoreCancelled = true)
public void onItemFrameBreak(HangingBreakEvent ev) {
if (!(ev.getEntity() instanceof ItemFrame)) return;
ItemFrame f = (ItemFrame) ev.getEntity();
if (f.getItem() == null || f.getItem().getType() == Material.AIR) return;
if (ExhibitionFrame.fromItemFrame(f).isSet()) {
if (ev.getCause() == HangingBreakEvent.RemoveCause.EXPLOSION) { // Explosion protect
ev.setCancelled(true);
} else {
plugin.getLogger().warning(String.format("Exhibition broken: Location: %s, item: %s", f.getLocation().toString(),
f.getItem().toString()));
f.setItem(new ItemStack(Material.AIR));
}
}
}
示例7: showInFrame
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
@Override
public void showInFrame(Player player, ItemFrame frame, boolean force) {
if (frame.getItem() == null || frame.getItem().getType() != Material.MAP) {
if (!force) {//There's no map in the item frame: don't do anything
return;
}
}
showInFrame(player, frame.getEntityId());
}
示例8: propagateItemFrame
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
private void propagateItemFrame(ItemFrame itemFrame) {
ItemStack item = itemFrame.getItem();
if (item.getType() == Material.MAP) {
@SuppressWarnings("deprecation")
MapView mapView = plugin.getServer().getMap(item.getDurability());
for (Entity p : itemFrame.getNearbyEntities(128, 128, 128)) {
if (p instanceof Player) {
((Player) p).sendMap(mapView);
}
}
}
}
示例9: isEmpty
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public boolean isEmpty() throws CivException {
ItemFrame frame = getItemFrame();
if (frame == null) {
throw new CivException("Bad frame. Could not be found.");
}
if (frame.getItem() == null || frame.getItem().getType().equals(Material.AIR)) {
return true;
}
return false;
}
示例10: checkForEmptyDuplicateFrames
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public static void checkForEmptyDuplicateFrames(ItemFrameStorage frame) {
if (frame.noFrame()) {
return;
}
Chunk chunk = frame.getLocation().getChunk();
ArrayList<Entity> removed = new ArrayList<Entity>();
HashMap<Integer, Boolean> droppedItems = new HashMap<Integer, Boolean>();
try {
if (!frame.isEmpty()) {
droppedItems.put(ItemManager.getId(frame.getItem()), true);
}
} catch (CivException e1) {
e1.printStackTrace();
}
for (Entity entity : chunk.getEntities()) {
if (entity instanceof ItemFrame) {
if (frame.isOurEntity(entity)) {
continue;
}
int x = frame.getLocation().getBlockX();
int y = frame.getLocation().getBlockY();
int z = frame.getLocation().getBlockZ();
if (x == entity.getLocation().getBlockX() &&
y == entity.getLocation().getBlockY() &&
z == entity.getLocation().getBlockZ()) {
// We have found a duplicate item frame here.
ItemFrame eFrame = (ItemFrame)entity;
boolean eFrameEmpty = (eFrame.getItem() == null || eFrame.getItem().getType().equals(Material.AIR));
if (!eFrameEmpty) {
Boolean droppedAlready = droppedItems.get(ItemManager.getId(eFrame.getItem()));
if (droppedAlready == null || droppedAlready == false) {
droppedItems.put(ItemManager.getId(eFrame.getItem()), true);
eFrame.getLocation().getWorld().dropItemNaturally(eFrame.getLocation(), eFrame.getItem());
}
}
removed.add(eFrame);
}
}
}
for (Entity e : removed) {
e.remove();
}
return;
}
示例11: getItem
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public ItemStack getItem() {
ItemFrame frame = getItemFrame();
return frame.getItem();
}
示例12: canTarget
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
@Override
public boolean canTarget(Entity entity) {
// This is mainly here to ignore pets...
if (!targetUnknown && entity.getType() == EntityType.UNKNOWN) {
return false;
}
if (entity.hasMetadata("notarget")) return false;
if (!targetNPCs && controller.isNPC(entity)) return false;
if (!targetArmorStands && entity instanceof ArmorStand) return false;
if (damageResistanceProtection > 0 && entity instanceof LivingEntity)
{
LivingEntity living = (LivingEntity)entity;
if (living.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE)) {
Collection<PotionEffect> effects = living.getActivePotionEffects();
for (PotionEffect effect : effects) {
if (effect.getType().equals(PotionEffectType.DAMAGE_RESISTANCE) && effect.getAmplifier() >= damageResistanceProtection) {
return false;
}
}
}
}
if (entity instanceof Player)
{
Player player = (Player)entity;
if (checkProtection && player.hasPermission("Magic.protected." + this.getKey())) return false;
if (controller.isMage(entity) && isSuperProtected(controller.getMage(entity))) return false;
}
// Ignore invisible entities
if (!targetInvisible && entity instanceof LivingEntity && ((LivingEntity)entity).hasPotionEffect(PotionEffectType.INVISIBILITY)) return false;
if (targetContents != null && entity instanceof ItemFrame)
{
ItemFrame itemFrame = (ItemFrame)entity;
ItemStack item = itemFrame.getItem();
if (item == null || item.getType() != targetContents) return false;
}
if (targetEntityType == null && targetEntityTypes == null) return super.canTarget(entity);
if (targetEntityTypes != null) {
return targetEntityTypes.contains(entity.getType()) && super.canTarget(entity);
}
return targetEntityType.isAssignableFrom(entity.getClass()) && super.canTarget(entity);
}
示例13: rotate
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
private void rotate() {
Craftomat.debug("rotate", "Called! ("+Craftomat.DELAY_BETWEEN_ROTATIONS.toTicks() + ", " +(System.currentTimeMillis() - this.rotationStart) + ", " + this.isRotating + ")");
if (!this.isRotating) {
if (this.rotationTask != null && this.rotationTask.isEnabled()) { this.rotationTask.disable(); }
Craftomat.debug("rotate", "Method still called even though craftomat has finished rotation?!");
return;
}
// Check if the craftomat is still valid
if (!this.isValid()) { this.finish(); return; }
final ItemFrame frame = this.getItemFrame().get();
// Check if the item is still in the frame
final ItemStack itemStack = frame.getItem();
if (itemStack == null || itemStack.getType().equals(Material.AIR)) { this.finish(); return; }
// Rotate the itemframe
switch (frame.getRotation()) {
case NONE: frame.setRotation(Rotation.CLOCKWISE_45); break;
case CLOCKWISE_45: frame.setRotation(Rotation.CLOCKWISE); break;
case CLOCKWISE: frame.setRotation(Rotation.CLOCKWISE_135); break;
case CLOCKWISE_135: frame.setRotation(Rotation.FLIPPED); break;
case FLIPPED: frame.setRotation(Rotation.FLIPPED_45); break;
case FLIPPED_45: frame.setRotation(Rotation.COUNTER_CLOCKWISE); break;
case COUNTER_CLOCKWISE: frame.setRotation(Rotation.COUNTER_CLOCKWISE_45); break;
case COUNTER_CLOCKWISE_45: frame.setRotation(Rotation.NONE); break;
default: CraftoMessenger.warnStaff("Got unknown itemframe rotation '" + frame.getRotation() + "' in Craftomat#rotate()!"); break;
}
// Update the sign
final Sign sign = this.getSign().get();
if (sign.getLine(0).length() < 1) {
sign.setLine(0, ChatColor.BOLD + "#");
sign.setLine(3, ChatColor.BOLD + "#");
}
else {
sign.setLine(0, sign.getLine(0) + "#");
sign.setLine(3, sign.getLine(3) + "#");
}
sign.update(true, false);
// Play sound
frame.getLocation().getWorld().playSound(frame.getLocation(), Sound.BLOCK_WOOD_BUTTON_CLICK_ON, 0.75f, 0.4f);
// Check if this is the last run
if (System.currentTimeMillis() - this.rotationStart > Craftomat.COMPLETE_ROTATION_DURATION.toMillis()) {
this.finish();
}
}
示例14: finish
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
private void finish() {
Craftomat.debug("finish", "Called! ("+(System.currentTimeMillis() - this.rotationStart) + ", " + this.isRotating + ")");
this.isRotating = false;
this.rotationTask.disable();
// this.currentTransflere gets set to null at the end of the method because we still need it
// Reset the sign
if (this.getSign().isPresent()) {
final Sign sign = this.getSign().get();
sign.setLine(0, "");
sign.setLine(3, "");
sign.update(true, false);
}
// Transform the item if it is still in the frame
if (this.getItemFrame().isPresent()) {
final ItemFrame frame = this.getItemFrame().get();
final ItemStack itemStack = frame.getItem();
if (itemStack != null && !itemStack.getType().equals(Material.AIR)) {
// Validate that the item in the frame is still valid
final Optional<ItemModule> itemModule = this.module.getModule(ItemModule.class);
if (!itemModule.isPresent()) { Craftomat.debug("finish", "Missing ItemModule!"); return; }
final Optional<CustomItem> customItem = itemModule.get().getItem(itemStack);
if (!customItem.isPresent()) { Craftomat.debug("finish", "Inserted item is not a CustomItem!"); return; }
final Optional<CustomItemHandler> itemHandler = customItem.get().getHandler();
if (!itemHandler.isPresent()) { Craftomat.debug("finish", "Customitem " + customItem.get().getId() + " doesnt have a handler"); return; }
// Check if the itemHandler has changed
if (!itemHandler.get().equals(this.currentTransferable)) { Craftomat.debug("finish", "The currentTransferable is not equal to the itemHandler of currently inserted item?!?!"); return; }
final Optional<ItemStack> resultItem = this.currentTransferable.onTransfer(this.rotationInitiator, customItem.get(), itemStack);
if (resultItem.isPresent()) {
// Prepare log message
final StringBuilder logMessage = new StringBuilder("Craftomat Rotation (initiated by ").append(this.rotationInitiator.getName())
.append(") transformed the CustomItem #").append(customItem.get().getId()).append(" to item: ").append(resultItem.get().getType());
final Optional<CustomItem> resultCustomItem = itemModule.get().getItem(resultItem.get());
if (resultCustomItem.isPresent()) {
logMessage.append(" (customItemId=").append(resultCustomItem.get().getId()).append(')');
}
if (resultItem.get().hasItemMeta()) {
final ItemMeta meta = resultItem.get().getItemMeta();
if (meta.hasDisplayName()) { logMessage.append(" (displayName=").append(meta.getDisplayName()).append(')'); }
}
CraftoMessenger.log(logMessage.toString());
// Play some sounds & particle
frame.getLocation().getWorld().playSound(frame.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1.5f, 2.0f);
final Location particleLoc = new Location(frame.getWorld(), frame.getLocation().getBlockX() + 0.5, frame.getLocation().getBlockY() + 0.5, frame.getLocation().getBlockZ() + 0.5);
Particle particleEffect = Particle.SPELL;
if (resultCustomItem.isPresent() && resultCustomItem.get().getHandler().isPresent()) {
final Tier tier = resultCustomItem.get().getHandler().get().getTier();
switch (tier) {
case BASIC: particleEffect = Particle.SPELL; break;
case ADVANCED: particleEffect = Particle.SPELL_INSTANT; break;
case LEGENDARY: particleEffect = Particle.SPELL_MOB; break;
case MYTHICAL: particleEffect = Particle.SPELL_WITCH; break;
}
}
particleLoc.getWorld().spawnParticle(particleEffect, particleLoc, 2);
// Finish
frame.setItem(resultItem.get());
Craftomat.debug("finish", "Successfully transformed item! (See console log for more information)");
}
}
}
this.currentTransferable = null;
}
示例15: SerializableFurnitureEntity
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
/**
* Constructor.
*
* @param entity The {@link org.bukkit.entity.Entity} that needs to be serialized.
*/
public SerializableFurnitureEntity(Entity entity) {
PreCon.notNull(entity);
_location = entity.getLocation();
_type = entity.getType();
if (entity instanceof Directional) {
Directional directional = (Directional)entity;
_facing = directional.getFacing();
_canSerialize = true;
}
if (entity instanceof Painting) {
Painting painting = (Painting)entity;
_art = painting.getArt();
_canSerialize = true;
}
if (entity instanceof ItemFrame) {
ItemFrame frame = (ItemFrame)entity;
_frameItem = frame.getItem();
_frameRotation = frame.getRotation();
}
if (entity instanceof ArmorStand) {
ArmorStand stand = (ArmorStand)entity;
_hasArmorStand = true;
_itemInHand = stand.getItemInHand();
_helmet = stand.getHelmet();
_chestplate = stand.getChestplate();
_leggings = stand.getLeggings();
_boots = stand.getBoots();
_headPose = stand.getHeadPose();
_bodyPose = stand.getBodyPose();
_leftArmPose = stand.getLeftArmPose();
_rightArmPose = stand.getRightArmPose();
_leftLegPose = stand.getLeftLegPose();
_rightLegPose = stand.getRightLegPose();
_hasArmorBasePlate = stand.hasBasePlate();
_hasArmorGravity = stand.hasGravity();
_isArmorVisible = stand.isVisible();
_hasArmorArms = stand.hasArms();
_isArmorSmall = stand.isSmall();
}
}