diff --git a/CommandLocate.cs b/CommandLocate.cs index a0dfab5..bb59947 100644 --- a/CommandLocate.cs +++ b/CommandLocate.cs @@ -1,68 +1,74 @@ using System; using System.Collections.Generic; +using Rocket.API; +using Rocket.Unturned.Chat; using Rocket.Unturned.Commands; using Rocket.Unturned.Player; -using Rocket.Unturned; - namespace TeleportUtil { public class CommandLocate : IRocketCommand { + public bool AllowFromConsole + { + get { return true; } + } + + public string Name + { + get { return "locate"; } + } + + public string Help + { + get { return "Prints out the location of a player on the map for usage in the /tp command."; } + } + + public string Syntax + { + get { return "[\"name\"]"; } + } + public List Aliases { get { return new List(); } } - public void Execute(RocketPlayer caller, string[] command) + public List Permissions + { + get { return new List() { "TeleportUtil.locate" }; } + } + + public void Execute(IRocketPlayer caller, string[] command) { - if ((caller == null && command.Length < 1) || command.Length > 1) + if ((caller is ConsolePlayer && command.Length < 1) || command.Length > 1) { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("can't_locate_player", new object[] {})); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("can't_locate_player")); return; } if (command.Length == 1) { if (!caller.HasPermission("locate.other")) { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("locate_other_not_allowed", new object[] { })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("locate_other_not_allowed")); return; } - RocketPlayer target = RocketPlayer.FromName(command[0]); + UnturnedPlayer target = command.GetUnturnedPlayerParameter(0); if (target == null) { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("can't_locate_player", new object[] { })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("can't_locate_player")); return; } else { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("location_on_map_other", new object[] { target.CharacterName.Truncate(14), Math.Round(target.Position.x, 2), Math.Round(target.Position.y, 2), Math.Round(target.Position.z, 2) })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("location_on_map_other", target.CharacterName.Truncate(14), Math.Round(target.Position.x, 2), Math.Round(target.Position.y, 2), Math.Round(target.Position.z, 2))); } } else { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("location_on_map", new object[] { Math.Round(caller.Position.x, 2), Math.Round(caller.Position.y, 2), Math.Round(caller.Position.z, 2) })); + UnturnedPlayer unturnedCaller = UnturnedPlayer.FromName(caller.Id); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("location_on_map", Math.Round(unturnedCaller.Position.x, 2), Math.Round(unturnedCaller.Position.y, 2), Math.Round(unturnedCaller.Position.z, 2))); } } - - public string Help - { - get { return "Prints out the location of a player on the map for usage in the /tp command."; } - } - - public string Name - { - get { return "locate"; } - } - - public bool RunFromConsole - { - get { return true; } - } - - public string Syntax - { - get { return "[\"name\"]"; } - } } } diff --git a/CommandTprel.cs b/CommandTprel.cs index 1ef08ad..ee101ea 100644 --- a/CommandTprel.cs +++ b/CommandTprel.cs @@ -1,31 +1,57 @@ using System; using System.Collections.Generic; -using Rocket.Unturned; +using Rocket.API; +using Rocket.Unturned.Chat; using Rocket.Unturned.Commands; using Rocket.Unturned.Player; using UnityEngine; using SDG.Unturned; - namespace TeleportUtil { public class CommandTprel : IRocketCommand { - public System.Collections.Generic.List Aliases + public bool AllowFromConsole + { + get { return false; } + } + + public string Name + { + get { return "tprel"; } + } + + public string Help + { + get { return "Teleport to x,y,z coords relative to yourself."; } + } + + public string Syntax + { + get { return " "; } + } + + public List Aliases { get { return new List(); } } - public void Execute(RocketPlayer caller, string[] command) + public List Permissions + { + get { return new List() { "TeleportUtil.tprel" }; } + } + + public void Execute(IRocketPlayer caller, string[] command) { + UnturnedPlayer unturnedCaller = UnturnedPlayer.FromName(caller.Id); if (command.Length == 0) { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("tprel_help", new object[] { })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("tprel_help", new object[] { })); return; } if (command.Length != 3) { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); return; } else @@ -36,41 +62,21 @@ public void Execute(RocketPlayer caller, string[] command) if (x.HasValue && y.HasValue && z.HasValue) { - if (caller.Stance == EPlayerStance.DRIVING) + if (unturnedCaller.Stance == EPlayerStance.DRIVING || unturnedCaller.Stance == EPlayerStance.SITTING) { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("tp_fail", new object[] { })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("tp_fail", new object[] { })); return; } - Vector3 newLocation = new Vector3(caller.Position.x + x.Value, caller.Position.y + y.Value, caller.Position.z + z.Value); - caller.Teleport(newLocation, caller.Rotation); - RocketChat.Say(caller, TeleportUtil.Instance.Translate("tp_success", new object[] { Math.Round(newLocation.x, 2), Math.Round(newLocation.y, 2), Math.Round(newLocation.z, 2) })); + Vector3 newLocation = new Vector3(unturnedCaller.Position.x + x.Value, unturnedCaller.Position.y + y.Value, unturnedCaller.Position.z + z.Value); + unturnedCaller.Teleport(newLocation, unturnedCaller.Rotation); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("tp_success", new object[] { Math.Round(newLocation.x, 2), Math.Round(newLocation.y, 2), Math.Round(newLocation.z, 2) })); } else { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); return; } } } - - public string Help - { - get { return "Teleport to x,y,z coords relative to yourself."; } - } - - public string Name - { - get { return "tprel"; } - } - - public bool RunFromConsole - { - get { return false; } - } - - public string Syntax - { - get { return " "; } - } } } diff --git a/CommandTpto.cs b/CommandTpto.cs index 9363c01..7557015 100644 --- a/CommandTpto.cs +++ b/CommandTpto.cs @@ -1,49 +1,75 @@ using System; using System.Collections.Generic; -using Rocket.Unturned.Commands; -using Rocket.Unturned.Player; -using Rocket.Unturned; using UnityEngine; using SDG.Unturned; +using Rocket.API; +using Rocket.Unturned.Chat; +using Rocket.Unturned.Player; namespace TeleportUtil { public class CommandTpto : IRocketCommand { + public bool AllowFromConsole + { + get { return false; } + } + + public string Name + { + get { return "tpto"; } + } + + public string Help + { + get { return "Teleport by direction:distance."; } + } + + public string Syntax + { + get { return "[distance] [...] [...]"; } + } + public List Aliases { get { return new List(); } } - public void Execute(RocketPlayer caller, string[] command) + public List Permissions + { + get { return new List() { "TeleportUtil.tpto" }; } + } + + public void Execute(IRocketPlayer caller, string[] command) { + UnturnedPlayer unturnedCaller = UnturnedPlayer.FromName(caller.Id); if (command.Length == 0) { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("tpto_help", new object[] { })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("tpto_help", new object[] { })); return; } if (command.Length > 3) { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); return; } - if (caller.Stance == EPlayerStance.DRIVING) + if (unturnedCaller.Stance == EPlayerStance.DRIVING || unturnedCaller.Stance == EPlayerStance.SITTING) { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("tp_fail", new object[] { })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("tp_fail", new object[] { })); return; } - Vector3 newLocation = caller.Position; + Vector3 newLocation = unturnedCaller.Position; foreach (string part in command) { if (part.Length < 2) { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); return; } float distance; if (!float.TryParse(part.Substring(1, part.Length - 1), out distance)) { - RocketChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); return; } switch (part.Substring(0, 1).ToLower()) @@ -67,32 +93,12 @@ public void Execute(RocketPlayer caller, string[] command) newLocation.x -= distance; break; default: - RocketChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); return; } } - caller.Teleport(newLocation, caller.Rotation); - RocketChat.Say(caller, TeleportUtil.Instance.Translate("tp_success", new object[] { Math.Round(newLocation.x, 2), Math.Round(newLocation.y, 2), Math.Round(newLocation.z, 2) })); - } - - public string Help - { - get { return "Teleport by direction:distance."; } - } - - public string Name - { - get { return "tpto"; } - } - - public bool RunFromConsole - { - get { return false; } - } - - public string Syntax - { - get { return "[distance] [...] [...]"; } + unturnedCaller.Teleport(newLocation, unturnedCaller.Rotation); + UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("tp_success", new object[] { Math.Round(newLocation.x, 2), Math.Round(newLocation.y, 2), Math.Round(newLocation.z, 2) })); } } } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 758bc10..a3bbde1 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0.0")] -[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyVersion("1.3.0.0")] +[assembly: AssemblyFileVersion("1.3.0.0")] diff --git a/TeleportUtil.cs b/TeleportUtil.cs index 0852160..5a3b09c 100644 --- a/TeleportUtil.cs +++ b/TeleportUtil.cs @@ -1,6 +1,5 @@ -using System; -using Rocket.Unturned.Plugins; -using System.Collections.Generic; +using Rocket.API.Collections; +using Rocket.Core.Plugins; namespace TeleportUtil { @@ -13,48 +12,21 @@ protected override void Load() Instance = this; } - public override Dictionary DefaultTranslations + public override TranslationList DefaultTranslations { get { - return new Dictionary + return new TranslationList { - { - "invalid_arg", - "Invalid Arguments." - }, - { - "can't_locate_player", - "Can't locate player." - }, - { - "locate_other_not_allowed", - "You're not allowed to use locate on another player." - }, - { - "location_on_map", - "Your location on the map is: x:{0}, y:{1}, z:{2}" - }, - { - "location_on_map_other", - "Player: \"{0}\" location on the map is: x:{1}, y:{2}, z:{3}" - }, - { - "tprel_help", - " - Teleport to x,y,z coords relative to yourself." - }, - { - "tp_fail", - "Failed to teleport: Can't teleport while in a car." - }, - { - "tp_success", - "You have been teleported to: x:{0}, y:{1}, z:{2}" - }, - { - "tpto_help", - "[distance] [...] [...] - Teleport by direction:distance." - } + { "invalid_arg", "Invalid Arguments." }, + { "can't_locate_player", "Can't locate player." }, + { "locate_other_not_allowed", "You're not allowed to use locate on another player." }, + { "location_on_map", "Your location on the map is: x:{0}, y:{1}, z:{2}" }, + { "location_on_map_other", "Player: \"{0}\" location on the map is: x:{1}, y:{2}, z:{3}" }, + { "tprel_help", " - Teleport to x,y,z coords relative to yourself." }, + { "tp_fail", "Failed to teleport: Can't teleport while in a car." }, + { "tp_success", "You have been teleported to: x:{0}, y:{1}, z:{2}" }, + { "tpto_help", "[distance] [...] [...] - Teleport by direction:distance." } }; } } diff --git a/TeleportUtil.csproj b/TeleportUtil.csproj index 069e90d..851a218 100644 --- a/TeleportUtil.csproj +++ b/TeleportUtil.csproj @@ -34,18 +34,23 @@ ..\Rocket_Ref\Assembly-CSharp.dll + False ..\Rocket_Ref\Assembly-CSharp-firstpass.dll + False ..\Rocket_Ref\Rocket.API.dll + False ..\Rocket_Ref\Rocket.Core.dll + False ..\Rocket_Ref\Rocket.Unturned.dll + False @@ -55,6 +60,7 @@ ..\Rocket_Ref\UnityEngine.dll + False diff --git a/TeleportUtilConfig.cs b/TeleportUtilConfig.cs index a9b2043..efb1336 100644 --- a/TeleportUtilConfig.cs +++ b/TeleportUtilConfig.cs @@ -8,15 +8,5 @@ namespace TeleportUtil { public class TeleportUtilConfig : IRocketPluginConfiguration { - public IRocketPluginConfiguration DefaultConfiguration - { - get - { - return new TeleportUtilConfig() - { - - }; - } - } } }