mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-29 03:49:07 +00:00
checkpoint - 5
This commit is contained in:
@@ -15,31 +15,29 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing;
|
||||
package net.momirealms.customfishing.bukkit;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.event.CustomFishingReloadEvent;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.cooldown.CoolDownManager;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.placeholder.BukkitPlaceholderManager;
|
||||
import net.momirealms.customfishing.bukkit.compatibility.IntegrationManagerImpl;
|
||||
import net.momirealms.customfishing.bukkit.competition.CompetitionManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.action.ActionManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.bag.BagManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.block.BlockManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.effect.EffectManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.entity.EntityManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.fishing.FishingManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.game.GameManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.hook.HookManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.item.ItemManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.loot.LootManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.market.MarketManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.misc.ChatCatcherManager;
|
||||
import net.momirealms.customfishing.mechanic.misc.CoolDownManager;
|
||||
import net.momirealms.customfishing.mechanic.requirement.RequirementManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.statistic.StatisticsManagerImpl;
|
||||
import net.momirealms.customfishing.mechanic.totem.TotemManagerImpl;
|
||||
import net.momirealms.customfishing.storage.StorageManagerImpl;
|
||||
import net.momirealms.customfishing.version.VersionManagerImpl;
|
||||
import net.momirealms.customfishing.bukkit.bag.BukkitBagManager;
|
||||
import net.momirealms.customfishing.bukkit.block.BukkitBlockManager;
|
||||
import net.momirealms.customfishing.bukkit.compatibility.BukkitIntegrationManager;
|
||||
import net.momirealms.customfishing.bukkit.competition.BukkitCompetitionManager;
|
||||
import net.momirealms.customfishing.bukkit.effect.BukkitEffectManager;
|
||||
import net.momirealms.customfishing.bukkit.entity.BukkitEntityManager;
|
||||
import net.momirealms.customfishing.bukkit.fishing.BukkitFishingManager;
|
||||
import net.momirealms.customfishing.bukkit.game.BukkitGameManager;
|
||||
import net.momirealms.customfishing.bukkit.hook.BukkitHookManager;
|
||||
import net.momirealms.customfishing.bukkit.item.ItemManagerImpl;
|
||||
import net.momirealms.customfishing.bukkit.loot.LootManagerImpl;
|
||||
import net.momirealms.customfishing.bukkit.market.BukkitMarketManager;
|
||||
import net.momirealms.customfishing.bukkit.misc.ChatCatcherManager;
|
||||
import net.momirealms.customfishing.bukkit.statistic.BukkitStatisticsManager;
|
||||
import net.momirealms.customfishing.bukkit.storage.BukkitStorageManager;
|
||||
import net.momirealms.customfishing.bukkit.totem.BukkitTotemManager;
|
||||
import net.momirealms.customfishing.common.helper.VersionHelper;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -65,7 +63,7 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
this.versionManager = new VersionManagerImpl(this);
|
||||
this.versionManager = new VersionHelper(this);
|
||||
this.dependencyManager = new DependencyManagerImpl(this, new ReflectionClassPathAppender(this.getClassLoader()));
|
||||
this.dependencyManager.loadDependencies(new ArrayList<>(
|
||||
List.of(
|
||||
@@ -101,26 +99,26 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
|
||||
|
||||
this.actionManager = new ActionManagerImpl(this);
|
||||
this.adventure = new AdventureHelper(this);
|
||||
this.bagManager = new BagManagerImpl(this);
|
||||
this.blockManager = new BlockManagerImpl(this);
|
||||
this.bagManager = new BukkitBagManager(this);
|
||||
this.blockManager = new BukkitBlockManager(this);
|
||||
this.commandManager = new CommandManagerImpl(this);
|
||||
this.effectManager = new EffectManagerImpl(this);
|
||||
this.fishingManager = new FishingManagerImpl(this);
|
||||
this.gameManager = new GameManagerImpl(this);
|
||||
this.effectManager = new BukkitEffectManager(this);
|
||||
this.fishingManager = new BukkitFishingManager(this);
|
||||
this.gameManager = new BukkitGameManager(this);
|
||||
this.itemManager = new ItemManagerImpl(this);
|
||||
this.lootManager = new LootManagerImpl(this);
|
||||
this.marketManager = new MarketManagerImpl(this);
|
||||
this.entityManager = new EntityManagerImpl(this);
|
||||
this.marketManager = new BukkitMarketManager(this);
|
||||
this.entityManager = new BukkitEntityManager(this);
|
||||
this.placeholderManager = new BukkitPlaceholderManager(this);
|
||||
this.requirementManager = new RequirementManagerImpl(this);
|
||||
this.scheduler = new SchedulerImpl(this);
|
||||
this.storageManager = new StorageManagerImpl(this);
|
||||
this.competitionManager = new CompetitionManagerImpl(this);
|
||||
this.integrationManager = new IntegrationManagerImpl(this);
|
||||
this.statisticsManager = new StatisticsManagerImpl(this);
|
||||
this.storageManager = new BukkitStorageManager(this);
|
||||
this.competitionManager = new BukkitCompetitionManager(this);
|
||||
this.integrationManager = new BukkitIntegrationManager(this);
|
||||
this.statisticsManager = new BukkitStatisticsManager(this);
|
||||
this.coolDownManager = new CoolDownManager(this);
|
||||
this.totemManager = new TotemManagerImpl(this);
|
||||
this.hookManager = new HookManagerImpl(this);
|
||||
this.totemManager = new BukkitTotemManager(this);
|
||||
this.hookManager = new BukkitHookManager(this);
|
||||
this.chatCatcherManager = new ChatCatcherManager(this);
|
||||
this.reload();
|
||||
super.initialized = true;
|
||||
@@ -136,25 +134,25 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (this.adventure != null) ((AdventureHelper) this.adventure).close();
|
||||
if (this.bagManager != null) ((BagManagerImpl) this.bagManager).disable();
|
||||
if (this.blockManager != null) ((BlockManagerImpl) this.blockManager).disable();
|
||||
if (this.effectManager != null) ((EffectManagerImpl) this.effectManager).disable();
|
||||
if (this.fishingManager != null) ((FishingManagerImpl) this.fishingManager).disable();
|
||||
if (this.gameManager != null) ((GameManagerImpl) this.gameManager).disable();
|
||||
if (this.bagManager != null) ((BukkitBagManager) this.bagManager).disable();
|
||||
if (this.blockManager != null) ((BukkitBlockManager) this.blockManager).disable();
|
||||
if (this.effectManager != null) ((BukkitEffectManager) this.effectManager).disable();
|
||||
if (this.fishingManager != null) ((BukkitFishingManager) this.fishingManager).disable();
|
||||
if (this.gameManager != null) ((BukkitGameManager) this.gameManager).disable();
|
||||
if (this.itemManager != null) ((ItemManagerImpl) this.itemManager).disable();
|
||||
if (this.lootManager != null) ((LootManagerImpl) this.lootManager).disable();
|
||||
if (this.marketManager != null) ((MarketManagerImpl) this.marketManager).disable();
|
||||
if (this.entityManager != null) ((EntityManagerImpl) this.entityManager).disable();
|
||||
if (this.marketManager != null) ((BukkitMarketManager) this.marketManager).disable();
|
||||
if (this.entityManager != null) ((BukkitEntityManager) this.entityManager).disable();
|
||||
if (this.requirementManager != null) ((RequirementManagerImpl) this.requirementManager).disable();
|
||||
if (this.scheduler != null) ((SchedulerImpl) this.scheduler).shutdown();
|
||||
if (this.integrationManager != null) ((IntegrationManagerImpl) this.integrationManager).disable();
|
||||
if (this.competitionManager != null) ((CompetitionManagerImpl) this.competitionManager).disable();
|
||||
if (this.storageManager != null) ((StorageManagerImpl) this.storageManager).disable();
|
||||
if (this.integrationManager != null) ((BukkitIntegrationManager) this.integrationManager).disable();
|
||||
if (this.competitionManager != null) ((BukkitCompetitionManager) this.competitionManager).disable();
|
||||
if (this.storageManager != null) ((BukkitStorageManager) this.storageManager).disable();
|
||||
if (this.placeholderManager != null) ((BukkitPlaceholderManager) this.placeholderManager).disable();
|
||||
if (this.statisticsManager != null) ((StatisticsManagerImpl) this.statisticsManager).disable();
|
||||
if (this.statisticsManager != null) ((BukkitStatisticsManager) this.statisticsManager).disable();
|
||||
if (this.actionManager != null) ((ActionManagerImpl) this.actionManager).disable();
|
||||
if (this.totemManager != null) ((TotemManagerImpl) this.totemManager).disable();
|
||||
if (this.hookManager != null) ((HookManagerImpl) this.hookManager).disable();
|
||||
if (this.totemManager != null) ((BukkitTotemManager) this.totemManager).disable();
|
||||
if (this.hookManager != null) ((BukkitHookManager) this.hookManager).disable();
|
||||
if (this.coolDownManager != null) this.coolDownManager.disable();
|
||||
if (this.chatCatcherManager != null) this.chatCatcherManager.disable();
|
||||
if (this.commandManager != null) this.commandManager.unload();
|
||||
@@ -173,35 +171,35 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
|
||||
((RequirementManagerImpl) this.requirementManager).load();
|
||||
((ActionManagerImpl) this.actionManager).unload();
|
||||
((ActionManagerImpl) this.actionManager).load();
|
||||
((GameManagerImpl) this.gameManager).unload();
|
||||
((GameManagerImpl) this.gameManager).load();
|
||||
((BukkitGameManager) this.gameManager).unload();
|
||||
((BukkitGameManager) this.gameManager).load();
|
||||
((ItemManagerImpl) this.itemManager).unload();
|
||||
((ItemManagerImpl) this.itemManager).load();
|
||||
((LootManagerImpl) this.lootManager).unload();
|
||||
((LootManagerImpl) this.lootManager).load();
|
||||
((FishingManagerImpl) this.fishingManager).unload();
|
||||
((FishingManagerImpl) this.fishingManager).load();
|
||||
((TotemManagerImpl) this.totemManager).unload();
|
||||
((TotemManagerImpl) this.totemManager).load();
|
||||
((EffectManagerImpl) this.effectManager).unload();
|
||||
((EffectManagerImpl) this.effectManager).load();
|
||||
((MarketManagerImpl) this.marketManager).unload();
|
||||
((MarketManagerImpl) this.marketManager).load();
|
||||
((BagManagerImpl) this.bagManager).unload();
|
||||
((BagManagerImpl) this.bagManager).load();
|
||||
((BlockManagerImpl) this.blockManager).unload();
|
||||
((BlockManagerImpl) this.blockManager).load();
|
||||
((EntityManagerImpl) this.entityManager).unload();
|
||||
((EntityManagerImpl) this.entityManager).load();
|
||||
((CompetitionManagerImpl) this.competitionManager).unload();
|
||||
((CompetitionManagerImpl) this.competitionManager).load();
|
||||
((StorageManagerImpl) this.storageManager).reload();
|
||||
((StatisticsManagerImpl) this.statisticsManager).unload();
|
||||
((StatisticsManagerImpl) this.statisticsManager).load();
|
||||
((BukkitFishingManager) this.fishingManager).unload();
|
||||
((BukkitFishingManager) this.fishingManager).load();
|
||||
((BukkitTotemManager) this.totemManager).unload();
|
||||
((BukkitTotemManager) this.totemManager).load();
|
||||
((BukkitEffectManager) this.effectManager).unload();
|
||||
((BukkitEffectManager) this.effectManager).load();
|
||||
((BukkitMarketManager) this.marketManager).unload();
|
||||
((BukkitMarketManager) this.marketManager).load();
|
||||
((BukkitBagManager) this.bagManager).unload();
|
||||
((BukkitBagManager) this.bagManager).load();
|
||||
((BukkitBlockManager) this.blockManager).unload();
|
||||
((BukkitBlockManager) this.blockManager).load();
|
||||
((BukkitEntityManager) this.entityManager).unload();
|
||||
((BukkitEntityManager) this.entityManager).load();
|
||||
((BukkitCompetitionManager) this.competitionManager).unload();
|
||||
((BukkitCompetitionManager) this.competitionManager).load();
|
||||
((BukkitStorageManager) this.storageManager).reload();
|
||||
((BukkitStatisticsManager) this.statisticsManager).unload();
|
||||
((BukkitStatisticsManager) this.statisticsManager).load();
|
||||
((BukkitPlaceholderManager) this.placeholderManager).unload();
|
||||
((BukkitPlaceholderManager) this.placeholderManager).load();
|
||||
((HookManagerImpl) this.hookManager).unload();
|
||||
((HookManagerImpl) this.hookManager).load();
|
||||
((BukkitHookManager) this.hookManager).unload();
|
||||
((BukkitHookManager) this.hookManager).load();
|
||||
this.commandManager.unload();
|
||||
this.commandManager.load();
|
||||
this.coolDownManager.unload();
|
||||
@@ -20,8 +20,8 @@ import net.momirealms.customfishing.common.util.ClassUtils;
|
||||
import net.momirealms.customfishing.common.util.ListUtils;
|
||||
import net.momirealms.customfishing.common.util.Pair;
|
||||
import net.momirealms.customfishing.common.util.RandomUtils;
|
||||
import net.momirealms.customfishing.util.ItemUtils;
|
||||
import net.momirealms.customfishing.util.LocationUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.ItemUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.LocationUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -135,10 +135,10 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
List<String> messages = ListUtils.toList(args);
|
||||
return context -> {
|
||||
if (Math.random() > chance) return;
|
||||
List<String> replaced = plugin.getPlaceholderManager().parse(context.getHolder(), messages, context.toPlaceholderMap());
|
||||
List<String> replaced = plugin.getPlaceholderManager().parse(context.getHolder(), messages, context.placeholderMap());
|
||||
Audience audience = plugin.getSenderFactory().getAudience(context.getHolder());
|
||||
for (String text : replaced) {
|
||||
audience.sendMessage(AdventureHelper.getMiniMessage().deserialize(text));
|
||||
audience.sendMessage(AdventureHelper.miniMessage(text));
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -147,20 +147,20 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
return context -> {
|
||||
if (Math.random() > chance) return;
|
||||
String random = messages.get(RandomUtils.generateRandomInt(0, messages.size()));
|
||||
random = BukkitPlaceholderManager.getInstance().parse(context.getHolder(), random, context.toPlaceholderMap());
|
||||
random = BukkitPlaceholderManager.getInstance().parse(context.getHolder(), random, context.placeholderMap());
|
||||
Audience audience = plugin.getSenderFactory().getAudience(context.getHolder());
|
||||
audience.sendMessage(AdventureHelper.getMiniMessage().deserialize(random));
|
||||
audience.sendMessage(AdventureHelper.miniMessage(random));
|
||||
};
|
||||
});
|
||||
registerAction("broadcast", (args, chance) -> {
|
||||
List<String> messages = ListUtils.toList(args);
|
||||
return context -> {
|
||||
if (Math.random() > chance) return;
|
||||
List<String> replaced = plugin.getPlaceholderManager().parse(context.getHolder(), messages, context.toPlaceholderMap());
|
||||
List<String> replaced = plugin.getPlaceholderManager().parse(context.getHolder(), messages, context.placeholderMap());
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
Audience audience = plugin.getSenderFactory().getAudience(player);
|
||||
for (String text : replaced) {
|
||||
audience.sendMessage(AdventureHelper.getMiniMessage().deserialize(text));
|
||||
audience.sendMessage(AdventureHelper.miniMessage(text));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -182,11 +182,11 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
List<String> replaced = BukkitPlaceholderManager.getInstance().parse(
|
||||
owner,
|
||||
messages,
|
||||
context.toPlaceholderMap()
|
||||
context.placeholderMap()
|
||||
);
|
||||
Audience audience = plugin.getSenderFactory().getAudience(player);
|
||||
for (String text : replaced) {
|
||||
audience.sendMessage(AdventureHelper.getMiniMessage().deserialize(text));
|
||||
audience.sendMessage(AdventureHelper.miniMessage(text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
List<String> commands = ListUtils.toList(args);
|
||||
return context -> {
|
||||
if (Math.random() > chance) return;
|
||||
List<String> replaced = BukkitPlaceholderManager.getInstance().parse(context.getHolder(), commands, context.toPlaceholderMap());
|
||||
List<String> replaced = BukkitPlaceholderManager.getInstance().parse(context.getHolder(), commands, context.placeholderMap());
|
||||
plugin.getScheduler().sync().run(() -> {
|
||||
for (String text : replaced) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), text);
|
||||
@@ -216,7 +216,7 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
List<String> commands = ListUtils.toList(args);
|
||||
return context -> {
|
||||
if (Math.random() > chance) return;
|
||||
List<String> replaced = BukkitPlaceholderManager.getInstance().parse(context.getHolder(), commands, context.toPlaceholderMap());
|
||||
List<String> replaced = BukkitPlaceholderManager.getInstance().parse(context.getHolder(), commands, context.placeholderMap());
|
||||
plugin.getScheduler().sync().run(() -> {
|
||||
for (String text : replaced) {
|
||||
context.getHolder().performCommand(text);
|
||||
@@ -229,7 +229,7 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
return context -> {
|
||||
if (Math.random() > chance) return;
|
||||
String random = commands.get(ThreadLocalRandom.current().nextInt(commands.size()));
|
||||
random = BukkitPlaceholderManager.getInstance().parse(context.getHolder(), random, context.toPlaceholderMap());
|
||||
random = BukkitPlaceholderManager.getInstance().parse(context.getHolder(), random, context.placeholderMap());
|
||||
String finalRandom = random;
|
||||
plugin.getScheduler().sync().run(() -> {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), finalRandom);
|
||||
@@ -250,7 +250,7 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
double distance = LocationUtils.getDistance(player.getLocation(), location);
|
||||
if (distance <= realRange) {
|
||||
context.arg(ContextKeys.TEMP_NEAR_PLAYER, player.getName());
|
||||
List<String> replaced = BukkitPlaceholderManager.getInstance().parse(owner, cmd, context.toPlaceholderMap());
|
||||
List<String> replaced = BukkitPlaceholderManager.getInstance().parse(owner, cmd, context.placeholderMap());
|
||||
for (String text : replaced) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), text);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
return context -> {
|
||||
if (Math.random() > chance) return;
|
||||
Audience audience = plugin.getSenderFactory().getAudience(context.getHolder());
|
||||
Component component = AdventureHelper.getMiniMessage().deserialize(plugin.getPlaceholderManager().parse(context.getHolder(), text, context.toPlaceholderMap()));
|
||||
Component component = AdventureHelper.miniMessage(plugin.getPlaceholderManager().parse(context.getHolder(), text, context.placeholderMap()));
|
||||
audience.sendActionBar(component);
|
||||
};
|
||||
});
|
||||
@@ -287,9 +287,9 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
return context -> {
|
||||
if (Math.random() > chance) return;
|
||||
String random = texts.get(RandomUtils.generateRandomInt(0, texts.size()));
|
||||
random = plugin.getPlaceholderManager().parse(context.getHolder(), random, context.toPlaceholderMap());
|
||||
random = plugin.getPlaceholderManager().parse(context.getHolder(), random, context.placeholderMap());
|
||||
Audience audience = plugin.getSenderFactory().getAudience(context.getHolder());
|
||||
audience.sendActionBar(AdventureHelper.getMiniMessage().deserialize(random));
|
||||
audience.sendActionBar(AdventureHelper.miniMessage(random));
|
||||
};
|
||||
});
|
||||
registerAction("actionbar-nearby", (args, chance) -> {
|
||||
@@ -306,9 +306,9 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
double distance = LocationUtils.getDistance(player.getLocation(), location);
|
||||
if (distance <= realRange) {
|
||||
context.arg(ContextKeys.TEMP_NEAR_PLAYER, player.getName());
|
||||
String replaced = plugin.getPlaceholderManager().parse(owner, actionbar, context.toPlaceholderMap());
|
||||
String replaced = plugin.getPlaceholderManager().parse(owner, actionbar, context.placeholderMap());
|
||||
Audience audience = plugin.getSenderFactory().getAudience(player);
|
||||
audience.sendActionBar(AdventureHelper.getMiniMessage().deserialize(replaced));
|
||||
audience.sendActionBar(AdventureHelper.miniMessage(replaced));
|
||||
}
|
||||
}
|
||||
}, location
|
||||
@@ -662,8 +662,8 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
final Player player = context.getHolder();
|
||||
Audience audience = plugin.getSenderFactory().getAudience(player);
|
||||
AdventureHelper.sendTitle(audience,
|
||||
AdventureHelper.getMiniMessage().deserialize(title.render(context)),
|
||||
AdventureHelper.getMiniMessage().deserialize(subtitle.render(context)),
|
||||
AdventureHelper.miniMessage(title.render(context)),
|
||||
AdventureHelper.miniMessage(subtitle.render(context)),
|
||||
fadeIn, stay, fadeOut
|
||||
);
|
||||
};
|
||||
@@ -688,8 +688,8 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
final Player player = context.getHolder();
|
||||
Audience audience = plugin.getSenderFactory().getAudience(player);
|
||||
AdventureHelper.sendTitle(audience,
|
||||
AdventureHelper.getMiniMessage().deserialize(title.render(context)),
|
||||
AdventureHelper.getMiniMessage().deserialize(subtitle.render(context)),
|
||||
AdventureHelper.miniMessage(title.render(context)),
|
||||
AdventureHelper.miniMessage(subtitle.render(context)),
|
||||
fadeIn, stay, fadeOut
|
||||
);
|
||||
};
|
||||
@@ -716,8 +716,8 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
context.arg(ContextKeys.TEMP_NEAR_PLAYER, player.getName());
|
||||
Audience audience = plugin.getSenderFactory().getAudience(player);
|
||||
AdventureHelper.sendTitle(audience,
|
||||
AdventureHelper.getMiniMessage().deserialize(title.render(context)),
|
||||
AdventureHelper.getMiniMessage().deserialize(subtitle.render(context)),
|
||||
AdventureHelper.miniMessage(title.render(context)),
|
||||
AdventureHelper.miniMessage(subtitle.render(context)),
|
||||
fadeIn, stay, fadeOut
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.bag;
|
||||
package net.momirealms.customfishing.bukkit.bag;
|
||||
|
||||
import net.momirealms.customfishing.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.bukkit.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.action.Action;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.placeholder.BukkitPlaceholderManager;
|
||||
@@ -41,7 +41,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class BagManagerImpl implements BagManager, Listener {
|
||||
public class BukkitBagManager implements BagManager, Listener {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
private final HashMap<UUID, UserData> tempEditMap;
|
||||
@@ -52,7 +52,7 @@ public class BagManagerImpl implements BagManager, Listener {
|
||||
private List<Material> bagWhiteListItems;
|
||||
private Requirement[] collectRequirements;
|
||||
|
||||
public BagManagerImpl(BukkitCustomFishingPluginImpl plugin) {
|
||||
public BukkitBagManager(BukkitCustomFishingPluginImpl plugin) {
|
||||
this.plugin = plugin;
|
||||
this.tempEditMap = new HashMap<>();
|
||||
}
|
||||
@@ -15,9 +15,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.block;
|
||||
package net.momirealms.customfishing.bukkit.block;
|
||||
|
||||
import net.momirealms.customfishing.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.bukkit.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.common.Pair;
|
||||
import net.momirealms.customfishing.api.common.Tuple;
|
||||
@@ -25,7 +25,7 @@ import net.momirealms.customfishing.api.integration.BlockProvider;
|
||||
import net.momirealms.customfishing.api.mechanic.block.*;
|
||||
import net.momirealms.customfishing.api.mechanic.loot.Loot;
|
||||
import net.momirealms.customfishing.bukkit.compatibility.block.VanillaBlockProvider;
|
||||
import net.momirealms.customfishing.util.ConfigUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.ConfigUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@@ -55,7 +55,7 @@ import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BlockManagerImpl implements BlockManager, Listener {
|
||||
public class BukkitBlockManager implements BlockManager, Listener {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
private final HashMap<String, BlockProvider> blockLibraryMap;
|
||||
@@ -64,7 +64,7 @@ public class BlockManagerImpl implements BlockManager, Listener {
|
||||
private final HashMap<String, BlockDataModifierFactory> dataBuilderMap;
|
||||
private final HashMap<String, BlockStateModifierFactory> stateBuilderMap;
|
||||
|
||||
public BlockManagerImpl(BukkitCustomFishingPluginImpl plugin) {
|
||||
public BukkitBlockManager(BukkitCustomFishingPluginImpl plugin) {
|
||||
this.plugin = plugin;
|
||||
this.blockLibraryMap = new HashMap<>();
|
||||
this.blockConfigMap = new HashMap<>();
|
||||
@@ -42,14 +42,14 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IntegrationManagerImpl implements IntegrationManager {
|
||||
public class BukkitIntegrationManager implements IntegrationManager {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
private final HashMap<String, LevelerProvider> levelPluginMap;
|
||||
private final HashMap<String, EnchantmentProvider> enchantmentPluginMap;
|
||||
private SeasonProvider seasonProvider;
|
||||
|
||||
public IntegrationManagerImpl(BukkitCustomFishingPlugin plugin) {
|
||||
public BukkitIntegrationManager(BukkitCustomFishingPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.levelPluginMap = new HashMap<>();
|
||||
this.enchantmentPluginMap = new HashMap<>();
|
||||
@@ -17,23 +17,26 @@
|
||||
|
||||
package net.momirealms.customfishing.bukkit.competition;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import dev.dejvokep.boostedyaml.YamlDocument;
|
||||
import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.common.Pair;
|
||||
import net.momirealms.customfishing.api.mechanic.action.Action;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.CompetitionConfigImpl;
|
||||
import net.momirealms.customfishing.api.mechanic.action.ActionManager;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.CompetitionConfig;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.CompetitionGoal;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.CompetitionManager;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.info.ActionBarConfigImpl;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.info.BossBarConfigImpl;
|
||||
import net.momirealms.customfishing.api.scheduler.CancellableTask;
|
||||
import net.momirealms.customfishing.storage.method.database.nosql.RedisManager;
|
||||
import net.momirealms.customfishing.util.ConfigUtils;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.info.ActionBarConfig;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.info.BossBarConfig;
|
||||
import net.momirealms.customfishing.api.mechanic.context.Context;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.database.nosql.RedisManager;
|
||||
import net.momirealms.customfishing.common.plugin.scheduler.SchedulerTask;
|
||||
import net.momirealms.customfishing.common.util.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
@@ -41,16 +44,16 @@ import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CompetitionManagerImpl implements CompetitionManager {
|
||||
public class BukkitCompetitionManager implements CompetitionManager {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
private final HashMap<CompetitionSchedule, CompetitionConfigImpl> timeConfigMap;
|
||||
private final HashMap<String, CompetitionConfigImpl> commandConfigMap;
|
||||
private final HashMap<CompetitionSchedule, CompetitionConfig> timeConfigMap;
|
||||
private final HashMap<String, CompetitionConfig> commandConfigMap;
|
||||
private Competition currentCompetition;
|
||||
private CancellableTask timerCheckTask;
|
||||
private SchedulerTask timerCheckTask;
|
||||
private int nextCompetitionSeconds;
|
||||
|
||||
public CompetitionManagerImpl(BukkitCustomFishingPlugin plugin) {
|
||||
public BukkitCompetitionManager(BukkitCustomFishingPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.timeConfigMap = new HashMap<>();
|
||||
this.commandConfigMap = new HashMap<>();
|
||||
@@ -58,7 +61,7 @@ public class CompetitionManagerImpl implements CompetitionManager {
|
||||
|
||||
public void load() {
|
||||
loadConfig();
|
||||
this.timerCheckTask = plugin.getScheduler().runTaskAsyncTimer(
|
||||
this.timerCheckTask = plugin.getScheduler().asyncRepeating(
|
||||
this::timerCheck,
|
||||
1,
|
||||
1,
|
||||
@@ -67,33 +70,21 @@ public class CompetitionManagerImpl implements CompetitionManager {
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
if (this.timerCheckTask != null && !this.timerCheckTask.isCancelled())
|
||||
if (this.timerCheckTask != null)
|
||||
this.timerCheckTask.cancel();
|
||||
if (currentCompetition != null && currentCompetition.isOnGoing())
|
||||
currentCompetition.stop(true);
|
||||
this.commandConfigMap.clear();
|
||||
this.timeConfigMap.clear();
|
||||
if (currentCompetition != null && currentCompetition.isOnGoing()) {
|
||||
plugin.getScheduler().runTaskAsync(() -> currentCompetition.stop(true));
|
||||
}
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
if (this.timerCheckTask != null && !this.timerCheckTask.isCancelled())
|
||||
if (this.timerCheckTask != null)
|
||||
this.timerCheckTask.cancel();
|
||||
this.commandConfigMap.clear();
|
||||
this.timeConfigMap.clear();
|
||||
if (currentCompetition != null && currentCompetition.isOnGoing())
|
||||
currentCompetition.stop(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a set of all competition names.
|
||||
*
|
||||
* @return A set of competition names.
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<String> getAllCompetitionKeys() {
|
||||
return commandConfigMap.keySet();
|
||||
this.commandConfigMap.clear();
|
||||
this.timeConfigMap.clear();
|
||||
}
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
@@ -103,7 +94,7 @@ public class CompetitionManagerImpl implements CompetitionManager {
|
||||
File typeFolder = new File(plugin.getDataFolder() + File.separator + "contents" + File.separator + type);
|
||||
if (!typeFolder.exists()) {
|
||||
if (!typeFolder.mkdirs()) return;
|
||||
plugin.saveResource("contents" + File.separator + type + File.separator + "default.yml", false);
|
||||
plugin.getBoostrap().saveResource("contents" + File.separator + type + File.separator + "default.yml", false);
|
||||
}
|
||||
fileDeque.push(typeFolder);
|
||||
while (!fileDeque.isEmpty()) {
|
||||
@@ -122,55 +113,65 @@ public class CompetitionManagerImpl implements CompetitionManager {
|
||||
}
|
||||
|
||||
private void loadSingleFileCompetition(File file) {
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
for (Map.Entry<String, Object> entry : config.getValues(false).entrySet()) {
|
||||
if (entry.getValue() instanceof ConfigurationSection section) {
|
||||
YamlDocument document = plugin.getConfigManager().loadData(file);
|
||||
for (Map.Entry<String, Object> entry : document.getStringRouteMappedValues(false).entrySet()) {
|
||||
if (entry.getValue() instanceof Section section) {
|
||||
|
||||
CompetitionConfigImpl.Builder builder = new CompetitionConfigImpl.Builder(entry.getKey())
|
||||
.goal(CompetitionGoal.valueOf(section.getString("goal", "TOTAL_SCORE").toUpperCase(Locale.ENGLISH)))
|
||||
CompetitionConfig.Builder builder = CompetitionConfig.builder()
|
||||
.key(entry.getKey())
|
||||
.goal(CompetitionGoal.index().value(section.getString("goal", "TOTAL_SCORE").toLowerCase(Locale.ENGLISH)))
|
||||
.minPlayers(section.getInt("min-players", 0))
|
||||
.duration(section.getInt("duration", 300))
|
||||
.rewards(getPrizeActions(section.getConfigurationSection("rewards")))
|
||||
.requirements(plugin.getRequirementManager().parseRequirements(section.getConfigurationSection("participate-requirements"), false))
|
||||
.joinActions(plugin.getActionManager().getActions(section.getConfigurationSection("participate-actions")))
|
||||
.startActions(plugin.getActionManager().getActions(section.getConfigurationSection("start-actions")))
|
||||
.endActions(plugin.getActionManager().getActions(section.getConfigurationSection("end-actions")))
|
||||
.skipActions(plugin.getActionManager().getActions(section.getConfigurationSection("skip-actions")));
|
||||
.rewards(getPrizeActions(section.getSection("rewards")))
|
||||
.joinRequirements(plugin.getRequirementManager().parseRequirements(section.getSection("participate-requirements"), false))
|
||||
.joinActions(plugin.getActionManager().parseActions(section.getSection("participate-actions")))
|
||||
.startActions(plugin.getActionManager().parseActions(section.getSection("start-actions")))
|
||||
.endActions(plugin.getActionManager().parseActions(section.getSection("end-actions")))
|
||||
.skipActions(plugin.getActionManager().parseActions(section.getSection("skip-actions")));;
|
||||
|
||||
if (section.getBoolean("bossbar.enable", false)) {
|
||||
builder.bossbar(new BossBarConfigImpl.BuilderImpl()
|
||||
.color(BarColor.valueOf(section.getString("bossbar.color", "WHITE").toUpperCase(Locale.ENGLISH)))
|
||||
.overlay(BossBarConfigImpl.Overlay.valueOf(section.getString("bossbar.overlay", "PROGRESS").toUpperCase(Locale.ENGLISH)))
|
||||
.refreshRate(section.getInt("bossbar.refresh-rate", 20))
|
||||
.switchInterval(section.getInt("bossbar.switch-interval", 200))
|
||||
.showToAll(!section.getBoolean("bossbar.only-show-to-participants", true))
|
||||
.text(section.getStringList("bossbar.text").toArray(new String[0]))
|
||||
.build());
|
||||
builder.bossBarConfig(
|
||||
BossBarConfig.builder()
|
||||
.enable(true)
|
||||
.color(BossBar.Color.valueOf(section.getString("bossbar.color", "WHITE").toUpperCase(Locale.ENGLISH)))
|
||||
.overlay(BossBar.Overlay.valueOf(section.getString("bossbar.overlay", "PROGRESS").toUpperCase(Locale.ENGLISH)))
|
||||
.refreshRate(section.getInt("bossbar.refresh-rate", 20))
|
||||
.switchInterval(section.getInt("bossbar.switch-interval", 200))
|
||||
.showToAll(!section.getBoolean("bossbar.only-show-to-participants", true))
|
||||
.text(section.getStringList("bossbar.text").toArray(new String[0]))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
if (section.getBoolean("actionbar.enable", false)) {
|
||||
builder.actionbar(new ActionBarConfigImpl.BuilderImpl()
|
||||
.refreshRate(section.getInt("actionbar.refresh-rate", 5))
|
||||
.switchInterval(section.getInt("actionbar.switch-interval", 200))
|
||||
.showToAll(!section.getBoolean("actionbar.only-show-to-participants", true))
|
||||
.text(section.getStringList("actionbar.text").toArray(new String[0]))
|
||||
.build());
|
||||
builder.actionBarConfig(
|
||||
ActionBarConfig.builder()
|
||||
.enable(true)
|
||||
.refreshRate(section.getInt("actionbar.refresh-rate", 5))
|
||||
.switchInterval(section.getInt("actionbar.switch-interval", 200))
|
||||
.showToAll(!section.getBoolean("actionbar.only-show-to-participants", true))
|
||||
.text(section.getStringList("actionbar.text").toArray(new String[0]))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
CompetitionConfigImpl competitionConfigImpl = builder.build();
|
||||
CompetitionConfig competitionConfig = builder.build();
|
||||
List<Pair<Integer, Integer>> timePairs = section.getStringList("start-time")
|
||||
.stream().map(it -> ConfigUtils.splitStringIntegerArgs(it, ":")).toList();
|
||||
List<Integer> weekdays = section.getIntegerList("start-weekday");
|
||||
if (weekdays.size() == 0) {
|
||||
.stream().map(it -> {
|
||||
String[] split = it.split(":");
|
||||
return Pair.of(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
}).toList();
|
||||
List<Integer> weekdays = section.getIntList("start-weekday");
|
||||
if (weekdays.isEmpty()) {
|
||||
weekdays.addAll(List.of(1,2,3,4,5,6,7));
|
||||
}
|
||||
for (Integer weekday : weekdays) {
|
||||
for (Pair<Integer, Integer> timePair : timePairs) {
|
||||
CompetitionSchedule schedule = new CompetitionSchedule(weekday, timePair.left(), timePair.right(), 0);
|
||||
timeConfigMap.put(schedule, competitionConfigImpl);
|
||||
timeConfigMap.put(schedule, competitionConfig);
|
||||
}
|
||||
}
|
||||
commandConfigMap.put(entry.getKey(), competitionConfigImpl);
|
||||
commandConfigMap.put(entry.getKey(), competitionConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,12 +182,12 @@ public class CompetitionManagerImpl implements CompetitionManager {
|
||||
* @param section The configuration section containing prize actions.
|
||||
* @return A HashMap where keys are action names and values are arrays of Action objects.
|
||||
*/
|
||||
public HashMap<String, Action[]> getPrizeActions(ConfigurationSection section) {
|
||||
HashMap<String, Action[]> map = new HashMap<>();
|
||||
public HashMap<String, Action<Player>[]> getPrizeActions(Section section) {
|
||||
HashMap<String, Action<Player>[]> map = new HashMap<>();
|
||||
if (section == null) return map;
|
||||
for (Map.Entry<String, Object> entry : section.getValues(false).entrySet()) {
|
||||
if (entry.getValue() instanceof ConfigurationSection innerSection) {
|
||||
map.put(entry.getKey(), plugin.getActionManager().getActions(innerSection));
|
||||
for (Map.Entry<String, Object> entry : section.getStringRouteMappedValues(false).entrySet()) {
|
||||
if (entry.getValue() instanceof Section innerSection) {
|
||||
map.put(entry.getKey(), plugin.getActionManager().parseActions(innerSection));
|
||||
}
|
||||
}
|
||||
return map;
|
||||
@@ -209,43 +210,17 @@ public class CompetitionManagerImpl implements CompetitionManager {
|
||||
nextCompetitionTime = Math.min(nextCompetitionTime, schedule.getTimeDelta(seconds));
|
||||
}
|
||||
this.nextCompetitionSeconds = nextCompetitionTime;
|
||||
CompetitionConfigImpl config = timeConfigMap.get(competitionSchedule);
|
||||
CompetitionConfig config = timeConfigMap.get(competitionSchedule);
|
||||
if (config != null) {
|
||||
startCompetition(config, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the localization key for a given competition goal.
|
||||
*
|
||||
* @param goal The competition goal to retrieve the localization key for.
|
||||
* @return The localization key for the specified competition goal.
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCompetitionGoalLocale(CompetitionGoal goal) {
|
||||
switch (goal) {
|
||||
case MAX_SIZE -> {
|
||||
return CFLocale.MSG_Max_Size;
|
||||
}
|
||||
case CATCH_AMOUNT -> {
|
||||
return CFLocale.MSG_Catch_Amount;
|
||||
}
|
||||
case TOTAL_SCORE -> {
|
||||
return CFLocale.MSG_Total_Score;
|
||||
}
|
||||
case TOTAL_SIZE -> {
|
||||
return CFLocale.MSG_Total_Size;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startCompetition(String competition, boolean force, String serverGroup) {
|
||||
CompetitionConfigImpl config = commandConfigMap.get(competition);
|
||||
CompetitionConfig config = commandConfigMap.get(competition);
|
||||
if (config == null) {
|
||||
LogUtils.warn("Competition " + competition + " doesn't exist.");
|
||||
plugin.getPluginLogger().warn("Competition " + competition + " doesn't exist.");
|
||||
return false;
|
||||
}
|
||||
return startCompetition(config, force, serverGroup);
|
||||
@@ -264,17 +239,11 @@ public class CompetitionManagerImpl implements CompetitionManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startCompetition(CompetitionConfigImpl config, boolean force, @Nullable String serverGroup) {
|
||||
public boolean startCompetition(CompetitionConfig config, boolean force, @Nullable String serverGroup) {
|
||||
if (!force) {
|
||||
int players = Bukkit.getOnlinePlayers().size();
|
||||
if (players < config.getMinPlayersToStart()) {
|
||||
var actions = config.getSkipActions();
|
||||
if (actions != null) {
|
||||
PlayerContext playerContext = new PlayerContext(null, null, new HashMap<>());
|
||||
for (Action action : actions) {
|
||||
action.trigger(playerContext);
|
||||
}
|
||||
}
|
||||
if (players < config.minPlayersToStart()) {
|
||||
ActionManager.trigger(Context.player(null), config.skipActions());
|
||||
return false;
|
||||
}
|
||||
start(config);
|
||||
@@ -283,25 +252,30 @@ public class CompetitionManagerImpl implements CompetitionManager {
|
||||
start(config);
|
||||
return true;
|
||||
} else {
|
||||
RedisManager.getInstance().publishRedisMessage(serverGroup, "start;" + config.getKey());
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF(serverGroup);
|
||||
out.writeUTF("competition");
|
||||
out.writeUTF("start");
|
||||
out.writeUTF(config.key());
|
||||
RedisManager.getInstance().publishRedisMessage(Arrays.toString(out.toByteArray()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void start(CompetitionConfigImpl config) {
|
||||
private void start(CompetitionConfig config) {
|
||||
if (getOnGoingCompetition() != null) {
|
||||
// END
|
||||
currentCompetition.end(true);
|
||||
plugin.getScheduler().runTaskAsyncLater(() -> {
|
||||
plugin.getScheduler().asyncLater(() -> {
|
||||
// start one second later
|
||||
this.currentCompetition = new Competition(config);
|
||||
this.currentCompetition.start();
|
||||
this.currentCompetition = new Competition(plugin, config);
|
||||
this.currentCompetition.start(true);
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
} else {
|
||||
// start instantly
|
||||
plugin.getScheduler().runTaskAsync(() -> {
|
||||
this.currentCompetition = new Competition(config);
|
||||
this.currentCompetition.start();
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
this.currentCompetition = new Competition(plugin, config);
|
||||
this.currentCompetition.start(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -312,19 +286,13 @@ public class CompetitionManagerImpl implements CompetitionManager {
|
||||
* @return The number of seconds until the next competition.
|
||||
*/
|
||||
@Override
|
||||
public int getNextCompetitionSeconds() {
|
||||
public int getNextCompetitionInSeconds() {
|
||||
return nextCompetitionSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the configuration for a competition based on its key.
|
||||
*
|
||||
* @param key The key of the competition configuration to retrieve.
|
||||
* @return The {@link CompetitionConfigImpl} for the specified key, or {@code null} if no configuration exists with that key.
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public CompetitionConfigImpl getConfig(String key) {
|
||||
public CompetitionConfig getCompetition(String key) {
|
||||
return commandConfigMap.get(key);
|
||||
}
|
||||
}
|
||||
@@ -18,18 +18,23 @@
|
||||
package net.momirealms.customfishing.bukkit.competition;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.common.Pair;
|
||||
import net.momirealms.customfishing.api.event.CompetitionEvent;
|
||||
import net.momirealms.customfishing.api.mechanic.action.Action;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.CompetitionConfigImpl;
|
||||
import net.momirealms.customfishing.api.mechanic.action.ActionManager;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.CompetitionConfig;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.CompetitionGoal;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.RankingProvider;
|
||||
import net.momirealms.customfishing.api.scheduler.CancellableTask;
|
||||
import net.momirealms.customfishing.api.mechanic.config.ConfigManager;
|
||||
import net.momirealms.customfishing.api.mechanic.context.Context;
|
||||
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
|
||||
import net.momirealms.customfishing.bukkit.competition.actionbar.ActionBarManager;
|
||||
import net.momirealms.customfishing.bukkit.competition.bossbar.BossBarManager;
|
||||
import net.momirealms.customfishing.bukkit.competition.ranking.LocalRankingProvider;
|
||||
import net.momirealms.customfishing.bukkit.competition.ranking.RedisRankingProvider;
|
||||
import net.momirealms.customfishing.common.locale.StandardLocales;
|
||||
import net.momirealms.customfishing.common.plugin.scheduler.SchedulerTask;
|
||||
import net.momirealms.customfishing.common.util.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -38,77 +43,139 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Competition implements FishingCompetition {
|
||||
|
||||
private final CompetitionConfigImpl config;
|
||||
private CancellableTask competitionTimerTask;
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
private final CompetitionConfig config;
|
||||
private SchedulerTask competitionTimerTask;
|
||||
private final CompetitionGoal goal;
|
||||
private final ConcurrentHashMap<String, String> publicPlaceholders;
|
||||
private final Context<Player> publicContext;
|
||||
private final RankingProvider rankingProvider;
|
||||
private float progress;
|
||||
private long remainingTime;
|
||||
private int remainingTime;
|
||||
private long startTime;
|
||||
private BossBarManager bossBarManager;
|
||||
private ActionBarManager actionBarManager;
|
||||
|
||||
public Competition(CompetitionConfigImpl config) {
|
||||
public Competition(BukkitCustomFishingPlugin plugin, CompetitionConfig config) {
|
||||
this.config = config;
|
||||
this.goal = config.getGoal() == CompetitionGoal.RANDOM ? CompetitionGoal.getRandom() : config.getGoal();
|
||||
if (CFConfig.redisRanking) this.rankingProvider = new RedisRankingProvider();
|
||||
else this.rankingProvider = new LocalRankingProvider();
|
||||
this.publicPlaceholders = new ConcurrentHashMap<>();
|
||||
this.publicPlaceholders.put("{goal}", BukkitCustomFishingPlugin.get().getCompetitionManager().getCompetitionGoalLocale(goal));
|
||||
this.plugin = plugin;
|
||||
this.goal = config.goal() == CompetitionGoal.RANDOM ? CompetitionGoal.getRandom() : config.goal();
|
||||
if (ConfigManager.redisRanking()) this.rankingProvider = new RedisRankingProvider();
|
||||
else this.rankingProvider = new LocalRankingProvider();
|
||||
this.publicContext = Context.player(null, true);
|
||||
this.publicContext.arg(
|
||||
ContextKeys.GOAL,
|
||||
goal
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the fishing competition, initializing its settings and actions.
|
||||
* This method sets the initial progress, remaining time, start time, and updates public placeholders.
|
||||
* It also arranges timer tasks for competition timing and initializes boss bar and action bar managers if configured.
|
||||
* Additionally, it triggers the start actions defined in the competition's configuration.
|
||||
*/
|
||||
@Override
|
||||
public void start() {
|
||||
public void start(boolean triggerEvent) {
|
||||
this.progress = 1;
|
||||
this.remainingTime = config.getDurationInSeconds();
|
||||
this.remainingTime = this.config.durationInSeconds();
|
||||
this.startTime = Instant.now().getEpochSecond();
|
||||
|
||||
this.arrangeTimerTask();
|
||||
if (config.getBossBarConfig() != null) {
|
||||
this.bossBarManager = new BossBarManager(config.getBossBarConfig(), this);
|
||||
if (this.config.bossBarConfig() != null && this.config.bossBarConfig().enabled()) {
|
||||
this.bossBarManager = new BossBarManager(this.config.bossBarConfig(), this);
|
||||
this.bossBarManager.load();
|
||||
}
|
||||
if (config.getActionBarConfig() != null) {
|
||||
this.actionBarManager = new ActionBarManager(config.getActionBarConfig(), this);
|
||||
if (this.config.actionBarConfig() != null && this.config.actionBarConfig().enabled()) {
|
||||
this.actionBarManager = new ActionBarManager(this.config.actionBarConfig(), this);
|
||||
this.actionBarManager.load();
|
||||
}
|
||||
|
||||
Action[] actions = config.startActions();
|
||||
if (actions != null) {
|
||||
PlayerContext playerContext = new PlayerContext(null, null, this.publicPlaceholders);
|
||||
for (Action action : actions) {
|
||||
action.trigger(playerContext);
|
||||
this.updatePublicPlaceholders();
|
||||
ActionManager.trigger(this.publicContext, this.config.startActions());
|
||||
this.rankingProvider.clear();
|
||||
if (triggerEvent) {
|
||||
this.plugin.getScheduler().async().execute(() -> {
|
||||
CompetitionEvent competitionStartEvent = new CompetitionEvent(CompetitionEvent.State.START, this);
|
||||
Bukkit.getPluginManager().callEvent(competitionStartEvent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(boolean triggerEvent) {
|
||||
if (this.competitionTimerTask != null)
|
||||
this.competitionTimerTask.cancel();
|
||||
if (this.bossBarManager != null)
|
||||
this.bossBarManager.unload();
|
||||
if (this.actionBarManager != null)
|
||||
this.actionBarManager.unload();
|
||||
this.rankingProvider.clear();
|
||||
this.remainingTime = 0;
|
||||
if (triggerEvent) {
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
CompetitionEvent competitionEvent = new CompetitionEvent(CompetitionEvent.State.STOP, this);
|
||||
Bukkit.getPluginManager().callEvent(competitionEvent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(boolean triggerEvent) {
|
||||
// mark it as ended
|
||||
this.remainingTime = 0;
|
||||
|
||||
// cancel some sub tasks
|
||||
if (competitionTimerTask != null)
|
||||
this.competitionTimerTask.cancel();
|
||||
if (this.bossBarManager != null)
|
||||
this.bossBarManager.unload();
|
||||
if (this.actionBarManager != null)
|
||||
this.actionBarManager.unload();
|
||||
|
||||
// give prizes
|
||||
HashMap<String, Action<Player>[]> rewardsMap = config.rewards();
|
||||
if (rankingProvider.getSize() != 0 && rewardsMap != null) {
|
||||
Iterator<Pair<String, Double>> iterator = rankingProvider.getIterator();
|
||||
int i = 1;
|
||||
while (iterator.hasNext()) {
|
||||
Pair<String, Double> competitionPlayer = iterator.next();
|
||||
this.publicContext.arg(ContextKeys.of(i + "_player", String.class), competitionPlayer.left());
|
||||
this.publicContext.arg(ContextKeys.of(i + "_score", String.class), String.format("%.2f", competitionPlayer.right()));
|
||||
if (i < rewardsMap.size()) {
|
||||
Player player = Bukkit.getPlayer(competitionPlayer.left());
|
||||
if (player != null) {
|
||||
ActionManager.trigger(Context.player(player).combine(this.publicContext), rewardsMap.get(String.valueOf(i)));
|
||||
}
|
||||
} else {
|
||||
Action<Player>[] actions = rewardsMap.get("participation");
|
||||
if (actions != null) {
|
||||
Player player = Bukkit.getPlayer(competitionPlayer.left()); {
|
||||
if (player != null) {
|
||||
ActionManager.trigger(Context.player(player).combine(this.publicContext), actions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
this.rankingProvider.clear();
|
||||
this.updatePublicPlaceholders();
|
||||
// end actions
|
||||
ActionManager.trigger(publicContext, config.endActions());
|
||||
|
||||
CompetitionEvent competitionStartEvent = new CompetitionEvent(CompetitionEvent.State.START, this);
|
||||
Bukkit.getPluginManager().callEvent(competitionStartEvent);
|
||||
// call event
|
||||
if (triggerEvent) {
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
CompetitionEvent competitionEndEvent = new CompetitionEvent(CompetitionEvent.State.END, this);
|
||||
Bukkit.getPluginManager().callEvent(competitionEndEvent);
|
||||
});
|
||||
}
|
||||
|
||||
// 1 seconds delay for other servers to read the redis data
|
||||
plugin.getScheduler().asyncLater(this.rankingProvider::clear, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Arranges the timer task for the fishing competition.
|
||||
* This method schedules a recurring task that updates the competition's remaining time and public placeholders.
|
||||
* If the remaining time reaches zero, the competition is ended.
|
||||
*/
|
||||
private void arrangeTimerTask() {
|
||||
this.competitionTimerTask = BukkitCustomFishingPlugin.get().getScheduler().runTaskAsyncTimer(() -> {
|
||||
this.competitionTimerTask = this.plugin.getScheduler().asyncRepeating(() -> {
|
||||
if (decreaseTime()) {
|
||||
end(true);
|
||||
return;
|
||||
@@ -117,115 +184,23 @@ public class Competition implements FishingCompetition {
|
||||
}, 1, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update public placeholders for the fishing competition.
|
||||
* This method updates placeholders representing player rankings, remaining time, and score in public messages.
|
||||
* Placeholders for player rankings include {1_player}, {1_score}, {2_player}, {2_score}, and so on.
|
||||
* The placeholders for time include {hour}, {minute}, {second}, and {seconds}.
|
||||
*/
|
||||
private void updatePublicPlaceholders() {
|
||||
for (int i = 1; i < CFConfig.placeholderLimit + 1; i++) {
|
||||
int finalI = i;
|
||||
Optional.ofNullable(rankingProvider.getPlayerAt(i)).ifPresentOrElse(player -> {
|
||||
publicPlaceholders.put("{" + finalI + "_player}", player);
|
||||
publicPlaceholders.put("{" + finalI + "_score}", String.format("%.2f", rankingProvider.getScoreAt(finalI)));
|
||||
}, () -> {
|
||||
publicPlaceholders.put("{" + finalI + "_player}", CFLocale.MSG_No_Player);
|
||||
publicPlaceholders.put("{" + finalI + "_score}", CFLocale.MSG_No_Score);
|
||||
});
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the fishing competition.
|
||||
* This method cancels the competition timer task, unloads boss bars and action bars, clears the ranking,
|
||||
* and sets the remaining time to zero.
|
||||
*/
|
||||
@Override
|
||||
public void stop(boolean triggerEvent) {
|
||||
if (!competitionTimerTask.isCancelled()) this.competitionTimerTask.cancel();
|
||||
if (this.bossBarManager != null) this.bossBarManager.unload();
|
||||
if (this.actionBarManager != null) this.actionBarManager.unload();
|
||||
this.rankingProvider.clear();
|
||||
this.remainingTime = 0;
|
||||
|
||||
if (triggerEvent) {
|
||||
CompetitionEvent competitionEvent = new CompetitionEvent(CompetitionEvent.State.STOP, this);
|
||||
Bukkit.getPluginManager().callEvent(competitionEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End the fishing competition.
|
||||
* This method marks the competition as ended, cancels sub-tasks such as timers and bar management,
|
||||
* gives prizes to top participants and participation rewards, performs end actions, and clears the ranking.
|
||||
*/
|
||||
@Override
|
||||
public void end(boolean triggerEvent) {
|
||||
// mark it as ended
|
||||
this.remainingTime = 0;
|
||||
|
||||
// cancel some sub tasks
|
||||
if (!competitionTimerTask.isCancelled()) this.competitionTimerTask.cancel();
|
||||
if (this.bossBarManager != null) this.bossBarManager.unload();
|
||||
if (this.actionBarManager != null) this.actionBarManager.unload();
|
||||
|
||||
// give prizes
|
||||
HashMap<String, Action[]> rewardsMap = config.getRewards();
|
||||
if (rankingProvider.getSize() != 0 && rewardsMap != null) {
|
||||
Iterator<Pair<String, Double>> iterator = rankingProvider.getIterator();
|
||||
int i = 1;
|
||||
while (iterator.hasNext()) {
|
||||
Pair<String, Double> competitionPlayer = iterator.next();
|
||||
this.publicPlaceholders.put("{" + i + "_player}", competitionPlayer.left());
|
||||
this.publicPlaceholders.put("{" + i + "_score}", String.format("%.2f", competitionPlayer.right()));
|
||||
if (i < rewardsMap.size()) {
|
||||
Player player = Bukkit.getPlayer(competitionPlayer.left());
|
||||
if (player != null)
|
||||
for (Action action : rewardsMap.get(String.valueOf(i)))
|
||||
action.trigger(new PlayerContext(player, this.publicPlaceholders));
|
||||
} else {
|
||||
Action[] actions = rewardsMap.get("participation");
|
||||
if (actions != null) {
|
||||
Player player = Bukkit.getPlayer(competitionPlayer.left()); {
|
||||
if (player != null)
|
||||
for (Action action : actions)
|
||||
action.trigger(new PlayerContext(player, this.publicPlaceholders));
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
for (int i = 1; i < ConfigManager.placeholderLimit() + 1; i++) {
|
||||
Optional<String> player = Optional.ofNullable(this.rankingProvider.getPlayerAt(i));
|
||||
if (player.isPresent()) {
|
||||
this.publicContext.arg(ContextKeys.of(i + "_player", String.class), player.get());
|
||||
this.publicContext.arg(ContextKeys.of(i + "_score", String.class), String.format("%.2f", this.rankingProvider.getScoreAt(i)));
|
||||
} else {
|
||||
this.publicContext.arg(ContextKeys.of(i + "_player", String.class), StandardLocales.COMPETITION_NO_PLAYER);
|
||||
this.publicContext.arg(ContextKeys.of(i + "_score", String.class), StandardLocales.COMPETITION_NO_SCORE);
|
||||
}
|
||||
}
|
||||
|
||||
// do end actions
|
||||
Action[] actions = config.getEndActions();
|
||||
if (actions != null) {
|
||||
PlayerContext playerContext = new PlayerContext(null, null, new HashMap<>(publicPlaceholders));
|
||||
for (Action action : actions) {
|
||||
action.trigger(playerContext);
|
||||
}
|
||||
}
|
||||
|
||||
// call event
|
||||
if (triggerEvent) {
|
||||
CompetitionEvent competitionEndEvent = new CompetitionEvent(CompetitionEvent.State.END, this);
|
||||
Bukkit.getPluginManager().callEvent(competitionEndEvent);
|
||||
}
|
||||
|
||||
// 1 seconds delay for other servers to read the redis data
|
||||
BukkitCustomFishingPlugin.get().getScheduler().runTaskAsyncLater(this.rankingProvider::clear, 1, TimeUnit.SECONDS);
|
||||
this.publicContext.arg(ContextKeys.HOUR, remainingTime < 3600 ? "" : (remainingTime / 3600) + StandardLocales.FORMAT_HOUR);
|
||||
this.publicContext.arg(ContextKeys.MINUTE, remainingTime < 60 ? "" : (remainingTime % 3600) / 60 + StandardLocales.FORMAT_MINUTE);
|
||||
this.publicContext.arg(ContextKeys.SECOND, remainingTime == 0 ? "" : remainingTime % 60 + StandardLocales.FORMAT_SECOND);
|
||||
this.publicContext.arg(ContextKeys.SECONDS, remainingTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the fishing competition is ongoing.
|
||||
*
|
||||
* @return {@code true} if the competition is still ongoing, {@code false} if it has ended.
|
||||
*/
|
||||
@Override
|
||||
public boolean isOnGoing() {
|
||||
return remainingTime > 0;
|
||||
@@ -238,141 +213,69 @@ public class Competition implements FishingCompetition {
|
||||
*/
|
||||
private boolean decreaseTime() {
|
||||
long current = Instant.now().getEpochSecond();
|
||||
int duration = config.getDurationInSeconds();
|
||||
remainingTime = duration - (current - startTime);
|
||||
int duration = config.durationInSeconds();
|
||||
remainingTime = (int) (duration - (current - startTime));
|
||||
progress = (float) remainingTime / duration;
|
||||
return remainingTime <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the data for a player in the fishing competition, including updating their score and triggering
|
||||
* actions if it's their first time joining the competition.
|
||||
*
|
||||
* @param player The player whose data needs to be refreshed.
|
||||
* @param score The player's current score in the competition.
|
||||
*/
|
||||
@Override
|
||||
public void refreshData(Player player, double score) {
|
||||
// if player join for the first time, trigger join actions
|
||||
if (!hasPlayerJoined(player)) {
|
||||
Action[] actions = config.getJoinActions();
|
||||
if (actions != null) {
|
||||
PlayerContext playerContext = new PlayerContext(player);
|
||||
for (Action action : actions) {
|
||||
action.trigger(playerContext);
|
||||
}
|
||||
}
|
||||
ActionManager.trigger(Context.player(player).combine(publicContext), config.joinActions());
|
||||
}
|
||||
|
||||
// show competition info
|
||||
if (this.bossBarManager != null) this.bossBarManager.showBossBarTo(player);
|
||||
if (this.actionBarManager != null) this.actionBarManager.showActionBarTo(player);
|
||||
if (this.bossBarManager != null)
|
||||
this.bossBarManager.showBossBarTo(player);
|
||||
if (this.actionBarManager != null)
|
||||
this.actionBarManager.showActionBarTo(player);
|
||||
|
||||
// refresh data
|
||||
switch (this.goal) {
|
||||
case CATCH_AMOUNT -> rankingProvider.refreshData(player.getName(), 1);
|
||||
case TOTAL_SIZE, TOTAL_SCORE -> rankingProvider.refreshData(player.getName(), score);
|
||||
case MAX_SIZE -> {
|
||||
if (score > rankingProvider.getPlayerScore(player.getName())) {
|
||||
rankingProvider.setData(player.getName(), score);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.goal.refreshScore(rankingProvider, player, score);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player has joined the fishing competition based on their name.
|
||||
*
|
||||
* @param player The player to check for participation.
|
||||
* @return {@code true} if the player has joined the competition; {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean hasPlayerJoined(OfflinePlayer player) {
|
||||
return rankingProvider.getPlayerRank(player.getName()) != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the progress of the fishing competition as a float value (0~1).
|
||||
*
|
||||
* @return The progress of the fishing competition as a float.
|
||||
*/
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remaining time in seconds for the fishing competition.
|
||||
*
|
||||
* @return The remaining time in seconds.
|
||||
*/
|
||||
@Override
|
||||
public long getRemainingTime() {
|
||||
return remainingTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the start time of the fishing competition.
|
||||
*
|
||||
* @return The start time of the fishing competition.
|
||||
*/
|
||||
@Override
|
||||
public long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration of the fishing competition.
|
||||
*
|
||||
* @return The configuration of the fishing competition.
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public CompetitionConfigImpl getConfig() {
|
||||
public CompetitionConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the goal of the fishing competition.
|
||||
*
|
||||
* @return The goal of the fishing competition.
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public CompetitionGoal getGoal() {
|
||||
return goal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ranking data for the fishing competition.
|
||||
*
|
||||
* @return The ranking data for the fishing competition.
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public RankingProvider getRanking() {
|
||||
return rankingProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cached placeholders for the fishing competition.
|
||||
*
|
||||
* @return A ConcurrentHashMap containing cached placeholders.
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, String> getCachedPlaceholders() {
|
||||
return publicPlaceholders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a specific cached placeholder value by its key.
|
||||
*
|
||||
* @param papi The key of the cached placeholder.
|
||||
* @return The cached placeholder value as a string, or null if not found.
|
||||
*/
|
||||
@Override
|
||||
public String getCachedPlaceholder(String papi) {
|
||||
return publicPlaceholders.get(papi);
|
||||
public Context<Player> getPublicContext() {
|
||||
return publicContext;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package net.momirealms.customfishing.bukkit.competition.actionbar;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.info.ActionBarConfigImpl;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.info.ActionBarConfig;
|
||||
import net.momirealms.customfishing.bukkit.competition.Competition;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -35,11 +35,11 @@ import java.util.concurrent.TimeUnit;
|
||||
public class ActionBarManager implements Listener {
|
||||
|
||||
private static final ConcurrentHashMap<UUID, ActionBarSender> senderMap = new ConcurrentHashMap<>();
|
||||
private final ActionBarConfigImpl actionBarConfigImpl;
|
||||
private final ActionBarConfig actionBarConfig;
|
||||
private final Competition competition;
|
||||
|
||||
public ActionBarManager(ActionBarConfigImpl actionBarConfigImpl, Competition competition) {
|
||||
this.actionBarConfigImpl = actionBarConfigImpl;
|
||||
public ActionBarManager(ActionBarConfig actionBarConfig, Competition competition) {
|
||||
this.actionBarConfig = actionBarConfig;
|
||||
this.competition = competition;
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ public class ActionBarManager implements Listener {
|
||||
* Loads the ActionBar manager, registering events and showing ActionBar messages to online players.
|
||||
*/
|
||||
public void load() {
|
||||
Bukkit.getPluginManager().registerEvents(this, BukkitCustomFishingPlugin.getInstance());
|
||||
if (actionBarConfigImpl.showToAll()) {
|
||||
Bukkit.getPluginManager().registerEvents(this, BukkitCustomFishingPlugin.getInstance().getBoostrap());
|
||||
if (actionBarConfig.showToAll()) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
ActionBarSender sender = new ActionBarSender(player, actionBarConfigImpl, competition);
|
||||
ActionBarSender sender = new ActionBarSender(player, actionBarConfig, competition);
|
||||
if (!sender.isVisible()) {
|
||||
sender.show();
|
||||
}
|
||||
@@ -93,11 +93,11 @@ public class ActionBarManager implements Listener {
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
BukkitCustomFishingPlugin.getInstance().getScheduler().runTaskAsyncLater(() -> {
|
||||
BukkitCustomFishingPlugin.getInstance().getScheduler().asyncLater(() -> {
|
||||
boolean hasJoined = competition.hasPlayerJoined(player);
|
||||
if ((hasJoined || actionBarConfigImpl.showToAll())
|
||||
if ((hasJoined || actionBarConfig.showToAll())
|
||||
&& !senderMap.containsKey(player.getUniqueId())) {
|
||||
ActionBarSender sender = new ActionBarSender(player, actionBarConfigImpl, competition);
|
||||
ActionBarSender sender = new ActionBarSender(player, actionBarConfig, competition);
|
||||
if (!sender.isVisible()) {
|
||||
sender.show();
|
||||
}
|
||||
@@ -114,11 +114,10 @@ public class ActionBarManager implements Listener {
|
||||
public void showActionBarTo(Player player) {
|
||||
ActionBarSender sender = senderMap.get(player.getUniqueId());
|
||||
if (sender == null) {
|
||||
sender = new ActionBarSender(player, actionBarConfigImpl, competition);
|
||||
sender = new ActionBarSender(player, actionBarConfig, competition);
|
||||
senderMap.put(player.getUniqueId(), sender);
|
||||
}
|
||||
if (!sender.isVisible()) {
|
||||
if (!sender.isVisible())
|
||||
sender.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,73 +17,61 @@
|
||||
|
||||
package net.momirealms.customfishing.bukkit.competition.actionbar;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.info.ActionBarConfigImpl;
|
||||
import net.momirealms.customfishing.api.scheduler.CancellableTask;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.info.ActionBarConfig;
|
||||
import net.momirealms.customfishing.api.mechanic.context.Context;
|
||||
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.value.DynamicText;
|
||||
import net.momirealms.customfishing.bukkit.competition.Competition;
|
||||
import net.momirealms.customfishing.mechanic.misc.DynamicText;
|
||||
import net.momirealms.customfishing.common.helper.AdventureHelper;
|
||||
import net.momirealms.customfishing.common.locale.StandardLocales;
|
||||
import net.momirealms.customfishing.common.plugin.scheduler.SchedulerTask;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Manages and updates ActionBar messages for a specific player in a competition context.
|
||||
*/
|
||||
public class ActionBarSender {
|
||||
|
||||
private final Player player;
|
||||
private final Audience audience;
|
||||
private int refreshTimer;
|
||||
private int switchTimer;
|
||||
private int counter;
|
||||
private final DynamicText[] texts;
|
||||
private CancellableTask senderTask;
|
||||
private final ActionBarConfigImpl config;
|
||||
private SchedulerTask senderTask;
|
||||
private final ActionBarConfig config;
|
||||
private boolean isShown;
|
||||
private final Competition competition;
|
||||
private final HashMap<String, String> privatePlaceholders;
|
||||
private final Context<Player> privateContext;
|
||||
|
||||
/**
|
||||
* Creates a new ActionBarSender instance for a player.
|
||||
*
|
||||
* @param player The player to manage ActionBar messages for.
|
||||
* @param config The configuration for ActionBar messages.
|
||||
* @param competition The competition associated with this ActionBarSender.
|
||||
*/
|
||||
public ActionBarSender(Player player, ActionBarConfigImpl config, Competition competition) {
|
||||
public ActionBarSender(Player player, ActionBarConfig config, Competition competition) {
|
||||
this.player = player;
|
||||
this.audience = BukkitCustomFishingPlugin.getInstance().getSenderFactory().getAudience(player);
|
||||
this.config = config;
|
||||
this.privateContext = Context.player(player);
|
||||
this.isShown = false;
|
||||
this.competition = competition;
|
||||
this.privatePlaceholders = new HashMap<>();
|
||||
this.privatePlaceholders.put("{player}", player.getName());
|
||||
this.updatePrivatePlaceholders();
|
||||
|
||||
String[] str = config.texts();
|
||||
texts = new DynamicText[str.length];
|
||||
for (int i = 0; i < str.length; i++) {
|
||||
texts[i] = new DynamicText(player, str[i]);
|
||||
texts[i].update(privatePlaceholders);
|
||||
texts[i].update(privateContext.placeholderMap());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates private placeholders used in ActionBar messages.
|
||||
*/
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
private void updatePrivatePlaceholders() {
|
||||
this.privatePlaceholders.put("{score}", String.format("%.2f", competition.getRanking().getPlayerScore(player.getName())));
|
||||
this.privateContext.arg(ContextKeys.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) : CFLocale.MSG_No_Rank);
|
||||
this.privatePlaceholders.putAll(competition.getCachedPlaceholders());
|
||||
this.privateContext.arg(ContextKeys.RANK, rank != -1 ? String.valueOf(rank) : StandardLocales.COMPETITION_NO_RANK);
|
||||
this.privateContext.combine(competition.getPublicContext());
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the ActionBar message to the player.
|
||||
*/
|
||||
public void show() {
|
||||
this.isShown = true;
|
||||
senderTask = BukkitCustomFishingPlugin.get().getScheduler().runTaskAsyncTimer(() -> {
|
||||
senderTask = BukkitCustomFishingPlugin.getInstance().getScheduler().asyncRepeating(() -> {
|
||||
switchTimer++;
|
||||
if (switchTimer > config.switchInterval()) {
|
||||
switchTimer = 0;
|
||||
@@ -95,39 +83,23 @@ public class ActionBarSender {
|
||||
refreshTimer = 0;
|
||||
DynamicText text = texts[counter % (texts.length)];
|
||||
updatePrivatePlaceholders();
|
||||
text.update(privatePlaceholders);
|
||||
AdventureHelper.getInstance().sendActionbar(
|
||||
player,
|
||||
text.getLatestValue()
|
||||
);
|
||||
text.update(this.privateContext.placeholderMap());
|
||||
audience.sendActionBar(AdventureHelper.miniMessage().deserialize(text.getLatestValue()));
|
||||
}
|
||||
}, 50, 50, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the ActionBar message from the player.
|
||||
*/
|
||||
public void hide() {
|
||||
if (senderTask != null && !senderTask.isCancelled())
|
||||
if (senderTask != null)
|
||||
senderTask.cancel();
|
||||
this.isShown = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the ActionBar message is currently visible to the player.
|
||||
*
|
||||
* @return True if the ActionBar message is visible, false otherwise.
|
||||
*/
|
||||
public boolean isVisible() {
|
||||
return this.isShown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ActionBar configuration.
|
||||
*
|
||||
* @return The ActionBar configuration.
|
||||
*/
|
||||
public ActionBarConfigImpl getConfig() {
|
||||
public ActionBarConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package net.momirealms.customfishing.bukkit.competition.bossbar;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.info.BossBarConfigImpl;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.info.BossBarConfig;
|
||||
import net.momirealms.customfishing.bukkit.competition.Competition;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -35,11 +35,11 @@ import java.util.concurrent.TimeUnit;
|
||||
public class BossBarManager implements Listener {
|
||||
|
||||
private static final ConcurrentHashMap<UUID, BossBarSender> senderMap = new ConcurrentHashMap<>();
|
||||
private final BossBarConfigImpl bossBarConfigImpl;
|
||||
private final BossBarConfig bossBarConfig;
|
||||
private final Competition competition;
|
||||
|
||||
public BossBarManager(BossBarConfigImpl bossBarConfigImpl, Competition competition) {
|
||||
this.bossBarConfigImpl = bossBarConfigImpl;
|
||||
public BossBarManager(BossBarConfig bossBarConfig, Competition competition) {
|
||||
this.bossBarConfig = bossBarConfig;
|
||||
this.competition = competition;
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ public class BossBarManager implements Listener {
|
||||
* Loads the boss bar manager, registering events and showing boss bars to online players.
|
||||
*/
|
||||
public void load() {
|
||||
Bukkit.getPluginManager().registerEvents(this, BukkitCustomFishingPlugin.getInstance());
|
||||
if (bossBarConfigImpl.showToAll()) {
|
||||
Bukkit.getPluginManager().registerEvents(this, BukkitCustomFishingPlugin.getInstance().getBoostrap());
|
||||
if (bossBarConfig.showToAll()) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
BossBarSender sender = new BossBarSender(player, bossBarConfigImpl, competition);
|
||||
BossBarSender sender = new BossBarSender(player, bossBarConfig, competition);
|
||||
if (!sender.isVisible()) {
|
||||
sender.show();
|
||||
}
|
||||
@@ -93,11 +93,11 @@ public class BossBarManager implements Listener {
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
BukkitCustomFishingPlugin.getInstance().getScheduler().runTaskAsyncLater(() -> {
|
||||
BukkitCustomFishingPlugin.getInstance().getScheduler().asyncLater(() -> {
|
||||
boolean hasJoined = competition.hasPlayerJoined(player);
|
||||
if ((hasJoined || bossBarConfigImpl.showToAll())
|
||||
if ((hasJoined || bossBarConfig.showToAll())
|
||||
&& !senderMap.containsKey(player.getUniqueId())) {
|
||||
BossBarSender sender = new BossBarSender(player, bossBarConfigImpl, competition);
|
||||
BossBarSender sender = new BossBarSender(player, bossBarConfig, competition);
|
||||
if (!sender.isVisible()) {
|
||||
sender.show();
|
||||
}
|
||||
@@ -114,11 +114,10 @@ public class BossBarManager implements Listener {
|
||||
public void showBossBarTo(Player player) {
|
||||
BossBarSender sender = senderMap.get(player.getUniqueId());
|
||||
if (sender == null) {
|
||||
sender = new BossBarSender(player, bossBarConfigImpl, competition);
|
||||
sender = new BossBarSender(player, bossBarConfig, competition);
|
||||
senderMap.put(player.getUniqueId(), sender);
|
||||
}
|
||||
if (!sender.isVisible()) {
|
||||
if (!sender.isVisible())
|
||||
sender.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,87 +17,72 @@
|
||||
|
||||
package net.momirealms.customfishing.bukkit.competition.bossbar;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.InternalStructure;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customfishing.BukkitCustomFishingPluginImpl;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.info.BossBarConfigImpl;
|
||||
import net.momirealms.customfishing.api.scheduler.CancellableTask;
|
||||
import net.momirealms.customfishing.api.util.ReflectionUtils;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.info.BossBarConfig;
|
||||
import net.momirealms.customfishing.api.mechanic.context.Context;
|
||||
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.value.DynamicText;
|
||||
import net.momirealms.customfishing.bukkit.competition.Competition;
|
||||
import net.momirealms.customfishing.mechanic.misc.DynamicText;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import net.momirealms.customfishing.common.helper.AdventureHelper;
|
||||
import net.momirealms.customfishing.common.locale.StandardLocales;
|
||||
import net.momirealms.customfishing.common.plugin.scheduler.SchedulerTask;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Manages and updates boss bars for a specific player in a competition context.
|
||||
*/
|
||||
public class BossBarSender {
|
||||
|
||||
private final Player player;
|
||||
private final Audience audience;
|
||||
private int refreshTimer;
|
||||
private int switchTimer;
|
||||
private int counter;
|
||||
private final DynamicText[] texts;
|
||||
private CancellableTask senderTask;
|
||||
private final UUID uuid;
|
||||
private final BossBarConfigImpl config;
|
||||
private SchedulerTask senderTask;
|
||||
private final BossBar bossBar;
|
||||
private final BossBarConfig config;
|
||||
private boolean isShown;
|
||||
private final Competition competition;
|
||||
private final HashMap<String, String> privatePlaceholders;
|
||||
private final Context<Player> privateContext;
|
||||
|
||||
/**
|
||||
* Creates a new BossBarSender instance for a player.
|
||||
*
|
||||
* @param player The player to manage the boss bar for.
|
||||
* @param config The configuration for the boss bar.
|
||||
* @param competition The competition associated with this boss bar.
|
||||
*/
|
||||
public BossBarSender(Player player, BossBarConfigImpl config, Competition competition) {
|
||||
public BossBarSender(Player player, BossBarConfig config, Competition competition) {
|
||||
this.player = player;
|
||||
this.uuid = UUID.randomUUID();
|
||||
this.audience = BukkitCustomFishingPlugin.getInstance().getSenderFactory().getAudience(player);
|
||||
this.config = config;
|
||||
this.isShown = false;
|
||||
this.competition = competition;
|
||||
this.privatePlaceholders = new HashMap<>();
|
||||
this.privatePlaceholders.put("{player}", player.getName());
|
||||
this.privateContext = Context.player(player);
|
||||
this.updatePrivatePlaceholders();
|
||||
|
||||
String[] str = config.texts();
|
||||
texts = new DynamicText[str.length];
|
||||
for (int i = 0; i < str.length; i++) {
|
||||
texts[i] = new DynamicText(player, str[i]);
|
||||
texts[i].update(privatePlaceholders);
|
||||
texts[i].update(privateContext.placeholderMap());
|
||||
}
|
||||
bossBar = BossBar.bossBar(
|
||||
AdventureHelper.miniMessage().deserialize(texts[0].getLatestValue()),
|
||||
competition.getProgress(),
|
||||
config.color(),
|
||||
config.overlay(),
|
||||
Set.of()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates private placeholders used in boss bar messages.
|
||||
*/
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
private void updatePrivatePlaceholders() {
|
||||
this.privatePlaceholders.put("{score}", String.format("%.2f", competition.getRanking().getPlayerScore(player.getName())));
|
||||
this.privateContext.arg(ContextKeys.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) : CFLocale.MSG_No_Rank);
|
||||
this.privatePlaceholders.putAll(competition.getCachedPlaceholders());
|
||||
this.privateContext.arg(ContextKeys.RANK, rank != -1 ? String.valueOf(rank) : StandardLocales.COMPETITION_NO_RANK);
|
||||
this.privateContext.combine(competition.getPublicContext());
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the boss bar to the player.
|
||||
*/
|
||||
public void show() {
|
||||
this.isShown = true;
|
||||
BukkitCustomFishingPluginImpl.getProtocolManager().sendServerPacket(player, getCreatePacket());
|
||||
senderTask = BukkitCustomFishingPlugin.get().getScheduler().runTaskAsyncTimer(() -> {
|
||||
this.bossBar.addViewer(audience);
|
||||
this.senderTask = BukkitCustomFishingPlugin.getInstance().getScheduler().asyncRepeating(() -> {
|
||||
switchTimer++;
|
||||
if (switchTimer > config.switchInterval()) {
|
||||
switchTimer = 0;
|
||||
@@ -109,88 +94,25 @@ public class BossBarSender {
|
||||
refreshTimer = 0;
|
||||
DynamicText text = texts[counter % (texts.length)];
|
||||
updatePrivatePlaceholders();
|
||||
if (text.update(privatePlaceholders)) {
|
||||
BukkitCustomFishingPluginImpl.getProtocolManager().sendServerPacket(player, getUpdatePacket(text));
|
||||
if (text.update(privateContext.placeholderMap())) {
|
||||
bossBar.name(AdventureHelper.miniMessage().deserialize(text.getLatestValue()));
|
||||
}
|
||||
BukkitCustomFishingPluginImpl.getProtocolManager().sendServerPacket(player, getProgressPacket());
|
||||
bossBar.progress(competition.getProgress());
|
||||
}
|
||||
}, 50, 50, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the boss bar is currently visible to the player.
|
||||
*
|
||||
* @return True if the boss bar is visible, false otherwise.
|
||||
*/
|
||||
public boolean isVisible() {
|
||||
return this.isShown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the boss bar configuration.
|
||||
*
|
||||
* @return The boss bar configuration.
|
||||
*/
|
||||
public BossBarConfigImpl getConfig() {
|
||||
public BossBarConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the boss bar from the player.
|
||||
*/
|
||||
public void hide() {
|
||||
BukkitCustomFishingPluginImpl.getProtocolManager().sendServerPacket(player, getRemovePacket());
|
||||
if (senderTask != null && !senderTask.isCancelled()) senderTask.cancel();
|
||||
this.bossBar.removeViewer(audience);
|
||||
if (senderTask != null) senderTask.cancel();
|
||||
this.isShown = false;
|
||||
}
|
||||
|
||||
private PacketContainer getUpdatePacket(DynamicText text) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS);
|
||||
packet.getModifier().write(0, uuid);
|
||||
try {
|
||||
Object chatComponent = ReflectionUtils.iChatComponentMethod.invoke(null,
|
||||
GsonComponentSerializer.gson().serialize(
|
||||
AdventureHelper.getInstance().getComponentFromMiniMessage(
|
||||
text.getLatestValue()
|
||||
)));
|
||||
Object updatePacket = ReflectionUtils.updateConstructor.newInstance(chatComponent);
|
||||
packet.getModifier().write(1, updatePacket);
|
||||
} catch (InvocationTargetException | IllegalAccessException | InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
private PacketContainer getProgressPacket() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS);
|
||||
packet.getModifier().write(0, uuid);
|
||||
try {
|
||||
Object updatePacket = ReflectionUtils.progressConstructor.newInstance(competition.getProgress());
|
||||
packet.getModifier().write(1, updatePacket);
|
||||
} catch (InvocationTargetException | IllegalAccessException | InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
private PacketContainer getCreatePacket() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS);
|
||||
packet.getModifier().write(0, uuid);
|
||||
InternalStructure internalStructure = packet.getStructures().read(1);
|
||||
internalStructure.getChatComponents().write(0, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(texts[0].getLatestValue()))));
|
||||
internalStructure.getFloat().write(0, competition.getProgress());
|
||||
internalStructure.getEnumModifier(BarColor.class, 2).write(0, config.getColor());
|
||||
internalStructure.getEnumModifier(BossBarConfigImpl.Overlay.class, 3).write(0, config.getOverlay());
|
||||
internalStructure.getModifier().write(4, false);
|
||||
internalStructure.getModifier().write(5, false);
|
||||
internalStructure.getModifier().write(6, false);
|
||||
return packet;
|
||||
}
|
||||
|
||||
private PacketContainer getRemovePacket() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS);
|
||||
packet.getModifier().write(0, uuid);
|
||||
packet.getModifier().write(1, ReflectionUtils.removeBossBarPacket);
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package net.momirealms.customfishing.bukkit.competition.ranking;
|
||||
|
||||
import net.momirealms.customfishing.api.mechanic.competition.CompetitionPlayer;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.RankingProvider;
|
||||
import net.momirealms.customfishing.common.util.Pair;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
|
||||
package net.momirealms.customfishing.bukkit.competition.ranking;
|
||||
|
||||
import net.momirealms.customfishing.api.common.Pair;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.CompetitionPlayer;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.RankingProvider;
|
||||
import net.momirealms.customfishing.storage.method.database.nosql.RedisManager;
|
||||
import net.momirealms.customfishing.api.mechanic.config.ConfigManager;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.database.nosql.RedisManager;
|
||||
import net.momirealms.customfishing.common.util.Pair;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.resps.Tuple;
|
||||
|
||||
@@ -35,7 +36,7 @@ public class RedisRankingProvider implements RankingProvider {
|
||||
@Override
|
||||
public void clear() {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
jedis.del("cf_competition_" + CFConfig.serverGroup);
|
||||
jedis.del("cf_competition_" + ConfigManager.serverGroup());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ public class RedisRankingProvider implements RankingProvider {
|
||||
@Override
|
||||
public CompetitionPlayer getCompetitionPlayer(String player) {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
Double score = jedis.zscore("cf_competition_" + CFConfig.serverGroup, player);
|
||||
Double score = jedis.zscore("cf_competition_" + ConfigManager.serverGroup(), player);
|
||||
if (score == null || score == 0) return null;
|
||||
return new CompetitionPlayer(player, Float.parseFloat(score.toString()));
|
||||
}
|
||||
@@ -57,8 +58,8 @@ public class RedisRankingProvider implements RankingProvider {
|
||||
@Override
|
||||
public CompetitionPlayer getCompetitionPlayer(int rank) {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
List<Tuple> player = jedis.zrevrangeWithScores("cf_competition_" + CFConfig.serverGroup, rank - 1, rank -1);
|
||||
if (player == null || player.size() == 0) return null;
|
||||
List<Tuple> player = jedis.zrevrangeWithScores("cf_competition_" + ConfigManager.serverGroup(), rank - 1, rank -1);
|
||||
if (player == null || player.isEmpty()) return null;
|
||||
return new CompetitionPlayer(player.get(0).getElement(), player.get(0).getScore());
|
||||
}
|
||||
}
|
||||
@@ -66,14 +67,14 @@ public class RedisRankingProvider implements RankingProvider {
|
||||
@Override
|
||||
public void addPlayer(CompetitionPlayer competitionPlayer) {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
jedis.zincrby("cf_competition_" + CFConfig.serverGroup, competitionPlayer.getScore(), competitionPlayer.getPlayer());
|
||||
jedis.zincrby("cf_competition_" + ConfigManager.serverGroup(), competitionPlayer.getScore(), competitionPlayer.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayer(String player) {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
jedis.zrem("cf_competition_" + CFConfig.serverGroup, player);
|
||||
jedis.zrem("cf_competition_" + ConfigManager.serverGroup(), player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ public class RedisRankingProvider implements RankingProvider {
|
||||
@Override
|
||||
public Iterator<Pair<String, Double>> getIterator() {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
List<Tuple> players = jedis.zrevrangeWithScores("cf_competition_" + CFConfig.serverGroup, 0, -1);
|
||||
List<Tuple> players = jedis.zrevrangeWithScores("cf_competition_" + ConfigManager.serverGroup(), 0, -1);
|
||||
return players.stream().map(it -> Pair.of(it.getElement(), it.getScore())).toList().iterator();
|
||||
}
|
||||
}
|
||||
@@ -98,7 +99,7 @@ public class RedisRankingProvider implements RankingProvider {
|
||||
@Override
|
||||
public int getSize() {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
long size = jedis.zcard("cf_competition_" + CFConfig.serverGroup);
|
||||
long size = jedis.zcard("cf_competition_" + ConfigManager.serverGroup());
|
||||
return (int) size;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +113,7 @@ public class RedisRankingProvider implements RankingProvider {
|
||||
@Override
|
||||
public int getPlayerRank(String player) {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
Long rank = jedis.zrevrank("cf_competition_" + CFConfig.serverGroup, player);
|
||||
Long rank = jedis.zrevrank("cf_competition_" + ConfigManager.serverGroup(), player);
|
||||
if (rank == null)
|
||||
return -1;
|
||||
return (int) (rank + 1);
|
||||
@@ -128,7 +129,7 @@ public class RedisRankingProvider implements RankingProvider {
|
||||
@Override
|
||||
public double getPlayerScore(String player) {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
Double rank = jedis.zscore("cf_competition_" + CFConfig.serverGroup, player);
|
||||
Double rank = jedis.zscore("cf_competition_" + ConfigManager.serverGroup(), player);
|
||||
if (rank == null)
|
||||
return 0;
|
||||
return rank.floatValue();
|
||||
@@ -144,7 +145,7 @@ public class RedisRankingProvider implements RankingProvider {
|
||||
@Override
|
||||
public void refreshData(String player, double score) {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
jedis.zincrby("cf_competition_" + CFConfig.serverGroup, score, player);
|
||||
jedis.zincrby("cf_competition_" + ConfigManager.serverGroup(), score, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +158,7 @@ public class RedisRankingProvider implements RankingProvider {
|
||||
@Override
|
||||
public void setData(String player, double score) {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
jedis.zadd("cf_competition_" + CFConfig.serverGroup, score, player);
|
||||
jedis.zadd("cf_competition_" + ConfigManager.serverGroup(), score, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,8 +171,8 @@ public class RedisRankingProvider implements RankingProvider {
|
||||
@Override
|
||||
public String getPlayerAt(int rank) {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
List<String> player = jedis.zrevrange("cf_competition_" + CFConfig.serverGroup, rank - 1, rank -1);
|
||||
if (player == null || player.size() == 0) return null;
|
||||
List<String> player = jedis.zrevrange("cf_competition_" + ConfigManager.serverGroup(), rank - 1, rank -1);
|
||||
if (player == null || player.isEmpty()) return null;
|
||||
return player.get(0);
|
||||
}
|
||||
}
|
||||
@@ -185,8 +186,8 @@ public class RedisRankingProvider implements RankingProvider {
|
||||
@Override
|
||||
public double getScoreAt(int rank) {
|
||||
try (Jedis jedis = RedisManager.getInstance().getJedis()) {
|
||||
List<Tuple> players = jedis.zrevrangeWithScores("cf_competition_" + CFConfig.serverGroup, rank - 1, rank -1);
|
||||
if (players == null || players.size() == 0) return 0;
|
||||
List<Tuple> players = jedis.zrevrangeWithScores("cf_competition_" + ConfigManager.serverGroup(), rank - 1, rank -1);
|
||||
if (players == null || players.isEmpty()) return 0;
|
||||
return players.get(0).getScore();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.effect;
|
||||
package net.momirealms.customfishing.bukkit.effect;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.common.Key;
|
||||
@@ -24,7 +24,7 @@ import net.momirealms.customfishing.api.mechanic.effect.LootBaseEffectImpl;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.value.MathValue;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
|
||||
import net.momirealms.customfishing.mechanic.misc.value.PlainMathValue;
|
||||
import net.momirealms.customfishing.util.ConfigUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.ConfigUtils;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -33,13 +33,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class EffectManagerImpl implements EffectManager {
|
||||
public class BukkitEffectManager implements EffectManager {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
|
||||
private final HashMap<Key, EffectCarrier> effectMap;
|
||||
|
||||
public EffectManagerImpl(BukkitCustomFishingPlugin plugin) {
|
||||
public BukkitEffectManager(BukkitCustomFishingPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.effectMap = new HashMap<>();
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.entity;
|
||||
package net.momirealms.customfishing.bukkit.entity;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.integration.EntityProvider;
|
||||
@@ -32,13 +32,13 @@ import org.bukkit.util.Vector;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class EntityManagerImpl implements EntityManager {
|
||||
public class BukkitEntityManager implements EntityManager {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
private final HashMap<String, EntityProvider> entityLibraryMap;
|
||||
private final HashMap<String, EntityConfigImpl> entityConfigMap;
|
||||
|
||||
public EntityManagerImpl(BukkitCustomFishingPlugin plugin) {
|
||||
public BukkitEntityManager(BukkitCustomFishingPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.entityLibraryMap = new HashMap<>();
|
||||
this.entityConfigMap = new HashMap<>();
|
||||
@@ -15,12 +15,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.fishing;
|
||||
package net.momirealms.customfishing.bukkit.fishing;
|
||||
|
||||
import net.momirealms.customfishing.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.bukkit.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.scheduler.CancellableTask;
|
||||
import net.momirealms.customfishing.util.FakeItemUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.FakeItemUtils;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -15,14 +15,14 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.fishing;
|
||||
package net.momirealms.customfishing.bukkit.fishing;
|
||||
|
||||
import com.destroystokyo.paper.event.player.PlayerJumpEvent;
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customfishing.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.bukkit.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.api.common.Pair;
|
||||
import net.momirealms.customfishing.api.event.FishingResultEvent;
|
||||
import net.momirealms.customfishing.api.event.LavaFishingEvent;
|
||||
@@ -39,8 +39,7 @@ import net.momirealms.customfishing.api.mechanic.loot.Loot;
|
||||
import net.momirealms.customfishing.api.mechanic.loot.LootType;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementManager;
|
||||
import net.momirealms.customfishing.api.util.WeightUtils;
|
||||
import net.momirealms.customfishing.mechanic.requirement.RequirementManagerImpl;
|
||||
import net.momirealms.customfishing.util.ItemUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.ItemUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -60,7 +59,7 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class FishingManagerImpl implements Listener, FishingManager {
|
||||
public class BukkitFishingManager implements Listener, FishingManager {
|
||||
|
||||
private final BukkitCustomFishingPluginImpl plugin;
|
||||
private final ConcurrentHashMap<UUID, FishHook> hookCacheMap;
|
||||
@@ -69,7 +68,7 @@ public class FishingManagerImpl implements Listener, FishingManager {
|
||||
private final ConcurrentHashMap<UUID, GamingPlayer> gamingPlayerMap;
|
||||
private final ConcurrentHashMap<UUID, Pair<ItemStack, Integer>> vanillaLootMap;
|
||||
|
||||
public FishingManagerImpl(BukkitCustomFishingPluginImpl plugin) {
|
||||
public BukkitFishingManager(BukkitCustomFishingPluginImpl plugin) {
|
||||
this.plugin = plugin;
|
||||
this.hookCacheMap = new ConcurrentHashMap<>();
|
||||
this.tempFishingStateMap = new ConcurrentHashMap<>();
|
||||
@@ -803,8 +802,8 @@ public class FishingManagerImpl implements Listener, FishingManager {
|
||||
*/
|
||||
@Override
|
||||
public boolean startFishingGame(Player player, GameSettings settings, GameInstance gameInstance) {
|
||||
plugin.debug("Difficulty:" + settings.getDifficulty());
|
||||
plugin.debug("Time:" + settings.getTime());
|
||||
plugin.debug("Difficulty:" + settings.difficulty());
|
||||
plugin.debug("Time:" + settings.time());
|
||||
FishHook hook = getHook(player.getUniqueId());
|
||||
if (hook != null) {
|
||||
this.gamingPlayerMap.put(player.getUniqueId(), gameInstance.start(player, hook, settings));
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.fishing;
|
||||
package net.momirealms.customfishing.bukkit.fishing;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.fishing;
|
||||
package net.momirealms.customfishing.bukkit.fishing;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
@@ -46,7 +46,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class HookCheckTimerTask implements Runnable {
|
||||
|
||||
private final FishingManagerImpl manager;
|
||||
private final BukkitFishingManager manager;
|
||||
private final CancellableTask hookMovementTask;
|
||||
private LavaEffectTask lavaFishingTask;
|
||||
private final FishHook fishHook;
|
||||
@@ -71,7 +71,7 @@ public class HookCheckTimerTask implements Runnable {
|
||||
* @param initialEffect The initial fishing effect.
|
||||
*/
|
||||
public HookCheckTimerTask(
|
||||
FishingManagerImpl manager,
|
||||
BukkitFishingManager manager,
|
||||
FishHook fishHook,
|
||||
FishingPreparation fishingPreparation,
|
||||
FishingEffect initialEffect
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.fishing;
|
||||
package net.momirealms.customfishing.bukkit.fishing;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.scheduler.CancellableTask;
|
||||
@@ -15,15 +15,14 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.game;
|
||||
package net.momirealms.customfishing.bukkit.game;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.game.*;
|
||||
import net.momirealms.customfishing.common.util.Pair;
|
||||
import net.momirealms.customfishing.mechanic.requirement.RequirementManagerImpl;
|
||||
import net.momirealms.customfishing.util.ConfigUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.ConfigUtils;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -36,14 +35,14 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public class GameManagerImpl implements GameManager {
|
||||
public class BukkitGameManager implements GameManager {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
private final HashMap<String, GameFactory> gameCreatorMap;
|
||||
private final HashMap<String, Pair<BasicGameConfig, GameInstance>> gameInstanceMap;
|
||||
private final String EXPANSION_FOLDER = "expansions/minigame";
|
||||
|
||||
public GameManagerImpl(BukkitCustomFishingPlugin plugin) {
|
||||
public BukkitGameManager(BukkitCustomFishingPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.gameCreatorMap = new HashMap<>();
|
||||
this.gameInstanceMap = new HashMap<>();
|
||||
@@ -223,7 +222,7 @@ public class GameManagerImpl implements GameManager {
|
||||
|
||||
@Override
|
||||
public void arrangeTask() {
|
||||
var period = ((double) 10*(200-settings.getDifficulty()))/((double) (1+4*settings.getDifficulty()));
|
||||
var period = ((double) 10*(200-settings.difficulty()))/((double) (1+4*settings.difficulty()));
|
||||
this.task = BukkitCustomFishingPlugin.get().getScheduler().runTaskAsyncTimer(
|
||||
this,
|
||||
50,
|
||||
@@ -310,11 +309,11 @@ public class GameManagerImpl implements GameManager {
|
||||
public void onTick() {
|
||||
if (player.isSneaking()) addV();
|
||||
else reduceV();
|
||||
if (timer < 40 - (settings.getDifficulty() / 10)) {
|
||||
if (timer < 40 - (settings.difficulty() / 10)) {
|
||||
timer++;
|
||||
} else {
|
||||
timer = 0;
|
||||
if (Math.random() > ((double) 25 / (settings.getDifficulty() + 100))) {
|
||||
if (Math.random() > ((double) 25 / (settings.difficulty() + 100))) {
|
||||
burst();
|
||||
}
|
||||
}
|
||||
@@ -338,9 +337,9 @@ public class GameManagerImpl implements GameManager {
|
||||
|
||||
private void burst() {
|
||||
if (Math.random() < (judgement_position / barEffectiveWidth)) {
|
||||
judgement_velocity = -1 - 0.8 * Math.random() * ((double) settings.getDifficulty() / 15);
|
||||
judgement_velocity = -1 - 0.8 * Math.random() * ((double) settings.difficulty() / 15);
|
||||
} else {
|
||||
judgement_velocity = 1 + 0.8 * Math.random() * ((double) settings.getDifficulty() / 15);
|
||||
judgement_velocity = 1 + 0.8 * Math.random() * ((double) settings.difficulty() / 15);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,8 +438,8 @@ public class GameManagerImpl implements GameManager {
|
||||
@Override
|
||||
public void onTick() {
|
||||
if (struggling_time <= 0) {
|
||||
if (Math.random() < ((double) settings.getDifficulty() / 4000)) {
|
||||
struggling_time = (int) (10 + Math.random() * (settings.getDifficulty() / 4));
|
||||
if (Math.random() < ((double) settings.difficulty() / 4000)) {
|
||||
struggling_time = (int) (10 + Math.random() * (settings.difficulty() / 4));
|
||||
}
|
||||
} else {
|
||||
struggling_time--;
|
||||
@@ -463,7 +462,7 @@ public class GameManagerImpl implements GameManager {
|
||||
public void pull() {
|
||||
played = true;
|
||||
if (struggling_time > 0) {
|
||||
strain += (strugglingIncrease + ((double) settings.getDifficulty() / 50));
|
||||
strain += (strugglingIncrease + ((double) settings.difficulty() / 50));
|
||||
fish_position -= 1;
|
||||
} else {
|
||||
strain += normalIncrease;
|
||||
@@ -535,7 +534,7 @@ public class GameManagerImpl implements GameManager {
|
||||
|
||||
@Override
|
||||
public void arrangeTask() {
|
||||
requiredTimes = settings.getDifficulty() / 4;
|
||||
requiredTimes = settings.difficulty() / 4;
|
||||
order = new int[requiredTimes];
|
||||
for (int i = 0; i < requiredTimes; i++) {
|
||||
order[i] = ThreadLocalRandom.current().nextInt(0, easy ? 2 : 4);
|
||||
@@ -788,7 +787,7 @@ public class GameManagerImpl implements GameManager {
|
||||
return (player, fishHook, settings) -> new AbstractGamingPlayer(player, fishHook, settings) {
|
||||
|
||||
private int clickedTimes;
|
||||
private final int requiredTimes = settings.getDifficulty();
|
||||
private final int requiredTimes = settings.difficulty();
|
||||
private boolean preventFirst = true;
|
||||
|
||||
@Override
|
||||
@@ -878,7 +877,7 @@ public class GameManagerImpl implements GameManager {
|
||||
@Override
|
||||
public void onTick() {
|
||||
timer++;
|
||||
if (timer % (21 - settings.getDifficulty() / 5) == 0) {
|
||||
if (timer % (21 - settings.difficulty() / 5) == 0) {
|
||||
movePointer();
|
||||
}
|
||||
showUI();
|
||||
@@ -955,7 +954,7 @@ public class GameManagerImpl implements GameManager {
|
||||
|
||||
@Override
|
||||
public void arrangeTask() {
|
||||
var period = ((double) 10*(200-settings.getDifficulty()))/((double) (1+4*settings.getDifficulty()));
|
||||
var period = ((double) 10*(200-settings.difficulty()))/((double) (1+4*settings.difficulty()));
|
||||
this.task = BukkitCustomFishingPlugin.get().getScheduler().runTaskAsyncTimer(
|
||||
this,
|
||||
50,
|
||||
@@ -1053,11 +1052,11 @@ public class GameManagerImpl implements GameManager {
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
if (timer < 40 - (settings.getDifficulty() / 10)) {
|
||||
if (timer < 40 - (settings.difficulty() / 10)) {
|
||||
timer++;
|
||||
} else {
|
||||
timer = 0;
|
||||
if (Math.random() > ((double) 25 / (settings.getDifficulty() + 100))) {
|
||||
if (Math.random() > ((double) 25 / (settings.difficulty() + 100))) {
|
||||
burst();
|
||||
}
|
||||
}
|
||||
@@ -1081,9 +1080,9 @@ public class GameManagerImpl implements GameManager {
|
||||
|
||||
private void burst() {
|
||||
if (Math.random() < (judgement_position / barEffectiveWidth)) {
|
||||
judgement_velocity = -1 - 0.8 * Math.random() * ((double) settings.getDifficulty() / 15);
|
||||
judgement_velocity = -1 - 0.8 * Math.random() * ((double) settings.difficulty() / 15);
|
||||
} else {
|
||||
judgement_velocity = 1 + 0.8 * Math.random() * ((double) settings.getDifficulty() / 15);
|
||||
judgement_velocity = 1 + 0.8 * Math.random() * ((double) settings.difficulty() / 15);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui;
|
||||
package net.momirealms.customfishing.bukkit.gui;
|
||||
|
||||
public interface Icon {
|
||||
}
|
||||
@@ -15,9 +15,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui;
|
||||
package net.momirealms.customfishing.bukkit.gui;
|
||||
|
||||
import net.momirealms.customfishing.gui.icon.BackToPageItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackToPageItem;
|
||||
import xyz.xenondevs.invui.item.Item;
|
||||
|
||||
public interface ParentPage {
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui;
|
||||
package net.momirealms.customfishing.bukkit.gui;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui;
|
||||
package net.momirealms.customfishing.bukkit.gui;
|
||||
|
||||
public interface YamlPage extends ParentPage {
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon;
|
||||
|
||||
import net.momirealms.customfishing.gui.Icon;
|
||||
import net.momirealms.customfishing.bukkit.gui.Icon;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.Icon;
|
||||
import net.momirealms.customfishing.gui.page.file.FileSelector;
|
||||
import net.momirealms.customfishing.bukkit.gui.Icon;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.file.FileSelector;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.ParentPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.ParentPage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.Icon;
|
||||
import net.momirealms.customfishing.bukkit.gui.Icon;
|
||||
import org.bukkit.Material;
|
||||
import xyz.xenondevs.invui.gui.PagedGui;
|
||||
import xyz.xenondevs.invui.item.ItemProvider;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.Icon;
|
||||
import net.momirealms.customfishing.bukkit.gui.Icon;
|
||||
import org.bukkit.Material;
|
||||
import xyz.xenondevs.invui.gui.PagedGui;
|
||||
import xyz.xenondevs.invui.item.ItemProvider;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.Icon;
|
||||
import net.momirealms.customfishing.bukkit.gui.Icon;
|
||||
import org.bukkit.Material;
|
||||
import xyz.xenondevs.invui.gui.ScrollGui;
|
||||
import xyz.xenondevs.invui.item.ItemProvider;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.Icon;
|
||||
import net.momirealms.customfishing.bukkit.gui.Icon;
|
||||
import org.bukkit.Material;
|
||||
import xyz.xenondevs.invui.gui.ScrollGui;
|
||||
import xyz.xenondevs.invui.item.ItemProvider;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.AmountEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.AmountEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.CustomModelDataEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.CustomModelDataEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.DisplayNameEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.DisplayNameEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.DurabilityEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.DurabilityEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.EnchantmentEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.EnchantmentEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,12 +15,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.bukkit.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.ItemFlagEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.ItemFlagEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.LoreEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.LoreEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.MaterialEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.MaterialEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,12 +15,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.NBTEditor;
|
||||
import net.momirealms.customfishing.util.ConfigUtils;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.NBTEditor;
|
||||
import net.momirealms.customfishing.bukkit.util.ConfigUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.PriceEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.PriceEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.SizeEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.SizeEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.EnchantmentEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.EnchantmentEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.loot;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.loot;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.loot;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.loot;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.loot;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.loot;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.loot;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.loot;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.NickEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.NickEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.loot;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.loot;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.page.property.ScoreEditor;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.property.ScoreEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.icon.property.loot;
|
||||
package net.momirealms.customfishing.bukkit.gui.icon.property.loot;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,14 +15,14 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.file;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.file;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.gui.icon.BackToFolderItem;
|
||||
import net.momirealms.customfishing.gui.icon.ScrollDownItem;
|
||||
import net.momirealms.customfishing.gui.icon.ScrollUpItem;
|
||||
import net.momirealms.customfishing.gui.page.item.ItemSelector;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackToFolderItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.ScrollDownItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.ScrollUpItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.page.item.ItemSelector;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -15,15 +15,15 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.item;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.gui.icon.BackToPageItem;
|
||||
import net.momirealms.customfishing.gui.icon.NextPageItem;
|
||||
import net.momirealms.customfishing.gui.icon.PreviousPageItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackToPageItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.NextPageItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.PreviousPageItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,9 +15,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.item;
|
||||
|
||||
import net.momirealms.customfishing.gui.icon.property.item.*;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.property.item.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.xenondevs.invui.item.Item;
|
||||
@@ -15,9 +15,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.item;
|
||||
|
||||
import net.momirealms.customfishing.gui.icon.property.item.*;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.property.item.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.xenondevs.invui.item.Item;
|
||||
@@ -15,16 +15,16 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.item;
|
||||
|
||||
import com.saicone.rtag.RtagItem;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.YamlPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.gui.icon.BackToFolderItem;
|
||||
import net.momirealms.customfishing.gui.icon.NextPageItem;
|
||||
import net.momirealms.customfishing.gui.icon.PreviousPageItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.YamlPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackToFolderItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.NextPageItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.PreviousPageItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -15,9 +15,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.item;
|
||||
|
||||
import net.momirealms.customfishing.gui.icon.property.item.*;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.property.item.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.xenondevs.invui.item.Item;
|
||||
@@ -15,10 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.item;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.item;
|
||||
|
||||
import net.momirealms.customfishing.gui.icon.property.item.*;
|
||||
import net.momirealms.customfishing.gui.icon.property.loot.*;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.property.item.*;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.property.loot.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.xenondevs.invui.item.Item;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,12 +15,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,12 +15,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,13 +15,13 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.mechanic.item.ItemManagerImpl;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.item.ItemManagerImpl;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,12 +15,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.util.ConfigUtils;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.util.ConfigUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.gui.page.property;
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,14 +15,14 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.hook;
|
||||
package net.momirealms.customfishing.bukkit.hook;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.hook.HookManager;
|
||||
import net.momirealms.customfishing.api.mechanic.hook.HookSetting;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementManager;
|
||||
import net.momirealms.customfishing.mechanic.item.ItemManagerImpl;
|
||||
import net.momirealms.customfishing.util.ItemUtils;
|
||||
import net.momirealms.customfishing.bukkit.item.ItemManagerImpl;
|
||||
import net.momirealms.customfishing.bukkit.util.ItemUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@@ -40,12 +40,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class HookManagerImpl implements Listener, HookManager {
|
||||
public class BukkitHookManager implements Listener, HookManager {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
private final HashMap<String, HookSetting> hookSettingMap;
|
||||
|
||||
public HookManagerImpl(BukkitCustomFishingPlugin plugin) {
|
||||
public BukkitHookManager(BukkitCustomFishingPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.hookSettingMap = new HashMap<>();
|
||||
}
|
||||
@@ -36,12 +36,12 @@ public class BukkitItemManager implements ItemManager {
|
||||
this.itemProviders.put("vanilla", new ItemProvider() {
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack buildItem(Player player, String id) {
|
||||
public ItemStack buildItem(@NotNull Player player, @NotNull String id) {
|
||||
return new ItemStack(Material.valueOf(id.toUpperCase(Locale.ENGLISH)));
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public String itemID(ItemStack itemStack) {
|
||||
public String itemID(@NotNull ItemStack itemStack) {
|
||||
return itemStack.getType().name();
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.item;
|
||||
package net.momirealms.customfishing.bukkit.item;
|
||||
|
||||
import com.saicone.rtag.RtagItem;
|
||||
import com.saicone.rtag.tag.TagCompound;
|
||||
@@ -38,9 +38,9 @@ import net.momirealms.customfishing.api.mechanic.misc.placeholder.BukkitPlacehol
|
||||
import net.momirealms.customfishing.api.mechanic.misc.value.MathValue;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementManager;
|
||||
import net.momirealms.customfishing.bukkit.compatibility.item.CustomFishingItemProvider;
|
||||
import net.momirealms.customfishing.util.ConfigUtils;
|
||||
import net.momirealms.customfishing.util.ItemUtils;
|
||||
import net.momirealms.customfishing.util.LocationUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.ConfigUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.ItemUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.LocationUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.momirealms.customfishing.mechanic.loot;
|
||||
package net.momirealms.customfishing.bukkit.loot;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.context.Context;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.loot;
|
||||
package net.momirealms.customfishing.bukkit.loot;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.common.Pair;
|
||||
@@ -25,8 +25,7 @@ import net.momirealms.customfishing.api.mechanic.loot.LootManager;
|
||||
import net.momirealms.customfishing.api.mechanic.loot.LootType;
|
||||
import net.momirealms.customfishing.api.mechanic.statistic.StatisticsKeys;
|
||||
import net.momirealms.customfishing.api.util.WeightUtils;
|
||||
import net.momirealms.customfishing.mechanic.requirement.RequirementManagerImpl;
|
||||
import net.momirealms.customfishing.util.ConfigUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.ConfigUtils;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.market;
|
||||
package net.momirealms.customfishing.bukkit.market;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
@@ -25,8 +25,8 @@ import net.momirealms.customfishing.api.mechanic.market.MarketManager;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.placeholder.BukkitPlaceholderManager;
|
||||
import net.momirealms.customfishing.api.scheduler.CancellableTask;
|
||||
import net.momirealms.customfishing.api.storage.data.EarningData;
|
||||
import net.momirealms.customfishing.util.ConfigUtils;
|
||||
import net.momirealms.customfishing.util.NumberUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.ConfigUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.NumberUtils;
|
||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -48,7 +48,7 @@ import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class MarketManagerImpl implements MarketManager, Listener {
|
||||
public class BukkitMarketManager implements MarketManager, Listener {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
private final HashMap<String, Double> priceMap;
|
||||
@@ -79,7 +79,7 @@ public class MarketManagerImpl implements MarketManager, Listener {
|
||||
private CancellableTask resetEarningsTask;
|
||||
private int date;
|
||||
|
||||
public MarketManagerImpl(BukkitCustomFishingPlugin plugin) {
|
||||
public BukkitMarketManager(BukkitCustomFishingPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.priceMap = new HashMap<>();
|
||||
this.decorativeIcons = new HashMap<>();
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.market;
|
||||
package net.momirealms.customfishing.bukkit.market;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.market;
|
||||
package net.momirealms.customfishing.bukkit.market;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.market.MarketGUIHolder;
|
||||
import net.momirealms.customfishing.api.storage.data.EarningData;
|
||||
import net.momirealms.customfishing.api.util.InventoryUtils;
|
||||
import net.momirealms.customfishing.util.ItemUtils;
|
||||
import net.momirealms.customfishing.util.NumberUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.ItemUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.NumberUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@@ -39,7 +39,7 @@ public class MarketGUI {
|
||||
// A map that associates slot indices with MarketGUI elements.
|
||||
private final HashMap<Integer, MarketGUIElement> itemsSlotMap;
|
||||
private final Inventory inventory;
|
||||
private final MarketManagerImpl manager;
|
||||
private final BukkitMarketManager manager;
|
||||
private final Player owner;
|
||||
private final EarningData earningData;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class MarketGUI {
|
||||
* @param player The player who owns this MarketGUI.
|
||||
* @param earningData Data related to earnings for this MarketGUI.
|
||||
*/
|
||||
public MarketGUI(MarketManagerImpl manager, Player player, EarningData earningData) {
|
||||
public MarketGUI(BukkitMarketManager manager, Player player, EarningData earningData) {
|
||||
this.manager = manager;
|
||||
this.owner = player;
|
||||
this.earningData = earningData;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.market;
|
||||
package net.momirealms.customfishing.bukkit.market;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.misc;
|
||||
package net.momirealms.customfishing.bukkit.misc;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.common.Pair;
|
||||
import net.momirealms.customfishing.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.common.util.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -65,13 +65,14 @@ public class ChatCatcherManager implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
var uuid = event.getPlayer().getUniqueId();
|
||||
final Player player = event.getPlayer();
|
||||
var uuid = player.getUniqueId();
|
||||
var pair = pageMap.remove(uuid);
|
||||
if (pair == null) return;
|
||||
event.setCancelled(true);
|
||||
plugin.getScheduler().runTaskSync(() -> {
|
||||
plugin.getScheduler().sync().run(() -> {
|
||||
pair.right().getSection().set(pair.left(), event.getMessage());
|
||||
pair.right().reOpen();
|
||||
}, event.getPlayer().getLocation());
|
||||
}, player.getLocation());
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,32 @@ package net.momirealms.customfishing.bukkit.requirement;
|
||||
|
||||
import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.integration.LevelerProvider;
|
||||
import net.momirealms.customfishing.api.integration.SeasonProvider;
|
||||
import net.momirealms.customfishing.api.mechanic.action.Action;
|
||||
import net.momirealms.customfishing.api.mechanic.action.ActionManager;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
|
||||
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
|
||||
import net.momirealms.customfishing.api.mechanic.effect.EffectProperties;
|
||||
import net.momirealms.customfishing.api.mechanic.loot.Loot;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.season.Season;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.value.MathValue;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.value.TextValue;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.*;
|
||||
import net.momirealms.customfishing.api.util.MoonPhase;
|
||||
import net.momirealms.customfishing.bukkit.compatibility.VaultHook;
|
||||
import net.momirealms.customfishing.common.util.ClassUtils;
|
||||
import net.momirealms.customfishing.common.util.ListUtils;
|
||||
import net.momirealms.customfishing.common.util.Pair;
|
||||
import net.momirealms.sparrow.heart.SparrowHeart;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -112,6 +128,100 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
|
||||
this.registerInLavaRequirement();
|
||||
this.registerAndRequirement();
|
||||
this.registerOrRequirement();
|
||||
this.registerGroupRequirement();
|
||||
this.registerRodRequirement();
|
||||
this.registerPAPIRequirement();
|
||||
this.registerSeasonRequirement();
|
||||
this.registerPermissionRequirement();
|
||||
this.registerMoonPhaseRequirement();
|
||||
this.registerCoolDownRequirement();
|
||||
this.registerDateRequirement();
|
||||
this.registerWeatherRequirement();
|
||||
this.registerBiomeRequirement();
|
||||
this.registerWorldRequirement();
|
||||
this.registerMoneyRequirement();
|
||||
this.registerLevelRequirement();
|
||||
this.registerRandomRequirement();
|
||||
this.registerIceFishingRequirement();
|
||||
this.registerOpenWaterRequirement();
|
||||
this.registerBaitRequirement();
|
||||
this.registerLootRequirement();
|
||||
this.registerSizeRequirement();
|
||||
this.registerLootTypeRequirement();
|
||||
this.registerHasStatsRequirement();
|
||||
this.registerHookRequirement();
|
||||
this.registerEnvironmentRequirement();
|
||||
this.registerListRequirement();
|
||||
this.registerInBagRequirement();
|
||||
this.registerCompetitionRequirement();
|
||||
this.registerPluginLevelRequirement();
|
||||
}
|
||||
|
||||
private void registerCompetitionRequirement() {
|
||||
registerRequirement("competition", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
boolean onCompetition = section.getBoolean("ongoing", true);
|
||||
List<String> ids = ListUtils.toList(section.get("id"));
|
||||
return context -> {
|
||||
if (ids.isEmpty()) {
|
||||
if (plugin.getCompetitionManager().getOnGoingCompetition() != null == onCompetition) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
if (onCompetition) {
|
||||
if (competition != null)
|
||||
if (ids.contains(competition.getConfig().key()))
|
||||
return true;
|
||||
} else {
|
||||
if (competition == null)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at competition requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void registerInBagRequirement() {
|
||||
registerRequirement("in-fishingbag", (args, actions, advanced) -> {
|
||||
boolean arg = (boolean) args;
|
||||
return context -> {
|
||||
boolean inBag = Optional.ofNullable(context.arg(ContextKeys.IN_BAG)).orElse(false);
|
||||
if (inBag == arg) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerPluginLevelRequirement() {
|
||||
registerRequirement("plugin-level", (args, actions, advanced) -> {
|
||||
if (args instanceof Section section) {
|
||||
String pluginName = section.getString("plugin");
|
||||
int level = section.getInt("level");
|
||||
String target = section.getString("target");
|
||||
return context -> {
|
||||
LevelerProvider levelerProvider = plugin.getIntegrationManager().getLevelerProvider(pluginName);
|
||||
if (levelerProvider == null) {
|
||||
plugin.getPluginLogger().warn("Plugin (" + pluginName + "'s) level is not compatible. Please double check if it's a problem caused by pronunciation.");
|
||||
return true;
|
||||
}
|
||||
if (levelerProvider.getLevel(context.getHolder(), target) >= level)
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at plugin-level requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void registerTimeRequirement() {
|
||||
@@ -239,6 +349,752 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
|
||||
});
|
||||
}
|
||||
|
||||
private void registerRodRequirement() {
|
||||
registerRequirement("rod", (args, actions, advanced) -> {
|
||||
HashSet<String> rods = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
String id = context.arg(ContextKeys.ROD);
|
||||
if (rods.contains(id)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("!rod", (args, actions, advanced) -> {
|
||||
HashSet<String> rods = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
String id = context.arg(ContextKeys.ROD);
|
||||
if (!rods.contains(id)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerGroupRequirement() {
|
||||
registerRequirement("group", (args, actions, advanced) -> {
|
||||
HashSet<String> groups = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
String lootID = context.arg(ContextKeys.ID);
|
||||
Optional<Loot> loot = plugin.getLootManager().getLoot(lootID);
|
||||
if (loot.isEmpty()) return false;
|
||||
String[] group = loot.get().lootGroup();
|
||||
if (group != null)
|
||||
for (String x : group)
|
||||
if (groups.contains(x))
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("!group", (args, actions, advanced) -> {
|
||||
HashSet<String> groups = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
String lootID = context.arg(ContextKeys.ID);
|
||||
Optional<Loot> loot = plugin.getLootManager().getLoot(lootID);
|
||||
if (loot.isEmpty()) return false;
|
||||
String[] group = loot.get().lootGroup();
|
||||
if (group == null)
|
||||
return true;
|
||||
outer: {
|
||||
for (String x : group)
|
||||
if (groups.contains(x))
|
||||
break outer;
|
||||
return true;
|
||||
}
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerLootRequirement() {
|
||||
registerRequirement("loot", (args, actions, advanced) -> {
|
||||
HashSet<String> arg = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
String lootID = context.arg(ContextKeys.ID);
|
||||
if (arg.contains(lootID)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("!loot", (args, actions, advanced) -> {
|
||||
HashSet<String> arg = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
String lootID = context.arg(ContextKeys.ID);
|
||||
if (!arg.contains(lootID)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerHookRequirement() {
|
||||
registerRequirement("hook", (args, actions, advanced) -> {
|
||||
HashSet<String> hooks = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
String id = context.arg(ContextKeys.HOOK);
|
||||
if (hooks.contains(id)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("!hook", (args, actions, advanced) -> {
|
||||
HashSet<String> hooks = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
String id = context.arg(ContextKeys.HOOK);
|
||||
if (!hooks.contains(id)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("has-hook", (args, actions, advanced) -> {
|
||||
boolean has = (boolean) args;
|
||||
return context -> {
|
||||
String id = context.arg(ContextKeys.HOOK);
|
||||
if (id != null && has) return true;
|
||||
if (id == null && !has) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerBaitRequirement() {
|
||||
registerRequirement("bait", (args, actions, advanced) -> {
|
||||
HashSet<String> arg = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
String id = context.arg(ContextKeys.BAIT);
|
||||
if (arg.contains(id)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("!bait", (args, actions, advanced) -> {
|
||||
HashSet<String> arg = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
String id = context.arg(ContextKeys.BAIT);
|
||||
if (!arg.contains(id)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("has-bait", (args, actions, advanced) -> {
|
||||
boolean has = (boolean) args;
|
||||
return context -> {
|
||||
String id = context.arg(ContextKeys.BAIT);
|
||||
if (id != null && has) return true;
|
||||
if (id == null && !has) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerSizeRequirement() {
|
||||
registerRequirement("has-size", (args, actions, advanced) -> {
|
||||
boolean has = (boolean) args;
|
||||
return context -> {
|
||||
float size = Optional.ofNullable(context.arg(ContextKeys.SIZE)).orElse(-1f);
|
||||
if (size != -1 && has) return true;
|
||||
if (size == -1 && !has) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerOpenWaterRequirement() {
|
||||
registerRequirement("open-water", (args, actions, advanced) -> {
|
||||
boolean openWater = (boolean) args;
|
||||
return context -> {
|
||||
boolean current = Optional.ofNullable(context.arg(ContextKeys.OPEN_WATER)).orElse(false);
|
||||
if (openWater == current)
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerHasStatsRequirement() {
|
||||
registerRequirement("has-stats", (args, actions, advanced) -> {
|
||||
boolean has = (boolean) args;
|
||||
return context -> {
|
||||
String loot = context.arg(ContextKeys.ID);
|
||||
Optional<Loot> lootInstance = plugin.getLootManager().getLoot(loot);
|
||||
if (lootInstance.isPresent()) {
|
||||
if (!lootInstance.get().disableStats() && has) return true;
|
||||
if (lootInstance.get().disableStats() && !has) return true;
|
||||
}
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerLootTypeRequirement() {
|
||||
registerRequirement("loot-type", (args, actions, advanced) -> {
|
||||
List<String> types = ListUtils.toList(args);
|
||||
return context -> {
|
||||
String loot = context.arg(ContextKeys.ID);
|
||||
Optional<Loot> lootInstance = plugin.getLootManager().getLoot(loot);
|
||||
if (lootInstance.isPresent()) {
|
||||
if (types.contains(lootInstance.get().getType().name().toLowerCase(Locale.ENGLISH)))
|
||||
return true;
|
||||
}
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("!loot-type", (args, actions, advanced) -> {
|
||||
List<String> types = ListUtils.toList(args);
|
||||
return context -> {
|
||||
String loot = context.arg(ContextKeys.ID);
|
||||
Optional<Loot> lootInstance = plugin.getLootManager().getLoot(loot);
|
||||
if (lootInstance.isPresent()) {
|
||||
if (!types.contains(lootInstance.get().getType().name().toLowerCase(Locale.ENGLISH)))
|
||||
return true;
|
||||
}
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerListRequirement() {
|
||||
registerRequirement("list", (args, actions, advanced) -> {
|
||||
plugin.getPluginLogger().severe("It seems that you made a mistake where you put \"list\" into \"conditions\" section.");
|
||||
plugin.getPluginLogger().warn("list:");
|
||||
for (String e : ListUtils.toList(args)) {
|
||||
plugin.getPluginLogger().warn(" - " + e);
|
||||
}
|
||||
return EmptyRequirement.INSTANCE;
|
||||
});
|
||||
}
|
||||
|
||||
private void registerEnvironmentRequirement() {
|
||||
registerRequirement("environment", (args, actions, advanced) -> {
|
||||
List<String> environments = ListUtils.toList(args);
|
||||
return context -> {
|
||||
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
|
||||
var name = location.getWorld().getEnvironment().name().toLowerCase(Locale.ENGLISH);
|
||||
if (environments.contains(name)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("!environment", (args, actions, advanced) -> {
|
||||
List<String> environments = ListUtils.toList(args);
|
||||
return context -> {
|
||||
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
|
||||
var name = location.getWorld().getEnvironment().name().toLowerCase(Locale.ENGLISH);
|
||||
if (!environments.contains(name)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerIceFishingRequirement() {
|
||||
registerRequirement("ice-fishing", (args, actions, advanced) -> {
|
||||
boolean iceFishing = (boolean) args;
|
||||
return context -> {
|
||||
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
|
||||
int water = 0, ice = 0;
|
||||
for (int i = -2; i <= 2; i++)
|
||||
for (int j = -1; j <= 2; j++)
|
||||
for (int k = -2; k <= 2; k++) {
|
||||
Block block = location.clone().add(i, j, k).getBlock();
|
||||
Material material = block.getType();
|
||||
switch (material) {
|
||||
case ICE -> ice++;
|
||||
case WATER -> water++;
|
||||
}
|
||||
}
|
||||
if ((ice >= 16 && water >= 25) == iceFishing)
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerLevelRequirement() {
|
||||
registerRequirement("level", (args, actions, advanced) -> {
|
||||
MathValue<Player> value = MathValue.auto(args);
|
||||
return context -> {
|
||||
int current = context.getHolder().getLevel();
|
||||
if (current >= value.evaluate(context))
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerMoneyRequirement() {
|
||||
registerRequirement("money", (args, actions, advanced) -> {
|
||||
MathValue<Player> value = MathValue.auto(args);
|
||||
return context -> {
|
||||
double current = VaultHook.getBalance(context.getHolder());
|
||||
if (current >= value.evaluate(context))
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerRandomRequirement() {
|
||||
registerRequirement("random", (args, actions, advanced) -> {
|
||||
MathValue<Player> value = MathValue.auto(args);
|
||||
return context -> {
|
||||
if (Math.random() < value.evaluate(context))
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerBiomeRequirement() {
|
||||
registerRequirement("biome", (args, actions, advanced) -> {
|
||||
HashSet<String> biomes = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
|
||||
String currentBiome = SparrowHeart.getInstance().getBiomeResourceLocation(location);
|
||||
if (biomes.contains(currentBiome))
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("!biome", (args, actions, advanced) -> {
|
||||
HashSet<String> biomes = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
|
||||
String currentBiome = SparrowHeart.getInstance().getBiomeResourceLocation(location);
|
||||
if (!biomes.contains(currentBiome))
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerMoonPhaseRequirement() {
|
||||
registerRequirement("moon-phase", (args, actions, advanced) -> {
|
||||
HashSet<String> moonPhases = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
|
||||
long days = location.getWorld().getFullTime() / 24_000;
|
||||
if (moonPhases.contains(MoonPhase.getPhase(days).name().toLowerCase(Locale.ENGLISH)))
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("!moon-phase", (args, actions, advanced) -> {
|
||||
HashSet<String> moonPhases = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
|
||||
long days = location.getWorld().getFullTime() / 24_000;
|
||||
if (!moonPhases.contains(MoonPhase.getPhase(days).name().toLowerCase(Locale.ENGLISH)))
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerWorldRequirement() {
|
||||
registerRequirement("world", (args, actions, advanced) -> {
|
||||
HashSet<String> worlds = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
|
||||
if (worlds.contains(location.getWorld().getName()))
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("!world", (args, actions, advanced) -> {
|
||||
HashSet<String> worlds = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
|
||||
if (!worlds.contains(location.getWorld().getName()))
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerWeatherRequirement() {
|
||||
registerRequirement("weather", (args, actions, advanced) -> {
|
||||
HashSet<String> weathers = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
String currentWeather;
|
||||
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
|
||||
World world = location.getWorld();
|
||||
if (world.isClearWeather()) currentWeather = "clear";
|
||||
else if (world.isThundering()) currentWeather = "thunder";
|
||||
else currentWeather = "rain";
|
||||
if (weathers.contains(currentWeather)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerCoolDownRequirement() {
|
||||
registerRequirement("cooldown", (args, actions, advanced) -> {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
private void registerDateRequirement() {
|
||||
registerRequirement("date", (args, actions, advanced) -> {
|
||||
HashSet<String> dates = new HashSet<>(ListUtils.toList(args));
|
||||
return context -> {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
String current = (calendar.get(Calendar.MONTH) + 1) + "/" + calendar.get(Calendar.DATE);
|
||||
if (dates.contains(current))
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerPermissionRequirement() {
|
||||
registerRequirement("permission", (args, actions, advanced) -> {
|
||||
List<String> perms = ListUtils.toList(args);
|
||||
return context -> {
|
||||
for (String perm : perms)
|
||||
if (context.getHolder().hasPermission(perm))
|
||||
return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("!permission", (args, actions, advanced) -> {
|
||||
List<String> perms = ListUtils.toList(args);
|
||||
return context -> {
|
||||
for (String perm : perms)
|
||||
if (context.getHolder().hasPermission(perm)) {
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerSeasonRequirement() {
|
||||
registerRequirement("season", (args, actions, advanced) -> {
|
||||
List<String> seasons = ListUtils.toList(args);
|
||||
return context -> {
|
||||
SeasonProvider seasonProvider = plugin.getIntegrationManager().getSeasonProvider();
|
||||
if (seasonProvider == null) return true;
|
||||
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
|
||||
World world = location.getWorld();
|
||||
Season season = seasonProvider.getSeason(world);
|
||||
if (seasons.contains(season.name().toLowerCase(Locale.ENGLISH))) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerPAPIRequirement() {
|
||||
registerRequirement("<", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
MathValue<Player> v1 = MathValue.auto(section.get("value1"));
|
||||
MathValue<Player> v2 = MathValue.auto(section.get("value2"));
|
||||
return context -> {
|
||||
if (v1.evaluate(context) < v2.evaluate(context)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at < requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("<=", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
MathValue<Player> v1 = MathValue.auto(section.get("value1"));
|
||||
MathValue<Player> v2 = MathValue.auto(section.get("value2"));
|
||||
return context -> {
|
||||
if (v1.evaluate(context) <= v2.evaluate(context)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at <= requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("!=", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
MathValue<Player> v1 = MathValue.auto(section.get("value1"));
|
||||
MathValue<Player> v2 = MathValue.auto(section.get("value2"));
|
||||
return context -> {
|
||||
if (v1.evaluate(context) != v2.evaluate(context)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at != requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("==", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
MathValue<Player> v1 = MathValue.auto(section.get("value1"));
|
||||
MathValue<Player> v2 = MathValue.auto(section.get("value2"));
|
||||
return context -> {
|
||||
if (v1.evaluate(context) == v2.evaluate(context)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at == requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement(">=", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
MathValue<Player> v1 = MathValue.auto(section.get("value1"));
|
||||
MathValue<Player> v2 = MathValue.auto(section.get("value2"));
|
||||
return context -> {
|
||||
if (v1.evaluate(context) >= v2.evaluate(context)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at >= requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement(">", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
MathValue<Player> v1 = MathValue.auto(section.get("value1"));
|
||||
MathValue<Player> v2 = MathValue.auto(section.get("value2"));
|
||||
return context -> {
|
||||
if (v1.evaluate(context) > v2.evaluate(context)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at > requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("regex", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
TextValue<Player> v1 = TextValue.auto(section.getString("papi", ""));
|
||||
String v2 = section.getString("regex", "");
|
||||
return context -> {
|
||||
if (v1.render(context).matches(v2)) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at regex requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("startsWith", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
|
||||
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
|
||||
return context -> {
|
||||
if (v1.render(context).startsWith(v2.render(context))) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at startsWith requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("!startsWith", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
|
||||
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
|
||||
return context -> {
|
||||
if (!v1.render(context).startsWith(v2.render(context))) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at !startsWith requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("endsWith", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
|
||||
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
|
||||
return context -> {
|
||||
if (v1.render(context).endsWith(v2.render(context))) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at endsWith requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("!endsWith", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
|
||||
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
|
||||
return context -> {
|
||||
if (!v1.render(context).endsWith(v2.render(context))) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at !endsWith requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("contains", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
|
||||
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
|
||||
return context -> {
|
||||
if (v1.render(context).contains(v2.render(context))) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at contains requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("!contains", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
|
||||
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
|
||||
return context -> {
|
||||
if (!v1.render(context).contains(v2.render(context))) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at !contains requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("in-list", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
TextValue<Player> papi = TextValue.auto(section.getString("papi", ""));
|
||||
List<String> values = ListUtils.toList(section.get("values"));
|
||||
return context -> {
|
||||
if (values.contains(papi.render(context))) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at in-list requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("!in-list", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
TextValue<Player> papi = TextValue.auto(section.getString("papi", ""));
|
||||
List<String> values = ListUtils.toList(section.get("values"));
|
||||
return context -> {
|
||||
if (!values.contains(papi.render(context))) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at !in-list requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("equals", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
|
||||
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
|
||||
return context -> {
|
||||
if (v1.render(context).equals(v2.render(context))) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at equals requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
registerRequirement("!equals", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
|
||||
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
|
||||
return context -> {
|
||||
if (!v1.render(context).equals(v2.render(context))) return true;
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at !equals requirement which should be Section");
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void registerPotionEffectRequirement() {
|
||||
registerRequirement("potion-effect", (args, actions, advanced) -> {
|
||||
String potions = (String) args;
|
||||
String[] split = potions.split("(<=|>=|<|>|==)", 2);
|
||||
PotionEffectType type = PotionEffectType.getByName(split[0]);
|
||||
if (type == null) {
|
||||
plugin.getPluginLogger().warn("Potion effect doesn't exist: " + split[0]);
|
||||
return EmptyRequirement.INSTANCE;
|
||||
}
|
||||
int required = Integer.parseInt(split[1]);
|
||||
String operator = potions.substring(split[0].length(), potions.length() - split[1].length());
|
||||
return context -> {
|
||||
int level = -1;
|
||||
PotionEffect potionEffect = context.getHolder().getPotionEffect(type);
|
||||
if (potionEffect != null) {
|
||||
level = potionEffect.getAmplifier();
|
||||
}
|
||||
boolean result = false;
|
||||
switch (operator) {
|
||||
case ">=" -> {
|
||||
if (level >= required) result = true;
|
||||
}
|
||||
case ">" -> {
|
||||
if (level > required) result = true;
|
||||
}
|
||||
case "==" -> {
|
||||
if (level == required) result = true;
|
||||
}
|
||||
case "!=" -> {
|
||||
if (level != required) result = true;
|
||||
}
|
||||
case "<=" -> {
|
||||
if (level <= required) result = true;
|
||||
}
|
||||
case "<" -> {
|
||||
if (level < required) result = true;
|
||||
}
|
||||
}
|
||||
if (result) {
|
||||
return true;
|
||||
}
|
||||
if (advanced) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads requirement expansions from external JAR files located in the expansion folder.
|
||||
* Each expansion JAR should contain classes that extends the RequirementExpansion class.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.requirement;
|
||||
package net.momirealms.customfishing.bukkit.requirement;
|
||||
|
||||
import net.momirealms.customfishing.api.common.Pair;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
|
||||
@@ -23,7 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.bukkit;
|
||||
package net.momirealms.customfishing.bukkit.scheduler;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.common.plugin.scheduler.AbstractJavaScheduler;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.mechanic.statistic;
|
||||
package net.momirealms.customfishing.bukkit.statistic;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.statistic.StatisticsManager;
|
||||
@@ -25,12 +25,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class StatisticsManagerImpl implements StatisticsManager {
|
||||
public class BukkitStatisticsManager implements StatisticsManager {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
private final HashMap<String, List<String>> categoryMap;
|
||||
|
||||
public StatisticsManagerImpl(BukkitCustomFishingPlugin plugin) {
|
||||
public BukkitStatisticsManager(BukkitCustomFishingPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.categoryMap = new HashMap<>();
|
||||
}
|
||||
@@ -15,12 +15,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.storage;
|
||||
package net.momirealms.customfishing.bukkit.storage;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import net.momirealms.customfishing.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.bukkit.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.scheduler.CancellableTask;
|
||||
import net.momirealms.customfishing.api.storage.DataStorageProvider;
|
||||
@@ -28,15 +28,15 @@ import net.momirealms.customfishing.api.storage.StorageManager;
|
||||
import net.momirealms.customfishing.api.storage.StorageType;
|
||||
import net.momirealms.customfishing.api.storage.data.PlayerData;
|
||||
import net.momirealms.customfishing.api.storage.user.UserData;
|
||||
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;
|
||||
import net.momirealms.customfishing.storage.method.database.sql.MariaDBImpl;
|
||||
import net.momirealms.customfishing.storage.method.database.sql.MySQLImpl;
|
||||
import net.momirealms.customfishing.storage.method.database.sql.SQLiteImpl;
|
||||
import net.momirealms.customfishing.storage.method.file.JsonImpl;
|
||||
import net.momirealms.customfishing.storage.method.file.YAMLImpl;
|
||||
import net.momirealms.customfishing.storage.user.OfflineUser;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.database.nosql.MongoDBImpl;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.database.nosql.RedisManager;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.database.sql.H2Impl;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.database.sql.MariaDBImpl;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.database.sql.MySQLImpl;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.database.sql.SQLiteImpl;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.file.JsonImpl;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.file.YAMLImpl;
|
||||
import net.momirealms.customfishing.bukkit.storage.user.OfflineUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -61,7 +61,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* This class implements the StorageManager interface and is responsible for managing player data storage.
|
||||
* It includes methods to handle player data retrieval, storage, and serialization.
|
||||
*/
|
||||
public class StorageManagerImpl implements StorageManager, Listener {
|
||||
public class BukkitStorageManager implements StorageManager, Listener {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
private DataStorageProvider dataSource;
|
||||
@@ -74,7 +74,7 @@ public class StorageManagerImpl implements StorageManager, Listener {
|
||||
private CancellableTask timerSaveTask;
|
||||
private final Gson gson;
|
||||
|
||||
public StorageManagerImpl(BukkitCustomFishingPluginImpl plugin) {
|
||||
public BukkitStorageManager(BukkitCustomFishingPluginImpl plugin) {
|
||||
this.plugin = plugin;
|
||||
this.locked = new HashSet<>();
|
||||
this.onlineUserMap = new ConcurrentHashMap<>();
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.storage.method;
|
||||
package net.momirealms.customfishing.bukkit.storage.method;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.storage.DataStorageProvider;
|
||||
@@ -80,4 +80,8 @@ public abstract class AbstractStorage implements DataStorageProvider {
|
||||
// By default, delegate to the updatePlayerData method to update or insert player data.
|
||||
return updatePlayerData(uuid, playerData, unlock);
|
||||
}
|
||||
|
||||
public BukkitCustomFishingPlugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.storage.method.database.nosql;
|
||||
package net.momirealms.customfishing.bukkit.storage.method.database.nosql;
|
||||
|
||||
import com.mongodb.*;
|
||||
import com.mongodb.client.*;
|
||||
@@ -25,7 +25,7 @@ import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.storage.StorageType;
|
||||
import net.momirealms.customfishing.api.storage.data.PlayerData;
|
||||
import net.momirealms.customfishing.api.storage.user.UserData;
|
||||
import net.momirealms.customfishing.storage.method.AbstractStorage;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.AbstractStorage;
|
||||
import org.bson.Document;
|
||||
import org.bson.UuidRepresentation;
|
||||
import org.bson.conversions.Bson;
|
||||
@@ -15,14 +15,17 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.storage.method.database.nosql;
|
||||
package net.momirealms.customfishing.bukkit.storage.method.database.nosql;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import dev.dejvokep.boostedyaml.YamlDocument;
|
||||
import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.config.ConfigManager;
|
||||
import net.momirealms.customfishing.api.storage.StorageType;
|
||||
import net.momirealms.customfishing.api.storage.data.PlayerData;
|
||||
import net.momirealms.customfishing.storage.method.AbstractStorage;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.AbstractStorage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import redis.clients.jedis.*;
|
||||
import redis.clients.jedis.exceptions.JedisException;
|
||||
@@ -77,10 +80,10 @@ public class RedisManager extends AbstractStorage {
|
||||
*/
|
||||
@Override
|
||||
public void initialize() {
|
||||
YamlConfiguration config = plugin.getConfig("database.yml");
|
||||
ConfigurationSection section = config.getConfigurationSection("Redis");
|
||||
YamlDocument config = plugin.getConfigManager().loadConfig("database.yml");
|
||||
Section section = config.getSection("Redis");
|
||||
if (section == null) {
|
||||
LogUtils.warn("Failed to load database config. It seems that your config is broken. Please regenerate a new one.");
|
||||
plugin.getPluginLogger().warn("Failed to load database config. It seems that your config is broken. Please regenerate a new one.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,7 +91,7 @@ public class RedisManager extends AbstractStorage {
|
||||
jedisPoolConfig.setTestWhileIdle(true);
|
||||
jedisPoolConfig.setTimeBetweenEvictionRuns(Duration.ofMillis(30000));
|
||||
jedisPoolConfig.setNumTestsPerEvictionRun(-1);
|
||||
jedisPoolConfig.setMinEvictableIdleTime(Duration.ofMillis(section.getInt("MinEvictableIdleTimeMillis",1800000)));
|
||||
jedisPoolConfig.setMinEvictableIdleDuration(Duration.ofMillis(section.getInt("MinEvictableIdleTimeMillis", 1800000)));
|
||||
jedisPoolConfig.setMaxTotal(section.getInt("MaxTotal",8));
|
||||
jedisPoolConfig.setMaxIdle(section.getInt("MaxIdle",8));
|
||||
jedisPoolConfig.setMinIdle(section.getInt("MinIdle",1));
|
||||
@@ -107,9 +110,9 @@ public class RedisManager extends AbstractStorage {
|
||||
String info;
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
info = jedis.info();
|
||||
LogUtils.info("Redis server connected.");
|
||||
plugin.getPluginLogger().info("Redis server connected.");
|
||||
} catch (JedisException e) {
|
||||
LogUtils.warn("Failed to connect redis.", e);
|
||||
plugin.getPluginLogger().warn("Failed to connect redis.", e);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,12 +142,9 @@ public class RedisManager extends AbstractStorage {
|
||||
/**
|
||||
* Send a message to Redis on a specified channel.
|
||||
*
|
||||
* @param server The Redis channel to send the message to.
|
||||
* @param message The message to send.
|
||||
*/
|
||||
public void publishRedisMessage(@NotNull String server, @NotNull String message) {
|
||||
message = server + ";" + message;
|
||||
plugin.debug("Sent Redis message: " + message);
|
||||
public void publishRedisMessage(@NotNull String message) {
|
||||
if (isNewerThan5) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
HashMap<String, String> messages = new HashMap<>();
|
||||
@@ -187,30 +187,28 @@ public class RedisManager extends AbstractStorage {
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private static void handleMessage(String message) {
|
||||
BukkitCustomFishingPlugin.get().debug("Received Redis message: " + message);
|
||||
String[] split = message.split(";");
|
||||
String server = split[0];
|
||||
if (!CFConfig.serverGroup.contains(server)) {
|
||||
private void handleMessage(String message) {
|
||||
ByteArrayDataInput input = ByteStreams.newDataInput(message.getBytes(StandardCharsets.UTF_8));
|
||||
String server = input.readUTF();
|
||||
if (!ConfigManager.serverGroup().equals(server))
|
||||
return;
|
||||
}
|
||||
String action = split[1];
|
||||
BukkitCustomFishingPlugin.get().getScheduler().runTaskAsync(() -> {
|
||||
String type = input.readUTF();
|
||||
if (type.equals("competition")) {
|
||||
String action = input.readUTF();
|
||||
switch (action) {
|
||||
case "start" -> {
|
||||
// start competition for all the servers that connected to redis
|
||||
BukkitCustomFishingPlugin.get().getCompetitionManager().startCompetition(split[2], true, null);
|
||||
plugin.getCompetitionManager().startCompetition(input.readUTF(), true, null);
|
||||
}
|
||||
case "end" -> {
|
||||
if (BukkitCustomFishingPlugin.get().getCompetitionManager().getOnGoingCompetition() != null)
|
||||
BukkitCustomFishingPlugin.get().getCompetitionManager().getOnGoingCompetition().end(true);
|
||||
if (plugin.getCompetitionManager().getOnGoingCompetition() != null)
|
||||
plugin.getCompetitionManager().getOnGoingCompetition().end(true);
|
||||
}
|
||||
case "stop" -> {
|
||||
if (BukkitCustomFishingPlugin.get().getCompetitionManager().getOnGoingCompetition() != null)
|
||||
BukkitCustomFishingPlugin.get().getCompetitionManager().getOnGoingCompetition().stop(true);
|
||||
if (plugin.getCompetitionManager().getOnGoingCompetition() != null)
|
||||
plugin.getCompetitionManager().getOnGoingCompetition().stop(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -226,7 +224,7 @@ public class RedisManager extends AbstractStorage {
|
||||
*/
|
||||
public CompletableFuture<Void> setChangeServer(UUID uuid) {
|
||||
var future = new CompletableFuture<Void>();
|
||||
plugin.getScheduler().runTaskAsync(() -> {
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
jedis.setex(
|
||||
getRedisKey("cf_server", uuid),
|
||||
@@ -235,7 +233,6 @@ public class RedisManager extends AbstractStorage {
|
||||
);
|
||||
}
|
||||
future.complete(null);
|
||||
plugin.debug("Server data set for " + uuid);
|
||||
});
|
||||
return future;
|
||||
}
|
||||
@@ -248,16 +245,14 @@ public class RedisManager extends AbstractStorage {
|
||||
*/
|
||||
public CompletableFuture<Boolean> getChangeServer(UUID uuid) {
|
||||
var future = new CompletableFuture<Boolean>();
|
||||
plugin.getScheduler().runTaskAsync(() -> {
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
byte[] key = getRedisKey("cf_server", uuid);
|
||||
if (jedis.get(key) != null) {
|
||||
jedis.del(key);
|
||||
future.complete(true);
|
||||
plugin.debug("Server data retrieved for " + uuid + "; value: true");
|
||||
} else {
|
||||
future.complete(false);
|
||||
plugin.debug("Server data retrieved for " + uuid + "; value: false");
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -274,21 +269,18 @@ public class RedisManager extends AbstractStorage {
|
||||
@Override
|
||||
public CompletableFuture<Optional<PlayerData>> getPlayerData(UUID uuid, boolean lock) {
|
||||
var future = new CompletableFuture<Optional<PlayerData>>();
|
||||
plugin.getScheduler().runTaskAsync(() -> {
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
byte[] key = getRedisKey("cf_data", uuid);
|
||||
byte[] data = jedis.get(key);
|
||||
jedis.del(key);
|
||||
if (data != null) {
|
||||
future.complete(Optional.of(plugin.getStorageManager().fromBytes(data)));
|
||||
plugin.debug("Redis data retrieved for " + uuid + "; normal data");
|
||||
} else {
|
||||
future.complete(Optional.empty());
|
||||
plugin.debug("Redis data retrieved for " + uuid + "; empty data");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
future.complete(Optional.empty());
|
||||
LogUtils.warn("Failed to get redis data for " + uuid, e);
|
||||
}
|
||||
});
|
||||
return future;
|
||||
@@ -305,7 +297,7 @@ public class RedisManager extends AbstractStorage {
|
||||
@Override
|
||||
public CompletableFuture<Boolean> updatePlayerData(UUID uuid, PlayerData playerData, boolean ignore) {
|
||||
var future = new CompletableFuture<Boolean>();
|
||||
plugin.getScheduler().runTaskAsync(() -> {
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
jedis.setex(
|
||||
getRedisKey("cf_data", uuid),
|
||||
@@ -313,24 +305,15 @@ public class RedisManager extends AbstractStorage {
|
||||
plugin.getStorageManager().toBytes(playerData)
|
||||
);
|
||||
future.complete(true);
|
||||
plugin.debug("Redis data set for " + uuid);
|
||||
} catch (Exception e) {
|
||||
future.complete(false);
|
||||
LogUtils.warn("Failed to set redis data for player " + uuid, e);
|
||||
}
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a set of unique player UUIDs from Redis (Returns an empty set).
|
||||
* This method is designed for importing and exporting so it would not actually be called.
|
||||
*
|
||||
* @param legacy Flag indicating whether to retrieve legacy data (not used).
|
||||
* @return An empty set of UUIDs.
|
||||
*/
|
||||
@Override
|
||||
public Set<UUID> getUniqueUsers(boolean legacy) {
|
||||
public Set<UUID> getUniqueUsers() {
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
@@ -349,17 +332,17 @@ public class RedisManager extends AbstractStorage {
|
||||
return STREAM;
|
||||
}
|
||||
|
||||
private static boolean isRedisNewerThan5(String version) {
|
||||
private boolean isRedisNewerThan5(String version) {
|
||||
String[] split = version.split("\\.");
|
||||
int major = Integer.parseInt(split[0]);
|
||||
if (major < 7) {
|
||||
LogUtils.warn(String.format("Detected that you are running an outdated Redis server. v%s. ", version));
|
||||
LogUtils.warn("It's recommended to update to avoid security vulnerabilities!");
|
||||
plugin.getPluginLogger().warn(String.format("Detected that you are running an outdated Redis server. v%s. ", version));
|
||||
plugin.getPluginLogger().warn("It's recommended to update to avoid security vulnerabilities!");
|
||||
}
|
||||
return major >= 5;
|
||||
}
|
||||
|
||||
private static String parseRedisVersion(String info) {
|
||||
private String parseRedisVersion(String info) {
|
||||
for (String line : info.split("\n")) {
|
||||
if (line.startsWith("redis_version:")) {
|
||||
return line.split(":")[1];
|
||||
@@ -386,7 +369,7 @@ public class RedisManager extends AbstractStorage {
|
||||
if (connection != null) {
|
||||
var messages = connection.xread(XReadParams.xReadParams().count(1).block(2000), map);
|
||||
connection.close();
|
||||
if (messages != null && messages.size() != 0) {
|
||||
if (messages != null && !messages.isEmpty()) {
|
||||
for (Map.Entry<String, List<StreamEntry>> message : messages) {
|
||||
if (message.getKey().equals(getStream())) {
|
||||
var value = message.getValue().get(0).getFields().get("value");
|
||||
@@ -398,7 +381,7 @@ public class RedisManager extends AbstractStorage {
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.warn("Failed to connect redis. Try reconnecting 10s later",e);
|
||||
plugin.getPluginLogger().warn("Failed to connect redis. Try reconnecting 10s later",e);
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException ex) {
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.storage.method.database.sql;
|
||||
package net.momirealms.customfishing.bukkit.storage.method.database.sql;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
@@ -15,12 +15,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.storage.method.database.sql;
|
||||
package net.momirealms.customfishing.bukkit.storage.method.database.sql;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.storage.data.PlayerData;
|
||||
import net.momirealms.customfishing.api.storage.user.UserData;
|
||||
import net.momirealms.customfishing.storage.method.AbstractStorage;
|
||||
import net.momirealms.customfishing.bukkit.storage.method.AbstractStorage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.storage.method.database.sql;
|
||||
package net.momirealms.customfishing.bukkit.storage.method.database.sql;
|
||||
|
||||
import net.momirealms.customfishing.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.bukkit.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.storage.StorageType;
|
||||
import net.momirealms.customfishing.libraries.dependencies.Dependency;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.storage.method.database.sql;
|
||||
package net.momirealms.customfishing.bukkit.storage.method.database.sql;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.storage.StorageType;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.storage.method.database.sql;
|
||||
package net.momirealms.customfishing.bukkit.storage.method.database.sql;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.storage.StorageType;
|
||||
@@ -15,9 +15,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.storage.method.database.sql;
|
||||
package net.momirealms.customfishing.bukkit.storage.method.database.sql;
|
||||
|
||||
import net.momirealms.customfishing.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.bukkit.BukkitCustomFishingPluginImpl;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.storage.StorageType;
|
||||
import net.momirealms.customfishing.api.storage.data.PlayerData;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user