de.eldoria.jacksonbukkit.serializer.ComponentMiniMessageSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of paper Show documentation
Show all versions of paper Show documentation
Module for serialization on Paper based servers
The newest version!
/*
* SPDX-License-Identifier: MIT
*
* Copyright (C) EldoriaRPG Team and Contributor
*/
package de.eldoria.jacksonbukkit.serializer;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import java.io.IOException;
/**
* Class for serialization of {@link Component} using {@link MiniMessage}.
*/
public class ComponentMiniMessageSerializer extends JsonSerializer {
private final MiniMessage miniMessage;
/**
* Creates a new serializer
*
* @param miniMessage MiniMessage instance to use
*/
public ComponentMiniMessageSerializer(MiniMessage miniMessage) {
this.miniMessage = miniMessage;
}
/**
* Creates a new serializer
*/
public ComponentMiniMessageSerializer() {
this.miniMessage = MiniMessage.miniMessage();
}
@Override
public void serialize(Component value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeString(miniMessage.serialize(value));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy