Skip to content

Commit

Permalink
Add upgrade guide for V1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Micky5991 committed Jun 1, 2019
1 parent bfe4a31 commit 46e9049
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
4 changes: 2 additions & 2 deletions documentation/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Command Handlers are an easy way to register new commands. A command handler is
You can register new command handlers by calling following method:

```cs
public class Main implements IResource {
public class Main : IResource {

public Main()
{
Expand Down Expand Up @@ -74,7 +74,7 @@ Delegate commands are an alternative way to add or register commands without the
#### Registration

```cs
public class Main implements IResource {
public class Main : IResource {

public Main()
{
Expand Down
4 changes: 4 additions & 0 deletions documentation/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
href: installation.md
- name: First resource
href: first-resource.md
- name: Upgrade
items:
- name: v1.1 to v1.2
href: upgrade-1_2.md
- name: Events
href: events.md
- name: Commands
Expand Down
75 changes: 75 additions & 0 deletions documentation/upgrade-1_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Upgrade from v1.1 to v1.2

This version contains many changes in favor of stability and performance. In this guide we list all breaking changes and how to migrate to the latest implementations.

## Migration

### Events

All events received an overhaul and now follow the [standard .NET event pattern](https://docs.microsoft.com/en-us/dotnet/csharp/event-pattern). The event-signature now contains the sender of that event and the arguments as the second parameter.

#### Changes

Before:
```cs
public async Task OnPlayerReady(IPlayer player)
{
player.OutputChatBox("Hey!");
}
```

After:
```cs
public async Task OnPlayerReady(object sender, PlayerEventArgs eventArgs)
{
IPlayer player = eventArgs.Player;

player.OutputChatBox("Hey!");
}
```

### Properties

We replaced all properties with getter and setter methods to streamline synchronous and asynchronous methods. This way is much cleaner in regards of exception handling and simplicity in combination with asynchronous methods.

#### Changes

Before
```cs
Vector3 position = player.Position;

player.Position += new Vector3(0, 1, 0);
```

After
```cs
Vector3 position = player.GetPosition();

player.SetPosition(position + new Vector3(0, 1, 0));
```

### Utility API

In order to clean up the `MP` class we moved all methods into a special utility class, accessible from `MP.Utility`.

[See IUtility interface documentation](~/api/AlternateLife.RageMP.Net.Interfaces.IUtility.yml)

#### Changes

Before
```cs
MP.Joaat("name");

MP.Schedule(() => {
// Calls
});
```

After
```cs
MP.Utility.Joaat("name");

MP.Utility.Schedule(() => {
// Calls
});
```

0 comments on commit 46e9049

Please sign in to comment.