From 023667a7d7f74153ba4d103e080431a5c347d298 Mon Sep 17 00:00:00 2001 From: Xiao-MoMi <70987828+Xiao-MoMi@users.noreply.github.com> Date: Tue, 18 Oct 2022 01:50:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 7 + .../customfishing/CustomFishing.java | 12 + .../api/event/FishHookEvent.java | 2 +- .../api/event/FishResultEvent.java | 2 +- .../customfishing/api/event/RodCastEvent.java | 2 +- .../competition/Competition.java | 4 +- .../competition/CompetitionSchedule.java | 2 +- .../competition/bossbar/BossBarManager.java | 2 +- .../competition/bossbar/BossBarSender.java | 2 +- .../competition/bossbar/Sender.java | 164 ------ .../data/AbstractSQLStorage.java | 4 + .../data/DataStorageInterface.java | 4 + .../customfishing/data/FileStorageImpl.java | 4 + .../data/MongoDBStorageImpl.java | 4 + .../customfishing/data/MySQLStorageImpl.java | 4 + .../customfishing/data/SQLiteStorageImpl.java | 4 + .../integration/AntiGriefInterface.java | 47 ++ .../integration/BlockInterface.java | 15 + .../integration/antigrief/BentoBoxHook.java | 45 ++ .../integration/antigrief/CrashClaimHook.java | 39 ++ .../antigrief/GriefDefenderHook.java | 35 ++ .../antigrief/GriefPreventionHook.java} | 23 +- .../integration/antigrief/KingdomsXHook.java | 53 ++ .../integration/antigrief/LandsHook.java | 42 ++ .../antigrief/PlotSquaredHook.java | 42 ++ .../integration/antigrief/ResidenceHook.java | 48 ++ .../integration/antigrief/TownyHook.java | 41 ++ .../integration/antigrief/WorldGuardHook.java | 68 +++ .../block/ItemsAdderBlockImpl.java | 46 ++ ...xenBlockHook.java => OraxenBlockImpl.java} | 25 +- ...erBlockHook.java => VanillaBlockImpl.java} | 22 +- ...emHook.java => CustomFishingItemImpl.java} | 2 +- ...{EcoItemHook.java => EcoItemRegister.java} | 2 +- ...rItemHook.java => ItemsAdderItemImpl.java} | 2 +- ...emsItemHook.java => MMOItemsItemImpl.java} | 2 +- ...sItemHook.java => MythicMobsItemImpl.java} | 4 +- ...raxenItemHook.java => OraxenItemImpl.java} | 2 +- ...obsMobHook.java => MythicMobsMobImpl.java} | 6 +- .../integration/papi/PlaceholderManager.java | 2 +- .../season/CustomCropsSeasonImpl.java | 10 +- ...{AureliumsHook.java => AureliumsImpl.java} | 4 +- ...{EcoSkillsHook.java => EcoSkillsImpl.java} | 4 +- ...obsRebornHook.java => JobsRebornImpl.java} | 4 +- .../{MMOCoreHook.java => MMOCoreImpl.java} | 4 +- .../skill/{mcMMOHook.java => mcMMOImpl.java} | 2 +- .../listener/InteractListener.java | 10 +- .../listener/SimpleListener.java | 2 +- .../customfishing/manager/BonusManager.java | 10 +- .../manager/CompetitionManager.java | 2 +- .../customfishing/manager/ConfigManager.java | 18 +- .../customfishing/manager/DataManager.java | 16 + .../customfishing/manager/FishingManager.java | 13 +- .../manager/IntegrationManager.java | 103 +++- .../customfishing/manager/LayoutManager.java | 4 +- .../customfishing/manager/LootManager.java | 9 +- .../customfishing/manager/TotemManager.java | 481 +++++++++++++++++- .../customfishing/{ => object}/Function.java | 7 +- .../customfishing/object/TextCache.java | 21 +- .../object/action/ActionInterface.java | 3 +- .../object/action/CommandActionImpl.java | 3 +- .../object/action/MessageActionImpl.java | 7 +- .../object/action/SkillXPImpl.java | 2 +- .../object/action/SoundActionImpl.java | 2 +- .../object/action/VanillaXPImpl.java | 2 +- .../object/{ => fishing}/Bonus.java | 2 +- .../object/{ => fishing}/Difficulty.java | 2 +- .../object/{ => fishing}/FishResult.java | 2 +- .../{ => fishing}/FishingCondition.java | 2 +- .../object/{ => fishing}/FishingPlayer.java | 2 +- .../object/{ => fishing}/Layout.java | 2 +- .../object/{ => fishing}/Modifier.java | 2 +- .../object/{ => fishing}/VanillaLoot.java | 2 +- .../object/loot/DroppedItem.java | 3 +- .../customfishing/object/{ => loot}/Item.java | 2 +- .../object/{ => loot}/LeveledEnchantment.java | 2 +- .../customfishing/object/loot/Loot.java | 4 +- .../customfishing/object/loot/Mob.java | 3 +- .../object/{ => loot}/MobVector.java | 2 +- .../object/requirements/BiomeImpl.java | 2 +- .../object/requirements/CustomPapi.java | 2 +- .../object/requirements/PermissionImpl.java | 2 +- .../requirements/RequirementInterface.java | 2 +- .../object/requirements/SeasonImpl.java | 2 +- .../object/requirements/SkillLevelImpl.java | 2 +- .../object/requirements/TimeImpl.java | 2 +- .../object/requirements/WeatherImpl.java | 2 +- .../object/requirements/WorldImpl.java | 2 +- .../object/requirements/YPosImpl.java | 2 +- .../customfishing/object/totem/Totem.java | 76 ++- .../customfishing/util/ConfigUtil.java | 1 - .../customfishing/util/ItemStackUtil.java | 4 +- .../customfishing/util/JedisUtil.java | 10 +- .../{object => util}/Reflection.java | 2 +- .../customfishing/util/TotemUtil.java | 348 ------------- src/main/resources/config.yml | 12 +- src/main/resources/database.yml | 47 +- src/main/resources/redis.yml | 11 - src/main/resources/totems.yml | 22 +- 98 files changed, 1423 insertions(+), 741 deletions(-) delete mode 100644 src/main/java/net/momirealms/customfishing/competition/bossbar/Sender.java create mode 100644 src/main/java/net/momirealms/customfishing/data/AbstractSQLStorage.java create mode 100644 src/main/java/net/momirealms/customfishing/data/DataStorageInterface.java create mode 100644 src/main/java/net/momirealms/customfishing/data/FileStorageImpl.java create mode 100644 src/main/java/net/momirealms/customfishing/data/MongoDBStorageImpl.java create mode 100644 src/main/java/net/momirealms/customfishing/data/MySQLStorageImpl.java create mode 100644 src/main/java/net/momirealms/customfishing/data/SQLiteStorageImpl.java create mode 100644 src/main/java/net/momirealms/customfishing/integration/AntiGriefInterface.java create mode 100644 src/main/java/net/momirealms/customfishing/integration/antigrief/BentoBoxHook.java create mode 100644 src/main/java/net/momirealms/customfishing/integration/antigrief/CrashClaimHook.java create mode 100644 src/main/java/net/momirealms/customfishing/integration/antigrief/GriefDefenderHook.java rename src/main/java/net/momirealms/customfishing/{competition/bossbar/Overlay.java => integration/antigrief/GriefPreventionHook.java} (50%) create mode 100644 src/main/java/net/momirealms/customfishing/integration/antigrief/KingdomsXHook.java create mode 100644 src/main/java/net/momirealms/customfishing/integration/antigrief/LandsHook.java create mode 100644 src/main/java/net/momirealms/customfishing/integration/antigrief/PlotSquaredHook.java create mode 100644 src/main/java/net/momirealms/customfishing/integration/antigrief/ResidenceHook.java create mode 100644 src/main/java/net/momirealms/customfishing/integration/antigrief/TownyHook.java create mode 100644 src/main/java/net/momirealms/customfishing/integration/antigrief/WorldGuardHook.java create mode 100644 src/main/java/net/momirealms/customfishing/integration/block/ItemsAdderBlockImpl.java rename src/main/java/net/momirealms/customfishing/integration/block/{OraxenBlockHook.java => OraxenBlockImpl.java} (56%) rename src/main/java/net/momirealms/customfishing/integration/block/{ItemsAdderBlockHook.java => VanillaBlockImpl.java} (51%) rename src/main/java/net/momirealms/customfishing/integration/item/{CustomFishingItemHook.java => CustomFishingItemImpl.java} (87%) rename src/main/java/net/momirealms/customfishing/integration/item/{EcoItemHook.java => EcoItemRegister.java} (99%) rename src/main/java/net/momirealms/customfishing/integration/item/{ItemsAdderItemHook.java => ItemsAdderItemImpl.java} (90%) rename src/main/java/net/momirealms/customfishing/integration/item/{MMOItemsItemHook.java => MMOItemsItemImpl.java} (93%) rename src/main/java/net/momirealms/customfishing/integration/item/{MythicMobsItemHook.java => MythicMobsItemImpl.java} (87%) rename src/main/java/net/momirealms/customfishing/integration/item/{OraxenItemHook.java => OraxenItemImpl.java} (91%) rename src/main/java/net/momirealms/customfishing/integration/mob/{MythicMobsMobHook.java => MythicMobsMobImpl.java} (91%) rename src/main/java/net/momirealms/customfishing/integration/skill/{AureliumsHook.java => AureliumsImpl.java} (94%) rename src/main/java/net/momirealms/customfishing/integration/skill/{EcoSkillsHook.java => EcoSkillsImpl.java} (93%) rename src/main/java/net/momirealms/customfishing/integration/skill/{JobsRebornHook.java => JobsRebornImpl.java} (96%) rename src/main/java/net/momirealms/customfishing/integration/skill/{MMOCoreHook.java => MMOCoreImpl.java} (95%) rename src/main/java/net/momirealms/customfishing/integration/skill/{mcMMOHook.java => mcMMOImpl.java} (96%) create mode 100644 src/main/java/net/momirealms/customfishing/manager/DataManager.java rename src/main/java/net/momirealms/customfishing/{ => object}/Function.java (61%) rename src/main/java/net/momirealms/customfishing/object/{ => fishing}/Bonus.java (97%) rename src/main/java/net/momirealms/customfishing/object/{ => fishing}/Difficulty.java (94%) rename src/main/java/net/momirealms/customfishing/object/{ => fishing}/FishResult.java (63%) rename src/main/java/net/momirealms/customfishing/object/{ => fishing}/FishingCondition.java (97%) rename src/main/java/net/momirealms/customfishing/object/{ => fishing}/FishingPlayer.java (98%) rename src/main/java/net/momirealms/customfishing/object/{ => fishing}/Layout.java (97%) rename src/main/java/net/momirealms/customfishing/object/{ => fishing}/Modifier.java (95%) rename src/main/java/net/momirealms/customfishing/object/{ => fishing}/VanillaLoot.java (87%) rename src/main/java/net/momirealms/customfishing/object/{ => loot}/Item.java (97%) rename src/main/java/net/momirealms/customfishing/object/{ => loot}/LeveledEnchantment.java (95%) rename src/main/java/net/momirealms/customfishing/object/{ => loot}/MobVector.java (94%) rename src/main/java/net/momirealms/customfishing/{object => util}/Reflection.java (95%) delete mode 100644 src/main/java/net/momirealms/customfishing/util/TotemUtil.java delete mode 100644 src/main/resources/redis.yml diff --git a/build.gradle b/build.gradle index b58fe4d1..dff5a7c3 100644 --- a/build.gradle +++ b/build.gradle @@ -40,12 +40,19 @@ repositories { name = "Lumine Releases" url = "https://mvn.lumine.io/repository/maven-public" } + maven { + name = 'glaremasters repo' + url = 'https://repo.glaremasters.me/repository/towny/' + } } dependencies { compileOnly fileTree(dir:'libs',includes:['*.jar']) compileOnly('io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT') + compileOnly('com.github.angeschossen:LandsAPI:6.5.1') compileOnly('com.github.Archy-X:AureliumSkills:Beta1.3.6') + compileOnly('com.github.TechFortress:GriefPrevention:16.18') + compileOnly('com.palmergames.bukkit.towny:towny:0.98.2.0') compileOnly('com.comphenix.protocol:ProtocolLib:4.8.0') compileOnly('redis.clients:jedis:4.2.3') compileOnly('me.clip:placeholderapi:2.11.1') diff --git a/src/main/java/net/momirealms/customfishing/CustomFishing.java b/src/main/java/net/momirealms/customfishing/CustomFishing.java index 3e543bc8..eb8098fa 100644 --- a/src/main/java/net/momirealms/customfishing/CustomFishing.java +++ b/src/main/java/net/momirealms/customfishing/CustomFishing.java @@ -41,6 +41,8 @@ public final class CustomFishing extends JavaPlugin { private BonusManager bonusManager; private LootManager lootManager; private LayoutManager layoutManager; + private DataManager dataManager; + private TotemManager totemManager; // _ooOoo_ // o8888888o @@ -80,6 +82,8 @@ public final class CustomFishing extends JavaPlugin { this.bonusManager = new BonusManager(); this.lootManager = new LootManager(); this.layoutManager = new LayoutManager(); + this.dataManager = new DataManager(); + this.totemManager = new TotemManager(integrationManager.getBlockInterface()); ConfigUtil.reload(); PluginCommand pluginCommand = new PluginCommand(); @@ -120,4 +124,12 @@ public final class CustomFishing extends JavaPlugin { public LayoutManager getLayoutManager() { return layoutManager; } + + public DataManager getDataManager() { + return dataManager; + } + + public TotemManager getTotemManager() { + return totemManager; + } } diff --git a/src/main/java/net/momirealms/customfishing/api/event/FishHookEvent.java b/src/main/java/net/momirealms/customfishing/api/event/FishHookEvent.java index 1ed042f9..6a039f3b 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/FishHookEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/FishHookEvent.java @@ -1,6 +1,6 @@ package net.momirealms.customfishing.api.event; -import net.momirealms.customfishing.object.Difficulty; +import net.momirealms.customfishing.object.fishing.Difficulty; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; diff --git a/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java b/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java index 5f786f0d..acee4d33 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java @@ -1,6 +1,6 @@ package net.momirealms.customfishing.api.event; -import net.momirealms.customfishing.object.FishResult; +import net.momirealms.customfishing.object.fishing.FishResult; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; diff --git a/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java b/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java index 44d63992..90154978 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java @@ -1,6 +1,6 @@ package net.momirealms.customfishing.api.event; -import net.momirealms.customfishing.object.Bonus; +import net.momirealms.customfishing.object.fishing.Bonus; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; diff --git a/src/main/java/net/momirealms/customfishing/competition/Competition.java b/src/main/java/net/momirealms/customfishing/competition/Competition.java index af613c2e..409184d7 100644 --- a/src/main/java/net/momirealms/customfishing/competition/Competition.java +++ b/src/main/java/net/momirealms/customfishing/competition/Competition.java @@ -143,7 +143,7 @@ public class Competition { Player player = Bukkit.getPlayer(playerName); if (player != null){ for (ActionInterface action : rewardsMap.get(String.valueOf(i))) { - action.doOn(player); + action.doOn(player, null); } } i++; @@ -155,7 +155,7 @@ public class Competition { Player player = Bukkit.getPlayer(playerName); if (player != null){ for (ActionInterface action : actions) { - action.doOn(player); + action.doOn(player, null); } } }); diff --git a/src/main/java/net/momirealms/customfishing/competition/CompetitionSchedule.java b/src/main/java/net/momirealms/customfishing/competition/CompetitionSchedule.java index 0380730f..4c9dbcba 100644 --- a/src/main/java/net/momirealms/customfishing/competition/CompetitionSchedule.java +++ b/src/main/java/net/momirealms/customfishing/competition/CompetitionSchedule.java @@ -1,8 +1,8 @@ package net.momirealms.customfishing.competition; import net.momirealms.customfishing.CustomFishing; -import net.momirealms.customfishing.Function; import net.momirealms.customfishing.manager.CompetitionManager; +import net.momirealms.customfishing.object.Function; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; diff --git a/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarManager.java b/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarManager.java index d3187b44..ab431b8c 100644 --- a/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarManager.java +++ b/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarManager.java @@ -1,10 +1,10 @@ package net.momirealms.customfishing.competition.bossbar; import net.momirealms.customfishing.CustomFishing; -import net.momirealms.customfishing.Function; import net.momirealms.customfishing.competition.Competition; import net.momirealms.customfishing.listener.SimpleListener; import net.momirealms.customfishing.manager.MessageManager; +import net.momirealms.customfishing.object.Function; import net.momirealms.customfishing.util.AdventureUtil; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarSender.java b/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarSender.java index 2a52b11f..a97a2e68 100644 --- a/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarSender.java +++ b/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarSender.java @@ -25,9 +25,9 @@ import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.competition.Competition; -import net.momirealms.customfishing.object.Reflection; import net.momirealms.customfishing.object.TextCache; import net.momirealms.customfishing.util.AdventureUtil; +import net.momirealms.customfishing.util.Reflection; import org.bukkit.boss.BarColor; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; diff --git a/src/main/java/net/momirealms/customfishing/competition/bossbar/Sender.java b/src/main/java/net/momirealms/customfishing/competition/bossbar/Sender.java deleted file mode 100644 index c51ebde2..00000000 --- a/src/main/java/net/momirealms/customfishing/competition/bossbar/Sender.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) <2022> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.momirealms.customfishing.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.CustomFishing; -import net.momirealms.customfishing.competition.Competition; -import net.momirealms.customfishing.object.Reflection; -import net.momirealms.customfishing.object.TextCache; -import net.momirealms.customfishing.util.AdventureUtil; -import org.bukkit.boss.BarColor; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.scheduler.BukkitTask; - -import java.lang.reflect.InvocationTargetException; -import java.util.Optional; -import java.util.UUID; - -public class Sender { - - private final Player player; - private int timer_1; - private int timer_2; - private int counter; - private final int size; - private final TextCache[] texts; - private TextCache text; - private BukkitTask bukkitTask; - private final UUID uuid; - private boolean force; - private final BossBarConfig config; - private boolean isShown; - private final BossBarManager bossBarManager; - - public void setText(int position) { - this.text = texts[position]; - this.force = true; - } - - public Sender(Player player, BossBarConfig config, BossBarManager bossBarManager){ - this.bossBarManager = bossBarManager; - String[] str = config.getText(); - this.size = str.length; - texts = new TextCache[str.length]; - for (int i = 0; i < str.length; i++) { - texts[i] = new TextCache(player, str[i]); - } - text = texts[0]; - this.player = player; - this.uuid = UUID.randomUUID(); - this.config = config; - this.isShown = false; - } - - public void show() { - this.isShown = true; - - try { - CustomFishing.protocolManager.sendServerPacket(player, getPacket()); - } catch (InvocationTargetException e){ - AdventureUtil.consoleMessage("[CustomFishing] Failed to display bossbar for " + player.getName()); - } - - this.bukkitTask = new BukkitRunnable() { - @Override - public void run() { - if (size != 1) { - timer_2++; - if (timer_2 > config.getInterval()) { - timer_2 = 0; - counter++; - if (counter == size) { - counter = 0; - } - setText(counter); - } - } - if (timer_1 < config.getRate()){ - timer_1++; - } - else { - timer_1 = 0; - if (text.update() || force) { - force = false; - try{ - CustomFishing.protocolManager.sendServerPacket(player, getPacket()); - } - catch (InvocationTargetException e){ - AdventureUtil.consoleMessage("[CustomFishing] Failed to update bossbar for " + player.getName()); - } - } - } - } - }.runTaskTimerAsynchronously(CustomFishing.plugin,1,1); - } - - private PacketContainer getPacket() { - 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( - text.getLatestValue() - .replace("{rank}", Competition.currentCompetition.getPlayerRank(player)) - .replace("{minute}", String.format("%02d", Competition.currentCompetition.getRemainingTime() / 60)) - .replace("{second}",String.format("%02d", Competition.currentCompetition.getRemainingTime() % 60)) - .replace("{point}", String.format("%.1f", Competition.currentCompetition.getScore(player)) - .replace("{1st_score}", String.format("%.1f", Competition.currentCompetition.getFirstScore())) - .replace("{1st_player}", Competition.currentCompetition.getFirstPlayer()) - ))))); - internalStructure.getFloat().write(0,1F); - internalStructure.getEnumModifier(BarColor.class, 2).write(0, config.getColor()); - internalStructure.getEnumModifier(Overlay.class, 3).write(0, config.getOverlay()); - internalStructure.getModifier().write(4, false); - internalStructure.getModifier().write(5, false); - internalStructure.getModifier().write(6, false); - return packet; - } - - public void hide() { - remove(); - if (bukkitTask != null) bukkitTask.cancel(); - this.isShown = false; - } - - private void remove() { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS); - packet.getModifier().write(0, uuid); - packet.getModifier().write(1, Reflection.removeBar); - try{ - CustomFishing.protocolManager.sendServerPacket(player, packet); - }catch (InvocationTargetException e){ - AdventureUtil.consoleMessage("[CustomFishing] Failed to remove bossbar for " + player.getName()); - } - } - - public boolean getStatus() { - return this.isShown; - } - - public BossBarConfig getConfig() { - return config; - } -} diff --git a/src/main/java/net/momirealms/customfishing/data/AbstractSQLStorage.java b/src/main/java/net/momirealms/customfishing/data/AbstractSQLStorage.java new file mode 100644 index 00000000..f8fa871d --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/data/AbstractSQLStorage.java @@ -0,0 +1,4 @@ +package net.momirealms.customfishing.data; + +public abstract class AbstractSQLStorage { +} diff --git a/src/main/java/net/momirealms/customfishing/data/DataStorageInterface.java b/src/main/java/net/momirealms/customfishing/data/DataStorageInterface.java new file mode 100644 index 00000000..633e99db --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/data/DataStorageInterface.java @@ -0,0 +1,4 @@ +package net.momirealms.customfishing.data; + +public interface DataStorageInterface { +} diff --git a/src/main/java/net/momirealms/customfishing/data/FileStorageImpl.java b/src/main/java/net/momirealms/customfishing/data/FileStorageImpl.java new file mode 100644 index 00000000..679d4a42 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/data/FileStorageImpl.java @@ -0,0 +1,4 @@ +package net.momirealms.customfishing.data; + +public class FileStorageImpl { +} diff --git a/src/main/java/net/momirealms/customfishing/data/MongoDBStorageImpl.java b/src/main/java/net/momirealms/customfishing/data/MongoDBStorageImpl.java new file mode 100644 index 00000000..85648df6 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/data/MongoDBStorageImpl.java @@ -0,0 +1,4 @@ +package net.momirealms.customfishing.data; + +public class MongoDBStorageImpl { +} diff --git a/src/main/java/net/momirealms/customfishing/data/MySQLStorageImpl.java b/src/main/java/net/momirealms/customfishing/data/MySQLStorageImpl.java new file mode 100644 index 00000000..fdde0964 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/data/MySQLStorageImpl.java @@ -0,0 +1,4 @@ +package net.momirealms.customfishing.data; + +public class MySQLStorageImpl extends AbstractSQLStorage implements DataStorageInterface { +} diff --git a/src/main/java/net/momirealms/customfishing/data/SQLiteStorageImpl.java b/src/main/java/net/momirealms/customfishing/data/SQLiteStorageImpl.java new file mode 100644 index 00000000..802f873f --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/data/SQLiteStorageImpl.java @@ -0,0 +1,4 @@ +package net.momirealms.customfishing.data; + +public class SQLiteStorageImpl extends AbstractSQLStorage implements DataStorageInterface { +} diff --git a/src/main/java/net/momirealms/customfishing/integration/AntiGriefInterface.java b/src/main/java/net/momirealms/customfishing/integration/AntiGriefInterface.java new file mode 100644 index 00000000..cda2bd28 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/AntiGriefInterface.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customfishing.integration; + +import net.momirealms.customfishing.CustomFishing; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public interface AntiGriefInterface { + + boolean canBreak(Location location, Player player); + + boolean canPlace(Location location, Player player); + + static boolean testBreak(Player player, Location location) { + for (AntiGriefInterface antiGrief : CustomFishing.plugin.getIntegrationManager().getAntiGriefs()) { + if(!antiGrief.canBreak(location, player)) { + return false; + } + } + return true; + } + + static boolean testPlace(Player player, Location location) { + for (AntiGriefInterface antiGrief : CustomFishing.plugin.getIntegrationManager().getAntiGriefs()) { + if(!antiGrief.canPlace(location, player)) { + return false; + } + } + return true; + } +} diff --git a/src/main/java/net/momirealms/customfishing/integration/BlockInterface.java b/src/main/java/net/momirealms/customfishing/integration/BlockInterface.java index 052d2b50..33e2bdee 100644 --- a/src/main/java/net/momirealms/customfishing/integration/BlockInterface.java +++ b/src/main/java/net/momirealms/customfishing/integration/BlockInterface.java @@ -10,4 +10,19 @@ public interface BlockInterface { void placeBlock(String id, Location location); @Nullable String getID(Block block); + + default void replaceBlock(Location location, String id) { + removeBlock(location.getBlock()); + placeBlock(id, location); + } + + static boolean isVanillaItem(String item) { + char[] chars = item.toCharArray(); + for (char character : chars) { + if ((character < 65 || character > 90) && character != 95) { + return false; + } + } + return true; + } } diff --git a/src/main/java/net/momirealms/customfishing/integration/antigrief/BentoBoxHook.java b/src/main/java/net/momirealms/customfishing/integration/antigrief/BentoBoxHook.java new file mode 100644 index 00000000..c28e21b1 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/antigrief/BentoBoxHook.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customfishing.integration.antigrief; + +import net.momirealms.customfishing.integration.AntiGriefInterface; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import world.bentobox.bentobox.BentoBox; +import world.bentobox.bentobox.api.user.User; +import world.bentobox.bentobox.database.objects.Island; +import world.bentobox.bentobox.lists.Flags; + +import java.util.Optional; + +public class BentoBoxHook implements AntiGriefInterface { + + @Override + public boolean canBreak(Location location, Player player) { + User user = User.getInstance(player); + Optional islandOptional = BentoBox.getInstance().getIslands().getIslandAt(location); + return islandOptional.map(island -> island.isAllowed(user, Flags.BREAK_BLOCKS)).orElse(true); + } + + @Override + public boolean canPlace(Location location, Player player) { + User user = User.getInstance(player); + Optional islandOptional = BentoBox.getInstance().getIslands().getIslandAt(location); + return islandOptional.map(island -> island.isAllowed(user, Flags.PLACE_BLOCKS)).orElse(true); + } +} diff --git a/src/main/java/net/momirealms/customfishing/integration/antigrief/CrashClaimHook.java b/src/main/java/net/momirealms/customfishing/integration/antigrief/CrashClaimHook.java new file mode 100644 index 00000000..1e960aeb --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/antigrief/CrashClaimHook.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customfishing.integration.antigrief; + +import net.crashcraft.crashclaim.api.CrashClaimAPI; +import net.crashcraft.crashclaim.permissions.PermissionRoute; +import net.momirealms.customfishing.integration.AntiGriefInterface; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class CrashClaimHook implements AntiGriefInterface { + + @Override + public boolean canBreak(Location location, Player player) { + CrashClaimAPI crashClaimAPI = net.crashcraft.crashclaim.CrashClaim.getPlugin().getApi(); + return crashClaimAPI.getPermissionHelper().hasPermission(player.getUniqueId(), location, PermissionRoute.BUILD); + } + + @Override + public boolean canPlace(Location location, Player player) { + CrashClaimAPI crashClaimAPI = net.crashcraft.crashclaim.CrashClaim.getPlugin().getApi(); + return crashClaimAPI.getPermissionHelper().hasPermission(player.getUniqueId(), location, PermissionRoute.BUILD); + } +} diff --git a/src/main/java/net/momirealms/customfishing/integration/antigrief/GriefDefenderHook.java b/src/main/java/net/momirealms/customfishing/integration/antigrief/GriefDefenderHook.java new file mode 100644 index 00000000..b7d32b38 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/antigrief/GriefDefenderHook.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customfishing.integration.antigrief; + +import net.momirealms.customfishing.integration.AntiGriefInterface; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class GriefDefenderHook implements AntiGriefInterface { + + @Override + public boolean canBreak(Location location, Player player) { + return com.griefdefender.api.GriefDefender.getCore().getUser(player.getUniqueId()).canBreak(location); + } + + @Override + public boolean canPlace(Location location, Player player) { + return com.griefdefender.api.GriefDefender.getCore().getUser(player.getUniqueId()).canPlace(player.getInventory().getItemInMainHand(), location); + } +} diff --git a/src/main/java/net/momirealms/customfishing/competition/bossbar/Overlay.java b/src/main/java/net/momirealms/customfishing/integration/antigrief/GriefPreventionHook.java similarity index 50% rename from src/main/java/net/momirealms/customfishing/competition/bossbar/Overlay.java rename to src/main/java/net/momirealms/customfishing/integration/antigrief/GriefPreventionHook.java index f3941409..1125f675 100644 --- a/src/main/java/net/momirealms/customfishing/competition/bossbar/Overlay.java +++ b/src/main/java/net/momirealms/customfishing/integration/antigrief/GriefPreventionHook.java @@ -15,12 +15,21 @@ * along with this program. If not, see . */ -package net.momirealms.customfishing.competition.bossbar; +package net.momirealms.customfishing.integration.antigrief; -public enum Overlay { - NOTCHED_6, - NOTCHED_10, - NOTCHED_12, - NOTCHED_20, - PROGRESS +import net.momirealms.customfishing.integration.AntiGriefInterface; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class GriefPreventionHook implements AntiGriefInterface { + + @Override + public boolean canBreak(Location location, Player player) { + return me.ryanhamshire.GriefPrevention.GriefPrevention.instance.allowBreak(player, location.getBlock(), location) == null; + } + + @Override + public boolean canPlace(Location location, Player player) { + return me.ryanhamshire.GriefPrevention.GriefPrevention.instance.allowBuild(player, location) == null; + } } diff --git a/src/main/java/net/momirealms/customfishing/integration/antigrief/KingdomsXHook.java b/src/main/java/net/momirealms/customfishing/integration/antigrief/KingdomsXHook.java new file mode 100644 index 00000000..02e6b0fd --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/antigrief/KingdomsXHook.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customfishing.integration.antigrief; + +import net.momirealms.customfishing.integration.AntiGriefInterface; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.kingdoms.constants.group.Kingdom; +import org.kingdoms.constants.land.Land; +import org.kingdoms.constants.player.KingdomPlayer; + +public class KingdomsXHook implements AntiGriefInterface { + + @Override + public boolean canBreak(Location location, Player player) { + return kingdomsCheck(location, player); + } + + @Override + public boolean canPlace(Location location, Player player) { + return kingdomsCheck(location, player); + } + + private boolean kingdomsCheck(Location location, Player player) { + Land land = Land.getLand(location); + if (land == null) return true; + if (land.isClaimed()) { + KingdomPlayer kp = KingdomPlayer.getKingdomPlayer(player); + Kingdom cropKingdom = land.getKingdom(); + if (kp.getKingdom() != null) { + Kingdom kingdom = kp.getKingdom(); + return kingdom != cropKingdom; + } + else return false; + } + else return true; + } +} diff --git a/src/main/java/net/momirealms/customfishing/integration/antigrief/LandsHook.java b/src/main/java/net/momirealms/customfishing/integration/antigrief/LandsHook.java new file mode 100644 index 00000000..c62bc9e1 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/antigrief/LandsHook.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customfishing.integration.antigrief; + +import me.angeschossen.lands.api.flags.Flags; +import me.angeschossen.lands.api.land.Area; +import net.momirealms.customcrops.CustomCrops; +import net.momirealms.customfishing.integration.AntiGriefInterface; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class LandsHook implements AntiGriefInterface { + + @Override + public boolean canBreak(Location location, Player player) { + Area area = new me.angeschossen.lands.api.integration.LandsIntegration(CustomCrops.plugin).getAreaByLoc(location); + if (area != null) return area.hasFlag(player, Flags.BLOCK_BREAK, false); + else return true; + } + + @Override + public boolean canPlace(Location location, Player player) { + Area area = new me.angeschossen.lands.api.integration.LandsIntegration(CustomCrops.plugin).getAreaByLoc(location); + if (area != null) return area.hasFlag(player, Flags.BLOCK_PLACE, false); + else return true; + } +} diff --git a/src/main/java/net/momirealms/customfishing/integration/antigrief/PlotSquaredHook.java b/src/main/java/net/momirealms/customfishing/integration/antigrief/PlotSquaredHook.java new file mode 100644 index 00000000..914b0746 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/antigrief/PlotSquaredHook.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customfishing.integration.antigrief; + +import com.plotsquared.core.location.Location; +import net.momirealms.customfishing.integration.AntiGriefInterface; +import org.bukkit.entity.Player; + +public class PlotSquaredHook implements AntiGriefInterface { + + @Override + public boolean canBreak(org.bukkit.Location location, Player player) { + return isAllowed(location, player); + } + + @Override + public boolean canPlace(org.bukkit.Location location, Player player) { + return isAllowed(location, player); + } + + private boolean isAllowed(org.bukkit.Location location, Player player) { + Location plotLoc = Location.at(location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()); + if (plotLoc.isPlotRoad()) return false; + if (plotLoc.getPlotArea() != null) return plotLoc.getPlotArea().getPlot(plotLoc).isAdded(player.getUniqueId()); + else return true; + } +} diff --git a/src/main/java/net/momirealms/customfishing/integration/antigrief/ResidenceHook.java b/src/main/java/net/momirealms/customfishing/integration/antigrief/ResidenceHook.java new file mode 100644 index 00000000..bcefdfd8 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/antigrief/ResidenceHook.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customfishing.integration.antigrief; + +import com.bekvon.bukkit.residence.containers.Flags; +import com.bekvon.bukkit.residence.protection.ClaimedResidence; +import com.bekvon.bukkit.residence.protection.ResidencePermissions; +import net.momirealms.customfishing.integration.AntiGriefInterface; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class ResidenceHook implements AntiGriefInterface { + + @Override + public boolean canBreak(Location location, Player player) { + ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location); + if(res!=null){ + ResidencePermissions perms = res.getPermissions(); + return perms.playerHas(player, Flags.destroy, true); + } + return true; + } + + @Override + public boolean canPlace(Location location, Player player) { + ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location); + if(res!=null){ + ResidencePermissions perms = res.getPermissions(); + return perms.playerHas(player, Flags.build, true); + } + return true; + } +} diff --git a/src/main/java/net/momirealms/customfishing/integration/antigrief/TownyHook.java b/src/main/java/net/momirealms/customfishing/integration/antigrief/TownyHook.java new file mode 100644 index 00000000..754b034b --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/antigrief/TownyHook.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customfishing.integration.antigrief; + +import com.palmergames.bukkit.towny.object.TownyPermission; +import com.palmergames.bukkit.towny.utils.PlayerCacheUtil; +import net.momirealms.customfishing.integration.AntiGriefInterface; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class TownyHook implements AntiGriefInterface { + + @Override + public boolean canBreak(Location location, Player player) { + return TownyPermission(player, location, TownyPermission.ActionType.DESTROY); + } + + @Override + public boolean canPlace(Location location, Player player) { + return TownyPermission(player, location, TownyPermission.ActionType.BUILD); + } + + private boolean TownyPermission(Player player, Location location, TownyPermission.ActionType actionType){ + return PlayerCacheUtil.getCachePermission(player, location, location.getBlock().getType(), actionType); + } +} diff --git a/src/main/java/net/momirealms/customfishing/integration/antigrief/WorldGuardHook.java b/src/main/java/net/momirealms/customfishing/integration/antigrief/WorldGuardHook.java new file mode 100644 index 00000000..4ee48e4e --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/antigrief/WorldGuardHook.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customfishing.integration.antigrief; + +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.world.World; +import com.sk89q.worldguard.LocalPlayer; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import com.sk89q.worldguard.internal.platform.WorldGuardPlatform; +import com.sk89q.worldguard.protection.flags.Flags; +import com.sk89q.worldguard.protection.managers.RegionManager; +import com.sk89q.worldguard.protection.regions.RegionContainer; +import com.sk89q.worldguard.protection.regions.RegionQuery; +import net.momirealms.customfishing.integration.AntiGriefInterface; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class WorldGuardHook implements AntiGriefInterface { + + @Override + public boolean canPlace(Location location, Player player) { + if (player.isOp()) return true; + LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); + World world = BukkitAdapter.adapt(location.getWorld()); + WorldGuardPlatform platform = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform(); + if (hasRegion(world, BukkitAdapter.asBlockVector(location))){ + RegionQuery query = platform.getRegionContainer().createQuery(); + return query.testBuild(BukkitAdapter.adapt(location), localPlayer, Flags.BUILD); + } + else return true; + } + + @Override + public boolean canBreak(Location location, Player player) { + if (player.isOp()) return true; + LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); + World world = BukkitAdapter.adapt(location.getWorld()); + WorldGuardPlatform platform = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform(); + if (hasRegion(world, BukkitAdapter.asBlockVector(location))){ + RegionQuery query = platform.getRegionContainer().createQuery(); + return query.testBuild(BukkitAdapter.adapt(location), localPlayer, Flags.BLOCK_BREAK); + } + else return true; + } + + private boolean hasRegion(World world, BlockVector3 vector){ + RegionContainer container = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform().getRegionContainer(); + RegionManager regionManager = container.get(world); + if (regionManager == null) return true; + return regionManager.getApplicableRegions(vector).size() > 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/momirealms/customfishing/integration/block/ItemsAdderBlockImpl.java b/src/main/java/net/momirealms/customfishing/integration/block/ItemsAdderBlockImpl.java new file mode 100644 index 00000000..8da8ca84 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/block/ItemsAdderBlockImpl.java @@ -0,0 +1,46 @@ +package net.momirealms.customfishing.integration.block; + +import dev.lone.itemsadder.api.CustomBlock; +import net.momirealms.customfishing.integration.BlockInterface; +import net.momirealms.customfishing.manager.TotemManager; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.jetbrains.annotations.Nullable; + +public class ItemsAdderBlockImpl implements BlockInterface { + + @Override + public void removeBlock(Block block) { + if (CustomBlock.byAlreadyPlaced(block) != null) { + CustomBlock.remove(block.getLocation()); + } + else { + block.setType(Material.AIR); + } + } + + @Override + public void placeBlock(String id, Location location) { + if (BlockInterface.isVanillaItem(id)) { + location.getBlock().setType(Material.valueOf(id)); + } + else { + CustomBlock.place(id, location); + } + } + + @Override + @Nullable + public String getID(Block block) { + CustomBlock customBlock = CustomBlock.byAlreadyPlaced(block); + String id; + if (customBlock == null) { + id = block.getType().name(); + } + else { + id = customBlock.getNamespacedID(); + } + return TotemManager.BLOCKS.get(id); + } +} \ No newline at end of file diff --git a/src/main/java/net/momirealms/customfishing/integration/block/OraxenBlockHook.java b/src/main/java/net/momirealms/customfishing/integration/block/OraxenBlockImpl.java similarity index 56% rename from src/main/java/net/momirealms/customfishing/integration/block/OraxenBlockHook.java rename to src/main/java/net/momirealms/customfishing/integration/block/OraxenBlockImpl.java index 7c51960d..036c28e6 100644 --- a/src/main/java/net/momirealms/customfishing/integration/block/OraxenBlockHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/block/OraxenBlockImpl.java @@ -4,12 +4,13 @@ import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanic import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanicFactory; import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanicListener; import net.momirealms.customfishing.integration.BlockInterface; +import net.momirealms.customfishing.manager.TotemManager; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.jetbrains.annotations.Nullable; -public class OraxenBlockHook implements BlockInterface { +public class OraxenBlockImpl implements BlockInterface { @Override public void removeBlock(Block block) { @@ -18,14 +19,30 @@ public class OraxenBlockHook implements BlockInterface { @Override public void placeBlock(String id, Location location) { - NoteBlockMechanicFactory.setBlockModel(location.getBlock(), id); + if (BlockInterface.isVanillaItem(id)) { + location.getBlock().setType(Material.valueOf(id)); + } + else { + NoteBlockMechanicFactory.setBlockModel(location.getBlock(), id); + } + } + + @Override + public void replaceBlock(Location location, String id) { + placeBlock(id, location); } @Nullable @Override public String getID(Block block) { NoteBlockMechanic mechanic = NoteBlockMechanicListener.getNoteBlockMechanic(block); - if (mechanic == null) return null; - else return mechanic.getItemID(); + String id; + if (mechanic == null) { + id = block.getType().name(); + } + else { + id = mechanic.getItemID(); + } + return TotemManager.BLOCKS.get(id); } } diff --git a/src/main/java/net/momirealms/customfishing/integration/block/ItemsAdderBlockHook.java b/src/main/java/net/momirealms/customfishing/integration/block/VanillaBlockImpl.java similarity index 51% rename from src/main/java/net/momirealms/customfishing/integration/block/ItemsAdderBlockHook.java rename to src/main/java/net/momirealms/customfishing/integration/block/VanillaBlockImpl.java index 6b94444f..7b6132d5 100644 --- a/src/main/java/net/momirealms/customfishing/integration/block/ItemsAdderBlockHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/block/VanillaBlockImpl.java @@ -1,27 +1,31 @@ package net.momirealms.customfishing.integration.block; -import dev.lone.itemsadder.api.CustomBlock; import net.momirealms.customfishing.integration.BlockInterface; +import net.momirealms.customfishing.manager.TotemManager; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; import org.jetbrains.annotations.Nullable; -public class ItemsAdderBlockHook implements BlockInterface { - +public class VanillaBlockImpl implements BlockInterface { @Override public void removeBlock(Block block) { - CustomBlock.remove(block.getLocation()); + block.setType(Material.AIR); } @Override public void placeBlock(String id, Location location) { - CustomBlock.place(id, location); + location.getBlock().setType(Material.valueOf(id)); + } + + @Nullable + @Override + public String getID(Block block) { + return TotemManager.BLOCKS.get(block.getType().name()); } @Override - @Nullable - public String getID(Block block) { - CustomBlock customBlock = CustomBlock.byAlreadyPlaced(block); - return customBlock == null ? null : customBlock.getNamespacedID(); + public void replaceBlock(Location location, String id) { + placeBlock(id, location); } } diff --git a/src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemHook.java b/src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemImpl.java similarity index 87% rename from src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemHook.java rename to src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemImpl.java index 49eacbdb..572ec391 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemImpl.java @@ -5,7 +5,7 @@ import net.momirealms.customfishing.manager.LootManager; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.Nullable; -public class CustomFishingItemHook implements ItemInterface { +public class CustomFishingItemImpl implements ItemInterface { @Override @Nullable diff --git a/src/main/java/net/momirealms/customfishing/integration/item/EcoItemHook.java b/src/main/java/net/momirealms/customfishing/integration/item/EcoItemRegister.java similarity index 99% rename from src/main/java/net/momirealms/customfishing/integration/item/EcoItemHook.java rename to src/main/java/net/momirealms/customfishing/integration/item/EcoItemRegister.java index 4ca1889d..c57170f9 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/EcoItemHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/EcoItemRegister.java @@ -10,7 +10,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Map; -public class EcoItemHook { +public class EcoItemRegister { public static void registerItems() { // Rods diff --git a/src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemHook.java b/src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemImpl.java similarity index 90% rename from src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemHook.java rename to src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemImpl.java index d6f2f5f6..c0de515c 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemImpl.java @@ -5,7 +5,7 @@ import net.momirealms.customfishing.integration.ItemInterface; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.Nullable; -public class ItemsAdderItemHook implements ItemInterface { +public class ItemsAdderItemImpl implements ItemInterface { @Override @Nullable diff --git a/src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemHook.java b/src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemImpl.java similarity index 93% rename from src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemHook.java rename to src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemImpl.java index 056a9232..50da12d8 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemImpl.java @@ -8,7 +8,7 @@ import org.apache.commons.lang.StringUtils; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.Nullable; -public class MMOItemsItemHook implements ItemInterface { +public class MMOItemsItemImpl implements ItemInterface { @Nullable @Override diff --git a/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemHook.java b/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java similarity index 87% rename from src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemHook.java rename to src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java index 08f9f79f..0d728ede 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java @@ -6,11 +6,11 @@ import net.momirealms.customfishing.integration.ItemInterface; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.Nullable; -public class MythicMobsItemHook implements ItemInterface { +public class MythicMobsItemImpl implements ItemInterface { private final ItemExecutor itemManager; - public MythicMobsItemHook() { + public MythicMobsItemImpl() { this.itemManager = MythicBukkit.inst().getItemManager(); } diff --git a/src/main/java/net/momirealms/customfishing/integration/item/OraxenItemHook.java b/src/main/java/net/momirealms/customfishing/integration/item/OraxenItemImpl.java similarity index 91% rename from src/main/java/net/momirealms/customfishing/integration/item/OraxenItemHook.java rename to src/main/java/net/momirealms/customfishing/integration/item/OraxenItemImpl.java index 8bfb0297..e07c98bb 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/OraxenItemHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/OraxenItemImpl.java @@ -6,7 +6,7 @@ import net.momirealms.customfishing.integration.ItemInterface; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.Nullable; -public class OraxenItemHook implements ItemInterface { +public class OraxenItemImpl implements ItemInterface { @Override @Nullable diff --git a/src/main/java/net/momirealms/customfishing/integration/mob/MythicMobsMobHook.java b/src/main/java/net/momirealms/customfishing/integration/mob/MythicMobsMobImpl.java similarity index 91% rename from src/main/java/net/momirealms/customfishing/integration/mob/MythicMobsMobHook.java rename to src/main/java/net/momirealms/customfishing/integration/mob/MythicMobsMobImpl.java index 04263f47..0560da70 100644 --- a/src/main/java/net/momirealms/customfishing/integration/mob/MythicMobsMobHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/mob/MythicMobsMobImpl.java @@ -8,18 +8,18 @@ import io.lumine.mythic.bukkit.MythicBukkit; import io.lumine.mythic.bukkit.utils.serialize.Position; import io.lumine.mythic.core.mobs.ActiveMob; import net.momirealms.customfishing.integration.MobInterface; -import net.momirealms.customfishing.object.MobVector; import net.momirealms.customfishing.object.loot.Mob; +import net.momirealms.customfishing.object.loot.MobVector; import org.bukkit.Location; import org.bukkit.util.Vector; import java.util.Optional; -public class MythicMobsMobHook implements MobInterface { +public class MythicMobsMobImpl implements MobInterface { private final MobManager mobManager; - public MythicMobsMobHook() { + public MythicMobsMobImpl() { this.mobManager = MythicBukkit.inst().getMobManager(); } diff --git a/src/main/java/net/momirealms/customfishing/integration/papi/PlaceholderManager.java b/src/main/java/net/momirealms/customfishing/integration/papi/PlaceholderManager.java index 74a589d6..db4be568 100644 --- a/src/main/java/net/momirealms/customfishing/integration/papi/PlaceholderManager.java +++ b/src/main/java/net/momirealms/customfishing/integration/papi/PlaceholderManager.java @@ -1,7 +1,7 @@ package net.momirealms.customfishing.integration.papi; import me.clip.placeholderapi.PlaceholderAPI; -import net.momirealms.customfishing.Function; +import net.momirealms.customfishing.object.Function; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; diff --git a/src/main/java/net/momirealms/customfishing/integration/season/CustomCropsSeasonImpl.java b/src/main/java/net/momirealms/customfishing/integration/season/CustomCropsSeasonImpl.java index 434061fc..7fa139bb 100644 --- a/src/main/java/net/momirealms/customfishing/integration/season/CustomCropsSeasonImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/season/CustomCropsSeasonImpl.java @@ -1,4 +1,12 @@ package net.momirealms.customfishing.integration.season; -public class CustomCropsSeasonImpl { +import net.momirealms.customcrops.api.utils.SeasonUtils; +import net.momirealms.customfishing.integration.SeasonInterface; +import org.bukkit.World; + +public class CustomCropsSeasonImpl implements SeasonInterface { + @Override + public String getSeason(World world) { + return SeasonUtils.getSeason(world).name(); + } } diff --git a/src/main/java/net/momirealms/customfishing/integration/skill/AureliumsHook.java b/src/main/java/net/momirealms/customfishing/integration/skill/AureliumsImpl.java similarity index 94% rename from src/main/java/net/momirealms/customfishing/integration/skill/AureliumsHook.java rename to src/main/java/net/momirealms/customfishing/integration/skill/AureliumsImpl.java index 53ca00e7..8a8adc28 100644 --- a/src/main/java/net/momirealms/customfishing/integration/skill/AureliumsHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/skill/AureliumsImpl.java @@ -23,12 +23,12 @@ import com.archyx.aureliumskills.skills.Skill; import net.momirealms.customfishing.integration.SkillInterface; import org.bukkit.entity.Player; -public class AureliumsHook implements SkillInterface { +public class AureliumsImpl implements SkillInterface { private final Leveler leveler; private final Skill skill; - public AureliumsHook() { + public AureliumsImpl() { leveler = AureliumAPI.getPlugin().getLeveler(); skill = AureliumAPI.getPlugin().getSkillRegistry().getSkill("fishing"); } diff --git a/src/main/java/net/momirealms/customfishing/integration/skill/EcoSkillsHook.java b/src/main/java/net/momirealms/customfishing/integration/skill/EcoSkillsImpl.java similarity index 93% rename from src/main/java/net/momirealms/customfishing/integration/skill/EcoSkillsHook.java rename to src/main/java/net/momirealms/customfishing/integration/skill/EcoSkillsImpl.java index e7d363d7..c04b6024 100644 --- a/src/main/java/net/momirealms/customfishing/integration/skill/EcoSkillsHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/skill/EcoSkillsImpl.java @@ -22,11 +22,11 @@ import com.willfp.ecoskills.skills.Skills; import net.momirealms.customfishing.integration.SkillInterface; import org.bukkit.entity.Player; -public class EcoSkillsHook implements SkillInterface { +public class EcoSkillsImpl implements SkillInterface { public EcoSkillsAPI ecoSkillsAPI; - public EcoSkillsHook() { + public EcoSkillsImpl() { ecoSkillsAPI = EcoSkillsAPI.getInstance(); } diff --git a/src/main/java/net/momirealms/customfishing/integration/skill/JobsRebornHook.java b/src/main/java/net/momirealms/customfishing/integration/skill/JobsRebornImpl.java similarity index 96% rename from src/main/java/net/momirealms/customfishing/integration/skill/JobsRebornHook.java rename to src/main/java/net/momirealms/customfishing/integration/skill/JobsRebornImpl.java index dd6c3fb3..c704ff0a 100644 --- a/src/main/java/net/momirealms/customfishing/integration/skill/JobsRebornHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/skill/JobsRebornImpl.java @@ -27,11 +27,11 @@ import org.bukkit.entity.Player; import java.util.List; -public class JobsRebornHook implements SkillInterface { +public class JobsRebornImpl implements SkillInterface { private final PlayerManager playerManager; - public JobsRebornHook() { + public JobsRebornImpl() { this.playerManager = Jobs.getPlayerManager(); } diff --git a/src/main/java/net/momirealms/customfishing/integration/skill/MMOCoreHook.java b/src/main/java/net/momirealms/customfishing/integration/skill/MMOCoreImpl.java similarity index 95% rename from src/main/java/net/momirealms/customfishing/integration/skill/MMOCoreHook.java rename to src/main/java/net/momirealms/customfishing/integration/skill/MMOCoreImpl.java index 17031e74..eb293242 100644 --- a/src/main/java/net/momirealms/customfishing/integration/skill/MMOCoreHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/skill/MMOCoreImpl.java @@ -24,12 +24,12 @@ import net.Indyuce.mmocore.manager.data.PlayerDataManager; import net.momirealms.customfishing.integration.SkillInterface; import org.bukkit.entity.Player; -public class MMOCoreHook implements SkillInterface { +public class MMOCoreImpl implements SkillInterface { private final Profession profession; private final PlayerDataManager playerDataManager; - public MMOCoreHook() { + public MMOCoreImpl() { profession = MMOCore.plugin.professionManager.get("fishing"); playerDataManager = MMOCore.plugin.dataProvider.getDataManager(); } diff --git a/src/main/java/net/momirealms/customfishing/integration/skill/mcMMOHook.java b/src/main/java/net/momirealms/customfishing/integration/skill/mcMMOImpl.java similarity index 96% rename from src/main/java/net/momirealms/customfishing/integration/skill/mcMMOHook.java rename to src/main/java/net/momirealms/customfishing/integration/skill/mcMMOImpl.java index 457407eb..a49e16a7 100644 --- a/src/main/java/net/momirealms/customfishing/integration/skill/mcMMOHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/skill/mcMMOImpl.java @@ -22,7 +22,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import net.momirealms.customfishing.integration.SkillInterface; import org.bukkit.entity.Player; -public class mcMMOHook implements SkillInterface { +public class mcMMOImpl implements SkillInterface { @Override public void addXp(Player player, double amount) { diff --git a/src/main/java/net/momirealms/customfishing/listener/InteractListener.java b/src/main/java/net/momirealms/customfishing/listener/InteractListener.java index 236eca42..043b21e1 100644 --- a/src/main/java/net/momirealms/customfishing/listener/InteractListener.java +++ b/src/main/java/net/momirealms/customfishing/listener/InteractListener.java @@ -1,20 +1,20 @@ package net.momirealms.customfishing.listener; -import net.momirealms.customfishing.manager.FishingManager; +import net.momirealms.customfishing.object.Function; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; public class InteractListener implements Listener { - private final FishingManager fishingManager; + private final Function function; - public InteractListener(FishingManager fishingManager) { - this.fishingManager = fishingManager; + public InteractListener(Function function) { + this.function = function; } @EventHandler public void onInteract(PlayerInteractEvent event) { - fishingManager.onInteract(event); + function.onInteract(event); } } diff --git a/src/main/java/net/momirealms/customfishing/listener/SimpleListener.java b/src/main/java/net/momirealms/customfishing/listener/SimpleListener.java index ffcee539..8022c3d7 100644 --- a/src/main/java/net/momirealms/customfishing/listener/SimpleListener.java +++ b/src/main/java/net/momirealms/customfishing/listener/SimpleListener.java @@ -1,6 +1,6 @@ package net.momirealms.customfishing.listener; -import net.momirealms.customfishing.Function; +import net.momirealms.customfishing.object.Function; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; diff --git a/src/main/java/net/momirealms/customfishing/manager/BonusManager.java b/src/main/java/net/momirealms/customfishing/manager/BonusManager.java index 70d4716c..22d93f40 100644 --- a/src/main/java/net/momirealms/customfishing/manager/BonusManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/BonusManager.java @@ -1,10 +1,10 @@ package net.momirealms.customfishing.manager; import net.momirealms.customfishing.CustomFishing; -import net.momirealms.customfishing.Function; -import net.momirealms.customfishing.object.Bonus; -import net.momirealms.customfishing.object.Item; -import net.momirealms.customfishing.object.LeveledEnchantment; +import net.momirealms.customfishing.object.Function; +import net.momirealms.customfishing.object.fishing.Bonus; +import net.momirealms.customfishing.object.loot.Item; +import net.momirealms.customfishing.object.loot.LeveledEnchantment; import net.momirealms.customfishing.util.AdventureUtil; import net.momirealms.customfishing.util.ConfigUtil; import net.momirealms.customfishing.util.ItemStackUtil; @@ -131,7 +131,7 @@ public class BonusManager extends Function { AdventureUtil.consoleMessage("[CustomFishing] Loaded " + BAITITEMS.size() + " baits"); } - private Bonus getBonus(YamlConfiguration config, String key) { + public static Bonus getBonus(YamlConfiguration config, String key) { Bonus bonus = new Bonus(); config.getConfigurationSection(key + ".modifier").getKeys(false).forEach(modifier -> { switch (modifier) { diff --git a/src/main/java/net/momirealms/customfishing/manager/CompetitionManager.java b/src/main/java/net/momirealms/customfishing/manager/CompetitionManager.java index 2b3f53a0..7c2c3b04 100644 --- a/src/main/java/net/momirealms/customfishing/manager/CompetitionManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/CompetitionManager.java @@ -1,11 +1,11 @@ package net.momirealms.customfishing.manager; -import net.momirealms.customfishing.Function; import net.momirealms.customfishing.competition.CompetitionConfig; import net.momirealms.customfishing.competition.CompetitionGoal; import net.momirealms.customfishing.competition.CompetitionSchedule; import net.momirealms.customfishing.competition.bossbar.BossBarConfig; import net.momirealms.customfishing.competition.bossbar.BossBarOverlay; +import net.momirealms.customfishing.object.Function; import net.momirealms.customfishing.object.action.ActionInterface; import net.momirealms.customfishing.object.action.CommandActionImpl; import net.momirealms.customfishing.object.action.MessageActionImpl; diff --git a/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java b/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java index d8a310d0..0932577c 100644 --- a/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java @@ -78,7 +78,7 @@ public class ConfigManager { needRodToFish = config.getBoolean("mechanics.need-special-rod.to-fish", false); rodLoseDurability = config.getBoolean("mechanics.rod-lose-durability", true); fishFinderCoolDown = config.getInt("mechanics.fishfinder-cooldown", 3000); - enableCompetition = config.getBoolean("mechanics.fishing-competition", true); + enableCompetition = config.getBoolean("mechanics.fishing-competition.enable", true); priority = config.getString("other-settings.event-priority", "NORMAL").toUpperCase(); disableJobsXp = config.getBoolean("other-settings.disable-JobsReborn-fishing-exp", false); @@ -97,7 +97,12 @@ public class ConfigManager { failureFadeStay = config.getInt("titles.failure.fade.stay", 30) * 50; failureFadeOut = config.getInt("titles.failure.fade.out", 10) * 50; - tryEnableJedis(); + useRedis = false; + if (enableCompetition && config.getBoolean("mechanics.fishing-competition.redis", false)) { + YamlConfiguration configuration = ConfigUtil.getConfig("database.yml"); + JedisUtil.initializeRedis(configuration); + useRedis = true; + } } public static List getWorldsList() { if (whiteOrBlack) { @@ -109,13 +114,4 @@ public class ConfigManager { return worldList; } } - - public static void tryEnableJedis(){ - YamlConfiguration configuration = ConfigUtil.getConfig("redis.yml"); - useRedis = false; - if (configuration.getBoolean("redis.enable")){ - JedisUtil.initializeRedis(configuration); - useRedis = true; - } - } } diff --git a/src/main/java/net/momirealms/customfishing/manager/DataManager.java b/src/main/java/net/momirealms/customfishing/manager/DataManager.java new file mode 100644 index 00000000..028f9abb --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/manager/DataManager.java @@ -0,0 +1,16 @@ +package net.momirealms.customfishing.manager; + +import net.momirealms.customfishing.object.Function; + +public class DataManager extends Function { + + @Override + public void load() { + super.load(); + } + + @Override + public void unload() { + super.unload(); + } +} diff --git a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java index a8aaded0..ed517d66 100644 --- a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java @@ -8,7 +8,6 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customfishing.CustomFishing; -import net.momirealms.customfishing.Function; import net.momirealms.customfishing.api.event.FishFinderEvent; import net.momirealms.customfishing.api.event.FishHookEvent; import net.momirealms.customfishing.api.event.FishResultEvent; @@ -17,8 +16,9 @@ import net.momirealms.customfishing.competition.Competition; import net.momirealms.customfishing.integration.MobInterface; import net.momirealms.customfishing.integration.item.McMMOTreasure; import net.momirealms.customfishing.listener.*; -import net.momirealms.customfishing.object.*; +import net.momirealms.customfishing.object.Function; import net.momirealms.customfishing.object.action.ActionInterface; +import net.momirealms.customfishing.object.fishing.*; import net.momirealms.customfishing.object.loot.DroppedItem; import net.momirealms.customfishing.object.loot.Loot; import net.momirealms.customfishing.object.loot.Mob; @@ -367,7 +367,7 @@ public class FishingManager extends Function { dropItem(player, location, fishResultEvent.isDouble(), drop); for (ActionInterface action : droppedItem.getSuccessActions()) - action.doOn(player); + action.doOn(player, null); sendSuccessTitle(player, droppedItem.getNick()); } @@ -465,7 +465,7 @@ public class FishingManager extends Function { mobInterface.summon(player.getLocation(), location, mob); for (ActionInterface action : loot.getSuccessActions()) - action.doOn(player); + action.doOn(player, null); sendSuccessTitle(player, loot.getNick()); } @@ -556,7 +556,7 @@ public class FishingManager extends Function { if (!isVanilla && loot != null){ for (ActionInterface action : loot.getFailureActions()) - action.doOn(player); + action.doOn(player, null); } AdventureUtil.playerTitle( @@ -652,6 +652,7 @@ public class FishingManager extends Function { return available; } + @Override public void onInteract(PlayerInteractEvent event) { ItemStack itemStack = event.getItem(); if (itemStack == null || itemStack.getType() == Material.AIR) return; @@ -739,7 +740,7 @@ public class FishingManager extends Function { if (vanillaLoot.get(player) == null && loot != null){ for (ActionInterface action : loot.getHookActions()) { - action.doOn(player); + action.doOn(player, null); } } diff --git a/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java b/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java index 289bbf1c..a8f8f479 100644 --- a/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java @@ -1,15 +1,18 @@ package net.momirealms.customfishing.manager; -import net.momirealms.customfishing.Function; -import net.momirealms.customfishing.integration.ItemInterface; -import net.momirealms.customfishing.integration.MobInterface; -import net.momirealms.customfishing.integration.SeasonInterface; -import net.momirealms.customfishing.integration.SkillInterface; +import net.momirealms.customfishing.helper.Log; +import net.momirealms.customfishing.integration.*; +import net.momirealms.customfishing.integration.antigrief.*; +import net.momirealms.customfishing.integration.block.ItemsAdderBlockImpl; +import net.momirealms.customfishing.integration.block.OraxenBlockImpl; +import net.momirealms.customfishing.integration.block.VanillaBlockImpl; import net.momirealms.customfishing.integration.item.*; -import net.momirealms.customfishing.integration.mob.MythicMobsMobHook; +import net.momirealms.customfishing.integration.mob.MythicMobsMobImpl; import net.momirealms.customfishing.integration.papi.PlaceholderManager; +import net.momirealms.customfishing.integration.season.CustomCropsSeasonImpl; import net.momirealms.customfishing.integration.season.RealisticSeasonsImpl; import net.momirealms.customfishing.integration.skill.*; +import net.momirealms.customfishing.object.Function; import net.momirealms.customfishing.util.AdventureUtil; import net.momirealms.customfishing.util.ConfigUtil; import org.bukkit.Bukkit; @@ -29,7 +32,9 @@ public class IntegrationManager extends Function { private SkillInterface skillInterface; private ItemInterface[] itemInterfaces; private MobInterface mobInterface; + private BlockInterface blockInterface; private PlaceholderManager placeholderManager; + private AntiGriefInterface[] antiGriefs; public IntegrationManager() { load(); @@ -48,19 +53,24 @@ public class IntegrationManager extends Function { } List itemInterfaceList = new ArrayList<>(); - itemInterfaceList.add(new CustomFishingItemHook()); - if (pluginManager.getPlugin("ItemsAdder") != null) itemInterfaceList.add(new ItemsAdderItemHook()); - if (pluginManager.getPlugin("Oraxen") != null) itemInterfaceList.add(new OraxenItemHook()); - if (pluginManager.getPlugin("MMOItems") != null) itemInterfaceList.add(new MMOItemsItemHook()); + itemInterfaceList.add(new CustomFishingItemImpl()); + if (pluginManager.getPlugin("ItemsAdder") != null) itemInterfaceList.add(new ItemsAdderItemImpl()); + if (pluginManager.getPlugin("Oraxen") != null) itemInterfaceList.add(new OraxenItemImpl()); + if (pluginManager.getPlugin("MMOItems") != null) itemInterfaceList.add(new MMOItemsItemImpl()); if (pluginManager.getPlugin("MythicMobs") != null) { - itemInterfaceList.add(new MythicMobsItemHook()); - this.mobInterface = new MythicMobsMobHook(); + itemInterfaceList.add(new MythicMobsItemImpl()); + this.mobInterface = new MythicMobsMobImpl(); } this.itemInterfaces = itemInterfaceList.toArray(new ItemInterface[0]); + if (pluginManager.getPlugin("ItemsAdder") != null) { + this.blockInterface = new ItemsAdderBlockImpl(); + } else if (pluginManager.getPlugin("Oraxen") != null) { + this.blockInterface = new OraxenBlockImpl(); + } else this.blockInterface = new VanillaBlockImpl(); if (pluginManager.getPlugin("eco") != null) { - EcoItemHook.registerItems(); + EcoItemRegister.registerItems(); } YamlConfiguration config = ConfigUtil.getConfig("config.yml"); @@ -68,26 +78,68 @@ public class IntegrationManager extends Function { this.seasonInterface = new RealisticSeasonsImpl(); hookMessage("RealisticSeasons"); } else if (config.getBoolean("integration.CustomCrops", false) && pluginManager.getPlugin("CustomCrops") != null) { - //TODO - this.seasonInterface = null; + this.seasonInterface = new CustomCropsSeasonImpl(); hookMessage("CustomCrops"); } if (config.getBoolean("integration.mcMMO", false) && Bukkit.getPluginManager().getPlugin("mcMMO") != null) { - this.skillInterface = new mcMMOHook(); + this.skillInterface = new mcMMOImpl(); hookMessage("mcMMO"); } else if (config.getBoolean("integration.MMOCore", false) && Bukkit.getPluginManager().getPlugin("MMOCore") != null) { - this.skillInterface = new MMOCoreHook(); + this.skillInterface = new MMOCoreImpl(); hookMessage("MMOCore"); } else if (config.getBoolean("integration.AureliumSkills", false) && Bukkit.getPluginManager().getPlugin("AureliumSkills") != null) { - this.skillInterface = new AureliumsHook(); + this.skillInterface = new AureliumsImpl(); hookMessage("AureliumSkills"); } else if (config.getBoolean("integration.EcoSkills", false) && Bukkit.getPluginManager().getPlugin("EcoSkills") != null) { - this.skillInterface = new EcoSkillsHook(); + this.skillInterface = new EcoSkillsImpl(); hookMessage("EcoSkills"); } else if (config.getBoolean("integration.JobsReborn", false) && Bukkit.getPluginManager().getPlugin("Jobs") != null) { - this.skillInterface = new JobsRebornHook(); + this.skillInterface = new JobsRebornImpl(); hookMessage("JobsReborn"); } + + List antiGriefsList = new ArrayList<>(); + if (config.getBoolean("integration.Residence",false)){ + if (Bukkit.getPluginManager().getPlugin("Residence") == null) Log.warn("Failed to initialize Residence!"); + else {antiGriefsList.add(new net.momirealms.customfishing.integration.antigrief.ResidenceHook());hookMessage("Residence");} + } + if (config.getBoolean("integration.Kingdoms",false)){ + if (Bukkit.getPluginManager().getPlugin("Kingdoms") == null) Log.warn("Failed to initialize Kingdoms!"); + else {antiGriefsList.add(new KingdomsXHook());hookMessage("Kingdoms");} + } + if (config.getBoolean("integration.WorldGuard",false)){ + if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null) Log.warn("Failed to initialize WorldGuard!"); + else {antiGriefsList.add(new WorldGuardHook());hookMessage("WorldGuard");} + } + if (config.getBoolean("integration.GriefDefender",false)){ + if(Bukkit.getPluginManager().getPlugin("GriefDefender") == null) Log.warn("Failed to initialize GriefDefender!"); + else {antiGriefsList.add(new GriefDefenderHook());hookMessage("GriefDefender");} + } + if (config.getBoolean("integration.PlotSquared",false)){ + if(Bukkit.getPluginManager().getPlugin("PlotSquared") == null) Log.warn("Failed to initialize PlotSquared!"); + else {antiGriefsList.add(new PlotSquaredHook());hookMessage("PlotSquared");} + } + if (config.getBoolean("integration.Towny",false)){ + if (Bukkit.getPluginManager().getPlugin("Towny") == null) Log.warn("Failed to initialize Towny!"); + else {antiGriefsList.add(new TownyHook());hookMessage("Towny");} + } + if (config.getBoolean("integration.Lands",false)){ + if (Bukkit.getPluginManager().getPlugin("Lands") == null) Log.warn("Failed to initialize Lands!"); + else {antiGriefsList.add(new LandsHook());hookMessage("Lands");} + } + if (config.getBoolean("integration.GriefPrevention",false)){ + if (Bukkit.getPluginManager().getPlugin("GriefPrevention") == null) Log.warn("Failed to initialize GriefPrevention!"); + else {antiGriefsList.add(new GriefPreventionHook());hookMessage("GriefPrevention");} + } + if (config.getBoolean("integration.CrashClaim",false)){ + if (Bukkit.getPluginManager().getPlugin("CrashClaim") == null) Log.warn("Failed to initialize CrashClaim!"); + else {antiGriefsList.add(new CrashClaimHook());hookMessage("CrashClaim");} + } + if (config.getBoolean("integration.BentoBox",false)){ + if (Bukkit.getPluginManager().getPlugin("BentoBox") == null) Log.warn("Failed to initialize BentoBox!"); + else {antiGriefsList.add(new BentoBoxHook());hookMessage("BentoBox");} + } + antiGriefs = antiGriefsList.toArray(new AntiGriefInterface[0]); } @Override @@ -96,6 +148,7 @@ public class IntegrationManager extends Function { this.skillInterface = null; this.itemInterfaces = null; this.mobInterface = null; + this.blockInterface = null; if (this.placeholderManager != null) { this.placeholderManager.unload(); this.placeholderManager = null; @@ -122,11 +175,21 @@ public class IntegrationManager extends Function { return mobInterface; } + @NotNull + public BlockInterface getBlockInterface() { + return blockInterface; + } + @Nullable public PlaceholderManager getPlaceholderManager() { return placeholderManager; } + @NotNull + public AntiGriefInterface[] getAntiGriefs() { + return antiGriefs; + } + @NotNull public ItemStack build(String key) { for (ItemInterface itemInterface : itemInterfaces) { diff --git a/src/main/java/net/momirealms/customfishing/manager/LayoutManager.java b/src/main/java/net/momirealms/customfishing/manager/LayoutManager.java index ffee5350..ed899287 100644 --- a/src/main/java/net/momirealms/customfishing/manager/LayoutManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/LayoutManager.java @@ -1,7 +1,7 @@ package net.momirealms.customfishing.manager; -import net.momirealms.customfishing.Function; -import net.momirealms.customfishing.object.Layout; +import net.momirealms.customfishing.object.Function; +import net.momirealms.customfishing.object.fishing.Layout; import net.momirealms.customfishing.util.AdventureUtil; import net.momirealms.customfishing.util.ConfigUtil; import org.bukkit.configuration.file.YamlConfiguration; diff --git a/src/main/java/net/momirealms/customfishing/manager/LootManager.java b/src/main/java/net/momirealms/customfishing/manager/LootManager.java index b5221941..de8ebaf8 100644 --- a/src/main/java/net/momirealms/customfishing/manager/LootManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/LootManager.java @@ -1,12 +1,11 @@ package net.momirealms.customfishing.manager; import net.momirealms.customfishing.CustomFishing; -import net.momirealms.customfishing.Function; -import net.momirealms.customfishing.object.*; +import net.momirealms.customfishing.object.Function; import net.momirealms.customfishing.object.action.*; -import net.momirealms.customfishing.object.loot.DroppedItem; -import net.momirealms.customfishing.object.loot.Loot; -import net.momirealms.customfishing.object.loot.Mob; +import net.momirealms.customfishing.object.fishing.Difficulty; +import net.momirealms.customfishing.object.fishing.Layout; +import net.momirealms.customfishing.object.loot.*; import net.momirealms.customfishing.object.requirements.*; import net.momirealms.customfishing.util.AdventureUtil; import net.momirealms.customfishing.util.ItemStackUtil; diff --git a/src/main/java/net/momirealms/customfishing/manager/TotemManager.java b/src/main/java/net/momirealms/customfishing/manager/TotemManager.java index a96f9c90..d6e2c52d 100644 --- a/src/main/java/net/momirealms/customfishing/manager/TotemManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/TotemManager.java @@ -1,9 +1,486 @@ package net.momirealms.customfishing.manager; +import net.momirealms.customfishing.integration.BlockInterface; +import net.momirealms.customfishing.object.Function; +import net.momirealms.customfishing.object.action.ActionInterface; +import net.momirealms.customfishing.object.action.CommandActionImpl; +import net.momirealms.customfishing.object.action.MessageActionImpl; +import net.momirealms.customfishing.object.requirements.*; +import net.momirealms.customfishing.object.totem.CorePos; +import net.momirealms.customfishing.object.totem.FinalModel; +import net.momirealms.customfishing.object.totem.OriginalModel; +import net.momirealms.customfishing.object.totem.Totem; +import net.momirealms.customfishing.util.AdventureUtil; +import net.momirealms.customfishing.util.ConfigUtil; +import org.apache.commons.lang.StringUtils; +import org.bukkit.Location; +import org.bukkit.Particle; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.util.Objects; -public class TotemManager { +public class TotemManager extends Function { - public static HashMap TOTEMS; + public static HashMap TOTEMS; + public static HashMap> CORES; + public static HashMap BLOCKS; + public static HashMap INVERTED; + private final BlockInterface blockInterface; + public TotemManager(BlockInterface blockInterface) { + this.blockInterface = blockInterface; + } + + @Override + public void unload() { + if (TOTEMS != null) TOTEMS.clear(); + if (CORES != null) CORES.clear(); + if (BLOCKS != null) BLOCKS.clear(); + if (INVERTED != null) INVERTED.clear(); + } + + @Override + public void load(){ + + TOTEMS = new HashMap<>(); + CORES = new HashMap<>(); + BLOCKS = new HashMap<>(); + INVERTED = new HashMap<>(); + + YamlConfiguration config = ConfigUtil.getConfig("totems.yml"); + for (String key : config.getKeys(false)) { + List cores = config.getStringList(key + ".core"); + List flat = config.getStringList(key + ".layer.1"); + int length = flat.get(0).split("\\s+").length; + int width = flat.size(); + int height = Objects.requireNonNull(config.getConfigurationSection(key + ".layer")).getKeys(false).size(); + CorePos corePos = null; + OriginalModel originalModel = new OriginalModel(length, width, height); + FinalModel finalModel = new FinalModel(length, width, height); + for (int k = 0; k < height; k++) { + List layer = config.getStringList(key + ".layer." + (k+1)); + if (layer.size() != width) { + AdventureUtil.consoleMessage("[CustomFishing] Each layer should have the same size! Error exists in totem:" + key + " layer:" + (k + 1)); + return; + } + for (int j = 0; j < width; j++) { + String[] args = layer.get(j).split("\\s+"); + if (args.length != length) { + AdventureUtil.consoleMessage("[CustomFishing] Each layer should have the same size! Error exists in totem:" + key + " layer:" + (k + 1) + " line:" + (k + 1)); + return; + } + for (int i = 0; i < length; i++) { + if (args[i].startsWith("(") && args[i].endsWith(")")){ + String content = args[i].substring(1, args[i].length()-1); + corePos = getCorePos(cores, corePos, originalModel, k, j, i, content); + finalModel.setElement("*", i, j, k); + } + else if (args[i].contains(">")) { + String before = StringUtils.split(args[i],">")[0]; + String after = StringUtils.split(args[i],">")[1]; + finalModel.setElement(after, i, j, k); + corePos = getCorePos(cores, corePos, originalModel, k, j, i, before); + } + else { + String[] elements = StringUtils.split(args[i], "|"); + originalModel.setElement(elements, i, j, k); + for (String core : cores) { + for (String element : elements) { + if (element.equals(core)) { + corePos = new CorePos(i, j, k); + } + } + } + } + } + } + } + if(corePos == null) { + AdventureUtil.consoleMessage("[CustomTotems] No core block set for totem:" + key); + return; + } + else { + finalModel.setCorePos(corePos); + originalModel.setCorePos(corePos); + } + + Totem totem = new Totem( + originalModel, + finalModel, + config.getBoolean(key + ".require-item", false), + config.getBoolean(key + ".consume-item", false), + config.getInt(key + ".radius", 16), + config.getInt(key + ".duration", 300), + Particle.valueOf(config.getString(key + ".particle", "SPELL").toUpperCase()), + BonusManager.getBonus(config, key) + ); + + List actionList = new ArrayList<>(); + List nearActionList = new ArrayList<>(); + if (config.contains(key + ".action")) { + for (String action : config.getConfigurationSection(key + ".action").getKeys(false)) { + switch (action) { + case "commands-activator" -> actionList.add(new CommandActionImpl(config.getStringList(key + ".action." + action).toArray(new String[0]), null)); + case "commands-nearby-players" -> nearActionList.add(new CommandActionImpl(config.getStringList(key + ".action." + action).toArray(new String[0]), null)); + case "messages-activator" -> actionList.add(new MessageActionImpl(config.getStringList(key + ".action." + action).toArray(new String[0]), null)); + case "messages-nearby-players" -> nearActionList.add(new MessageActionImpl(config.getStringList(key + ".action." + action).toArray(new String[0]), null)); + } + } + } + totem.setActivatorActions(actionList.toArray(new ActionInterface[0])); + totem.setNearbyActions(nearActionList.toArray(new ActionInterface[0])); + + if (config.contains(key + ".requirements")) { + List requirements = new ArrayList<>(); + config.getConfigurationSection(key + ".requirements").getKeys(false).forEach(requirement -> { + switch (requirement){ + case "weather" -> requirements.add(new WeatherImpl(config.getStringList(key + ".requirements.weather"))); + case "ypos" -> requirements.add(new YPosImpl(config.getStringList(key + ".requirements.ypos"))); + case "season" -> requirements.add(new SeasonImpl(config.getStringList(key + ".requirements.season"))); + case "world" -> requirements.add(new WorldImpl(config.getStringList(key + ".requirements.world"))); + case "biome" -> requirements.add(new BiomeImpl(config.getStringList(key + ".requirements.biome"))); + case "permission" -> requirements.add(new PermissionImpl(config.getString(key + ".requirements.permission"))); + case "time" -> requirements.add(new TimeImpl(config.getStringList(key + ".requirements.time"))); + case "skill-level" -> requirements.add(new SkillLevelImpl(config.getInt(key + ".requirements.skill-level"))); + case "papi-condition" -> requirements.add(new CustomPapi(config.getConfigurationSection(key + ".requirements.papi-condition").getValues(false))); + } + }); + totem.setRequirements(requirements.toArray(new RequirementInterface[0])); + } + + TOTEMS.put(key, totem); + + for (String core : cores) { + if (CORES.get(core) == null){ + List totems = new ArrayList<>(); + totems.add(totem); + CORES.put(core, totems); + } + else { + CORES.get(core).add(totem); + } + } + } + AdventureUtil.consoleMessage("[CustomFishing] Loaded " + TOTEMS.size() + " totems"); + } + + private CorePos getCorePos(List cores, CorePos corePos, OriginalModel originalModel, int k, int j, int i, String content) { + String[] elements = StringUtils.split(content, "|"); + originalModel.setElement(elements, i, j, k); + for (String core : cores) { + for (String element : elements) { + if (element.equals(core)) { + corePos = new CorePos(i, j, k); + } + } + } + return corePos; + } + + public int checkLocationModel(OriginalModel model, Location location){ + + CorePos corePos = model.getCorePos(); + int xOffset = corePos.getX(); + int yOffset = corePos.getY(); + int zOffset = corePos.getZ(); + + int height = model.getHeight(); + int length = model.getLength(); + int width = model.getWidth(); + + Location startLoc = location.clone().subtract(0, yOffset, 0); + + Label_1: + { + for(int i = 0; i< height; i++) { + Location loc = startLoc.clone().add(-xOffset, i, -zOffset); + for (int z = 0; z < width; z++) { + inner: for (int x = 0; x < length; x++) { + String[] elements = model.getElement(x, z, i); + String id = blockInterface.getID(loc.clone().add(x, 0, z).getBlock()); + for (String element : elements) { + if (element.equals("*")) continue inner; + if (id == null) break; + if (id.equals(element)) continue inner; + } + break Label_1; + } + } + } + return 1; + } + + Label_2: + { + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(xOffset, i, zOffset); + for (int z = 0; z < width; z++) { + inner: for (int x = 0; x < length; x++) { + String[] elements = model.getElement(x, z, i); + String id = blockInterface.getID(loc.clone().add(-x, 0, -z).getBlock()); + for (String element : elements) { + if (element.equals("*")) continue inner; + if (id == null) break; + if (id.equals(element)) continue inner; + } + break Label_2; + } + } + } + return 2; + } + + Label_3: + { + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(-zOffset, i, xOffset); + for (int z = 0; z < width; z++) { + inner: for (int x = 0; x < length; x++) { + String[] elements = model.getElement(x, z, i); + String id = blockInterface.getID(loc.clone().add(z, 0, -x).getBlock()); + for (String element : elements) { + if (element.equals("*")) continue inner; + if (id == null) break; + if (id.equals(element)) continue inner; + } + break Label_3; + } + } + } + return 3; + } + + Label_4: + { + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(zOffset, i, -xOffset); + for (int z = 0; z < width; z++) { + inner: for (int x = 0; x < length; x++) { + String[] elements = model.getElement(x, z, i); + String id = blockInterface.getID(loc.clone().add(-z, 0, x).getBlock()); + for (String element : elements) { + if (element.equals("*")) continue inner; + if (id == null) break; + if (id.equals(element)) continue inner; + } + break Label_4; + } + } + } + return 4; + } + + Label_5: + { + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(-zOffset, i, -xOffset); + for (int z = 0; z < width; z++) { + inner: for (int x = 0; x < length; x++) { + String[] elements = model.getElement(x, z, i); + String id = blockInterface.getID(loc.clone().add(z, 0, x).getBlock()); + for (String element : elements) { + if (element.equals("*")) continue inner; + if (id == null) break; + if (id.equals(element)) continue inner; + } + break Label_5; + } + } + } + return 5; + } + + Label_6: + { + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(zOffset, i, xOffset); + for (int z = 0; z < width; z++) { + inner: for (int x = 0; x < length; x++) { + String[] elements = model.getElement(x, z, i); + String id = blockInterface.getID(loc.clone().add(-z, 0, -x).getBlock()); + for (String element : elements) { + if (element.equals("*")) continue inner; + if (id == null) break; + if (id.equals(element)) continue inner; + } + break Label_6; + } + } + } + return 6; + } + + Label_7: + { + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(-xOffset, i, zOffset); + for (int z = 0; z < width; z++) { + inner: for (int x = 0; x < length; x++) { + String[] elements = model.getElement(x, z, i); + String id = blockInterface.getID(loc.clone().add(x, 0, -z).getBlock()); + for (String element : elements) { + if (element.equals("*")) continue inner; + if (id == null) break; + if (id.equals(element)) continue inner; + } + break Label_7; + } + } + } + return 7; + } + Label_8: + { + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(xOffset, i, -zOffset); + for (int z = 0; z < width; z++) { + inner: for (int x = 0; x < length; x++) { + String[] elements = model.getElement(x, z, i); + String id = blockInterface.getID(loc.clone().add(-x, 0, z).getBlock()); + for (String element : elements) { + if (element.equals("*")) continue inner; + if (id == null) break; + if (id.equals(element)) continue inner; + } + break Label_8; + } + } + } + return 8; + } + return 0; + } + + + public void removeModel(FinalModel model, Location location, int id) { + + CorePos corePos = model.getCorePos(); + int xOffset = corePos.getX(); + int yOffset = corePos.getY(); + int zOffset = corePos.getZ(); + + int height = model.getHeight(); + int length = model.getLength(); + int width = model.getWidth(); + + Location startLoc = location.clone().subtract(0, yOffset, 0); + + switch (id) { + case 1: + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(-xOffset, i, -zOffset); + for (int z = 0; z < width; z++) + for (int x = 0; x < length; x++) { + if (model.getElement(x, z, i) == null) { + blockInterface.removeBlock(loc.clone().add(x, 0, z).getBlock()); + } + else if (!model.getElement(x, z, i).equals("*")){ + blockInterface.replaceBlock(loc.clone().add(x, 0, z), model.getElement(x, z, i)); + } + } + } + break; + case 2: + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(xOffset, i, zOffset); + for (int z = 0; z < width; z++) + for (int x = 0; x < length; x++) { + if (model.getElement(x, z, i) == null) { + blockInterface.removeBlock(loc.clone().add(-x, 0, -z).getBlock()); + } + else if (!model.getElement(x, z, i).equals("*")){ + blockInterface.replaceBlock(loc.clone().add(-x, 0, -z), model.getElement(x, z, i)); + } + } + } + break; + case 3: + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(-zOffset, i, xOffset); + for (int z = 0; z < width; z++) + for (int x = 0; x < length; x++) { + if (model.getElement(x, z, i) == null) { + blockInterface.removeBlock(loc.clone().add(z, 0, -x).getBlock()); + } + else if (!model.getElement(x, z, i).equals("*")){ + blockInterface.replaceBlock(loc.clone().add(z, 0, -x), model.getElement(x, z, i)); + } + } + } + break; + case 4: + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(zOffset, i, -xOffset); + for (int z = 0; z < width; z++) + for (int x = 0; x < length; x++) { + if (model.getElement(x, z, i) == null) { + blockInterface.removeBlock(loc.clone().add(-z, 0, x).getBlock()); + } + else if (!model.getElement(x, z, i).equals("*")){ + blockInterface.replaceBlock(loc.clone().add(-z, 0, x), model.getElement(x, z, i)); + } + } + } + break; + case 5: + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(-zOffset, i, -xOffset); + for (int z = 0; z < width; z++) + for (int x = 0; x < length; x++) { + if (model.getElement(x, z, i) == null) { + blockInterface.removeBlock(loc.clone().add(z, 0, x).getBlock()); + } + else if (!model.getElement(x, z, i).equals("*")){ + blockInterface.replaceBlock(loc.clone().add(z, 0, x), model.getElement(x, z, i)); + } + } + } + break; + case 6: + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(zOffset, i, xOffset); + for (int z = 0; z < width; z++) + for (int x = 0; x < length; x++) { + if (model.getElement(x, z, i) == null) { + blockInterface.removeBlock(loc.clone().add(-z, 0, -x).getBlock()); + } + else if (!model.getElement(x, z, i).equals("*")){ + blockInterface.replaceBlock(loc.clone().add(-z, 0, -x), model.getElement(x, z, i)); + } + } + } + break; + case 7: + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(-xOffset, i, zOffset); + for (int z = 0; z < width; z++) + for (int x = 0; x < length; x++) { + if (model.getElement(x, z, i) == null) { + blockInterface.removeBlock(loc.clone().add(x, 0, -z).getBlock()); + } + else if (!model.getElement(x, z, i).equals("*")){ + blockInterface.replaceBlock(loc.clone().add(x, 0, -z), model.getElement(x, z, i)); + } + } + } + break; + case 8: + for (int i = 0; i < height; i++) { + Location loc = startLoc.clone().add(xOffset, i, -zOffset); + for (int z = 0; z < width; z++) + for (int x = 0; x < length; x++) { + if (model.getElement(x, z, i) == null) { + blockInterface.removeBlock(loc.clone().add(-x, 0, z).getBlock()); + } + else if (!model.getElement(x, z, i).equals("*")){ + blockInterface.replaceBlock(loc.clone().add(-x, 0, z), model.getElement(x, z, i)); + } + } + } + break; + } + } } diff --git a/src/main/java/net/momirealms/customfishing/Function.java b/src/main/java/net/momirealms/customfishing/object/Function.java similarity index 61% rename from src/main/java/net/momirealms/customfishing/Function.java rename to src/main/java/net/momirealms/customfishing/object/Function.java index 2f4e6a59..08333e98 100644 --- a/src/main/java/net/momirealms/customfishing/Function.java +++ b/src/main/java/net/momirealms/customfishing/object/Function.java @@ -1,6 +1,7 @@ -package net.momirealms.customfishing; +package net.momirealms.customfishing.object; import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerInteractEvent; public class Function { @@ -19,4 +20,8 @@ public class Function { public void onJoin(Player player) { } + + public void onInteract(PlayerInteractEvent event) { + + } } diff --git a/src/main/java/net/momirealms/customfishing/object/TextCache.java b/src/main/java/net/momirealms/customfishing/object/TextCache.java index 678c0a64..9ec753c2 100644 --- a/src/main/java/net/momirealms/customfishing/object/TextCache.java +++ b/src/main/java/net/momirealms/customfishing/object/TextCache.java @@ -27,21 +27,14 @@ import java.util.List; public class TextCache { - //所属玩家 private final Player owner; - //初始值 - private final String rawValue; - //原始文字加工后的值 private String originalValue; - //最近一次替换值 private String latestValue; - //持有者占位符 private String[] ownerPlaceholders; public TextCache(Player owner, String rawValue) { this.owner = owner; - this.rawValue = rawValue; - analyze(this.rawValue); + analyze(rawValue); } private void analyze(String value) { @@ -56,15 +49,6 @@ public class TextCache { update(); } - public String getRawValue() { - return rawValue; - } - - public String updateAndGet() { - update(); - return getLatestValue(); - } - public String getLatestValue() { return latestValue; } @@ -87,6 +71,7 @@ public class TextCache { } } } + string = string.replace("{rank}", Competition.currentCompetition.getPlayerRank(owner)) .replace("{time}", String.valueOf(Competition.currentCompetition.getRemainingTime())) .replace("{minute}", String.format("%02d", Competition.currentCompetition.getRemainingTime() / 60)) @@ -94,11 +79,11 @@ public class TextCache { .replace("{score}", String.format("%.1f", Competition.currentCompetition.getScore(owner))) .replace("{1st_score}", String.format("%.1f", Competition.currentCompetition.getFirstScore())) .replace("{1st_player}", Competition.currentCompetition.getFirstPlayer()); + if (!latestValue.equals(string)) { latestValue = string; return true; } return false; } - } diff --git a/src/main/java/net/momirealms/customfishing/object/action/ActionInterface.java b/src/main/java/net/momirealms/customfishing/object/action/ActionInterface.java index 327025c6..e0951589 100644 --- a/src/main/java/net/momirealms/customfishing/object/action/ActionInterface.java +++ b/src/main/java/net/momirealms/customfishing/object/action/ActionInterface.java @@ -1,9 +1,10 @@ package net.momirealms.customfishing.object.action; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; public interface ActionInterface { - void doOn(Player player); + void doOn(Player player, @Nullable Player anotherPlayer); } diff --git a/src/main/java/net/momirealms/customfishing/object/action/CommandActionImpl.java b/src/main/java/net/momirealms/customfishing/object/action/CommandActionImpl.java index ef498a75..1b5530a7 100644 --- a/src/main/java/net/momirealms/customfishing/object/action/CommandActionImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/action/CommandActionImpl.java @@ -13,7 +13,7 @@ public record CommandActionImpl(String[] commands, String nick) implements Actio } @Override - public void doOn(Player player) { + public void doOn(Player player, @Nullable Player anotherPlayer) { for (String command : commands) { CustomFishing.plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command.replace("{player}", player.getName()) @@ -22,6 +22,7 @@ public record CommandActionImpl(String[] commands, String nick) implements Actio .replace("{z}", String.valueOf(player.getLocation().getBlockZ())) .replace("{loot}", nick) .replace("{world}", player.getWorld().getName()) + .replace("{activator}", anotherPlayer == null ? "" : anotherPlayer.getName()) ); } } diff --git a/src/main/java/net/momirealms/customfishing/object/action/MessageActionImpl.java b/src/main/java/net/momirealms/customfishing/object/action/MessageActionImpl.java index 34c58880..88ffd246 100644 --- a/src/main/java/net/momirealms/customfishing/object/action/MessageActionImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/action/MessageActionImpl.java @@ -2,6 +2,7 @@ package net.momirealms.customfishing.object.action; import net.momirealms.customfishing.util.AdventureUtil; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; public record MessageActionImpl(String[] messages, String nick) implements ActionInterface { @@ -11,7 +12,7 @@ public record MessageActionImpl(String[] messages, String nick) implements Actio } @Override - public void doOn(Player player) { + public void doOn(Player player, @Nullable Player anotherPlayer) { for (String message : messages) { AdventureUtil.playerMessage(player, message.replace("{player}", player.getName()) @@ -19,7 +20,9 @@ public record MessageActionImpl(String[] messages, String nick) implements Actio .replace("{x}", String.valueOf(player.getLocation().getBlockX())) .replace("{y}", String.valueOf(player.getLocation().getBlockY())) .replace("{z}", String.valueOf(player.getLocation().getBlockZ())) - .replace("{loot}", nick)); + .replace("{loot}", nick) + .replace("{activator}", anotherPlayer == null ? "" : anotherPlayer.getName()) + ); } } } \ No newline at end of file diff --git a/src/main/java/net/momirealms/customfishing/object/action/SkillXPImpl.java b/src/main/java/net/momirealms/customfishing/object/action/SkillXPImpl.java index f3d1db42..9e63bc09 100644 --- a/src/main/java/net/momirealms/customfishing/object/action/SkillXPImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/action/SkillXPImpl.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; public record SkillXPImpl(double amount) implements ActionInterface { @Override - public void doOn(Player player) { + public void doOn(Player player, Player another) { CustomFishing.plugin.getIntegrationManager().getSkillInterface().addXp(player, amount); } } \ No newline at end of file diff --git a/src/main/java/net/momirealms/customfishing/object/action/SoundActionImpl.java b/src/main/java/net/momirealms/customfishing/object/action/SoundActionImpl.java index 4e14e0cf..af19db0a 100644 --- a/src/main/java/net/momirealms/customfishing/object/action/SoundActionImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/action/SoundActionImpl.java @@ -8,7 +8,7 @@ import org.bukkit.entity.Player; public record SoundActionImpl(String sound) implements ActionInterface { @Override - public void doOn(Player player) { + public void doOn(Player player, Player another) { AdventureUtil.playerSound(player, Sound.Source.PLAYER, Key.key(sound), 1, 1); } } diff --git a/src/main/java/net/momirealms/customfishing/object/action/VanillaXPImpl.java b/src/main/java/net/momirealms/customfishing/object/action/VanillaXPImpl.java index 50546ba9..ab99c12c 100644 --- a/src/main/java/net/momirealms/customfishing/object/action/VanillaXPImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/action/VanillaXPImpl.java @@ -8,7 +8,7 @@ import org.bukkit.entity.Player; public record VanillaXPImpl(int amount, boolean mending) implements ActionInterface { @Override - public void doOn(Player player) { + public void doOn(Player player, Player another) { player.giveExp(amount, mending); AdventureUtil.playerSound(player, Sound.Source.PLAYER, Key.key("minecraft:entity.experience_orb.pickup"), 1, 1); } diff --git a/src/main/java/net/momirealms/customfishing/object/Bonus.java b/src/main/java/net/momirealms/customfishing/object/fishing/Bonus.java similarity index 97% rename from src/main/java/net/momirealms/customfishing/object/Bonus.java rename to src/main/java/net/momirealms/customfishing/object/fishing/Bonus.java index 5786086c..d85c0769 100644 --- a/src/main/java/net/momirealms/customfishing/object/Bonus.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/Bonus.java @@ -1,4 +1,4 @@ -package net.momirealms.customfishing.object; +package net.momirealms.customfishing.object.fishing; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/net/momirealms/customfishing/object/Difficulty.java b/src/main/java/net/momirealms/customfishing/object/fishing/Difficulty.java similarity index 94% rename from src/main/java/net/momirealms/customfishing/object/Difficulty.java rename to src/main/java/net/momirealms/customfishing/object/fishing/Difficulty.java index a2becbe0..fbe84b46 100644 --- a/src/main/java/net/momirealms/customfishing/object/Difficulty.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/Difficulty.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package net.momirealms.customfishing.object; +package net.momirealms.customfishing.object.fishing; public record Difficulty(int timer, int speed) { diff --git a/src/main/java/net/momirealms/customfishing/object/FishResult.java b/src/main/java/net/momirealms/customfishing/object/fishing/FishResult.java similarity index 63% rename from src/main/java/net/momirealms/customfishing/object/FishResult.java rename to src/main/java/net/momirealms/customfishing/object/fishing/FishResult.java index aa0a4cbe..9372599b 100644 --- a/src/main/java/net/momirealms/customfishing/object/FishResult.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/FishResult.java @@ -1,4 +1,4 @@ -package net.momirealms.customfishing.object; +package net.momirealms.customfishing.object.fishing; public enum FishResult { diff --git a/src/main/java/net/momirealms/customfishing/object/FishingCondition.java b/src/main/java/net/momirealms/customfishing/object/fishing/FishingCondition.java similarity index 97% rename from src/main/java/net/momirealms/customfishing/object/FishingCondition.java rename to src/main/java/net/momirealms/customfishing/object/fishing/FishingCondition.java index 8111fcab..f058f388 100644 --- a/src/main/java/net/momirealms/customfishing/object/FishingCondition.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/FishingCondition.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package net.momirealms.customfishing.object; +package net.momirealms.customfishing.object.fishing; import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.integration.papi.PlaceholderManager; diff --git a/src/main/java/net/momirealms/customfishing/object/FishingPlayer.java b/src/main/java/net/momirealms/customfishing/object/fishing/FishingPlayer.java similarity index 98% rename from src/main/java/net/momirealms/customfishing/object/FishingPlayer.java rename to src/main/java/net/momirealms/customfishing/object/fishing/FishingPlayer.java index ec991d99..30d59e4d 100644 --- a/src/main/java/net/momirealms/customfishing/object/FishingPlayer.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/FishingPlayer.java @@ -1,4 +1,4 @@ -package net.momirealms.customfishing.object; +package net.momirealms.customfishing.object.fishing; import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.manager.FishingManager; diff --git a/src/main/java/net/momirealms/customfishing/object/Layout.java b/src/main/java/net/momirealms/customfishing/object/fishing/Layout.java similarity index 97% rename from src/main/java/net/momirealms/customfishing/object/Layout.java rename to src/main/java/net/momirealms/customfishing/object/fishing/Layout.java index 47346c4f..e4221355 100644 --- a/src/main/java/net/momirealms/customfishing/object/Layout.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/Layout.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package net.momirealms.customfishing.object; +package net.momirealms.customfishing.object.fishing; public class Layout { diff --git a/src/main/java/net/momirealms/customfishing/object/Modifier.java b/src/main/java/net/momirealms/customfishing/object/fishing/Modifier.java similarity index 95% rename from src/main/java/net/momirealms/customfishing/object/Modifier.java rename to src/main/java/net/momirealms/customfishing/object/fishing/Modifier.java index a1af59c0..a5d8cc61 100644 --- a/src/main/java/net/momirealms/customfishing/object/Modifier.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/Modifier.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package net.momirealms.customfishing.object; +package net.momirealms.customfishing.object.fishing; public class Modifier { diff --git a/src/main/java/net/momirealms/customfishing/object/VanillaLoot.java b/src/main/java/net/momirealms/customfishing/object/fishing/VanillaLoot.java similarity index 87% rename from src/main/java/net/momirealms/customfishing/object/VanillaLoot.java rename to src/main/java/net/momirealms/customfishing/object/fishing/VanillaLoot.java index d969b7fe..bb4a95ed 100644 --- a/src/main/java/net/momirealms/customfishing/object/VanillaLoot.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/VanillaLoot.java @@ -1,4 +1,4 @@ -package net.momirealms.customfishing.object; +package net.momirealms.customfishing.object.fishing; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/net/momirealms/customfishing/object/loot/DroppedItem.java b/src/main/java/net/momirealms/customfishing/object/loot/DroppedItem.java index 160173d6..a6767f48 100644 --- a/src/main/java/net/momirealms/customfishing/object/loot/DroppedItem.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/DroppedItem.java @@ -1,7 +1,6 @@ package net.momirealms.customfishing.object.loot; -import net.momirealms.customfishing.object.Difficulty; -import net.momirealms.customfishing.object.LeveledEnchantment; +import net.momirealms.customfishing.object.fishing.Difficulty; import org.jetbrains.annotations.Nullable; public class DroppedItem extends Loot{ diff --git a/src/main/java/net/momirealms/customfishing/object/Item.java b/src/main/java/net/momirealms/customfishing/object/loot/Item.java similarity index 97% rename from src/main/java/net/momirealms/customfishing/object/Item.java rename to src/main/java/net/momirealms/customfishing/object/loot/Item.java index e9a834a7..fdbddea3 100644 --- a/src/main/java/net/momirealms/customfishing/object/Item.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/Item.java @@ -1,4 +1,4 @@ -package net.momirealms.customfishing.object; +package net.momirealms.customfishing.object.loot; import org.bukkit.Material; import org.bukkit.inventory.ItemFlag; diff --git a/src/main/java/net/momirealms/customfishing/object/LeveledEnchantment.java b/src/main/java/net/momirealms/customfishing/object/loot/LeveledEnchantment.java similarity index 95% rename from src/main/java/net/momirealms/customfishing/object/LeveledEnchantment.java rename to src/main/java/net/momirealms/customfishing/object/loot/LeveledEnchantment.java index 474dc42b..6a2773d5 100644 --- a/src/main/java/net/momirealms/customfishing/object/LeveledEnchantment.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/LeveledEnchantment.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package net.momirealms.customfishing.object; +package net.momirealms.customfishing.object.loot; import org.bukkit.NamespacedKey; diff --git a/src/main/java/net/momirealms/customfishing/object/loot/Loot.java b/src/main/java/net/momirealms/customfishing/object/loot/Loot.java index 154bf186..7b3cc189 100644 --- a/src/main/java/net/momirealms/customfishing/object/loot/Loot.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/Loot.java @@ -1,8 +1,8 @@ package net.momirealms.customfishing.object.loot; -import net.momirealms.customfishing.object.Difficulty; -import net.momirealms.customfishing.object.Layout; import net.momirealms.customfishing.object.action.ActionInterface; +import net.momirealms.customfishing.object.fishing.Difficulty; +import net.momirealms.customfishing.object.fishing.Layout; import net.momirealms.customfishing.object.requirements.RequirementInterface; public class Loot { diff --git a/src/main/java/net/momirealms/customfishing/object/loot/Mob.java b/src/main/java/net/momirealms/customfishing/object/loot/Mob.java index fa9e0703..3be9856a 100644 --- a/src/main/java/net/momirealms/customfishing/object/loot/Mob.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/Mob.java @@ -1,7 +1,6 @@ package net.momirealms.customfishing.object.loot; -import net.momirealms.customfishing.object.Difficulty; -import net.momirealms.customfishing.object.MobVector; +import net.momirealms.customfishing.object.fishing.Difficulty; import org.jetbrains.annotations.NotNull; public class Mob extends Loot{ diff --git a/src/main/java/net/momirealms/customfishing/object/MobVector.java b/src/main/java/net/momirealms/customfishing/object/loot/MobVector.java similarity index 94% rename from src/main/java/net/momirealms/customfishing/object/MobVector.java rename to src/main/java/net/momirealms/customfishing/object/loot/MobVector.java index 0a3675d5..8686d06c 100644 --- a/src/main/java/net/momirealms/customfishing/object/MobVector.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/MobVector.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package net.momirealms.customfishing.object; +package net.momirealms.customfishing.object.loot; public record MobVector(double horizontal, double vertical) { diff --git a/src/main/java/net/momirealms/customfishing/object/requirements/BiomeImpl.java b/src/main/java/net/momirealms/customfishing/object/requirements/BiomeImpl.java index 13022998..24838d82 100644 --- a/src/main/java/net/momirealms/customfishing/object/requirements/BiomeImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/requirements/BiomeImpl.java @@ -17,7 +17,7 @@ package net.momirealms.customfishing.object.requirements; -import net.momirealms.customfishing.object.FishingCondition; +import net.momirealms.customfishing.object.fishing.FishingCondition; import java.util.List; diff --git a/src/main/java/net/momirealms/customfishing/object/requirements/CustomPapi.java b/src/main/java/net/momirealms/customfishing/object/requirements/CustomPapi.java index b7a803e3..02a820c6 100644 --- a/src/main/java/net/momirealms/customfishing/object/requirements/CustomPapi.java +++ b/src/main/java/net/momirealms/customfishing/object/requirements/CustomPapi.java @@ -17,7 +17,7 @@ package net.momirealms.customfishing.object.requirements; -import net.momirealms.customfishing.object.FishingCondition; +import net.momirealms.customfishing.object.fishing.FishingCondition; import net.momirealms.customfishing.object.requirements.papi.*; import org.bukkit.configuration.MemorySection; diff --git a/src/main/java/net/momirealms/customfishing/object/requirements/PermissionImpl.java b/src/main/java/net/momirealms/customfishing/object/requirements/PermissionImpl.java index c2ffd19f..5da0d39e 100644 --- a/src/main/java/net/momirealms/customfishing/object/requirements/PermissionImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/requirements/PermissionImpl.java @@ -17,7 +17,7 @@ package net.momirealms.customfishing.object.requirements; -import net.momirealms.customfishing.object.FishingCondition; +import net.momirealms.customfishing.object.fishing.FishingCondition; public record PermissionImpl(String permission) implements RequirementInterface { diff --git a/src/main/java/net/momirealms/customfishing/object/requirements/RequirementInterface.java b/src/main/java/net/momirealms/customfishing/object/requirements/RequirementInterface.java index c772f3db..92b9f39d 100644 --- a/src/main/java/net/momirealms/customfishing/object/requirements/RequirementInterface.java +++ b/src/main/java/net/momirealms/customfishing/object/requirements/RequirementInterface.java @@ -17,7 +17,7 @@ package net.momirealms.customfishing.object.requirements; -import net.momirealms.customfishing.object.FishingCondition; +import net.momirealms.customfishing.object.fishing.FishingCondition; public interface RequirementInterface { boolean isConditionMet(FishingCondition fishingCondition); diff --git a/src/main/java/net/momirealms/customfishing/object/requirements/SeasonImpl.java b/src/main/java/net/momirealms/customfishing/object/requirements/SeasonImpl.java index 53cbe59b..b336b80d 100644 --- a/src/main/java/net/momirealms/customfishing/object/requirements/SeasonImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/requirements/SeasonImpl.java @@ -19,7 +19,7 @@ package net.momirealms.customfishing.object.requirements; import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.integration.SeasonInterface; -import net.momirealms.customfishing.object.FishingCondition; +import net.momirealms.customfishing.object.fishing.FishingCondition; import java.util.List; diff --git a/src/main/java/net/momirealms/customfishing/object/requirements/SkillLevelImpl.java b/src/main/java/net/momirealms/customfishing/object/requirements/SkillLevelImpl.java index 51c5a1ea..40abaa38 100644 --- a/src/main/java/net/momirealms/customfishing/object/requirements/SkillLevelImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/requirements/SkillLevelImpl.java @@ -1,7 +1,7 @@ package net.momirealms.customfishing.object.requirements; import net.momirealms.customfishing.CustomFishing; -import net.momirealms.customfishing.object.FishingCondition; +import net.momirealms.customfishing.object.fishing.FishingCondition; public record SkillLevelImpl(int level) implements RequirementInterface { diff --git a/src/main/java/net/momirealms/customfishing/object/requirements/TimeImpl.java b/src/main/java/net/momirealms/customfishing/object/requirements/TimeImpl.java index 926b2c45..276b6205 100644 --- a/src/main/java/net/momirealms/customfishing/object/requirements/TimeImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/requirements/TimeImpl.java @@ -17,7 +17,7 @@ package net.momirealms.customfishing.object.requirements; -import net.momirealms.customfishing.object.FishingCondition; +import net.momirealms.customfishing.object.fishing.FishingCondition; import org.apache.commons.lang.StringUtils; import java.util.List; diff --git a/src/main/java/net/momirealms/customfishing/object/requirements/WeatherImpl.java b/src/main/java/net/momirealms/customfishing/object/requirements/WeatherImpl.java index 1ef62da4..f458442c 100644 --- a/src/main/java/net/momirealms/customfishing/object/requirements/WeatherImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/requirements/WeatherImpl.java @@ -17,7 +17,7 @@ package net.momirealms.customfishing.object.requirements; -import net.momirealms.customfishing.object.FishingCondition; +import net.momirealms.customfishing.object.fishing.FishingCondition; import org.bukkit.World; import java.util.List; diff --git a/src/main/java/net/momirealms/customfishing/object/requirements/WorldImpl.java b/src/main/java/net/momirealms/customfishing/object/requirements/WorldImpl.java index a6731561..4019bbe9 100644 --- a/src/main/java/net/momirealms/customfishing/object/requirements/WorldImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/requirements/WorldImpl.java @@ -17,7 +17,7 @@ package net.momirealms.customfishing.object.requirements; -import net.momirealms.customfishing.object.FishingCondition; +import net.momirealms.customfishing.object.fishing.FishingCondition; import java.util.List; diff --git a/src/main/java/net/momirealms/customfishing/object/requirements/YPosImpl.java b/src/main/java/net/momirealms/customfishing/object/requirements/YPosImpl.java index 0ba79b3c..06578fa0 100644 --- a/src/main/java/net/momirealms/customfishing/object/requirements/YPosImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/requirements/YPosImpl.java @@ -17,7 +17,7 @@ package net.momirealms.customfishing.object.requirements; -import net.momirealms.customfishing.object.FishingCondition; +import net.momirealms.customfishing.object.fishing.FishingCondition; import org.apache.commons.lang.StringUtils; import java.util.List; diff --git a/src/main/java/net/momirealms/customfishing/object/totem/Totem.java b/src/main/java/net/momirealms/customfishing/object/totem/Totem.java index ecf3445e..99f21954 100644 --- a/src/main/java/net/momirealms/customfishing/object/totem/Totem.java +++ b/src/main/java/net/momirealms/customfishing/object/totem/Totem.java @@ -17,35 +17,49 @@ package net.momirealms.customfishing.object.totem; -import java.util.List; +import net.momirealms.customfishing.object.action.ActionInterface; +import net.momirealms.customfishing.object.fishing.Bonus; +import net.momirealms.customfishing.object.requirements.RequirementInterface; +import org.bukkit.Particle; public class Totem { private final OriginalModel originalModel; private FinalModel finalModel; - private List commands; - private List messages; private final boolean cItem; private final boolean rItem; + private RequirementInterface[] requirements; + private final int radius; + private final Particle particle; + private final int duration; + private final Bonus bonus; + private ActionInterface[] activatorActions; + private ActionInterface[] nearbyActions; - public Totem(OriginalModel originalModel, boolean rItem, boolean cItem) { + public Totem(OriginalModel originalModel, FinalModel finalModel, boolean rItem, boolean cItem, int radius, int duration, Particle particle, Bonus bonus) { this.originalModel = originalModel; + this.finalModel = finalModel; + this.radius = radius; + this.duration = duration; + this.particle = particle; + this.bonus = bonus; this.rItem = rItem; if (rItem) this.cItem = cItem; else this.cItem = false; } + public RequirementInterface[] getRequirements() { + return requirements; + } + + public void setRequirements(RequirementInterface[] requirements) { + this.requirements = requirements; + } + public OriginalModel getOriginalModel() { return originalModel; } - public List getMessages() { - return messages; - } - - public void setMessages(List messages) { - this.messages = messages; - } public FinalModel getFinalModel() { return finalModel; @@ -55,19 +69,43 @@ public class Totem { this.finalModel = finalModel; } - public void setCommands(List commands) { - this.commands = commands; - } - public boolean isrItem() { return rItem; } - public List getCommands() { - return commands; - } - public boolean iscItem() { return cItem; } + + public int getRadius() { + return radius; + } + + public Particle getParticle() { + return particle; + } + + public int getDuration() { + return duration; + } + + public Bonus getBonus() { + return bonus; + } + + public ActionInterface[] getActivatorActions() { + return activatorActions; + } + + public void setActivatorActions(ActionInterface[] activatorActions) { + this.activatorActions = activatorActions; + } + + public ActionInterface[] getNearbyActions() { + return nearbyActions; + } + + public void setNearbyActions(ActionInterface[] nearbyActions) { + this.nearbyActions = nearbyActions; + } } diff --git a/src/main/java/net/momirealms/customfishing/util/ConfigUtil.java b/src/main/java/net/momirealms/customfishing/util/ConfigUtil.java index b7f4e9fb..291fea6d 100644 --- a/src/main/java/net/momirealms/customfishing/util/ConfigUtil.java +++ b/src/main/java/net/momirealms/customfishing/util/ConfigUtil.java @@ -10,7 +10,6 @@ import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.helper.Log; import net.momirealms.customfishing.manager.ConfigManager; import net.momirealms.customfishing.manager.MessageManager; -import net.momirealms.customfishing.object.Reflection; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; diff --git a/src/main/java/net/momirealms/customfishing/util/ItemStackUtil.java b/src/main/java/net/momirealms/customfishing/util/ItemStackUtil.java index d534dd04..f2149297 100644 --- a/src/main/java/net/momirealms/customfishing/util/ItemStackUtil.java +++ b/src/main/java/net/momirealms/customfishing/util/ItemStackUtil.java @@ -7,9 +7,9 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.manager.BonusManager; import net.momirealms.customfishing.manager.LootManager; -import net.momirealms.customfishing.object.Item; -import net.momirealms.customfishing.object.LeveledEnchantment; import net.momirealms.customfishing.object.loot.DroppedItem; +import net.momirealms.customfishing.object.loot.Item; +import net.momirealms.customfishing.object.loot.LeveledEnchantment; import net.momirealms.customfishing.object.loot.Loot; import org.bukkit.Material; import org.bukkit.configuration.file.YamlConfiguration; diff --git a/src/main/java/net/momirealms/customfishing/util/JedisUtil.java b/src/main/java/net/momirealms/customfishing/util/JedisUtil.java index ad3a6903..18c65837 100644 --- a/src/main/java/net/momirealms/customfishing/util/JedisUtil.java +++ b/src/main/java/net/momirealms/customfishing/util/JedisUtil.java @@ -23,13 +23,13 @@ public class JedisUtil { jedisPoolConfig.setTestWhileIdle(true); jedisPoolConfig.setTimeBetweenEvictionRunsMillis(30000); jedisPoolConfig.setNumTestsPerEvictionRun(-1); - jedisPoolConfig.setMinEvictableIdleTimeMillis(configuration.getInt("redis.MinEvictableIdleTimeMillis",1800000)); - jedisPoolConfig.setMaxTotal(configuration.getInt("redis.MaxTotal",8)); - jedisPoolConfig.setMaxIdle(configuration.getInt("redis.MaxIdle",8)); - jedisPoolConfig.setMinIdle(configuration.getInt("redis.MinIdle",1)); + jedisPoolConfig.setMinEvictableIdleTimeMillis(configuration.getInt("Redis.MinEvictableIdleTimeMillis",1800000)); + jedisPoolConfig.setMaxTotal(configuration.getInt("Redis.MaxTotal",8)); + jedisPoolConfig.setMaxIdle(configuration.getInt("Redis.MaxIdle",8)); + jedisPoolConfig.setMinIdle(configuration.getInt("Redis.MinIdle",1)); jedisPoolConfig.setMaxWaitMillis(configuration.getInt("redis.MaxWaitMillis",30000)); - jedisPool = new JedisPool(jedisPoolConfig, configuration.getString("redis.host","localhost"), configuration.getInt("redis.port",6379)); + jedisPool = new JedisPool(jedisPoolConfig, configuration.getString("Redis.host","localhost"), configuration.getInt("Redis.port",6379)); AdventureUtil.consoleMessage("[CustomFishing] Redis Server Connected!"); diff --git a/src/main/java/net/momirealms/customfishing/object/Reflection.java b/src/main/java/net/momirealms/customfishing/util/Reflection.java similarity index 95% rename from src/main/java/net/momirealms/customfishing/object/Reflection.java rename to src/main/java/net/momirealms/customfishing/util/Reflection.java index 0622e3b6..20bc277b 100644 --- a/src/main/java/net/momirealms/customfishing/object/Reflection.java +++ b/src/main/java/net/momirealms/customfishing/util/Reflection.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package net.momirealms.customfishing.object; +package net.momirealms.customfishing.util; import java.lang.reflect.Field; diff --git a/src/main/java/net/momirealms/customfishing/util/TotemUtil.java b/src/main/java/net/momirealms/customfishing/util/TotemUtil.java deleted file mode 100644 index 65b70642..00000000 --- a/src/main/java/net/momirealms/customfishing/util/TotemUtil.java +++ /dev/null @@ -1,348 +0,0 @@ -///* -// * Copyright (C) <2022> -// * -// * This program is free software: you can redistribute it and/or modify -// * it under the terms of the GNU General Public License as published by -// * the Free Software Foundation, either version 3 of the License, or -// * any later version. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program. If not, see . -// */ -// -//package net.momirealms.customfishing.util; -// -//import net.momirealms.customfishing.object.totem.CorePos; -//import net.momirealms.customfishing.object.totem.FinalModel; -//import net.momirealms.customfishing.object.totem.OriginalModel; -//import org.bukkit.Location; -// -//public class TotemUtil { -// -// public static int checkLocationModel(OriginalModel model, Location location){ -// -// CorePos corePos = model.getCorePos(); -// int xOffset = corePos.getX(); -// int yOffset = corePos.getY(); -// int zOffset = corePos.getZ(); -// -// int height = model.getHeight(); -// int length = model.getLength(); -// int width = model.getWidth(); -// -// //从第一层开始逐层扫描,只有一层满足要求才能扫描上一层,否则跳入下一个方向检测 -// Location startLoc = location.clone().subtract(0, yOffset, 0); -// -// Label_1: -// { -// for(int i = 0; i< height; i++) { -// //起点定于左下角,向右上遍历 -// Location loc = startLoc.clone().add(-xOffset, i, -zOffset); -// for (int z = 0; z < width; z++) { -// inner: for (int x = 0; x < length; x++) { -// String[] elements = model.getElement(x, z, i); -// String id = BlockUtil.getId(loc.clone().add(x, 0, z)); -// for (String element : elements) { -// if (element.equals("*")) continue inner; -// if (id == null) break; -// if (id.equals(element)) continue inner; -// } -// break Label_1; -// } -// } -// } -// return 1; -// } -// -// Label_2: -// { -// for (int i = 0; i < height; i++) { -// //起点定于右上角,向左下遍历 -// Location loc = startLoc.clone().add(xOffset, i, zOffset); -// for (int z = 0; z < width; z++) { -// inner: for (int x = 0; x < length; x++) { -// String[] elements = model.getElement(x, z, i); -// String id = BlockUtil.getId(loc.clone().add(-x, 0, -z)); -// for (String element : elements) { -// if (element.equals("*")) continue inner; -// if (id == null) break; -// if (id.equals(element)) continue inner; -// } -// break Label_2; -// } -// } -// } -// return 2; -// } -// -// Label_3: -// { -// for (int i = 0; i < height; i++) { -// //起点定于左上角,向右下遍历 -// Location loc = startLoc.clone().add(-zOffset, i, xOffset); -// for (int z = 0; z < width; z++) { -// inner: for (int x = 0; x < length; x++) { -// String[] elements = model.getElement(x, z, i); -// String id = BlockUtil.getId(loc.clone().add(z, 0, -x)); -// for (String element : elements) { -// if (element.equals("*")) continue inner; -// if (id == null) break; -// if (id.equals(element)) continue inner; -// } -// break Label_3; -// } -// } -// } -// return 3; -// } -// -// Label_4: -// { -// for (int i = 0; i < height; i++) { -// //起点定于右下角,向左上遍历 -// Location loc = startLoc.clone().add(zOffset, i, -xOffset); -// for (int z = 0; z < width; z++) { -// inner: for (int x = 0; x < length; x++) { -// String[] elements = model.getElement(x, z, i); -// String id = BlockUtil.getId(loc.clone().add(-z, 0, x)); -// for (String element : elements) { -// if (element.equals("*")) continue inner; -// if (id == null) break; -// if (id.equals(element)) continue inner; -// } -// break Label_4; -// } -// } -// } -// return 4; -// } -// -// Label_5: -// { -// for (int i = 0; i < height; i++) { -// //起点定于左下角(镜像),向上左遍历 -// Location loc = startLoc.clone().add(-zOffset, i, -xOffset); -// for (int z = 0; z < width; z++) { -// inner: for (int x = 0; x < length; x++) { -// String[] elements = model.getElement(x, z, i); -// String id = BlockUtil.getId(loc.clone().add(z, 0, x)); -// for (String element : elements) { -// if (element.equals("*")) continue inner; -// if (id == null) break; -// if (id.equals(element)) continue inner; -// } -// break Label_5; -// } -// } -// } -// return 5; -// } -// -// Label_6: -// { -// for (int i = 0; i < height; i++) { -// //起点定于右上角(镜像),向下左遍历 -// Location loc = startLoc.clone().add(zOffset, i, xOffset); -// for (int z = 0; z < width; z++) { -// inner: for (int x = 0; x < length; x++) { -// String[] elements = model.getElement(x, z, i); -// String id = BlockUtil.getId(loc.clone().add(-z, 0, -x)); -// for (String element : elements) { -// if (element.equals("*")) continue inner; -// if (id == null) break; -// if (id.equals(element)) continue inner; -// } -// break Label_6; -// } -// } -// } -// return 6; -// } -// -// Label_7: -// { -// for (int i = 0; i < height; i++) { -// //起点定于左上角(镜像),向右下遍历 -// Location loc = startLoc.clone().add(-xOffset, i, zOffset); -// for (int z = 0; z < width; z++) { -// inner: for (int x = 0; x < length; x++) { -// String[] elements = model.getElement(x, z, i); -// String id = BlockUtil.getId(loc.clone().add(x, 0, -z)); -// for (String element : elements) { -// if (element.equals("*")) continue inner; -// if (id == null) break; -// if (id.equals(element)) continue inner; -// } -// break Label_7; -// } -// } -// } -// return 7; -// } -// Label_8: -// { -// for (int i = 0; i < height; i++) { -// //起点定于右下角(镜像),向左上遍历 -// Location loc = startLoc.clone().add(xOffset, i, -zOffset); -// for (int z = 0; z < width; z++) { -// inner: for (int x = 0; x < length; x++) { -// String[] elements = model.getElement(x, z, i); -// String id = BlockUtil.getId(loc.clone().add(-x, 0, z)); -// for (String element : elements) { -// if (element.equals("*")) continue inner; -// if (id == null) break; -// if (id.equals(element)) continue inner; -// } -// break Label_8; -// } -// } -// } -// return 8; -// } -// return 0; -// } -// -// -// public static void removeModel(FinalModel model, Location location, int id) { -// -// CorePos corePos = model.getCorePos(); -// int xOffset = corePos.getX(); -// int yOffset = corePos.getY(); -// int zOffset = corePos.getZ(); -// -// int height = model.getHeight(); -// int length = model.getLength(); -// int width = model.getWidth(); -// -// //从第一层开始逐层扫描,只有一层满足要求才能扫描上一层,否则跳入下一个方向检测 -// Location startLoc = location.clone().subtract(0, yOffset, 0); -// -// switch (id) { -// case 1: -// for (int i = 0; i < height; i++) { -// //起点定于左下角,向右上遍历 -// Location loc = startLoc.clone().add(-xOffset, i, -zOffset); -// for (int z = 0; z < width; z++) -// for (int x = 0; x < length; x++) { -// if (model.getElement(x, z, i) == null) { -// BlockUtil.remove(loc.clone().add(x, 0, z)); -// } -// else if (!model.getElement(x, z, i).equals("*")){ -// BlockUtil.replace(loc.clone().add(x, 0, z), model.getElement(x, z, i)); -// } -// } -// } -// break; -// case 2: -// for (int i = 0; i < height; i++) { -// //起点定于右上角,向左下遍历 -// Location loc = startLoc.clone().add(xOffset, i, zOffset); -// for (int z = 0; z < width; z++) -// for (int x = 0; x < length; x++) { -// if (model.getElement(x, z, i) == null) { -// BlockUtil.remove(loc.clone().add(-x, 0, -z)); -// } -// else if (!model.getElement(x, z, i).equals("*")){ -// BlockUtil.replace(loc.clone().add(-x, 0, -z), model.getElement(x, z, i)); -// } -// } -// } -// break; -// case 3: -// for (int i = 0; i < height; i++) { -// //起点定于左上角,向右下遍历 -// Location loc = startLoc.clone().add(-zOffset, i, xOffset); -// for (int z = 0; z < width; z++) -// for (int x = 0; x < length; x++) { -// if (model.getElement(x, z, i) == null) { -// BlockUtil.remove(loc.clone().add(z, 0, -x)); -// } -// else if (!model.getElement(x, z, i).equals("*")){ -// BlockUtil.replace(loc.clone().add(z, 0, -x), model.getElement(x, z, i)); -// } -// } -// } -// break; -// case 4: -// for (int i = 0; i < height; i++) { -// //起点定于右下角,向左上遍历 -// Location loc = startLoc.clone().add(zOffset, i, -xOffset); -// for (int z = 0; z < width; z++) -// for (int x = 0; x < length; x++) { -// if (model.getElement(x, z, i) == null) { -// BlockUtil.remove(loc.clone().add(-z, 0, x)); -// } -// else if (!model.getElement(x, z, i).equals("*")){ -// BlockUtil.replace(loc.clone().add(-z, 0, x), model.getElement(x, z, i)); -// } -// } -// } -// break; -// case 5: -// for (int i = 0; i < height; i++) { -// //起点定于左下角(镜像),向上左遍历 -// Location loc = startLoc.clone().add(-zOffset, i, -xOffset); -// for (int z = 0; z < width; z++) -// for (int x = 0; x < length; x++) { -// if (model.getElement(x, z, i) == null) { -// BlockUtil.remove(loc.clone().add(z, 0, x)); -// } -// else if (!model.getElement(x, z, i).equals("*")){ -// BlockUtil.replace(loc.clone().add(z, 0, x), model.getElement(x, z, i)); -// } -// } -// } -// break; -// case 6: -// for (int i = 0; i < height; i++) { -// //起点定于右上角(镜像),向下左遍历 -// Location loc = startLoc.clone().add(zOffset, i, xOffset); -// for (int z = 0; z < width; z++) -// for (int x = 0; x < length; x++) { -// if (model.getElement(x, z, i) == null) { -// BlockUtil.remove(loc.clone().add(-z, 0, -x)); -// } -// else if (!model.getElement(x, z, i).equals("*")){ -// BlockUtil.replace(loc.clone().add(-z, 0, -x), model.getElement(x, z, i)); -// } -// } -// } -// break; -// case 7: -// for (int i = 0; i < height; i++) { -// //起点定于左上角(镜像),向右下遍历 -// Location loc = startLoc.clone().add(-xOffset, i, zOffset); -// for (int z = 0; z < width; z++) -// for (int x = 0; x < length; x++) { -// if (model.getElement(x, z, i) == null) { -// BlockUtil.remove(loc.clone().add(x, 0, -z)); -// } -// else if (!model.getElement(x, z, i).equals("*")){ -// BlockUtil.replace(loc.clone().add(x, 0, -z), model.getElement(x, z, i)); -// } -// } -// } -// break; -// case 8: -// for (int i = 0; i < height; i++) { -// //起点定于右下角(镜像),向左上遍历 -// Location loc = startLoc.clone().add(xOffset, i, -zOffset); -// for (int z = 0; z < width; z++) -// for (int x = 0; x < length; x++) { -// if (model.getElement(x, z, i) == null) { -// BlockUtil.remove(loc.clone().add(-x, 0, z)); -// } -// else if (!model.getElement(x, z, i).equals("*")){ -// BlockUtil.replace(loc.clone().add(-x, 0, z), model.getElement(x, z, i)); -// } -// } -// } -// break; -// } -// } -//} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 582de3fb..45c806fb 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -63,7 +63,17 @@ mechanics: fishfinder-cooldown: 3000 # Competition - fishing-competition: true + fishing-competition: + enable: true + redis: false + + # Fishing bag is a place where players can store their baits, utils, rods (Fish optional) + fishing-bag: + enable: true + # This would add additional NBT Tags to the fish + can-store-fish: false + # File/SQLite/MySql + data-storage-mode: File titles: diff --git a/src/main/resources/database.yml b/src/main/resources/database.yml index 8dac85be..e249c41f 100644 --- a/src/main/resources/database.yml +++ b/src/main/resources/database.yml @@ -1,13 +1,3 @@ -# Do not change -config-version: '1' - -settings: - # Valid Options: SQLite MYSQL - # Only MYSQL supports pool. - storage-mode: SQLite - use-pool: false - disable-async: false - # MySQL settings MySQL: host: localhost @@ -15,16 +5,39 @@ MySQL: user: root password: password database: minecraft - table-name: nameplates_data + table-name: customfishing_data property: use-ssl: false encoding: utf8 timezone: '' allowPublicKeyRetrieval: false + # Connection pool settings + Pool-Settings: + enable: false + maximum-pool-size: 10 + minimum-idle: 10 + maximum-lifetime: 180000 + idle-timeout: 60000 -# Connection pool settings -Pool-Settings: - maximum-pool-size: 10 - minimum-idle: 10 - maximum-lifetime: 180000 - idle-timeout: 60000 \ No newline at end of file +# SQLite settings +SQLite: + file-name: data + table: npc + +# MongoDB settings +MongoDB: + client: 'mongodb://localhost:3307' + database: customfishing + collection: customfishing.statistics + +# Redis server +# Sync competition scores between servers without lag! +Redis: + enable: false + host: localhost + port: 6379 + MaxTotal: 10 + MaxIdle: 10 + MinIdle: 1 + MaxWaitMillis: 30000 + MinEvictableIdleTimeMillis: 1800000 \ No newline at end of file diff --git a/src/main/resources/redis.yml b/src/main/resources/redis.yml deleted file mode 100644 index 93dcd923..00000000 --- a/src/main/resources/redis.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Redis server -# Sync competition scores between servers without lag! -redis: - enable: false - host: localhost - port: 6379 - MaxTotal: 10 - MaxIdle: 10 - MinIdle: 1 - MaxWaitMillis: 30000 - MinEvictableIdleTimeMillis: 1800000 \ No newline at end of file diff --git a/src/main/resources/totems.yml b/src/main/resources/totems.yml index af622f24..153b6639 100644 --- a/src/main/resources/totems.yml +++ b/src/main/resources/totems.yml @@ -22,19 +22,17 @@ primary_fishing_totem: silver: -20 gold: 20 - # placeholders: {activator} {players_in_radius} {all_players} - # {world} {x} {y} {z} - commands: - - 'effect give {player_in_radius} ' + # placeholders: {player} {world} {x} {y} {z} + action: + commands-activator: + - '' + messages-activator: + - '' + commands-nearby-players: + - '' + messages-nearby-players: + - '' - messages: - activator: - - You activated a totem - players_in_radius: - - You are now in {activator}'s totem - - Your chance of getting gold fish is temporarily up - all_players: - - {activator} activated a totem at {world},{x},{y},{z} # The layout of the totem # The greater the layer is, the higher the y position is