/FileExtraction/Java_unseen/Wind-Development_WindSpigot/WindSpigot-Server/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
package net.minecraft.server;

import java.io.IOException;

public class PacketPlayOutTitle implements Packet<PacketListenerPlayOut> {

	private EnumTitleAction a;
	private IChatBaseComponent b;
	private int c;
	private int d;
	private int e;

	// Paper start
	public net.md_5.bungee.api.chat.BaseComponent[] components;

	public PacketPlayOutTitle(EnumTitleAction action, net.md_5.bungee.api.chat.BaseComponent[] components, int fadeIn,
			int stay, int fadeOut) {
		this.a = action;
		this.components = components;
		this.c = fadeIn;
		this.d = stay;
		this.e = fadeOut;
	}
	// Paper end

	public PacketPlayOutTitle() {
	}

	public PacketPlayOutTitle(EnumTitleAction packetplayouttitle_enumtitleaction,
			IChatBaseComponent ichatbasecomponent) {
		this(packetplayouttitle_enumtitleaction, ichatbasecomponent, -1, -1, -1);
	}

	public PacketPlayOutTitle(int i, int j, int k) {
		this(EnumTitleAction.TIMES, (IChatBaseComponent) null, i, j, k);
	}

	public PacketPlayOutTitle(EnumTitleAction packetplayouttitle_enumtitleaction, IChatBaseComponent ichatbasecomponent,
			int i, int j, int k) {
		this.a = packetplayouttitle_enumtitleaction;
		this.b = ichatbasecomponent;
		this.c = i;
		this.d = j;
		this.e = k;
	}

	@Override
	public void a(PacketDataSerializer serializer) throws IOException {
		this.a = serializer.a(EnumTitleAction.class);
		if (this.a == EnumTitleAction.TITLE || this.a == EnumTitleAction.SUBTITLE) {
			this.b = serializer.d();
		}

		if (this.a == EnumTitleAction.TIMES) {
			this.c = serializer.readInt();
			this.d = serializer.readInt();
			this.e = serializer.readInt();
		}

	}

	@Override
	public void b(PacketDataSerializer serializer) throws IOException {
		serializer.a(this.a);
		if (this.a == EnumTitleAction.TITLE || this.a == EnumTitleAction.SUBTITLE) {
			// Paper start
			if (this.components != null) {
				serializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(components));
			} else {
				serializer.a(this.b);
			}
			// Paper end
		}

		if (this.a == EnumTitleAction.TIMES) {
			serializer.writeInt(this.c);
			serializer.writeInt(this.d);
			serializer.writeInt(this.e);
		}

	}

	@Override
	public void a(PacketListenerPlayOut packetlistenerplayout) {
		packetlistenerplayout.a(this);
	}

	// PaperSpigot start - fix compile error
	/*
	 * public void a(PacketListener packetlistener) { this.a((PacketListenerPlayOut)
	 * packetlistener); }
	 */
	// PaperSpigot end

	public static enum EnumTitleAction {

		TITLE, SUBTITLE, TIMES, CLEAR, RESET;

		private EnumTitleAction() {
		}

		public static EnumTitleAction a(String s) {
			EnumTitleAction[] apacketplayouttitle_enumtitleaction = values();
			int i = apacketplayouttitle_enumtitleaction.length;

			for (int j = 0; j < i; ++j) {
				EnumTitleAction packetplayouttitle_enumtitleaction = apacketplayouttitle_enumtitleaction[j];

				if (packetplayouttitle_enumtitleaction.name().equalsIgnoreCase(s)) {
					return packetplayouttitle_enumtitleaction;
				}
			}

			return EnumTitleAction.TITLE;
		}

		public static String[] a() {
			String[] astring = new String[values().length];
			int i = 0;
			EnumTitleAction[] apacketplayouttitle_enumtitleaction = values();
			int j = apacketplayouttitle_enumtitleaction.length;

			for (int k = 0; k < j; ++k) {
				EnumTitleAction packetplayouttitle_enumtitleaction = apacketplayouttitle_enumtitleaction[k];

				astring[i++] = packetplayouttitle_enumtitleaction.name().toLowerCase();
			}

			return astring;
		}
	}
}
