C# Класс MCSharp.Player

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
Loading bool
bindings byte[]
connections List
disconnected bool
group Group
hidden bool
id byte
ip string
isJailed bool
isJoker bool
isMuted bool
lastSeen DateTime>.Dictionary
left string>.Dictionary
name string
players ThreadedBindingList

Открытые методы

Метод Описание
Ban ( string name ) : void

Changes the players rank to banned.

ChangeRank ( Player p, GroupEnum g ) : void

Changes a players rank

ChangeRank ( string name, GroupEnum g ) : void

Changes the given players rank

Disconnect ( ) : void

Handles a player disconnection. Cleans up the player from other players on the server as well as handles cleaning up the player from the system.

Exists ( byte id ) : bool

Checks to see if a player exists in the list

Exists ( string name ) : bool

Checks to see if a player exists in the list

Find ( string name ) : Player

Finds a player in the list

GZip ( byte bytes ) : byte[]

Zips an array of bytes using gzip

GetColor ( string name ) : string

Gets the color for a given player

GetGroup ( string name ) : Group

Get the group of a given player

GetPlayers ( ) : List

Returns the list of players.

GetRank ( string name ) : GroupEnum

Gets a players rank

HandleBlockchange ( byte message ) : void

Handles a player blockchange packet

HandleLogin ( byte message ) : void

Handles a player login packet

IsOnline ( string name ) : bool

Determines if the user is online

Kick ( string message ) : void

Kicks the player with a given message

Player ( Socket s ) : System

The main constructor for the player.

SMPKick ( string message ) : void

A kick function that works for the new SMP clients. That way they have a friendly way of being removed from the server instead of "Invalid packet id 2"

SendBlockchange ( ushort x, ushort y, ushort z, byte type ) : void
SendChat ( Player p, string message ) : void
SendDie ( byte id ) : void
SendKick ( string message ) : void
SendMap ( ) : void
SendMessage ( byte id, string message ) : void
SendMessage ( string message ) : void
SendMotd ( ) : void
SendPing ( ) : void
SendPos ( byte id, ushort x, ushort y, ushort z, byte rotx, byte roty ) : void
SendRaw ( byte send ) : void
SendRaw ( int id ) : void
SendRaw ( int id, byte send ) : void
SendSpawn ( byte id, string name, ushort x, ushort y, ushort z, byte rotx, byte roty ) : void
ToString ( ) : string
UpdatePosition ( ) : void
ValidName ( string name ) : bool

Checks to see if a players name is valid

initNetworking ( Socket s ) : void

Initializes the players networking and handles the incoming socket connection.

loginTimerCallback ( Object sender, ElapsedEventArgs e ) : void

Handles the login timer callback once it finishes. If the player has not been authenticated then we kick them.

Приватные методы

Метод Описание
CheckBlockSpam ( ) : bool

Detects whether or not a player is spamming blocks around the map

FreeId ( ) : byte

Find the next free id available

HTNO ( short x ) : byte[]

Converts a short to network byte order

HTNO ( ushort x ) : byte[]

Converts a ushort to network byte order

HandleMessage ( byte buffer ) : byte[]

Handles messages in the buffer

NTHO ( byte x, int offset ) : ushort

Converts a ushort to host byte order

Receive ( IAsyncResult result ) : void

Handles network callbacks and adding to the players buffer

StringFormat ( string str, int size ) : byte[]

Formats a string

Wordwrap ( string message ) : List

Performs wordwrap on a string

checkOp ( ) : bool

Checks to see if the player has operator permissions

Описание методов

Ban() публичный статический Метод

Changes the players rank to banned.
public static Ban ( string name ) : void
name string The player's name to ban
Результат void

ChangeRank() публичный статический Метод

Changes a players rank
public static ChangeRank ( Player p, GroupEnum g ) : void
p Player The player object to change
g GroupEnum The rank to change the player to
Результат void

ChangeRank() публичный статический Метод

Changes the given players rank
public static ChangeRank ( string name, GroupEnum g ) : void
name string The name of the player
g GroupEnum The players new rank
Результат void

Disconnect() публичный Метод

Handles a player disconnection. Cleans up the player from other players on the server as well as handles cleaning up the player from the system.
public Disconnect ( ) : void
Результат void

Exists() публичный статический Метод

Checks to see if a player exists in the list
public static Exists ( byte id ) : bool
id byte The id of the player
Результат bool

Exists() публичный статический Метод

Checks to see if a player exists in the list
public static Exists ( string name ) : bool
name string the players name
Результат bool

Find() публичный статический Метод

Finds a player in the list
public static Find ( string name ) : Player
name string The name of the player
Результат Player

GZip() публичный статический Метод

Zips an array of bytes using gzip
public static GZip ( byte bytes ) : byte[]
bytes byte The bytes to zip
Результат byte[]

GetColor() публичный статический Метод

