本文整理了Java中org.bukkit.Bukkit.getItemFactory()
方法的一些代码示例,展示了Bukkit.getItemFactory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bukkit.getItemFactory()
方法的具体详情如下:
包路径:org.bukkit.Bukkit
类名称:Bukkit
方法名:getItemFactory
暂无
代码示例来源:origin: Bukkit/Bukkit
/**
* Checks to see if any meta data has been defined.
*
* @return Returns true if some meta data has been set for this item
*/
public boolean hasItemMeta() {
return !Bukkit.getItemFactory().equals(meta, null);
}
代码示例来源:origin: Bukkit/Bukkit
public PlayerEditBookEvent(Player who, int slot, BookMeta previousBookMeta, BookMeta newBookMeta, boolean isSigning) {
super(who);
Validate.isTrue(slot >= 0 && slot <=8, "Slot must be in range 0-8 inclusive");
Validate.notNull(previousBookMeta, "Previous book meta must not be null");
Validate.notNull(newBookMeta, "New book meta must not be null");
Bukkit.getItemFactory().equals(previousBookMeta, newBookMeta);
this.previousBookMeta = previousBookMeta;
this.newBookMeta = newBookMeta;
this.slot = slot;
this.isSigning = isSigning;
this.cancel = false;
}
代码示例来源:origin: Bukkit/Bukkit
/**
* Sets the book meta that will actually be added to the book.
*
* @param newBookMeta new book meta
* @throws IllegalArgumentException if the new book meta is null
*/
public void setNewBookMeta(BookMeta newBookMeta) throws IllegalArgumentException {
Validate.notNull(newBookMeta, "New book meta must not be null");
Bukkit.getItemFactory().equals(newBookMeta, null);
this.newBookMeta = newBookMeta.clone();
}
代码示例来源:origin: Bukkit/Bukkit
private boolean setItemMeta0(ItemMeta itemMeta, Material material) {
if (itemMeta == null) {
this.meta = null;
return true;
}
if (!Bukkit.getItemFactory().isApplicable(itemMeta, material)) {
return false;
}
this.meta = Bukkit.getItemFactory().asMetaFor(itemMeta, material);
if (this.meta == itemMeta) {
this.meta = itemMeta.clone();
}
return true;
}
}
代码示例来源:origin: Bukkit/Bukkit
/**
* Sets the type id of this item
* <p>
* Note that in doing so you will reset the MaterialData for this stack
*
* @param type New type id to set the items in this stack to
* @deprecated Magic value
*/
@Deprecated
public void setTypeId(int type) {
this.type = type;
if (this.meta != null) {
this.meta = Bukkit.getItemFactory().asMetaFor(meta, getType0());
}
createData((byte) 0);
}
代码示例来源:origin: Bukkit/Bukkit
/**
* Get a copy of this ItemStack's {@link ItemMeta}.
*
* @return a copy of the current ItemStack's ItemData
*/
public ItemMeta getItemMeta() {
return this.meta == null ? Bukkit.getItemFactory().getItemMeta(getType0()) : this.meta.clone();
}
代码示例来源:origin: Bukkit/Bukkit
/**
* Adds the specified {@link Enchantment} to this item stack.
* <p>
* If this item stack already contained the given enchantment (at any
* level), it will be replaced.
* <p>
* This method is unsafe and will ignore level restrictions or item type.
* Use at your own discretion.
*
* @param ench Enchantment to add
* @param level Level of the enchantment
*/
public void addUnsafeEnchantment(Enchantment ench, int level) {
(meta == null ? meta = Bukkit.getItemFactory().getItemMeta(getType0()) : meta).addEnchant(ench, level, true);
}
代码示例来源:origin: Bukkit/Bukkit
@Utility
public Map<String, Object> serialize() {
Map<String, Object> result = new LinkedHashMap<String, Object>();
result.put("type", getType().name());
if (getDurability() != 0) {
result.put("damage", getDurability());
}
if (getAmount() != 1) {
result.put("amount", getAmount());
}
ItemMeta meta = getItemMeta();
if (!Bukkit.getItemFactory().equals(meta, null)) {
result.put("meta", meta);
}
return result;
}
代码示例来源:origin: Bukkit/Bukkit
/**
* This method is the same as equals, but does not consider stack size
* (amount).
*
* @param stack the item stack to compare to
* @return true if the two stacks are equal, ignoring the amount
*/
@Utility
public boolean isSimilar(ItemStack stack) {
if (stack == null) {
return false;
}
if (stack == this) {
return true;
}
return getTypeId() == stack.getTypeId() && getDurability() == stack.getDurability() && hasItemMeta() == stack.hasItemMeta() && (hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true);
}
代码示例来源:origin: SpigotMC/Spigot-API
/**
* Checks to see if any meta data has been defined.
*
* @return Returns true if some meta data has been set for this item
*/
public boolean hasItemMeta() {
return !Bukkit.getItemFactory().equals(meta, null);
}
代码示例来源:origin: SpigotMC/Spigot-API
public PlayerEditBookEvent(Player who, int slot, BookMeta previousBookMeta, BookMeta newBookMeta, boolean isSigning) {
super(who);
Validate.isTrue(slot >= 0 && slot <=8, "Slot must be in range 0-8 inclusive");
Validate.notNull(previousBookMeta, "Previous book meta must not be null");
Validate.notNull(newBookMeta, "New book meta must not be null");
Bukkit.getItemFactory().equals(previousBookMeta, newBookMeta);
this.previousBookMeta = previousBookMeta;
this.newBookMeta = newBookMeta;
this.slot = slot;
this.isSigning = isSigning;
this.cancel = false;
}
代码示例来源:origin: SpigotMC/Spigot-API
/**
* Sets the book meta that will actually be added to the book.
*
* @param newBookMeta new book meta
* @throws IllegalArgumentException if the new book meta is null
*/
public void setNewBookMeta(BookMeta newBookMeta) throws IllegalArgumentException {
Validate.notNull(newBookMeta, "New book meta must not be null");
Bukkit.getItemFactory().equals(newBookMeta, null);
this.newBookMeta = newBookMeta.clone();
}
代码示例来源:origin: SpigotMC/Spigot-API
private boolean setItemMeta0(ItemMeta itemMeta, Material material) {
if (itemMeta == null) {
this.meta = null;
return true;
}
if (!Bukkit.getItemFactory().isApplicable(itemMeta, material)) {
return false;
}
this.meta = Bukkit.getItemFactory().asMetaFor(itemMeta, material);
if (this.meta == itemMeta) {
this.meta = itemMeta.clone();
}
return true;
}
}
代码示例来源:origin: SpigotMC/Spigot-API
/**
* Sets the type id of this item
* <p>
* Note that in doing so you will reset the MaterialData for this stack
*
* @param type New type id to set the items in this stack to
* @deprecated Magic value
*/
@Deprecated
public void setTypeId(int type) {
this.type = type;
if (this.meta != null) {
this.meta = Bukkit.getItemFactory().asMetaFor(meta, getType0());
}
createData((byte) 0);
}
代码示例来源:origin: SpigotMC/Spigot-API
/**
* Get a copy of this ItemStack's {@link ItemMeta}.
*
* @return a copy of the current ItemStack's ItemData
*/
public ItemMeta getItemMeta() {
return this.meta == null ? Bukkit.getItemFactory().getItemMeta(getType0()) : this.meta.clone();
}
代码示例来源:origin: SpigotMC/Spigot-API
/**
* Adds the specified {@link Enchantment} to this item stack.
* <p>
* If this item stack already contained the given enchantment (at any
* level), it will be replaced.
* <p>
* This method is unsafe and will ignore level restrictions or item type.
* Use at your own discretion.
*
* @param ench Enchantment to add
* @param level Level of the enchantment
*/
public void addUnsafeEnchantment(Enchantment ench, int level) {
(meta == null ? meta = Bukkit.getItemFactory().getItemMeta(getType0()) : meta).addEnchant(ench, level, true);
}
代码示例来源:origin: SpigotMC/Spigot-API
@Utility
public Map<String, Object> serialize() {
Map<String, Object> result = new LinkedHashMap<String, Object>();
result.put("type", getType().name());
if (getDurability() != 0) {
result.put("damage", getDurability());
}
if (getAmount() != 1) {
result.put("amount", getAmount());
}
ItemMeta meta = getItemMeta();
if (!Bukkit.getItemFactory().equals(meta, null)) {
result.put("meta", meta);
}
return result;
}
代码示例来源:origin: aikar/commands
@SuppressWarnings("JavaReflectionMemberAccess")
public BukkitCommandManager(Plugin plugin) {
this.plugin = plugin;
this.logger = Logger.getLogger(this.plugin.getName());
this.timingManager = TimingManager.of(plugin);
this.commandTiming = this.timingManager.of("Commands");
this.commandMap = hookCommandMap();
this.formatters.put(MessageType.ERROR, defaultFormatter = new BukkitMessageFormatter(ChatColor.RED, ChatColor.YELLOW, ChatColor.RED));
this.formatters.put(MessageType.SYNTAX, new BukkitMessageFormatter(ChatColor.YELLOW, ChatColor.GREEN, ChatColor.WHITE));
this.formatters.put(MessageType.INFO, new BukkitMessageFormatter(ChatColor.BLUE, ChatColor.DARK_GREEN, ChatColor.GREEN));
this.formatters.put(MessageType.HELP, new BukkitMessageFormatter(ChatColor.AQUA, ChatColor.GREEN, ChatColor.YELLOW));
Bukkit.getPluginManager().registerEvents(new ACFBukkitListener(this, plugin), plugin);
getLocales(); // auto load locales
this.localeTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
if (this.cantReadLocale || !this.autoDetectFromClient) {
return;
}
Bukkit.getOnlinePlayers().forEach(this::readPlayerLocale);
}, 5, 5);
registerDependency(plugin.getClass(), plugin);
registerDependency(Plugin.class, plugin);
registerDependency(JavaPlugin.class, plugin);
registerDependency(PluginManager.class, Bukkit.getPluginManager());
registerDependency(Server.class, Bukkit.getServer());
registerDependency(BukkitScheduler.class, Bukkit.getScheduler());
registerDependency(ScoreboardManager.class, Bukkit.getScoreboardManager());
registerDependency(ItemFactory.class, Bukkit.getItemFactory());
}
代码示例来源:origin: SpigotMC/Spigot-API
/**
* This method is the same as equals, but does not consider stack size
* (amount).
*
* @param stack the item stack to compare to
* @return true if the two stacks are equal, ignoring the amount
*/
@Utility
public boolean isSimilar(ItemStack stack) {
if (stack == null) {
return false;
}
if (stack == this) {
return true;
}
return getTypeId() == stack.getTypeId() && getDurability() == stack.getDurability() && hasItemMeta() == stack.hasItemMeta() && (hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true);
}
代码示例来源:origin: artex-development/Lukkit
this.meta = (SkullMeta) Bukkit.getItemFactory().getItemMeta(Material.SKULL_ITEM);
} else {
this.meta = (SkullMeta) this.skull.getItemMeta();
内容来源于网络,如有侵权,请联系作者删除!