Hopefully fixed the SerializationException

This commit is contained in:
Norbi Peti 2017-07-19 22:50:57 +02:00
parent 2aa0443286
commit bae49352ef
2 changed files with 21 additions and 4 deletions

12
pom.xml
View file

@ -112,12 +112,16 @@
</repository>
<!-- <repository> <id>WorldEdit</id> <url>http://maven.sk89q.com/artifactory/repo</url>
</repository> -->
<repository>
<id>projectlombok.org</id>
<url>http://projectlombok.org/mavenrepo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.9.2-R0.1-SNAPSHOT</version>
<version>1.12-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
@ -159,6 +163,12 @@
<version>1.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.16</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ButtonChat</artifactId>
<organization>

View file

@ -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() {