Skip to content

Instantly share code, notes, and snippets.

@odenforge
odenforge / .java
Created May 31, 2017 05:56
Item stack serial
public String serializeItemStack(ItemStack itemStack) {
ConfigurationNode node = DataTranslators.CONFIGURATION_NODE.translate(itemStack.createSnapshot().toContainer());
StringWriter stringWriter = new StringWriter();
try {
HoconConfigurationLoader.builder().setSink(() -> new BufferedWriter(stringWriter)).build().save(node);
} catch (IOException e) {
e.printStackTrace();
return null;
}
package com.odenshop.shop;
import java.util.Arrays;
import java.util.List;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.data.DataHolder;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.effect.sound.SoundTypes;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;