9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-28 19:39:20 +00:00

fix some component issues

This commit is contained in:
XiaoMoMi
2025-07-26 23:53:11 +08:00
parent d4d09d58c3
commit 7542dfeed1
8 changed files with 22 additions and 68 deletions

View File

@@ -18,7 +18,6 @@
package net.momirealms.customcrops.api.action.builtin;
import dev.dejvokep.boostedyaml.block.implementation.Section;
import net.kyori.adventure.audience.Audience;
import net.momirealms.customcrops.api.BukkitCustomCropsPlugin;
import net.momirealms.customcrops.api.context.Context;
import net.momirealms.customcrops.api.context.ContextKeys;
@@ -26,6 +25,7 @@ import net.momirealms.customcrops.api.misc.value.MathValue;
import net.momirealms.customcrops.api.misc.value.TextValue;
import net.momirealms.customcrops.api.util.LocationUtils;
import net.momirealms.customcrops.common.helper.AdventureHelper;
import net.momirealms.sparrow.heart.SparrowHeart;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -61,10 +61,9 @@ public class ActionTitleNearby<T> extends AbstractBuiltInAction<T> {
for (Player player : location.getWorld().getPlayers()) {
if (LocationUtils.getDistance(player.getLocation(), location) <= range) {
context.arg(ContextKeys.TEMP_NEAR_PLAYER, player.getName());
Audience audience = plugin.getSenderFactory().getAudience(player);
AdventureHelper.sendTitle(audience,
AdventureHelper.miniMessage(title.render(context)),
AdventureHelper.miniMessage(subtitle.render(context)),
SparrowHeart.getInstance().sendTitle(player,
AdventureHelper.componentToJson(AdventureHelper.miniMessage(title.render(context))),
AdventureHelper.componentToJson(AdventureHelper.miniMessage(subtitle.render(context))),
fadeIn, stay, fadeOut
);
}

View File

@@ -17,7 +17,6 @@
package net.momirealms.customcrops.api.core;
import io.papermc.paper.event.block.BlockBreakBlockEvent;
import net.momirealms.customcrops.api.BukkitCustomCropsPlugin;
import net.momirealms.customcrops.api.action.ActionManager;
import net.momirealms.customcrops.api.context.Context;
@@ -42,7 +41,10 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.*;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;

View File

@@ -25,9 +25,7 @@ import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.title.Title;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
/**
@@ -103,40 +101,6 @@ public class AdventureHelper {
return instance.miniMessageToJsonCache.get(miniMessage, (text) -> instance.gsonComponentSerializer.serialize(miniMessage(text)));
}
/**
* Sends a title to an audience.
*
* @param audience the audience to send the title to
* @param title the title component
* @param subtitle the subtitle component
* @param fadeIn the fade-in duration in ticks
* @param stay the stay duration in ticks
* @param fadeOut the fade-out duration in ticks
*/
public static void sendTitle(Audience audience, Component title, Component subtitle, int fadeIn, int stay, int fadeOut) {
audience.showTitle(Title.title(title, subtitle, Title.Times.times(Duration.ofMillis(fadeIn * 50L), Duration.ofMillis(stay * 50L), Duration.ofMillis(fadeOut * 50L))));
}
/**
* Sends an action bar message to an audience.
*
* @param audience the audience to send the action bar message to
* @param actionBar the action bar component
*/
public static void sendActionBar(Audience audience, Component actionBar) {
audience.sendActionBar(actionBar);
}
/**
* Sends a message to an audience.
*
* @param audience the audience to send the message to
* @param message the message component
*/
public static void sendMessage(Audience audience, Component message) {
audience.sendMessage(message);
}
/**
* Plays a sound for an audience.
*