From 6d3eaf682cfcaec3a2380ce2e411264b16909c37 Mon Sep 17 00:00:00 2001 From: Xiao-MoMi <70987828+Xiao-MoMi@users.noreply.github.com> Date: Fri, 21 Oct 2022 17:07:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customfishing/CustomFishing.java | 5 +- .../customfishing/api/CustomFishingAPI.java | 17 +++ .../api/event/FishFinderEvent.java | 17 +++ .../api/event/FishHookEvent.java | 17 +++ .../api/event/FishResultEvent.java | 17 +++ .../customfishing/api/event/RodCastEvent.java | 17 +++ .../api/event/TotemActivationEvent.java | 17 +++ .../commands/FishingBagCommand.java | 17 +++ .../commands/SellFishCommand.java | 17 +++ .../commands/subcmd/BaitCommand.java | 17 +++ .../commands/subcmd/CompetitionCommand.java | 17 +++ .../commands/subcmd/ImportCommand.java | 17 +++ .../commands/subcmd/ItemsCommand.java | 17 +++ .../commands/subcmd/LootCommand.java | 17 +++ .../commands/subcmd/OpenCommand.java | 17 +++ .../commands/subcmd/RodCommand.java | 17 +++ .../commands/subcmd/UtilCommand.java | 17 +++ .../competition/Competition.java | 17 +++ .../competition/CompetitionConfig.java | 17 +++ .../competition/CompetitionGoal.java | 17 +++ .../competition/CompetitionPlayer.java | 17 +++ .../competition/CompetitionSchedule.java | 17 +++ .../competition/bossbar/BossBarManager.java | 17 +++ .../competition/ranking/LocalRankingImpl.java | 17 +++ .../competition/ranking/RankingInterface.java | 17 +++ .../competition/ranking/RedisRankingImpl.java | 17 +++ .../customfishing/data/PlayerBagData.java | 17 +++ .../data/storage/DataStorageInterface.java | 25 +++- .../data/storage/FileStorageImpl.java | 33 ++++- .../data/storage/MySQLStorageImpl.java | 122 +++++++++++++++- .../data/storage/SqlConnection.java | 138 ++++++++++++++++++ .../data/storage/SqlConstants.java | 9 ++ .../integration/BlockInterface.java | 17 +++ .../integration/ItemInterface.java | 18 ++- .../integration/MobInterface.java | 17 +++ .../integration/SeasonInterface.java | 17 +++ .../integration/SkillInterface.java | 17 +++ .../customfishing/integration/VaultHook.java | 17 +++ .../block/ItemsAdderBlockImpl.java | 17 +++ .../integration/block/OraxenBlockImpl.java | 17 +++ .../integration/block/VanillaBlockImpl.java | 17 +++ .../item/CustomFishingItemImpl.java | 17 +++ .../integration/item/EcoItemRegister.java | 17 +++ .../integration/item/ItemsAdderItemImpl.java | 17 +++ .../integration/item/MMOItemsItemImpl.java | 17 +++ .../integration/item/McMMOTreasure.java | 17 +++ .../integration/item/MythicMobsItemImpl.java | 17 +++ .../integration/item/OraxenItemImpl.java | 17 +++ .../integration/mob/MythicMobsMobImpl.java | 17 +++ .../integration/papi/CompetitionPapi.java | 22 ++- .../integration/papi/PlaceholderManager.java | 17 +++ .../season/CustomCropsSeasonImpl.java | 17 +++ .../season/RealisticSeasonsImpl.java | 17 +++ .../listener/InteractListener.java | 17 +++ .../listener/InventoryListener.java | 17 +++ .../listener/JobsRebornXPListener.java | 17 +++ .../listener/MMOItemsListener.java | 17 +++ .../listener/PickUpListener.java | 17 +++ .../listener/PlayerFishListener.java | 17 +++ .../listener/SimpleListener.java | 17 +++ .../listener/WindowPacketListener.java | 17 +++ .../customfishing/manager/BagDataManager.java | 66 +++++++-- .../customfishing/manager/BonusManager.java | 18 ++- .../manager/CompetitionManager.java | 17 +++ .../customfishing/manager/ConfigManager.java | 32 ++-- .../customfishing/manager/FishingManager.java | 61 +++++--- .../manager/IntegrationManager.java | 25 ++++ .../customfishing/manager/LayoutManager.java | 17 +++ .../customfishing/manager/LootManager.java | 19 ++- .../customfishing/manager/MessageManager.java | 17 +++ .../customfishing/manager/SellManager.java | 23 ++- .../customfishing/manager/TotemManager.java | 17 +++ .../customfishing/object/Function.java | 17 +++ .../object/action/ActionInterface.java | 17 +++ .../object/action/CommandActionImpl.java | 17 +++ .../object/action/MessageActionImpl.java | 17 +++ .../object/action/SkillXPImpl.java | 22 ++- .../object/action/SoundActionImpl.java | 17 +++ .../object/action/VanillaXPImpl.java | 17 +++ .../object/fishing/BobberCheckTask.java | 71 +++++++-- .../customfishing/object/fishing/Bonus.java | 17 +++ .../object/fishing/FishResult.java | 17 +++ .../object/fishing/FishingPlayer.java | 17 +++ .../object/fishing/LavaEffect.java | 18 ++- .../object/fishing/VanillaLoot.java | 17 +++ .../object/loot/DroppedItem.java | 17 +++ .../customfishing/object/loot/Item.java | 17 +++ .../customfishing/object/loot/Loot.java | 17 +++ .../customfishing/object/loot/Mob.java | 17 +++ .../object/totem/ActivatedTotem.java | 17 +++ .../object/totem/TotemParticle.java | 17 +++ .../customfishing/util/ArmorStandUtil.java | 17 +++ .../customfishing/util/BlockUtil.java | 13 ++ .../customfishing/util/ConfigUtil.java | 17 +++ .../customfishing/util/InventoryUtil.java | 35 ++++- .../customfishing/util/ItemStackUtil.java | 17 +++ .../customfishing/util/JedisUtil.java | 17 +++ .../customfishing/util/NBTUtil.java | 17 +++ src/main/resources/config.yml | 47 ++++-- src/main/resources/database.yml | 36 ++++- src/main/resources/enchant-bonus.yml | 6 +- .../resources/messages/messages_chinese.yml | 1 - .../resources/messages/messages_english.yml | 1 - .../resources/messages/messages_spanish.yml | 5 +- src/main/resources/mobs/example.yml | 4 +- 105 files changed, 2085 insertions(+), 116 deletions(-) create mode 100644 src/main/java/net/momirealms/customfishing/data/storage/SqlConnection.java create mode 100644 src/main/java/net/momirealms/customfishing/data/storage/SqlConstants.java create mode 100644 src/main/java/net/momirealms/customfishing/util/BlockUtil.java diff --git a/src/main/java/net/momirealms/customfishing/CustomFishing.java b/src/main/java/net/momirealms/customfishing/CustomFishing.java index cc6c8acf..6951259d 100644 --- a/src/main/java/net/momirealms/customfishing/CustomFishing.java +++ b/src/main/java/net/momirealms/customfishing/CustomFishing.java @@ -36,7 +36,6 @@ public final class CustomFishing extends JavaPlugin { public static CustomFishing plugin; public static BukkitAudiences adventure; public static ProtocolManager protocolManager; - private IntegrationManager integrationManager; private FishingManager fishingManager; private CompetitionManager competitionManager; @@ -70,11 +69,12 @@ public final class CustomFishing extends JavaPlugin { @Override public void onLoad() { plugin = this; - LibraryLoader.load("redis.clients","jedis","4.2.3","https://repo.maven.apache.org/maven2/"); + LibraryLoader.load("redis.clients","jedis","4.3.0","https://repo.maven.apache.org/maven2/"); LibraryLoader.load("org.apache.commons","commons-pool2","2.11.1","https://repo.maven.apache.org/maven2/"); LibraryLoader.load("dev.dejvokep","boosted-yaml","1.3","https://repo.maven.apache.org/maven2/"); LibraryLoader.load("com.zaxxer","HikariCP","5.0.1","https://repo.maven.apache.org/maven2/"); LibraryLoader.load("net.objecthunter","exp4j","0.4.8","https://repo.maven.apache.org/maven2/"); + LibraryLoader.load("org.mariadb.jdbc","mariadb-java-client","3.0.6","https://repo.maven.apache.org/maven2/"); } @Override @@ -106,6 +106,7 @@ public final class CustomFishing extends JavaPlugin { this.lootManager.unload(); this.layoutManager.unload(); this.bagDataManager.unload(); + this.bagDataManager.disable(); this.totemManager.unload(); this.sellManager.unload(); if (adventure != null) { diff --git a/src/main/java/net/momirealms/customfishing/api/CustomFishingAPI.java b/src/main/java/net/momirealms/customfishing/api/CustomFishingAPI.java index 2d30e13f..80dcf803 100644 --- a/src/main/java/net/momirealms/customfishing/api/CustomFishingAPI.java +++ b/src/main/java/net/momirealms/customfishing/api/CustomFishingAPI.java @@ -1,3 +1,20 @@ +/* + * 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.api; public class CustomFishingAPI { diff --git a/src/main/java/net/momirealms/customfishing/api/event/FishFinderEvent.java b/src/main/java/net/momirealms/customfishing/api/event/FishFinderEvent.java index 983467db..5b6191a1 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/FishFinderEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/FishFinderEvent.java @@ -1,3 +1,20 @@ +/* + * 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.api.event; import net.momirealms.customfishing.object.loot.Loot; 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 6a039f3b..ce23f2e7 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/FishHookEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/FishHookEvent.java @@ -1,3 +1,20 @@ +/* + * 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.api.event; import net.momirealms.customfishing.object.fishing.Difficulty; 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 acee4d33..9d9c1c1e 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java @@ -1,3 +1,20 @@ +/* + * 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.api.event; import net.momirealms.customfishing.object.fishing.FishResult; 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 90154978..d95cef43 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java @@ -1,3 +1,20 @@ +/* + * 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.api.event; import net.momirealms.customfishing.object.fishing.Bonus; diff --git a/src/main/java/net/momirealms/customfishing/api/event/TotemActivationEvent.java b/src/main/java/net/momirealms/customfishing/api/event/TotemActivationEvent.java index 590ca4d8..dae72217 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/TotemActivationEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/TotemActivationEvent.java @@ -1,3 +1,20 @@ +/* + * 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.api.event; import net.momirealms.customfishing.object.totem.Totem; diff --git a/src/main/java/net/momirealms/customfishing/commands/FishingBagCommand.java b/src/main/java/net/momirealms/customfishing/commands/FishingBagCommand.java index 9ba8a9e1..d83e04d8 100644 --- a/src/main/java/net/momirealms/customfishing/commands/FishingBagCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/FishingBagCommand.java @@ -1,3 +1,20 @@ +/* + * 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.commands; import net.momirealms.customfishing.commands.subcmd.OpenCommand; diff --git a/src/main/java/net/momirealms/customfishing/commands/SellFishCommand.java b/src/main/java/net/momirealms/customfishing/commands/SellFishCommand.java index e589e5c7..6370fe59 100644 --- a/src/main/java/net/momirealms/customfishing/commands/SellFishCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/SellFishCommand.java @@ -1,3 +1,20 @@ +/* + * 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.commands; import net.momirealms.customfishing.CustomFishing; diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/BaitCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/BaitCommand.java index 99be798f..d3e72411 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/BaitCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/BaitCommand.java @@ -1,3 +1,20 @@ +/* + * 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.commands.subcmd; import net.momirealms.customfishing.commands.AbstractSubCommand; diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/CompetitionCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/CompetitionCommand.java index d26f9868..1e2b8543 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/CompetitionCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/CompetitionCommand.java @@ -1,3 +1,20 @@ +/* + * 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.commands.subcmd; import net.momirealms.customfishing.commands.AbstractSubCommand; diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/ImportCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/ImportCommand.java index aaa8c28e..2d109760 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/ImportCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/ImportCommand.java @@ -1,3 +1,20 @@ +/* + * 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.commands.subcmd; import net.momirealms.customfishing.commands.AbstractSubCommand; diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/ItemsCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/ItemsCommand.java index 68f5391e..4697f8fa 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/ItemsCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/ItemsCommand.java @@ -1,3 +1,20 @@ +/* + * 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.commands.subcmd; import net.momirealms.customfishing.commands.AbstractSubCommand; diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/LootCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/LootCommand.java index 88dcab9a..ba3e1b4d 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/LootCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/LootCommand.java @@ -1,3 +1,20 @@ +/* + * 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.commands.subcmd; import net.momirealms.customfishing.commands.AbstractSubCommand; diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/OpenCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/OpenCommand.java index 492fe98d..0bee02e4 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/OpenCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/OpenCommand.java @@ -1,3 +1,20 @@ +/* + * 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.commands.subcmd; import net.momirealms.customfishing.CustomFishing; diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/RodCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/RodCommand.java index dd635bd9..37decc26 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/RodCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/RodCommand.java @@ -1,3 +1,20 @@ +/* + * 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.commands.subcmd; import net.momirealms.customfishing.commands.AbstractSubCommand; diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/UtilCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/UtilCommand.java index 196efe38..edc413ad 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/UtilCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/UtilCommand.java @@ -1,3 +1,20 @@ +/* + * 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.commands.subcmd; import net.momirealms.customfishing.commands.AbstractSubCommand; diff --git a/src/main/java/net/momirealms/customfishing/competition/Competition.java b/src/main/java/net/momirealms/customfishing/competition/Competition.java index 409184d7..d9fe9509 100644 --- a/src/main/java/net/momirealms/customfishing/competition/Competition.java +++ b/src/main/java/net/momirealms/customfishing/competition/Competition.java @@ -1,3 +1,20 @@ +/* + * 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; import net.momirealms.customfishing.CustomFishing; diff --git a/src/main/java/net/momirealms/customfishing/competition/CompetitionConfig.java b/src/main/java/net/momirealms/customfishing/competition/CompetitionConfig.java index c9957ea2..bd7d0da5 100644 --- a/src/main/java/net/momirealms/customfishing/competition/CompetitionConfig.java +++ b/src/main/java/net/momirealms/customfishing/competition/CompetitionConfig.java @@ -1,3 +1,20 @@ +/* + * 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; import net.momirealms.customfishing.competition.bossbar.BossBarConfig; diff --git a/src/main/java/net/momirealms/customfishing/competition/CompetitionGoal.java b/src/main/java/net/momirealms/customfishing/competition/CompetitionGoal.java index 0d88baa2..e2ffd48f 100644 --- a/src/main/java/net/momirealms/customfishing/competition/CompetitionGoal.java +++ b/src/main/java/net/momirealms/customfishing/competition/CompetitionGoal.java @@ -1,3 +1,20 @@ +/* + * 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; public enum CompetitionGoal { diff --git a/src/main/java/net/momirealms/customfishing/competition/CompetitionPlayer.java b/src/main/java/net/momirealms/customfishing/competition/CompetitionPlayer.java index 213a4371..4d92fee2 100644 --- a/src/main/java/net/momirealms/customfishing/competition/CompetitionPlayer.java +++ b/src/main/java/net/momirealms/customfishing/competition/CompetitionPlayer.java @@ -1,3 +1,20 @@ +/* + * 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; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/net/momirealms/customfishing/competition/CompetitionSchedule.java b/src/main/java/net/momirealms/customfishing/competition/CompetitionSchedule.java index 4c9dbcba..ee7c0067 100644 --- a/src/main/java/net/momirealms/customfishing/competition/CompetitionSchedule.java +++ b/src/main/java/net/momirealms/customfishing/competition/CompetitionSchedule.java @@ -1,3 +1,20 @@ +/* + * 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; import net.momirealms.customfishing.CustomFishing; 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 ab431b8c..542901fd 100644 --- a/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarManager.java +++ b/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarManager.java @@ -1,3 +1,20 @@ +/* + * 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 net.momirealms.customfishing.CustomFishing; diff --git a/src/main/java/net/momirealms/customfishing/competition/ranking/LocalRankingImpl.java b/src/main/java/net/momirealms/customfishing/competition/ranking/LocalRankingImpl.java index 473623b4..300d6672 100644 --- a/src/main/java/net/momirealms/customfishing/competition/ranking/LocalRankingImpl.java +++ b/src/main/java/net/momirealms/customfishing/competition/ranking/LocalRankingImpl.java @@ -1,3 +1,20 @@ +/* + * 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.ranking; import net.momirealms.customfishing.competition.CompetitionPlayer; diff --git a/src/main/java/net/momirealms/customfishing/competition/ranking/RankingInterface.java b/src/main/java/net/momirealms/customfishing/competition/ranking/RankingInterface.java index 02d68889..c6201673 100644 --- a/src/main/java/net/momirealms/customfishing/competition/ranking/RankingInterface.java +++ b/src/main/java/net/momirealms/customfishing/competition/ranking/RankingInterface.java @@ -1,3 +1,20 @@ +/* + * 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.ranking; import net.momirealms.customfishing.competition.CompetitionPlayer; diff --git a/src/main/java/net/momirealms/customfishing/competition/ranking/RedisRankingImpl.java b/src/main/java/net/momirealms/customfishing/competition/ranking/RedisRankingImpl.java index 887083d8..d906f262 100644 --- a/src/main/java/net/momirealms/customfishing/competition/ranking/RedisRankingImpl.java +++ b/src/main/java/net/momirealms/customfishing/competition/ranking/RedisRankingImpl.java @@ -1,3 +1,20 @@ +/* + * 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.ranking; import net.momirealms.customfishing.competition.CompetitionPlayer; diff --git a/src/main/java/net/momirealms/customfishing/data/PlayerBagData.java b/src/main/java/net/momirealms/customfishing/data/PlayerBagData.java index 68d4c4d5..670cbfb8 100644 --- a/src/main/java/net/momirealms/customfishing/data/PlayerBagData.java +++ b/src/main/java/net/momirealms/customfishing/data/PlayerBagData.java @@ -1,3 +1,20 @@ +/* + * 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.data; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/net/momirealms/customfishing/data/storage/DataStorageInterface.java b/src/main/java/net/momirealms/customfishing/data/storage/DataStorageInterface.java index 8474f908..307be88b 100644 --- a/src/main/java/net/momirealms/customfishing/data/storage/DataStorageInterface.java +++ b/src/main/java/net/momirealms/customfishing/data/storage/DataStorageInterface.java @@ -1,3 +1,20 @@ +/* + * 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.data.storage; import net.momirealms.customfishing.data.PlayerBagData; @@ -6,8 +23,8 @@ import org.bukkit.inventory.Inventory; public interface DataStorageInterface { - Inventory load(OfflinePlayer player); - - void save(PlayerBagData playerBagData); - + void initialize(); + void disable(); + Inventory loadBagData(OfflinePlayer player); + void saveBagData(PlayerBagData playerBagData); } diff --git a/src/main/java/net/momirealms/customfishing/data/storage/FileStorageImpl.java b/src/main/java/net/momirealms/customfishing/data/storage/FileStorageImpl.java index a3ec4da0..9e29e1ce 100644 --- a/src/main/java/net/momirealms/customfishing/data/storage/FileStorageImpl.java +++ b/src/main/java/net/momirealms/customfishing/data/storage/FileStorageImpl.java @@ -1,3 +1,20 @@ +/* + * 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.data.storage; import net.momirealms.customfishing.CustomFishing; @@ -16,18 +33,28 @@ import java.io.IOException; public class FileStorageImpl implements DataStorageInterface { @Override - public Inventory load(OfflinePlayer player) { + public void initialize() { + + } + + @Override + public void disable() { + + } + + @Override + public Inventory loadBagData(OfflinePlayer player) { YamlConfiguration config = ConfigUtil.readData(new File(CustomFishing.plugin.getDataFolder(), "fishingbag_data" + File.separator + player.getUniqueId() + ".yml")); String contents = config.getString("contents"); int size = config.getInt("size", 9); ItemStack[] itemStacks = InventoryUtil.getInventoryItems(contents); Inventory inventory = Bukkit.createInventory(null, size, "{CustomFishing_Bag_" + player.getName() + "}"); - inventory.setContents(itemStacks); + if (itemStacks != null) inventory.setContents(itemStacks); return inventory; } @Override - public void save(PlayerBagData playerBagData) { + public void saveBagData(PlayerBagData playerBagData) { YamlConfiguration data = new YamlConfiguration(); Inventory inventory = playerBagData.getInventory(); String contents = InventoryUtil.toBase64(inventory.getContents()); diff --git a/src/main/java/net/momirealms/customfishing/data/storage/MySQLStorageImpl.java b/src/main/java/net/momirealms/customfishing/data/storage/MySQLStorageImpl.java index 02bab520..4908796e 100644 --- a/src/main/java/net/momirealms/customfishing/data/storage/MySQLStorageImpl.java +++ b/src/main/java/net/momirealms/customfishing/data/storage/MySQLStorageImpl.java @@ -1,18 +1,134 @@ +/* + * 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.data.storage; import net.momirealms.customfishing.data.PlayerBagData; +import net.momirealms.customfishing.util.AdventureUtil; +import net.momirealms.customfishing.util.InventoryUtil; +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.UUID; public class MySQLStorageImpl implements DataStorageInterface { + public static SqlConnection sqlConnection = new SqlConnection(); + @Override - public Inventory load(OfflinePlayer player) { - return null; + public void initialize() { + sqlConnection.createNewHikariConfiguration(); + createTableIfNotExist(sqlConnection.getTablePrefix() + "_fishingbag"); } @Override - public void save(PlayerBagData playerBagData) { + public void disable() { + sqlConnection.close(); + } + @Override + public Inventory loadBagData(OfflinePlayer player) { + Inventory inventory = null; + try { + Connection connection = sqlConnection.getConnectionAndCheck(); + String sql = String.format(SqlConstants.SQL_SELECT_BAG_BY_UUID, sqlConnection.getTablePrefix() + "_fishingbag");; + PreparedStatement statement = connection.prepareStatement(sql); + statement.setString(1, player.getUniqueId().toString()); + ResultSet rs = statement.executeQuery(); + if (rs.next()) { + int size = rs.getInt(2); + String contents = rs.getString(3); + ItemStack[] itemStacks = InventoryUtil.getInventoryItems(contents); + inventory = Bukkit.createInventory(null, size, "{CustomFishing_Bag_" + player.getName() + "}"); + if (itemStacks != null) inventory.setContents(itemStacks); + } + else { + inventory = Bukkit.createInventory(null, 9, "{CustomFishing_Bag_" + player.getName() + "}"); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return inventory; + } + + @Override + public void saveBagData(PlayerBagData playerBagData) { + UUID uuid = playerBagData.getPlayer().getUniqueId(); + Inventory inventory = playerBagData.getInventory(); + String contents = InventoryUtil.toBase64(inventory.getContents()); + if (contents == null) contents = ""; + if (exists(uuid)) { + updateBagData(uuid, inventory.getSize(), contents); + } + else { + insertBagData(uuid, inventory.getSize(), contents); + } + } + + private void createTableIfNotExist(String table) { + String sql = String.format(SqlConstants.SQL_CREATE_BAG_TABLE, table); + try (Connection connection = sqlConnection.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { + statement.executeUpdate(); + } catch (SQLException ex) { + AdventureUtil.consoleMessage("[CustomFishing] Failed to create table"); + } + } + + private void insertBagData(UUID uuid, int size, String contents) { + String sql = String.format(SqlConstants.SQL_INSERT_BAG, sqlConnection.getTablePrefix() + "_fishingbag"); + try (Connection connection = sqlConnection.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { + statement.setString(1, uuid.toString()); + statement.setInt(2, size); + statement.setString(3, contents); + statement.executeUpdate(); + } catch (SQLException ex) { + AdventureUtil.consoleMessage("[CustomFishing] Failed to insert data for " + uuid); + } + } + + private void updateBagData(UUID uuid, int size, String contents) { + String sql = String.format(SqlConstants.SQL_UPDATE_BAG_BY_UUID, sqlConnection.getTablePrefix() + "_fishingbag"); + try (Connection connection = sqlConnection.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { + statement.setInt(1, size); + statement.setString(2, contents); + statement.setString(3, uuid.toString()); + statement.executeUpdate(); + } catch (SQLException ex) { + AdventureUtil.consoleMessage("[CustomFishing] Failed to update data for " + uuid); + } + } + + public boolean exists(UUID uuid) { + String sql = String.format(SqlConstants.SQL_SELECT_BAG_BY_UUID, sqlConnection.getTablePrefix() + "_fishingbag"); + boolean exist; + try (Connection connection = sqlConnection.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { + statement.setString(1, uuid.toString()); + ResultSet rs = statement.executeQuery(); + exist = rs.next(); + } catch (SQLException ex) { + AdventureUtil.consoleMessage("[CustomFishing] Failed to select data for " + uuid); + return false; + } + return exist; } } diff --git a/src/main/java/net/momirealms/customfishing/data/storage/SqlConnection.java b/src/main/java/net/momirealms/customfishing/data/storage/SqlConnection.java new file mode 100644 index 00000000..ebe26a87 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/data/storage/SqlConnection.java @@ -0,0 +1,138 @@ +/* + * 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.data.storage; + +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import com.zaxxer.hikari.pool.HikariPool; +import net.momirealms.customfishing.util.AdventureUtil; +import net.momirealms.customfishing.util.ConfigUtil; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.sql.Connection; +import java.sql.SQLException; + +public class SqlConnection { + + private boolean secondTry = false; + private boolean firstTry = false; + private boolean isFirstTry = true; + public int waitTimeOut = 10; + private HikariDataSource hikariDataSource; + private String tablePrefix; + + public void createNewHikariConfiguration() { + + YamlConfiguration config = ConfigUtil.getConfig("database.yml"); + String storageMode = config.getString("data-storage-method", "MySQL"); + + HikariConfig hikariConfig = new HikariConfig(); + String sql = "mysql"; + if (storageMode.equalsIgnoreCase("MariaDB")) { + hikariConfig.setDriverClassName("org.mariadb.jdbc.Driver"); + sql = "mariadb"; + } + + tablePrefix = config.getString("MySQL.table-prefix"); + hikariConfig.setPoolName("[CustomFishing]"); + hikariConfig.setJdbcUrl(String.format("jdbc:%s://%s/%s", sql, config.getString("MySQL.host") + ":" + config.getString("MySQL.port"), config.getString("MySQL.database"))); + hikariConfig.setUsername(config.getString(storageMode + ".user")); + hikariConfig.setPassword(config.getString(storageMode + ".password")); + hikariConfig.setMaximumPoolSize(config.getInt(storageMode + ".Pool-Settings.maximum-pool-size")); + hikariConfig.setMinimumIdle(config.getInt(storageMode + ".Pool-Settings.minimum-idle")); + hikariConfig.setMaxLifetime(config.getInt(storageMode + ".Pool-Settings.maximum-lifetime")); + for (String property : config.getConfigurationSection(storageMode + ".properties").getKeys(false)) { + hikariConfig.addDataSourceProperty(property, config.getString(storageMode + ".properties." + property)); + } + if (hikariConfig.getMinimumIdle() < hikariConfig.getMaximumPoolSize()) { + hikariConfig.setIdleTimeout(config.getInt(storageMode + ".Pool-Settings.idle-timeout")); + } else { + hikariConfig.setIdleTimeout(0); + } + + try { + hikariDataSource = new HikariDataSource(hikariConfig); + } catch (HikariPool.PoolInitializationException e) { + AdventureUtil.consoleMessage("[CustomFishing] Failed to create sql connection"); + } + } + + public boolean setGlobalConnection() { + try { + createNewHikariConfiguration(); + Connection connection = getConnection(); + connection.close(); + if (secondTry) { + AdventureUtil.consoleMessage("[CustomFishing] Successfully reconnect to SQL!"); + } else { + secondTry = true; + } + return true; + } catch (SQLException e) { + AdventureUtil.consoleMessage("[CustomFishing] Error! Failed to connect to SQL!"); + e.printStackTrace(); + close(); + return false; + } + } + + public Connection getConnection() throws SQLException { + return hikariDataSource.getConnection(); + } + + public boolean canConnect() { + if (hikariDataSource == null) { + return setGlobalConnection(); + } + if (hikariDataSource.isClosed()) { + return setGlobalConnection(); + } + return true; + } + + public void close() { + if (hikariDataSource != null && hikariDataSource.isRunning()) { + hikariDataSource.close(); + } + } + + public String getTablePrefix() { + return tablePrefix; + } + + public Connection getConnectionAndCheck() { + if (!canConnect()) { + return null; + } + try { + return getConnection(); + } catch (SQLException e) { + if (firstTry) { + firstTry = false; + close(); + return getConnectionAndCheck(); + } else { + firstTry = true; + AdventureUtil.consoleMessage("[CustomNameplates] Error! Failed to connect to SQL!"); + close(); + e.printStackTrace(); + return null; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/momirealms/customfishing/data/storage/SqlConstants.java b/src/main/java/net/momirealms/customfishing/data/storage/SqlConstants.java new file mode 100644 index 00000000..8846a356 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/data/storage/SqlConstants.java @@ -0,0 +1,9 @@ +package net.momirealms.customfishing.data.storage; + +public class SqlConstants { + + public static final String SQL_CREATE_BAG_TABLE = "CREATE TABLE IF NOT EXISTS `%s` ( `uuid` VARCHAR(36) NOT NULL , `size` INT(8) NOT NULL , `contents` LONGTEXT NOT NULL , PRIMARY KEY (`uuid`) )"; + public static final String SQL_INSERT_BAG = "INSERT INTO `%s`(`uuid`, `size`, `contents`) VALUES (?, ?, ?)"; + public static final String SQL_UPDATE_BAG_BY_UUID = "UPDATE `%s` SET `size` = ?, `contents` = ? WHERE `uuid` = ?"; + public static final String SQL_SELECT_BAG_BY_UUID = "SELECT * FROM `%s` WHERE `uuid` = ?"; +} diff --git a/src/main/java/net/momirealms/customfishing/integration/BlockInterface.java b/src/main/java/net/momirealms/customfishing/integration/BlockInterface.java index 33e2bdee..6e698af3 100644 --- a/src/main/java/net/momirealms/customfishing/integration/BlockInterface.java +++ b/src/main/java/net/momirealms/customfishing/integration/BlockInterface.java @@ -1,3 +1,20 @@ +/* + * 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 org.bukkit.Location; diff --git a/src/main/java/net/momirealms/customfishing/integration/ItemInterface.java b/src/main/java/net/momirealms/customfishing/integration/ItemInterface.java index 2dcf33f3..f749ebe2 100644 --- a/src/main/java/net/momirealms/customfishing/integration/ItemInterface.java +++ b/src/main/java/net/momirealms/customfishing/integration/ItemInterface.java @@ -1,3 +1,20 @@ +/* + * 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 org.bukkit.inventory.ItemStack; @@ -7,5 +24,4 @@ public interface ItemInterface { @Nullable ItemStack build(String id); - } diff --git a/src/main/java/net/momirealms/customfishing/integration/MobInterface.java b/src/main/java/net/momirealms/customfishing/integration/MobInterface.java index e2fe1800..9675623f 100644 --- a/src/main/java/net/momirealms/customfishing/integration/MobInterface.java +++ b/src/main/java/net/momirealms/customfishing/integration/MobInterface.java @@ -1,3 +1,20 @@ +/* + * 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.object.loot.Mob; diff --git a/src/main/java/net/momirealms/customfishing/integration/SeasonInterface.java b/src/main/java/net/momirealms/customfishing/integration/SeasonInterface.java index 7b9c458d..d784f00b 100644 --- a/src/main/java/net/momirealms/customfishing/integration/SeasonInterface.java +++ b/src/main/java/net/momirealms/customfishing/integration/SeasonInterface.java @@ -1,3 +1,20 @@ +/* + * 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 org.bukkit.World; diff --git a/src/main/java/net/momirealms/customfishing/integration/SkillInterface.java b/src/main/java/net/momirealms/customfishing/integration/SkillInterface.java index 5175d588..bcc094f3 100644 --- a/src/main/java/net/momirealms/customfishing/integration/SkillInterface.java +++ b/src/main/java/net/momirealms/customfishing/integration/SkillInterface.java @@ -1,3 +1,20 @@ +/* + * 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 org.bukkit.entity.Player; diff --git a/src/main/java/net/momirealms/customfishing/integration/VaultHook.java b/src/main/java/net/momirealms/customfishing/integration/VaultHook.java index 70564b41..708de51b 100644 --- a/src/main/java/net/momirealms/customfishing/integration/VaultHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/VaultHook.java @@ -1,3 +1,20 @@ +/* + * 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.milkbowl.vault.economy.Economy; diff --git a/src/main/java/net/momirealms/customfishing/integration/block/ItemsAdderBlockImpl.java b/src/main/java/net/momirealms/customfishing/integration/block/ItemsAdderBlockImpl.java index 8da8ca84..f3dac508 100644 --- a/src/main/java/net/momirealms/customfishing/integration/block/ItemsAdderBlockImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/block/ItemsAdderBlockImpl.java @@ -1,3 +1,20 @@ +/* + * 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.block; import dev.lone.itemsadder.api.CustomBlock; diff --git a/src/main/java/net/momirealms/customfishing/integration/block/OraxenBlockImpl.java b/src/main/java/net/momirealms/customfishing/integration/block/OraxenBlockImpl.java index 036c28e6..5147df98 100644 --- a/src/main/java/net/momirealms/customfishing/integration/block/OraxenBlockImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/block/OraxenBlockImpl.java @@ -1,3 +1,20 @@ +/* + * 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.block; import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanic; diff --git a/src/main/java/net/momirealms/customfishing/integration/block/VanillaBlockImpl.java b/src/main/java/net/momirealms/customfishing/integration/block/VanillaBlockImpl.java index 7b6132d5..a46a6bc6 100644 --- a/src/main/java/net/momirealms/customfishing/integration/block/VanillaBlockImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/block/VanillaBlockImpl.java @@ -1,3 +1,20 @@ +/* + * 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.block; import net.momirealms.customfishing.integration.BlockInterface; diff --git a/src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemImpl.java b/src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemImpl.java index 572ec391..7db44949 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemImpl.java @@ -1,3 +1,20 @@ +/* + * 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.item; import net.momirealms.customfishing.integration.ItemInterface; diff --git a/src/main/java/net/momirealms/customfishing/integration/item/EcoItemRegister.java b/src/main/java/net/momirealms/customfishing/integration/item/EcoItemRegister.java index c57170f9..732fe73d 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/EcoItemRegister.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/EcoItemRegister.java @@ -1,3 +1,20 @@ +/* + * 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.item; import com.willfp.eco.core.items.CustomItem; diff --git a/src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemImpl.java b/src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemImpl.java index c0de515c..fb172cbf 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemImpl.java @@ -1,3 +1,20 @@ +/* + * 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.item; import dev.lone.itemsadder.api.CustomStack; diff --git a/src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemImpl.java b/src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemImpl.java index 50da12d8..0f2d4149 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemImpl.java @@ -1,3 +1,20 @@ +/* + * 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.item; import net.Indyuce.mmoitems.MMOItems; diff --git a/src/main/java/net/momirealms/customfishing/integration/item/McMMOTreasure.java b/src/main/java/net/momirealms/customfishing/integration/item/McMMOTreasure.java index 8cfc2ce5..e8defa1c 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/McMMOTreasure.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/McMMOTreasure.java @@ -1,3 +1,20 @@ +/* + * 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.item; import com.gmail.nossr50.config.treasure.FishingTreasureConfig; diff --git a/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java b/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java index 0d728ede..7616446a 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java @@ -1,3 +1,20 @@ +/* + * 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.item; import io.lumine.mythic.bukkit.MythicBukkit; diff --git a/src/main/java/net/momirealms/customfishing/integration/item/OraxenItemImpl.java b/src/main/java/net/momirealms/customfishing/integration/item/OraxenItemImpl.java index e07c98bb..000d1751 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/OraxenItemImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/OraxenItemImpl.java @@ -1,3 +1,20 @@ +/* + * 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.item; import io.th0rgal.oraxen.items.ItemBuilder; diff --git a/src/main/java/net/momirealms/customfishing/integration/mob/MythicMobsMobImpl.java b/src/main/java/net/momirealms/customfishing/integration/mob/MythicMobsMobImpl.java index 0560da70..c6bf633b 100644 --- a/src/main/java/net/momirealms/customfishing/integration/mob/MythicMobsMobImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/mob/MythicMobsMobImpl.java @@ -1,3 +1,20 @@ +/* + * 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.mob; import io.lumine.mythic.api.adapters.AbstractLocation; diff --git a/src/main/java/net/momirealms/customfishing/integration/papi/CompetitionPapi.java b/src/main/java/net/momirealms/customfishing/integration/papi/CompetitionPapi.java index 03fb3a67..74d1a20a 100644 --- a/src/main/java/net/momirealms/customfishing/integration/papi/CompetitionPapi.java +++ b/src/main/java/net/momirealms/customfishing/integration/papi/CompetitionPapi.java @@ -1,3 +1,20 @@ +/* + * 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.papi; import me.clip.placeholderapi.expansion.PlaceholderExpansion; @@ -30,11 +47,14 @@ public class CompetitionPapi extends PlaceholderExpansion { @Override public @Nullable String onPlaceholderRequest(Player player, @NotNull String params) { - if (Competition.currentCompetition == null) return "null"; + if (Competition.currentCompetition == null) return ""; switch (params) { case "rank" -> { return Competition.currentCompetition.getPlayerRank(player); } + case "score" -> { + return String.format("%.1f", Competition.currentCompetition.getScore(player)); + } case "time" -> { return String.valueOf(Competition.currentCompetition.getRemainingTime()); } 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 db4be568..f6b82830 100644 --- a/src/main/java/net/momirealms/customfishing/integration/papi/PlaceholderManager.java +++ b/src/main/java/net/momirealms/customfishing/integration/papi/PlaceholderManager.java @@ -1,3 +1,20 @@ +/* + * 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.papi; import me.clip.placeholderapi.PlaceholderAPI; 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 7fa139bb..cefc5718 100644 --- a/src/main/java/net/momirealms/customfishing/integration/season/CustomCropsSeasonImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/season/CustomCropsSeasonImpl.java @@ -1,3 +1,20 @@ +/* + * 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.season; import net.momirealms.customcrops.api.utils.SeasonUtils; diff --git a/src/main/java/net/momirealms/customfishing/integration/season/RealisticSeasonsImpl.java b/src/main/java/net/momirealms/customfishing/integration/season/RealisticSeasonsImpl.java index deee9690..3beec64a 100644 --- a/src/main/java/net/momirealms/customfishing/integration/season/RealisticSeasonsImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/season/RealisticSeasonsImpl.java @@ -1,3 +1,20 @@ +/* + * 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.season; import me.casperge.realisticseasons.api.SeasonsAPI; diff --git a/src/main/java/net/momirealms/customfishing/listener/InteractListener.java b/src/main/java/net/momirealms/customfishing/listener/InteractListener.java index 043b21e1..7a77b749 100644 --- a/src/main/java/net/momirealms/customfishing/listener/InteractListener.java +++ b/src/main/java/net/momirealms/customfishing/listener/InteractListener.java @@ -1,3 +1,20 @@ +/* + * 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.listener; import net.momirealms.customfishing.object.Function; diff --git a/src/main/java/net/momirealms/customfishing/listener/InventoryListener.java b/src/main/java/net/momirealms/customfishing/listener/InventoryListener.java index d65318e8..ab781b8b 100644 --- a/src/main/java/net/momirealms/customfishing/listener/InventoryListener.java +++ b/src/main/java/net/momirealms/customfishing/listener/InventoryListener.java @@ -1,3 +1,20 @@ +/* + * 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.listener; import net.momirealms.customfishing.object.Function; diff --git a/src/main/java/net/momirealms/customfishing/listener/JobsRebornXPListener.java b/src/main/java/net/momirealms/customfishing/listener/JobsRebornXPListener.java index 8357422f..00b3b965 100644 --- a/src/main/java/net/momirealms/customfishing/listener/JobsRebornXPListener.java +++ b/src/main/java/net/momirealms/customfishing/listener/JobsRebornXPListener.java @@ -1,3 +1,20 @@ +/* + * 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.listener; import com.gamingmesh.jobs.Jobs; diff --git a/src/main/java/net/momirealms/customfishing/listener/MMOItemsListener.java b/src/main/java/net/momirealms/customfishing/listener/MMOItemsListener.java index 1cfa5c93..5166de56 100644 --- a/src/main/java/net/momirealms/customfishing/listener/MMOItemsListener.java +++ b/src/main/java/net/momirealms/customfishing/listener/MMOItemsListener.java @@ -1,3 +1,20 @@ +/* + * 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.listener; import net.momirealms.customfishing.manager.FishingManager; diff --git a/src/main/java/net/momirealms/customfishing/listener/PickUpListener.java b/src/main/java/net/momirealms/customfishing/listener/PickUpListener.java index 4dd356c7..6c35fe40 100644 --- a/src/main/java/net/momirealms/customfishing/listener/PickUpListener.java +++ b/src/main/java/net/momirealms/customfishing/listener/PickUpListener.java @@ -1,3 +1,20 @@ +/* + * 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.listener; import de.tr7zw.changeme.nbtapi.NBTItem; diff --git a/src/main/java/net/momirealms/customfishing/listener/PlayerFishListener.java b/src/main/java/net/momirealms/customfishing/listener/PlayerFishListener.java index 1ad2540e..fac23d30 100644 --- a/src/main/java/net/momirealms/customfishing/listener/PlayerFishListener.java +++ b/src/main/java/net/momirealms/customfishing/listener/PlayerFishListener.java @@ -1,3 +1,20 @@ +/* + * 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.listener; import net.momirealms.customfishing.manager.ConfigManager; diff --git a/src/main/java/net/momirealms/customfishing/listener/SimpleListener.java b/src/main/java/net/momirealms/customfishing/listener/SimpleListener.java index 8022c3d7..7c9817dd 100644 --- a/src/main/java/net/momirealms/customfishing/listener/SimpleListener.java +++ b/src/main/java/net/momirealms/customfishing/listener/SimpleListener.java @@ -1,3 +1,20 @@ +/* + * 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.listener; import net.momirealms.customfishing.object.Function; diff --git a/src/main/java/net/momirealms/customfishing/listener/WindowPacketListener.java b/src/main/java/net/momirealms/customfishing/listener/WindowPacketListener.java index 1ee5969b..1fab0c59 100644 --- a/src/main/java/net/momirealms/customfishing/listener/WindowPacketListener.java +++ b/src/main/java/net/momirealms/customfishing/listener/WindowPacketListener.java @@ -1,3 +1,20 @@ +/* + * 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.listener; import com.comphenix.protocol.PacketType; diff --git a/src/main/java/net/momirealms/customfishing/manager/BagDataManager.java b/src/main/java/net/momirealms/customfishing/manager/BagDataManager.java index b590ccd4..f063f155 100644 --- a/src/main/java/net/momirealms/customfishing/manager/BagDataManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/BagDataManager.java @@ -1,3 +1,20 @@ +/* + * 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.manager; import com.comphenix.protocol.events.PacketContainer; @@ -10,41 +27,57 @@ import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.data.PlayerBagData; import net.momirealms.customfishing.data.storage.DataStorageInterface; import net.momirealms.customfishing.data.storage.FileStorageImpl; +import net.momirealms.customfishing.data.storage.MySQLStorageImpl; import net.momirealms.customfishing.listener.InventoryListener; import net.momirealms.customfishing.listener.SimpleListener; import net.momirealms.customfishing.listener.WindowPacketListener; import net.momirealms.customfishing.object.Function; import net.momirealms.customfishing.util.AdventureUtil; +import net.momirealms.customfishing.util.ConfigUtil; import net.momirealms.customfishing.util.ItemStackUtil; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; -import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.scheduler.BukkitTask; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; public class BagDataManager extends Function { - public static HashMap dataCache; + public static ConcurrentHashMap dataCache; public static HashSet tempCache; private final DataStorageInterface dataStorageInterface; private final InventoryListener inventoryListener; private final WindowPacketListener windowPacketListener; private final SimpleListener simpleListener; + private final BukkitTask timerSave; public BagDataManager() { - dataCache = new HashMap<>(); + dataCache = new ConcurrentHashMap<>(); tempCache = new HashSet<>(); - this.dataStorageInterface = new FileStorageImpl(); + YamlConfiguration config = ConfigUtil.getConfig("database.yml"); + if (config.getString("data-storage-method","YAML").equalsIgnoreCase("YAML")) { + this.dataStorageInterface = new FileStorageImpl(); + } else this.dataStorageInterface = new MySQLStorageImpl(); + this.dataStorageInterface.initialize(); this.inventoryListener = new InventoryListener(this); this.windowPacketListener = new WindowPacketListener(this); this.simpleListener = new SimpleListener(this); + this.timerSave = Bukkit.getScheduler().runTaskTimerAsynchronously(CustomFishing.plugin, () -> { + for (PlayerBagData playerBagData : dataCache.values()) { + dataStorageInterface.saveBagData(playerBagData); + } + AdventureUtil.consoleMessage("[CustomFishing] Fishing bag data saving for " + dataCache.size() + " online players..."); + }, 6000, 6000); } @Override @@ -61,14 +94,21 @@ public class BagDataManager extends Function { HandlerList.unregisterAll(simpleListener); CustomFishing.protocolManager.removePacketListener(windowPacketListener); for (PlayerBagData playerBagData : dataCache.values()) { - dataStorageInterface.save(playerBagData); + dataStorageInterface.saveBagData(playerBagData); } } + public void disable() { + this.dataStorageInterface.disable(); + dataCache.clear(); + tempCache.clear(); + timerSave.cancel(); + } + public void openFishingBag(Player viewer, OfflinePlayer ownerOffline) { Player owner = ownerOffline.getPlayer(); if (owner == null) { - Inventory inventory = dataStorageInterface.load(ownerOffline); + Inventory inventory = dataStorageInterface.loadBagData(ownerOffline); PlayerBagData playerBagData = new PlayerBagData(ownerOffline, inventory); tempCache.add(playerBagData); viewer.openInventory(inventory); @@ -89,17 +129,21 @@ public class BagDataManager extends Function { public void onQuit(Player player) { PlayerBagData playerBagData = dataCache.remove(player.getUniqueId()); if (playerBagData != null) { - dataStorageInterface.save(playerBagData); + Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> { + dataStorageInterface.saveBagData(playerBagData); + }); } } @Override public void onJoin(Player player) { - readData(player); + Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> { + readData(player); + }); } public PlayerBagData readData(Player player) { - Inventory inventory = dataStorageInterface.load(player); + Inventory inventory = dataStorageInterface.loadBagData(player); PlayerBagData playerBagData = new PlayerBagData(player, inventory); dataCache.put(player.getUniqueId(), playerBagData); return playerBagData; @@ -159,7 +203,9 @@ public class BagDataManager extends Function { for (PlayerBagData temp : tempCache) { if (temp.getInventory() == inventory) { tempCache.remove(temp); - dataStorageInterface.save(temp); + Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> { + dataStorageInterface.saveBagData(temp); + }); } } } diff --git a/src/main/java/net/momirealms/customfishing/manager/BonusManager.java b/src/main/java/net/momirealms/customfishing/manager/BonusManager.java index a1073f79..99218ae0 100644 --- a/src/main/java/net/momirealms/customfishing/manager/BonusManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/BonusManager.java @@ -1,3 +1,20 @@ +/* + * 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.manager; import net.momirealms.customfishing.CustomFishing; @@ -25,7 +42,6 @@ public class BonusManager extends Function { public static HashMap RODITEMS; public static HashMap ROD; public static HashMap ENCHANTS = new HashMap<>(); - public static HashMap UTILITEMS; @Override diff --git a/src/main/java/net/momirealms/customfishing/manager/CompetitionManager.java b/src/main/java/net/momirealms/customfishing/manager/CompetitionManager.java index 7c2c3b04..1109a6d8 100644 --- a/src/main/java/net/momirealms/customfishing/manager/CompetitionManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/CompetitionManager.java @@ -1,3 +1,20 @@ +/* + * 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.manager; import net.momirealms.customfishing.competition.CompetitionConfig; diff --git a/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java b/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java index 0c0ae5ff..cadbdc32 100644 --- a/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java @@ -1,3 +1,20 @@ +/* + * 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.manager; import net.momirealms.customfishing.integration.VaultHook; @@ -25,8 +42,6 @@ public class ConfigManager { public static boolean enableMcMMOLoot; public static double vanillaLootRatio; public static double mcMMOLootChance; - public static boolean needOpenWater; - public static boolean needRodForLoots; public static boolean needRodToFish; public static boolean rodLoseDurability; public static boolean enableCompetition; @@ -35,13 +50,11 @@ public class ConfigManager { public static boolean preventPickUp; public static boolean enableFishingBag; public static boolean alwaysFishingBar; - public static String[] successTitle; public static String[] successSubTitle; public static int successFadeIn; public static int successFadeStay; public static int successFadeOut; - public static String[] failureTitle; public static String[] failureSubTitle; public static int failureFadeIn; @@ -83,9 +96,7 @@ public class ConfigManager { vanillaLootRatio = config.getDouble("mechanics.other-loots.vanilla.ratio", 0.4); enableMcMMOLoot = config.getBoolean("mechanics.other-loots.mcMMO.enable", false); mcMMOLootChance = config.getDouble("mechanics.other-loots.mcMMO.chance", 0.5); - needOpenWater = config.getBoolean("mechanics.need-open-water", true); - needRodForLoots = config.getBoolean("mechanics.need-special-rod.for-loots", false); - needRodToFish = config.getBoolean("mechanics.need-special-rod.to-fish", false); + needRodToFish = config.getBoolean("mechanics.need-special-rod-to-fish", false); rodLoseDurability = config.getBoolean("mechanics.rod-lose-durability", true); enableCompetition = config.getBoolean("mechanics.fishing-competition.enable", true); @@ -125,13 +136,6 @@ public class ConfigManager { JedisUtil.initializeRedis(configuration); useRedis = true; } - - if (vaultHook) { - if (!VaultHook.initialize()) { - vaultHook = false; - AdventureUtil.consoleMessage("[CustomFishing] Failed to hook into Vault!"); - } - } } public static List getWorldsList() { if (whiteOrBlack) { diff --git a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java index 26e7e45c..9893e368 100644 --- a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java @@ -1,3 +1,20 @@ +/* + * 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.manager; import de.tr7zw.changeme.nbtapi.NBTCompound; @@ -67,7 +84,7 @@ public class FishingManager extends Function { private final HashMap vanillaLoot; private final ConcurrentHashMap fishingPlayerCache; private final ConcurrentHashMap totemCache; - private final ConcurrentHashMap lavaFishing; + private final ConcurrentHashMap bobberTaskCache; public FishingManager() { this.playerFishListener = new PlayerFishListener(this); @@ -79,7 +96,7 @@ public class FishingManager extends Function { this.vanillaLoot = new HashMap<>(); this.fishingPlayerCache = new ConcurrentHashMap<>(); this.totemCache = new ConcurrentHashMap<>(); - this.lavaFishing = new ConcurrentHashMap<>(); + this.bobberTaskCache = new ConcurrentHashMap<>(); load(); } @@ -108,6 +125,9 @@ public class FishingManager extends Function { if (this.pickUpListener != null) HandlerList.unregisterAll(this.pickUpListener); if (this.mmoItemsListener != null) HandlerList.unregisterAll(this.mmoItemsListener); if (this.jobsRebornXPListener != null) HandlerList.unregisterAll(this.jobsRebornXPListener); + for (BobberCheckTask bobberCheckTask : bobberTaskCache.values()) { + bobberCheckTask.stop(); + } } public void onFishing(PlayerFishEvent event) { @@ -214,6 +234,7 @@ public class FishingManager extends Function { if (baitBonus != null) { initialBonus.addBonus(baitBonus); itemStack.setAmount(itemStack.getAmount() - 1); + break; } } } @@ -230,17 +251,14 @@ public class FishingManager extends Function { nextBonus.put(player, initialBonus); - if (ConfigManager.needRodForLoots && noSpecialRod){ - if (!ConfigManager.enableVanillaLoot) AdventureUtil.playerMessage(player, MessageManager.prefix + MessageManager.noRod); - nextLoot.put(player, null); - } if (ConfigManager.needRodToFish && noSpecialRod){ nextLoot.put(player, Loot.EMPTY); + return; } - if ((ConfigManager.needRodForLoots || ConfigManager.needRodToFish) && noSpecialRod) return; BobberCheckTask bobberCheckTask = new BobberCheckTask(player, initialBonus, fishHook, this, lureLevel); bobberCheckTask.runTaskTimer(CustomFishing.plugin, 1, 1); + bobberTaskCache.put(player, bobberCheckTask); }); } @@ -304,11 +322,14 @@ public class FishingManager extends Function { FishingPlayer fishingPlayer = fishingPlayerCache.remove(player); if (fishingPlayer == null) { + + Loot loot = nextLoot.get(player); + if (loot == Loot.EMPTY) return; + if (ConfigManager.enableVanillaLoot) { // Not a vanilla loot if (ConfigManager.vanillaLootRatio < Math.random()) { event.setCancelled(true); - Loot loot = nextLoot.get(player); if (loot != null) { vanillaLoot.remove(player); } @@ -329,7 +350,6 @@ public class FishingManager extends Function { } else { // No custom loot - Loot loot = nextLoot.get(player); if (loot == null) { item.remove(); event.setExpToDrop(0); @@ -354,14 +374,12 @@ public class FishingManager extends Function { VanillaLoot vanilla = vanillaLoot.remove(player); player.removePotionEffect(PotionEffectType.SLOW); - if (ConfigManager.needOpenWater && !event.getHook().isInOpenWater()){ - AdventureUtil.playerMessage(player, MessageManager.prefix + MessageManager.notOpenWater); - return; - } - if (fishingPlayer.isSuccess()) { if (ConfigManager.rodLoseDurability) loseDurability(player); Location location = event.getHook().getLocation(); + if (location.getBlock().getType() == Material.LAVA) { + location.add(0,0.3,0); + } if (vanilla != null) { dropVanillaLoot(player, vanilla, location, fishingPlayer.isDouble()); return; @@ -389,10 +407,11 @@ public class FishingManager extends Function { FishingPlayer fishingPlayer = fishingPlayerCache.remove(player); if (fishingPlayer != null) { proceedReelIn(event, player, fishingPlayer); - lavaFishing.remove(player); + bobberTaskCache.remove(player); return; } - if (lavaFishing.containsKey(player)) { + BobberCheckTask bobberCheckTask = bobberTaskCache.get(player); + if (bobberCheckTask != null && bobberCheckTask.isHooked()) { showPlayerBar(player, nextLoot.get(player)); event.setCancelled(true); } @@ -465,9 +484,9 @@ public class FishingManager extends Function { if (itemStack.getType() == Material.AIR) return; Entity item = location.getWorld().dropItem(location, itemStack); Vector vector = player.getLocation().subtract(location).toVector().multiply(0.1); - vector = vector.setY((vector.getY()+0.2) * 1.2); + vector = vector.setY((vector.getY()+0.25) * 1.2); item.setVelocity(vector); - if (isDouble){ + if (isDouble) { Entity item2 = location.getWorld().dropItem(location, itemStack); item2.setVelocity(vector); } @@ -852,7 +871,7 @@ public class FishingManager extends Function { nextLoot.remove(player); nextBonus.remove(player); vanillaLoot.remove(player); - BobberCheckTask task = lavaFishing.remove(player); + BobberCheckTask task = bobberTaskCache.remove(player); if (task != null) task.stop(); // prevent bar duplication FishHook fishHook = hooksCache.remove(player); @@ -887,10 +906,10 @@ public class FishingManager extends Function { } public void addPlayerToLavaFishing(Player player, BobberCheckTask task) { - this.lavaFishing.put(player, task); + this.bobberTaskCache.put(player, task); } public void removePlayerFromLavaFishing(Player player) { - this.lavaFishing.remove(player); + this.bobberTaskCache.remove(player); } } diff --git a/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java b/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java index ff21afd2..557ec3bd 100644 --- a/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java @@ -1,3 +1,20 @@ +/* + * 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.manager; import net.momirealms.customfishing.helper.Log; @@ -50,6 +67,14 @@ public class IntegrationManager extends Function { YamlConfiguration config = ConfigUtil.getConfig("config.yml"); + if (ConfigManager.vaultHook) { + if (!VaultHook.initialize()) { + ConfigManager.vaultHook = false; + Log.warn("Failed to initialize Vault!"); + } + else hookMessage("Vault"); + } + this.blockInterface = new VanillaBlockImpl(); List itemInterfaceList = new ArrayList<>(); diff --git a/src/main/java/net/momirealms/customfishing/manager/LayoutManager.java b/src/main/java/net/momirealms/customfishing/manager/LayoutManager.java index ed899287..7adc05fd 100644 --- a/src/main/java/net/momirealms/customfishing/manager/LayoutManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/LayoutManager.java @@ -1,3 +1,20 @@ +/* + * 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.manager; import net.momirealms.customfishing.object.Function; diff --git a/src/main/java/net/momirealms/customfishing/manager/LootManager.java b/src/main/java/net/momirealms/customfishing/manager/LootManager.java index 640d6ccb..4f9e48e9 100644 --- a/src/main/java/net/momirealms/customfishing/manager/LootManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/LootManager.java @@ -1,3 +1,20 @@ +/* + * 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.manager; import net.momirealms.customfishing.CustomFishing; @@ -78,7 +95,7 @@ public class LootManager extends Function { difficulty, time, weight, - config.getString(key + ".mythicmobsID", key), + config.getString(key + ".mobID", key), config.getInt(key + ".level", 0), new MobVector( config.getDouble(key + ".vector.horizontal",1.1), diff --git a/src/main/java/net/momirealms/customfishing/manager/MessageManager.java b/src/main/java/net/momirealms/customfishing/manager/MessageManager.java index 5f7015ec..ccf158fb 100644 --- a/src/main/java/net/momirealms/customfishing/manager/MessageManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/MessageManager.java @@ -1,3 +1,20 @@ +/* + * 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.manager; import net.momirealms.customfishing.util.ConfigUtil; diff --git a/src/main/java/net/momirealms/customfishing/manager/SellManager.java b/src/main/java/net/momirealms/customfishing/manager/SellManager.java index 26d2c67e..008b4cd1 100644 --- a/src/main/java/net/momirealms/customfishing/manager/SellManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/SellManager.java @@ -1,3 +1,20 @@ +/* + * 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.manager; import com.comphenix.protocol.events.PacketContainer; @@ -207,13 +224,13 @@ public class SellManager extends Function { } } } - if (update && !isCoolDown(player, 1000)) { - Bukkit.getScheduler().runTaskLater(CustomFishing.plugin, () -> { + if (update) { + Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> { ItemStack icon = ItemStackUtil.getFromItem(sellIcon.cloneWithPrice(getTotalPrice(getPlayerItems(inventory)))); for (int slot : functionIconSlots) { inventory.setItem(slot, icon); } - }, 1); + }); } } diff --git a/src/main/java/net/momirealms/customfishing/manager/TotemManager.java b/src/main/java/net/momirealms/customfishing/manager/TotemManager.java index bb349bb3..7a9ba04e 100644 --- a/src/main/java/net/momirealms/customfishing/manager/TotemManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/TotemManager.java @@ -1,3 +1,20 @@ +/* + * 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.manager; import net.momirealms.customfishing.CustomFishing; diff --git a/src/main/java/net/momirealms/customfishing/object/Function.java b/src/main/java/net/momirealms/customfishing/object/Function.java index 69c0f77d..fd8517e3 100644 --- a/src/main/java/net/momirealms/customfishing/object/Function.java +++ b/src/main/java/net/momirealms/customfishing/object/Function.java @@ -1,3 +1,20 @@ +/* + * 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.object; import com.comphenix.protocol.events.PacketContainer; 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 e0951589..709715ff 100644 --- a/src/main/java/net/momirealms/customfishing/object/action/ActionInterface.java +++ b/src/main/java/net/momirealms/customfishing/object/action/ActionInterface.java @@ -1,3 +1,20 @@ +/* + * 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.object.action; import org.bukkit.entity.Player; 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 1b5530a7..f5f9dd08 100644 --- a/src/main/java/net/momirealms/customfishing/object/action/CommandActionImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/action/CommandActionImpl.java @@ -1,3 +1,20 @@ +/* + * 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.object.action; import net.momirealms.customfishing.CustomFishing; 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 88ffd246..689e5e22 100644 --- a/src/main/java/net/momirealms/customfishing/object/action/MessageActionImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/action/MessageActionImpl.java @@ -1,3 +1,20 @@ +/* + * 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.object.action; import net.momirealms.customfishing.util.AdventureUtil; 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 9e63bc09..c2a0ea3b 100644 --- a/src/main/java/net/momirealms/customfishing/object/action/SkillXPImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/action/SkillXPImpl.java @@ -1,12 +1,32 @@ +/* + * 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.object.action; import net.momirealms.customfishing.CustomFishing; +import net.momirealms.customfishing.integration.SkillInterface; import org.bukkit.entity.Player; public record SkillXPImpl(double amount) implements ActionInterface { @Override public void doOn(Player player, Player another) { - CustomFishing.plugin.getIntegrationManager().getSkillInterface().addXp(player, amount); + SkillInterface skillInterface = CustomFishing.plugin.getIntegrationManager().getSkillInterface(); + if (skillInterface == null) return; + skillInterface.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 af19db0a..27ac83a3 100644 --- a/src/main/java/net/momirealms/customfishing/object/action/SoundActionImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/action/SoundActionImpl.java @@ -1,3 +1,20 @@ +/* + * 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.object.action; import net.kyori.adventure.key.Key; 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 ab99c12c..d83fe9f4 100644 --- a/src/main/java/net/momirealms/customfishing/object/action/VanillaXPImpl.java +++ b/src/main/java/net/momirealms/customfishing/object/action/VanillaXPImpl.java @@ -1,3 +1,20 @@ +/* + * 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.object.action; import net.kyori.adventure.key.Key; diff --git a/src/main/java/net/momirealms/customfishing/object/fishing/BobberCheckTask.java b/src/main/java/net/momirealms/customfishing/object/fishing/BobberCheckTask.java index 4a3548cf..102501f8 100644 --- a/src/main/java/net/momirealms/customfishing/object/fishing/BobberCheckTask.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/BobberCheckTask.java @@ -1,12 +1,36 @@ +/* + * 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.object.fishing; +import com.plotsquared.core.plot.PlotId; +import net.kyori.adventure.key.Key; +import net.kyori.adventure.sound.Sound; import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.manager.ConfigManager; import net.momirealms.customfishing.manager.FishingManager; import net.momirealms.customfishing.manager.LootManager; +import net.momirealms.customfishing.manager.MessageManager; import net.momirealms.customfishing.object.loot.Loot; +import net.momirealms.customfishing.util.AdventureUtil; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.FishHook; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -30,6 +54,7 @@ public class BobberCheckTask extends BukkitRunnable { private BukkitTask cache_1; private BukkitTask cache_2; private BukkitTask cache_3; + private ArmorStand entityCache; public BobberCheckTask(Player player, Bonus bonus, FishHook fishHook, FishingManager fishingManager, int lureLevel) { this.fishHook = fishHook; @@ -45,6 +70,9 @@ public class BobberCheckTask extends BukkitRunnable { @Override public void run() { timer ++; + if (timer > 3600) { + stop(); + } if (!fishHook.isValid()) { stop(); return; @@ -56,7 +84,7 @@ public class BobberCheckTask extends BukkitRunnable { } if (hooked) { jump_timer++; - if (jump_timer < 5) { + if (jump_timer < 4) { return; } jump_timer = 0; @@ -64,32 +92,38 @@ public class BobberCheckTask extends BukkitRunnable { return; } if (first_time) { + if (jump_timer < 8) { + jump_timer++; + fishHook.setVelocity(new Vector(0,0.18 - jump_timer * 0.01,0)); + return; + } first_time = false; randomTime(); + spawnArmorStand(fishHook.getLocation()); } - fishHook.setVelocity(new Vector(0, 0.12,0)); return; } if (fishHook.isInWater()) { + stop(); Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> { List possibleLoots = fishingManager.getPossibleLootList(new FishingCondition(fishHook.getLocation(), player), false, LootManager.WATERLOOTS.values()); fishingManager.getNextLoot(player, bonus, possibleLoots); }); - stop(); return; } if (fishHook.isOnGround()) { stop(); - return; - } - if (timer > 2400) { - stop(); } } public void stop() { cancel(); cancelTask(); + fishingManager.removePlayerFromLavaFishing(player); + if (entityCache != null && !entityCache.isDead()) { + entityCache.remove(); + entityCache = null; + } } public void cancelTask() { @@ -119,13 +153,32 @@ public class BobberCheckTask extends BukkitRunnable { if (random < ConfigManager.lavaMinTime) random = ConfigManager.lavaMinTime; cache_1 = Bukkit.getScheduler().runTaskLater(CustomFishing.plugin, () -> { hooked = true; - fishingManager.addPlayerToLavaFishing(player, this); + if (entityCache != null && !entityCache.isDead()) entityCache.remove(); + AdventureUtil.playerSound(player, Sound.Source.NEUTRAL, Key.key("minecraft:block.pointed_dripstone.drip_lava_into_cauldron"), 1, 1); }, random); cache_2 = Bukkit.getScheduler().runTaskLater(CustomFishing.plugin, () -> { hooked = false; first_time = true; - fishingManager.removePlayerFromLavaFishing(player); }, random + 40); cache_3 = new LavaEffect(fishHook.getLocation()).runTaskTimerAsynchronously(CustomFishing.plugin,random - 60,1); } + + private void spawnArmorStand(Location armorLoc) { + armorLoc.setY(armorLoc.getBlockY() + 0.2); + if (entityCache != null && !entityCache.isDead()) entityCache.remove(); + entityCache = armorLoc.getWorld().spawn(armorLoc, ArmorStand.class, a -> { + a.setInvisible(true); + a.setCollidable(false); + a.setInvulnerable(true); + a.setVisible(false); + a.setCustomNameVisible(false); + a.setSmall(true); + a.setGravity(false); + }); + fishHook.setHookedEntity(entityCache); + } + + public boolean isHooked() { + return hooked; + } } diff --git a/src/main/java/net/momirealms/customfishing/object/fishing/Bonus.java b/src/main/java/net/momirealms/customfishing/object/fishing/Bonus.java index c49bd470..bfe9614e 100644 --- a/src/main/java/net/momirealms/customfishing/object/fishing/Bonus.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/Bonus.java @@ -1,3 +1,20 @@ +/* + * 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.object.fishing; import java.util.HashMap; diff --git a/src/main/java/net/momirealms/customfishing/object/fishing/FishResult.java b/src/main/java/net/momirealms/customfishing/object/fishing/FishResult.java index 9372599b..ccaf439f 100644 --- a/src/main/java/net/momirealms/customfishing/object/fishing/FishResult.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/FishResult.java @@ -1,3 +1,20 @@ +/* + * 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.object.fishing; public enum FishResult { diff --git a/src/main/java/net/momirealms/customfishing/object/fishing/FishingPlayer.java b/src/main/java/net/momirealms/customfishing/object/fishing/FishingPlayer.java index 30d59e4d..49cca6d3 100644 --- a/src/main/java/net/momirealms/customfishing/object/fishing/FishingPlayer.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/FishingPlayer.java @@ -1,3 +1,20 @@ +/* + * 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.object.fishing; import net.momirealms.customfishing.CustomFishing; diff --git a/src/main/java/net/momirealms/customfishing/object/fishing/LavaEffect.java b/src/main/java/net/momirealms/customfishing/object/fishing/LavaEffect.java index 6b173342..b235caec 100644 --- a/src/main/java/net/momirealms/customfishing/object/fishing/LavaEffect.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/LavaEffect.java @@ -1,10 +1,26 @@ +/* + * 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.object.fishing; import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.scheduler.BukkitRunnable; - public class LavaEffect extends BukkitRunnable { private final Location startLoc; diff --git a/src/main/java/net/momirealms/customfishing/object/fishing/VanillaLoot.java b/src/main/java/net/momirealms/customfishing/object/fishing/VanillaLoot.java index bb4a95ed..9af20c53 100644 --- a/src/main/java/net/momirealms/customfishing/object/fishing/VanillaLoot.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/VanillaLoot.java @@ -1,3 +1,20 @@ +/* + * 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.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 e43ad3ac..8fa9161e 100644 --- a/src/main/java/net/momirealms/customfishing/object/loot/DroppedItem.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/DroppedItem.java @@ -1,3 +1,20 @@ +/* + * 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.object.loot; import net.momirealms.customfishing.object.fishing.Difficulty; diff --git a/src/main/java/net/momirealms/customfishing/object/loot/Item.java b/src/main/java/net/momirealms/customfishing/object/loot/Item.java index d1b79ba6..735b9505 100644 --- a/src/main/java/net/momirealms/customfishing/object/loot/Item.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/Item.java @@ -1,3 +1,20 @@ +/* + * 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.object.loot; import org.bukkit.Material; 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 7b3cc189..efbd4975 100644 --- a/src/main/java/net/momirealms/customfishing/object/loot/Loot.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/Loot.java @@ -1,3 +1,20 @@ +/* + * 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.object.loot; import net.momirealms.customfishing.object.action.ActionInterface; 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 3be9856a..25695e0d 100644 --- a/src/main/java/net/momirealms/customfishing/object/loot/Mob.java +++ b/src/main/java/net/momirealms/customfishing/object/loot/Mob.java @@ -1,3 +1,20 @@ +/* + * 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.object.loot; import net.momirealms.customfishing.object.fishing.Difficulty; diff --git a/src/main/java/net/momirealms/customfishing/object/totem/ActivatedTotem.java b/src/main/java/net/momirealms/customfishing/object/totem/ActivatedTotem.java index 4ed9af00..6d5457c8 100644 --- a/src/main/java/net/momirealms/customfishing/object/totem/ActivatedTotem.java +++ b/src/main/java/net/momirealms/customfishing/object/totem/ActivatedTotem.java @@ -1,3 +1,20 @@ +/* + * 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.object.totem; import net.momirealms.customfishing.CustomFishing; diff --git a/src/main/java/net/momirealms/customfishing/object/totem/TotemParticle.java b/src/main/java/net/momirealms/customfishing/object/totem/TotemParticle.java index e1d09c17..22464ab3 100644 --- a/src/main/java/net/momirealms/customfishing/object/totem/TotemParticle.java +++ b/src/main/java/net/momirealms/customfishing/object/totem/TotemParticle.java @@ -1,3 +1,20 @@ +/* + * 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.object.totem; import org.bukkit.Location; diff --git a/src/main/java/net/momirealms/customfishing/util/ArmorStandUtil.java b/src/main/java/net/momirealms/customfishing/util/ArmorStandUtil.java index ed6b9545..ef480354 100644 --- a/src/main/java/net/momirealms/customfishing/util/ArmorStandUtil.java +++ b/src/main/java/net/momirealms/customfishing/util/ArmorStandUtil.java @@ -1,3 +1,20 @@ +/* + * 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 com.comphenix.protocol.PacketType; diff --git a/src/main/java/net/momirealms/customfishing/util/BlockUtil.java b/src/main/java/net/momirealms/customfishing/util/BlockUtil.java new file mode 100644 index 00000000..57cb8277 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/util/BlockUtil.java @@ -0,0 +1,13 @@ +package net.momirealms.customfishing.util; + +import org.bukkit.Location; + +public class BlockUtil { + + public static void isInOpenLava(Location location) { + + + + } + +} diff --git a/src/main/java/net/momirealms/customfishing/util/ConfigUtil.java b/src/main/java/net/momirealms/customfishing/util/ConfigUtil.java index 7f04164f..f21055ba 100644 --- a/src/main/java/net/momirealms/customfishing/util/ConfigUtil.java +++ b/src/main/java/net/momirealms/customfishing/util/ConfigUtil.java @@ -1,3 +1,20 @@ +/* + * 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 dev.dejvokep.boostedyaml.YamlDocument; diff --git a/src/main/java/net/momirealms/customfishing/util/InventoryUtil.java b/src/main/java/net/momirealms/customfishing/util/InventoryUtil.java index d7e990dd..3e4c9fd4 100644 --- a/src/main/java/net/momirealms/customfishing/util/InventoryUtil.java +++ b/src/main/java/net/momirealms/customfishing/util/InventoryUtil.java @@ -1,8 +1,26 @@ +/* + * 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 org.bukkit.inventory.ItemStack; import org.bukkit.util.io.BukkitObjectInputStream; import org.bukkit.util.io.BukkitObjectOutputStream; +import org.jetbrains.annotations.Nullable; import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; import java.io.ByteArrayInputStream; @@ -11,15 +29,17 @@ import java.io.IOException; public class InventoryUtil { + @Nullable public static String toBase64(ItemStack[] contents) { boolean convert = false; - for (ItemStack item : contents) { - if (item != null) { + for (ItemStack content : contents) { + if (content != null) { convert = true; break; } } + if (convert) { try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); @@ -27,19 +47,20 @@ public class InventoryUtil { dataOutput.writeInt(contents.length); - for (ItemStack stack : contents) { - dataOutput.writeObject(stack); + for (ItemStack itemStack : contents) { + dataOutput.writeObject(itemStack); } dataOutput.close(); byte[] byteArr = outputStream.toByteArray(); return Base64Coder.encodeLines(byteArr); - } catch (Exception e) { - throw new IllegalStateException("Unable to save item stacks.", e); + } catch (IOException e) { + throw new RuntimeException("[CustomFishing] Data save error", e); } } return null; } + @Nullable public static ItemStack[] getInventoryItems(String base64) { ItemStack[] itemStacks = null; try { @@ -51,7 +72,7 @@ public class InventoryUtil { } private static ItemStack[] stacksFromBase64(String data) { - if (data == null) return new ItemStack[]{}; + if (data == null || data.equals("")) return new ItemStack[]{}; ByteArrayInputStream inputStream; try { diff --git a/src/main/java/net/momirealms/customfishing/util/ItemStackUtil.java b/src/main/java/net/momirealms/customfishing/util/ItemStackUtil.java index cad2cd70..3b49ec2d 100644 --- a/src/main/java/net/momirealms/customfishing/util/ItemStackUtil.java +++ b/src/main/java/net/momirealms/customfishing/util/ItemStackUtil.java @@ -1,3 +1,20 @@ +/* + * 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 de.tr7zw.changeme.nbtapi.NBTCompound; diff --git a/src/main/java/net/momirealms/customfishing/util/JedisUtil.java b/src/main/java/net/momirealms/customfishing/util/JedisUtil.java index 18c65837..e17bbf2a 100644 --- a/src/main/java/net/momirealms/customfishing/util/JedisUtil.java +++ b/src/main/java/net/momirealms/customfishing/util/JedisUtil.java @@ -1,3 +1,20 @@ +/* + * 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.helper.Log; diff --git a/src/main/java/net/momirealms/customfishing/util/NBTUtil.java b/src/main/java/net/momirealms/customfishing/util/NBTUtil.java index 13c5d6a3..45159450 100644 --- a/src/main/java/net/momirealms/customfishing/util/NBTUtil.java +++ b/src/main/java/net/momirealms/customfishing/util/NBTUtil.java @@ -1,3 +1,20 @@ +/* + * 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 de.tr7zw.changeme.nbtapi.NBTCompound; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 43027849..f70200b8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -37,8 +37,10 @@ integrations: MMOItems: false # Worlds where fishing mechanic takes effects +# 启用本插件的世界 worlds: # Mode: whitelist/blacklist + # 模式:白名单/黑名单 mode: whitelist list: - world @@ -48,47 +50,55 @@ worlds: mechanics: other-loots: # Should other loots have the same fishing mechanic CustomFishing provides + # 其他战利品是否有插件提供的钓鱼特性 fishing-bar: true + # 原版战利品 vanilla: - # Vanilla loot is available only when 'double-reel-in' is true enable: true - # 0.4 means 40% of the loots are from vanilla - # and 60% are from CustomFishing Loot system + # 0.4 means 40% of the loots are from vanilla and 60% are from CustomFishing Loot system + # if there's no custom loot, it would definitely be a vanilla loot + # 0.4代表40%的战利品来自于原版,60%来自CustomFishing物品库 + # 如果钓鱼的地方没有自定义战利品,那么下一个一定是原版战利品 ratio: 0.4 mcMMO: # mcMMO treasure system # chance represents the chance to try to be a mcMMO treasure # But it doesn't mean 50% chance of the loot would be mcMMO treasure # mcMMO has a complex treasure system + # mcMMO宝藏系统 + # 概率代表尝试变成mcMMO宝藏的概率,但这不意味着50%概率一定会变成mcMMO宝藏 enable: false chance: 0.5 - # The same to vanilla mechanic (refer to the wiki) - # https://technical-minecraft.fandom.com/wiki/Fishing - need-open-water: false - need-special-rod: - # Players must use rods with CustomFishing's NBT Tags to get loots in CustomFishing but they can experience the special fishing mechanic. - for-loots: false - # Players must use rods with CustomFishing's NBT Tags to experience the special fishing mechanic. Otherwise they can only fish in a vanilla way - to-fish: false - # does rod lose durability when player successfully fish + # Does the special fishing mechanic requires special rod + # 是否需要特殊鱼竿才能体验钓鱼机制 + need-special-rod-to-fish: false + # Does rod lose durability when player successfully fish + # 钓鱼成功后是否消耗耐久度 rod-lose-durability: true # Competition + # 钓鱼比赛 fishing-competition: enable: true - # Enable redis server for syncing data between servers + # Enable redis server to sync data between servers + # 启用Redis服务器以跨服同步比赛数据 redis: false # Fishing bag is a place where players can store their baits, utils, rods (Fish optional) + # 渔具袋是玩家存放鱼饵,实用道具,鱼竿的地方,其中的鱼饵会在钓鱼时被消耗 fishing-bag: enable: true + # Fishing bag window title + # 渔具袋的容器标题 bag-title: '{player}''s Fishing Bag' + # Can fishing bag store the loots? # This would add additional NBT Tags to the loot + # 渔具袋是否能存放捕鱼战利品,这会在捕鱼战利品上增加额外NBT can-store-loot: false - # File/MySql - data-storage-mode: File # Other whitelist-items + # 允许放入渔具袋的其他物品白名单 whitelist-items: - fishing_rod # Lava fishing settings + # 岩浆钓鱼设置 lava-fishing: # ticks min-wait-time: 100 @@ -103,7 +113,7 @@ titles: - 'Good Job!' subtitle: - 'You have captured a {loot}' - - 'Hi Harm Hi {loot} Here we go!' + - '{loot} Here we go!' fade: # ticks in: 10 @@ -125,14 +135,19 @@ titles: # Other settings other-settings: # MONITOR HIGHEST HIGH NORMAL LOW LOWEST + # 事件优先级 event-priority: NORMAL # If enabled, players would not be able to get job exp in vanilla way + # 如果启用,玩家则无法通过原版方式获得Jobs经验 disable-JobsReborn-fishing-exp: false # Convert MMOItems' rod into CustomFishing's rod # keep the same key name both in MMOItems and CustomFishing so rods can extend the bonus of those in CustomFishing + # 将MMOItems中的鱼竿转换为CustomFishing的鱼竿,只需要保持相同的键名即可继承效果 convert-MMOItems-rods: false # Prevent other players to pick up your fishing loot # This is useful for players to fish in a public area + # 防止其他玩家抢夺捕鱼战利品 prevent-other-players-pick-up-loot: false # Log the money player get from selling the fish in the console + # 后台记录玩家销售鱼类所得金额 log-earnings: true \ No newline at end of file diff --git a/src/main/resources/database.yml b/src/main/resources/database.yml index 7512884a..3bcdef03 100644 --- a/src/main/resources/database.yml +++ b/src/main/resources/database.yml @@ -1,3 +1,7 @@ +# YAML/MySQL/MariaDB +# 存储模式 +data-storage-method: YAML + # MySQL settings MySQL: host: localhost @@ -5,15 +9,31 @@ MySQL: user: root password: password database: minecraft - table-name: customfishing_data - property: - use-ssl: false - encoding: utf8 - timezone: '' - allowPublicKeyRetrieval: false - # Connection pool settings + table-prefix: customfishing + properties: + cachePrepStmts: 'true' + prepStmtCacheSize: '250' + prepStmtCacheSqlLimit: '2048' + useSSL: 'false' + verifyServerCertificate: 'false' + Pool-Settings: + maximum-pool-size: 10 + minimum-idle: 10 + maximum-lifetime: 180000 + idle-timeout: 60000 + +MariaDB: + host: localhost + port: 3306 + user: root + password: password + database: minecraft + table-prefix: customfishing + properties: + cachePrepStmts: 'true' + prepStmtCacheSize: '250' + prepStmtCacheSqlLimit: '2048' Pool-Settings: - enable: false maximum-pool-size: 10 minimum-idle: 10 maximum-lifetime: 180000 diff --git a/src/main/resources/enchant-bonus.yml b/src/main/resources/enchant-bonus.yml index 7b27a107..e693dd44 100644 --- a/src/main/resources/enchant-bonus.yml +++ b/src/main/resources/enchant-bonus.yml @@ -3,15 +3,15 @@ minecraft:luck_of_the_sea: #levels 1: - weight-PM: + weight-add: silver: 2 gold: 1 2: - weight-PM: + weight-add: silver: 3 gold: 2 3: - weight-PM: + weight-add: silver: 4 gold: 3 diff --git a/src/main/resources/messages/messages_chinese.yml b/src/main/resources/messages/messages_chinese.yml index 8703a002..450c7f4d 100644 --- a/src/main/resources/messages/messages_chinese.yml +++ b/src/main/resources/messages/messages_chinese.yml @@ -18,7 +18,6 @@ messages: possible-loots: '此处可能钓到: ' split-char: ',' no-loot: '这个地方什么鱼都没有!' - not-open-water: '这里不是开放水域,你将无法获得任何奖励!' competition-ongoing: '当前有一场钓鱼比赛进行中! 开始钓鱼以加入比赛获取奖励!' players-not-enough: '玩家数量不足,钓鱼比赛无法如期举行!' no-rank: '未上榜' diff --git a/src/main/resources/messages/messages_english.yml b/src/main/resources/messages/messages_english.yml index 3b0a7746..d432c82c 100644 --- a/src/main/resources/messages/messages_english.yml +++ b/src/main/resources/messages/messages_english.yml @@ -18,7 +18,6 @@ messages: possible-loots: 'Possible loots here: ' split-char: ', ' no-loot: 'There''s no fish in this place!' - not-open-water: 'This is not open water and you will not be able to get any rewards!' competition-ongoing: 'There is currently a fishing tournament in progress! Start fishing to join the contest for a prize!' players-not-enough: 'The number of players is not enough for the fishing contest to be held as scheduled!' no-rank: 'No Rank' diff --git a/src/main/resources/messages/messages_spanish.yml b/src/main/resources/messages/messages_spanish.yml index e3fb5e9b..30a6bb06 100644 --- a/src/main/resources/messages/messages_spanish.yml +++ b/src/main/resources/messages/messages_spanish.yml @@ -5,8 +5,8 @@ messages: reload: 'Recarga con éxito.' no-perm: 'No tienes permiso.' not-online: 'Los jugadores no están en línea.' - item-not-exist: '此物品不存在!' - player-not-exist: '此玩家不存在!' + item-not-exist: 'Ese itemartículo no existe!' + player-not-exist: 'Ese jugador no existe!' escape: 'Ha pasado demasiado tiempo desde que tiré del anzuelo y el pez huyó.' give-item: 'Se dio con éxito a los jugadores {Player} {Amount}x {Item}.' get-item: 'Obtenido con éxito {Amount}x {Item}.' @@ -18,7 +18,6 @@ messages: possible-loots: 'Posible pesca aquí: ' split-char: ', ' no-loot: '¡No hay peces en este lugar!' - not-open-water: 'Esto no son aguas abiertas y no podrás obtener ninguna recompensa.' competition-ongoing: '¡Actualmente hay un torneo de pesca en curso! Empieza a pescar para participar en el concurso y ganar un premio.' players-not-enough: 'El número de jugadores no es suficiente para que el torneo de pesca se celebre como estaba previsto.' no-rank: 'No está en la lista' diff --git a/src/main/resources/mobs/example.yml b/src/main/resources/mobs/example.yml index c934d18b..e55c0c09 100644 --- a/src/main/resources/mobs/example.yml +++ b/src/main/resources/mobs/example.yml @@ -3,7 +3,7 @@ skeletalknight: enable: true # MythicMobsID - mob: SkeletalKnight + mobID: SkeletalKnight # The level of the mob level: 0 @@ -29,7 +29,7 @@ skeletalknight: piranha: enable: false - mob: piranha + mobID: piranha name: 'Piranha' weight: 50 time: 1000000