Implement /setspawn player, fixes #395

This commit is contained in:
UnknownShadow200 2017-09-21 17:44:10 +10:00
parent 8520799833
commit 79de17943c
3 changed files with 27 additions and 28 deletions

View File

@ -14,7 +14,7 @@
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 {
public override string name { get { return "SetSpawn"; } }
@ -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, "%T/SetSpawn [player]");
Player.Message(p, "%HSets the spawn location of that player");
}
}
}

View File

@ -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

View File

@ -87,17 +87,6 @@ namespace MCGalaxy {
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;
return BlockBindings[RawHeldBlock.RawID];