Skip to content

Commit

Permalink
Add tpr and added /tpa <playerName>
Browse files Browse the repository at this point in the history
  • Loading branch information
negrifelipe committed Dec 8, 2021
1 parent ab7b9bf commit 7f39c59
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
33 changes: 23 additions & 10 deletions Feli.RocketMod.Teleporting/Commands/TpaCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ public void Execute(IRocketPlayer caller, string[] command)
var plugin = Plugin.Instance;
var messageColor = plugin.MessageColor;
var messageIcon = plugin.Configuration.Instance.MessageIcon;

if (command.Length < 1)
{
Say(caller, plugin.Translate("TpaCommand:WrongUsage"), messageColor, messageIcon);
return;
}

var player = (UnturnedPlayer) caller;

var type = command[0].ToLower();

var teleportsManager = plugin.TeleportsManager;

if (type == "s" | type == "send")
Expand All @@ -38,21 +38,31 @@ public void Execute(IRocketPlayer caller, string[] command)

if (target == null)
{
Say(caller, plugin.Translate("TpaCommand:WrongUsage:NotFound", command[1]), messageColor, messageIcon);
Say(caller, plugin.Translate("TpaCommand:WrongUsage:NotFound", command[1]), messageColor,
messageIcon);
return;
}

teleportsManager.Send(player, target);
}
else if (type == "a" | type == "accept")
teleportsManager.Accept(player);
else if (type == "c" | type == "cancel")
teleportsManager.Cancel(player);
else if(type == "l" | type == "list")
else if (type == "l" | type == "list")
teleportsManager.List(player);
else
{
Say(caller, plugin.Translate("TpaCommand:WrongUsage"), messageColor, messageIcon);
var target = UnturnedPlayer.FromName(command[0]);

if (target == null)
{
Say(caller, plugin.Translate("TpaCommand:WrongUsage:NotFound", command[0]), messageColor,
messageIcon);
return;
}

teleportsManager.Send(player, target);
}
}

Expand All @@ -66,8 +76,11 @@ private void Say(IRocketPlayer rocketPlayer, string message, Color messageColor,
public AllowedCaller AllowedCaller => AllowedCaller.Player;
public string Name => "tpa";
public string Help => "Send, accept, deny and cancel teleport requests";
public string Syntax => "<accept|send|cancel|list>";
public List<string> Aliases => new List<string>();
public string Syntax => "<playerName|accept|send|cancel|list>";
public List<string> Aliases => new List<string>()
{
"tpr"
};
public List<string> Permissions => new List<string>();
}
}
2 changes: 1 addition & 1 deletion Feli.RocketMod.Teleporting/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected override void Unload()

public override TranslationList DefaultTranslations => new TranslationList()
{
{"TpaCommand:WrongUsage", "Correct command usage: /tpa <accept|send|cancel|list>"},
{"TpaCommand:WrongUsage", "Correct command usage: /tpa <playerName|accept|send|cancel|list>"},
{"TpaCommand:WrongUsage:Send", "Correct command usage: /tpa send <playerName>"},
{"TpaCommand:WrongUsage:NotFound", "Player with name {0} was not found"},
{"TpaCommand:Send:Yourself", "There is no point on sending a tpa request to yourself"},
Expand Down

0 comments on commit 7f39c59

Please sign in to comment.