9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-26 18:39:11 +00:00

fish finder

This commit is contained in:
XiaoMoMi
2023-09-10 18:59:24 +08:00
parent 4741e383a1
commit 54da6fe236
32 changed files with 330 additions and 132 deletions

View File

@@ -43,9 +43,10 @@ import net.momirealms.customfishing.mechanic.mob.MobManagerImpl;
import net.momirealms.customfishing.mechanic.requirement.RequirementManagerImpl;
import net.momirealms.customfishing.mechanic.statistic.StatisticsManagerImpl;
import net.momirealms.customfishing.scheduler.SchedulerImpl;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.Locale;
import net.momirealms.customfishing.setting.CFConfig;
import net.momirealms.customfishing.setting.CFLocale;
import net.momirealms.customfishing.storage.StorageManagerImpl;
import net.momirealms.customfishing.mechanic.misc.CoolDownManager;
import net.momirealms.customfishing.version.VersionManagerImpl;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -58,6 +59,7 @@ import java.util.TimeZone;
public class CustomFishingPluginImpl extends CustomFishingPlugin {
private static ProtocolManager protocolManager;
private CoolDownManager coolDownManager;
public CustomFishingPluginImpl() {
super();
@@ -94,8 +96,9 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin {
this.competitionManager = new CompetitionManagerImpl(this);
this.integrationManager = new IntegrationManagerImpl(this);
this.statisticsManager = new StatisticsManagerImpl(this);
this.coolDownManager = new CoolDownManager(this);
this.reload();
if (Config.updateChecker)
if (CFConfig.updateChecker)
this.versionManager.checkUpdate().thenAccept(result -> {
if (!result) this.getAdventure().sendConsoleMessage("[CustomFishing] You are using the latest version.");
else this.getAdventure().sendConsoleMessage("[CustomFishing] Update is available: <u>https://polymart.org/resource/customfishing.2723<!u>");
@@ -122,12 +125,14 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin {
((PlaceholderManagerImpl) this.placeholderManager).disable();
((StatisticsManagerImpl) this.statisticsManager).disable();
((ActionManagerImpl) this.actionManager).disable();
this.coolDownManager.disable();
this.commandManager.unload();
}
@Override
public void reload() {
Config.load();
Locale.load();
CFConfig.load();
CFLocale.load();
((SchedulerImpl) this.scheduler).reload();
((RequirementManagerImpl) this.requirementManager).unload();
((RequirementManagerImpl) this.requirementManager).load();
@@ -160,6 +165,8 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin {
((PlaceholderManagerImpl) this.placeholderManager).load();
this.commandManager.unload();
this.commandManager.load();
this.coolDownManager.unload();
this.coolDownManager.load();
}
private void loadDependencies() {
@@ -233,7 +240,11 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin {
}
public void debug(String message) {
if (!Config.debug) return;
if (!CFConfig.debug) return;
LogUtils.info(message);
}
public CoolDownManager getCoolDownManager() {
return coolDownManager;
}
}

View File

@@ -29,8 +29,8 @@ import net.kyori.adventure.title.Title;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.manager.AdventureManager;
import net.momirealms.customfishing.api.util.ReflectionUtils;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.Locale;
import net.momirealms.customfishing.setting.CFConfig;
import net.momirealms.customfishing.setting.CFLocale;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
@@ -60,7 +60,7 @@ public class AdventureManagerImpl implements AdventureManager {
@Override
public Component getComponentFromMiniMessage(String text) {
if (Config.legacyColorSupport) {
if (CFConfig.legacyColorSupport) {
return MiniMessage.miniMessage().deserialize(legacyToMiniMessage(text));
} else {
return MiniMessage.miniMessage().deserialize(text);
@@ -77,8 +77,8 @@ public class AdventureManagerImpl implements AdventureManager {
@Override
public void sendMessageWithPrefix(CommandSender sender, String s) {
if (s == null) return;
if (sender instanceof Player player) sendPlayerMessage(player, Locale.MSG_Prefix + s);
else if (sender instanceof ConsoleCommandSender) sendConsoleMessage(Locale.MSG_Prefix + s);
if (sender instanceof Player player) sendPlayerMessage(player, CFLocale.MSG_Prefix + s);
else if (sender instanceof ConsoleCommandSender) sendConsoleMessage(CFLocale.MSG_Prefix + s);
}
@Override

View File

@@ -25,7 +25,7 @@ import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.manager.CommandManager;
import net.momirealms.customfishing.api.util.LogUtils;
import net.momirealms.customfishing.command.sub.*;
import net.momirealms.customfishing.setting.Locale;
import net.momirealms.customfishing.setting.CFLocale;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
@@ -80,7 +80,7 @@ public class CommandManagerImpl implements CommandManager {
.executes((sender, args) -> {
long time = System.currentTimeMillis();
plugin.reload();
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, Locale.MSG_Reload.replace("{time}", String.valueOf(System.currentTimeMillis()-time)));
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_Reload.replace("{time}", String.valueOf(System.currentTimeMillis()-time)));
});
}
@@ -96,7 +96,7 @@ public class CommandManagerImpl implements CommandManager {
assert players != null;
for (Player player : players) {
plugin.getMarketManager().openMarketGUI(player);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, Locale.MSG_Market_GUI_Open.replace("{player}", player.getName()));
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_Market_GUI_Open.replace("{player}", player.getName()));
}
}));
}
@@ -111,7 +111,7 @@ public class CommandManagerImpl implements CommandManager {
Inventory inventory = plugin.getBagManager().getOnlineBagInventory(player.getUniqueId());
if (inventory != null) {
player.openInventory(inventory);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, Locale.MSG_Market_GUI_Open.replace("{player}", player.getName()));
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_Fishing_Bag_Open.replace("{player}", player.getName()));
} else {
LogUtils.warn("Player " + player.getName() + "'s bag data has not been loaded.");
}

View File

@@ -23,8 +23,8 @@ import dev.jorel.commandapi.arguments.StringArgument;
import net.momirealms.customfishing.adventure.AdventureManagerImpl;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.Locale;
import net.momirealms.customfishing.setting.CFConfig;
import net.momirealms.customfishing.setting.CFLocale;
import net.momirealms.customfishing.storage.method.database.nosql.RedisManager;
import java.util.Set;
@@ -52,12 +52,12 @@ public class CompetitionCommand {
ArgumentSuggestions.strings(allCompetitions)
)
);
if (Config.redisRanking) command.withOptionalArguments(new StringArgument("-allservers"));
if (CFConfig.redisRanking) command.withOptionalArguments(new StringArgument("-allservers"));
command.executes((sender, args) -> {
String id = (String) args.get(0);
assert id != null;
if (!allCompetitions.contains(id)) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, Locale.MSG_Competition_Not_Exist.replace("{id}", id));
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_Competition_Not_Exist.replace("{id}", id));
return;
}
boolean allServer = args.getOrDefault(1, "").equals("-allservers");
@@ -68,7 +68,7 @@ public class CompetitionCommand {
private CommandAPICommand getCompetitionEndCommand() {
var command = new CommandAPICommand("end");
if (Config.redisRanking) command.withOptionalArguments(new StringArgument("-allservers"));
if (CFConfig.redisRanking) command.withOptionalArguments(new StringArgument("-allservers"));
command.executes((sender, args) -> {
boolean allServer = args.getOrDefault(1, "").equals("-allservers");
if (allServer) {
@@ -77,9 +77,9 @@ public class CompetitionCommand {
FishingCompetition competition = CustomFishingPlugin.get().getCompetitionManager().getOnGoingCompetition();
if (competition != null) {
competition.end();
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, Locale.MSG_End_Competition);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_End_Competition);
} else {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, Locale.MSG_No_Competition_Ongoing);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_No_Competition_Ongoing);
}
}
});
@@ -88,7 +88,7 @@ public class CompetitionCommand {
private CommandAPICommand getCompetitionStopCommand() {
var command = new CommandAPICommand("stop");
if (Config.redisRanking) command.withOptionalArguments(new StringArgument("-allservers"));
if (CFConfig.redisRanking) command.withOptionalArguments(new StringArgument("-allservers"));
command.executes((sender, args) -> {
boolean allServer = args.getOrDefault(1, "").equals("-allservers");
if (allServer) {
@@ -97,9 +97,9 @@ public class CompetitionCommand {
FishingCompetition competition = CustomFishingPlugin.get().getCompetitionManager().getOnGoingCompetition();
if (competition != null) {
competition.stop();
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, Locale.MSG_Stop_Competition);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_Stop_Competition);
} else {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, Locale.MSG_No_Competition_Ongoing);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_No_Competition_Ongoing);
}
}
});

