-
Notifications
You must be signed in to change notification settings - Fork 0
/
Events.cs
71 lines (66 loc) · 2.34 KB
/
Events.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
namespace SkyEssentials
{
using OpenAPI.Events;
using OpenAPI.Events.Entity;
using OpenAPI.Events.Player;
using OpenAPI.Player;
using System;
/// <summary>
/// Defines the <see cref="Events" />.
/// </summary>
public class Events : IEventHandler
{
/// <summary>
/// Defines the Plugin.
/// </summary>
public SkyEssentials Plugin;
/// <summary>
/// Initializes a new instance of the <see cref="Events"/> class.
/// </summary>
/// <param name="caller">The caller<see cref="SkyEssentials"/>.</param>
public Events(SkyEssentials caller) => Plugin = caller;
/// <summary>
/// The OnJoin.
/// </summary>
/// <param name="e">The e<see cref="PlayerJoinEvent"/>.</param>
[EventHandler]
public void OnJoin(PlayerJoinEvent e)
{
var player = e.Player;
player.PermissionLevel = MiNET.Net.PermissionLevel.Member;
player.ActionPermissions = MiNET.Net.ActionPermissions.Default;
player.SendAdventureSettings();
player.SendMessage("Joined!");
Plugin.BroadcastMessage($"§e[§a+§e] §6{player.Username} §fjust joined!");
}
/// <summary>
/// The OnChat.
/// </summary>
/// <param name="e">The e<see cref="PlayerChatEvent"/>.</param>
[EventHandler]
public void OnChat(PlayerChatEvent e)
{
}
/// <summary>
/// The OnEntityKilled.
/// </summary>
/// <param name="e">The e<see cref="EntityKilledEvent"/>.</param>
[EventHandler]
public void OnEntityKilled(EntityKilledEvent e)
{
if (!(e.Entity is OpenPlayer))
return;
var player = (OpenPlayer)e.Entity;
e.SetCancelled(true);
if (!player.Level.KeepInventory)
player.DropInventory();
player.HealthManager.Health = player.HealthManager.MaxHealth;
//Rewriting the death only for this line lol..
player.Teleport(player.Level.SpawnPoint);
player.RemoveAllEffects();
player.HungerManager.Hunger = player.HungerManager.MaxHunger;
//Yeah i should do better messages
//Plugin.BroadcastMessage($"{player.Username} is dead");
}
}
}