From 55348346e92a6ec548a70aed29084396f461054c Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Fri, 19 Apr 2019 14:49:29 +1000 Subject: [PATCH] Shade in Kashike's lib --- build.gradle | 3 +++ config/checkstyle/import-control.xml | 1 + worldedit-bukkit/build.gradle | 1 + .../com/sk89q/worldedit/bukkit/BukkitCommandSender.java | 8 ++++---- .../java/com/sk89q/worldedit/bukkit/BukkitPlayer.java | 9 ++++----- worldedit-core/build.gradle | 3 ++- .../com/sk89q/worldedit/extension/platform/Actor.java | 8 ++++---- .../sk89q/worldedit/extension/platform/PlayerProxy.java | 6 +++--- worldedit-forge/build.gradle | 1 + .../main/java/com/sk89q/worldedit/forge/ForgePlayer.java | 6 ++++++ worldedit-sponge/build.gradle | 1 + .../com/sk89q/worldedit/sponge/SpongeCommandSender.java | 7 +++++++ .../java/com/sk89q/worldedit/sponge/SpongePlayer.java | 7 +++++++ 13 files changed, 44 insertions(+), 17 deletions(-) diff --git a/build.gradle b/build.gradle index 8bdb1a122..57570e2ff 100644 --- a/build.gradle +++ b/build.gradle @@ -142,6 +142,9 @@ subprojects { include(dependency('com.sk89q:jchronic:0.2.4a')) include(dependency('com.thoughtworks.paranamer:paranamer:2.6')) include(dependency('com.sk89q.lib:jlibnoise:1.0.0')) + relocate('net.kyori.text', 'com.sk89q.worldedit.util.formatting') { + include(dependency('net.kyori:text-api:2.0.0')) + } } exclude 'GradleStart**' exclude '.cache' diff --git a/config/checkstyle/import-control.xml b/config/checkstyle/import-control.xml index 28ccad1e4..b4a2f4808 100644 --- a/config/checkstyle/import-control.xml +++ b/config/checkstyle/import-control.xml @@ -16,6 +16,7 @@ + diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle index 335b96c0a..af7f00114 100644 --- a/worldedit-bukkit/build.gradle +++ b/worldedit-bukkit/build.gradle @@ -15,6 +15,7 @@ dependencies { compile 'org.bstats:bstats-bukkit:1.4' compile "io.papermc:paperlib:1.0.1" compile 'org.slf4j:slf4j-jdk14:1.7.26' + compile 'net.kyori:text-adapter-bukkit:1.0.3' testCompile 'org.mockito:mockito-core:1.9.0-rc1' } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java index 7f48b193d..21d08d726 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java @@ -26,7 +26,8 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.auth.AuthorizationException; -import com.sk89q.worldedit.util.formatting.Fragment; +import net.kyori.text.TextComponent; +import net.kyori.text.adapter.bukkit.TextAdapter; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -93,9 +94,8 @@ public class BukkitCommandSender implements Actor { } @Override - public void print(Fragment fragment) { - // TODO Bukkit is bad and the API is somewhat lacking - printRaw(fragment.toString()); + public void print(TextComponent component) { + TextAdapter.sendComponent(sender, component); } @Override diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 8ef240f2c..ca15daa91 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -31,14 +31,14 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.HandSide; -import com.sk89q.worldedit.util.formatting.Fragment; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameModes; - +import net.kyori.text.TextComponent; +import net.kyori.text.adapter.bukkit.TextAdapter; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -127,9 +127,8 @@ public class BukkitPlayer extends AbstractPlayerActor { } @Override - public void print(Fragment fragment) { - // TODO Bukkit is bad and the API is somewhat lacking - printRaw(fragment.toString()); + public void print(TextComponent component) { + TextAdapter.sendComponent(player, component); } @Override diff --git a/worldedit-core/build.gradle b/worldedit-core/build.gradle index f91186083..e47c27f02 100644 --- a/worldedit-core/build.gradle +++ b/worldedit-core/build.gradle @@ -13,6 +13,7 @@ dependencies { compile 'com.sk89q.lib:jlibnoise:1.0.0' compile 'com.googlecode.json-simple:json-simple:1.1.1' compile 'org.slf4j:slf4j-api:1.7.26' + compile 'net.kyori:text-api:2.0.0' //compile 'net.sf.trove4j:trove4j:3.0.3' testCompile 'org.mockito:mockito-core:1.9.0-rc1' } @@ -29,4 +30,4 @@ sourceSets { } } -build.dependsOn(shadowJar) +build.dependsOn(shadowJar { classifier = null }) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java index c5fb1b6b1..86bae5934 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java @@ -23,7 +23,7 @@ import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.session.SessionOwner; import com.sk89q.worldedit.util.Identifiable; import com.sk89q.worldedit.util.auth.Subject; -import com.sk89q.worldedit.util.formatting.Fragment; +import net.kyori.text.TextComponent; import java.io.File; @@ -77,11 +77,11 @@ public interface Actor extends Identifiable, SessionOwner, Subject { void printError(String msg); /** - * Print a {@link Fragment}. + * Print a {@link TextComponent}. * - * @param fragment The fragment to print + * @param component The component to print */ - void print(Fragment fragment); + void print(TextComponent component); /** * Returns true if the actor can destroy bedrock. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java index 54700aeea..5211e1380 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java @@ -31,10 +31,10 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.util.formatting.Fragment; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.gamemode.GameMode; +import net.kyori.text.TextComponent; import java.util.UUID; @@ -134,8 +134,8 @@ class PlayerProxy extends AbstractPlayerActor { } @Override - public void print(Fragment fragment) { - basePlayer.print(fragment); + public void print(TextComponent component) { + basePlayer.print(component); } @Override diff --git a/worldedit-forge/build.gradle b/worldedit-forge/build.gradle index 8fe3fb9af..41c798310 100644 --- a/worldedit-forge/build.gradle +++ b/worldedit-forge/build.gradle @@ -19,6 +19,7 @@ def forgeVersion = "25.0.76" dependencies { compile project(':worldedit-core') compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.11.2' + compile 'net.kyori:text-serializer-gson:2.0.0' minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}" diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java index 5b3b2ca84..57734f43a 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java @@ -34,6 +34,7 @@ import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; +import net.kyori.text.TextComponent; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; @@ -141,6 +142,11 @@ public class ForgePlayer extends AbstractPlayerActor { sendColorized(msg, TextFormatting.RED); } + @Override + public void print(TextComponent component) { + // TODO + } + private void sendColorized(String msg, TextFormatting formatting) { for (String part : msg.split("\n")) { TextComponentString component = new TextComponentString(part); diff --git a/worldedit-sponge/build.gradle b/worldedit-sponge/build.gradle index 0ef1e5361..f65952c91 100644 --- a/worldedit-sponge/build.gradle +++ b/worldedit-sponge/build.gradle @@ -19,6 +19,7 @@ dependencies { compile project(':worldedit-core') compile 'org.spongepowered:spongeapi:7.1.0' compile 'org.bstats:bstats-sponge:1.4' + compile 'net.kyori:text-adapter-spongeapi:1.0.3' testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0-rc1' } diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java index bf1ceb7bd..fe5c626a3 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java @@ -26,6 +26,8 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.auth.AuthorizationException; +import net.kyori.text.TextComponent; +import net.kyori.text.adapter.spongeapi.TextAdapter; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.text.Text; @@ -89,6 +91,11 @@ public class SpongeCommandSender implements Actor { sendColorized(msg, TextColors.RED); } + @Override + public void print(TextComponent component) { + TextAdapter.sendComponent(sender, component); + } + private void sendColorized(String msg, TextColor formatting) { for (String part : msg.split("\n")) { sender.sendMessage(Text.of(formatting, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(part))); diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java index 3793ffb87..10b1f47e8 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java @@ -36,6 +36,8 @@ import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.item.ItemTypes; +import net.kyori.text.TextComponent; +import net.kyori.text.adapter.spongeapi.TextAdapter; import org.spongepowered.api.Sponge; import org.spongepowered.api.data.type.HandTypes; import org.spongepowered.api.entity.living.player.Player; @@ -149,6 +151,11 @@ public class SpongePlayer extends AbstractPlayerActor { sendColorized(msg, TextColors.RED); } + @Override + public void print(TextComponent component) { + TextAdapter.sendComponent(player, component); + } + private void sendColorized(String msg, TextColor formatting) { for (String part : msg.split("\n")) { this.player.sendMessage(Text.of(formatting, TextSerializers.FORMATTING_CODE.deserialize(part)));