Fixed NoClassDefFoundError caused by latest Adventure-platform snapshot. (#4446)

* Bumped adventure versions

* Added Unit Test to ensure Adventure being set up correctly
This commit is contained in:
TheBusyBiscuit 2021-03-09 17:15:11 +01:00 committed by GitHub
parent 935ab22477
commit 4402484d47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 6 deletions

10
pom.xml
View File

@ -219,27 +219,27 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson</artifactId>
<version>4.5.1</version>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.5.1</version>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-nbt</artifactId>
<version>4.5.1</version>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-key</artifactId>
<version>4.5.1</version>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson-legacy-impl</artifactId>
<version>4.5.1</version>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>

View File

@ -16,9 +16,12 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
public class TextUtils {
private static @Nullable LegacyComponentSerializer customLegacySerializer;
private TextUtils() {
// We don't want any instances of this class.
}
/**
* Makes a single component from an array of components, can optionally add prefixes and suffixes to come before and after each component
* @param componentsArray target array

View File

@ -0,0 +1,33 @@
package com.gmail.nossr50.util.text;
import org.junit.Assert;
import org.junit.Test;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor;
/**
* This Unit Test checks if Adventure was set up correctly and works as expected.
* Normally we can rely on this to be the case. However sometimes our dependencies
* lack so far behind that things stop working correctly.
* This test ensures that basic functionality is guaranteed to work as we would expect.
*
* See https://github.com/mcMMO-Dev/mcMMO/pull/4446
*
*/
public class TextUtilsTest {
@Test
public void testColorizeText() {
String inputText = "&4This text should be red.";
/*
* If this method raises an exception, we know Adventure is not set up correctly.
* This will also make the test fail and warn us about it.
*/
TextComponent component = TextUtils.colorizeText(inputText);
Assert.assertEquals("Looks like Adventure is not working correctly.",
NamedTextColor.DARK_RED, component.color());
}
}