C# Class MCSharp.Player

Afficher le fichier Open project: Voziv/MCSharp Class Usage Examples

Méthodes publiques

Свойство Type Description
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

Méthodes publiques

Méthode Description
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.

Private Methods

Méthode Description
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

Method Details

Ban() public static méthode

Changes the players rank to banned.
public static Ban ( string name ) : void
name string The player's name to ban
Résultat void

ChangeRank() public static méthode

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
Résultat void

ChangeRank() public static méthode

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
Résultat void

Disconnect() public méthode

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
Résultat void

Exists() public static méthode

Checks to see if a player exists in the list
public static Exists ( byte id ) : bool
id byte The id of the player
Résultat bool

Exists() public static méthode

Checks to see if a player exists in the list
public static Exists ( string name ) : bool
name string the players name
Résultat bool

Find() public static méthode

Finds a player in the list
public static Find ( string name ) : Player
name string The name of the player
Résultat Player

GZip() public static méthode

Zips an array of bytes using gzip
public static GZip ( byte bytes ) : byte[]
bytes byte The bytes to zip
Résultat byte[]

GetColor() public static méthode

Gets the color for a given player
public static GetColor ( string name ) : string
name string The player to get the color for
Résultat string

GetGroup() public static méthode

Get the group of a given player
public static GetGroup ( string name ) : Group
name string The players name
Résultat Group

GetPlayers() public static méthode

Returns the list of players.
public static GetPlayers ( ) : List
Résultat List

GetRank() public static méthode

Gets a players rank
public static GetRank ( string name ) : GroupEnum
name string The player name to get the rank for
Résultat GroupEnum

HandleBlockchange() public méthode

Handles a player blockchange packet
public HandleBlockchange ( byte message ) : void
message byte The blockchange packet
Résultat void

HandleLogin() public méthode

Handles a player login packet
public HandleLogin ( byte message ) : void
message byte The login packet
Résultat void

IsOnline() public static méthode

Determines if the user is online
public static IsOnline ( string name ) : bool
name string The player's name
Résultat bool

Kick() public méthode

Kicks the player with a given message
public Kick ( string message ) : void
message string The reason the player was kicked
Résultat void

Player() public méthode

The main constructor for the player.
public Player ( Socket s ) : System
s Socket The incoming socket connection for the player to bind to
Résultat System

SMPKick() public méthode

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
Résultat void

SendBlockchange() public méthode

public SendBlockchange ( ushort x, ushort y, ushort z, byte type ) : void
x ushort
y ushort
z ushort
type byte
Résultat void

SendChat() public méthode

public SendChat ( Player p, string message ) : void
p Player
message string
Résultat void

SendDie() public méthode

public SendDie ( byte id ) : void
id byte
Résultat void

SendKick() public méthode

public SendKick ( string message ) : void
message string
Résultat void

SendMap() public méthode

public SendMap ( ) : void
Résultat void

SendMessage() public méthode

public SendMessage ( byte id, string message ) : void
id byte
message string
Résultat void

SendMessage() public méthode

public SendMessage ( string message ) : void
message string
Résultat void

SendMotd() public méthode

public SendMotd ( ) : void
Résultat void

SendPing() public méthode

public SendPing ( ) : void
Résultat void

SendPos() public méthode

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
Résultat void

SendRaw() public méthode

public SendRaw ( byte send ) : void
send byte
Résultat void

SendRaw() public méthode

public SendRaw ( int id ) : void
id int
Résultat void

SendRaw() public méthode

public SendRaw ( int id, byte send ) : void
id int
send byte
Résultat void

SendSpawn() public méthode

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
Résultat void

ToString() public méthode

public ToString ( ) : string
Résultat string

UpdatePosition() public méthode

public UpdatePosition ( ) : void
Résultat void

ValidName() public static méthode

Checks to see if a players name is valid
public static ValidName ( string name ) : bool
name string
Résultat bool

initNetworking() public méthode

Initializes the players networking and handles the incoming socket connection.
public initNetworking ( Socket s ) : void
s Socket The incoming socket connection
Résultat void

loginTimerCallback() public méthode

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
Résultat void

Property Details

Loading public_oe property

public bool Loading
Résultat bool

bindings public_oe property

public byte[] bindings
Résultat byte[]

connections public_oe static_oe property

public static List connections
Résultat List

disconnected public_oe property

public bool disconnected
Résultat bool

group public_oe property

public Group group
Résultat Group

hidden public_oe property

public bool hidden
Résultat bool

id public_oe property

public byte id
Résultat byte

ip public_oe property

public string ip
Résultat string

isJailed public_oe property

public bool isJailed
Résultat bool

isJoker public_oe property

public bool isJoker
Résultat bool

isMuted public_oe property

public bool isMuted
Résultat bool

lastSeen public_oe static_oe property

This keeps track of when a player was last seen. Resets when the server is reset.
public static Dictionary lastSeen
Résultat DateTime>.Dictionary

left public_oe static_oe property

This needs a better description. What does left do?
public static Dictionary left
Résultat string>.Dictionary

name public_oe property

public string name
Résultat string

players public_oe static_oe property

public static ThreadedBindingList players
Résultat ThreadedBindingList