mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-22 16:38:20 +01:00
Shade relocated adventure without breaking native platform usage
This commit is contained in:
parent
b84bc7668a
commit
ec188db247
29
adventure/build.gradle.kts
Normal file
29
adventure/build.gradle.kts
Normal file
@ -0,0 +1,29 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
||||
|
||||
// Shade and relocate adventure in an extra module, so that common/the rest can directly depend on a
|
||||
// relocated adventure without breaking native platform's adventure usage with project wide relocation
|
||||
apply<ShadowPlugin>()
|
||||
tasks {
|
||||
withType<ShadowJar> {
|
||||
relocate("net.kyori", "us.myles.viaversion.libs.kyori")
|
||||
}
|
||||
getByName("build") {
|
||||
dependsOn(withType<ShadowJar>())
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api("net.kyori", "adventure-api", Versions.adventure) {
|
||||
exclude("org.checkerframework")
|
||||
}
|
||||
api("net.kyori", "adventure-text-serializer-gson", Versions.adventure) {
|
||||
exclude("net.kyori", "adventure-api")
|
||||
exclude("net.kyori", "adventure-bom")
|
||||
exclude("com.google.code.gson", "gson")
|
||||
}
|
||||
api("net.kyori", "adventure-text-serializer-legacy", Versions.adventure) {
|
||||
exclude("net.kyori", "adventure-api")
|
||||
exclude("net.kyori", "adventure-bom")
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ private fun ShadowJar.configureRelocations() {
|
||||
relocate("com.google.gson", "us.myles.viaversion.libs.gson")
|
||||
relocate("com.github.steveice10.opennbt", "us.myles.viaversion.libs.opennbt")
|
||||
relocate("it.unimi.dsi.fastutil", "us.myles.viaversion.libs.fastutil")
|
||||
relocate("net.kyori", "us.myles.viaversion.libs.kyori")
|
||||
}
|
||||
|
||||
private fun ShadowJar.configureExcludes() {
|
||||
|
@ -8,23 +8,11 @@ blossom {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":adventure", "shadow"))
|
||||
api("it.unimi.dsi", "fastutil", Versions.fastUtil)
|
||||
api("com.github.steveice10", "opennbt", Versions.openNBT)
|
||||
api("com.google.code.gson", "gson", Versions.gson)
|
||||
|
||||
api("net.kyori", "adventure-api", Versions.adventure) {
|
||||
exclude("org.checkerframework")
|
||||
}
|
||||
api("net.kyori", "adventure-text-serializer-gson", Versions.adventure) {
|
||||
exclude("net.kyori", "adventure-api")
|
||||
exclude("net.kyori", "adventure-bom")
|
||||
exclude("com.google.code.gson", "gson")
|
||||
}
|
||||
api("net.kyori", "adventure-text-serializer-legacy", Versions.adventure) {
|
||||
exclude("net.kyori", "adventure-api")
|
||||
exclude("net.kyori", "adventure-bom")
|
||||
}
|
||||
|
||||
compileOnlyApi("org.yaml", "snakeyaml", Versions.snakeYaml)
|
||||
compileOnlyApi("io.netty", "netty-all", Versions.netty)
|
||||
compileOnlyApi("com.google.guava", "guava", Versions.guava)
|
||||
|
@ -2,13 +2,13 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.rewriters.ComponentRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.ComponentRewriter1_13;
|
||||
import us.myles.viaversion.libs.kyori.adventure.text.Component;
|
||||
import us.myles.viaversion.libs.kyori.adventure.text.format.TextDecoration;
|
||||
import us.myles.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import us.myles.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class ChatRewriter {
|
||||
private static final ComponentRewriter COMPONENT_REWRITER = new ComponentRewriter1_13();
|
||||
@ -18,6 +18,8 @@ public class ChatRewriter {
|
||||
if (itemData) {
|
||||
builder.decoration(TextDecoration.ITALIC, false);
|
||||
}
|
||||
|
||||
// Not used for chat messages, so no need for url extraction
|
||||
builder.append(LegacyComponentSerializer.legacySection().deserialize(message));
|
||||
});
|
||||
return GsonComponentSerializer.gson().serialize(component);
|
||||
|
@ -1,5 +1,7 @@
|
||||
rootProject.name = "viaversion-parent"
|
||||
|
||||
include("adventure")
|
||||
|
||||
setupViaSubproject("common")
|
||||
setupViaSubproject("bukkit")
|
||||
setupViaSubproject("bukkit-legacy")
|
||||
|
@ -2,7 +2,6 @@ package us.myles.ViaVersion;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.inject.Inject;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.config.DefaultConfig;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
@ -32,6 +31,7 @@ import us.myles.ViaVersion.sponge.platform.SpongeViaLoader;
|
||||
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
import us.myles.ViaVersion.util.VersionInfo;
|
||||
import us.myles.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -54,6 +54,7 @@ public class SpongePlugin implements ViaPlatform<Player> {
|
||||
@DefaultConfig(sharedRoot = false)
|
||||
private File spongeConfig;
|
||||
|
||||
public static final LegacyComponentSerializer COMPONENT_SERIALIZER = LegacyComponentSerializer.builder().character('§').extractUrls().build();
|
||||
private final ViaConnectionManager connectionManager = new ViaConnectionManager();
|
||||
private final SpongeViaAPI api = new SpongeViaAPI();
|
||||
private SpongeViaConfig conf;
|
||||
@ -169,8 +170,8 @@ public class SpongePlugin implements ViaPlatform<Player> {
|
||||
|
||||
@Override
|
||||
public void sendMessage(UUID uuid, String message) {
|
||||
String serialized = LegacyComponentSerializer.legacySection().serialize(LegacyComponentSerializer.legacySection().deserialize(message));
|
||||
game.getServer().getPlayer(uuid).ifPresent(player -> player.sendMessage(TextSerializers.JSON.deserialize(serialized))); // Hacky way to fix links //TODO ??
|
||||
String serialized = SpongePlugin.COMPONENT_SERIALIZER.serialize(SpongePlugin.COMPONENT_SERIALIZER.deserialize(message));
|
||||
game.getServer().getPlayer(uuid).ifPresent(player -> player.sendMessage(TextSerializers.JSON.deserialize(serialized))); // Hacky way to fix links
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,9 +1,9 @@
|
||||
package us.myles.ViaVersion.sponge.commands;
|
||||
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.spongepowered.api.command.CommandSource;
|
||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
import org.spongepowered.api.util.Identifiable;
|
||||
import us.myles.ViaVersion.SpongePlugin;
|
||||
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -22,8 +22,8 @@ public class SpongeCommandSender implements ViaCommandSender {
|
||||
|
||||
@Override
|
||||
public void sendMessage(String msg) {
|
||||
String serialized = LegacyComponentSerializer.legacySection().serialize(LegacyComponentSerializer.legacySection().deserialize(msg));
|
||||
source.sendMessage(TextSerializers.JSON.deserialize(serialized)); // Hacky way to fix links //TODO ??
|
||||
String serialized = SpongePlugin.COMPONENT_SERIALIZER.serialize(SpongePlugin.COMPONENT_SERIALIZER.deserialize(msg));
|
||||
source.sendMessage(TextSerializers.JSON.deserialize(serialized)); // Hacky way to fix links
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user