From 79de17943c5625e3f05d72c432a5f90aac8d3607 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 21 Sep 2017 17:44:10 +1000 Subject: [PATCH] Implement /setspawn player, fixes #395 --- MCGalaxy/Commands/World/CmdSetspawn.cs | 40 +++++++++++++++++--------- MCGalaxy/Player/Player.Fields.cs | 2 -- MCGalaxy/Player/Player.cs | 13 +-------- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/MCGalaxy/Commands/World/CmdSetspawn.cs b/MCGalaxy/Commands/World/CmdSetspawn.cs index a0ea7a422..33af2b2bb 100644 --- a/MCGalaxy/Commands/World/CmdSetspawn.cs +++ b/MCGalaxy/Commands/World/CmdSetspawn.cs @@ -14,9 +14,9 @@ BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licenses for the specific language governing permissions and limitations under the Licenses. -*/ -namespace MCGalaxy.Commands.World { - public sealed class CmdSetspawn : Command { + */ +namespace MCGalaxy.Commands.World { + public sealed class CmdSetspawn : Command { public override string name { get { return "SetSpawn"; } } public override string type { get { return CommandTypes.World; } } public override bool museumUsable { get { return false; } } @@ -24,22 +24,34 @@ namespace MCGalaxy.Commands.World { public override bool SuperUseable { get { return false; } } public override void Use(Player p, string message) { - if (message.Length > 0) { Help(p); return; } - if (!LevelInfo.ValidateAction(p, p.level.name, "set spawn of this level")) return; - Player.Message(p, "Spawn location set to your current location."); - p.level.spawnx = (ushort)p.Pos.BlockX; - p.level.spawny = (ushort)p.Pos.BlockY; - p.level.spawnz = (ushort)p.Pos.BlockZ; - p.level.rotx = p.Rot.RotY; - p.level.roty = p.Rot.HeadX; - p.level.Changed = true; - Entities.Spawn(p, p); + + if (message.Length == 0) { + Player.Message(p, "Spawn location set to your current location."); + p.level.spawnx = (ushort)p.Pos.BlockX; + p.level.spawny = (ushort)p.Pos.BlockY; + p.level.spawnz = (ushort)p.Pos.BlockZ; + p.level.rotx = p.Rot.RotY; p.level.roty = p.Rot.HeadX; + p.level.Changed = true; + Entities.Spawn(p, p); + return; + } + + Player who = PlayerInfo.FindMatches(p, message); + if (who == null) return; + if (who.level != p.level) { Player.Message(p, "{0} %Sis on a different map.", who.ColoredName); return; } + if (p != who && who.Rank >= p.Rank) { MessageTooHighRank(p, "set spawn of", false); return; } + + Player.Message(p, "Set spawn location of {0} %Sto your current location.", who.ColoredName); + who.Pos = p.Pos; who.Rot = p.Rot; + Entities.Spawn(who, who); } public override void Help(Player p) { Player.Message(p, "%T/SetSpawn"); - Player.Message(p, "%HSets the spawn location of the map to your current location."); + Player.Message(p, "%HSets the spawn location of the map to your current location."); + Player.Message(p, "%T/SetSpawn [player]"); + Player.Message(p, "%HSets the spawn location of that player"); } } } diff --git a/MCGalaxy/Player/Player.Fields.cs b/MCGalaxy/Player/Player.Fields.cs index bddd95033..2f17be055 100644 --- a/MCGalaxy/Player/Player.Fields.cs +++ b/MCGalaxy/Player/Player.Fields.cs @@ -211,8 +211,6 @@ namespace MCGalaxy { public string PreTeleportMap; public string summonedMap; - public ushort[] pos = new ushort[3]; - public byte[] rot = new byte[2]; internal Position tempPos; // CmdVoteKick diff --git a/MCGalaxy/Player/Player.cs b/MCGalaxy/Player/Player.cs index 9800a3e09..bc2601cfd 100644 --- a/MCGalaxy/Player/Player.cs +++ b/MCGalaxy/Player/Player.cs @@ -85,18 +85,7 @@ namespace MCGalaxy { if (target.otherRankHidden) return Rank >= target.oHideRank; return Rank >= target.Rank; - } - - protected override void OnSetPos() { - Position p = Pos; - pos[0] = (ushort)p.X; pos[1] = (ushort)p.Y; pos[2] = (ushort)p.Z; - } - - protected override void OnSetRot() { - Orientation r = Rot; - rot[0] = r.RotY; rot[1] = r.HeadX; - } - + } public ExtBlock GetHeldBlock() { if (!ModeBlock.IsAir) return ModeBlock;