forked from LeeIzaZombie/RocketMod_TPA
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCommandTpaAccept.cs
90 lines (76 loc) · 3 KB
/
CommandTpaAccept.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Drawing;
using Rocket.API.Commands;
using Rocket.API.Player;
using Rocket.Core.I18N;
using Rocket.Core.Player;
using Rocket.Core.User;
namespace RocketMod_TPA
{
public class CommandTpaAccept : IChildCommand
{
private readonly PluginTpa _tpaPlugin;
public CommandTpaAccept(PluginTpa tpaPlugin)
{
_tpaPlugin = tpaPlugin;
}
public string Name => "Accept";
public string[] Aliases => new[] { "a", "yes" };
public string Summary => "Accepts a teleport request";
public string Description => null;
public string Permission => "tpa.accept";
public string Syntax => "";
public IChildCommand[] ChildCommands => null;
public bool SupportsUser(Type user)
{
return typeof(IPlayerUser).IsAssignableFrom(user);
}
public void Execute(ICommandContext context)
{
var player = ((IPlayerUser)context.User).GetPlayer();
if (!_tpaPlugin.Requests.ContainsKey(player))
{
context.User.SendLocalizedMessage(_tpaPlugin.Translations, "request_none", Color.Red);
return;
}
IPlayer teleporter = _tpaPlugin.Requests[player];
if (teleporter == null || !_tpaPlugin.CheckPlayer(teleporter))
{
_tpaPlugin.Requests.Remove(player);
throw new PlayerNotOnlineException();
}
/*
if (teleporter.Stance == EPlayerStance.DRIVING || teleporter.Stance == EPlayerStance.SITTING)
{
UnturnedChat.Say(teleporter, PluginTPA.Instance.Translate("YouInCar"), Color.red);
UnturnedChat.Say(caller, PluginTPA.Instance.Translate("PlayerInCar"), Color.red);
Requests.Remove(player);
return;
}
*/
if (_tpaPlugin.ConfigurationInstance.TpaDelaySeconds > 0)
{
_tpaPlugin.DelayTeleport(player, teleporter);
return;
}
/*
if (_tpaPlugin.ConfigurationInstance.CancelOnBleeding && teleporter.Bleeding)
{
UnturnedChat.Say(teleporter, PluginTPA.Instance.Translate("error_bleeding"), Color.red);
Requests.Remove(player);
return;
}
*/
player.GetUser().SendLocalizedMessage(_tpaPlugin.Translations, "request_accepted", Color.Yellow, teleporter.Name);
teleporter.GetUser().SendLocalizedMessage(_tpaPlugin.Translations, "request_accepted_1", Color.Yellow, player.Name);
/*
if (ConfigurationInstance.NinjaTP)
{
EffectManager.sendEffect((ushort)PluginTPA.Instance.Configuration.Instance.NinjaEffectID, 30, player.Position);
}
*/
_tpaPlugin.TeleportPlayer(teleporter, player);
_tpaPlugin.Requests.Remove(player);
}
}
}