View File

@@ -20,11 +20,10 @@ package net.momirealms.customfishing.command.sub;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.arguments.PlayerArgument;
import dev.jorel.commandapi.arguments.UUIDArgument;
import net.momirealms.customfishing.CustomFishingPluginImpl;
import net.momirealms.customfishing.adventure.AdventureManagerImpl;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.data.user.OfflineUser;
import net.momirealms.customfishing.setting.Locale;
import net.momirealms.customfishing.setting.CFLocale;
import net.momirealms.customfishing.storage.user.OfflineUserImpl;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -46,7 +45,7 @@ public class FishingBagCommand {
if (inv != null) {
player.openInventory(inv);
} else {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, Locale.MSG_Data_Not_Loaded);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CFLocale.MSG_Data_Not_Loaded);
}
}
}));
@@ -82,12 +81,12 @@ public class FishingBagCommand {
}
CustomFishingPlugin.get().getStorageManager().getOfflineUser(uuid, false).thenAccept(optional -> {
if (optional.isEmpty()) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, Locale.MSG_Never_Played);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CFLocale.MSG_Never_Played);
return;
}
OfflineUser offlineUser = optional.get();
if (offlineUser == OfflineUserImpl.LOCKED_USER) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, Locale.MSG_Unsafe_Modification);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CFLocale.MSG_Unsafe_Modification);
return;
}
CustomFishingPlugin.get().getScheduler().runTaskSync(() -> {

View File

@@ -28,7 +28,7 @@ import net.momirealms.customfishing.api.common.Key;
import net.momirealms.customfishing.api.mechanic.condition.Condition;
import net.momirealms.customfishing.api.mechanic.item.BuildableItem;
import net.momirealms.customfishing.mechanic.item.ItemManagerImpl;
import net.momirealms.customfishing.setting.Locale;
import net.momirealms.customfishing.setting.CFLocale;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -81,9 +81,9 @@ public class ItemCommand {
ItemStack item = CustomFishingPlugin.get().getItemManager().build(player, namespace, id, new Condition(player).getArgs());
if (item != null) {
int actual = ItemManagerImpl.giveCertainAmountOfItem(player, item, amount);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, Locale.MSG_Get_Item.replace("{item}", id).replace("{amount}", String.valueOf(actual)));
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CFLocale.MSG_Get_Item.replace("{item}", id).replace("{amount}", String.valueOf(actual)));
} else {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, Locale.MSG_Item_Not_Exists);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CFLocale.MSG_Item_Not_Exists);
}
});
}
@@ -107,10 +107,10 @@ public class ItemCommand {
for (Player player : players) {
ItemStack item = CustomFishingPlugin.get().getItemManager().build(player, namespace, id, new Condition(player).getArgs());
int actual = ItemManagerImpl.giveCertainAmountOfItem(player, item, amount);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, Locale.MSG_Give_Item.replace("{item}", id).replace("{amount}", String.valueOf(actual)).replace("{player}", player.getName()));
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_Give_Item.replace("{item}", id).replace("{amount}", String.valueOf(actual)).replace("{player}", player.getName()));
}
} else {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, Locale.MSG_Item_Not_Exists);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_Item_Not_Exists);
}
});
}

