Вопрос Как сделать поддержку эффекты на стрелы и зелья

rezetkakiller

Заблокирован
Сообщения
11
всем привет, хотел бы сделать чтобы была поддержка стрел с эффектами и зелья с эффектами, но не понимаю как сделать. вот пример:
package ru.merkii.mbox.model;

import ru.merkii.mbox.util.RandomUtil;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import java.util.Iterator;
import org.bukkit.enchantments.Enchantment;
import java.util.Map;
import java.util.ArrayList;
import ru.den_abr.commonlib.utility.ItemLore;
import org.bukkit.inventory.ItemStack;
import java.util.List;

public class LootInfo
{
private String id;
private String displayName;
private List<String> lore;
private int amount;
private List<String> enchantments;
private double chance;

public LootInfo(final ItemStack is) {
this.chance = 100.0;
this.id = ItemLore.getId(is);
if (is.getItemMeta().hasDisplayName()) {
this.displayName = is.getItemMeta().getDisplayName();
}
if (is.getItemMeta().hasLore()) {
this.lore = (List<String>)is.getItemMeta().getLore();
}
this.amount = is.getAmount();
this.enchantments = new ArrayList<String>();
for (final Map.Entry<Enchantment, Integer> ench : is.getEnchantments().entrySet()) {
this.enchantments.add(String.valueOf(String.valueOf(ench.getKey().getName())) + ":" + ench.getValue());
}
}

public ItemStack toItem(final int amount) {
final String[] item = this.id.split(":");
final Material mat = Material.matchMaterial(item[0]);
ItemStack is;
if (item.length == 2) {
if (mat != Material.POTION || mat != Material.TIPPED_ARROW) {
is = new ItemStack(mat, amount);
}
else {
is = new ItemStack(mat, amount, (short)Integer.parseInt(item[1]));
}
}
else {
is = new ItemStack(mat, amount);
}
final ItemMeta im = is.getItemMeta();
if (this.displayName != null) {
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', this.displayName));
}
if (this.lore != null) {
im.setLore((List)this.lore);
}
is.setItemMeta(im);
for (final String ench : this.enchantments) {
final String[] spl = ench.split(":");
final Enchantment enchant = Enchantment.getByName(spl[0].toUpperCase());
is.addUnsafeEnchantment(enchant, Integer.parseInt(spl[1]));
}
return is;
}

public void setAmount(final int amount) {
this.amount = amount;
}

public void setLore(final List<String> lore) {
this.lore = lore;
}

public void setDisplayName(final String displayName) {
this.displayName = displayName;
}

public void setId(final String id) {
this.id = id;
}

public void setEnchantments(final List<String> enchantments) {
this.enchantments = enchantments;
}

public List<String> getEnchantments() {
return this.enchantments;
}

public int getAmount() {
return this.amount;
}

public String getDisplayName() {
return this.displayName;
}

public String getId() {
return this.id;
}

public List<String> getLore() {
return this.lore;
}

public ItemStack toItem() {
return this.toItem(this.amount);
}

public double getChance() {
return this.chance;
}

public boolean passChance() {
final RandomUtil r = new RandomUtil();
r.addNumber(1337, this.chance);
r.addNumber(322, 100.0 - this.chance);
return r.getRandomNumber() == 1337;
}
}
Объединено

UP
 
Последнее редактирование:
Назад
Сверху Снизу