mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2026-02-04 23:53:20 +01:00
click event stuff
This commit is contained in:
@@ -47,5 +47,11 @@ public class TestCommand implements BasicCommand {
|
|||||||
commandSourceStack.getSender().sendMessage(String.valueOf(System.currentTimeMillis() - tmp));
|
commandSourceStack.getSender().sendMessage(String.valueOf(System.currentTimeMillis() - tmp));
|
||||||
|
|
||||||
|
|
||||||
|
Component.text()
|
||||||
|
.append(Component.text().content("yes ").color(TextColor.color(50,50,50)))
|
||||||
|
.append(Component.text("%player_name%"))
|
||||||
|
.append(Component.text(" omg").color(TextColor.color(200,200,200)));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package me.clip.placeholderapi.replacer;
|
package me.clip.placeholderapi.replacer;
|
||||||
|
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import net.kyori.adventure.text.*;
|
import net.kyori.adventure.text.*;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
import net.kyori.adventure.text.format.Style;
|
import net.kyori.adventure.text.format.Style;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
@@ -98,17 +101,35 @@ public final class ComponentReplacer {
|
|||||||
Object hoverValue = modStyle.hoverEvent().value();
|
Object hoverValue = modStyle.hoverEvent().value();
|
||||||
|
|
||||||
if (hoverValue instanceof Component) {
|
if (hoverValue instanceof Component) {
|
||||||
final Component replacedHoverComponent = replace((Component) hoverValue, player, function);
|
final Object replacedValue = replace((Component) hoverValue, player, function);
|
||||||
|
|
||||||
if (replacedHoverComponent != hoverValue) {
|
if (replacedValue != hoverValue) {
|
||||||
modified.style();
|
((HoverEvent<Object>) modified.style().hoverEvent()).value(replacedValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modStyle.clickEvent() != null) {
|
if (modStyle.clickEvent() != null) {
|
||||||
String clickValue =
|
final ClickEvent.Payload payload = modStyle.clickEvent().payload();
|
||||||
|
|
||||||
|
if (payload instanceof ClickEvent.Payload.Text) {
|
||||||
|
final ClickEvent.Payload.Text replacedPayload = ClickEvent.Payload.string(PlaceholderAPI.setPlaceholders(player, ((ClickEvent.Payload.Text) payload).value()));
|
||||||
|
modStyle.clickEvent(ClickEvent.clickEvent(modStyle.clickEvent().action(), replacedPayload));
|
||||||
|
} else if (payload instanceof ClickEvent.Payload.Dialog) {
|
||||||
|
final ClickEvent.Payload.Dialog replacedPayload;
|
||||||
|
|
||||||
|
// ((ClickEvent.Payload.Dialog) payload).dialog()
|
||||||
|
// apparently adventure doesn't have dialog support yet
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (children == null) {
|
||||||
|
children = new ArrayList<>(oldChildrenSize + modified.children().size());
|
||||||
|
children.addAll(modified.children());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
modified = Component.text("", component.style());
|
||||||
|
// final ComponentLike child =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,4 +164,8 @@ public final class ComponentReplacer {
|
|||||||
|
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static <V> void test(HoverEvent<V> event, V value) {
|
||||||
|
event.value(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
# Discord: https://helpch.at/discord
|
# Discord: https://helpch.at/discord
|
||||||
# No placeholders are provided with this plugin by default.
|
# No placeholders are provided with this plugin by default.
|
||||||
# Download placeholders: /papi ecloud
|
# Download placeholders: /papi ecloud
|
||||||
|
#
|
||||||
|
# CHANGE use_regex_component_replacer to true if you notice new minecraft text features not getting their placeholders replaced properly -- may cause performance issues
|
||||||
check_updates: true
|
check_updates: true
|
||||||
cloud_enabled: true
|
cloud_enabled: true
|
||||||
cloud_sorting: "name"
|
cloud_sorting: "name"
|
||||||
@@ -15,5 +17,6 @@ boolean:
|
|||||||
'true': 'yes'
|
'true': 'yes'
|
||||||
'false': 'no'
|
'false': 'no'
|
||||||
date_format: MM/dd/yy HH:mm:ss
|
date_format: MM/dd/yy HH:mm:ss
|
||||||
|
use_regex_component_replacer: false
|
||||||
detect_malicious_expansions: true
|
detect_malicious_expansions: true
|
||||||
debug: false
|
debug: false
|
||||||
|
|||||||
Reference in New Issue
Block a user