mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
1.0
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
package net.momirealms.customfishing;
|
package net.momirealms.customfishing;
|
||||||
|
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
import net.momirealms.customfishing.requirements.*;
|
import net.momirealms.customfishing.requirements.*;
|
||||||
import net.momirealms.customfishing.utils.*;
|
import net.momirealms.customfishing.utils.*;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -74,7 +77,7 @@ public class ConfigReader{
|
|||||||
AdventureManager.consoleMessage("<red>[CustomFishing] 未检测到插件 MythicMobs!</red>");
|
AdventureManager.consoleMessage("<red>[CustomFishing] 未检测到插件 MythicMobs!</red>");
|
||||||
mm = false;
|
mm = false;
|
||||||
}else {
|
}else {
|
||||||
AdventureManager.consoleMessage("<gradient:#0070B3:#A0EACF>[CustomFishing] <color:#E1FFFF>检测到 <color:#00BFFF>MythicMobs <color:#E1FFFF>已启用怪物拓展!");
|
AdventureManager.consoleMessage("<gradient:#0070B3:#A0EACF>[CustomFishing] </gradient><color:#E1FFFF>检测到 <color:#00BFFF>MythicMobs <color:#E1FFFF>已启用怪物拓展!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
papi = config.getBoolean("config.integrations.PlaceholderAPI");
|
papi = config.getBoolean("config.integrations.PlaceholderAPI");
|
||||||
@@ -238,10 +241,6 @@ public class ConfigReader{
|
|||||||
int weight;
|
int weight;
|
||||||
if (config.contains("items." + key + ".weight")) {
|
if (config.contains("items." + key + ".weight")) {
|
||||||
weight = config.getInt("items." + key + ".weight");
|
weight = config.getInt("items." + key + ".weight");
|
||||||
if (weight <= 0){
|
|
||||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! " + key + " 的捕获权重必须为正整数!</red>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的捕获权重!</red>");
|
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的捕获权重!</red>");
|
||||||
return;
|
return;
|
||||||
@@ -275,7 +274,22 @@ public class ConfigReader{
|
|||||||
*/
|
*/
|
||||||
if (config.contains("items." + key + ".display.lore"))
|
if (config.contains("items." + key + ".display.lore"))
|
||||||
loot.setLore(config.getStringList("items." + key + ".display.lore"));
|
loot.setLore(config.getStringList("items." + key + ".display.lore"));
|
||||||
|
if (config.contains("items." + key + ".enchantments")) {
|
||||||
|
ArrayList<Enchantment> arrayList = new ArrayList<>();
|
||||||
|
config.getStringList("items." + key + ".enchantments").forEach(enchant -> {
|
||||||
|
String[] split = StringUtils.split(enchant, "/");
|
||||||
|
NamespacedKey namespacedKey = NamespacedKey.fromString(split[0]);
|
||||||
|
arrayList.add(new Enchantment(namespacedKey, Integer.parseInt(split[1])));
|
||||||
|
});
|
||||||
|
loot.setEnchantment(arrayList);
|
||||||
|
}
|
||||||
|
if (config.contains("items." + key + ".item_flags")) {
|
||||||
|
ArrayList<ItemFlag> arrayList = new ArrayList<>();
|
||||||
|
config.getStringList("items." + key + ".item_flags").forEach(flag -> {
|
||||||
|
arrayList.add(ItemFlag.valueOf(flag));
|
||||||
|
});
|
||||||
|
loot.setItemFlags(arrayList);
|
||||||
|
}
|
||||||
if (config.contains("items." + key + ".nbt"))
|
if (config.contains("items." + key + ".nbt"))
|
||||||
loot.setNbt(config.getMapList("items." + key + ".nbt").get(0));
|
loot.setNbt(config.getMapList("items." + key + ".nbt").get(0));
|
||||||
|
|
||||||
@@ -363,10 +377,6 @@ public class ConfigReader{
|
|||||||
int weight;
|
int weight;
|
||||||
if (config.contains("mobs." + key + ".weight")) {
|
if (config.contains("mobs." + key + ".weight")) {
|
||||||
weight = config.getInt("mobs." + key + ".weight");
|
weight = config.getInt("mobs." + key + ".weight");
|
||||||
if (weight <= 0){
|
|
||||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! " + key + " 的捕获权重必须为正整数!</red>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的捕获权重!</red>");
|
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的捕获权重!</red>");
|
||||||
return;
|
return;
|
||||||
@@ -496,7 +506,22 @@ public class ConfigReader{
|
|||||||
utilInstance.setLore(config.getStringList("utils." + key + ".display.lore"));
|
utilInstance.setLore(config.getStringList("utils." + key + ".display.lore"));
|
||||||
if (config.contains("utils." + key + ".nbt"))
|
if (config.contains("utils." + key + ".nbt"))
|
||||||
utilInstance.setNbt(config.getMapList("utils." + key + ".nbt").get(0));
|
utilInstance.setNbt(config.getMapList("utils." + key + ".nbt").get(0));
|
||||||
|
if (config.contains("utils." + key + ".enchantments")) {
|
||||||
|
ArrayList<Enchantment> arrayList = new ArrayList<>();
|
||||||
|
config.getStringList("utils." + key + ".enchantments").forEach(enchant -> {
|
||||||
|
String[] split = StringUtils.split(enchant, "/");
|
||||||
|
NamespacedKey namespacedKey = NamespacedKey.fromString(split[0]);
|
||||||
|
arrayList.add(new Enchantment(namespacedKey, Integer.parseInt(split[1])));
|
||||||
|
});
|
||||||
|
utilInstance.setEnchantment(arrayList);
|
||||||
|
}
|
||||||
|
if (config.contains("utils." + key + ".item_flags")) {
|
||||||
|
ArrayList<ItemFlag> arrayList = new ArrayList<>();
|
||||||
|
config.getStringList("utils." + key + ".item_flags").forEach(flag -> {
|
||||||
|
arrayList.add(ItemFlag.valueOf(flag));
|
||||||
|
});
|
||||||
|
utilInstance.setItemFlags(arrayList);
|
||||||
|
}
|
||||||
UTIL.put(key, utilInstance);
|
UTIL.put(key, utilInstance);
|
||||||
utilInstance.addUtil2cache(key);
|
utilInstance.addUtil2cache(key);
|
||||||
});
|
});
|
||||||
@@ -533,6 +558,22 @@ public class ConfigReader{
|
|||||||
if (config.contains("rods." + key + ".nbt")) {
|
if (config.contains("rods." + key + ".nbt")) {
|
||||||
rodInstance.setNbt(config.getMapList("rods." + key + ".nbt").get(0));
|
rodInstance.setNbt(config.getMapList("rods." + key + ".nbt").get(0));
|
||||||
}
|
}
|
||||||
|
if (config.contains("rods." + key + ".enchantments")) {
|
||||||
|
ArrayList<Enchantment> arrayList = new ArrayList<>();
|
||||||
|
config.getStringList("rods." + key + ".enchantments").forEach(enchant -> {
|
||||||
|
String[] split = StringUtils.split(enchant, "/");
|
||||||
|
NamespacedKey namespacedKey = NamespacedKey.fromString(split[0]);
|
||||||
|
arrayList.add(new Enchantment(namespacedKey, Integer.parseInt(split[1])));
|
||||||
|
});
|
||||||
|
rodInstance.setEnchantment(arrayList);
|
||||||
|
}
|
||||||
|
if (config.contains("rods." + key + ".item_flags")) {
|
||||||
|
ArrayList<ItemFlag> arrayList = new ArrayList<>();
|
||||||
|
config.getStringList("rods." + key + ".item_flags").forEach(flag -> {
|
||||||
|
arrayList.add(ItemFlag.valueOf(flag));
|
||||||
|
});
|
||||||
|
rodInstance.setItemFlags(arrayList);
|
||||||
|
}
|
||||||
if (config.contains("rods." + key + ".modifier")){
|
if (config.contains("rods." + key + ".modifier")){
|
||||||
config.getConfigurationSection("rods." + key + ".modifier").getKeys(false).forEach(modifier -> {
|
config.getConfigurationSection("rods." + key + ".modifier").getKeys(false).forEach(modifier -> {
|
||||||
switch (modifier){
|
switch (modifier){
|
||||||
@@ -597,6 +638,22 @@ public class ConfigReader{
|
|||||||
if (config.contains("baits." + key + ".nbt")) {
|
if (config.contains("baits." + key + ".nbt")) {
|
||||||
baitInstance.setNbt(config.getMapList("baits." + key + ".nbt").get(0));
|
baitInstance.setNbt(config.getMapList("baits." + key + ".nbt").get(0));
|
||||||
}
|
}
|
||||||
|
if (config.contains("baits." + key + ".enchantments")) {
|
||||||
|
ArrayList<Enchantment> arrayList = new ArrayList<>();
|
||||||
|
config.getStringList("baits." + key + ".enchantments").forEach(enchant -> {
|
||||||
|
String[] split = StringUtils.split(enchant, "/");
|
||||||
|
NamespacedKey namespacedKey = NamespacedKey.fromString(split[0]);
|
||||||
|
arrayList.add(new Enchantment(namespacedKey, Integer.parseInt(split[1])));
|
||||||
|
});
|
||||||
|
baitInstance.setEnchantment(arrayList);
|
||||||
|
}
|
||||||
|
if (config.contains("baits." + key + ".item_flags")) {
|
||||||
|
ArrayList<ItemFlag> arrayList = new ArrayList<>();
|
||||||
|
config.getStringList("baits." + key + ".item_flags").forEach(flag -> {
|
||||||
|
arrayList.add(ItemFlag.valueOf(flag));
|
||||||
|
});
|
||||||
|
baitInstance.setItemFlags(arrayList);
|
||||||
|
}
|
||||||
if (config.contains("baits." + key + ".modifier")){
|
if (config.contains("baits." + key + ".modifier")){
|
||||||
config.getConfigurationSection("baits." + key + ".modifier").getKeys(false).forEach(modifier -> {
|
config.getConfigurationSection("baits." + key + ".modifier").getKeys(false).forEach(modifier -> {
|
||||||
switch (modifier){
|
switch (modifier){
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
|||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.momirealms.customfishing.ConfigReader;
|
import net.momirealms.customfishing.ConfigReader;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -24,6 +27,8 @@ public class BaitInstance {
|
|||||||
private double doubleLoot;
|
private double doubleLoot;
|
||||||
private int difficulty;
|
private int difficulty;
|
||||||
private final String material;
|
private final String material;
|
||||||
|
private List<net.momirealms.customfishing.utils.Enchantment> enchantment;
|
||||||
|
private List<ItemFlag> itemFlags;
|
||||||
|
|
||||||
public BaitInstance(String name, String material) {
|
public BaitInstance(String name, String material) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -31,7 +36,18 @@ public class BaitInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addBait2Cache(String baitKey){
|
public void addBait2Cache(String baitKey){
|
||||||
NBTItem nbtItem = new NBTItem(new ItemStack(Material.valueOf(this.material.toUpperCase())));
|
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");
|
NBTCompound display = nbtItem.addCompound("display");
|
||||||
display.setString("Name", GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + this.name)));
|
display.setString("Name", GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + this.name)));
|
||||||
if(this.lore != null){
|
if(this.lore != null){
|
||||||
@@ -55,6 +71,9 @@ public class BaitInstance {
|
|||||||
player.getInventory().addItem(itemStack);
|
player.getInventory().addItem(itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setItemFlags(List<ItemFlag> itemFlags) {
|
||||||
|
this.itemFlags = itemFlags;
|
||||||
|
}
|
||||||
public void setDifficulty(int difficulty) {
|
public void setDifficulty(int difficulty) {
|
||||||
this.difficulty = difficulty;
|
this.difficulty = difficulty;
|
||||||
}
|
}
|
||||||
@@ -79,6 +98,10 @@ public class BaitInstance {
|
|||||||
return this.doubleLoot;
|
return this.doubleLoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEnchantment(List<net.momirealms.customfishing.utils.Enchantment> enchantment) {
|
||||||
|
this.enchantment = enchantment;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<?, ?> getNbt() {
|
public Map<?, ?> getNbt() {
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.momirealms.customfishing.utils;
|
||||||
|
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
|
||||||
|
public record Enchantment(NamespacedKey key, int level) {
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,13 +2,17 @@ package net.momirealms.customfishing.utils;
|
|||||||
|
|
||||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.momirealms.customfishing.ConfigReader;
|
import net.momirealms.customfishing.ConfigReader;
|
||||||
import net.momirealms.customfishing.requirements.Requirement;
|
import net.momirealms.customfishing.requirements.Requirement;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -32,6 +36,8 @@ public class LootInstance {
|
|||||||
private int exp;
|
private int exp;
|
||||||
private List<String> commands;
|
private List<String> commands;
|
||||||
private String group;
|
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){
|
public LootInstance(String key, String name, Difficulty difficulty, int weight, int time){
|
||||||
this.key = key;
|
this.key = key;
|
||||||
@@ -95,11 +101,28 @@ public class LootInstance {
|
|||||||
this.group = group;
|
this.group = group;
|
||||||
}
|
}
|
||||||
public void setExp(int exp) {this.exp = exp;}
|
public void setExp(int exp) {this.exp = exp;}
|
||||||
/*
|
|
||||||
将实例转换为缓存中的NBT物品
|
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){
|
public void addLoot2cache(String lootKey){
|
||||||
ItemStack itemStack = new ItemStack(Material.valueOf(this.material.toUpperCase()));
|
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);
|
NBTItem nbtItem = new NBTItem(itemStack);
|
||||||
//设置Name和Lore
|
//设置Name和Lore
|
||||||
NBTCompound display = nbtItem.addCompound("display");
|
NBTCompound display = nbtItem.addCompound("display");
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
|||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.momirealms.customfishing.ConfigReader;
|
import net.momirealms.customfishing.ConfigReader;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -23,13 +26,27 @@ public class RodInstance {
|
|||||||
private double time;
|
private double time;
|
||||||
private int difficulty;
|
private int difficulty;
|
||||||
private double doubleLoot;
|
private double doubleLoot;
|
||||||
|
private List<net.momirealms.customfishing.utils.Enchantment> enchantment;
|
||||||
|
private List<ItemFlag> itemFlags;
|
||||||
|
|
||||||
public RodInstance(String name) {
|
public RodInstance(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRod2Cache(String rodKey){
|
public void addRod2Cache(String rodKey){
|
||||||
NBTItem nbtItem = new NBTItem(new ItemStack(Material.FISHING_ROD));
|
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");
|
NBTCompound display = nbtItem.addCompound("display");
|
||||||
display.setString("Name", GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + this.name)));
|
display.setString("Name", GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + this.name)));
|
||||||
if(this.lore != null){
|
if(this.lore != null){
|
||||||
@@ -69,6 +86,12 @@ public class RodInstance {
|
|||||||
this.lore = 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) {
|
public void setTime(double time) {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
|||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.momirealms.customfishing.ConfigReader;
|
import net.momirealms.customfishing.ConfigReader;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -19,6 +22,8 @@ public class UtilInstance {
|
|||||||
private List<String> lore;
|
private List<String> lore;
|
||||||
private Map<?, ?> nbt;
|
private Map<?, ?> nbt;
|
||||||
private final String material;
|
private final String material;
|
||||||
|
private List<net.momirealms.customfishing.utils.Enchantment> enchantment;
|
||||||
|
private List<ItemFlag> itemFlags;
|
||||||
|
|
||||||
public UtilInstance(String key, String name, String material){
|
public UtilInstance(String key, String name, String material){
|
||||||
this.key = key;
|
this.key = key;
|
||||||
@@ -48,12 +53,28 @@ public class UtilInstance {
|
|||||||
public void setNbt(Map<?, ?> nbt){
|
public void setNbt(Map<?, ?> nbt){
|
||||||
this.nbt = 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物品
|
将实例转换为缓存中的NBT物品
|
||||||
*/
|
*/
|
||||||
public void addUtil2cache(String utilKey){
|
public void addUtil2cache(String utilKey){
|
||||||
ItemStack itemStack = new ItemStack(Material.valueOf(this.material.toUpperCase()));
|
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);
|
NBTItem nbtItem = new NBTItem(itemStack);
|
||||||
NBTCompound display = nbtItem.addCompound("display");
|
NBTCompound display = nbtItem.addCompound("display");
|
||||||
display.setString("Name", GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + this.name)));
|
display.setString("Name", GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + this.name)));
|
||||||
|
|||||||
@@ -59,6 +59,20 @@ items:
|
|||||||
#若不设置则每次都随机
|
#若不设置则每次都随机
|
||||||
layout: bar1
|
layout: bar1
|
||||||
|
|
||||||
|
#附魔
|
||||||
|
enchantments:
|
||||||
|
- minecraft:sharpness/1
|
||||||
|
- minecraft:flames/1
|
||||||
|
|
||||||
|
item_flags:
|
||||||
|
- HIDE_ENCHANTS
|
||||||
|
# - HIDE_ATTRIBUTES
|
||||||
|
# - HIDE_DESTROYS
|
||||||
|
# - HIDE_DYE
|
||||||
|
# - HIDE_PLACED_ON
|
||||||
|
# - HIDE_UNBREAKABLE
|
||||||
|
# - HIDE_POTION_EFFECTS
|
||||||
|
|
||||||
# 玩家有多少时间捕鱼
|
# 玩家有多少时间捕鱼
|
||||||
# 超过指定时间鱼会跑(单位:毫秒)
|
# 超过指定时间鱼会跑(单位:毫秒)
|
||||||
time: 5000
|
time: 5000
|
||||||
|
|||||||
Reference in New Issue
Block a user