From d40806514b860239f1b90fb0f385b02949b842f4 Mon Sep 17 00:00:00 2001 From: Xiao-MoMi <70987828+Xiao-MoMi@users.noreply.github.com> Date: Wed, 3 Aug 2022 18:18:59 +0800 Subject: [PATCH] 1.0 --- .../customfishing/utils/BaitInstance.java | 124 ------------- .../customfishing/utils/Difficulty.java | 12 -- .../customfishing/utils/FishingPlayer.java | 14 -- .../customfishing/utils/LayoutUtil.java | 44 ----- .../customfishing/utils/LootInstance.java | 164 ------------------ .../customfishing/utils/RodInstance.java | 134 -------------- .../customfishing/utils/UtilInstance.java | 106 ----------- src/main/resources/messages.yml | 19 -- 8 files changed, 617 deletions(-) delete mode 100644 src/main/java/net/momirealms/customfishing/utils/BaitInstance.java delete mode 100644 src/main/java/net/momirealms/customfishing/utils/Difficulty.java delete mode 100644 src/main/java/net/momirealms/customfishing/utils/FishingPlayer.java delete mode 100644 src/main/java/net/momirealms/customfishing/utils/LayoutUtil.java delete mode 100644 src/main/java/net/momirealms/customfishing/utils/LootInstance.java delete mode 100644 src/main/java/net/momirealms/customfishing/utils/RodInstance.java delete mode 100644 src/main/java/net/momirealms/customfishing/utils/UtilInstance.java delete mode 100644 src/main/resources/messages.yml diff --git a/src/main/java/net/momirealms/customfishing/utils/BaitInstance.java b/src/main/java/net/momirealms/customfishing/utils/BaitInstance.java deleted file mode 100644 index b1d0eade..00000000 --- a/src/main/java/net/momirealms/customfishing/utils/BaitInstance.java +++ /dev/null @@ -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 lore; - private Map nbt; - private HashMap weightMQ; - private HashMap weightPM; - private double time; - private double doubleLoot; - private int difficulty; - private final String material; - private List enchantment; - private List 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("" + this.name))); - if(this.lore != null){ - List lores = display.getStringList("Lore"); - this.lore.forEach(lore -> lores.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("" + 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 itemFlags) { - this.itemFlags = itemFlags; - } - public void setDifficulty(int difficulty) { - this.difficulty = difficulty; - } - public void setNbt(Map nbt) { - this.nbt = nbt; - } - public void setLore(List lore) { - this.lore = lore; - } - public void setTime(double time) { - this.time = time; - } - public void setWeightMQ(HashMap weightMQ) { - this.weightMQ = weightMQ; - } - public void setWeightPM(HashMap weightPM) { - this.weightPM = weightPM; - } - public int getDifficulty() { return difficulty; } - - public double getDoubleLoot() { - return this.doubleLoot; - } - - public void setEnchantment(List enchantment) { - this.enchantment = enchantment; - } - - public Map getNbt() { - return nbt; - } - public List getLore() { - return lore; - } - public double getTime() { - return time; - } - public HashMap getWeightMQ() { - return weightMQ; - } - public HashMap getWeightPM() { - return weightPM; - } - - public void setDoubleLoot(double doubleLoot) { - this.doubleLoot = doubleLoot; - } -} diff --git a/src/main/java/net/momirealms/customfishing/utils/Difficulty.java b/src/main/java/net/momirealms/customfishing/utils/Difficulty.java deleted file mode 100644 index 3e82259a..00000000 --- a/src/main/java/net/momirealms/customfishing/utils/Difficulty.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/net/momirealms/customfishing/utils/FishingPlayer.java b/src/main/java/net/momirealms/customfishing/utils/FishingPlayer.java deleted file mode 100644 index 3d04b68a..00000000 --- a/src/main/java/net/momirealms/customfishing/utils/FishingPlayer.java +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/src/main/java/net/momirealms/customfishing/utils/LayoutUtil.java b/src/main/java/net/momirealms/customfishing/utils/LayoutUtil.java deleted file mode 100644 index 0b4ce83d..00000000 --- a/src/main/java/net/momirealms/customfishing/utils/LayoutUtil.java +++ /dev/null @@ -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;} -} diff --git a/src/main/java/net/momirealms/customfishing/utils/LootInstance.java b/src/main/java/net/momirealms/customfishing/utils/LootInstance.java deleted file mode 100644 index 65bb11b3..00000000 --- a/src/main/java/net/momirealms/customfishing/utils/LootInstance.java +++ /dev/null @@ -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 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 requirements; - private final int time; - private int mmLevel; - private int exp; - private List commands; - private String group; - private List enchantment; - private List 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 getLore(){ - return this.lore; - } - public List 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 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 lore){ - this.lore = lore; - } - public void setNbt(Map nbt){ - this.nbt = nbt; - } - public void setRequirements(List 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 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 itemFlags) { - this.itemFlags = itemFlags; - } - - public void setEnchantment(List 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("" + this.name))); - if(this.lore != null){ - List lores = display.getStringList("Lore"); - this.lore.forEach(lore -> lores.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("" + 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); - } -} diff --git a/src/main/java/net/momirealms/customfishing/utils/RodInstance.java b/src/main/java/net/momirealms/customfishing/utils/RodInstance.java deleted file mode 100644 index 71b3aad7..00000000 --- a/src/main/java/net/momirealms/customfishing/utils/RodInstance.java +++ /dev/null @@ -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 lore; - private Map nbt; - private HashMap weightMQ; - private HashMap weightPM; - private double time; - private int difficulty; - private double doubleLoot; - private List enchantment; - private List 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("" + this.name))); - if(this.lore != null){ - List lores = display.getStringList("Lore"); - this.lore.forEach(lore -> lores.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("" + 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 lore) { - this.lore = lore; - } - - public void setEnchantment(List enchantment) { - this.enchantment = enchantment; - } - public void setItemFlags(List itemFlags) { - this.itemFlags = itemFlags; - } - public void setTime(double time) { - this.time = time; - } - - public void setWeightMQ(HashMap weightMQ) { - this.weightMQ = weightMQ; - } - - public void setWeightPM(HashMap weightPM) { - this.weightPM = weightPM; - } - - public int getDifficulty() { - return difficulty; - } - - public double getDoubleLoot() { - return this.doubleLoot; - } - - public Map getNbt() { - return nbt; - } - - public List getLore() { - return lore; - } - - public double getTime() { - return time; - } - - public HashMap getWeightMQ() { - return weightMQ; - } - - public HashMap getWeightPM() { - return weightPM; - } -} diff --git a/src/main/java/net/momirealms/customfishing/utils/UtilInstance.java b/src/main/java/net/momirealms/customfishing/utils/UtilInstance.java deleted file mode 100644 index f4c440d9..00000000 --- a/src/main/java/net/momirealms/customfishing/utils/UtilInstance.java +++ /dev/null @@ -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 lore; - private Map nbt; - private final String material; - private List enchantment; - private List 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 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 lore){ - this.lore = lore; - } - public void setNbt(Map nbt){ - this.nbt = nbt; - } - public void setEnchantment(List enchantment) { - this.enchantment = enchantment; - } - public void setItemFlags(List 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("" + this.name))); - if (this.lore != null){ - List lores = display.getStringList("Lore"); - this.lore.forEach(lore -> lores.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(""+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); - } -} diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml deleted file mode 100644 index 62613b74..00000000 --- a/src/main/resources/messages.yml +++ /dev/null @@ -1,19 +0,0 @@ -#所有位置均可使用MiniMessage Format -#https://docs.adventure.kyori.net/minimessage/format.html -messages: - prefix: '[CustomFishing] ' - reload: '重载成功.' - no-perm: '你没有权限!' - not-online: '玩家不在线!' - not-exist: '此物品不存在!' - escape: '太久没拉钩鱼儿跑走啦!' - give-item: '成功给予玩家 {Player} {Amount}x {Item}.' - get-item: '成功获得 {Amount}x {Item}.' - no-console: '这个指令不能由控制台执行!' - wrong-amount: '不能给玩家数量为负数的物品!' - lack-args: '参数不足.' - cooldown: '你使用找鱼器的速度太快了!' - possible-loots: '此处可能钓到: ' - split-char: ',' - no-loot: '这个地方什么鱼都没有!' - not-open-water: '这里不是开放水域,你将无法获得任何奖励!' \ No newline at end of file