9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00
This commit is contained in:
XiaoMoMi
2025-07-03 21:29:53 +08:00
parent b7a038d867
commit ee760d29ba
9 changed files with 63 additions and 24 deletions

View File

@@ -32,17 +32,17 @@ dependencies {
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(21)
}
withSourcesJar()
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
options.release.set(21)
dependsOn(tasks.clean)
}

View File

@@ -43,7 +43,7 @@ dependencies {
compileOnly(files("libs/mcMMO-api.jar"))
compileOnly("net.Indyuce:MMOCore-API:1.12.1-SNAPSHOT")
// compileOnly("dev.aurelium:auraskills-api-bukkit:2.2.7")
compileOnly(files("libs/AuraSkills-2.2.7.jar"))
compileOnly(files("libs/AuraSkills-2.3.4.jar"))
compileOnly("com.github.Archy-X:AureliumSkills:Beta1.3.21")
compileOnly("com.github.Zrips:Jobs:v5.2.2.3")
// quest
@@ -83,15 +83,15 @@ dependencies {
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(21)
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
options.release.set(21)
dependsOn(tasks.clean)
}

View File

@@ -12,6 +12,8 @@ dependencies {
compileOnly("com.nexomc:nexo:1.7.3")
compileOnly("net.momirealms:craft-engine-core:0.0.57")
compileOnly("net.momirealms:craft-engine-bukkit:0.0.57")
compileOnly("net.momirealms:sparrow-heart:${rootProject.properties["sparrow_heart_version"]}")
compileOnly(files("libs/AuraSkills-2.3.4.jar"))
}
tasks.withType<JavaCompile> {

View File

@@ -17,13 +17,13 @@ import dev.aurelium.auraskills.bukkit.AuraSkills;
import dev.aurelium.auraskills.bukkit.hooks.WorldGuardFlags.FlagKey;
import dev.aurelium.auraskills.bukkit.hooks.WorldGuardHook;
import dev.aurelium.auraskills.bukkit.loot.context.MobContext;
import dev.aurelium.auraskills.bukkit.loot.context.SourceContext;
import dev.aurelium.auraskills.bukkit.loot.type.CommandLoot;
import dev.aurelium.auraskills.bukkit.loot.type.EntityLoot;
import dev.aurelium.auraskills.bukkit.loot.type.ItemLoot;
import dev.aurelium.auraskills.bukkit.source.FishingLeveler;
import dev.aurelium.auraskills.common.commands.CommandExecutor;
import dev.aurelium.auraskills.common.hooks.PlaceholderHook;
import dev.aurelium.auraskills.common.loot.CommandLoot;
import dev.aurelium.auraskills.common.loot.SourceContext;
import dev.aurelium.auraskills.common.message.MessageKey;
import dev.aurelium.auraskills.common.user.User;
import dev.aurelium.auraskills.common.util.text.TextUtil;
@@ -41,6 +41,8 @@ import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -49,6 +51,9 @@ import java.util.HashSet;
import java.util.Locale;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
import static dev.aurelium.auraskills.bukkit.ref.BukkitItemRef.unwrap;
/*
*
@@ -88,7 +93,7 @@ public class AuraSkillItemProvider implements ItemProvider {
User user = plugin.getUser(context.holder());
Skill skill = originalSource != null ? originalSource.skill() : Skills.FISHING;
LootTable table = plugin.getLootTableManager().getLootTable(skill);
LootTable table = plugin.getLootManager().getLootTable(skill);
if (table == null) return originalItem;
for (LootPool pool : table.getPools()) {
// Calculate chance for pool
@@ -115,7 +120,7 @@ public class AuraSkillItemProvider implements ItemProvider {
if (random.nextDouble() < chance) { // Pool is selected
XpSource contextSource = originalSource != null ? originalSource.source() : null;
Loot selectedLoot = selectLoot(pool, new SourceContext(contextSource));
Loot selectedLoot = selectLoot(pool, new dev.aurelium.auraskills.common.loot.SourceContext(contextSource));
// Give loot
if (selectedLoot == null) { // Continue iterating pools
continue;
@@ -220,7 +225,7 @@ public class AuraSkillItemProvider implements ItemProvider {
int amount = generateAmount(loot.getMinAmount(), loot.getMaxAmount());
if (amount == 0) return new ItemStack(Material.AIR);
ItemStack drop = loot.getItem().supplyItem(plugin, table);
ItemStack drop = generateDamaged(unwrap(loot.getItem().supplyItem(plugin, table)), loot.getMinDamage(), loot.getMaxDamage());
drop.setAmount(amount);
attemptSendMessage(player, loot);
@@ -229,6 +234,37 @@ public class AuraSkillItemProvider implements ItemProvider {
return drop;
}
private ItemStack generateDamaged(ItemStack drop, double minDamage, double maxDamage) {
if (minDamage >= 0.0 && minDamage <= 1.0 &&
maxDamage >= 0.0 && maxDamage <= 1.0 &&
minDamage <= maxDamage) {
// Check if the item is damageable.
if (drop == null) {
return drop;
}
ItemMeta meta = drop.getItemMeta();
if (meta instanceof Damageable damageable) {
int damage = 0; // Default to 0 damage
short durability = drop.getType().getMaxDurability();
int minDamageValue = (int) (durability * minDamage); // E.g. 1561 * 0.0 = 0 -> resulting in an undamaged item.
int maxDamageValue = (int) (durability * maxDamage); // E.g. 1561 * 0.5 = 780 -> resulting in a max 50% damaged item.
if (minDamage == maxDamage) {
damage = maxDamageValue;
} else {
damage = ThreadLocalRandom.current().nextInt(minDamageValue, maxDamageValue);
}
damageable.setDamage(damage);
drop.setItemMeta(meta);
}
}
return drop;
}
private void giveXp(Player player, Loot loot, @Nullable XpSource source, Skill skill) {
if (plugin.getHookManager().isRegistered(WorldGuardHook.class)) {
// Check generic xp-gain and skill-specific flags
@@ -312,13 +348,14 @@ public class AuraSkillItemProvider implements ItemProvider {
protected Loot selectLoot(LootPool pool, @NotNull LootContext providedContext) {
return pool.rollLoot(loot -> {
if (providedContext instanceof SourceContext sourceContext) {
XpSource providedSource = sourceContext.source();
Set<LootContext> lootContexts = loot.getValues().getContexts().get("sources");
// Make sure the loot defines a sources context and the provided context exists
if (lootContexts != null && sourceContext.source() != null) {
boolean matched = false;
for (LootContext context : lootContexts) { // Go through LootContext and cast to Source
if (context instanceof SourceContext sourceLootContext) {
if (sourceLootContext.source().equals(sourceContext.source())) { // Check if source matches one of the contexts
if (context instanceof SourceContext sourceContext1) {
if (sourceContext1.source().equals(providedSource)) { // Check if source matches one of the contexts
matched = true;
break;
}

View File

@@ -84,15 +84,15 @@ artifacts {
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(21)
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
options.release.set(21)
dependsOn(tasks.clean)
}

View File

@@ -68,7 +68,7 @@ public class BukkitIntegrationManager implements IntegrationManager {
this.plugin = plugin;
try {
this.load();
} catch (Exception e) {
} catch (Throwable e) {
plugin.getPluginLogger().warn("Failed to load integrations", e);
} finally {
instance = this;

View File

@@ -48,7 +48,7 @@ public abstract class BukkitItemFactory extends ItemFactory<CustomFishingPlugin,
"1.21", "1.21.1", "1.21.2", "1.21.3", "1.21.4" -> {
return new ComponentItemFactory(plugin);
}
case "1.21.5", "1.21.6" -> {
case "1.21.5", "1.21.6", "1.21.7" -> {
return new ComponentItemFactory1_21_5(plugin);
}
default -> throw new IllegalStateException("Unsupported server version: " + plugin.getServerVersion());

View File

@@ -1,6 +1,6 @@
# Project settings
# Rule: [major update].[feature update].[bug fix]
project_version=2.3.12
project_version=2.3.13
config_version=38
project_group=net.momirealms
@@ -20,7 +20,7 @@ h2_driver_version=2.3.232
sqlite_driver_version=3.49.1.0
adventure_bundle_version=4.23.0
adventure_platform_version=4.4.0
sparrow_heart_version=0.57
sparrow_heart_version=0.58
cloud_core_version=2.0.0
cloud_services_version=2.0.0
cloud_brigadier_version=2.0.0-beta.10