diff --git a/build.gradle b/build.gradle index 88ba7fcf..3a3a0c58 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'net.momirealms' -version = '1.3.2.1-hotfix' +version = '1.3.2.2' repositories { maven {name = "aliyun-repo"; url = "https://maven.aliyun.com/repository/public/"} @@ -16,8 +16,11 @@ repositories { maven {name = "sk89q-repo"; url = "https://maven.enginehub.org/repo/"} maven {name = "jitpack-repo"; url = "https://jitpack.io"} maven {name = "Lumine-repo"; url = "https://mvn.lumine.io/repository/maven-public"} - maven {name = 'glaremasters-repo'; url = 'https://repo.glaremasters.me/repository/towny/'} + maven {name = 'rapture-repo'; url = 'https://repo.rapture.pw/repository/maven-releases/'} maven {name = 'mmo-repo'; url = 'https://nexus.phoenixdevt.fr/repository/maven-public/'} + maven {name = 'i-repo'; url = 'https://r.irepo.space/maven/'} + maven {name = 'auxilor-repo'; url = 'https://repo.auxilor.io/repository/maven-public/'} + maven {name = 'betonquest-repo'; url = 'https://betonquest.org/nexus/repository/betonquest/'} mavenCentral() } @@ -30,6 +33,7 @@ dependencies { compileOnly('com.github.Archy-X:AureliumSkills:Beta1.3.6') compileOnly('redis.clients:jedis:4.4.3') compileOnly('me.clip:placeholderapi:2.11.3') + compileOnly("com.github.oraxen:oraxen:1.158.0") compileOnly('io.lumine:Mythic-Dist:5.2.1') compileOnly('dev.dejvokep:boosted-yaml:1.3') compileOnly('com.github.LoneDev6:api-itemsadder:3.4.1-r4') @@ -37,11 +41,18 @@ dependencies { compileOnly('org.mariadb.jdbc:mariadb-java-client:3.1.4') compileOnly('com.google.code.gson:gson:2.10.1') compileOnly('com.willfp:EcoEnchants:10.13.0') + compileOnly("pers.neige.neigeitems:NeigeItems:1.14.23") compileOnly('net.Indyuce:MMOItems-API:6.9.2-SNAPSHOT') - //repo is private access - //compileOnly('com.willfp:EcoSkills:3.0.0-b2') - compileOnly('com.willfp:eco:6.60.0') - compileOnly('com.willfp:EcoJobs:3.13.0') + compileOnly('io.lumine:MythicLib-dist:1.6-SNAPSHOT') + compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0") + compileOnly('net.Indyuce:MMOCore-API:1.12-SNAPSHOT') + compileOnly('com.github.Zrips:Jobs:4.17.2') + compileOnly("com.willfp:eco:6.65.1") + compileOnly("com.willfp:EcoJobs:3.13.0") + compileOnly("com.willfp:EcoSkills:3.8.1") + compileOnly("pl.betoncraft:betonquest:1.12.10") + compileOnly("com.github.MilkBowl:VaultAPI:1.7") + compileOnly("com.github.Archy-X:AureliumSkills:Beta1.3.21") implementation('net.kyori:adventure-api:4.14.0') implementation('net.kyori:adventure-platform-bukkit:4.3.0') implementation('net.kyori:adventure-text-minimessage:4.14.0') diff --git a/libs/AureliumSkills-Beta1.3.6.jar b/libs/AureliumSkills-Beta1.3.6.jar deleted file mode 100644 index ed284b9b..00000000 Binary files a/libs/AureliumSkills-Beta1.3.6.jar and /dev/null differ diff --git a/libs/BetonQuest1.12.9.jar b/libs/BetonQuest1.12.9.jar deleted file mode 100644 index 6a0f73f7..00000000 Binary files a/libs/BetonQuest1.12.9.jar and /dev/null differ diff --git a/libs/CustomCrops-3.2.1-API.jar b/libs/CustomCrops-3.2.1-API.jar deleted file mode 100644 index 343bc1c3..00000000 Binary files a/libs/CustomCrops-3.2.1-API.jar and /dev/null differ diff --git a/libs/CustomCrops-api-3.3.1.2.jar b/libs/CustomCrops-api-3.3.1.2.jar new file mode 100644 index 00000000..de2cedcc Binary files /dev/null and b/libs/CustomCrops-api-3.3.1.2.jar differ diff --git a/libs/EcoSkills v3.0.0-api.jar b/libs/EcoSkills v3.0.0-api.jar deleted file mode 100644 index 0f648d83..00000000 Binary files a/libs/EcoSkills v3.0.0-api.jar and /dev/null differ diff --git a/libs/MMOCore-1.11-api.jar b/libs/MMOCore-1.11-api.jar deleted file mode 100644 index f7a424b4..00000000 Binary files a/libs/MMOCore-1.11-api.jar and /dev/null differ diff --git a/libs/MythicLib-1.5.2.jar b/libs/MythicLib-1.5.2.jar deleted file mode 100644 index 98739445..00000000 Binary files a/libs/MythicLib-1.5.2.jar and /dev/null differ diff --git a/libs/ProtocolLib.jar b/libs/ProtocolLib.jar deleted file mode 100644 index 7224b28d..00000000 Binary files a/libs/ProtocolLib.jar and /dev/null differ diff --git a/libs/Vault.jar b/libs/Vault.jar deleted file mode 100644 index 4bcaa890..00000000 Binary files a/libs/Vault.jar and /dev/null differ diff --git a/libs/oraxen-api.jar b/libs/oraxen-api.jar deleted file mode 100644 index 85555d33..00000000 Binary files a/libs/oraxen-api.jar and /dev/null differ diff --git a/src/main/java/net/momirealms/customfishing/data/PlayerStatisticsData.java b/src/main/java/net/momirealms/customfishing/data/PlayerStatisticsData.java index 8b122904..4b10d7f9 100644 --- a/src/main/java/net/momirealms/customfishing/data/PlayerStatisticsData.java +++ b/src/main/java/net/momirealms/customfishing/data/PlayerStatisticsData.java @@ -85,7 +85,7 @@ public class PlayerStatisticsData { for (Map.Entry entry : actionMap.entrySet()) { if (entry.getKey() > previous && entry.getKey() <= after) { for (Action action : entry.getValue()) { - action.doOn(player, null); + action.doOn(player); } } } diff --git a/src/main/java/net/momirealms/customfishing/fishing/FishMeta.java b/src/main/java/net/momirealms/customfishing/fishing/FishMeta.java new file mode 100644 index 00000000..a728e591 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/fishing/FishMeta.java @@ -0,0 +1,4 @@ +package net.momirealms.customfishing.fishing; + +public record FishMeta(float size, float base, float bonus) { +} diff --git a/src/main/java/net/momirealms/customfishing/fishing/action/Action.java b/src/main/java/net/momirealms/customfishing/fishing/action/Action.java index e70f896c..58f7e2f5 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/action/Action.java +++ b/src/main/java/net/momirealms/customfishing/fishing/action/Action.java @@ -17,11 +17,19 @@ package net.momirealms.customfishing.fishing.action; +import net.momirealms.customfishing.fishing.FishMeta; import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; public interface Action { - void doOn(Player player, @Nullable Player anotherPlayer); + void doOn(Player player, @Nullable Player anotherPlayer, @Nullable FishMeta fishMeta); + default void doOn(Player player) { + doOn(player, null, null); + } + + default void doOn(Player player, Player anotherPlayer) { + doOn(player, anotherPlayer, null); + } } diff --git a/src/main/java/net/momirealms/customfishing/fishing/action/ChainImpl.java b/src/main/java/net/momirealms/customfishing/fishing/action/ChainImpl.java index 9330eaa4..8d417c9b 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/action/ChainImpl.java +++ b/src/main/java/net/momirealms/customfishing/fishing/action/ChainImpl.java @@ -17,6 +17,7 @@ package net.momirealms.customfishing.fishing.action; +import net.momirealms.customfishing.fishing.FishMeta; import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; @@ -30,10 +31,10 @@ public class ChainImpl extends AbstractAction implements Action { } @Override - public void doOn(Player player, @Nullable Player anotherPlayer) { + public void doOn(Player player, @Nullable Player anotherPlayer, @Nullable FishMeta fishMeta) { if (!canExecute()) return; for (Action action : actions) { - action.doOn(player, anotherPlayer); + action.doOn(player, anotherPlayer, fishMeta); } } } diff --git a/src/main/java/net/momirealms/customfishing/fishing/action/CommandActionImpl.java b/src/main/java/net/momirealms/customfishing/fishing/action/CommandActionImpl.java index e9459d6c..087b800d 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/action/CommandActionImpl.java +++ b/src/main/java/net/momirealms/customfishing/fishing/action/CommandActionImpl.java @@ -17,6 +17,7 @@ package net.momirealms.customfishing.fishing.action; +import net.momirealms.customfishing.fishing.FishMeta; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; @@ -33,7 +34,7 @@ public class CommandActionImpl extends AbstractAction implements Action { } @Override - public void doOn(Player player, @Nullable Player anotherPlayer) { + public void doOn(Player player, @Nullable Player anotherPlayer, @Nullable FishMeta fishMeta) { if (!canExecute()) return; for (String command : commands) { Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), @@ -44,6 +45,7 @@ public class CommandActionImpl extends AbstractAction implements Action { .replace("{loot}", nick) .replace("{world}", player.getWorld().getName()) .replace("{activator}", anotherPlayer == null ? "" : anotherPlayer.getName()) + .replace("{size}", fishMeta == null ? "" : String.format("%.2f", fishMeta.size())) ); } } diff --git a/src/main/java/net/momirealms/customfishing/fishing/action/JobXPImpl.java b/src/main/java/net/momirealms/customfishing/fishing/action/JobXPImpl.java index a59e0c87..5b201fe9 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/action/JobXPImpl.java +++ b/src/main/java/net/momirealms/customfishing/fishing/action/JobXPImpl.java @@ -1,6 +1,7 @@ package net.momirealms.customfishing.fishing.action; import net.momirealms.customfishing.CustomFishing; +import net.momirealms.customfishing.fishing.FishMeta; import net.momirealms.customfishing.integration.JobInterface; import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; @@ -15,7 +16,7 @@ public class JobXPImpl extends AbstractAction implements Action { } @Override - public void doOn(Player player, @Nullable Player anotherPlayer) { + public void doOn(Player player, @Nullable Player anotherPlayer, @Nullable FishMeta fishMeta) { if (!canExecute()) return; JobInterface jobInterface = CustomFishing.getInstance().getIntegrationManager().getJobInterface(); if (jobInterface == null) return; diff --git a/src/main/java/net/momirealms/customfishing/fishing/action/MessageActionImpl.java b/src/main/java/net/momirealms/customfishing/fishing/action/MessageActionImpl.java index d464aacc..990ea943 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/action/MessageActionImpl.java +++ b/src/main/java/net/momirealms/customfishing/fishing/action/MessageActionImpl.java @@ -17,6 +17,7 @@ package net.momirealms.customfishing.fishing.action; +import net.momirealms.customfishing.fishing.FishMeta; import net.momirealms.customfishing.util.AdventureUtils; import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; @@ -33,7 +34,7 @@ public class MessageActionImpl extends AbstractAction implements Action { } @Override - public void doOn(Player player, @Nullable Player anotherPlayer) { + public void doOn(Player player, @Nullable Player anotherPlayer, @Nullable FishMeta fishMeta) { if (!canExecute()) return; for (String message : messages) { AdventureUtils.playerMessage(player, @@ -44,6 +45,7 @@ public class MessageActionImpl extends AbstractAction implements Action { .replace("{z}", String.valueOf(player.getLocation().getBlockZ())) .replace("{loot}", nick) .replace("{activator}", anotherPlayer == null ? "" : anotherPlayer.getName()) + .replace("{size}", fishMeta == null ? "" : String.format("%.2f", fishMeta.size())) ); } } diff --git a/src/main/java/net/momirealms/customfishing/fishing/action/PotionEffectImpl.java b/src/main/java/net/momirealms/customfishing/fishing/action/PotionEffectImpl.java index 88e83460..61144a8d 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/action/PotionEffectImpl.java +++ b/src/main/java/net/momirealms/customfishing/fishing/action/PotionEffectImpl.java @@ -17,6 +17,7 @@ package net.momirealms.customfishing.fishing.action; +import net.momirealms.customfishing.fishing.FishMeta; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.jetbrains.annotations.Nullable; @@ -31,7 +32,7 @@ public class PotionEffectImpl extends AbstractAction implements Action { } @Override - public void doOn(Player player, @Nullable Player anotherPlayer) { + public void doOn(Player player, @Nullable Player anotherPlayer, @Nullable FishMeta fishMeta) { if (!canExecute()) return; player.addPotionEffect(potionEffect); } diff --git a/src/main/java/net/momirealms/customfishing/fishing/action/SkillXPImpl.java b/src/main/java/net/momirealms/customfishing/fishing/action/SkillXPImpl.java index 4248d193..fbe3e82a 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/action/SkillXPImpl.java +++ b/src/main/java/net/momirealms/customfishing/fishing/action/SkillXPImpl.java @@ -18,8 +18,10 @@ package net.momirealms.customfishing.fishing.action; import net.momirealms.customfishing.CustomFishing; +import net.momirealms.customfishing.fishing.FishMeta; import net.momirealms.customfishing.integration.SkillInterface; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; public class SkillXPImpl extends AbstractAction implements Action { @@ -31,7 +33,7 @@ public class SkillXPImpl extends AbstractAction implements Action { } @Override - public void doOn(Player player, Player another) { + public void doOn(Player player, Player another, @Nullable FishMeta fishMeta) { if (!canExecute()) return; SkillInterface skillInterface = CustomFishing.getInstance().getIntegrationManager().getSkillInterface(); if (skillInterface == null) return; diff --git a/src/main/java/net/momirealms/customfishing/fishing/action/SoundActionImpl.java b/src/main/java/net/momirealms/customfishing/fishing/action/SoundActionImpl.java index 3865677a..0e9bfe42 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/action/SoundActionImpl.java +++ b/src/main/java/net/momirealms/customfishing/fishing/action/SoundActionImpl.java @@ -19,8 +19,10 @@ package net.momirealms.customfishing.fishing.action; import net.kyori.adventure.key.Key; import net.kyori.adventure.sound.Sound; +import net.momirealms.customfishing.fishing.FishMeta; import net.momirealms.customfishing.util.AdventureUtils; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; public class SoundActionImpl extends AbstractAction implements Action { @@ -38,7 +40,7 @@ public class SoundActionImpl extends AbstractAction implements Action { } @Override - public void doOn(Player player, Player another) { + public void doOn(Player player, Player another, @Nullable FishMeta fishMeta) { AdventureUtils.playerSound(player, source, key, volume, pitch); } } diff --git a/src/main/java/net/momirealms/customfishing/fishing/action/VanillaXPImpl.java b/src/main/java/net/momirealms/customfishing/fishing/action/VanillaXPImpl.java index 98b678a4..afa8c6b4 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/action/VanillaXPImpl.java +++ b/src/main/java/net/momirealms/customfishing/fishing/action/VanillaXPImpl.java @@ -20,9 +20,11 @@ package net.momirealms.customfishing.fishing.action; import net.kyori.adventure.key.Key; import net.kyori.adventure.sound.Sound; import net.momirealms.customfishing.CustomFishing; +import net.momirealms.customfishing.fishing.FishMeta; import net.momirealms.customfishing.util.AdventureUtils; import org.bukkit.entity.ExperienceOrb; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; public class VanillaXPImpl extends AbstractAction implements Action { @@ -36,7 +38,7 @@ public class VanillaXPImpl extends AbstractAction implements Action { } @Override - public void doOn(Player player, Player another) { + public void doOn(Player player, Player another, @Nullable FishMeta fishMeta) { if (CustomFishing.getInstance().getVersionHelper().isSpigot()) { if (mending) { player.getLocation().getWorld().spawn(player.getLocation(), ExperienceOrb.class, e -> e.setExperience(amount)); diff --git a/src/main/java/net/momirealms/customfishing/fishing/competition/Competition.java b/src/main/java/net/momirealms/customfishing/fishing/competition/Competition.java index b5495187..3aedada3 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/competition/Competition.java +++ b/src/main/java/net/momirealms/customfishing/fishing/competition/Competition.java @@ -169,7 +169,7 @@ public class Competition { Player player = Bukkit.getPlayer(playerName); if (player != null){ for (Action action : rewardsMap.get(String.valueOf(i))) { - action.doOn(player, null); + action.doOn(player); } } i++; @@ -180,7 +180,7 @@ public class Competition { Player player = Bukkit.getPlayer(playerName); if (player != null){ for (Action action : actions) { - action.doOn(player, null); + action.doOn(player); } } }); diff --git a/src/main/java/net/momirealms/customfishing/integration/season/CustomCropsSeasonImpl.java b/src/main/java/net/momirealms/customfishing/integration/season/CustomCropsSeasonImpl.java index 19668d2a..7ec54c10 100644 --- a/src/main/java/net/momirealms/customfishing/integration/season/CustomCropsSeasonImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/season/CustomCropsSeasonImpl.java @@ -17,13 +17,22 @@ package net.momirealms.customfishing.integration.season; -import net.momirealms.customcrops.CustomCrops; +import net.momirealms.customcrops.api.CustomCropsAPI; import net.momirealms.customfishing.integration.SeasonInterface; import org.bukkit.World; +import java.util.Objects; + public class CustomCropsSeasonImpl implements SeasonInterface { + + private final CustomCropsAPI customCropsAPI; + + public CustomCropsSeasonImpl() { + customCropsAPI = CustomCropsAPI.getInstance(); + } + @Override public String getSeason(World world) { - return CustomCrops.getInstance().getSeasonManager().getSeason(world.getName()).name(); + return Objects.requireNonNull(customCropsAPI.getSeason(world.getName())).getSeason(); } } \ No newline at end of file diff --git a/src/main/java/net/momirealms/customfishing/integration/skill/MMOCoreImpl.java b/src/main/java/net/momirealms/customfishing/integration/skill/MMOCoreImpl.java index a5f11d80..719427e4 100644 --- a/src/main/java/net/momirealms/customfishing/integration/skill/MMOCoreImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/skill/MMOCoreImpl.java @@ -18,6 +18,7 @@ package net.momirealms.customfishing.integration.skill; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.experience.EXPSource; import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmocore.manager.data.PlayerDataManager; @@ -27,22 +28,20 @@ import org.bukkit.entity.Player; public class MMOCoreImpl implements SkillInterface { private final Profession profession; - private final PlayerDataManager playerDataManager; public MMOCoreImpl(String name) { profession = MMOCore.plugin.professionManager.get(name); - playerDataManager = MMOCore.plugin.dataProvider.getDataManager(); } @Override public void addXp(Player player, double amount) { if (profession != null) { - profession.giveExperience(playerDataManager.get(player), amount, null ,EXPSource.OTHER); + profession.giveExperience(PlayerData.get(player), amount, null ,EXPSource.OTHER); } } @Override public int getLevel(Player player) { - return playerDataManager.get(player).getLevel(); + return PlayerData.get(player).getCollectionSkills().getLevel(profession); } } \ No newline at end of file diff --git a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java index 3cc0472f..279504db 100644 --- a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java @@ -50,6 +50,7 @@ import net.momirealms.customfishing.integration.MobInterface; import net.momirealms.customfishing.integration.item.McMMOTreasure; import net.momirealms.customfishing.listener.*; import net.momirealms.customfishing.object.Function; +import net.momirealms.customfishing.object.Pair; import net.momirealms.customfishing.object.SimpleLocation; import net.momirealms.customfishing.util.AdventureUtils; import net.momirealms.customfishing.util.FakeItemUtils; @@ -515,27 +516,29 @@ public class FishingManager extends Function { } private void dropCustomFishingLoot(Player player, Location location, DroppedItem droppedItem, boolean isDouble, double scoreMultiplier, double sizeMultiplier) { - ItemStack drop = getCustomFishingLootItemStack(droppedItem, player, sizeMultiplier); - FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_SPECIAL_ITEM, isDouble, drop, droppedItem.getKey(), droppedItem); + Pair dropPair = getCustomFishingLootItemStack(droppedItem, player, sizeMultiplier); + FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_SPECIAL_ITEM, isDouble, dropPair.left(), droppedItem.getKey(), droppedItem); Bukkit.getPluginManager().callEvent(fishResultEvent); if (fishResultEvent.isCancelled()) { return; } if (Competition.currentCompetition != null) { - float score = Competition.currentCompetition.getGoal() == CompetitionGoal.MAX_SIZE || Competition.currentCompetition.getGoal() == CompetitionGoal.TOTAL_SIZE ? getSize(drop) : (float) ((float) droppedItem.getScore() * scoreMultiplier); + float score = Competition.currentCompetition.getGoal() == CompetitionGoal.MAX_SIZE + || Competition.currentCompetition.getGoal() == CompetitionGoal.TOTAL_SIZE + ? dropPair.right().size() : (float) ((float) droppedItem.getScore() * scoreMultiplier); Competition.currentCompetition.refreshData(player, score, fishResultEvent.isDouble()); Competition.currentCompetition.tryJoinCompetition(player); } if (droppedItem.getSuccessActions() != null) for (Action action : droppedItem.getSuccessActions()) - action.doOn(player, null); + action.doOn(player, null, dropPair.right()); if (plugin.getVersionHelper().isFolia()) { - plugin.getScheduler().runTask(() -> dropItem(player, location, fishResultEvent.isDouble(), drop), location); + plugin.getScheduler().runTask(() -> dropItem(player, location, fishResultEvent.isDouble(), dropPair.left()), location); } else { - dropItem(player, location, fishResultEvent.isDouble(), drop); + dropItem(player, location, fishResultEvent.isDouble(), dropPair.left()); } addStats(player, droppedItem, isDouble ? 2 : 1); @@ -543,11 +546,12 @@ public class FishingManager extends Function { } public ItemStack getCustomFishingLootItemStack(DroppedItem droppedItem, Player player) { - return getCustomFishingLootItemStack(droppedItem, player, 1); + return getCustomFishingLootItemStack(droppedItem, player, 1).left(); } - public ItemStack getCustomFishingLootItemStack(DroppedItem droppedItem, @Nullable Player player, double sizeMultiplier) { + public Pair getCustomFishingLootItemStack(DroppedItem droppedItem, @Nullable Player player, double sizeMultiplier) { ItemStack drop = plugin.getIntegrationManager().build(droppedItem.getMaterial(), player); + FishMeta fishMeta = null; if (drop.getType() != Material.AIR) { if (droppedItem.getRandomEnchants() != null) ItemStackUtils.addRandomEnchants(drop, droppedItem.getRandomEnchants()); @@ -555,9 +559,9 @@ public class FishingManager extends Function { ItemStackUtils.addRandomDamage(drop); if (ConfigManager.preventPickUp && player != null) ItemStackUtils.addOwner(drop, player.getName()); - ItemStackUtils.addExtraMeta(drop, droppedItem, sizeMultiplier, player); + fishMeta = ItemStackUtils.addExtraMeta(drop, droppedItem, sizeMultiplier, player); } - return drop; + return Pair.of(drop, fishMeta); } private boolean dropMcMMOLoot(Player player, Location location, boolean isDouble) { @@ -571,7 +575,7 @@ public class FishingManager extends Function { } doVanillaActions(player, location, itemStack, fishResultEvent.isDouble()); - new VanillaXPImpl(new Random().nextInt(24), true, 1).doOn(player, null); + new VanillaXPImpl(new Random().nextInt(24), true, 1).doOn(player); return true; } @@ -591,7 +595,7 @@ public class FishingManager extends Function { } doVanillaActions(player, location, itemStack, fishResultEvent.isDouble()); - new VanillaXPImpl(vanillaLoot.getXp(), true, 1).doOn(player, null); + new VanillaXPImpl(vanillaLoot.getXp(), true, 1).doOn(player); } private void doVanillaActions(Player player, Location location, ItemStack itemStack, boolean isDouble) { @@ -605,7 +609,7 @@ public class FishingManager extends Function { if (vanilla.getSuccessActions() != null) for (Action action : vanilla.getSuccessActions()) - action.doOn(player, null); + action.doOn(player); AdventureUtils.playerSound(player, Sound.Source.PLAYER, Key.key("minecraft:entity.experience_orb.pickup"), 1, 1); @@ -654,7 +658,7 @@ public class FishingManager extends Function { if (loot.getSuccessActions() != null) for (Action action : loot.getSuccessActions()) - action.doOn(player, null); + action.doOn(player); mobInterface.summon(player.getLocation(), location, mob); addStats(player, mob, 1); @@ -740,7 +744,7 @@ public class FishingManager extends Function { if (!isVanilla && loot != null && loot.getFailureActions() != null) { for (Action action : loot.getFailureActions()) - action.doOn(player, null); + action.doOn(player); } if (!ConfigManager.enableFailureTitle) return; @@ -766,7 +770,13 @@ public class FishingManager extends Function { public boolean isCoolDown(Player player, long delay) { long time = System.currentTimeMillis(); - return coolDown.computeIfAbsent(player.getUniqueId(), k -> time - delay) + delay > time; + long last = coolDown.getOrDefault(player.getUniqueId(), time - delay); + if (last + delay > time) { + return true; + } else { + coolDown.put(player.getUniqueId(), time); + return false; + } } private void addEnchantEffect(Effect initialEffect, ItemStack itemStack, FishingCondition fishingCondition) { @@ -849,7 +859,7 @@ public class FishingManager extends Function { if (player.getGameMode() != GameMode.CREATIVE) itemStack.setAmount(itemStack.getAmount() - 1); if (totem.getActivatorActions() != null) for (Action action : totem.getActivatorActions()) { - action.doOn(player, null); + action.doOn(player); } if (totem.getNearbyActions() != null) for (Action action : totem.getNearbyActions()) { @@ -913,7 +923,7 @@ public class FishingManager extends Function { } if (loot.getHookActions() != null) { for (Action action : loot.getHookActions()) { - action.doOn(player, null); + action.doOn(player); } } player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, game.getTime() * 20,3)); @@ -1019,7 +1029,7 @@ public class FishingManager extends Function { final Player player = event.getPlayer(); if (droppedItem.getConsumeActions() != null) for (Action action : droppedItem.getConsumeActions()) - action.doOn(player, null); + action.doOn(player); } public Effect getInitialEffect(Player player) { diff --git a/src/main/java/net/momirealms/customfishing/util/ItemStackUtils.java b/src/main/java/net/momirealms/customfishing/util/ItemStackUtils.java index b140da5e..8c6b76d0 100644 --- a/src/main/java/net/momirealms/customfishing/util/ItemStackUtils.java +++ b/src/main/java/net/momirealms/customfishing/util/ItemStackUtils.java @@ -23,6 +23,7 @@ import de.tr7zw.changeme.nbtapi.NBTListCompound; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customfishing.CustomFishing; +import net.momirealms.customfishing.fishing.FishMeta; import net.momirealms.customfishing.fishing.loot.DroppedItem; import net.momirealms.customfishing.fishing.loot.Item; import net.momirealms.customfishing.fishing.loot.LootImpl; @@ -230,7 +231,7 @@ public class ItemStackUtils { return true; } - public static void addExtraMeta(ItemStack itemStack, DroppedItem droppedItem, double sizeMultiplier, Player player) { + public static FishMeta addExtraMeta(ItemStack itemStack, DroppedItem droppedItem, double sizeMultiplier, Player player) { NBTItem nbtItem = new NBTItem(itemStack); if (droppedItem.getBasicPrice() != 0) { NBTCompound fishMetaCompound = nbtItem.addCompound("FishMeta"); @@ -240,24 +241,26 @@ public class ItemStackUtils { NBTCompound fishMetaCompound = nbtItem.addCompound("FishMeta"); fishMetaCompound.setFloat("bonus", droppedItem.getSizeBonus()); } - replaceAndSetSizeProperties(droppedItem.getSize(), nbtItem, sizeMultiplier); + float size = replaceAndSetSizeProperties(droppedItem.getSize(), nbtItem, sizeMultiplier); replacePlaceholderInDisplay(nbtItem, player); itemStack.setItemMeta(nbtItem.getItem().getItemMeta()); + return new FishMeta(size, droppedItem.getBasicPrice(), droppedItem.getSizeBonus()); } - private static void replaceAndSetSizeProperties(String[] sizes, NBTItem nbtItem, double sizeMultiplier) { - if (sizes == null) return; + private static float replaceAndSetSizeProperties(String[] sizes, NBTItem nbtItem, double sizeMultiplier) { + if (sizes == null) return -1; float min = Float.parseFloat(sizes[0]); float max = Float.parseFloat(sizes[1]); - if (max - min < 0) return; + if (max - min < 0) return -1; float size = (float) ((min + Math.random() * (max - min)) * sizeMultiplier); String sizeText = String.format("%.1f", size); NBTCompound nbtCompound = nbtItem.getCompound("display"); - if (nbtCompound == null || !nbtCompound.hasTag("Lore")) return; + if (nbtCompound == null || !nbtCompound.hasTag("Lore")) return size; List lore = nbtCompound.getStringList("Lore"); lore.replaceAll(s -> s.replace("{size}", sizeText)); NBTCompound fishMetaCompound = nbtItem.addCompound("FishMeta"); fishMetaCompound.setFloat("size", size); + return size; } private static void replacePlaceholderInDisplay(NBTItem nbtItem, Player player) {