mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 07:49:03 +00:00
Test storing and loading a brew from lore
This commit is contained in:
@@ -6,6 +6,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class BIngredients {
|
||||
@@ -321,6 +324,37 @@ public class BIngredients {
|
||||
return copy;
|
||||
}
|
||||
|
||||
public void testStore(DataOutputStream out) throws IOException {
|
||||
out.writeInt(cookedTime);
|
||||
out.writeByte(ingredients.size());
|
||||
for (ItemStack item : ingredients) {
|
||||
out.writeUTF(item.getType().name());
|
||||
out.writeShort(item.getDurability());
|
||||
out.writeShort(item.getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
public void testLoad(DataInputStream in) throws IOException {
|
||||
if (in.readInt() != cookedTime) {
|
||||
P.p.log("cookedtime wrong");
|
||||
}
|
||||
if (in.readUnsignedByte() != ingredients.size()) {
|
||||
P.p.log("size wrong");
|
||||
return;
|
||||
}
|
||||
for (ItemStack item : ingredients) {
|
||||
if (!in.readUTF().equals(item.getType().name())) {
|
||||
P.p.log("name wrong");
|
||||
}
|
||||
if (in.readShort() != item.getDurability()) {
|
||||
P.p.log("dur wrong");
|
||||
}
|
||||
if (in.readShort() != item.getAmount()) {
|
||||
P.p.log("amount wrong");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// saves data into main Ingredient section. Returns the save id
|
||||
public int save(ConfigurationSection config) {
|
||||
String path = "Ingredients." + id;
|
||||
|
||||
Reference in New Issue
Block a user