From a4037f96eb09bca439fb168789bcedbad0c5275d Mon Sep 17 00:00:00 2001 From: Xiao-MoMi <70987828+Xiao-MoMi@users.noreply.github.com> Date: Mon, 6 Mar 2023 01:24:08 +0800 Subject: [PATCH] 1.3.0-beta --- .../customfishing/manager/EffectManager.java | 8 +- .../customfishing/manager/FishingManager.java | 8 ++ .../customfishing/manager/LootManager.java | 4 +- .../customfishing/manager/TotemManager.java | 23 +---- src/main/resources/bars/default.yml | 2 +- src/main/resources/config.yml | 1 + src/main/resources/database.yml | 2 + src/main/resources/rods/default.yml | 10 +- src/main/resources/sell-fish-gui.yml | 93 ------------------- src/main/resources/sell-fish.yml | 12 ++- src/main/resources/totems/default.yml | 9 +- src/main/resources/utils/fish_finder.yml | 4 +- 12 files changed, 47 insertions(+), 129 deletions(-) delete mode 100644 src/main/resources/sell-fish-gui.yml diff --git a/src/main/java/net/momirealms/customfishing/manager/EffectManager.java b/src/main/java/net/momirealms/customfishing/manager/EffectManager.java index 27851646..3d4b0bb1 100644 --- a/src/main/java/net/momirealms/customfishing/manager/EffectManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/EffectManager.java @@ -135,8 +135,8 @@ public class EffectManager extends Function { if (baitSection == null) continue; Item item = new Item(baitSection, key); baitItems.put(key, ItemStackUtil.addIdentifier(ItemStackUtil.getFromItem(item), "bait", key)); - if (config.contains(key + ".effect")) { - baitEffects.put(key, getEffect(config.getConfigurationSection(key + ".effect"))); + if (baitSection.contains("effect")) { + baitEffects.put(key, getEffect(baitSection.getConfigurationSection("effect"))); } } } @@ -160,8 +160,8 @@ public class EffectManager extends Function { if (rodSection == null) continue; Item item = new Item(rodSection, key); rodItems.put(key, ItemStackUtil.addIdentifier(ItemStackUtil.getFromItem(item), "rod", key)); - if (config.contains(key + ".effect")) { - rodEffects.put(key, getEffect(config.getConfigurationSection(key + ".effect"))); + if (rodSection.contains("effect")) { + rodEffects.put(key, getEffect(rodSection.getConfigurationSection("effect"))); } } } diff --git a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java index 8ee858bc..b2a23b96 100644 --- a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java @@ -873,6 +873,14 @@ public class FishingManager extends Function { if (blockID == null) return; List totemList = plugin.getTotemManager().getTotemsByCoreID(blockID); if (totemList == null || !totemList.contains(totem)) return; + + FishingCondition fishingCondition = new FishingCondition(block.getLocation(), player); + for (RequirementInterface requirement : totem.getRequirements()) { + if (!requirement.isConditionMet(fishingCondition)) { + return; + } + } + Location coreLoc = block.getLocation(); int direction = plugin.getTotemManager().checkLocationModel(totem.getOriginalModel(), coreLoc); if (direction == 0) return; diff --git a/src/main/java/net/momirealms/customfishing/manager/LootManager.java b/src/main/java/net/momirealms/customfishing/manager/LootManager.java index 4dc1d747..14db8db3 100644 --- a/src/main/java/net/momirealms/customfishing/manager/LootManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/LootManager.java @@ -208,7 +208,7 @@ public class LootManager extends Function { loot.setRequirements(getRequirements(section)); } - private ActionInterface[] getActions(ConfigurationSection section, String nick) { + public ActionInterface[] getActions(ConfigurationSection section, String nick) { List actions = new ArrayList<>(); if (section != null) { for (String action : section.getKeys(false)) { @@ -243,7 +243,7 @@ public class LootManager extends Function { return actions.toArray(new ActionInterface[0]); } - private RequirementInterface[] getRequirements(ConfigurationSection section) { + public RequirementInterface[] getRequirements(ConfigurationSection section) { List requirements = new ArrayList<>(); if (section != null) { for (String type : section.getKeys(false)) { diff --git a/src/main/java/net/momirealms/customfishing/manager/TotemManager.java b/src/main/java/net/momirealms/customfishing/manager/TotemManager.java index e1bb1cdb..46af81bc 100644 --- a/src/main/java/net/momirealms/customfishing/manager/TotemManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/TotemManager.java @@ -181,7 +181,7 @@ public class TotemManager extends Function { config.getInt(key + ".radius", 16), config.getInt(key + ".duration", 300), Particle.valueOf(config.getString(key + ".particle", "SPELL_MOB").toUpperCase()), - EffectManager.getEffect(config.getConfigurationSection(key + ".modifier")) + EffectManager.getEffect(config.getConfigurationSection(key + ".effect")) ); List actionList = new ArrayList<>(); @@ -196,26 +196,10 @@ public class TotemManager extends Function { } } } + totem.setActivatorActions(actionList.toArray(new ActionInterface[0])); totem.setNearbyActions(nearActionList.toArray(new ActionInterface[0])); - - if (config.contains(key + ".requirements")) { - List requirements = new ArrayList<>(); - Objects.requireNonNull(config.getConfigurationSection(key + ".requirements")).getKeys(false).forEach(requirement -> { - switch (requirement){ - case "weather" -> requirements.add(new WeatherImpl(config.getStringList(key + ".requirements.weather"))); - case "ypos" -> requirements.add(new YPosImpl(config.getStringList(key + ".requirements.ypos"))); - case "season" -> requirements.add(new SeasonImpl(config.getStringList(key + ".requirements.season"))); - case "world" -> requirements.add(new WorldImpl(config.getStringList(key + ".requirements.world"))); - case "biome" -> requirements.add(new BiomeImpl(config.getStringList(key + ".requirements.biome"))); - case "permission" -> requirements.add(new PermissionImpl(config.getString(key + ".requirements.permission"))); - case "time" -> requirements.add(new TimeImpl(config.getStringList(key + ".requirements.time"))); - case "skill-level" -> requirements.add(new SkillLevelImpl(config.getInt(key + ".requirements.skill-level"))); - case "papi-condition" -> requirements.add(new CustomPapi(config.getConfigurationSection(key + ".requirements.papi-condition").getValues(false))); - } - }); - totem.setRequirements(requirements.toArray(new RequirementInterface[0])); - } + totem.setRequirements(plugin.getLootManager().getRequirements(config.getConfigurationSection(key + ".requirements"))); if (config.getBoolean(key + ".hologram.enable", false)) { totem.setHoloText(config.getStringList(key + ".hologram.text").toArray(new String[0])); @@ -225,7 +209,6 @@ public class TotemManager extends Function { if (config.contains(key + ".potion-effects")) { List potionEffectList = new ArrayList<>(); for (String potion : config.getConfigurationSection(key + ".potion-effects").getKeys(false)) { - PotionEffectType potionType = PotionEffectType.getByName(potion.toUpperCase()); if (potionType == null) continue; int time = 40; diff --git a/src/main/resources/bars/default.yml b/src/main/resources/bars/default.yml index cac270c4..40548fb4 100644 --- a/src/main/resources/bars/default.yml +++ b/src/main/resources/bars/default.yml @@ -544,7 +544,7 @@ bar_11: title: '{strain}' subtitle: font: 'customfishing:default' - bar: '뀌' + bar: '뀓' fish: '뀎' struggling-fish: - 뀑 diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6270426f..47924900 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,6 +1,7 @@ # Don't change config-version: '16' +# Wiki: https://mo-mi.gitbook.io/xiaomomi-plugins/ # chinese/english/spanish lang: english diff --git a/src/main/resources/database.yml b/src/main/resources/database.yml index 47b6f76d..c66dc8e4 100644 --- a/src/main/resources/database.yml +++ b/src/main/resources/database.yml @@ -4,7 +4,9 @@ config-version: '1' data-storage-method: YAML # Migrate from 1.2 to 1.3 +# 迁移 1.2->1.3 # This option would automatically be set to false when migration finishes +# 这个选项会在迁移完毕后自动设置为false migration: false # MySQL settings diff --git a/src/main/resources/rods/default.yml b/src/main/resources/rods/default.yml index bcc6340c..03cb3839 100644 --- a/src/main/resources/rods/default.yml +++ b/src/main/resources/rods/default.yml @@ -5,7 +5,7 @@ wooden_rod: - 'Its just an ordinary fishing rod' - 'But it''s quite friendly to a starter!' # Click here to learn how modifier system works: https://www.yuque.com/docs/share/4842ac5f-b5ea-4568-acef-d510f8bc9064?# 《Modifier System》 - modifier: + effect: difficulty: -1 nature_fishing_cane: @@ -15,7 +15,7 @@ nature_fishing_cane: - 'The wild power makes it easier to be hooked' - 'But also increase the difficulty' custom-model-data: 50001 - modifier: + effect: time: 0.9 difficulty: 1 @@ -25,7 +25,7 @@ silver_fishing_rod: lore: - 'Increase the chance of getting silver quality fish' custom-model-data: 50002 - modifier: + effect: weight-add: silver: 20 gold: -10 @@ -36,7 +36,7 @@ golden_fishing_rod: lore: - 'Increase the chance of getting golden quality fish' custom-model-data: 50003 - modifier: + effect: weight-add: silver: -20 gold: 20 @@ -47,7 +47,7 @@ star_fishing_rod: lore: - 'Grants you the ability to fish in the lava' custom-model-data: 50004 - modifier: + effect: weight-add: silver: 20 gold: 10 diff --git a/src/main/resources/sell-fish-gui.yml b/src/main/resources/sell-fish-gui.yml deleted file mode 100644 index 771448cf..00000000 --- a/src/main/resources/sell-fish-gui.yml +++ /dev/null @@ -1,93 +0,0 @@ -container-title: 'Sell Fish' - -rows: 6 - -# Limit the money player can earn per day -sell-limitation: - enable: true - upper-limit: 10000 - -price-formula: '{base} + {bonus} * {size}' - -vanilla-item-price: - COD: 10 - PUFFERFISH: 10 - SALMON: 10 - TROPICAL_FISH: 10 - -sounds: - open: minecraft:block.chest.open - close: minecraft:block.chest.close - success: minecraft:block.amethyst_block.break - deny: minecraft:block.anvil.destroy - confirm: minecraft:entity.villager.trade - type: player - -actions: - message: - enable: true - text: 'You earned {money}$ from selling the fish! You can still gain {remains}$ from selling fish today' - title: - enable: true - title: 'Success' - subtitle: 'You earned {money}$ from selling the fish' - in: 20 - stay: 40 - out: 20 - actionbar: - enable: true - text: 'You earned {money}$ from selling the fish' - commands: - enable: false - value: - - 'cmi broadcast {player} earned {money}' - -functional-icons: - slots: - - 50 - sell: - material: IRON_BLOCK - display: - name: '<#00CED1>Sell the fish' - lore: - - 'You will gain {money}$' - custom-model-data: 1 - deny: - material: REDSTONE_BLOCK - display: - name: 'Denied' - lore: - - 'Nothing to sell!' - custom-model-data: 1 - -decorative-icons: - glass-pane: - material: BLACK_STAINED_GLASS_PANE - display: - name: ' ' - slots: - - 1 - - 2 - - 3 - - 4 - - 5 - - 6 - - 7 - - 8 - - 9 - - 10 - - 18 - - 19 - - 27 - - 28 - - 36 - - 37 - - 45 - - 46 - - 47 - - 48 - - 49 - - 51 - - 52 - - 53 - - 54 \ No newline at end of file diff --git a/src/main/resources/sell-fish.yml b/src/main/resources/sell-fish.yml index 771448cf..af1189d3 100644 --- a/src/main/resources/sell-fish.yml +++ b/src/main/resources/sell-fish.yml @@ -1,20 +1,26 @@ +# GUI标题 container-title: 'Sell Fish' +# GUI行数 rows: 6 # Limit the money player can earn per day +# 限制玩家每日的收入上限 sell-limitation: enable: true upper-limit: 10000 +# 价格公式 price-formula: '{base} + {bonus} * {size}' +# 原版物品出售价格 vanilla-item-price: COD: 10 PUFFERFISH: 10 SALMON: 10 TROPICAL_FISH: 10 +# 音效设置 sounds: open: minecraft:block.chest.open close: minecraft:block.chest.close @@ -23,6 +29,7 @@ sounds: confirm: minecraft:entity.villager.trade type: player +# 销售时发生的动作 actions: message: enable: true @@ -41,10 +48,11 @@ actions: enable: false value: - 'cmi broadcast {player} earned {money}' - +# 功能性的图标 functional-icons: slots: - 50 + # 销售信息图标 sell: material: IRON_BLOCK display: @@ -52,6 +60,7 @@ functional-icons: lore: - 'You will gain {money}$' custom-model-data: 1 + # 拒绝图标 deny: material: REDSTONE_BLOCK display: @@ -60,6 +69,7 @@ functional-icons: - 'Nothing to sell!' custom-model-data: 1 +# 装饰性的图标 decorative-icons: glass-pane: material: BLACK_STAINED_GLASS_PANE diff --git a/src/main/resources/totems/default.yml b/src/main/resources/totems/default.yml index 6833d941..f9246b00 100644 --- a/src/main/resources/totems/default.yml +++ b/src/main/resources/totems/default.yml @@ -20,7 +20,7 @@ double_loot_fishing_totem: NIGHT_VISION: 1 # Fishing bonus - modifier: + effect: double-loot: 1 # placeholders: {activator} {player} {world} {x} {y} {z} @@ -35,12 +35,19 @@ double_loot_fishing_totem: # The layout of the totem + # 图腾的摆放放 # The greater the layer number is, the higher the y position is + # 层数越高,则对应的Y坐标也越高 # Totem core can be put anywhere in the layout + # 图腾核心可以位于摆放中的任意位置 # “*” represents any type of block is allowed here [example *] + # “*” 代表这个位置可以用任何方块 # “()“ represents the block is protected and will not be removed when activating [example (a)] + # “()“ 代表图腾激活后此方块会被保护 # “>“ represents the block would turn into another block after activating [example: a>b] + # ">" 代表图腾激活后,左边的方块会变成右边的方块 # “|“ represents alternative block choice for this place [example a|b>c] + # “|“ 代表这个位置可以使用多种替选方块 layer: 4: - '(p) (o) (p)' diff --git a/src/main/resources/utils/fish_finder.yml b/src/main/resources/utils/fish_finder.yml index 6f8fbf31..46f635b7 100644 --- a/src/main/resources/utils/fish_finder.yml +++ b/src/main/resources/utils/fish_finder.yml @@ -1,7 +1,7 @@ fishfinder: - material: COMPASS + material: PAPER display: name: 'Fish Finder' lore: - 'Right click to see what fish can be caught in this place!' - custom-model-data: 50001 + custom-model-data: 50000