mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-28 03:19:12 +00:00
1.3.2.2
This commit is contained in:
23
build.gradle
23
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')
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/CustomCrops-api-3.3.1.2.jar
Normal file
BIN
libs/CustomCrops-api-3.3.1.2.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/Vault.jar
BIN
libs/Vault.jar
Binary file not shown.
Binary file not shown.
@@ -85,7 +85,7 @@ public class PlayerStatisticsData {
|
||||
for (Map.Entry<Integer, Action[]> entry : actionMap.entrySet()) {
|
||||
if (entry.getKey() > previous && entry.getKey() <= after) {
|
||||
for (Action action : entry.getValue()) {
|
||||
action.doOn(player, null);
|
||||
action.doOn(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.momirealms.customfishing.fishing;
|
||||
|
||||
public record FishMeta(float size, float base, float bonus) {
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<ItemStack, FishMeta> 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<ItemStack, FishMeta> 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) {
|
||||
|
||||
@@ -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<String> 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) {
|
||||
|
||||
Reference in New Issue
Block a user