mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
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:
parent
935ab22477
commit
4402484d47
10
pom.xml
10
pom.xml
@ -219,27 +219,27 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-serializer-gson</artifactId>
|
<artifactId>adventure-text-serializer-gson</artifactId>
|
||||||
<version>4.5.1</version>
|
<version>4.7.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-api</artifactId>
|
<artifactId>adventure-api</artifactId>
|
||||||
<version>4.5.1</version>
|
<version>4.7.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-nbt</artifactId>
|
<artifactId>adventure-nbt</artifactId>
|
||||||
<version>4.5.1</version>
|
<version>4.7.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-key</artifactId>
|
<artifactId>adventure-key</artifactId>
|
||||||
<version>4.5.1</version>
|
<version>4.7.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-serializer-gson-legacy-impl</artifactId>
|
<artifactId>adventure-text-serializer-gson-legacy-impl</artifactId>
|
||||||
<version>4.5.1</version>
|
<version>4.7.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
|
@ -16,9 +16,12 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TextUtils {
|
public class TextUtils {
|
||||||
|
|
||||||
private static @Nullable LegacyComponentSerializer customLegacySerializer;
|
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
|
* 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
|
* @param componentsArray target array
|
||||||
|
33
src/test/java/com/gmail/nossr50/util/text/TextUtilsTest.java
Normal file
33
src/test/java/com/gmail/nossr50/util/text/TextUtilsTest.java
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user