diff --git a/build.gradle b/build.gradle index 837f0dcd..c8b9ac54 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'net.momirealms' -version = '1.2.17.1' +version = '1.2.17.2' repositories { mavenCentral() diff --git a/src/main/java/net/momirealms/customfishing/api/event/SellFishEvent.java b/src/main/java/net/momirealms/customfishing/api/event/SellFishEvent.java index 41424e23..02a8b432 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/SellFishEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/SellFishEvent.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customfishing.api.event; import org.bukkit.entity.Player; diff --git a/src/main/java/net/momirealms/customfishing/data/PlayerSellData.java b/src/main/java/net/momirealms/customfishing/data/PlayerSellData.java index e3d2eaa7..ff616b09 100644 --- a/src/main/java/net/momirealms/customfishing/data/PlayerSellData.java +++ b/src/main/java/net/momirealms/customfishing/data/PlayerSellData.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customfishing.data; public class PlayerSellData { diff --git a/src/main/java/net/momirealms/customfishing/data/storage/SqlConstants.java b/src/main/java/net/momirealms/customfishing/data/storage/SqlConstants.java index c330910f..fb15ac2e 100644 --- a/src/main/java/net/momirealms/customfishing/data/storage/SqlConstants.java +++ b/src/main/java/net/momirealms/customfishing/data/storage/SqlConstants.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customfishing.data.storage; public class SqlConstants { diff --git a/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java b/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java index fdbf5c8c..aaaeaae8 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java @@ -19,7 +19,6 @@ package net.momirealms.customfishing.integration.item; import io.lumine.mythic.bukkit.MythicBukkit; import io.lumine.mythic.core.items.ItemExecutor; -import io.lumine.mythic.core.items.MythicItem; import net.momirealms.customfishing.integration.ItemInterface; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/net/momirealms/customfishing/integration/quest/BattlePassCFQuest.java b/src/main/java/net/momirealms/customfishing/integration/quest/BattlePassCFQuest.java index 5117bb95..540bea3a 100644 --- a/src/main/java/net/momirealms/customfishing/integration/quest/BattlePassCFQuest.java +++ b/src/main/java/net/momirealms/customfishing/integration/quest/BattlePassCFQuest.java @@ -18,14 +18,10 @@ package net.momirealms.customfishing.integration.quest; import io.github.battlepass.BattlePlugin; -import io.github.battlepass.objects.quests.variable.QuestResult; import io.github.battlepass.quests.quests.external.executor.ExternalQuestExecutor; import io.github.battlepass.registry.quest.QuestRegistry; -import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.api.event.FishResultEvent; import net.momirealms.customfishing.object.fishing.FishResult; -import org.bukkit.Bukkit; -import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -34,10 +30,7 @@ public class BattlePassCFQuest extends ExternalQuestExecutor implements Listener public static void register() { QuestRegistry questRegistry = BattlePlugin.getApi().getQuestRegistry(); - questRegistry.hook("customfishing", instance -> { - BattlePassCFQuest battlePassCFQuest = new BattlePassCFQuest(instance); - return battlePassCFQuest; - }); + questRegistry.hook("customfishing", BattlePassCFQuest::new); } public BattlePassCFQuest(BattlePlugin battlePlugin) { diff --git a/src/main/java/net/momirealms/customfishing/integration/quest/BetonQuestHook.java b/src/main/java/net/momirealms/customfishing/integration/quest/BetonQuestCFQuest.java similarity index 95% rename from src/main/java/net/momirealms/customfishing/integration/quest/BetonQuestHook.java rename to src/main/java/net/momirealms/customfishing/integration/quest/BetonQuestCFQuest.java index 4a476485..b76d498b 100644 --- a/src/main/java/net/momirealms/customfishing/integration/quest/BetonQuestHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/quest/BetonQuestCFQuest.java @@ -17,5 +17,5 @@ package net.momirealms.customfishing.integration.quest; -public class BetonQuestHook { +public class BetonQuestCFQuest { } diff --git a/src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollHook.java b/src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollCFQuest.java similarity index 95% rename from src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollHook.java rename to src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollCFQuest.java index 933e1a5a..3d8f4db4 100644 --- a/src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollCFQuest.java @@ -25,13 +25,13 @@ import net.momirealms.customfishing.object.fishing.FishResult; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -public class ClueScrollHook implements Listener { +public class ClueScrollCFQuest implements Listener { private final CustomClue fishClue; private final CustomClue mobClue; private final CustomClue commonClue; - public ClueScrollHook () { + public ClueScrollCFQuest() { commonClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.plugin, "fish"); fishClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.plugin, "catch_fish"); mobClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.plugin, "catch_mob"); diff --git a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java index a460264a..e8502f13 100644 --- a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java @@ -906,8 +906,9 @@ public class FishingManager extends Function { int timer; int time; if (loot != null){ - speed = loot.getDifficulty().speed(); - timer = loot.getDifficulty().timer(); + Difficulty difficulty = loot.getDifficulty()[new Random().nextInt(loot.getDifficulty().length)]; + speed = difficulty.speed(); + timer = difficulty.timer(); time = loot.getTime(); } else { diff --git a/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java b/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java index d3f7c01f..30325180 100644 --- a/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java @@ -28,7 +28,7 @@ import net.momirealms.customfishing.integration.item.*; import net.momirealms.customfishing.integration.mob.MythicMobsMobImpl; import net.momirealms.customfishing.integration.papi.PlaceholderManager; import net.momirealms.customfishing.integration.quest.BattlePassCFQuest; -import net.momirealms.customfishing.integration.quest.ClueScrollHook; +import net.momirealms.customfishing.integration.quest.ClueScrollCFQuest; import net.momirealms.customfishing.integration.season.CustomCropsSeasonImpl; import net.momirealms.customfishing.integration.season.RealisticSeasonsImpl; import net.momirealms.customfishing.integration.skill.*; @@ -213,8 +213,8 @@ public class IntegrationManager extends Function { public void registerQuests() { if (Bukkit.getPluginManager().isPluginEnabled("ClueScrolls")) { - ClueScrollHook clueScrollHook = new ClueScrollHook(); - Bukkit.getPluginManager().registerEvents(clueScrollHook, CustomFishing.plugin); + ClueScrollCFQuest clueScrollCFQuest = new ClueScrollCFQuest(); + Bukkit.getPluginManager().registerEvents(clueScrollCFQuest, CustomFishing.plugin); hookMessage("ClueScrolls"); } if (Bukkit.getPluginManager().isPluginEnabled("BetonQuest")) { diff --git a/src/main/java/net/momirealms/customfishing/manager/LootManager.java b/src/main/java/net/momirealms/customfishing/manager/LootManager.java index ca2c4be0..7b8119f9 100644 --- a/src/main/java/net/momirealms/customfishing/manager/LootManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/LootManager.java @@ -87,13 +87,26 @@ public class LootManager extends Function { for (String key : keys) { if (!config.getBoolean(key + ".enable", true)) continue; // Bar mechanic - String[] diff = StringUtils.split(config.getString(key + ".difficulty", "1-1"),"-"); - Difficulty difficulty = new Difficulty(Integer.parseInt(diff[0]), Integer.parseInt(diff[1])); + List difficulties = new ArrayList<>(); + List difficultyList = config.getStringList(key + ".difficulty"); + if (difficultyList.size() == 0) { + String[] diff = StringUtils.split(config.getString(key + ".difficulty", "1-1"),"-"); + Difficulty difficulty = new Difficulty(Integer.parseInt(diff[0]), Integer.parseInt(diff[1])); + difficulties.add(difficulty); + } + else { + for (String difficultyStr : difficultyList) { + String[] diff = StringUtils.split(difficultyStr,"-"); + Difficulty difficulty = new Difficulty(Integer.parseInt(diff[0]), Integer.parseInt(diff[1])); + difficulties.add(difficulty); + } + } + int weight = config.getInt(key + ".weight",10); int time = config.getInt(key + ".time",10000); Mob loot = new Mob( key, - difficulty, + difficulties.toArray(new Difficulty[0]), time, weight, config.getString(key + ".mobID", key), @@ -132,13 +145,25 @@ public class LootManager extends Function { String material = config.getString(key + ".material","COD"); // Bar mechanic - String[] diff = StringUtils.split(config.getString(key + ".difficulty", "1-1"),"-"); - Difficulty difficulty = new Difficulty(Integer.parseInt(diff[0]), Integer.parseInt(diff[1])); + List difficulties = new ArrayList<>(); + List difficultyList = config.getStringList(key + ".difficulty"); + if (difficultyList.size() == 0) { + String[] diff = StringUtils.split(config.getString(key + ".difficulty", "1-1"),"-"); + Difficulty difficulty = new Difficulty(Integer.parseInt(diff[0]), Integer.parseInt(diff[1])); + difficulties.add(difficulty); + } + else { + for (String difficultyStr : difficultyList) { + String[] diff = StringUtils.split(difficultyStr,"-"); + Difficulty difficulty = new Difficulty(Integer.parseInt(diff[0]), Integer.parseInt(diff[1])); + difficulties.add(difficulty); + } + } int weight = config.getInt(key + ".weight",10); int time = config.getInt(key + ".time",10000); DroppedItem loot = new DroppedItem( key, - difficulty, + difficulties.toArray(new Difficulty[0]), time, weight, material.contains(":") ? material : key); diff --git a/src/main/java/net/momirealms/customfishing/manager/SellManager.java b/src/main/java/net/momirealms/customfishing/manager/SellManager.java index b83ecec0..20c609fc 100644 --- a/src/main/java/net/momirealms/customfishing/manager/SellManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/SellManager.java @@ -58,7 +58,7 @@ public class SellManager extends Function { private final WindowPacketListener windowPacketListener; private final InventoryListener inventoryListener; - private SimpleListener simpleListener; + private final SimpleListener simpleListener; public static String formula; public static String title; public static int guiSize; diff --git a/src/main/java/net/momirealms/customfishing/object/loot/DroppedItem.java b/src/main/java/net/momirealms/customfishing/object/loot/DroppedItem.java index 8fa9161e..17353971 100644 --- a/src/main/java/net/momirealms/customfishing/object/loot/DroppedItem.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/DroppedItem.java @@ -29,7 +29,7 @@ public class DroppedItem extends Loot{ private float basicPrice; private float sizeBonus; - public DroppedItem(String key, Difficulty difficulty, int time, int weight, String material) { + public DroppedItem(String key, Difficulty[] difficulty, int time, int weight, String material) { super(key, difficulty, time, weight); this.material = material; } diff --git a/src/main/java/net/momirealms/customfishing/object/loot/Loot.java b/src/main/java/net/momirealms/customfishing/object/loot/Loot.java index efbd4975..cb7dff6e 100644 --- a/src/main/java/net/momirealms/customfishing/object/loot/Loot.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/Loot.java @@ -24,11 +24,11 @@ import net.momirealms.customfishing.object.requirements.RequirementInterface; public class Loot { - public static Loot EMPTY = new Loot("empty", new Difficulty(1,1), 5000, 10); + public static Loot EMPTY = new Loot("empty", new Difficulty[]{new Difficulty(1, 1)}, 5000, 10); protected String key; protected String nick; - protected Difficulty difficulty; + protected Difficulty[] difficulty; protected String group; protected boolean showInFinder; protected Layout[] layout; @@ -40,7 +40,7 @@ public class Loot { protected RequirementInterface[] requirements; protected double score; - public Loot(String key, Difficulty difficulty, int time, int weight) { + public Loot(String key, Difficulty[] difficulty, int time, int weight) { this.key = key; this.difficulty = difficulty; this.time = time; @@ -58,11 +58,11 @@ public class Loot { this.nick = nick; } - public Difficulty getDifficulty() { + public Difficulty[] getDifficulty() { return difficulty; } - public void setDifficulty(Difficulty difficulty) { + public void setDifficulty(Difficulty[] difficulty) { this.difficulty = difficulty; } diff --git a/src/main/java/net/momirealms/customfishing/object/loot/Mob.java b/src/main/java/net/momirealms/customfishing/object/loot/Mob.java index 25695e0d..104d285f 100644 --- a/src/main/java/net/momirealms/customfishing/object/loot/Mob.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/Mob.java @@ -26,7 +26,7 @@ public class Mob extends Loot{ private final int mobLevel; private final MobVector mobVector; - public Mob(String key, Difficulty difficulty, int time, int weight, String mobID, int level, MobVector vector) { + public Mob(String key, Difficulty[] difficulty, int time, int weight, String mobID, int level, MobVector vector) { super(key, difficulty, time, weight); this.mobID = mobID; this.mobLevel = level; diff --git a/src/main/java/net/momirealms/customfishing/object/totem/FinalModel.java b/src/main/java/net/momirealms/customfishing/object/totem/FinalModel.java index 5d9fc71d..dc9a3514 100644 --- a/src/main/java/net/momirealms/customfishing/object/totem/FinalModel.java +++ b/src/main/java/net/momirealms/customfishing/object/totem/FinalModel.java @@ -36,7 +36,7 @@ public class FinalModel { public String toString() { StringBuilder stringBuilder = new StringBuilder("FinalModel:"); for (int i = 0; i < height; i++) { - stringBuilder.append("\nlayer: "+ (i+1)); + stringBuilder.append("\nlayer: ").append(i + 1); for (int j = 0; j < width; j++) { stringBuilder.append("\n"); for (int k = 0; k < height; k++) { diff --git a/src/main/java/net/momirealms/customfishing/object/totem/OriginalModel.java b/src/main/java/net/momirealms/customfishing/object/totem/OriginalModel.java index 10569cc2..aa793a79 100644 --- a/src/main/java/net/momirealms/customfishing/object/totem/OriginalModel.java +++ b/src/main/java/net/momirealms/customfishing/object/totem/OriginalModel.java @@ -39,7 +39,7 @@ public class OriginalModel { public String toString() { StringBuilder stringBuilder = new StringBuilder("TotemModel:"); for (int i = 0; i < height; i++) { - stringBuilder.append("\nlayer: "+ (i+1)); + stringBuilder.append("\nlayer: ").append(i + 1); for (int j = 0; j < width; j++) { stringBuilder.append("\n"); for (int k = 0; k < height; k++) { diff --git a/src/main/resources/loots/example.yml b/src/main/resources/loots/example.yml index 676b6513..c29205f8 100644 --- a/src/main/resources/loots/example.yml +++ b/src/main/resources/loots/example.yml @@ -55,7 +55,7 @@ rainbow_fish: id: '(String) rainbow_fish' # Available events: success/failure/hook - # Available actions: message/command/exp/mending/skill-xp + # Available actions: message/command/exp/mending/skill-xp/sound action: success: message: diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b5d2b016..a49cd076 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -32,6 +32,7 @@ softdepend: - Vault - BattlePass - ClueScrolls + - BetonQuest commands: customfishing: