當前位置: 首頁>>代碼示例>>Java>>正文


Java ItemFrame.setItem方法代碼示例

本文整理匯總了Java中org.bukkit.entity.ItemFrame.setItem方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemFrame.setItem方法的具體用法?Java ItemFrame.setItem怎麽用?Java ItemFrame.setItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.entity.ItemFrame的用法示例。


在下文中一共展示了ItemFrame.setItem方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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;
}
 
開發者ID:stendec,項目名稱:Abyss,代碼行數:25,代碼來源:ABPortal.java

示例2: setMod

import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public boolean setMod(final Player player, final ItemFrame frame, final ItemStack item) {
    // Get the mod slot.
    final ModInfo info = getModFromFrame(frame);
    if (info == null || !mods.contains(info))
        return false;

    // If we've already got a modifier, remove it. If we can't, return false.
    if (info.item != null && removeMod(player, frame) == null)
        return false;

    // Get the modifier for this material and try to apply it.
    final PortalModifier modifier = PortalModifier.get(item.getType());
    if (modifier == null || !modifier.hasPermission(player, this, info, item) || !modifier.onApply(player, this, info, item))
        return false;

    // It worked. Set the item and return.
    info.item = item;
    frame.setItem(item);
    return true;
}
 
開發者ID:stendec,項目名稱:Abyss,代碼行數:21,代碼來源:ABPortal.java

示例3: setIDFrames

import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
private void setIDFrames(short value, ItemFrame frame1, ItemFrame frame2) {
    // Try to avoid null pointer exceptions, shall we?
    if (frame1 == null || frame2 == null)
        return;

    if (value < 0 || value > 288) {
        ItemStack bedrock = new ItemStack(Material.BEDROCK, 1);
        frame1.setItem(bedrock);
        frame2.setItem(bedrock);
        return;
    }

    int f1 = (value / 17) - 1;
    int f2 = (value % 17) - 1;

    frame1.setItem((f1 == -1) ? null : new ItemStack(Material.WOOL, 1, (short) f1));
    frame2.setItem((f2 == -1) ? null : new ItemStack(Material.WOOL, 1, (short) f2));
}
 
開發者ID:stendec,項目名稱:Abyss,代碼行數:19,代碼來源:ABPortal.java

示例4: 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));
        }
    }
}
 
開發者ID:NyaaCat,項目名稱:NyaaUtils,代碼行數:16,代碼來源:ExhibitionListener.java

示例5: attachItemFrame

import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public static void attachItemFrame(Block block, ItemStack map, BlockFace face) {
    ItemFrame frame = block.getWorld().spawn(block.getRelative(face).getLocation(), ItemFrame.class);
    Block frameBlock = block.getRelative(face);
    frameBlock.setType(Material.AIR);
    frame.teleport(frameBlock.getLocation());
    frame.setFacingDirection(face, true);
    frame.setItem(map);
    frame.setRotation(Rotation.NONE);
}
 
開發者ID:leMaik,項目名稱:RpgPlus,代碼行數:10,代碼來源:Util.java

示例6: setItem

import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public void setItem(ItemStack stack) {

		ItemFrame frame = getItemFrame();
		if (frame != null) {
			ItemStack newStack = new ItemStack(stack.getType(), 1, stack.getDurability());
			newStack.setData(stack.getData());
			newStack.setItemMeta(stack.getItemMeta());
			frame.setItem(newStack);
		} else {
			CivLog.warning("Frame:"+this.frameID+" was null when trying to set to "+stack.getType().name());
		}
		
	}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:14,代碼來源:ItemFrameStorage.java

示例7: execute

import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
@Override
public void execute(BlockPlacer blockPlacer, BlockLoger loger) {
    Chunk chunk = m_location.getChunk();
    if (!chunk.isLoaded()) {
        if (!chunk.load()) {
            return;
        }
    }

    World w = m_location.getWorld();
    Block block = w.getBlockAt(m_location);
    Material material = block.getType();
    if (!isSolid(material)) {
        m_oldMaterial = material;
        block.setType(Material.BARRIER);
    } else {
        m_oldMaterial = null;
    }

    m_frame = (ItemFrame) w.spawn(block.getRelative(m_rotation).getLocation(), ItemFrame.class);
    m_frame.setFacingDirection(m_rotation, true);
    m_frame.setRotation(Rotation.NONE);

    m_mapView = Bukkit.createMap(w);
    m_mapHelper.storeMap(m_mapView, m_img);
    m_mapHelper.drawImage(m_mapView, m_img);
    m_frame.setItem(new ItemStack(Material.MAP, 1, m_mapView.getId()));
}
 
開發者ID:SBPrime,項目名稱:MCPainter,代碼行數:29,代碼來源:HdImageCommand.java

示例8: setModFrame

import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public ItemFrame setModFrame(ModInfo info, ItemFrame frame) {
    FrameInfo f = new FrameInfo(FrameInfo.Frame.MOD, frame);

    // Store the new FrameInfo.
    info.frame = f;
    info.updateLocation();

    frameIDs.put(f.id, f);
    plugin.getManager().addFrame(this, frame);

    // Make sure the frame is showing the right item.
    frame.setItem(info.item);

    return frame;
}
 
開發者ID:stendec,項目名稱:Abyss,代碼行數:16,代碼來源:ABPortal.java

示例9: 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;
}
 
開發者ID:Craftolution,項目名稱:CraftoPlugin,代碼行數:80,代碼來源:Craftomat.java

示例10: applyToEntity

import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
private boolean applyToEntity(Entity entity) {

        entity.teleport(_location);

        if (entity instanceof Directional && _facing != null) {

            Directional directional = (Directional)entity;
            directional.setFacingDirection(_facing);
        }

        if (entity instanceof Painting && _art != null) {
            Painting painting = (Painting)entity;

            painting.setArt(_art);
        }

        if (entity instanceof ItemFrame && _frameItem != null) {
            ItemFrame frame = (ItemFrame)entity;

            frame.setItem(_frameItem);
            frame.setRotation(_frameRotation);
        }

        if (entity instanceof ArmorStand && _hasArmorStand) {
            ArmorStand stand = (ArmorStand)entity;

            stand.setItemInHand(_itemInHand);
            stand.setHelmet(_helmet);
            stand.setChestplate(_chestplate);
            stand.setLeggings(_leggings);
            stand.setBoots(_boots);
            stand.setHeadPose(_headPose);
            stand.setBodyPose(_bodyPose);
            stand.setLeftArmPose(_leftArmPose);
            stand.setRightArmPose(_rightArmPose);
            stand.setLeftLegPose(_leftLegPose);
            stand.setRightLegPose(_rightLegPose);
            stand.setBasePlate(_hasArmorBasePlate);
            stand.setGravity(_hasArmorGravity);
            stand.setVisible(_isArmorVisible);
            stand.setArms(_hasArmorArms);
            stand.setSmall(_isArmorSmall);
        }

        if (_facing == null)
            return false;

        return true;
    }
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:50,代碼來源:SerializableFurnitureEntity.java


注:本文中的org.bukkit.entity.ItemFrame.setItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。