本文整理汇总了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;
}
示例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;
}
示例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));
}
示例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));
}
}
}
示例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);
}
示例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());
}
}
示例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()));
}
示例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;
}
示例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;
}
示例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;
}