View File

@@ -20,7 +20,7 @@ package net.momirealms.customfishing.compatibility.papi;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
import net.momirealms.customfishing.setting.Locale;
import net.momirealms.customfishing.setting.CFLocale;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -73,22 +73,22 @@ public class CompetitionPapi extends PlaceholderExpansion {
return String.valueOf(plugin.getCompetitionManager().getNextCompetitionSeconds());
}
case "nextsecond" -> {
return plugin.getCompetitionManager().getNextCompetitionSeconds() % 60 + Locale.FORMAT_Second;
return plugin.getCompetitionManager().getNextCompetitionSeconds() % 60 + CFLocale.FORMAT_Second;
}
case "nextminute" -> {
int sec = plugin.getCompetitionManager().getNextCompetitionSeconds();
int min = (sec % 3600) / 60;
return sec < 60 ? "" : min + Locale.FORMAT_Minute;
return sec < 60 ? "" : min + CFLocale.FORMAT_Minute;
}
case "nexthour" -> {
int sec = plugin.getCompetitionManager().getNextCompetitionSeconds();
int h = (sec % (3600 * 24)) / 3600;
return sec < 3600 ? "" : h + Locale.FORMAT_Hour;
return sec < 3600 ? "" : h + CFLocale.FORMAT_Hour;
}
case "nextday" -> {
int sec = plugin.getCompetitionManager().getNextCompetitionSeconds();
int day = sec / (3600 * 24);
return day == 0 ? "" : day + Locale.FORMAT_Day;
return day == 0 ? "" : day + CFLocale.FORMAT_Day;
}
case "rank" -> {
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();

View File

@@ -23,14 +23,17 @@ import net.momirealms.customfishing.adventure.AdventureManagerImpl;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.common.Pair;
import net.momirealms.customfishing.api.manager.ActionManager;
import net.momirealms.customfishing.api.manager.LootManager;
import net.momirealms.customfishing.api.mechanic.GlobalSettings;
import net.momirealms.customfishing.api.mechanic.action.Action;
import net.momirealms.customfishing.api.mechanic.action.ActionExpansion;
import net.momirealms.customfishing.api.mechanic.action.ActionFactory;
import net.momirealms.customfishing.api.mechanic.action.ActionTrigger;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
import net.momirealms.customfishing.api.util.LogUtils;
import net.momirealms.customfishing.compatibility.papi.PlaceholderManagerImpl;
import net.momirealms.customfishing.setting.CFLocale;
import net.momirealms.customfishing.util.ArmorStandUtils;
import net.momirealms.customfishing.util.ClassUtils;
import net.momirealms.customfishing.util.ConfigUtils;
@@ -81,6 +84,7 @@ public class ActionManagerImpl implements ActionManager {
this.registerLevelAction();
this.registerHologramAction();
this.registerFakeItemAction();
this.registerFishFindAction();
}
public void load() {
@@ -478,7 +482,7 @@ public class ActionManagerImpl implements ActionManager {
registerAction("conditional", (args, chance) -> {
if (args instanceof ConfigurationSection section) {
Action[] actions = getActions(section.getConfigurationSection("actions"));
Requirement[] requirements = plugin.getRequirementManager().getRequirements(section.getConfigurationSection("conditions"), false);
Requirement[] requirements = plugin.getRequirementManager().getRequirements(section.getConfigurationSection("conditions"), true);
return condition -> {
if (Math.random() > chance) return;
if (requirements != null)
@@ -549,6 +553,24 @@ public class ActionManagerImpl implements ActionManager {
});
}
private void registerFishFindAction() {
registerAction("fish-finder", (args, chance) -> {
boolean arg = (boolean) args;
return condition -> {
if (Math.random() > chance) return;
condition.insertArg("{lava}", String.valueOf(arg));
LootManager lootManager = plugin.getLootManager();
List<String> loots = plugin.getFishingManager().getPossibleLootKeys(condition).stream().map(lootManager::getLoot).filter(Objects::nonNull).filter(Loot::showInFinder).map(Loot::getNick).toList();
StringJoiner stringJoiner = new StringJoiner(CFLocale.MSG_Split_Char);
for (String loot : loots) {
stringJoiner.add(loot);
}
condition.delArg("{lava}");
AdventureManagerImpl.getInstance().sendMessageWithPrefix(condition.getPlayer(), CFLocale.MSG_Possible_Loots + stringJoiner);
};
});
}
@SuppressWarnings("ResultOfMethodCallIgnored")
private void loadExpansions() {
File expansionFolder = new File(plugin.getDataFolder(), EXPANSION_FOLDER);

View File

@@ -22,8 +22,7 @@ import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.data.user.OfflineUser;
import net.momirealms.customfishing.api.manager.BagManager;
import net.momirealms.customfishing.api.mechanic.bag.FishingBagHolder;
import net.momirealms.customfishing.api.mechanic.condition.Condition;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.CFConfig;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -51,7 +50,7 @@ public class BagManagerImpl implements BagManager, Listener {
@Override
public boolean isEnabled() {
return Config.enableFishingBag;
return CFConfig.enableFishingBag;
}
public void load() {
@@ -105,7 +104,7 @@ public class BagManagerImpl implements BagManager, Listener {
ItemStack clickedItem = event.getCurrentItem();
if (clickedItem == null || clickedItem.getType() == Material.AIR)
return;
if (Config.bagWhiteListItems.contains(clickedItem.getType()))
if (CFConfig.bagWhiteListItems.contains(clickedItem.getType()))
return;
String id = plugin.getItemManager().getAnyItemID(clickedItem);
if (plugin.getEffectManager().getEffect("rod", id) != null)
@@ -114,7 +113,7 @@ public class BagManagerImpl implements BagManager, Listener {
return;
if (plugin.getEffectManager().getEffect("util", id) != null)
return;
if (Config.bagStoreLoots && plugin.getLootManager().getLoot(id) != null)
if (CFConfig.bagStoreLoots && plugin.getLootManager().getLoot(id) != null)
return;
event.setCancelled(true);
}

View File

@@ -30,8 +30,8 @@ import net.momirealms.customfishing.mechanic.competition.actionbar.ActionBarMana
import net.momirealms.customfishing.mechanic.competition.bossbar.BossBarManager;
import net.momirealms.customfishing.mechanic.competition.ranking.LocalRankingImpl;
import net.momirealms.customfishing.mechanic.competition.ranking.RedisRankingImpl;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.Locale;
import net.momirealms.customfishing.setting.CFConfig;
import net.momirealms.customfishing.setting.CFLocale;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@@ -59,7 +59,7 @@ public class Competition implements FishingCompetition {
public Competition(CompetitionConfig config) {
this.config = config;
this.goal = config.getGoal() == CompetitionGoal.RANDOM ? CompetitionGoal.getRandom() : config.getGoal();
if (Config.redisRanking) this.ranking = new RedisRankingImpl();
if (CFConfig.redisRanking) this.ranking = new RedisRankingImpl();
else this.ranking = new LocalRankingImpl();
this.publicPlaceholders = new ConcurrentHashMap<>();
this.publicPlaceholders.put("{goal}", CustomFishingPlugin.get().getCompetitionManager().getCompetitionLocale(goal));
@@ -103,19 +103,19 @@ public class Competition implements FishingCompetition {
}
private void updatePublicPlaceholders() {
for (int i = 1; i < Config.placeholderLimit + 1; i++) {
for (int i = 1; i < CFConfig.placeholderLimit + 1; i++) {
int finalI = i;
Optional.ofNullable(ranking.getPlayerAt(i)).ifPresentOrElse(player -> {
publicPlaceholders.put("{" + finalI + "_player}", player);
publicPlaceholders.put("{" + finalI + "_score}", String.format("%.2f", ranking.getScoreAt(finalI)));
}, () -> {
publicPlaceholders.put("{" + finalI + "_player}", Locale.MSG_No_Player);
publicPlaceholders.put("{" + finalI + "_score}", Locale.MSG_No_Score);
publicPlaceholders.put("{" + finalI + "_player}", CFLocale.MSG_No_Player);
publicPlaceholders.put("{" + finalI + "_score}", CFLocale.MSG_No_Score);
});
}
publicPlaceholders.put("{hour}", remainingTime < 3600 ? "" : (remainingTime / 3600) + Locale.FORMAT_Hour);
publicPlaceholders.put("{minute}", remainingTime < 60 ? "" : (remainingTime % 3600) / 60 + Locale.FORMAT_Minute);
publicPlaceholders.put("{second}", remainingTime == 0 ? "" : remainingTime % 60 + Locale.FORMAT_Second);
publicPlaceholders.put("{hour}", remainingTime < 3600 ? "" : (remainingTime / 3600) + CFLocale.FORMAT_Hour);
publicPlaceholders.put("{minute}", remainingTime < 60 ? "" : (remainingTime % 3600) / 60 + CFLocale.FORMAT_Minute);
publicPlaceholders.put("{second}", remainingTime == 0 ? "" : remainingTime % 60 + CFLocale.FORMAT_Second);
publicPlaceholders.put("{seconds}", String.valueOf(remainingTime));
}

View File

@@ -25,7 +25,8 @@ import net.momirealms.customfishing.api.mechanic.competition.*;
import net.momirealms.customfishing.api.mechanic.condition.Condition;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import net.momirealms.customfishing.api.util.LogUtils;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.CFLocale;
import net.momirealms.customfishing.setting.CFConfig;
import net.momirealms.customfishing.storage.method.database.nosql.RedisManager;
import org.bukkit.Bukkit;
import org.bukkit.boss.BarColor;
@@ -205,16 +206,16 @@ public class CompetitionManagerImpl implements CompetitionManager {
public String getCompetitionLocale(CompetitionGoal goal) {
switch (goal) {
case MAX_SIZE -> {
return net.momirealms.customfishing.setting.Locale.MSG_Max_Size;
return CFLocale.MSG_Max_Size;
}
case CATCH_AMOUNT -> {
return net.momirealms.customfishing.setting.Locale.MSG_Catch_Amount;
return CFLocale.MSG_Catch_Amount;
}
case TOTAL_SCORE -> {
return net.momirealms.customfishing.setting.Locale.MSG_Total_Score;
return CFLocale.MSG_Total_Score;
}
case TOTAL_SIZE -> {
return net.momirealms.customfishing.setting.Locale.MSG_Total_Size;
return CFLocale.MSG_Total_Size;
}
}
return "";
@@ -280,7 +281,7 @@ public class CompetitionManagerImpl implements CompetitionManager {
@Override
public CompletableFuture<Integer> getPlayerCount() {
if (!Config.redisRanking) {
if (!CFConfig.redisRanking) {
return CompletableFuture.completedFuture(Bukkit.getOnlinePlayers().size());
} else {
return plugin.getStorageManager().getRedisPlayerCount();

View File

@@ -22,7 +22,7 @@ import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.mechanic.competition.ActionBarConfig;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import net.momirealms.customfishing.mechanic.competition.Competition;
import net.momirealms.customfishing.setting.Locale;
import net.momirealms.customfishing.setting.CFLocale;
import net.momirealms.customfishing.util.DynamicText;
import org.bukkit.entity.Player;
@@ -63,7 +63,7 @@ public class ActionBarSender {
private void updatePrivatePlaceholders() {
this.privatePlaceholders.put("{score}", String.format("%.2f", competition.getRanking().getPlayerScore(player.getName())));
int rank = competition.getRanking().getPlayerRank(player.getName());
this.privatePlaceholders.put("{rank}", rank != -1 ? String.valueOf(rank) : Locale.MSG_No_Rank);
this.privatePlaceholders.put("{rank}", rank != -1 ? String.valueOf(rank) : CFLocale.MSG_No_Rank);
this.privatePlaceholders.putAll(competition.getCachedPlaceholders());
}

View File

@@ -30,7 +30,7 @@ import net.momirealms.customfishing.api.mechanic.competition.BossBarConfig;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import net.momirealms.customfishing.api.util.ReflectionUtils;
import net.momirealms.customfishing.mechanic.competition.Competition;
import net.momirealms.customfishing.setting.Locale;
import net.momirealms.customfishing.setting.CFLocale;
import net.momirealms.customfishing.util.DynamicText;
import org.bukkit.boss.BarColor;
import org.bukkit.entity.Player;
@@ -76,7 +76,7 @@ public class BossBarSender {
private void updatePrivatePlaceholders() {
this.privatePlaceholders.put("{score}", String.format("%.2f", competition.getRanking().getPlayerScore(player.getName())));
int rank = competition.getRanking().getPlayerRank(player.getName());
this.privatePlaceholders.put("{rank}", rank != -1 ? String.valueOf(rank) : Locale.MSG_No_Rank);
this.privatePlaceholders.put("{rank}", rank != -1 ? String.valueOf(rank) : CFLocale.MSG_No_Rank);
this.privatePlaceholders.putAll(competition.getCachedPlaceholders());
}

View File

@@ -249,7 +249,7 @@ public class EffectManagerImpl implements EffectManager {
return ((effect, condition) -> effect.setLavaFishing(true));
}
case "conditional" -> {
Requirement[] requirements = plugin.getRequirementManager().getRequirements(section.getConfigurationSection("conditions"), false);
Requirement[] requirements = plugin.getRequirementManager().getRequirements(section.getConfigurationSection("conditions"), true);
EffectModifier[] modifiers = getEffectModifiers(section.getConfigurationSection("effects"));
return ((effect, condition) -> {
for (Requirement requirement : requirements)

View File

@@ -28,11 +28,13 @@ import net.momirealms.customfishing.api.manager.FishingManager;
import net.momirealms.customfishing.api.manager.RequirementManager;
import net.momirealms.customfishing.api.mechanic.GlobalSettings;
import net.momirealms.customfishing.api.mechanic.TempFishingState;
import net.momirealms.customfishing.api.mechanic.action.Action;
import net.momirealms.customfishing.api.mechanic.action.ActionTrigger;
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
import net.momirealms.customfishing.api.mechanic.condition.Condition;
import net.momirealms.customfishing.api.mechanic.condition.FishingPreparation;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import net.momirealms.customfishing.api.mechanic.effect.EffectCarrier;
import net.momirealms.customfishing.api.mechanic.effect.FishingEffect;
import net.momirealms.customfishing.api.mechanic.game.GameConfig;
import net.momirealms.customfishing.api.mechanic.game.GameInstance;
@@ -43,15 +45,13 @@ import net.momirealms.customfishing.api.mechanic.loot.WeightModifier;
import net.momirealms.customfishing.api.util.LogUtils;
import net.momirealms.customfishing.api.util.WeightUtils;
import net.momirealms.customfishing.mechanic.requirement.RequirementManagerImpl;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.CFConfig;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Statistic;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.*;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
@@ -107,37 +107,37 @@ public class FishingManagerImpl implements Listener, FishingManager {
@EventHandler(priority = EventPriority.MONITOR)
public void onFishMONITOR(PlayerFishEvent event) {
if (Config.eventPriority != EventPriority.MONITOR) return;
if (CFConfig.eventPriority != EventPriority.MONITOR) return;
this.selectState(event);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onFishHIGHEST(PlayerFishEvent event) {
if (Config.eventPriority != EventPriority.HIGHEST) return;
if (CFConfig.eventPriority != EventPriority.HIGHEST) return;
this.selectState(event);
}
@EventHandler(priority = EventPriority.HIGH)
public void onFishHIGH(PlayerFishEvent event) {
if (Config.eventPriority != EventPriority.HIGH) return;
if (CFConfig.eventPriority != EventPriority.HIGH) return;
this.selectState(event);
}
@EventHandler(priority = EventPriority.NORMAL)
public void onFishNORMAL(PlayerFishEvent event) {
if (Config.eventPriority != EventPriority.NORMAL) return;
if (CFConfig.eventPriority != EventPriority.NORMAL) return;
this.selectState(event);
}
@EventHandler(priority = EventPriority.LOW)
public void onFishLOW(PlayerFishEvent event) {
if (Config.eventPriority != EventPriority.LOW) return;
if (CFConfig.eventPriority != EventPriority.LOW) return;
this.selectState(event);
}
@EventHandler(priority = EventPriority.LOWEST)
public void onFishLOWEST(PlayerFishEvent event) {
if (Config.eventPriority != EventPriority.LOWEST) return;
if (CFConfig.eventPriority != EventPriority.LOWEST) return;
this.selectState(event);
}
@@ -213,6 +213,27 @@ public class FishingManagerImpl implements Listener, FishingManager {
}
}
@EventHandler
public void onInteractWithUtils(PlayerInteractEvent event) {
if (event.useItemInHand() == Event.Result.DENY)
return;
ItemStack itemStack = event.getPlayer().getInventory().getItemInMainHand();
if (itemStack.getType() == Material.AIR)
return;
String id = plugin.getItemManager().getAnyItemID(itemStack);
EffectCarrier carrier = plugin.getEffectManager().getEffect("util", id);
if (carrier == null)
return;
Condition condition = new Condition(event.getPlayer());
if (!RequirementManager.isRequirementsMet(carrier.getRequirements(), condition))
return;
Action[] actions = carrier.getActions(ActionTrigger.INTERACT);
if (actions != null)
for (Action action : actions) {
action.trigger(condition);
}
}
@Override
public boolean removeHook(UUID uuid) {
FishHook hook = hookCacheMap.remove(uuid);
@@ -365,7 +386,7 @@ public class FishingManagerImpl implements Listener, FishingManager {
return;
}
if (!Config.vanillaMechanicIfNoLoot) {
if (!CFConfig.vanillaMechanicIfNoLoot) {
event.setCancelled(true);
event.getHook().remove();
}
@@ -607,16 +628,16 @@ public class FishingManagerImpl implements Listener, FishingManager {
}
@Override
public Collection<String> getPossibleLootKeys (FishingPreparation fishingPreparation) {
return plugin.getRequirementManager().getLootWithWeight(fishingPreparation).keySet();
public Collection<String> getPossibleLootKeys (Condition condition) {
return plugin.getRequirementManager().getLootWithWeight(condition).keySet();
}
@NotNull
@Override
public Map<String, Double> getPossibleLootKeysWithWeight(Effect initialEffect, FishingPreparation fishingPreparation) {
Map<String, Double> lootWithWeight = plugin.getRequirementManager().getLootWithWeight(fishingPreparation);
public Map<String, Double> getPossibleLootKeysWithWeight(Effect initialEffect, Condition condition) {
Map<String, Double> lootWithWeight = plugin.getRequirementManager().getLootWithWeight(condition);
Player player = fishingPreparation.getPlayer();
Player player = condition.getPlayer();
for (Pair<String, WeightModifier> pair : initialEffect.getWeightModifier()) {
Double previous = lootWithWeight.get(pair.left());
if (previous != null)
@@ -631,8 +652,8 @@ public class FishingManagerImpl implements Listener, FishingManager {
@Override
@Nullable
public Loot getNextLoot(Effect initialEffect, FishingPreparation fishingPreparation) {
String key = WeightUtils.getRandom(getPossibleLootKeysWithWeight(initialEffect, fishingPreparation));
public Loot getNextLoot(Effect initialEffect, Condition condition) {
String key = WeightUtils.getRandom(getPossibleLootKeysWithWeight(initialEffect, condition));
Loot loot = plugin.getLootManager().getLoot(key);
if (loot == null) {
LogUtils.warn(String.format("Loot %s doesn't exist!", key));

View File

@@ -29,7 +29,7 @@ import net.momirealms.customfishing.api.mechanic.condition.FishingPreparation;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.CFConfig;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -175,10 +175,10 @@ public class HookCheckTimerTask implements Runnable {
private void startLavaFishingMechanic() {
// get random time
int random = ThreadLocalRandom.current().nextInt(Config.lavaMinTime, Config.lavaMaxTime);
int random = ThreadLocalRandom.current().nextInt(CFConfig.lavaMinTime, CFConfig.lavaMaxTime);
random -= lureLevel * 100;
random *= initialEffect.getHookTimeModifier();
random = Math.max(Config.lavaMinTime, random);
random = Math.max(CFConfig.lavaMinTime, random);
// lava effect task (Three seconds in advance)
this.lavaFishingTask = new LavaEffectTask(

View File

@@ -32,7 +32,7 @@ import net.momirealms.customfishing.api.util.LogUtils;
import net.momirealms.customfishing.compatibility.item.CustomFishingItemImpl;
import net.momirealms.customfishing.compatibility.item.VanillaItemImpl;
import net.momirealms.customfishing.compatibility.papi.PlaceholderManagerImpl;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.CFConfig;
import net.momirealms.customfishing.util.NBTUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
@@ -173,7 +173,7 @@ public class ItemManagerImpl implements ItemManager {
@Override
public String getAnyItemID(ItemStack itemStack) {
for (String plugin : Config.itemDetectOrder) {
for (String plugin : CFConfig.itemDetectOrder) {
ItemLibrary itemLibrary = itemLibraryMap.get(plugin);
if (itemLibrary != null) {
String id = itemLibrary.getItemID(itemStack);

View File

@@ -0,0 +1,83 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.mechanic.misc;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashMap;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public class CoolDownManager implements Listener {
private final ConcurrentHashMap<UUID, Data> dataMap;
private final CustomFishingPlugin plugin;
public CoolDownManager(CustomFishingPlugin plugin) {
this.dataMap = new ConcurrentHashMap<>();
this.plugin = plugin;
}
public boolean isCoolDown(UUID uuid, String key, long time) {
Data data = this.dataMap.computeIfAbsent(uuid, k -> new Data());
return data.isCoolDown(key, time);
}
public void load() {
Bukkit.getPluginManager().registerEvents(this, plugin);
}
public void unload() {
HandlerList.unregisterAll(this);
}
public void disable() {
unload();
this.dataMap.clear();
}
@EventHandler
public void onQuit(PlayerQuitEvent event) {
dataMap.remove(event.getPlayer().getUniqueId());
}
public static class Data {
private final HashMap<String, Long> coolDownMap;
public Data() {
this.coolDownMap = new HashMap<>();
}
public synchronized boolean isCoolDown(String key, long delay) {
long time = System.currentTimeMillis();
long last = coolDownMap.getOrDefault(key, time - delay);
if (last + delay > time) {
return true;
} else {
coolDownMap.put(key, time);
return false;
}
}
}
}

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.mechanic.requirement;
import net.momirealms.customfishing.api.mechanic.condition.Condition;

View File

@@ -124,6 +124,7 @@ public class RequirementManagerImpl implements RequirementManager {
this.registerRandomRequirement();
this.registerIceFishingRequirement();
this.registerOpenWaterRequirement();
this.registerCoolDownRequirement();
}
public ConditionalLoots getConditionalLoots(ConfigurationSection section) {
@@ -310,7 +311,7 @@ public class RequirementManagerImpl implements RequirementManager {
registerRequirement("lava-fishing", (args, actions, advanced) -> {
boolean inLava = (boolean) args;
return condition -> {
String current = condition.getArgs().get("{lava}");
String current = condition.getArgs().getOrDefault("{lava}","false");
if (current.equals(String.valueOf(inLava)))
return true;
if (advanced) triggerActions(actions, condition);
@@ -446,6 +447,24 @@ public class RequirementManagerImpl implements RequirementManager {
});
}
private void registerCoolDownRequirement() {
registerRequirement("cooldown", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
String key = section.getString("key");
int time = section.getInt("time");
return condition -> {
if (!plugin.getCoolDownManager().isCoolDown(condition.getPlayer().getUniqueId(), key, time)) {
return true;
}
if (advanced) triggerActions(actions, condition);
return false;
};
} else {
return null;
}
});
}
private void registerDateRequirement() {
registerRequirement("date", (args, actions, advanced) -> {
HashSet<String> dates = new HashSet<>(ConfigUtils.stringListArgs(args));

View File

@@ -20,7 +20,7 @@ package net.momirealms.customfishing.scheduler;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import net.momirealms.customfishing.api.scheduler.Scheduler;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.CFConfig;
import org.bukkit.Location;
import java.util.concurrent.ScheduledFuture;
@@ -45,9 +45,9 @@ public class SchedulerImpl implements Scheduler {
}
public void reload() {
this.schedule.setCorePoolSize(Config.corePoolSize);
this.schedule.setKeepAliveTime(Config.keepAliveTime, TimeUnit.SECONDS);
this.schedule.setMaximumPoolSize(Config.maximumPoolSize);
this.schedule.setCorePoolSize(CFConfig.corePoolSize);
this.schedule.setKeepAliveTime(CFConfig.keepAliveTime, TimeUnit.SECONDS);
this.schedule.setMaximumPoolSize(CFConfig.maximumPoolSize);
}
public void shutdown() {

View File

@@ -37,7 +37,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Objects;
public class Config {
public class CFConfig {
// config version
public static String configVersion = "26";

View File

@@ -32,7 +32,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Objects;
public class Locale {
public class CFLocale {
public static String MSG_Total_Size;
public static String MSG_Catch_Amount;
public static String MSG_Total_Score;
@@ -53,6 +53,9 @@ public class Locale {
public static String MSG_Unsafe_Modification;
public static String MSG_Data_Not_Loaded;
public static String MSG_Market_GUI_Open;
public static String MSG_Fishing_Bag_Open;
public static String MSG_Split_Char;
public static String MSG_Possible_Loots;
public static String FORMAT_Day;
public static String FORMAT_Hour;
public static String FORMAT_Minute;
@@ -61,8 +64,8 @@ public class Locale {
public static void load() {
try {
YamlDocument.create(
new File(CustomFishingPlugin.getInstance().getDataFolder(), "messages/" + Config.language + ".yml"),
Objects.requireNonNull(CustomFishingPlugin.getInstance().getResource("messages/" + Config.language + ".yml")),
new File(CustomFishingPlugin.getInstance().getDataFolder(), "messages/" + CFConfig.language + ".yml"),
Objects.requireNonNull(CustomFishingPlugin.getInstance().getResource("messages/" + CFConfig.language + ".yml")),
GeneralSettings.DEFAULT,
LoaderSettings
.builder()
@@ -77,7 +80,7 @@ public class Locale {
} catch (IOException e) {
LogUtils.warn(e.getMessage());
}
loadSettings(CustomFishingPlugin.get().getConfig("messages/" + Config.language + ".yml"));
loadSettings(CustomFishingPlugin.get().getConfig("messages/" + CFConfig.language + ".yml"));
}
private static void loadSettings(YamlConfiguration locale) {
@@ -103,10 +106,13 @@ public class Locale {
MSG_Unsafe_Modification = msgSection.getString("unsafe-modification");
MSG_Data_Not_Loaded = msgSection.getString("data-not-loaded");
MSG_Market_GUI_Open = msgSection.getString("open-market-gui");
MSG_Fishing_Bag_Open = msgSection.getString("open-fishing-bag");
FORMAT_Day = msgSection.getString("format-day");
FORMAT_Hour = msgSection.getString("format-hour");
FORMAT_Minute = msgSection.getString("format-minute");
FORMAT_Second = msgSection.getString("format-second");
MSG_Split_Char = msgSection.getString("split-char");
MSG_Possible_Loots = msgSection.getString("possible-loots");
}
}
}

View File

@@ -29,7 +29,7 @@ import net.momirealms.customfishing.api.data.user.OnlineUser;
import net.momirealms.customfishing.api.manager.StorageManager;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import net.momirealms.customfishing.api.util.LogUtils;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.CFConfig;
import net.momirealms.customfishing.storage.method.database.nosql.MongoDBImpl;
import net.momirealms.customfishing.storage.method.database.nosql.RedisManager;
import net.momirealms.customfishing.storage.method.database.sql.H2Impl;
@@ -109,15 +109,15 @@ public class StorageManagerImpl implements StorageManager, Listener {
if (this.timerSaveTask != null && !this.timerSaveTask.isCancelled()) {
this.timerSaveTask.cancel();
}
if (Config.dataSaveInterval != -1)
if (CFConfig.dataSaveInterval != -1)
this.timerSaveTask = this.plugin.getScheduler().runTaskAsyncTimer(
() -> {
long time1 = System.currentTimeMillis();
this.dataSource.savePlayersData(this.onlineUserMap.values(), false);
LogUtils.info("Data Saved for online players. Took " + (System.currentTimeMillis() - time1) + "ms.");
},
Config.dataSaveInterval,
Config.dataSaveInterval,
CFConfig.dataSaveInterval,
CFConfig.dataSaveInterval,
TimeUnit.SECONDS
);
}

View File

@@ -21,7 +21,7 @@ import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.data.PlayerData;
import net.momirealms.customfishing.api.data.user.OfflineUser;
import net.momirealms.customfishing.api.util.LogUtils;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.CFConfig;
import net.momirealms.customfishing.storage.method.AbstractStorage;
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
@@ -90,7 +90,7 @@ public abstract class AbstractSQLDatabase extends AbstractStorage {
ResultSet rs = statement.executeQuery();
if (rs.next()) {
int lock = rs.getInt(2);
if (!force && (lock != 0 && getCurrentSeconds() - Config.dataSaveInterval <= lock)) {
if (!force && (lock != 0 && getCurrentSeconds() - CFConfig.dataSaveInterval <= lock)) {
statement.close(); rs.close(); connection.close();
future.complete(Optional.of(PlayerData.LOCKED));
return;

View File

@@ -22,7 +22,7 @@ import net.momirealms.customfishing.api.data.PlayerData;
import net.momirealms.customfishing.api.data.StorageType;
import net.momirealms.customfishing.api.data.user.OfflineUser;
import net.momirealms.customfishing.api.util.LogUtils;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.CFConfig;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.sqlite.SQLiteConfig;
@@ -88,7 +88,7 @@ public class SQLiteImpl extends AbstractSQLDatabase {
ResultSet rs = statement.executeQuery();
if (rs.next()) {
int lock = rs.getInt(2);
if (!force && (lock != 0 && getCurrentSeconds() - Config.dataSaveInterval <= lock)) {
if (!force && (lock != 0 && getCurrentSeconds() - CFConfig.dataSaveInterval <= lock)) {
statement.close(); rs.close(); connection.close();
future.complete(Optional.of(PlayerData.LOCKED));
return;

View File

@@ -27,7 +27,7 @@ import net.momirealms.customfishing.api.mechanic.bag.FishingBagHolder;
import net.momirealms.customfishing.api.mechanic.statistic.Statistics;
import net.momirealms.customfishing.api.util.InventoryUtils;
import net.momirealms.customfishing.compatibility.papi.PlaceholderManagerImpl;
import net.momirealms.customfishing.setting.Config;
import net.momirealms.customfishing.setting.CFConfig;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@@ -53,7 +53,7 @@ public class OfflineUserImpl implements OfflineUser {
this.holder.setInventory(InventoryUtils.createInventory(this.holder, playerData.getBagData().size,
AdventureManagerImpl.getInstance().getComponentFromMiniMessage(
PlaceholderManagerImpl.getInstance().parse(
offlinePlayer, Config.bagTitle, Map.of("{player}", Optional.ofNullable(offlinePlayer.getName()).orElse(String.valueOf(uuid)))
offlinePlayer, CFConfig.bagTitle, Map.of("{player}", Optional.ofNullable(offlinePlayer.getName()).orElse(String.valueOf(uuid)))
)
)));
this.holder.setItems(InventoryUtils.getInventoryItems(playerData.getBagData().serialized));

View File

@@ -9,26 +9,40 @@ fishfinder:
display:
name: '<gray>Fish Finder'
lore:
- '<white>Right click to see what fish can be caught in this place!'
- ''
- '<#7FFFD4>Desciption:'
- '<gray> - Compact yet powerful, it scans the waters'
- '<gray> - with precision, revealing the variety of'
- '<gray> - fish species lurking below the surface.'
- '<gray> - Whether you''re in uncharted territories or'
- '<gray> - familiar waters, this device ensures you''re'
- '<gray> - always informed about your aquatic neighbors.'
- ''
custom-model-data: 50000
events:
interact:
conditional_action:
type: conditional
value:
conditions:
condition_1:
type: cooldown
value:
key: fishfinder
time: 3000 #ms
not-met-actions:
action_1:
type: message
value:
- 'Slow down! You are using the fish finder too frequently.'
actions:
action_1:
type: fish-finder
value: false
water_effect:
material: PAPER
custom-model-data: 49998
lava_effect:
material: PAPER
custom-model-data: 49999
fisherman_talismans:
material: player_head
display:
name: '<blue>Fisherman Talismans'
lore:
- ''
- '<gray>Fishing would be easier when keeping'
- '<gray>the talismans in the fishing bag'
- ''
- '<gold>The effect cannot be stacked'
head64: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWQzZmVjNGI3M2E1ZThlMWY1Y2FiOTBjZDBhMzgzMDJmMzdiMDBjNzEzY2EwNmM4NDkzMDBmOGZkMTFlNWVjMiJ9fX0=
effect:
difficulty: -1
custom-model-data: 49999

View File

@@ -6,7 +6,7 @@ messages:
prefix: '<gradient:#0070B3:#A0EACF>[CustomFishing] </gradient>'
reload: '<white>Reloaded. Took <green>{time}ms.'
item-not-exist: 'That item does not exist.'
escape: 'It has been too long since the fish is hooked. Oh my god, it escaped.'
escape: 'The fish managed to get rid of the hook and escaped.'
give-item: 'Successfully given player {player} {amount}x {item}.'
get-item: 'Successfully got {amount}x {item}.'
possible-loots: 'Possible loots here: '
@@ -26,7 +26,7 @@ messages:
never-played: 'That player has never played the server. You can''t edit a non existent player''s fishing bag.'
data-not-loaded: '<red>Your data has not been loaded yet. Try rejoining the server. If the problem still occurs, contact the server administrator.'
open-market-gui: 'Successfully opened the market gui for {player}'
open-fishingbag-gui: 'Successfully opened the fishing bag for {player}'
open-fishing-bag: 'Successfully opened the fishing bag for {player}'
format-day: 'd'
format-hour: 'h'
format-minute: 'm'