package common.network;

import java.util.List;

import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.SoundEvent;
import common.inventory.Container;
import common.inventory.IInventory;
import common.item.ItemStack;
import common.packet.CPacketAction;
import common.packet.CPacketBreak;
import common.packet.CPacketCheat;
import common.packet.CPacketClick;
import common.packet.CPacketComplete;
import common.packet.CPacketForm;
import common.packet.CPacketInput;
import common.packet.CPacketKeepAlive;
import common.packet.CPacketMessage;
import common.packet.CPacketPlace;
import common.packet.CPacketPlayer;
import common.packet.CPacketSign;
import common.packet.CPacketSkin;
import common.potion.PotionEffect;
import common.tileentity.IInteractionObject;
import common.tileentity.TileEntitySign;
import common.util.BlockPos;
import common.util.CharValidator;
import common.util.ChunkPos;
import common.util.PortalType;

public interface IPlayer extends NetHandler {
	public static class UserValidator implements CharValidator {
		public boolean valid(char ch) {
			return (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_' || ch == '-';
		}
	}

	public static class NickValidator implements CharValidator {
		public boolean valid(char ch) {
			return (ch <= 0xff && Character.isLetterOrDigit(ch)) || (ch >= 32 && ch < 126);
		}
	}

	public static final int MAX_USER_LENGTH = 16;
	public static final int MAX_NICK_LENGTH = 32;
	public static final int MAX_PASS_LENGTH = 64;
	public static final int MAX_CMD_LENGTH = 1024;
	public static final int MAX_INFO_LENGTH = 4096;
	public static final int MAX_SKIN_SIZE = 65536;
	public static final CharValidator VALID_USER = new IPlayer.UserValidator();
	public static final CharValidator VALID_NICK = new IPlayer.NickValidator();

	public static boolean isValidNick(String user) {
		return VALID_NICK.valid(user);
	}

	public static boolean isValidUser(String user) {
		return VALID_USER.valid(user);
	}

	void onEntityDeath();
	boolean isInEditor();
	EntityNPC getPresentEntity();
	String getUser();
	int getLatency();
	boolean isAdmin();
	void addToPlayerScore(EntityLiving entity);
	void displayTradeGui(EntityNPC entity);
	void setPlayerHealthUpdated();
	void removeEntity(Entity entity);
	void sendPlayerAbilities();
	void addFeed(String msg);
	void addHotbar(String msg);
	void addHotbar(String format, Object... args);
	void sendThrowMessage(ItemStack stack);
	void resetLastExperience();
	void travelToDimension(int dimension, BlockPos pos, float yaw, float pitch, PortalType portal);
	void teleport(double x, double y, double z, float yaw, float pitch, int dimension);
	void onItemPickup(Entity entity, int amount);
	void mountEntity(Entity entity);
	void openEditSign(TileEntitySign signTile);
	void displayGui(IInteractionObject guiOwner);
	void displayGUIChest(IInventory chestInventory);
	void displayEntityGui(Entity entity, IInventory inventory);
	void closeScreen();
	void onItemUseFinish();
	void onNewEffect(PotionEffect id);
	void onChangedEffect(PotionEffect id, boolean added);
	void onFinishedEffect(PotionEffect effect);
	void setPositionAndUpdate(double x, double y, double z);
	void onCriticalHit(Entity entity);
	void onEnchantmentCritical(Entity entity);
	void updateEffectMeta();
	void playSound(SoundEvent name, float volume);
	void sendContainerToPlayer(Container container);
	void updateEntity();
	void setSelection(boolean primary, BlockPos pos);
	void setSelectMode();
	void sendPacket(Packet packet);
	void setPlayerLocation(double x, double y, double z, float yaw, float pitch);
	List<ChunkPos> getLoadedChunkList();
	double getManagedX();
	double getManagedZ();
	void setManagedPos(double x, double z);

	void processKeepAlive(CPacketKeepAlive packet);
	void processMessage(CPacketMessage packet);
	void processComplete(CPacketComplete packet);
	void processPlayer(CPacketPlayer packet);
	void processBreak(CPacketBreak packet);
	void processPlace(CPacketPlace packet);
	void processAction(CPacketAction packet);
	void processInput(CPacketInput packet);
	void processClick(CPacketClick packet);
	void processCheat(CPacketCheat packet);
	void processSign(CPacketSign packet);
	void processSkin(CPacketSkin packet);
	void processForm(CPacketForm packet);
}
