MCForge / MCForge-Vanilla-Redux

Restart of MCForge Vanilla featuring ClassiCube support.
http://mcforge.org
Other
8 stars 11 forks source link

[Suggestion] Add more player event handlers. #11

Open EricKilla opened 10 years ago

EricKilla commented 10 years ago

For example, Dzienny has a "Player.Joined" event, and we don't. It allows for custom commands to trigger when a player has joined the server.

Also a death event handler should be added.

Also the HandleDeath method is gone (if it existed to begin with).

ghost commented 10 years ago

The HandleDeath method is still there in Player.cs, and there is an event for Player Death (OnPlayerDeath), and for the Player.Joined event, we have OnPlayerConnect. 1 step ahead bro ;p

Peteys93 commented 10 years ago

A comment on the HandleDeath issue. It was found when custom commands that were using HandleDeath were messing up.

The error was resolved by changing the occurrence of Block.rock in the p.HandleDeath portion of the command to ((ushort)Block.rock). I assume this has something to do with changing things to ushorts recently, though the non-explicit 'Block.rock' still works fine in existing commands (e.g. /kill, /gun, etc.) as far as I can tell.

The error message was something along the lines of 'cannot find HandleDeath(byte,system.message,boolean)' before it was fixed by explicitly casting Block.rock as a ushort.

ghost commented 10 years ago

We have already changed them in existing commands, custom commands are easy to convert, change byte to ushort in the needed areas

ecp4224 commented 10 years ago

Breaking API changes should be avoid when possible, in this case, it can be avoided.

Add a method of HandleDeath that accepts a byte instead of a ushort that simply runs the ushort HandleDeath method via casting, then mark the method as deprecated

Ex:

[Obsolete("Blocks are no longer bytes, use the ushort overload instead.")]
public void HandleDeath(byte b, string customMessage = "", bool explode = false) {
    HandleDeath((ushort)b, customMessage, explode);
}

public void HandleDeath(ushort b, string customMessage = "", bool explode = false) {
    .......
}
DeveloperJose commented 10 years ago

Agreed. The server is more extendable when you have more events.