Gets the color for a given player
public static GetColor ( string name ) : string
name string The player to get the color for
Результат string

GetGroup() публичный статический Метод

Get the group of a given player
public static GetGroup ( string name ) : Group
name string The players name
Результат Group

GetPlayers() публичный статический Метод

Returns the list of players.
public static GetPlayers ( ) : List
Результат List

GetRank() публичный статический Метод

Gets a players rank
public static GetRank ( string name ) : GroupEnum
name string The player name to get the rank for
Результат GroupEnum

HandleBlockchange() публичный Метод

Handles a player blockchange packet
public HandleBlockchange ( byte message ) : void
message byte The blockchange packet
Результат void

HandleLogin() публичный Метод

Handles a player login packet
public HandleLogin ( byte message ) : void
message byte The login packet
Результат void

IsOnline() публичный статический Метод

Determines if the user is online
public static IsOnline ( string name ) : bool
name string The player's name
Результат bool

Kick() публичный Метод

Kicks the player with a given message
public Kick ( string message ) : void
message string The reason the player was kicked
Результат void

Player() публичный Метод

The main constructor for the player.
public Player ( Socket s ) : System
s Socket The incoming socket connection for the player to bind to
Результат System

SMPKick() публичный Метод

A kick function that works for the new SMP clients. That way they have a friendly way of being removed from the server instead of "Invalid packet id 2"
public SMPKick ( string message ) : void
message string The message to kick a SMP player with
Результат void

SendBlockchange() публичный Метод

public SendBlockchange ( ushort x, ushort y, ushort z, byte type ) : void
x ushort
y ushort
z ushort
type byte
Результат void

SendChat() публичный Метод

public SendChat ( Player p, string message ) : void
p Player
message string
Результат void

SendDie() публичный Метод

public SendDie ( byte id ) : void
id byte
Результат void

SendKick() публичный Метод

public SendKick ( string message ) : void
message string
Результат void

SendMap() публичный Метод

public SendMap ( ) : void
Результат void

SendMessage() публичный Метод

public SendMessage ( byte id, string message ) : void
id byte
message string
Результат void

SendMessage() публичный Метод

public SendMessage ( string message ) : void
message string
Результат void

SendMotd() публичный Метод

public SendMotd ( ) : void
Результат void

SendPing() публичный Метод

public SendPing ( ) : void
Результат void

SendPos() публичный Метод

public SendPos ( byte id, ushort x, ushort y, ushort z, byte rotx, byte roty ) : void
id byte
x ushort
y ushort
z ushort
rotx byte
roty byte
Результат void

SendRaw() публичный Метод

public SendRaw ( byte send ) : void
send byte
Результат void

SendRaw() публичный Метод

public SendRaw ( int id ) : void
id int
Результат void

SendRaw() публичный Метод

public SendRaw ( int id, byte send ) : void
id int
send byte
Результат void

SendSpawn() публичный Метод

public SendSpawn ( byte id, string name, ushort x, ushort y, ushort z, byte rotx, byte roty ) : void
id byte
name string
x ushort
y ushort
z ushort
rotx byte
roty byte
Результат void

ToString() публичный Метод

public ToString ( ) : string
Результат string

UpdatePosition() публичный Метод

public UpdatePosition ( ) : void
Результат void

ValidName() публичный статический Метод

Checks to see if a players name is valid
public static ValidName ( string name ) : bool
name string
Результат bool

initNetworking() публичный Метод

Initializes the players networking and handles the incoming socket connection.
public initNetworking ( Socket s ) : void
s Socket The incoming socket connection
Результат void

loginTimerCallback() публичный Метод

Handles the login timer callback once it finishes. If the player has not been authenticated then we kick them.
public loginTimerCallback ( Object sender, ElapsedEventArgs e ) : void
sender Object
e ElapsedEventArgs
Результат void

Описание свойств

Loading публичное свойство

public bool Loading
Результат bool

bindings публичное свойство

public byte[] bindings
Результат byte[]

connections публичное статическое свойство

public static List connections
Результат List

disconnected публичное свойство

public bool disconnected
Результат bool

group публичное свойство

public Group group
Результат Group

hidden публичное свойство

public bool hidden
Результат bool

id публичное свойство

public byte id
Результат byte

ip публичное свойство

public string ip
Результат string

isJailed публичное свойство

public bool isJailed
Результат bool

isJoker публичное свойство

public bool isJoker
Результат bool

isMuted публичное свойство

public bool isMuted
Результат bool

lastSeen публичное статическое свойство

This keeps track of when a player was last seen. Resets when the server is reset.
public static Dictionary lastSeen
Результат DateTime>.Dictionary

left публичное статическое свойство

This needs a better description. What does left do?
public static Dictionary left
Результат string>.Dictionary

name публичное свойство

public string name
Результат string

players публичное статическое свойство

public static ThreadedBindingList players
Результат ThreadedBindingList