mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 10:35:18 +01:00
Fix enchant book loot
This commit is contained in:
parent
3dd3a31f25
commit
1455cf2d1c
@ -4,9 +4,11 @@ import com.google.gson.annotations.SerializedName;
|
|||||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||||
import com.songoda.core.utils.ItemUtils;
|
import com.songoda.core.utils.ItemUtils;
|
||||||
import com.songoda.core.utils.TextUtils;
|
import com.songoda.core.utils.TextUtils;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -149,6 +151,25 @@ public class Loot {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Create enchantment book
|
||||||
|
if (item.getType().equals(Material.ENCHANTED_BOOK)) {
|
||||||
|
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
|
||||||
|
for (Map.Entry<String, Integer> entry : this.enchants.entrySet()) {
|
||||||
|
if (entry.getValue() == null) continue;
|
||||||
|
|
||||||
|
//TODO add random enchants
|
||||||
|
// if (entry.getKey().equalsIgnoreCase("RANDOM")) {
|
||||||
|
// item = ItemUtils.applyRandomEnchants(item, entry.getValue());
|
||||||
|
//
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
meta.addStoredEnchant(Enchantment.getByName(entry.getKey()), entry.getValue(), true);
|
||||||
|
}
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
Map<Enchantment, Integer> enchants = new HashMap<>();
|
Map<Enchantment, Integer> enchants = new HashMap<>();
|
||||||
for (Map.Entry<String, Integer> entry : this.enchants.entrySet()) {
|
for (Map.Entry<String, Integer> entry : this.enchants.entrySet()) {
|
||||||
if (entry.getValue() == null) continue;
|
if (entry.getValue() == null) continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user