9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-31 04:46:36 +00:00

I don't want to waste time on resolving conflicts

This commit is contained in:
XiaoMoMi
2024-07-10 03:24:56 +08:00
parent 0ed5d5745a
commit 80594731e6
551 changed files with 29876 additions and 31172 deletions

View File

@@ -0,0 +1,75 @@
repositories {
maven("https://jitpack.io/") // itemsadder
maven("https://mvn.lumine.io/repository/maven-public/") // mythicmobs
maven("https://nexus.phoenixdevt.fr/repository/maven-public/") // mmoitems
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") // papi
maven("https://r.irepo.space/maven/") // neigeitems
maven("https://repo.oraxen.com/releases/") // oraxen
maven("https://repo.auxilor.io/repository/maven-public/") // eco
maven("https://nexus.betonquest.org/repository/betonquest/") // betonquest
maven("https://repo.dmulloy2.net/repository/public/") // betonquest needs packet wrapper?
maven("https://maven.enginehub.org/repo/") // worldguard
}
dependencies {
compileOnly(project(":common"))
compileOnly(project(":api"))
compileOnly("net.kyori:adventure-api:${rootProject.properties["adventure_bundle_version"]}") {
exclude(module = "adventure-bom")
exclude(module = "checker-qual")
exclude(module = "annotations")
}
compileOnly("org.jetbrains:annotations:${rootProject.properties["jetbrains_annotations_version"]}")
// papi
compileOnly("me.clip:placeholderapi:${rootProject.properties["placeholder_api_version"]}")
// server
compileOnly("dev.folia:folia-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT")
// vault
compileOnly("com.github.MilkBowl:VaultAPI:${rootProject.properties["vault_version"]}")
// season
compileOnly("com.github.Xiao-MoMi:Custom-Crops:3.4.8")
compileOnly(files("libs/RealisticSeasons-api.jar"))
compileOnly(files("libs/AdvancedSeasons-API.jar"))
// enchantment
compileOnly(files("libs/AdvancedEnchantments-api.jar"))
// leveler
compileOnly(files("libs/mcMMO-api.jar"))
compileOnly("net.Indyuce:MMOCore-API:1.12.1-SNAPSHOT")
compileOnly("dev.aurelium:auraskills-api-bukkit:2.0.7")
compileOnly("com.github.Archy-X:AureliumSkills:Beta1.3.21")
compileOnly("com.github.Zrips:Jobs:4.17.2")
// quest
compileOnly(files("libs/BattlePass-4.0.6-api.jar"))
compileOnly(files("libs/ClueScrolls-4.8.7-api.jar"))
compileOnly(files("libs/notquests-5.17.1.jar"))
compileOnly("org.betonquest:betonquest:2.0.1")
// item
compileOnly(files("libs/zaphkiel-2.0.24.jar"))
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.6.1")
compileOnly("net.Indyuce:MMOItems-API:6.10-SNAPSHOT")
compileOnly("io.lumine:MythicLib-dist:1.6.2-SNAPSHOT")
compileOnly("pers.neige.neigeitems:NeigeItems:1.17.13")
compileOnly("io.th0rgal:oraxen:1.168.0")
// entity
compileOnly("io.lumine:Mythic-Dist:5.6.2")
// eco
compileOnly("com.willfp:eco:6.70.1")
compileOnly("com.willfp:EcoJobs:3.56.1")
compileOnly("com.willfp:EcoSkills:3.46.1")
compileOnly("com.willfp:libreforge:4.58.1")
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
dependsOn(tasks.clean)
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.RegisteredServiceProvider;
public class VaultHook {
private static Economy economy;
public static boolean initialize() {
RegisteredServiceProvider<Economy> rsp = Bukkit.getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
economy = rsp.getProvider();
return true;
}
public static Economy getEconomy() {
return economy;
}
public static void deposit(OfflinePlayer player, double amount) {
economy.depositPlayer(player, amount);
}
public static void withdraw(OfflinePlayer player, double amount) {
economy.withdrawPlayer(player, amount);
}
public static double getBalance(OfflinePlayer player) {
return economy.getBalance(player);
}
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.block;
import dev.lone.itemsadder.api.CustomBlock;
import net.momirealms.customfishing.api.integration.BlockProvider;
import net.momirealms.customfishing.api.mechanic.block.BlockDataModifier;
import net.momirealms.customfishing.api.mechanic.context.Context;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class ItemsAdderBlockProvider implements BlockProvider {
@Override
public String identifier() {
return "ItemsAdder";
}
@Override
public BlockData blockData(@NotNull Context<Player> context, @NotNull String id, List<BlockDataModifier> modifiers) {
BlockData blockData = CustomBlock.getBaseBlockData(id);
for (BlockDataModifier modifier : modifiers) {
modifier.apply(context, blockData);
}
return blockData;
}
@Override
public String blockID(@NotNull Block block) {
CustomBlock customBlock = CustomBlock.byAlreadyPlaced(block);
return customBlock == null ? null : customBlock.getId();
}
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.block;
import io.th0rgal.oraxen.api.OraxenBlocks;
import io.th0rgal.oraxen.mechanics.Mechanic;
import net.momirealms.customfishing.api.integration.BlockProvider;
import net.momirealms.customfishing.api.mechanic.block.BlockDataModifier;
import net.momirealms.customfishing.api.mechanic.context.Context;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class OraxenBlockProvider implements BlockProvider {
@Override
public String identifier() {
return "Oraxen";
}
@Override
public BlockData blockData(@NotNull Context<Player> context, @NotNull String id, List<BlockDataModifier> modifiers) {
return null;
}
@Override
public String blockID(@NotNull Block block) {
Mechanic mechanic = OraxenBlocks.getOraxenBlock(block.getBlockData());
if (mechanic == null) return null;
return mechanic.getItemID();
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.enchant;
import net.advancedplugins.ae.api.AEAPI;
import net.momirealms.customfishing.api.integration.EnchantmentProvider;
import net.momirealms.customfishing.common.util.Pair;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class AdvancedEnchantmentsProvider implements EnchantmentProvider {
@Override
public String identifier() {
return "AdvancedEnchantments";
}
@Override
public List<Pair<String, Short>> getEnchants(@NotNull ItemStack itemStack) {
List<Pair<String, Short>> enchants = new ArrayList<>();
for (Map.Entry<String, Integer> entry : AEAPI.getEnchantmentsOnItem(itemStack).entrySet()) {
enchants.add(Pair.of("AE:" + entry.getKey(), entry.getValue().shortValue()));
}
return enchants;
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.enchant;
import net.momirealms.customfishing.api.integration.EnchantmentProvider;
import net.momirealms.customfishing.common.util.Pair;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class VanillaEnchantmentsProvider implements EnchantmentProvider {
@Override
public String identifier() {
return "vanilla";
}
@Override
public List<Pair<String, Short>> getEnchants(@NotNull ItemStack itemStack) {
Map<Enchantment, Integer> enchantments = itemStack.getEnchantments();
List<Pair<String, Short>> enchants = new ArrayList<>(enchantments.size());
for (Map.Entry<Enchantment, Integer> en : enchantments.entrySet()) {
enchants.add(Pair.of(en.getKey().getKey().toString(), en.getValue().shortValue()));
}
return enchants;
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.entity;
import dev.lone.itemsadder.api.CustomEntity;
import net.momirealms.customfishing.api.integration.EntityProvider;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
public class ItemsAdderEntityProvider implements EntityProvider {
@Override
public String identifier() {
return "ItemsAdder";
}
@NotNull
@Override
public Entity spawn(@NotNull Location location, @NotNull String id, @NotNull Map<String, Object> propertyMap) {
CustomEntity customEntity = CustomEntity.spawn(
id,
location,
(Boolean) propertyMap.getOrDefault("frustumCulling", true),
(Boolean) propertyMap.getOrDefault("noBase", false),
(Boolean) propertyMap.getOrDefault("noHitbox", false)
);
return customEntity.getEntity();
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.entity;
import io.lumine.mythic.api.adapters.AbstractLocation;
import io.lumine.mythic.api.mobs.MythicMob;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.bukkit.utils.serialize.Position;
import io.lumine.mythic.core.mobs.ActiveMob;
import net.momirealms.customfishing.api.integration.EntityProvider;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import java.util.Optional;
public class MythicEntityProvider implements EntityProvider {
private MythicBukkit mythicBukkit;
@Override
public String identifier() {
return "MythicMobs";
}
@NotNull
@Override
public Entity spawn(@NotNull Location location, @NotNull String id, @NotNull Map<String, Object> propertyMap) {
if (this.mythicBukkit == null || mythicBukkit.isClosed()) {
this.mythicBukkit = MythicBukkit.inst();
}
Optional<MythicMob> mythicMob = mythicBukkit.getMobManager().getMythicMob(id);
if (mythicMob.isPresent()) {
MythicMob theMob = mythicMob.get();
Position position = Position.of(location);
AbstractLocation abstractLocation = new AbstractLocation(position);
ActiveMob activeMob = theMob.spawn(abstractLocation, (double) propertyMap.getOrDefault("level", 0d));
return activeMob.getEntity().getBukkitEntity();
}
throw new NullPointerException("MythicMobs: " + id + " doesn't exist.");
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.entity;
import net.momirealms.customfishing.api.integration.EntityProvider;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.NotNull;
import java.util.Locale;
import java.util.Map;
public class VanillaEntityProvider implements EntityProvider {
@Override
public String identifier() {
return "vanilla";
}
@NotNull
@Override
public Entity spawn(@NotNull Location location, @NotNull String id, @NotNull Map<String, Object> propertyMap) {
return location.getWorld().spawnEntity(location, EntityType.valueOf(id.toUpperCase(Locale.ENGLISH)));
}
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.item;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.integration.ItemProvider;
import net.momirealms.customfishing.api.mechanic.context.Context;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import static java.util.Objects.requireNonNull;
public class CustomFishingItemProvider implements ItemProvider {
@Override
public String identifier() {
return "CustomFishing";
}
@NotNull
@Override
public ItemStack buildItem(@NotNull Player player, @NotNull String id) {
String[] split = id.split(":", 2);
String finalID;
if (split.length == 1) {
// CustomFishing:ID
finalID = split[0];
} else {
// CustomFishing:TYPE:ID
finalID = split[1];
}
ItemStack itemStack = BukkitCustomFishingPlugin.getInstance().getItemManager().buildInternal(Context.player(player), finalID);
return requireNonNull(itemStack);
}
@Override
public String itemID(@NotNull ItemStack itemStack) {
return BukkitCustomFishingPlugin.getInstance().getItemManager().getCustomFishingItemID(itemStack);
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.item;
import dev.lone.itemsadder.api.CustomStack;
import net.momirealms.customfishing.api.integration.ItemProvider;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.Optional;
import static java.util.Objects.requireNonNull;
public class ItemsAdderItemProvider implements ItemProvider {
@Override
public String identifier() {
return "ItemsAdder";
}
@NotNull
@Override
public ItemStack buildItem(@NotNull Player player, @NotNull String id) {
CustomStack stack = requireNonNull(CustomStack.getInstance(id));
return stack.getItemStack();
}
@Override
public String itemID(@NotNull ItemStack itemStack) {
return Optional.ofNullable(CustomStack.byItemStack(itemStack)).map(CustomStack::getNamespacedID).orElse(null);
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.item;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.momirealms.customfishing.api.integration.ItemProvider;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.Locale;
import static java.util.Objects.requireNonNull;
public class MMOItemsItemProvider implements ItemProvider {
@Override
public String identifier() {
return "MMOItems";
}
@NotNull
@Override
public ItemStack buildItem(@NotNull Player player, @NotNull String id) {
String[] split = id.split(":");
MMOItem mmoItem = MMOItems.plugin.getMMOItem(Type.get(split[0]), split[1].toUpperCase(Locale.ENGLISH));
return mmoItem == null ? new ItemStack(Material.AIR) : requireNonNull(mmoItem.newBuilder().build());
}
@Override
public String itemID(@NotNull ItemStack itemStack) {
NBTItem nbtItem = NBTItem.get(itemStack);
if (!nbtItem.hasTag("MMOITEMS_ITEM_ID")) return null;
return nbtItem.getString("MMOITEMS_ITEM_ID");
}
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.item;
import net.momirealms.customfishing.api.integration.ItemProvider;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class McMMOTreasureProvider implements ItemProvider {
private final Method getMcMMOPlayerMethod;
private final Method getFishingManagerMethod;
private final Method getFishingTreasureMethod;
private final Method getItemStackMethod;
public McMMOTreasureProvider() throws ClassNotFoundException, NoSuchMethodException {
Class<?> userClass = Class.forName("com.gmail.nossr50.util.player.UserManager");
getMcMMOPlayerMethod = userClass.getMethod("getPlayer", Player.class);
Class<?> mcMMOPlayerClass = Class.forName("com.gmail.nossr50.datatypes.player.McMMOPlayer");
getFishingManagerMethod = mcMMOPlayerClass.getMethod("getFishingManager");
Class<?> fishingManagerClass = Class.forName("com.gmail.nossr50.skills.fishing.FishingManager");
getFishingTreasureMethod = fishingManagerClass.getDeclaredMethod("getFishingTreasure");
getFishingTreasureMethod.setAccessible(true);
Class<?> treasureClass = Class.forName("com.gmail.nossr50.datatypes.treasure.Treasure");
getItemStackMethod = treasureClass.getMethod("getDrop");
}
@Override
public String identifier() {
return "mcMMO";
}
@NotNull
@Override
public ItemStack buildItem(@NotNull Player player, @NotNull String id) {
if (!id.equals("treasure")) return new ItemStack(Material.AIR);
ItemStack itemStack = null;
int times = 0;
while (itemStack == null && times < 5) {
try {
Object mcMMOPlayer = getMcMMOPlayerMethod.invoke(null, player);
Object fishingManager = getFishingManagerMethod.invoke(mcMMOPlayer);
Object treasure = getFishingTreasureMethod.invoke(fishingManager);
if (treasure != null) {
itemStack = (ItemStack) getItemStackMethod.invoke(treasure);
}
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
} finally {
times++;
}
}
return itemStack == null ? (Math.random() > 0.5 ? new ItemStack(Material.COD) : (Math.random() > 0.2) ? new ItemStack(Material.SALMON) : new ItemStack(Material.PUFFERFISH)) : itemStack;
}
@Override
public String itemID(@NotNull ItemStack itemStack) {
return null;
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.item;
import io.lumine.mythic.bukkit.MythicBukkit;
import net.momirealms.customfishing.api.integration.ItemProvider;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public class MythicMobsItemProvider implements ItemProvider {
private MythicBukkit mythicBukkit;
@Override
public String identifier() {
return "MythicMobs";
}
@NotNull
@Override
public ItemStack buildItem(@NotNull Player player, @NotNull String id) {
if (mythicBukkit == null || mythicBukkit.isClosed()) {
this.mythicBukkit = MythicBukkit.inst();
}
return mythicBukkit.getItemManager().getItemStack(id);
}
@Override
public String itemID(@NotNull ItemStack itemStack) {
if (mythicBukkit == null || mythicBukkit.isClosed()) {
this.mythicBukkit = MythicBukkit.inst();
}
return mythicBukkit.getItemManager().getMythicTypeFromItem(itemStack);
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.item;
import net.momirealms.customfishing.api.integration.ItemProvider;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import pers.neige.neigeitems.item.ItemInfo;
import pers.neige.neigeitems.manager.ItemManager;
import pers.neige.neigeitems.utils.ItemUtils;
import java.util.Objects;
public class NeigeItemsItemProvider implements ItemProvider {
@Override
public String identifier() {
return "NeigeItems";
}
@NotNull
@Override
public ItemStack buildItem(@NotNull Player player, @NotNull String id) {
return Objects.requireNonNull(ItemManager.INSTANCE.getItemStack(id, player));
}
@Override
public String itemID(@NotNull ItemStack itemStack) {
ItemInfo itemInfo = ItemUtils.isNiItem(itemStack);
if (itemInfo != null) {
return itemInfo.getId();
}
return null;
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.item;
import io.th0rgal.oraxen.api.OraxenItems;
import io.th0rgal.oraxen.items.ItemBuilder;
import net.momirealms.customfishing.api.integration.ItemProvider;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public class OraxenItemProvider implements ItemProvider {
@Override
public String identifier() {
return "Oraxen";
}
@NotNull
@Override
public ItemStack buildItem(@NotNull Player player, @NotNull String id) {
ItemBuilder itemBuilder = OraxenItems.getItemById(id);
return itemBuilder == null ? new ItemStack(Material.AIR) : itemBuilder.build();
}
@Override
public String itemID(@NotNull ItemStack itemStack) {
return OraxenItems.getIdByItem(itemStack);
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.item;
import ink.ptms.zaphkiel.ZapAPI;
import ink.ptms.zaphkiel.Zaphkiel;
import net.momirealms.customfishing.api.integration.ItemProvider;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public class ZaphkielItemProvider implements ItemProvider {
private final ZapAPI zapAPI;
public ZaphkielItemProvider() {
this.zapAPI = Zaphkiel.INSTANCE.api();
}
@Override
public String identifier() {
return "Zaphkiel";
}
@NotNull
@Override
public ItemStack buildItem(@NotNull Player player, @NotNull String id) {
return Objects.requireNonNull(zapAPI.getItemManager().generateItemStack(id, player));
}
@Override
public String itemID(@NotNull ItemStack itemStack) {
if (itemStack == null || itemStack.getType() == Material.AIR) return null;
return zapAPI.getItemHandler().getItemId(itemStack);
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.level;
import dev.aurelium.auraskills.api.AuraSkillsApi;
import dev.aurelium.auraskills.api.registry.NamespacedId;
import net.momirealms.customfishing.api.integration.LevelerProvider;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class AuraSkillsLevelerProvider implements LevelerProvider {
@Override
public String identifier() {
return "AuraSkills";
}
@Override
public void addXp(@NotNull Player player, @NotNull String target, double amount) {
AuraSkillsApi.get().getUser(player.getUniqueId())
.addSkillXp(AuraSkillsApi.get().getGlobalRegistry().getSkill(NamespacedId.fromDefault(target)), amount);
}
@Override
public int getLevel(@NotNull Player player, @NotNull String target) {
return AuraSkillsApi.get().getUser(player.getUniqueId()).getSkillLevel(
AuraSkillsApi.get().getGlobalRegistry().getSkill(NamespacedId.fromDefault(target))
);
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.level;
import com.archyx.aureliumskills.api.AureliumAPI;
import com.archyx.aureliumskills.leveler.Leveler;
import net.momirealms.customfishing.api.integration.LevelerProvider;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class AureliumSkillsProvider implements LevelerProvider {
@Override
public String identifier() {
return "AureliumSkills";
}
private final Leveler leveler;
public AureliumSkillsProvider() {
leveler = AureliumAPI.getPlugin().getLeveler();
}
@Override
public void addXp(@NotNull Player player, @NotNull String target, double amount) {
leveler.addXp(player, AureliumAPI.getPlugin().getSkillRegistry().getSkill(target), amount);
}
@Override
public int getLevel(@NotNull Player player, @NotNull String target) {
return AureliumAPI.getSkillLevel(player, AureliumAPI.getPlugin().getSkillRegistry().getSkill(target));
}
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.level;
import com.willfp.ecojobs.api.EcoJobsAPI;
import com.willfp.ecojobs.jobs.Job;
import com.willfp.ecojobs.jobs.Jobs;
import net.momirealms.customfishing.api.integration.LevelerProvider;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class EcoJobsLevelerProvider implements LevelerProvider {
@Override
public void addXp(@NotNull Player player, @NotNull String target, double amount) {
for (Job job : EcoJobsAPI.getActiveJobs(player)) {
if (job.getId().equals(target)) {
EcoJobsAPI.giveJobExperience(player, job, amount);
}
}
}
@Override
public int getLevel(@NotNull Player player, @NotNull String target) {
Job job = Jobs.getByID(target);
if (job == null) return 0;
return EcoJobsAPI.getJobLevel(player, job);
}
@Override
public String identifier() {
return "EcoJobs";
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.level;
import com.willfp.ecoskills.api.EcoSkillsAPI;
import com.willfp.ecoskills.skills.Skills;
import net.momirealms.customfishing.api.integration.LevelerProvider;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public class EcoSkillsLevelerProvider implements LevelerProvider {
@Override
public void addXp(@NotNull Player player, @NotNull String target, double amount) {
EcoSkillsAPI.gainSkillXP(player, Objects.requireNonNull(Skills.INSTANCE.getByID(target)), amount);
}
@Override
public int getLevel(@NotNull Player player, @NotNull String target) {
return EcoSkillsAPI.getSkillLevel(player, Objects.requireNonNull(Skills.INSTANCE.getByID(target)));
}
@Override
public String identifier() {
return "EcoSkills";
}
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.level;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import net.momirealms.customfishing.api.integration.LevelerProvider;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class JobsRebornLevelerProvider implements LevelerProvider {
@Override
public void addXp(@NotNull Player player, @NotNull String target, double amount) {
JobsPlayer jobsPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
Job job = Jobs.getJob(target);
if (jobsPlayer != null && jobsPlayer.isInJob(job))
Jobs.getPlayerManager().addExperience(jobsPlayer, job, amount);
}
@Override
public int getLevel(@NotNull Player player, @NotNull String target) {
JobsPlayer jobsPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jobsPlayer != null) {
List<JobProgression> jobs = jobsPlayer.getJobProgression();
Job job = Jobs.getJob(target);
for (JobProgression progression : jobs)
if (progression.getJob().equals(job))
return progression.getLevel();
}
return 0;
}
@Override
public String identifier() {
return "JobsReborn";
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.level;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.EXPSource;
import net.momirealms.customfishing.api.integration.LevelerProvider;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class MMOCoreLevelerProvider implements LevelerProvider {
@Override
public String identifier() {
return "MMOCore";
}
@Override
public void addXp(@NotNull Player player, @NotNull String target, double amount) {
MMOCore.plugin.professionManager.get(target).giveExperience(PlayerData.get(player), amount, null ,EXPSource.OTHER);
}
@Override
public int getLevel(@NotNull Player player, @NotNull String target) {
return PlayerData.get(player).getCollectionSkills().getLevel(MMOCore.plugin.professionManager.get(target));
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.level;
import com.gmail.nossr50.api.ExperienceAPI;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import net.momirealms.customfishing.api.integration.LevelerProvider;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class McMMOLevelerProvider implements LevelerProvider {
@Override
public String identifier() {
return "mcMMO";
}
@Override
public void addXp(@NotNull Player player, @NotNull String target, double amount) {
ExperienceAPI.addRawXP(player, target, (float) amount, "UNKNOWN");
}
@Override
public int getLevel(@NotNull Player player, @NotNull String target) {
return ExperienceAPI.getLevel(player, PrimarySkillType.valueOf(target));
}
}

View File

@@ -0,0 +1,147 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.papi;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
import net.momirealms.customfishing.common.locale.MessageConstants;
import net.momirealms.customfishing.common.locale.TranslationManager;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Optional;
public class CompetitionPapi extends PlaceholderExpansion {
private final BukkitCustomFishingPlugin plugin;
public CompetitionPapi(BukkitCustomFishingPlugin plugin) {
this.plugin = plugin;
}
public void load() {
super.register();
}
public void unload() {
super.unregister();
}
@Override
public @NotNull String getIdentifier() {
return "cfcompetition";
}
@Override
public @NotNull String getAuthor() {
return "XiaoMoMi";
}
@Override
public @NotNull String getVersion() {
return "2.2";
}
@Override
public boolean persist() {
return true;
}
@Override
public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
switch (params) {
case "goingon" -> {
return String.valueOf(plugin.getCompetitionManager().getOnGoingCompetition() != null);
}
case "nextseconds" -> {
return String.valueOf(plugin.getCompetitionManager().getNextCompetitionInSeconds());
}
case "nextsecond" -> {
return plugin.getCompetitionManager().getNextCompetitionInSeconds() % 60 + TranslationManager.miniMessageTranslation(MessageConstants.FORMAT_SECOND.build().key());
}
case "nextminute" -> {
int sec = plugin.getCompetitionManager().getNextCompetitionInSeconds();
int min = (sec % 3600) / 60;
return sec < 60 ? "" : min + TranslationManager.miniMessageTranslation(MessageConstants.FORMAT_MINUTE.build().key());
}
case "nexthour" -> {
int sec = plugin.getCompetitionManager().getNextCompetitionInSeconds();
int h = (sec % (3600 * 24)) / 3600;
return sec < 3600 ? "" : h + TranslationManager.miniMessageTranslation(MessageConstants.FORMAT_HOUR.build().key());
}
case "nextday" -> {
int sec = plugin.getCompetitionManager().getNextCompetitionInSeconds();
int day = sec / (3600 * 24);
return day == 0 ? "" : day + TranslationManager.miniMessageTranslation(MessageConstants.FORMAT_DAY.build().key());
}
case "rank" -> {
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
if (competition == null) return "";
else return String.valueOf(competition.getRanking().getPlayerRank(player.getName()));
}
case "goal" -> {
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
if (competition == null) return "";
else return competition.getGoal().toString();
}
case "seconds" -> {
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
if (competition == null) return "";
return String.valueOf(competition.getPublicContext().arg(ContextKeys.SECONDS));
}
case "second" -> {
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
if (competition == null) return "";
return String.valueOf(competition.getPublicContext().arg(ContextKeys.SECOND));
}
case "minute" -> {
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
if (competition == null) return "";
return String.valueOf(competition.getPublicContext().arg(ContextKeys.MINUTE));
}
case "hour" -> {
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
if (competition == null) return "";
return String.valueOf(competition.getPublicContext().arg(ContextKeys.HOUR));
}
}
String[] split = params.split("_", 2);
switch (split[0]) {
case "score" -> {
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
if (competition == null) return "";
if (split.length == 1) {
return String.format("%.2f", competition.getRanking().getPlayerScore(player.getName()));
} else {
return String.format("%.2f", competition.getRanking().getScoreAt(Integer.parseInt(split[1])));
}
}
case "player" -> {
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
if (competition == null) return "";
if (split.length == 1) return "Invalid format";
return Optional.ofNullable(competition.getRanking().getPlayerAt(Integer.parseInt(split[1]))).orElse("");
}
}
return "null";
}
}

View File

@@ -0,0 +1,125 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.papi;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.mechanic.context.Context;
import net.momirealms.customfishing.api.storage.user.UserData;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class CustomFishingPapi extends PlaceholderExpansion {
private final BukkitCustomFishingPlugin plugin;
public CustomFishingPapi(BukkitCustomFishingPlugin plugin) {
this.plugin = plugin;
}
public void load() {
super.register();
}
public void unload() {
super.unregister();
}
@Override
public @NotNull String getIdentifier() {
return "customfishing";
}
@Override
public @NotNull String getAuthor() {
return "XiaoMoMi";
}
@Override
public @NotNull String getVersion() {
return "2.2";
}
@Override
public boolean persist() {
return true;
}
@Override
public @Nullable String onRequest(OfflinePlayer offlinePlayer, @NotNull String params) {
String[] split = params.split("_");
Player player = offlinePlayer.getPlayer();
if (player == null)
return "";
switch (split[0]) {
case "market" -> {
if (split.length < 2)
return null;
switch (split[1]) {
case "limit" -> {
if (split.length < 3) {
return String.format("%.2f", plugin.getMarketManager().earningLimit(Context.player(player)));
} else {
Player another = Bukkit.getPlayer(split[2]);
if (another == null) {
return "";
}
return String.format("%.2f", plugin.getMarketManager().earningLimit(Context.player(another)));
}
}
case "earnings" -> {
UserData user;
if (split.length < 3) {
user = plugin.getStorageManager().getOnlineUser(player.getUniqueId()).orElse(null);
} else {
Player another = Bukkit.getPlayer(split[2]);
if (another == null) {
return "";
}
user = plugin.getStorageManager().getOnlineUser(another.getUniqueId()).orElse(null);
}
if (user == null)
return "";
return String.format("%.2f", user.earningData().earnings());
}
case "canearn" -> {
if (split.length < 3) {
UserData user = plugin.getStorageManager().getOnlineUser(player.getUniqueId()).orElse(null);
if (user == null)
return "";
return String.format("%.2f", plugin.getMarketManager().earningLimit(Context.player(player)) - user.earningData().earnings());
} else {
Player another = Bukkit.getPlayer(split[2]);
if (another == null) {
return "";
}
UserData user = plugin.getStorageManager().getOnlineUser(another.getUniqueId()).orElse(null);
if (user == null)
return "";
return String.format("%.2f", plugin.getMarketManager().earningLimit(Context.player(another)) - user.earningData().earnings());
}
}
}
}
}
return null;
}
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.papi;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.mechanic.statistic.FishingStatistics;
import net.momirealms.customfishing.api.storage.user.UserData;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Optional;
public class StatisticsPapi extends PlaceholderExpansion {
private final BukkitCustomFishingPlugin plugin;
public StatisticsPapi(BukkitCustomFishingPlugin plugin) {
this.plugin = plugin;
}
public void load() {
super.register();
}
public void unload() {
super.unregister();
}
@Override
public @NotNull String getIdentifier() {
return "fishingstats";
}
@Override
public @NotNull String getAuthor() {
return "XiaoMoMi";
}
@Override
public @NotNull String getVersion() {
return "2.2";
}
@Override
public boolean persist() {
return true;
}
@Override
public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
Optional<UserData> onlineUser = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
return onlineUser.map(
data -> {
FishingStatistics statistics = data.statistics();
String[] split = params.split("_", 2);
switch (split[0]) {
case "total" -> {
return String.valueOf(statistics.amountOfFishCaught());
}
case "hascaught" -> {
if (split.length == 1) return "Invalid format";
return String.valueOf(statistics.getAmount(split[1]) != 0);
}
case "amount" -> {
if (split.length == 1) return "Invalid format";
return String.valueOf(statistics.getAmount(split[1]));
}
case "size-record" -> {
float size = statistics.getMaxSize(split[1]);
return String.format("%.2f", size < 0 ? 0 : size);
}
case "category" -> {
if (split.length == 1) return "Invalid format";
String[] categorySplit = split[1].split("_", 2);
if (categorySplit.length == 1) return "Invalid format";
List<String> category = plugin.getStatisticsManager().getCategoryMembers(categorySplit[1]);
if (categorySplit[0].equals("total")) {
int total = 0;
for (String loot : category) {
total += statistics.getAmount(loot);
}
return String.valueOf(total);
} else if (categorySplit[0].equals("progress")) {
int size = category.size();
int unlocked = 0;
for (String loot : category) {
if (statistics.getAmount(loot) != 0) unlocked++;
}
double percent = ((double) unlocked * 100) / size;
String progress = String.format("%.1f", percent);
return progress.equals("100.0") ? "100" : progress;
}
}
}
return "";
}
).orElse("Data not loaded");
}
}

View File

@@ -0,0 +1,79 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.quest;
import io.github.battlepass.BattlePlugin;
import io.github.battlepass.api.events.server.PluginReloadEvent;
import net.advancedplugins.bp.impl.actions.ActionRegistry;
import net.advancedplugins.bp.impl.actions.external.executor.ActionQuestExecutor;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.event.FishingResultEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class BattlePassQuest implements Listener {
public BattlePassQuest() {
Bukkit.getPluginManager().registerEvents(this, BukkitCustomFishingPlugin.getInstance().getBoostrap());
}
public void register() {
ActionRegistry actionRegistry = BattlePlugin.getPlugin().getActionRegistry();
actionRegistry.hook("customfishing", BPFishingQuest::new);
}
@EventHandler(ignoreCancelled = true)
public void onBattlePassReload(PluginReloadEvent event){
register();
}
private static class BPFishingQuest extends ActionQuestExecutor {
public BPFishingQuest(JavaPlugin plugin) {
super(plugin, "customfishing");
}
@EventHandler
public void onFish(FishingResultEvent event){
if (event.isCancelled() || event.getResult() == FishingResultEvent.Result.FAILURE)
return;
Player player = event.getPlayer();
// Single Fish Quest
if (event.getLoot().id() != null)
this.executionBuilder("loot")
.player(player)
.root(event.getLoot().id())
.progress(event.getAmount())
.buildAndExecute();
// Group Fish Quest
String[] lootGroup = event.getLoot().lootGroup();
if (event.getLoot() != null && lootGroup != null)
for (String group : lootGroup) {
this.executionBuilder("group")
.player(player)
.root(group)
.progress(event.getAmount())
.buildAndExecute();
}
}
}
}

View File

@@ -0,0 +1,190 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.quest;
import net.momirealms.customfishing.api.event.FishingResultEvent;
import org.betonquest.betonquest.BetonQuest;
import org.betonquest.betonquest.Instruction;
import org.betonquest.betonquest.VariableNumber;
import org.betonquest.betonquest.api.CountingObjective;
import org.betonquest.betonquest.api.config.quest.QuestPackage;
import org.betonquest.betonquest.api.profiles.OnlineProfile;
import org.betonquest.betonquest.api.profiles.Profile;
import org.betonquest.betonquest.exceptions.InstructionParseException;
import org.betonquest.betonquest.utils.PlayerConverter;
import org.betonquest.betonquest.utils.location.CompoundLocation;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import java.util.Collections;
import java.util.HashSet;
@SuppressWarnings("DuplicatedCode")
public class BetonQuestQuest {
public static void register() {
BetonQuest.getInstance().registerObjectives("customfishing_loot", IDObjective.class);
BetonQuest.getInstance().registerObjectives("customfishing_group", GroupObjective.class);
}
public static class IDObjective extends CountingObjective implements Listener {
private final CompoundLocation playerLocation;
private final VariableNumber rangeVar;
private final HashSet<String> loot_ids;
public IDObjective(Instruction instruction) throws InstructionParseException {
super(instruction, "loot_to_fish");
loot_ids = new HashSet<>();
Collections.addAll(loot_ids, instruction.getArray());
targetAmount = instruction.getVarNum();
preCheckAmountNotLessThanOne(targetAmount);
final QuestPackage pack = instruction.getPackage();
final String loc = instruction.getOptional("playerLocation");
final String range = instruction.getOptional("range");
if (loc != null && range != null) {
playerLocation = new CompoundLocation(pack, loc);
rangeVar = new VariableNumber(pack, range);
} else {
playerLocation = null;
rangeVar = null;
}
}
@EventHandler
public void onFish(FishingResultEvent event) {
if (event.getResult() != FishingResultEvent.Result.FAILURE) {
OnlineProfile onlineProfile = PlayerConverter.getID(event.getPlayer());
if (!containsPlayer(onlineProfile)) {
return;
}
if (isInvalidLocation(event, onlineProfile)) {
return;
}
if (this.loot_ids.contains(event.getLoot().id()) && this.checkConditions(onlineProfile)) {
getCountingData(onlineProfile).progress(event.getAmount());
completeIfDoneOrNotify(onlineProfile);
}
}
}
private boolean isInvalidLocation(FishingResultEvent event, final Profile profile) {
if (playerLocation == null || rangeVar == null) {
return false;
}
final Location targetLocation;
try {
targetLocation = playerLocation.getLocation(profile);
} catch (final org.betonquest.betonquest.exceptions.QuestRuntimeException e) {
e.printStackTrace();
return true;
}
final int range = rangeVar.getInt(profile);
final Location playerLoc = event.getPlayer().getLocation();
return !playerLoc.getWorld().equals(targetLocation.getWorld()) || targetLocation.distanceSquared(playerLoc) > range * range;
}
@Override
public void start() {
Bukkit.getPluginManager().registerEvents(this, BetonQuest.getInstance());
}
@Override
public void stop() {
HandlerList.unregisterAll(this);
}
}
public static class GroupObjective extends CountingObjective implements Listener {
private final CompoundLocation playerLocation;
private final VariableNumber rangeVar;
private final HashSet<String> loot_groups;
public GroupObjective(Instruction instruction) throws InstructionParseException {
super(instruction, "group_to_fish");
loot_groups = new HashSet<>();
Collections.addAll(loot_groups, instruction.getArray());
targetAmount = instruction.getVarNum();
preCheckAmountNotLessThanOne(targetAmount);
final QuestPackage pack = instruction.getPackage();
final String loc = instruction.getOptional("playerLocation");
final String range = instruction.getOptional("range");
if (loc != null && range != null) {
playerLocation = new CompoundLocation(pack, loc);
rangeVar = new VariableNumber(pack, range);
} else {
playerLocation = null;
rangeVar = null;
}
}
@EventHandler
public void onFish(FishingResultEvent event) {
if (event.getResult() != FishingResultEvent.Result.FAILURE) {
OnlineProfile onlineProfile = PlayerConverter.getID(event.getPlayer());
if (!containsPlayer(onlineProfile)) {
return;
}
if (isInvalidLocation(event, onlineProfile)) {
return;
}
String[] groups = event.getLoot().lootGroup();
if (groups != null)
for (String group : groups) {
if (this.loot_groups.contains(group) && this.checkConditions(onlineProfile)) {
getCountingData(onlineProfile).progress(event.getAmount());
completeIfDoneOrNotify(onlineProfile);
return;
}
}
}
}
private boolean isInvalidLocation(FishingResultEvent event, final Profile profile) {
if (playerLocation == null || rangeVar == null) {
return false;
}
final Location targetLocation;
try {
targetLocation = playerLocation.getLocation(profile);
} catch (final org.betonquest.betonquest.exceptions.QuestRuntimeException e) {
e.printStackTrace();
return true;
}
final int range = rangeVar.getInt(profile);
final Location playerLoc = event.getPlayer().getLocation();
return !playerLoc.getWorld().equals(targetLocation.getWorld()) || targetLocation.distanceSquared(playerLoc) > range * range;
}
@Override
public void start() {
Bukkit.getPluginManager().registerEvents(this, BetonQuest.getInstance());
}
@Override
public void stop() {
HandlerList.unregisterAll(this);
}
}
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.quest;
import com.electro2560.dev.cluescrolls.api.*;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.event.FishingResultEvent;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class ClueScrollsQuest implements Listener {
private final CustomClue idClue;
private final CustomClue groupClue;
public ClueScrollsQuest() {
idClue = ClueScrollsAPI.getInstance().registerCustomClue(BukkitCustomFishingPlugin.getInstance().getBoostrap(), "loot", new ClueConfigData("id", DataType.STRING));
groupClue = ClueScrollsAPI.getInstance().registerCustomClue(BukkitCustomFishingPlugin.getInstance().getBoostrap(), "group", new ClueConfigData("group", DataType.STRING));
}
public void register() {
Bukkit.getPluginManager().registerEvents(this, BukkitCustomFishingPlugin.getInstance().getBoostrap());
}
@EventHandler
public void onFish(FishingResultEvent event) {
if (event.isCancelled() || event.getResult() == FishingResultEvent.Result.FAILURE)
return;
final Player player = event.getPlayer();
idClue.handle(
player,
event.getAmount(),
new ClueDataPair("id", "any")
);
Loot loot = event.getLoot();
if (loot != null) {
idClue.handle(
player,
event.getAmount(),
new ClueDataPair("id", loot.id())
);
}
if (loot != null && loot.lootGroup() != null) {
for (String group : event.getLoot().lootGroup()) {
groupClue.handle(
player,
event.getAmount(),
new ClueDataPair("group", group)
);
}
}
}
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.season;
import net.advancedplugins.seasons.api.AdvancedSeasonsAPI;
import net.momirealms.customfishing.api.integration.SeasonProvider;
import net.momirealms.customfishing.api.mechanic.misc.season.Season;
import org.bukkit.World;
import org.jetbrains.annotations.NotNull;
public class AdvancedSeasonsProvider implements SeasonProvider {
private final AdvancedSeasonsAPI api;
public AdvancedSeasonsProvider() {
this.api = new AdvancedSeasonsAPI();
}
@NotNull
@Override
public Season getSeason(@NotNull World world) {
return switch (api.getSeason(world)) {
case "SPRING" -> Season.SPRING;
case "WINTER" -> Season.WINTER;
case "SUMMER" -> Season.SUMMER;
case "FALL" -> Season.AUTUMN;
default -> Season.DISABLE;
};
}
@Override
public String identifier() {
return "AdvancedSeasons";
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.season;
import net.momirealms.customcrops.api.CustomCropsPlugin;
import net.momirealms.customcrops.api.mechanic.world.season.Season;
import net.momirealms.customfishing.api.integration.SeasonProvider;
import org.bukkit.World;
import org.jetbrains.annotations.NotNull;
import java.util.Locale;
public class CustomCropsSeasonProvider implements SeasonProvider {
@NotNull
@Override
public net.momirealms.customfishing.api.mechanic.misc.season.Season getSeason(@NotNull World world) {
Season season = CustomCropsPlugin.get().getIntegrationManager().getSeasonInterface().getSeason(world);
if (season == null) return net.momirealms.customfishing.api.mechanic.misc.season.Season.DISABLE;
return net.momirealms.customfishing.api.mechanic.misc.season.Season.valueOf(season.name().toUpperCase(Locale.ENGLISH));
}
@Override
public String identifier() {
return "CustomCrops";
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.bukkit.integration.season;
import me.casperge.realisticseasons.api.SeasonsAPI;
import net.momirealms.customfishing.api.integration.SeasonProvider;
import org.bukkit.World;
import org.jetbrains.annotations.NotNull;
public class RealisticSeasonsProvider implements SeasonProvider {
@NotNull
@Override
public net.momirealms.customfishing.api.mechanic.misc.season.Season getSeason(@NotNull World world) {
return switch (SeasonsAPI.getInstance().getSeason(world)) {
case WINTER -> net.momirealms.customfishing.api.mechanic.misc.season.Season.WINTER;
case SPRING -> net.momirealms.customfishing.api.mechanic.misc.season.Season.SPRING;
case SUMMER -> net.momirealms.customfishing.api.mechanic.misc.season.Season.SUMMER;
case FALL -> net.momirealms.customfishing.api.mechanic.misc.season.Season.AUTUMN;
case DISABLED, RESTORE -> net.momirealms.customfishing.api.mechanic.misc.season.Season.DISABLE;
};
}
@Override
public String identifier() {
return "RealisticSeasons";
}
}