From bae49352efa114d583de91f6c407786e74d0d9e5 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 19 Jul 2017 22:50:57 +0200 Subject: [PATCH] Hopefully fixed the SerializationException --- pom.xml | 12 +++++++++++- .../chat/formatting/ChatFormatterBuilder.java | 13 ++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index c0873d6..c1b0016 100644 --- a/pom.xml +++ b/pom.xml @@ -112,12 +112,16 @@ + + projectlombok.org + http://projectlombok.org/mavenrepo + org.spigotmc spigot-api - 1.9.2-R0.1-SNAPSHOT + 1.12-R0.1-SNAPSHOT com.github.TBMCPlugins.ButtonCore @@ -159,6 +163,12 @@ 1.6 provided + + org.projectlombok + lombok + 1.16.16 + provided + ButtonChat diff --git a/src/main/java/buttondevteam/chat/formatting/ChatFormatterBuilder.java b/src/main/java/buttondevteam/chat/formatting/ChatFormatterBuilder.java index 9177a31..1f2df12 100644 --- a/src/main/java/buttondevteam/chat/formatting/ChatFormatterBuilder.java +++ b/src/main/java/buttondevteam/chat/formatting/ChatFormatterBuilder.java @@ -1,12 +1,15 @@ package buttondevteam.chat.formatting; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.function.BiFunction; import java.util.regex.Pattern; -import org.apache.commons.lang.SerializationUtils; - import buttondevteam.lib.chat.*; +import lombok.SneakyThrows; public class ChatFormatterBuilder implements Serializable { private static final long serialVersionUID = -6115913400749778686L; @@ -23,8 +26,12 @@ public class ChatFormatterBuilder implements Serializable { short removecharcount = 0; boolean range = false; + @SneakyThrows public ChatFormatter build() { - return new ChatFormatter((ChatFormatterBuilder) SerializationUtils.clone(this)); + final ByteArrayOutputStream str = new ByteArrayOutputStream(); + new ObjectOutputStream(str).writeObject(this); + return new ChatFormatter( + (ChatFormatterBuilder) new ObjectInputStream(new ByteArrayInputStream(str.toByteArray())).readObject()); } public Pattern getRegex() {