本文整理汇总了Java中org.bukkit.inventory.ItemStack.addUnsafeEnchantment方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.addUnsafeEnchantment方法的具体用法?Java ItemStack.addUnsafeEnchantment怎么用?Java ItemStack.addUnsafeEnchantment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.ItemStack
的用法示例。
在下文中一共展示了ItemStack.addUnsafeEnchantment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPreStart
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Override
public void onPreStart() {
Location spawnLocation = Utils.parseLocation((String) this.getGameMap().fetchSetting("startPosition"));
MaterialData materialData = Utils.parseMaterialData((String) this.getGameMap().fetchSetting("item"));
ItemStack itemStack = new ItemStack(materialData.getItemType(), 1, materialData.getData());
itemStack.addUnsafeEnchantment(Enchantment.KNOCKBACK,
Integer.parseInt((String) this.getGameMap().fetchSetting("knockbackAmount")));
for(Player player : Bukkit.getOnlinePlayers()) {
if(!this.getAPI().getGameManager().isAlive(player)) continue;
player.teleport(spawnLocation);
player.setGameMode(GameMode.ADVENTURE);
player.getInventory().addItem(itemStack);
}
this.hill = new Cuboid(Utils.parseLocation((String) this.getGameMap().fetchSetting("hillBoundsA")),
Utils.parseLocation((String) this.getGameMap().fetchSetting("hillBoundsB")));
}
示例2: run
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public void run(WCUser user, String label, String[] args){
if (args.length == 2){
boolean unsafe = plugin.getConfig().getBoolean("allowUnsafeEnchantment");
ItemStack i = user.getPlayer().getInventory().getItemInMainHand();
Enchantment enchantment;
int level;
if (!Utils.isInt(args[1])) return;
enchantment = getEnchantment(args[0]);
level = Integer.parseInt(args[1]);
if (enchantment == null) return;
if (unsafe){
i.addUnsafeEnchantment(enchantment, level);
return;
}
if (level > enchantment.getMaxLevel()) return;
i.addEnchantment(enchantment, level);
}
}
示例3: onPlayerGlide
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@EventHandler
public void onPlayerGlide(EntityToggleGlideEvent event)
{
if (!(event.getEntity() instanceof Player))
return;
if (!SamaGamesAPI.get().getPermissionsManager().hasPermission(event.getEntity(), "network.vipplus"))
if (((Player) event.getEntity()).isFlying() && ((Player) event.getEntity()).getInventory().getChestplate().getType() == Material.ELYTRA)
((Player) event.getEntity()).getInventory().setChestplate(null);
if (event.isGliding() && RestrictedVersion.isLoggedInPost19((Player) event.getEntity()))
{
ItemStack stack = new ItemStack(Material.FEATHER);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "Ventilateur" + ChatColor.RESET + "" + ChatColor.GRAY + " (Clic-droit)");
stack.setItemMeta(meta);
stack.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
((Player) event.getEntity()).getInventory().setItem(3, stack);
}
else
{
((Player) event.getEntity()).getInventory().setItem(3, new ItemStack(Material.AIR));
}
}
示例4: build
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
/**
* Get the final {@link ItemStack} with all the attributes you have been adding
*
* @return the {@link ItemStack} of this {@link ItemBuilder}
*/
@Override
public ItemStack build() {
ItemStack s = new ItemStack(this.getMaterial());
s.setAmount(this.getAmount());
s.setDurability(this.getDamage());
LeatherArmorMeta m = (LeatherArmorMeta) s.getItemMeta();
for (ItemFlag iflag : this.getAllItemflags()) {
m.addItemFlags(iflag);
}
m.setDisplayName(this.getName());
m.setLore(this.getLore());
m.setColor(color);
s.setItemMeta(m);
for (Map.Entry<Enchantment, Integer> temp : this.getAllEnchantments().entrySet()) {
s.addUnsafeEnchantment(temp.getKey(), temp.getValue());
}
return s;
}
示例5: build
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
/**
* Get the final {@link ItemStack} with all the attributes you have been adding
*
* @return the {@link ItemStack} out of this {@link ItemBuilder}
*/
public ItemStack build() {
ItemStack s = new ItemStack(material);
s.setAmount(amount);
s.setDurability(damage);
ItemMeta m = s.getItemMeta();
for (ItemFlag iflag : itemflags)
m.addItemFlags(iflag);
m.setDisplayName(name);
m.setLore(lore);
s.setItemMeta(m);
for (Map.Entry<Enchantment, Integer> temp : enchantments.entrySet())
s.addUnsafeEnchantment(temp.getKey(), temp.getValue());
for (ItemData id : getAllData())
try {
id.applyOn(s);
} catch (WrongDataException e) {
e.printStackTrace();
}
return s;
}
示例6: onGameStart
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
/**
* Give a cheated fishing rod to all the players
*
* @param game Game
*/
@Override
public void onGameStart(SurvivalGame game)
{
ItemStack rod = new ItemStack(Material.FISHING_ROD);
rod.addUnsafeEnchantment(Enchantment.LUCK, 255);
rod.addUnsafeEnchantment(Enchantment.DURABILITY, 255);
ItemMeta meta = rod.getItemMeta();
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
rod.setItemMeta(meta);
for (GamePlayer player : (Collection<GamePlayer>) game.getInGamePlayers().values())
{
Player p = player.getPlayerIfOnline();
if (p != null)
p.getInventory().addItem(rod);
}
}
示例7: run
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public void run(PAUser user, String label, String[] args) {
if (args.length == 2) {
ItemStack i = user.getPlayer().getInventory().getItemInHand();
Enchantment enchantment;
int level;
if (!Utils.isInt(args[1])) return;
enchantment = getEnchantment(args[0]);
level = Integer.parseInt(args[1]);
if (enchantment == null) return;
i.addUnsafeEnchantment(enchantment, level);
}
}
示例8: load
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public void load() {
// Power Crystal
ItemStack pcrys = new ItemStack(Material.DIAMOND);
ItemMeta pcrysm = pcrys.getItemMeta();
pcrysm.setDisplayName("&b&lPower Crystal".replace('&', '�'));
ArrayList<String> pcrysl = new ArrayList<String>();
pcrysl.add("&b&l0 / 100,000 RF".replace('&', '�'));
pcrysm.setLore(pcrysl);
pcrys.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 100);
pcrys.setItemMeta(pcrysm);
CustomItem pc = new PowerCrystal(pcrys, "superiorcraft:power_crystal");
SuperiorCraft.plugin.getServer().getPluginManager().registerEvents(pc, SuperiorCraft.plugin);
// Uranium Ingot
ItemStack uing = new ItemStack(Material.EMERALD);
ItemMeta uingm = uing.getItemMeta();
uingm.setDisplayName("&2Uranium Ingot".replace('&', '�'));
ArrayList<String> uingl = new ArrayList<String>();
uingl.add("&2A radioactive material".replace('&', '�'));
uingm.setLore(uingl);
uing.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 100);
uing.setItemMeta(uingm);
CustomItem ui = new UraniumIngot(uing, "more:uranium_ingot");
SuperiorCraft.plugin.getServer().getPluginManager().registerEvents(ui, SuperiorCraft.plugin);
}
示例9: create
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public static ItemStack create(Material m, String name, Enchantment ench, int level, String... lore) {
ItemStack i = new ItemStack(m);
ItemMeta im = i.getItemMeta();
im.setDisplayName(name);
im.setLore(Arrays.asList(lore));
i.setItemMeta(im);
i.addUnsafeEnchantment(ench, level);
return i;
}
示例10: addGlow
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public static ItemStack addGlow(ItemStack item) {
item.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
ItemMeta meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
return item;
}
示例11: onGameStart
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
/**
* Give an unbreakable flint and steel to all the players
*
* @param game Game
*/
@Override
public void onGameStart(SurvivalGame game)
{
ItemStack flintAndSteel = new ItemStack(Material.FLINT_AND_STEEL, 1);
flintAndSteel.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
for (GamePlayer player : (Collection<GamePlayer>) game.getInGamePlayers().values())
{
Player p = player.getPlayerIfOnline();
if (p != null)
p.getInventory().addItem(flintAndSteel);
}
}
示例12: onGameStart
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
/**
* Give a Thorns 3 gold chestplate to all the players
*
* @param game Game
*/
@Override
public void onGameStart(SurvivalGame game)
{
ItemStack chestplate = new ItemStack(Material.GOLD_CHESTPLATE, 1);
chestplate.addUnsafeEnchantment(Enchantment.THORNS, 3);
for (GamePlayer player : (Collection<GamePlayer>) game.getInGamePlayers().values())
{
Player p = player.getPlayerIfOnline();
if (p != null)
p.getInventory().setChestplate(chestplate);
}
}
示例13: setToItemStack
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Override
public void setToItemStack(ItemStack stack) {
for(Enchants a : myEnchant){
Enchantment enchantData = Enchantment.getById(a.id);
if(enchantData != null)
stack.addUnsafeEnchantment(enchantData,a.level);
}
}
示例14: initialize
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Override
public void initialize() {
ItemStack aboutItem = new ItemStack(Material.SNOW_BALL);
aboutItem.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
list.add(new MenuItem(5, 0, new ItemStack(Material.BOOK), ChatColor.AQUA + "Chat Hovers", new String[] {
ChatColor.GRAY + "Hover over people's names in chat to see more info about them.",
ChatColor.GRAY + "Click on player's names for information on their equipment and more!"
}, null));
list.add(new MenuItem(5, 2, new ItemStack(Material.BOOK), ChatColor.AQUA + "Item Rarities", new String[] {
ChatColor.GRAY + "The following is the order of Item Rarities in Zentrela (from most common to most rare).",
"",
ItemBalance.getRarityColor(0) + "Common",
ItemBalance.getRarityColor(1) + ItemBalance.getRarityName(1),
ItemBalance.getRarityColor(2) + ItemBalance.getRarityName(2),
ItemBalance.getRarityColor(3) + ItemBalance.getRarityName(3),
ItemBalance.getRarityColor(4) + ItemBalance.getRarityName(4),
ItemBalance.getRarityColor(5) + ItemBalance.getRarityName(5),
ItemBalance.getRarityColor(6) + ItemBalance.getRarityName(6),
}, null));
list.add(new MenuItem(5, 4, new ItemStack(Material.BOOK), ChatColor.AQUA + "Equipment Tiers", new String[] {
ChatColor.GRAY + "There are 5 tiers of equipment. Stronger monsters can drop higher tiered equipment.",
"",
ChatColor.GRAY + "Tier 1 - Recruit",
ChatColor.WHITE + "Tier 2 - Novice",
ChatColor.GREEN + "Tier 3 - Apprentice",
ChatColor.GOLD + "Tier 4 - Veteran",
ChatColor.AQUA + "Tier 5 - Expert"
}, null));
list.add(new MenuItem(5, 6, new ItemStack(Material.BOOK), ChatColor.AQUA + "Spellcasting", new String[] {
ChatColor.GRAY + "Spellcasting is a super important part of enjoying Zentrela, so we talk about it a lot!",
"",
ChatColor.GRAY + "There are 4 \"spellcasts\" which are used to actually cast your spells. These are RLL, RLR, RRL, and RRR.",
"",
ChatColor.WHITE + "To use a spellcast, just hold a weapon and click Right and Left on your mouse.",
"",
ChatColor.GRAY + "If you need more help, just type " + ChatColor.YELLOW + "!spells " + ChatColor.GRAY + "in chat for a useful video tutorial!",
}, null));
list.add(new MenuItem(5, 8, new ItemStack(Material.BOOK), ChatColor.AQUA + "Particles", new String[] {
ChatColor.GRAY + "Many spells and effects in Zentrela depend on particles.",
"",
ChatColor.GRAY + "Please turn on particles so that you can see spells from players and mobs! It's hard to fight things that are invisible."
}, null));
list.add(new MenuItem(0, 4, aboutItem, ChatColor.AQUA + "About Zentrela", new String[] {
ChatColor.GREEN + "Almost all of Zentrela's content is coded exclusively for the server! This means that we are always able to add and adjust features, since we write the code.",
"",
ChatColor.GRAY + "Check out our website at " + ChatColor.AQUA + "www.Zentrela.net" + ChatColor.GRAY + " to join the awesome community!",
"",
ChatColor.YELLOW + "The papers below have command details in ALPHABETICAL order for your convenience.",
}, null));
ItemStack orderItem = new ItemStack(Material.NETHER_STAR);
orderItem.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
list.add(new MenuItem(0, 8, orderItem, ChatColor.AQUA + "Menu Help", new String[] {
ChatColor.GREEN + "The commands shown here are ordered alphabetically for your convenience!",
"",
ChatColor.GRAY + "Be sure to check out the full list of commands at the top left.",
"",
ChatColor.YELLOW + "Have fun in Zentrela!",
}, null));
list.addAll(HelpCommandsSingleton.generated);
list.addAll(HelpCommandsSingleton.fullListGenerated);
}
示例15: read
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack read(JsonReader in) throws IOException {
Material material = null;
Integer amount = null;
Short dataValue = null;
String name = null;
List<String> lore = new ArrayList<>();
Map<Enchantment, Integer> enchantments = new HashMap<>();
if (in.peek() == JsonToken.NULL) {
in.skipValue();
return null;
}
in.beginObject();
while (in.hasNext())
switch (in.nextName()) {
case MATERIAL:
material = Material.getMaterial(in.nextString());
break;
case DATA_VALUE:
dataValue = (short) in.nextInt();
break;
case AMOUNT:
amount = in.nextInt();
break;
case LORE:
in.beginArray();
while (in.hasNext()) {
lore.add(in.nextString());
}
in.endArray();
break;
case NAME:
name = in.nextString();
break;
case ENCHANTS:
in.beginObject();
while (in.hasNext())
enchantments.put(Enchantment.getByName(in.nextName()), in.nextInt());
in.endObject();
break;
}
if (material == null)
throw new JsonParseException("An ItemStack must have a material field!");
ItemStack stack = new ItemStack(material);
if (amount != null) stack.setAmount(amount);
if (dataValue != null) stack.setDurability(dataValue);
if (name != null || !lore.isEmpty()) {
ItemMeta itemMeta = stack.getItemMeta();
if (name != null) itemMeta.setDisplayName(name);
if (!lore.isEmpty()) itemMeta.setLore(lore);
stack.setItemMeta(itemMeta);
}
if (!enchantments.isEmpty())
for (Map.Entry<Enchantment, Integer> enchantmentIntegerEntry : enchantments.entrySet()) {
stack.addUnsafeEnchantment(enchantmentIntegerEntry.getKey(), enchantmentIntegerEntry.getValue());
}
in.endObject();
return stack;
}