Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
90f2a51
Initial copy-paste over
tal5 Jul 31, 2025
1e468d7
Merge remote-tracking branch 'upstream/dev' into adventure_chat_switch
tal5 Sep 4, 2025
d9f1d7b
Copy-paste `HoverFormatHelper`
tal5 Sep 4, 2025
b306a28
Initial migration + TODOs
tal5 Sep 5, 2025
35f5080
Attempt mutability fix
tal5 Sep 6, 2025
5e75d3d
`BukkitElementExtensions`: raw copy-paste
tal5 Sep 6, 2025
65e5d51
`PaperElementExtensions`: initial update
tal5 Sep 6, 2025
35bbac4
`TextTagBase`: copy over to `TextFormattingTags`
tal5 Sep 7, 2025
9a7baf9
`TextFormattingTags`: initial update
tal5 Sep 7, 2025
843f083
`FormattedTextHelper`: more immutability fixes
tal5 Sep 8, 2025
e229dd5
`player receives message` event & related: update
tal5 Sep 8, 2025
55268a9
`ItemBook`: update
tal5 Sep 9, 2025
faf5f45
`FormattedTextHelper`: minor parsing fixes
tal5 Sep 10, 2025
c879115
`ActionBarCommand`: update
tal5 Sep 10, 2025
2854d59
`NarrateCommand`: update
tal5 Sep 10, 2025
b3adfda
`AnnounceCommand`: update
tal5 Sep 10, 2025
1d9a84d
`BookScriptContainer`: update
tal5 Sep 10, 2025
ad83ef1
`EnchantmentScriptContainer`: update
tal5 Sep 10, 2025
ff0a829
`/ex(s)` commands: update
tal5 Sep 10, 2025
901540c
Merge remote-tracking branch 'upstream/dev' into adventure_chat_switch
tal5 Sep 10, 2025
6834713
`PaperAPITools`: update
tal5 Sep 11, 2025
dba5685
`PaperModule`: cleanup parsing methods
tal5 Sep 11, 2025
0805f32
NMS modules: transition to `PaperAPITools` methods
tal5 Sep 11, 2025
6899b5f
Move alternate debug trimming
tal5 Sep 14, 2025
e1df248
Remove old impls
tal5 Sep 14, 2025
7248aaf
Merge branch 'DenizenScript:dev' into adventure_chat_switch
tal5 Sep 16, 2025
e11fc56
Merge branch 'adventure_chat_switch' of https://github.com/tal5/Deniz…
tal5 Sep 19, 2025
b6fd337
Item hovers handling
tal5 Sep 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@
<relocation>
<pattern>net.kyori.adventure.nbt</pattern>
<shadedPattern>com.denizenscript.shaded.net.adventure.nbt</shadedPattern>
<excludes>
<exclude>net.kyori.adventure.nbt.api.*</exclude>
</excludes>
</relocation>
</relocations>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
import com.denizenscript.denizen.paper.events.*;
import com.denizenscript.denizen.paper.properties.*;
import com.denizenscript.denizen.paper.tags.PaperTagBase;
import com.denizenscript.denizen.paper.tags.TextFormattingTags;
import com.denizenscript.denizen.paper.utilities.FormattedTextHelper;
import com.denizenscript.denizen.paper.utilities.PaperAPIToolsImpl;
import com.denizenscript.denizen.utilities.FormattedTextHelper;
import com.denizenscript.denizen.utilities.PaperAPITools;
import com.denizenscript.denizencore.events.ScriptEvent;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import com.denizenscript.denizencore.utilities.debugging.Debug;
import com.denizenscript.denizencore.utilities.debugging.DebugInternals;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;

