diff --git a/src/main/java/net/momirealms/customfishing/ConfigReader.java b/src/main/java/net/momirealms/customfishing/ConfigReader.java index a34db8ad..f4851d44 100644 --- a/src/main/java/net/momirealms/customfishing/ConfigReader.java +++ b/src/main/java/net/momirealms/customfishing/ConfigReader.java @@ -56,6 +56,8 @@ public class ConfigReader{ public static HashMap BAIT = new HashMap<>(); public static HashMap BaitItem = new HashMap<>(); public static HashMap LAYOUT = new HashMap<>(); + public static HashMap OTHERS = new HashMap<>(); + public static HashMap> ENCHANTS = new HashMap<>(); public static HashMap CompetitionsT = new HashMap<>(); public static HashMap CompetitionsC = new HashMap<>(); public static boolean useRedis; @@ -77,6 +79,7 @@ public class ConfigReader{ loadUtil(); loadRod(); loadBait(); + loadEnchants(); loadCompetitions(); } @@ -290,6 +293,7 @@ public class ConfigReader{ LOOT.clear(); LootItem.clear(); + OTHERS.clear(); CustomPapi.allPapi.clear(); File loot_file = new File(CustomFishing.instance.getDataFolder() + File.separator + "loots"); @@ -437,6 +441,7 @@ public class ConfigReader{ AdventureUtil.consoleMessage("Unknown Item: " + key); return; } + OTHERS.put(key, material); LOOT.put(key, loot); } else { @@ -478,7 +483,7 @@ public class ConfigReader{ } }); } - AdventureUtil.consoleMessage("[CustomFishing] Loaded " + LootItem.size() + " loots"); + AdventureUtil.consoleMessage("[CustomFishing] Loaded " + LOOT.size() + " loots"); } if (Config.mm){ @@ -492,6 +497,9 @@ public class ConfigReader{ } File[] mobFiles = mob_file.listFiles(); if (mobFiles != null) { + + int size = LOOT.size(); + for (File file : mobFiles) { YamlConfiguration config = YamlConfiguration.loadConfiguration(file); Set mobs = config.getKeys(false); @@ -593,7 +601,7 @@ public class ConfigReader{ LOOT.put(key, loot); }); } - AdventureUtil.consoleMessage("[CustomFishing] Loaded " + (LOOT.size() - LootItem.size()) + " mobs"); + AdventureUtil.consoleMessage("[CustomFishing] Loaded " + (LOOT.size() - size) + " mobs"); } } } @@ -897,7 +905,7 @@ public class ConfigReader{ public static void loadBars(){ LAYOUT.clear(); YamlConfiguration config = ConfigReader.getConfig("bars.yml"); - Set keys = Objects.requireNonNull(config.getConfigurationSection("")).getKeys(false); + Set keys = config.getKeys(false); keys.forEach(key -> { int range = config.getInt(key + ".range"); Set rates = Objects.requireNonNull(config.getConfigurationSection(key + ".layout")).getKeys(false); @@ -916,4 +924,43 @@ public class ConfigReader{ LAYOUT.put(key, layout); }); } + + public static void loadEnchants(){ + + ENCHANTS.clear(); + + YamlConfiguration config = ConfigReader.getConfig("enchant-bonus.yml"); + Set keys = config.getKeys(false); + keys.forEach(key -> { + HashMap levelBonus = new HashMap<>(); + config.getConfigurationSection(key).getKeys(false).forEach(level -> { + Bonus bonus = new Bonus(); + config.getConfigurationSection(key + "." + level).getKeys(false).forEach(modifier -> { + switch (modifier) { + case "weight-PM" -> { + HashMap pm = new HashMap<>(); + config.getConfigurationSection(key + "." + level + ".weight-PM").getValues(false).forEach((group, value) -> { + pm.put(group, (Integer) value); + }); + bonus.setWeightPM(pm); + } + case "weight-MQ" -> { + HashMap mq = new HashMap<>(); + config.getConfigurationSection(key + "." + level + ".weight-MQ").getValues(false).forEach((group, value) -> { + mq.put(group, Double.valueOf(String.valueOf(value))); + }); + bonus.setWeightMQ(mq); + } + case "time" -> bonus.setTime(config.getDouble(key + "." + level + ".time")); + case "difficulty" -> bonus.setDifficulty(config.getInt(key + "." + level + ".difficulty")); + case "double-loot" -> bonus.setDoubleLoot(config.getDouble(key + "." + level + ".double-loot")); + case "score" -> bonus.setScore(config.getDouble(key + "." + level + ".score")); + } + }); + levelBonus.put(Integer.parseInt(level), bonus); + }); + ENCHANTS.put(key, levelBonus); + }); + AdventureUtil.consoleMessage("[CustomFishing] Loaded " + ENCHANTS.size() + " enchants bonus"); + } } \ No newline at end of file diff --git a/src/main/java/net/momirealms/customfishing/command/Execute.java b/src/main/java/net/momirealms/customfishing/command/Execute.java index e22bf789..4adc1897 100644 --- a/src/main/java/net/momirealms/customfishing/command/Execute.java +++ b/src/main/java/net/momirealms/customfishing/command/Execute.java @@ -9,8 +9,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import javax.print.DocFlavor; + public class Execute implements CommandExecutor { @Override @@ -86,21 +89,37 @@ public class Execute implements CommandExecutor { //检验参数长度 [0]items [1]loot [2]get [3]xxx [4](amount) if (sender instanceof Player player){ //是否存在于缓存中 - if (!ConfigReader.LootItem.containsKey(args[3])){ + if (ConfigReader.LootItem.containsKey(args[3])){ + if (args.length == 4){ + ItemUtil.givePlayerLoot(player, args[3], 1); + AdventureUtil.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.getItem.replace("{Amount}", "1").replace("{Item}",args[3])); + }else { + if (Integer.parseInt(args[4]) < 1){ + wrongAmount(sender); + return true; + } + ItemUtil.givePlayerLoot(player, args[3], Integer.parseInt(args[4])); + AdventureUtil.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.getItem.replace("{Amount}", args[4]).replace("{Item}",args[3])); + } + }else if (ConfigReader.OTHERS.containsKey(args[3])){ + if (args.length == 4){ + player.getInventory().addItem(ItemUtil.getItemStackFromOtherPlugins(args[3])); + AdventureUtil.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.getItem.replace("{Amount}", "1").replace("{Item}",args[3])); + }else { + if (Integer.parseInt(args[4]) < 1){ + wrongAmount(sender); + return true; + } + ItemStack itemStack = ItemUtil.getItemStackFromOtherPlugins(args[3]); + itemStack.setAmount(Integer.parseInt(args[4])); + player.getInventory().addItem(itemStack); + AdventureUtil.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.getItem.replace("{Amount}", args[4]).replace("{Item}",args[3])); + } + }else { noItem(sender); return true; } - if (args.length == 4){ - ItemUtil.givePlayerLoot(player, args[3], 1); - AdventureUtil.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.getItem.replace("{Amount}", "1").replace("{Item}",args[3])); - }else { - if (Integer.parseInt(args[4]) < 1){ - wrongAmount(sender); - return true; - } - ItemUtil.givePlayerLoot(player, args[3], Integer.parseInt(args[4])); - AdventureUtil.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.getItem.replace("{Amount}", args[4]).replace("{Item}",args[3])); - } + }else { AdventureUtil.consoleMessage(ConfigReader.Message.prefix + ConfigReader.Message.noConsole); } @@ -119,20 +138,39 @@ public class Execute implements CommandExecutor { return true; } //是否存在于缓存中 - if (!ConfigReader.LootItem.containsKey(args[4])){ - noItem(sender); - return true; - } - if (args.length == 5){ - ItemUtil.givePlayerLoot(player, args[4], 1); - giveItem(sender, args[3], args[4], 1); - }else { - if (Integer.parseInt(args[5]) < 1){ - wrongAmount(sender); + if (ConfigReader.LootItem.containsKey(args[4])){ + if (args.length == 5){ + ItemUtil.givePlayerLoot(player, args[4], 1); + giveItem(sender, args[3], args[4], 1); return true; } - ItemUtil.givePlayerLoot(player, args[4], Integer.parseInt(args[5])); - giveItem(sender, args[3], args[4], Integer.parseInt(args[5])); + else { + if (Integer.parseInt(args[5]) < 1){ + wrongAmount(sender); + return true; + } + ItemUtil.givePlayerLoot(player, args[4], Integer.parseInt(args[5])); + giveItem(sender, args[3], args[4], Integer.parseInt(args[5])); + } + }else if (ConfigReader.OTHERS.containsKey(args[4])){ + if (args.length == 5){ + player.getInventory().addItem(ItemUtil.getItemStackFromOtherPlugins(args[4])); + giveItem(sender, args[3], args[4], 1); + return true; + } + else { + if (Integer.parseInt(args[5]) < 1) { + wrongAmount(sender); + return true; + } + ItemStack itemStack = ItemUtil.getItemStackFromOtherPlugins(args[4]); + itemStack.setAmount(Integer.parseInt(args[5])); + player.getInventory().addItem(itemStack); + giveItem(sender, args[3], args[4], Integer.parseInt(args[5])); + } + }else { + noItem(sender); + return true; } return true; } diff --git a/src/main/java/net/momirealms/customfishing/command/TabComplete.java b/src/main/java/net/momirealms/customfishing/command/TabComplete.java index aa758723..cc5bd1eb 100644 --- a/src/main/java/net/momirealms/customfishing/command/TabComplete.java +++ b/src/main/java/net/momirealms/customfishing/command/TabComplete.java @@ -228,17 +228,24 @@ public class TabComplete implements TabCompleter { } private List loots(){ - return new ArrayList<>(ConfigReader.LootItem.keySet()); + ArrayList loots = new ArrayList<>(); + loots.addAll(ConfigReader.LootItem.keySet()); + loots.addAll(ConfigReader.OTHERS.keySet()); + return loots; } + private List utils(){ return new ArrayList<>(ConfigReader.UtilItem.keySet()); } + private List rods() { return new ArrayList<>(ConfigReader.RodItem.keySet()); } + private List baits() { return new ArrayList<>(ConfigReader.BaitItem.keySet()); } + private List competitions() { return new ArrayList<>(ConfigReader.CompetitionsC.keySet()); } diff --git a/src/main/java/net/momirealms/customfishing/listener/FishListener.java b/src/main/java/net/momirealms/customfishing/listener/FishListener.java index 75d6916d..1a37986e 100644 --- a/src/main/java/net/momirealms/customfishing/listener/FishListener.java +++ b/src/main/java/net/momirealms/customfishing/listener/FishListener.java @@ -88,17 +88,54 @@ public class FishListener implements Listener { PlayerInventory inventory = player.getInventory(); + boolean noSpecialRod = true; boolean noRod = true; double timeModifier = 1; double doubleLoot = 0; double scoreModifier = 1; int difficultyModifier = 0; - HashMap pm1 = new HashMap<>(); - HashMap mq1 = new HashMap<>(); + HashMap pm = new HashMap<>(); + HashMap mq = new HashMap<>(); ItemStack mainHandItem = inventory.getItemInMainHand(); - if (mainHandItem.getType() != Material.AIR){ + + Material material1 = mainHandItem.getType(); + if (material1 != Material.AIR){ + if (material1 == Material.FISHING_ROD) { + noRod = false; + Map enchantments = mainHandItem.getEnchantments(); + Object[] enchantmentsArray = enchantments.keySet().toArray(); + for (Object o : enchantmentsArray) { + Enchantment enchantment = (Enchantment) o; + HashMap enchantMap = ConfigReader.ENCHANTS.get(enchantment.getKey().toString()); + if (enchantMap != null) { + Bonus enchantBonus = enchantMap.get(enchantments.get(enchantment)); + if (enchantBonus != null) { + HashMap weightPM = enchantBonus.getWeightPM(); + if (weightPM != null){ + Object[] bonus = weightPM.keySet().toArray(); + for (Object value : bonus) { + String group = (String) value; + pm.put(group, Optional.ofNullable(pm.get(group)).orElse(0) + weightPM.get(group)); + } + } + HashMap weightMQ = enchantBonus.getWeightPM(); + if (weightMQ != null){ + Object[] bonus = weightMQ.keySet().toArray(); + for (Object value : bonus) { + String group = (String) value; + mq.put(group, Optional.ofNullable(mq.get(group)).orElse(0d) + weightMQ.get(group)); + } + } + if (enchantBonus.getTime() != 0) timeModifier *= enchantBonus.getTime(); + if (enchantBonus.getDoubleLoot() != 0) doubleLoot += enchantBonus.getDoubleLoot(); + if (enchantBonus.getDifficulty() != 0) difficultyModifier += enchantBonus.getDifficulty(); + if (enchantBonus.getScore() != 0) scoreModifier *= enchantBonus.getScore(); + } + } + } + } NBTItem nbtItem = new NBTItem(inventory.getItemInMainHand()); NBTCompound nbtCompound = nbtItem.getCompound("CustomFishing"); if (nbtCompound != null){ @@ -106,21 +143,49 @@ public class FishListener implements Listener { String key = nbtCompound.getString("id"); Bonus rod = ConfigReader.ROD.get(key); if (rod != null){ - pm1 = rod.getWeightPM(); - mq1 = rod.getWeightMQ(); + HashMap weightPM = rod.getWeightPM(); + if (weightPM != null){ + Object[] bonus = weightPM.keySet().toArray(); + for (Object value : bonus) { + String group = (String) value; + pm.put(group, Optional.ofNullable(pm.get(group)).orElse(0) + weightPM.get(group)); + } + } + HashMap weightMQ = rod.getWeightPM(); + if (weightMQ != null){ + Object[] bonus = weightMQ.keySet().toArray(); + for (Object value : bonus) { + String group = (String) value; + mq.put(group, Optional.ofNullable(mq.get(group)).orElse(0d) + weightMQ.get(group)); + } + } if (rod.getTime() != 0) timeModifier *= rod.getTime(); if (rod.getDoubleLoot() != 0) doubleLoot += rod.getDoubleLoot(); if (rod.getDifficulty() != 0) difficultyModifier += rod.getDifficulty(); if (rod.getScore() != 0) scoreModifier *= rod.getScore(); - noRod = false; + noSpecialRod = false; } } else if (nbtCompound.getString("type").equals("bait")){ String key = nbtCompound.getString("id"); Bonus bait = ConfigReader.BAIT.get(key); if (bait != null){ - pm1 = bait.getWeightPM(); - mq1 = bait.getWeightMQ(); + HashMap weightPM = bait.getWeightPM(); + if (weightPM != null){ + Object[] bonus = weightPM.keySet().toArray(); + for (Object value : bonus) { + String group = (String) value; + pm.put(group, Optional.ofNullable(pm.get(group)).orElse(0) + weightPM.get(group)); + } + } + HashMap weightMQ = bait.getWeightPM(); + if (weightMQ != null){ + Object[] bonus = weightMQ.keySet().toArray(); + for (Object value : bonus) { + String group = (String) value; + mq.put(group, Optional.ofNullable(mq.get(group)).orElse(0d) + weightMQ.get(group)); + } + } if (bait.getTime() != 0) timeModifier *= bait.getTime(); if (bait.getDoubleLoot() != 0) doubleLoot += bait.getDoubleLoot(); if (bait.getDifficulty() != 0) difficultyModifier += bait.getDifficulty(); @@ -131,11 +196,42 @@ public class FishListener implements Listener { } } - HashMap pm2 = new HashMap<>(); - HashMap mq2 = new HashMap<>(); - ItemStack offHandItem = inventory.getItemInOffHand(); - if (offHandItem.getType() != Material.AIR){ + Material material2 = offHandItem.getType(); + if (material2 != Material.AIR){ + if (noRod && material2 == Material.FISHING_ROD) { + Map enchantments = mainHandItem.getEnchantments(); + Object[] enchantmentsArray = enchantments.keySet().toArray(); + for (Object o : enchantmentsArray) { + Enchantment enchantment = (Enchantment) o; + HashMap enchantMap = ConfigReader.ENCHANTS.get(enchantment.getKey().toString()); + if (enchantMap != null) { + Bonus enchantBonus = enchantMap.get(enchantments.get(enchantment)); + if (enchantBonus != null) { + HashMap weightPM = enchantBonus.getWeightPM(); + if (weightPM != null){ + Object[] bonus = weightPM.keySet().toArray(); + for (Object value : bonus) { + String group = (String) value; + pm.put(group, Optional.ofNullable(pm.get(group)).orElse(0) + weightPM.get(group)); + } + } + HashMap weightMQ = enchantBonus.getWeightPM(); + if (weightMQ != null){ + Object[] bonus = weightMQ.keySet().toArray(); + for (Object value : bonus) { + String group = (String) value; + mq.put(group, Optional.ofNullable(mq.get(group)).orElse(0d) + weightMQ.get(group)); + } + } + if (enchantBonus.getTime() != 0) timeModifier *= enchantBonus.getTime(); + if (enchantBonus.getDoubleLoot() != 0) doubleLoot += enchantBonus.getDoubleLoot(); + if (enchantBonus.getDifficulty() != 0) difficultyModifier += enchantBonus.getDifficulty(); + if (enchantBonus.getScore() != 0) scoreModifier *= enchantBonus.getScore(); + } + } + } + } NBTItem offHand = new NBTItem(inventory.getItemInOffHand()); NBTCompound offHandCompound = offHand.getCompound("CustomFishing"); if (offHandCompound != null){ @@ -143,31 +239,60 @@ public class FishListener implements Listener { String key = offHandCompound.getString("id"); Bonus bait = ConfigReader.BAIT.get(key); if (bait != null){ - pm2 = bait.getWeightPM(); - mq2 = bait.getWeightMQ(); + HashMap weightPM = bait.getWeightPM(); + if (weightPM != null){ + Object[] bonus = weightPM.keySet().toArray(); + for (Object value : bonus) { + String group = (String) value; + pm.put(group, Optional.ofNullable(pm.get(group)).orElse(0) + weightPM.get(group)); + } + } + HashMap weightMQ = bait.getWeightPM(); + if (weightMQ != null){ + Object[] bonus = weightMQ.keySet().toArray(); + for (Object value : bonus) { + String group = (String) value; + mq.put(group, Optional.ofNullable(mq.get(group)).orElse(0d) + weightMQ.get(group)); + } + } if (bait.getTime() != 0) timeModifier *= bait.getTime(); if (bait.getDoubleLoot() != 0) doubleLoot += bait.getDoubleLoot(); if (bait.getDifficulty() != 0) difficultyModifier += bait.getDifficulty(); if (bait.getScore() != 0) scoreModifier *= bait.getScore(); offHandItem.setAmount(offHandItem.getAmount() - 1); } - }else if (noRod && offHandCompound.getString("type").equals("rod")){ + } + else if (noSpecialRod && offHandCompound.getString("type").equals("rod")){ String key = offHandCompound.getString("id"); Bonus rod = ConfigReader.ROD.get(key); if (rod != null){ - pm2 = rod.getWeightPM(); - mq2 = rod.getWeightMQ(); + HashMap weightPM = rod.getWeightPM(); + if (weightPM != null){ + Object[] bonus = weightPM.keySet().toArray(); + for (Object value : bonus) { + String group = (String) value; + pm.put(group, Optional.ofNullable(pm.get(group)).orElse(0) + weightPM.get(group)); + } + } + HashMap weightMQ = rod.getWeightPM(); + if (weightMQ != null){ + Object[] bonus = weightMQ.keySet().toArray(); + for (Object value : bonus) { + String group = (String) value; + mq.put(group, Optional.ofNullable(mq.get(group)).orElse(0d) + weightMQ.get(group)); + } + } if (rod.getTime() != 0) timeModifier *= rod.getTime(); if (rod.getDoubleLoot() != 0) doubleLoot += rod.getDoubleLoot(); if (rod.getDifficulty() != 0) difficultyModifier += rod.getDifficulty(); if (rod.getScore() != 0) scoreModifier *= rod.getScore(); - noRod = false; + noSpecialRod = false; } } } } - if (ConfigReader.Config.needSpecialRod && noRod){ + if (ConfigReader.Config.needSpecialRod && noSpecialRod){ if (!ConfigReader.Config.vanillaLoot) AdventureUtil.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.noRod); nextLoot.put(player, null); @@ -192,23 +317,18 @@ public class FishListener implements Listener { modifier.setWillDouble(doubleLoot > Math.random()); modifiers.put(player, modifier); + double[] weights = new double[possibleLoots.size()]; int index = 0; for (Loot loot : possibleLoots){ double weight = loot.getWeight(); String group = loot.getGroup(); if (group != null){ - if (pm1 != null && pm1.get(group) != null){ - weight += pm1.get(group); + if (pm.get(group) != null){ + weight += pm.get(group); } - if (pm2!= null && pm2.get(group) != null){ - weight += pm2.get(group); - } - if (mq1 != null && mq1.get(group) != null){ - weight *= mq1.get(group); - } - if (mq2 != null && mq2.get(group) != null){ - weight *= mq2.get(group); + if (mq.get(group) != null){ + weight *= mq.get(group); } } if (weight <= 0) continue; @@ -545,28 +665,16 @@ public class FishListener implements Listener { Entity item2 = location.getWorld().dropItem(location, itemStack); item2.setVelocity(vector); } - String[] titleSplit = StringUtils.split(ConfigReader.Title.success_title.get((int) (ConfigReader.Title.success_title.size()*Math.random())) - .replace("{player}", player.getName()), "{loot}"); - String[] subtitleSplit = StringUtils.split(ConfigReader.Title.success_title.get((int) (ConfigReader.Title.success_title.size()*Math.random())) - .replace("{player}", player.getName()), "{loot}"); - Component titleComponent; - Component subComponent; - if (titleSplit.length == 1){ - titleComponent = MiniMessage.miniMessage().deserialize(titleSplit[0]); - } - else { - titleComponent = MiniMessage.miniMessage().deserialize(titleSplit[0]).append(itemStack.displayName()).append(MiniMessage.miniMessage().deserialize(titleSplit[1])); - } - if (subtitleSplit.length == 1){ - subComponent = MiniMessage.miniMessage().deserialize(subtitleSplit[0]); - } - else { - subComponent = MiniMessage.miniMessage().deserialize(subtitleSplit[0]).append(itemStack.displayName()).append(MiniMessage.miniMessage().deserialize(subtitleSplit[1])); - } + + String title = ConfigReader.Title.success_title.get((int) (ConfigReader.Title.success_title.size()*Math.random())); + Component titleComponent = getTitleComponent(itemStack, title); + String subTitle = ConfigReader.Title.success_subtitle.get((int) (ConfigReader.Title.success_subtitle.size()*Math.random())); + Component subtitleComponent = getTitleComponent(itemStack, subTitle); + AdventureUtil.playerTitle( player, titleComponent, - subComponent, + subtitleComponent, ConfigReader.Title.success_in, ConfigReader.Title.success_stay, ConfigReader.Title.success_out @@ -660,10 +768,10 @@ public class FishListener implements Listener { private void dropLoot(Player player, Location location, DroppedItem droppedItem) { ItemStack itemStack; switch (droppedItem.getType()){ - case "ia" -> itemStack = ItemsAdderItem.getItemStack(droppedItem.getId()); - case "oraxen" -> itemStack = OraxenItem.getItemStack(droppedItem.getId()); - case "mm" -> itemStack = MythicItems.getItemStack(droppedItem.getId()); - case "mmoitems" -> itemStack = MMOItemsHook.getItemStack(droppedItem.getId()); + case "ia" -> itemStack = ItemsAdderItem.getItemStack(droppedItem.getId()).clone(); + case "oraxen" -> itemStack = OraxenItem.getItemStack(droppedItem.getId()).clone(); + case "mm" -> itemStack = MythicItems.getItemStack(droppedItem.getId()).clone(); + case "mmoitems" -> itemStack = MMOItemsHook.getItemStack(droppedItem.getId()).clone(); default -> itemStack = ConfigReader.LootItem.get(droppedItem.getKey()).clone(); } diff --git a/src/main/java/net/momirealms/customfishing/utils/ItemUtil.java b/src/main/java/net/momirealms/customfishing/utils/ItemUtil.java index 30440909..941a01f8 100644 --- a/src/main/java/net/momirealms/customfishing/utils/ItemUtil.java +++ b/src/main/java/net/momirealms/customfishing/utils/ItemUtil.java @@ -21,6 +21,11 @@ import de.tr7zw.changeme.nbtapi.NBTCompound; import de.tr7zw.changeme.nbtapi.NBTItem; import net.momirealms.customfishing.ConfigReader; import net.momirealms.customfishing.CustomFishing; +import net.momirealms.customfishing.hook.ItemsAdderItem; +import net.momirealms.customfishing.hook.MMOItemsHook; +import net.momirealms.customfishing.hook.MythicItems; +import net.momirealms.customfishing.hook.OraxenItem; +import net.momirealms.customfishing.object.loot.DroppedItem; import org.bukkit.Material; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; @@ -61,6 +66,18 @@ public class ItemUtil { player.getInventory().addItem(itemStack); } + public static ItemStack getItemStackFromOtherPlugins(String key){ + DroppedItem droppedItem = (DroppedItem) ConfigReader.LOOT.get(key); + ItemStack itemStack = null; + switch (droppedItem.getType()){ + case "ia" -> itemStack = ItemsAdderItem.getItemStack(droppedItem.getId()).clone(); + case "oraxen" -> itemStack = OraxenItem.getItemStack(droppedItem.getId()).clone(); + case "mm" -> itemStack = MythicItems.getItemStack(droppedItem.getId()).clone(); + case "mmoitems" -> itemStack = MMOItemsHook.getItemStack(droppedItem.getId()).clone(); + } + return itemStack; + } + public static void saveToFile(ItemStack itemStack, String fileName){ if (itemStack == null || itemStack.getType() == Material.AIR) return; diff --git a/src/main/resources/enchant-bonus.yml b/src/main/resources/enchant-bonus.yml new file mode 100644 index 00000000..7b27a107 --- /dev/null +++ b/src/main/resources/enchant-bonus.yml @@ -0,0 +1,33 @@ +# CustomFishing does not contain an enchantment system but it's able to +# read enchantments from NBT tags and customize its bonus! +minecraft:luck_of_the_sea: + #levels + 1: + weight-PM: + silver: 2 + gold: 1 + 2: + weight-PM: + silver: 3 + gold: 2 + 3: + weight-PM: + silver: 4 + gold: 3 + +# lucky_catch from EcoEnchants +minecraft:lucky_catch: + 1: + double-loot: 0.1 + 2: + double-loot: 0.2 + 3: + double-loot: 0.3 + +# You can register an enchantment in EcoEnchants called "easy_catch" +# And then config its effects in CustomFishing! +minecraft:easy_catch: + 1: + difficulty: -1 + 2: + difficulty: -2 \ No newline at end of file