mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
2.2.35
This commit is contained in:
@@ -180,8 +180,6 @@ public class CustomFishingHook {
|
||||
context.arg(ContextKeys.OTHER_Z, hook.getLocation().getBlockZ());
|
||||
|
||||
// get the next loot
|
||||
|
||||
|
||||
Loot loot;
|
||||
try {
|
||||
loot = plugin.getLootManager().getNextLoot(tempEffect, context);
|
||||
@@ -201,11 +199,11 @@ public class CustomFishingHook {
|
||||
context.arg(ContextKeys.of("data_" + entry.getKey(), String.class), entry.getValue().render(context));
|
||||
}
|
||||
|
||||
plugin.debug("Next loot: " + loot.id());
|
||||
plugin.debug("Next Loot: " + loot.id());
|
||||
plugin.debug(context);
|
||||
// get its basic properties
|
||||
Effect baseEffect = loot.baseEffect().toEffect(context);
|
||||
plugin.debug(baseEffect);
|
||||
plugin.debug("Loot Base Effect:" + baseEffect);
|
||||
tempEffect.combine(baseEffect);
|
||||
// apply the gears' effects
|
||||
for (EffectModifier modifier : gears.effectModifiers()) {
|
||||
@@ -218,6 +216,7 @@ public class CustomFishingHook {
|
||||
EventUtils.fireAndForget(new FishingEffectApplyEvent(this, tempEffect, FishingEffectApplyEvent.Stage.FISHING));
|
||||
|
||||
// start the mechanic
|
||||
plugin.debug("Final Effect:" + tempEffect);
|
||||
mechanic.start(tempEffect);
|
||||
|
||||
this.tempFinalEffect = tempEffect;
|
||||
|
||||
@@ -89,9 +89,10 @@ public class VanillaMechanic implements HookMechanic {
|
||||
return;
|
||||
}
|
||||
if (!ConfigManager.overrideVanillaWaitTime()) {
|
||||
int before = Math.max(SparrowHeart.getInstance().getWaitTime(hook), 0);
|
||||
int rawBefore = SparrowHeart.getInstance().getWaitTime(hook);
|
||||
int before = Math.max(rawBefore, 0);
|
||||
int after = (int) Math.max(100, before * effect.waitTimeMultiplier() + effect.waitTimeAdder());
|
||||
BukkitCustomFishingPlugin.getInstance().debug("Wait time: " + before + " -> " + after + " ticks");
|
||||
BukkitCustomFishingPlugin.getInstance().debug("Wait time: " + rawBefore + " -> " + after + " ticks");
|
||||
SparrowHeart.getInstance().setWaitTime(hook, after);
|
||||
} else {
|
||||
int before = ThreadLocalRandom.current().nextInt(ConfigManager.waterMaxTime() - ConfigManager.waterMinTime() + 1) + ConfigManager.waterMinTime();
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -46,7 +47,7 @@ public interface ItemManager extends Reloadable {
|
||||
boolean registerItem(@NotNull CustomFishingItem item);
|
||||
|
||||
/**
|
||||
* Builds an internal representation of an item using the given context and item ID.
|
||||
* Builds an item using the given context and item ID.
|
||||
*
|
||||
* @param context the {@link Context} in which the item is built
|
||||
* @param id the ID of the item to be built
|
||||
@@ -54,6 +55,7 @@ public interface ItemManager extends Reloadable {
|
||||
* @throws NullPointerException if the item ID is not found
|
||||
*/
|
||||
@Nullable
|
||||
@ApiStatus.Internal
|
||||
ItemStack buildInternal(@NotNull Context<Player> context, @NotNull String id) throws NullPointerException;
|
||||
|
||||
/**
|
||||
|
||||
25
compatibility/j21/build.gradle.kts
Normal file
25
compatibility/j21/build.gradle.kts
Normal file
@@ -0,0 +1,25 @@
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://repo.nexomc.com/snapshots/")
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":api"))
|
||||
compileOnly(project(":common"))
|
||||
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
|
||||
compileOnly("com.nexomc:nexo:0.5.0-dev.8")
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = "UTF-8"
|
||||
options.release.set(21)
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) <2024> <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 com.nexomc.nexo.api.NexoBlocks;
|
||||
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 org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NexoBlockProvider implements BlockProvider {
|
||||
|
||||
@Override
|
||||
public BlockData blockData(@NotNull Context<Player> context, @NotNull String id, List<BlockDataModifier> modifiers) {
|
||||
BlockData blockData = NexoBlocks.blockData(id);
|
||||
for (BlockDataModifier modifier : modifiers) {
|
||||
modifier.apply(context, blockData);
|
||||
}
|
||||
return blockData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String blockID(@NotNull Block block) {
|
||||
return NexoBlocks.isCustomBlock(block) ? NexoBlocks.customBlockMechanic(block.getBlockData()).getItemID() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
return "Nexo";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) <2024> <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 com.nexomc.nexo.api.NexoItems;
|
||||
import com.nexomc.nexo.items.ItemBuilder;
|
||||
import net.momirealms.customfishing.api.integration.ItemProvider;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class NexoItemProvider implements ItemProvider {
|
||||
|
||||
@Override
|
||||
public @NotNull ItemStack buildItem(@NotNull Player player, @NotNull String id) {
|
||||
return Optional.ofNullable(NexoItems.itemFromId(id)).map(ItemBuilder::build).orElseThrow(() -> new IllegalArgumentException("Item not found in Nexo: " + id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String itemID(@NotNull ItemStack itemStack) {
|
||||
return NexoItems.idFromItem(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier() {
|
||||
return "Nexo";
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public class CraftEngineProvider implements ItemProvider {
|
||||
@Override
|
||||
public ItemStack buildItem(@NotNull Player player, @NotNull String id) {
|
||||
ItemStack itemStack = CraftEngine.instance().itemManager().buildItem(Key.fromString(id), player);
|
||||
return requireNonNull(itemStack, "Id: " + id + " not exists");
|
||||
return requireNonNull(itemStack, "Item not found in CraftEngine: " + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,6 +60,7 @@ dependencies {
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
from(project(":compatibility:j21").tasks.jar.get().archiveFile)
|
||||
archiveFileName = "CustomFishing-${rootProject.properties["project_version"]}.jar"
|
||||
destinationDirectory.set(file("$rootDir/target"))
|
||||
relocate("net.kyori", "net.momirealms.customfishing.libraries")
|
||||
|
||||
@@ -236,7 +236,11 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
|
||||
if (this.integrationManager != null) this.integrationManager.disable();
|
||||
if (this.storageManager != null) this.storageManager.disable();
|
||||
if (this.hologramManager != null) this.hologramManager.disable();
|
||||
if (this.commandManager != null) this.commandManager.unregisterFeatures();
|
||||
if (this.commandManager != null) {
|
||||
if (!Bukkit.getServer().isStopping()) {
|
||||
this.commandManager.unregisterFeatures();
|
||||
}
|
||||
}
|
||||
this.scheduler.shutdownScheduler();
|
||||
this.scheduler.shutdownExecutor();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import net.kyori.adventure.text.ScoreComponent;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.MechanicType;
|
||||
import net.momirealms.customfishing.api.mechanic.context.Context;
|
||||
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
|
||||
import net.momirealms.customfishing.api.mechanic.effect.EffectModifier;
|
||||
import net.momirealms.customfishing.api.mechanic.hook.HookConfig;
|
||||
import net.momirealms.customfishing.api.mechanic.hook.HookManager;
|
||||
@@ -129,7 +130,7 @@ public class BukkitHookManager implements HookManager, Listener {
|
||||
if (hookItemBase64 != null) {
|
||||
itemStack = bytesToHook(hookItemBase64);
|
||||
} else {
|
||||
itemStack = plugin.getItemManager().buildInternal(Context.player(player), id);
|
||||
itemStack = plugin.getItemManager().buildInternal(Context.player(player).arg(ContextKeys.ID, id), id);
|
||||
}
|
||||
plugin.getItemManager().setDamage(player, itemStack, damage);
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -84,6 +85,22 @@ public class BukkitIntegrationManager implements IntegrationManager {
|
||||
if (isHooked("CraftEngine")) {
|
||||
registerItemProvider(new CraftEngineProvider());
|
||||
}
|
||||
if (isHooked("Nexo")) {
|
||||
try {
|
||||
Class<?> nexoItemProviderClass = Class.forName("net.momirealms.customfishing.bukkit.integration.item.NexoItemProvider");
|
||||
Constructor<?> itemProviderConstructor = nexoItemProviderClass.getDeclaredConstructor();
|
||||
itemProviderConstructor.setAccessible(true);
|
||||
ItemProvider itemProvider = (ItemProvider) itemProviderConstructor.newInstance();
|
||||
registerItemProvider(itemProvider);
|
||||
Class<?> nexoBlockProviderClass = Class.forName("net.momirealms.customfishing.bukkit.integration.block.NexoBlockProvider");
|
||||
Constructor<?> nexoBlockProviderConstructor = nexoBlockProviderClass.getDeclaredConstructor();
|
||||
nexoBlockProviderConstructor.setAccessible(true);
|
||||
BlockProvider blockProvider = (BlockProvider) nexoBlockProviderConstructor.newInstance();
|
||||
registerBlockProvider(blockProvider);
|
||||
} catch (ReflectiveOperationException exception) {
|
||||
plugin.getPluginLogger().warn("Failed to hook Nexo", exception);
|
||||
}
|
||||
}
|
||||
if (isHooked("MMOItems")) {
|
||||
registerItemProvider(new MMOItemsItemProvider());
|
||||
}
|
||||
|
||||
@@ -138,6 +138,9 @@ public class BukkitItemManager implements ItemManager, Listener {
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack build(@NotNull Context<Player> context, @NotNull CustomFishingItem item) {
|
||||
if (context.arg(ContextKeys.ID) == null) {
|
||||
context.arg(ContextKeys.ID, item.id());
|
||||
}
|
||||
ItemStack itemStack = getOriginalStack(context.holder(), item.material());
|
||||
if (itemStack.getType() == Material.AIR) return itemStack;
|
||||
plugin.getLootManager().getLoot(item.id()).ifPresent(loot -> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=2.2.34
|
||||
project_version=2.2.35
|
||||
config_version=37
|
||||
project_group=net.momirealms
|
||||
|
||||
@@ -20,7 +20,7 @@ h2_driver_version=2.3.232
|
||||
sqlite_driver_version=3.47.0.0
|
||||
adventure_bundle_version=4.17.0
|
||||
adventure_platform_version=4.3.4
|
||||
sparrow_heart_version=0.48
|
||||
sparrow_heart_version=0.49
|
||||
cloud_core_version=2.0.0
|
||||
cloud_services_version=2.0.0
|
||||
cloud_brigadier_version=2.0.0-beta.10
|
||||
@@ -37,7 +37,7 @@ commons_pool_version=2.12.0
|
||||
bstats_version=3.1.0
|
||||
geantyref_version=1.3.16
|
||||
caffeine_version=3.1.8
|
||||
rtag_version=1.5.8
|
||||
rtag_version=1.5.9
|
||||
jedis_version=5.1.5
|
||||
exp4j_version=0.4.8
|
||||
placeholder_api_version=2.11.6
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
rootProject.name = "CustomFishing"
|
||||
include("api")
|
||||
include("common")
|
||||
include("core")
|
||||
include("compatibility")
|
||||
include(":api")
|
||||
include(":common")
|
||||
include(":core")
|
||||
include(":compatibility")
|
||||
include(":compatibility:j21")
|
||||
|
||||
Reference in New Issue
Block a user