public class PaperModule {
Expand Down Expand Up @@ -135,33 +136,15 @@ public static void init() {
PaperWorldExtensions.register();
// Paper Tags
new PaperTagBase();
new TextFormattingTags();

// Other helpers
Bukkit.getPluginManager().registerEvents(new PaperEventHelpers(), Denizen.getInstance());
DebugInternals.alternateTrimLogic = FormattedTextHelper::bukkitSafeDebugTrimming;
PaperAPITools.instance = new PaperAPIToolsImpl();
PacketOutChat.convertComponentToJsonString = (o) -> componentToJson((Component) o);
}

public static Component parseFormattedText(String text, ChatColor baseColor) {
if (text == null) {
return null;
}
try {
return jsonToComponent(FormattedTextHelper.componentToJson(FormattedTextHelper.parse(text, baseColor)));
}
catch (Exception ex) {
Debug.verboseLog("Failed to parse formatted text: " + text.replace(ChatColor.COLOR_CHAR, '&'));
throw ex;
}
}

public static String stringifyComponent(Component component) {
if (component == null) {
return null;
}
return FormattedTextHelper.stringify(FormattedTextHelper.parseJson(componentToJson(component)));
}

public static Component jsonToComponent(String json) {
if (json == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.denizenscript.denizen.paper.events;

import com.denizenscript.denizen.events.player.PlayerCompletesAdvancementScriptEvent;
import com.denizenscript.denizen.paper.PaperModule;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizen.paper.utilities.FormattedTextHelper;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import net.md_5.bungee.api.ChatColor;
import net.kyori.adventure.text.format.NamedTextColor;

public class PlayerCompletesAdvancementScriptEventPaperImpl extends PlayerCompletesAdvancementScriptEvent {

@Override
public ObjectTag getContext(String name) {
switch (name) {
case "message": return new ElementTag(PaperModule.stringifyComponent(event.message()));
case "message": return new ElementTag(FormattedTextHelper.stringify(event.message()), true);
}
return super.getContext(name);
}
Expand All @@ -26,7 +26,7 @@ public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
event.message(null);
return true;
}
event.message(PaperModule.parseFormattedText(determination, ChatColor.WHITE));
event.message(FormattedTextHelper.parse(determination, NamedTextColor.WHITE));
return true;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.paper.PaperModule;
import com.denizenscript.denizen.paper.utilities.FormattedTextHelper;
import com.denizenscript.denizen.utilities.PaperAPITools;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import io.papermc.paper.event.player.PlayerNameEntityEvent;
import net.md_5.bungee.api.ChatColor;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

Expand Down Expand Up @@ -53,7 +53,7 @@ public PlayerNameEntityScriptEvent() {
return false;
});
this.<PlayerNameEntityScriptEvent, ElementTag>registerDetermination("name", ElementTag.class, (evt, context, determination) -> {
evt.event.setName(PaperModule.parseFormattedText(determination.toString(), ChatColor.WHITE));
evt.event.setName(FormattedTextHelper.parse(determination.asString(), NamedTextColor.WHITE));
});
}

Expand Down Expand Up @@ -81,7 +81,7 @@ public ScriptEntryData getScriptEntryData() {
public ObjectTag getContext(String name) {
return switch (name) {
case "entity" -> entity.getDenizenObject();
case "name" -> new ElementTag(PaperModule.stringifyComponent(event.getName()), true);
case "name" -> new ElementTag(FormattedTextHelper.stringify(event.getName()), true);
case "old_name" -> oldName;
case "persistent" -> new ElementTag(event.isPersistent());
default -> super.getContext(name);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.denizenscript.denizen.paper.events;

import com.denizenscript.denizen.events.player.PlayerQuitsScriptEvent;
import com.denizenscript.denizen.paper.PaperModule;
import com.denizenscript.denizen.paper.utilities.FormattedTextHelper;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import net.md_5.bungee.api.ChatColor;
import net.kyori.adventure.text.format.NamedTextColor;


public class PlayerQuitsScriptEventPaperImpl extends PlayerQuitsScriptEvent {
Expand All @@ -15,7 +15,7 @@ public PlayerQuitsScriptEventPaperImpl() {
event.quitMessage(null);
});
this.<PlayerQuitsScriptEventPaperImpl, ElementTag>registerDetermination(null, ElementTag.class, (evt, context, determination) -> {
event.quitMessage(PaperModule.parseFormattedText(determination.toString(), ChatColor.WHITE));
event.quitMessage(FormattedTextHelper.parse(determination.asString(), NamedTextColor.WHITE));
});
}

Expand All @@ -30,7 +30,7 @@ public boolean matches(ScriptPath path) {
@Override
public ObjectTag getContext(String name) {
return switch (name) {
case "message" -> new ElementTag(PaperModule.stringifyComponent(event.quitMessage()));
case "message" -> new ElementTag(FormattedTextHelper.stringify(event.quitMessage()), true);
case "cause" -> new ElementTag(event.getReason());
default -> super.getContext(name);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.objects.LocationTag;
import com.denizenscript.denizen.paper.PaperModule;
import com.denizenscript.denizen.paper.utilities.FormattedTextHelper;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import com.destroystokyo.paper.event.player.PlayerSetSpawnEvent;
import net.md_5.bungee.api.ChatColor;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

Expand Down Expand Up @@ -58,7 +58,7 @@ public PlayerSetSpawnScriptEvent() {
return false;
});
this.<PlayerSetSpawnScriptEvent, ElementTag>registerDetermination("message", ElementTag.class, (evt, context, message) -> {
evt.event.setNotification(PaperModule.parseFormattedText(message.toString(), ChatColor.WHITE));
evt.event.setNotification(FormattedTextHelper.parse(message.asString(), NamedTextColor.WHITE));
});
this.<PlayerSetSpawnScriptEvent, ElementTag>registerOptionalDetermination("notify", ElementTag.class, (evt, context, value) -> {
if (value.isBoolean()) {
Expand Down Expand Up @@ -97,7 +97,7 @@ public ObjectTag getContext(String name) {
case "cause" -> new ElementTag(event.getCause());
case "forced" -> new ElementTag(event.isForced());
case "location" -> event.getLocation() != null ? new LocationTag(event.getLocation()) : null;
case "message" -> event.getNotification() != null ? new ElementTag(PaperModule.stringifyComponent(event.getNotification()), true) : null;
case "message" -> event.getNotification() != null ? new ElementTag(FormattedTextHelper.stringify(event.getNotification()), true) : null;
case "notify" -> new ElementTag(event.willNotifyPlayer());
default -> super.getContext(name);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.nms.abstracts.ProfileEditor;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizen.paper.PaperModule;
import com.denizenscript.denizen.paper.utilities.FormattedTextHelper;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.core.ListTag;
Expand All @@ -14,7 +14,7 @@
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
import com.destroystokyo.paper.profile.PlayerProfile;
import com.destroystokyo.paper.profile.ProfileProperty;
import net.md_5.bungee.api.ChatColor;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.profile.PlayerTextures;
Expand Down Expand Up @@ -124,13 +124,13 @@ public static class FakeProfile implements PlayerProfile {

@Override
public void setMotd(String text) {
event.motd(PaperModule.parseFormattedText(text, ChatColor.WHITE));
event.motd(FormattedTextHelper.parse(text, NamedTextColor.WHITE));
}

@Override
public ObjectTag getContext(String name) {
return switch (name) {
case "motd" -> new ElementTag(PaperModule.stringifyComponent(event.motd()), true);
case "motd" -> new ElementTag(FormattedTextHelper.stringify(event.motd()), true);
case "protocol_version" -> new ElementTag(getEvent().getProtocolVersion());
case "version_name" -> new ElementTag(getEvent().getVersion(), true);
case "client_protocol_version" -> new ElementTag(getEvent().getClient().getProtocolVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.objects.LocationTag;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizen.paper.PaperModule;
import com.denizenscript.denizen.paper.utilities.FormattedTextHelper;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizencore.objects.ArgumentHelper;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.core.ListTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import net.md_5.bungee.api.ChatColor;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.entity.minecart.CommandMinecart;
Expand Down Expand Up @@ -55,7 +55,7 @@ public class UnknownCommandScriptEvent extends BukkitScriptEvent implements List
public UnknownCommandScriptEvent() {
registerCouldMatcher("command unknown");
this.<UnknownCommandScriptEvent, ElementTag>registerDetermination(null, ElementTag.class, (evt, context, text) -> {
evt.event.message(PaperModule.parseFormattedText(text.toString(), ChatColor.WHITE));
evt.event.message(FormattedTextHelper.parse(text.asString(), NamedTextColor.WHITE));
});
this.<UnknownCommandScriptEvent>registerTextDetermination("none", (evt) -> {
evt.event.message(null);
Expand All @@ -82,7 +82,7 @@ public ObjectTag getContext(String name) {
case "source_type" -> new ElementTag(sourceType, true);
case "command_block_location" -> sourceType.equals("command_block") ? new LocationTag(((BlockCommandSender) event.getSender()).getBlock().getLocation()) : null;
case "command_minecart" -> sourceType.equals("command_minecart") ? new EntityTag((CommandMinecart) event.getSender()) : null;
case "message" -> new ElementTag(PaperModule.stringifyComponent(event.message()), true);
case "message" -> new ElementTag(FormattedTextHelper.stringify(event.message()), true);
default -> super.getContext(name);
};
}
Expand Down
Loading