Package net.glowstone.net

Source Code of net.glowstone.net.ProtocolTestUtils

package net.glowstone.net;

import net.glowstone.entity.meta.MetadataIndex;
import net.glowstone.entity.meta.MetadataMap;
import net.glowstone.util.TextMessage;
import net.glowstone.util.nbt.CompoundTag;
import net.glowstone.util.nbt.TagType;
import org.json.simple.JSONObject;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* Utilities for helping with the protocol test.
*/
public final class ProtocolTestUtils {

    private ProtocolTestUtils() {
    }

    @SuppressWarnings("unchecked")
    public static JSONObject getJson() {
        JSONObject obj = new JSONObject();
        obj.put("key", "value");
        return obj;
    }

    public static TextMessage getTextMessage() {
        return new TextMessage("text");
    }

    public static List<MetadataMap.Entry> getMetadataEntry() {
        List<MetadataMap.Entry> list = new ArrayList<>();
        list.add(new MetadataMap.Entry(MetadataIndex.AGE, 1));
        return list;
    }

    public static CompoundTag getTag() {
        CompoundTag tag = new CompoundTag();
        tag.putInt("int", 5);
        tag.putString("string", "text");
        tag.putList("list", TagType.FLOAT, Arrays.asList(1.f, 2.f, 3.f));
        tag.putCompound("compound", new CompoundTag());
        return tag;
    }
}
TOP

Related Classes of net.glowstone.net.ProtocolTestUtils

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.