mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-16 04:33:56 -07:00
Configurations now properly support lists of serializable objects, and ItemStack is properly serializable. Big thanks to GICodeWarrior for the PR. This fixes BUKKIT-425
By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
package org.bukkit.configuration.file;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -52,4 +59,26 @@ public class YamlConfigurationTest extends FileConfigurationTest {
|
||||
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveRestoreCompositeList() throws InvalidConfigurationException {
|
||||
YamlConfiguration out = getConfig();
|
||||
|
||||
List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
stacks.add(new ItemStack(1));
|
||||
stacks.add(new ItemStack(2));
|
||||
stacks.add(new ItemStack(3));
|
||||
|
||||
out.set("composite-list.abc.def", stacks);
|
||||
String yaml = out.saveToString();
|
||||
|
||||
YamlConfiguration in = new YamlConfiguration();
|
||||
in.loadFromString(yaml);
|
||||
List<Object> raw = in.getList("composite-list.abc.def");
|
||||
|
||||
assertEquals(stacks.size(), raw.size());
|
||||
assertEquals(stacks.get(0), raw.get(0));
|
||||
assertEquals(stacks.get(1), raw.get(1));
|
||||
assertEquals(stacks.get(2), raw.get(2));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user