Skip to content
Permalink
Browse files

Fix doing /portal create with no X/Y/Z argument at all, spawning you …

…at 0,0,0 instead of map spawn
  • Loading branch information...
UnknownShadow200 committed Sep 1, 2018
1 parent f5f946e commit 2c12179ff02f136d210184e1a05d8b375beadf34
Showing with 4 additions and 7 deletions.
  1. +2 −3 fCraft/Commands/WorldCommands.cs
  2. +2 −4 fCraft/Portals/Portal.cs
@@ -3714,13 +3714,14 @@ static void WorldClearHandler(Player player, CommandReader cmd)

string portalName = cmd.Next();
if (string.IsNullOrEmpty(portalName)) {
} else if (!Portal.DoesNameExist(player.World, portalName)) {
} else if (!Portal.Exists(player.World, portalName)) {
player.PortalName = portalName;
} else {
player.Message("A portal with name {0} already exists in this world.", portalName);
return;
}

player.PortalTPPos = world.map == null ? default(Position) : world.map.Spawn;
if (cmd.HasNext) {
int x, y, z, rot = player.Position.R, lot = player.Position.L;
string next = cmd.Next();
@@ -3754,8 +3755,6 @@ static void WorldClearHandler(Player player, CommandReader cmd)
}
}
player.PortalTPPos = new Position(x * 32, y * 32, z * 32, (byte)rot, (byte)lot);
} else {
player.PortalTPPos = world.map == null ? new Position(0, 0, 0) : world.map.Spawn;
}
}

@@ -107,13 +107,11 @@ public class Portal {
return "portal1";
}

public static bool DoesNameExist(World world, string name) {
public static bool Exists(World world, string name) {
if (world.Portals != null) {
if (world.Portals.Count > 0) {
foreach (Portal portal in world.Portals) {
if (portal.Name.Equals(name)) {
return true;
}
if (portal.Name.Equals(name)) return true;
}
}
}

0 comments on commit 2c12179

Please sign in to comment.
You can’t perform that action at this time.