mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-29 03:49:07 +00:00
1.0
This commit is contained in:
@@ -1,124 +0,0 @@
|
||||
package net.momirealms.customfishing.utils;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customfishing.ConfigReader;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BaitInstance {
|
||||
|
||||
private final String name;
|
||||
private List<String> lore;
|
||||
private Map<?, ?> nbt;
|
||||
private HashMap<String, Double> weightMQ;
|
||||
private HashMap<String, Integer> weightPM;
|
||||
private double time;
|
||||
private double doubleLoot;
|
||||
private int difficulty;
|
||||
private final String material;
|
||||
private List<net.momirealms.customfishing.utils.Enchantment> enchantment;
|
||||
private List<ItemFlag> itemFlags;
|
||||
|
||||
public BaitInstance(String name, String material) {
|
||||
this.name = name;
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
public void addBait2Cache(String baitKey){
|
||||
ItemStack itemStack = new ItemStack(Material.valueOf(this.material.toUpperCase()));
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (enchantment != null){
|
||||
enchantment.forEach(enchantment1 -> {
|
||||
itemMeta.addEnchant(Enchantment.getByKey(enchantment1.getKey()),enchantment1.getLevel(),true);
|
||||
});
|
||||
}
|
||||
if (itemFlags != null){
|
||||
itemFlags.forEach(itemMeta::addItemFlags);
|
||||
}
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
NBTCompound display = nbtItem.addCompound("display");
|
||||
display.setString("Name", GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + this.name)));
|
||||
if(this.lore != null){
|
||||
List<String> lores = display.getStringList("Lore");
|
||||
this.lore.forEach(lore -> lores.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + lore))));
|
||||
}
|
||||
if (this.nbt != null){
|
||||
NBTUtil nbtUtil = new NBTUtil(this.nbt, nbtItem.getItem());
|
||||
nbtItem = nbtUtil.getNBTItem();
|
||||
}
|
||||
nbtItem.addCompound("CustomFishing");
|
||||
NBTCompound nbtCompound = nbtItem.getCompound("CustomFishing");
|
||||
nbtCompound.setString("type", "bait");
|
||||
nbtCompound.setString("id", baitKey);
|
||||
ConfigReader.BAITITEM.put(baitKey, nbtItem.getItem());
|
||||
}
|
||||
|
||||
public static void givePlayerBait(Player player, String baitKey, int amount){
|
||||
ItemStack itemStack = ConfigReader.BAITITEM.get(baitKey);
|
||||
itemStack.setAmount(amount);
|
||||
player.getInventory().addItem(itemStack);
|
||||
}
|
||||
|
||||
public void setItemFlags(List<ItemFlag> itemFlags) {
|
||||
this.itemFlags = itemFlags;
|
||||
}
|
||||
public void setDifficulty(int difficulty) {
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
public void setNbt(Map<?, ?> nbt) {
|
||||
this.nbt = nbt;
|
||||
}
|
||||
public void setLore(List<String> lore) {
|
||||
this.lore = lore;
|
||||
}
|
||||
public void setTime(double time) {
|
||||
this.time = time;
|
||||
}
|
||||
public void setWeightMQ(HashMap<String, Double> weightMQ) {
|
||||
this.weightMQ = weightMQ;
|
||||
}
|
||||
public void setWeightPM(HashMap<String, Integer> weightPM) {
|
||||
this.weightPM = weightPM;
|
||||
}
|
||||
public int getDifficulty() { return difficulty; }
|
||||
|
||||
public double getDoubleLoot() {
|
||||
return this.doubleLoot;
|
||||
}
|
||||
|
||||
public void setEnchantment(List<net.momirealms.customfishing.utils.Enchantment> enchantment) {
|
||||
this.enchantment = enchantment;
|
||||
}
|
||||
|
||||
public Map<?, ?> getNbt() {
|
||||
return nbt;
|
||||
}
|
||||
public List<String> getLore() {
|
||||
return lore;
|
||||
}
|
||||
public double getTime() {
|
||||
return time;
|
||||
}
|
||||
public HashMap<String, Double> getWeightMQ() {
|
||||
return weightMQ;
|
||||
}
|
||||
public HashMap<String, Integer> getWeightPM() {
|
||||
return weightPM;
|
||||
}
|
||||
|
||||
public void setDoubleLoot(double doubleLoot) {
|
||||
this.doubleLoot = doubleLoot;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package net.momirealms.customfishing.utils;
|
||||
|
||||
public record Difficulty(int timer, int speed) {
|
||||
|
||||
public int getTimer() {
|
||||
return this.timer;
|
||||
}
|
||||
|
||||
public int getSpeed() {
|
||||
return this.speed;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package net.momirealms.customfishing.utils;
|
||||
|
||||
import net.momirealms.customfishing.timer.Timer;
|
||||
|
||||
public record FishingPlayer(Long fishingTime, Timer timer) {
|
||||
|
||||
public Long getFishingTime() {
|
||||
return this.fishingTime;
|
||||
}
|
||||
|
||||
public Timer getTimer() {
|
||||
return this.timer;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package net.momirealms.customfishing.utils;
|
||||
|
||||
public class LayoutUtil {
|
||||
|
||||
private final String key;
|
||||
private final int range;
|
||||
private final double[] successRate;
|
||||
private final int size;
|
||||
|
||||
private String start;
|
||||
private String bar;
|
||||
private String pointer;
|
||||
private String offset;
|
||||
private String end;
|
||||
private String pointerOffset;
|
||||
private String title;
|
||||
|
||||
public LayoutUtil(String key, int range, double[] successRate, int size){
|
||||
this.key = key;
|
||||
this.range = range;
|
||||
this.successRate = successRate;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public void setBar(String bar) {this.bar = bar;}
|
||||
public void setEnd(String end) {this.end = end;}
|
||||
public void setOffset(String offset) {this.offset = offset;}
|
||||
public void setPointer(String pointer) {this.pointer = pointer;}
|
||||
public void setPointerOffset(String pointerOffset) {this.pointerOffset = pointerOffset;}
|
||||
public void setStart(String start) {this.start = start;}
|
||||
public void setTitle(String title) {this.title = title;}
|
||||
|
||||
public String getKey(){return this.key;}
|
||||
public int getRange(){return this.range;}
|
||||
public double[] getSuccessRate(){return this.successRate;}
|
||||
public int getSize(){return this.size;}
|
||||
public String getBar() {return bar;}
|
||||
public String getEnd() {return end;}
|
||||
public String getOffset() {return offset;}
|
||||
public String getPointer() {return pointer;}
|
||||
public String getPointerOffset() {return pointerOffset;}
|
||||
public String getStart() {return start;}
|
||||
public String getTitle() {return title;}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
package net.momirealms.customfishing.utils;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customfishing.ConfigReader;
|
||||
import net.momirealms.customfishing.requirements.Requirement;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class LootInstance {
|
||||
|
||||
private final String key;
|
||||
private final String name;
|
||||
private String nick;
|
||||
private List<String> lore;
|
||||
private Map<?, ?> nbt;
|
||||
private String material;
|
||||
private String msg;
|
||||
private String mm;
|
||||
private String layout;
|
||||
private VectorUtil vectorUtil;
|
||||
private final Difficulty difficulty;
|
||||
private final int weight;
|
||||
private List<Requirement> requirements;
|
||||
private final int time;
|
||||
private int mmLevel;
|
||||
private int exp;
|
||||
private List<String> commands;
|
||||
private String group;
|
||||
private List<net.momirealms.customfishing.utils.Enchantment> enchantment;
|
||||
private List<ItemFlag> itemFlags;
|
||||
|
||||
public LootInstance(String key, String name, Difficulty difficulty, int weight, int time){
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.difficulty = difficulty;
|
||||
this.weight = weight;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getKey(){
|
||||
return this.key;
|
||||
}
|
||||
public String getNick(){ return this.nick; }
|
||||
public String getMsg(){ return this.msg; }
|
||||
public String getLayout(){ return this.layout; }
|
||||
public String getMm(){ return this.mm; }
|
||||
public List<String> getLore(){
|
||||
return this.lore;
|
||||
}
|
||||
public List<String> getCommands(){return this.commands;}
|
||||
public Difficulty getDifficulty(){
|
||||
return this.difficulty;
|
||||
}
|
||||
public int getWeight(){
|
||||
return this.weight;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public String getMaterial(){
|
||||
return this.material;
|
||||
}
|
||||
public Map<?, ?> getNbt(){
|
||||
return this.nbt;
|
||||
}
|
||||
public List<Requirement> getRequirements() { return this.requirements; }
|
||||
public int getTime(){ return this.time; }
|
||||
public int getMmLevel(){ return this.mmLevel; }
|
||||
public VectorUtil getVectorUtil(){ return this.vectorUtil; }
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
public int getExp() {return exp;}
|
||||
|
||||
public void setLore(List<String> lore){
|
||||
this.lore = lore;
|
||||
}
|
||||
public void setNbt(Map<?, ?> nbt){
|
||||
this.nbt = nbt;
|
||||
}
|
||||
public void setRequirements(List<Requirement> requirements) { this.requirements = requirements; }
|
||||
public void setMaterial(String material){ this.material = material; }
|
||||
public void setNick(String nick){ this.nick = nick; }
|
||||
public void setMsg(String msg){ this.msg = msg; }
|
||||
public void setMm(String mm){ this.mm = mm; }
|
||||
public void setLayout(String layout){ this.layout = layout; }
|
||||
public void setVectorUtil(VectorUtil vectorUtil){ this.vectorUtil = vectorUtil; }
|
||||
public void setCommands(List<String> commands){ this.commands = commands; }
|
||||
public void setMmLevel(int mmLevel){ this.mmLevel = mmLevel; }
|
||||
public void setGroup(String group) {
|
||||
this.group = group;
|
||||
}
|
||||
public void setExp(int exp) {this.exp = exp;}
|
||||
|
||||
public void setItemFlags(List<ItemFlag> itemFlags) {
|
||||
this.itemFlags = itemFlags;
|
||||
}
|
||||
|
||||
public void setEnchantment(List<net.momirealms.customfishing.utils.Enchantment> enchantment) {
|
||||
this.enchantment = enchantment;
|
||||
}
|
||||
|
||||
public void addLoot2cache(String lootKey){
|
||||
ItemStack itemStack = new ItemStack(Material.valueOf(this.material.toUpperCase()));
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (enchantment != null){
|
||||
if (itemStack.getType() == Material.ENCHANTED_BOOK){
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta)itemMeta;
|
||||
enchantment.forEach(enchantment1 -> {
|
||||
meta.addStoredEnchant(Enchantment.getByKey(enchantment1.getKey()),enchantment1.getLevel(),true);
|
||||
});
|
||||
if (itemFlags != null){
|
||||
itemFlags.forEach(meta::addItemFlags);
|
||||
}
|
||||
itemStack.setItemMeta(meta);
|
||||
}else {
|
||||
enchantment.forEach(enchantment1 -> {
|
||||
itemMeta.addEnchant(Enchantment.getByKey(enchantment1.getKey()),enchantment1.getLevel(),true);
|
||||
});
|
||||
if (itemFlags != null){
|
||||
itemFlags.forEach(itemMeta::addItemFlags);
|
||||
}
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
//设置Name和Lore
|
||||
NBTCompound display = nbtItem.addCompound("display");
|
||||
display.setString("Name", GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + this.name)));
|
||||
if(this.lore != null){
|
||||
List<String> lores = display.getStringList("Lore");
|
||||
this.lore.forEach(lore -> lores.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + lore))));
|
||||
}
|
||||
//设置NBT
|
||||
//添加物品进入缓存
|
||||
if (this.nbt != null){
|
||||
NBTUtil nbtUtil = new NBTUtil(this.nbt, nbtItem.getItem());
|
||||
ConfigReader.LOOTITEM.put(lootKey, nbtUtil.getNBTItem().getItem());
|
||||
}else {
|
||||
ConfigReader.LOOTITEM.put(lootKey, nbtItem.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
给予玩家某NBT物品
|
||||
*/
|
||||
public static void givePlayerLoot(Player player, String lootKey, int amount){
|
||||
ItemStack itemStack = ConfigReader.LOOTITEM.get(lootKey);
|
||||
itemStack.setAmount(amount);
|
||||
player.getInventory().addItem(itemStack);
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
package net.momirealms.customfishing.utils;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customfishing.ConfigReader;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RodInstance {
|
||||
|
||||
private final String name;
|
||||
private List<String> lore;
|
||||
private Map<?, ?> nbt;
|
||||
private HashMap<String, Double> weightMQ;
|
||||
private HashMap<String, Integer> weightPM;
|
||||
private double time;
|
||||
private int difficulty;
|
||||
private double doubleLoot;
|
||||
private List<net.momirealms.customfishing.utils.Enchantment> enchantment;
|
||||
private List<ItemFlag> itemFlags;
|
||||
|
||||
public RodInstance(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void addRod2Cache(String rodKey){
|
||||
ItemStack itemStack = new ItemStack(Material.FISHING_ROD);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (enchantment != null){
|
||||
enchantment.forEach(enchantment1 -> {
|
||||
itemMeta.addEnchant(Enchantment.getByKey(enchantment1.getKey()),enchantment1.getLevel(),true);
|
||||
});
|
||||
}
|
||||
if (itemFlags != null){
|
||||
itemFlags.forEach(itemMeta::addItemFlags);
|
||||
}
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
|
||||
NBTCompound display = nbtItem.addCompound("display");
|
||||
display.setString("Name", GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + this.name)));
|
||||
if(this.lore != null){
|
||||
List<String> lores = display.getStringList("Lore");
|
||||
this.lore.forEach(lore -> lores.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + lore))));
|
||||
}
|
||||
if (this.nbt != null){
|
||||
NBTUtil nbtUtil = new NBTUtil(this.nbt, nbtItem.getItem());
|
||||
nbtItem = nbtUtil.getNBTItem();
|
||||
}
|
||||
nbtItem.addCompound("CustomFishing");
|
||||
NBTCompound nbtCompound = nbtItem.getCompound("CustomFishing");
|
||||
nbtCompound.setString("type", "rod");
|
||||
nbtCompound.setString("id", rodKey);
|
||||
ConfigReader.RODITEM.put(rodKey, nbtItem.getItem());
|
||||
}
|
||||
|
||||
public static void givePlayerRod(Player player, String rodKey, int amount){
|
||||
ItemStack itemStack = ConfigReader.RODITEM.get(rodKey);
|
||||
itemStack.setAmount(amount);
|
||||
player.getInventory().addItem(itemStack);
|
||||
}
|
||||
|
||||
public void setDifficulty(int difficulty) {
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
|
||||
public void setDoubleLoot(double doubleLoot) {
|
||||
this.doubleLoot = doubleLoot;
|
||||
}
|
||||
|
||||
public void setNbt(Map<?, ?> nbt) {
|
||||
this.nbt = nbt;
|
||||
}
|
||||
|
||||
public void setLore(List<String> lore) {
|
||||
this.lore = lore;
|
||||
}
|
||||
|
||||
public void setEnchantment(List<net.momirealms.customfishing.utils.Enchantment> enchantment) {
|
||||
this.enchantment = enchantment;
|
||||
}
|
||||
public void setItemFlags(List<ItemFlag> itemFlags) {
|
||||
this.itemFlags = itemFlags;
|
||||
}
|
||||
public void setTime(double time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void setWeightMQ(HashMap<String, Double> weightMQ) {
|
||||
this.weightMQ = weightMQ;
|
||||
}
|
||||
|
||||
public void setWeightPM(HashMap<String, Integer> weightPM) {
|
||||
this.weightPM = weightPM;
|
||||
}
|
||||
|
||||
public int getDifficulty() {
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
public double getDoubleLoot() {
|
||||
return this.doubleLoot;
|
||||
}
|
||||
|
||||
public Map<?, ?> getNbt() {
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public List<String> getLore() {
|
||||
return lore;
|
||||
}
|
||||
|
||||
public double getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public HashMap<String, Double> getWeightMQ() {
|
||||
return weightMQ;
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getWeightPM() {
|
||||
return weightPM;
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
package net.momirealms.customfishing.utils;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customfishing.ConfigReader;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class UtilInstance {
|
||||
|
||||
private final String key;
|
||||
private final String name;
|
||||
private List<String> lore;
|
||||
private Map<?, ?> nbt;
|
||||
private final String material;
|
||||
private List<net.momirealms.customfishing.utils.Enchantment> enchantment;
|
||||
private List<ItemFlag> itemFlags;
|
||||
|
||||
public UtilInstance(String key, String name, String material){
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
public String getKey(){
|
||||
return this.key;
|
||||
}
|
||||
public List<String> getLore(){
|
||||
return this.lore;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public String getMaterial(){
|
||||
return this.material;
|
||||
}
|
||||
public Map<?, ?> getNbt(){
|
||||
return this.nbt;
|
||||
}
|
||||
|
||||
public void setLore(List<String> lore){
|
||||
this.lore = lore;
|
||||
}
|
||||
public void setNbt(Map<?, ?> nbt){
|
||||
this.nbt = nbt;
|
||||
}
|
||||
public void setEnchantment(List<net.momirealms.customfishing.utils.Enchantment> enchantment) {
|
||||
this.enchantment = enchantment;
|
||||
}
|
||||
public void setItemFlags(List<ItemFlag> itemFlags) {
|
||||
this.itemFlags = itemFlags;
|
||||
}
|
||||
/*
|
||||
将实例转换为缓存中的NBT物品
|
||||
*/
|
||||
public void addUtil2cache(String utilKey){
|
||||
ItemStack itemStack = new ItemStack(Material.valueOf(this.material.toUpperCase()));
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (enchantment != null){
|
||||
enchantment.forEach(enchantment1 -> {
|
||||
itemMeta.addEnchant(Enchantment.getByKey(enchantment1.getKey()),enchantment1.getLevel(),true);
|
||||
});
|
||||
}
|
||||
if (itemFlags != null){
|
||||
itemFlags.forEach(itemMeta::addItemFlags);
|
||||
}
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
NBTCompound display = nbtItem.addCompound("display");
|
||||
display.setString("Name", GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + this.name)));
|
||||
if (this.lore != null){
|
||||
List<String> lores = display.getStringList("Lore");
|
||||
this.lore.forEach(lore -> lores.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>"+lore))));
|
||||
}
|
||||
if (this.nbt != null){
|
||||
NBTUtil nbtUtil = new NBTUtil(this.nbt, nbtItem.getItem());
|
||||
nbtItem = nbtUtil.getNBTItem();
|
||||
}
|
||||
if (utilKey.equals("fishfinder")){
|
||||
nbtItem.addCompound("CustomFishing");
|
||||
NBTCompound nbtCompound = nbtItem.getCompound("CustomFishing");
|
||||
nbtCompound.setString("type", "util");
|
||||
nbtCompound.setString("id", "fishfinder");
|
||||
}
|
||||
ConfigReader.UTILITEM.put(utilKey, nbtItem.getItem());
|
||||
}
|
||||
|
||||
/*
|
||||
给予玩家某NBT物品
|
||||
*/
|
||||
public static void givePlayerUtil(Player player, String utilKey, int amount){
|
||||
ItemStack itemStack = ConfigReader.UTILITEM.get(utilKey);
|
||||
itemStack.setAmount(amount);
|
||||
player.getInventory().addItem(itemStack);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user