Package net.glowstone.net.message.play.game

Source Code of net.glowstone.net.message.play.game.UpdateSignMessage

package net.glowstone.net.message.play.game;

import com.flowpowered.networking.Message;
import lombok.Data;
import net.glowstone.util.TextMessage;

@Data
public final class UpdateSignMessage implements Message {

    private final int x, y, z;
    private final TextMessage[] message;

    public UpdateSignMessage(int x, int y, int z, TextMessage[] message) {
        if (message.length != 4) {
            throw new IllegalArgumentException();
        }

        this.x = x;
        this.y = y;
        this.z = z;
        this.message = message;
    }

    public static UpdateSignMessage fromPlainText(int x, int y, int z, String[] message) {
        if (message.length != 4) {
            throw new IllegalArgumentException();
        }

        TextMessage[] encoded = new TextMessage[4];
        for (int i = 0; i < 4; ++i) {
            encoded[i] = new TextMessage(message[i]);
        }
        return new UpdateSignMessage(x, y, z, encoded);
    }

}
TOP

Related Classes of net.glowstone.net.message.play.game.UpdateSignMessage

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.