Fixed getRegion not returning null (functions using it were expecting null too)
Disabled noclip check. (general-devel is not general-test) Added null check to /region info (Don't commit shit that you know is broken)
This commit is contained in:
parent
05f0e9d717
commit
625bab753b
4 changed files with 26 additions and 18 deletions
|
|
@ -1927,7 +1927,13 @@ namespace TShockAPI
|
|||
if (args.Parameters.Count > 1)
|
||||
{
|
||||
string regionName = String.Join(" ", args.Parameters.GetRange(1, args.Parameters.Count - 1));
|
||||
Region r = TShock.Regions.getRegion(regionName);
|
||||
Region r = TShock.Regions.GetRegionByName(regionName);
|
||||
|
||||
if (r == null)
|
||||
{
|
||||
args.Player.SendMessage("Region {0} does not exist");
|
||||
break;
|
||||
}
|
||||
|
||||
args.Player.SendMessage(r.Name + ": P: " + r.DisableBuild + " X: " + r.Area.X + " Y: " + r.Area.Y + " W: " + r.Area.Width + " H: " + r.Area.Height);
|
||||
foreach (int s in r.AllowedIDs)
|
||||
|
|
@ -1936,7 +1942,9 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /region info [name]", Color.Red);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ namespace TShockAPI.DB
|
|||
|
||||
public bool AddRegion(int tx, int ty, int width, int height, string regionname, string worldid)
|
||||
{
|
||||
if (TShock.Regions.getRegion(regionname) == null)
|
||||
if (TShock.Regions.GetRegionByName(regionname) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -279,7 +279,8 @@ namespace TShockAPI.DB
|
|||
try
|
||||
{
|
||||
database.Query("DELETE FROM Regions WHERE RegionName=@0 AND WorldID=@1", name, Main.worldID.ToString());
|
||||
Regions.Remove(getRegion(name));
|
||||
var worldid = Main.worldID.ToString();
|
||||
Regions.RemoveAll(r => r.Name == name && r.WorldID == worldid);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -294,7 +295,9 @@ namespace TShockAPI.DB
|
|||
try
|
||||
{
|
||||
database.Query("UPDATE Regions SET Protected=@0 WHERE RegionName=@1 AND WorldID=@2", state ? 1 : 0, name, Main.worldID.ToString());
|
||||
getRegion(name).DisableBuild = state;
|
||||
var region = GetRegionByName(name);
|
||||
if (region != null)
|
||||
region.DisableBuild = state;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -309,7 +312,9 @@ namespace TShockAPI.DB
|
|||
try
|
||||
{
|
||||
database.Query("UPDATE Regions SET Protected=@0 WHERE RegionName=@1 AND WorldID=@2", state ? 1 : 0, name, world);
|
||||
getRegion(name).DisableBuild = state;
|
||||
var region = GetRegionByName(name);
|
||||
if (region != null)
|
||||
region.DisableBuild = state;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -370,7 +375,7 @@ namespace TShockAPI.DB
|
|||
|
||||
public bool RemoveUser(string regionName, string userName )
|
||||
{
|
||||
Region r = getRegion(regionName);
|
||||
Region r = GetRegionByName(regionName);
|
||||
if( r != null )
|
||||
{
|
||||
r.RemoveID(TShock.Users.GetUserID(userName));
|
||||
|
|
@ -437,14 +442,9 @@ namespace TShockAPI.DB
|
|||
return regions;
|
||||
}
|
||||
|
||||
public Region getRegion(String name)
|
||||
public Region GetRegionByName(String name)
|
||||
{
|
||||
foreach (Region r in Regions)
|
||||
{
|
||||
if (r.Name.Equals(name) && r.WorldID == Main.worldID.ToString())
|
||||
return r;
|
||||
}
|
||||
return new Region();
|
||||
return Regions.FirstOrDefault(r => r.Name.Equals(name) && r.WorldID == Main.worldID.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,5 +36,5 @@ using System.Runtime.InteropServices;
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
|
||||
[assembly: AssemblyVersion("3.2.8.0818")]
|
||||
[assembly: AssemblyFileVersion("3.2.8.0818")]
|
||||
[assembly: AssemblyVersion("3.2.8.0820")]
|
||||
[assembly: AssemblyFileVersion("3.2.8.0820")]
|
||||
|
|
|
|||
|
|
@ -383,9 +383,9 @@ namespace TShockAPI
|
|||
player.TilesDestroyed.Clear();
|
||||
}
|
||||
}
|
||||
if (CheckPlayerCollision(player.TileX, player.TileY))
|
||||
player.SendMessage("You are currently nocliping!", Color.Red);
|
||||
if (player.LastDeath != null && player.ForceSpawn && (DateTime.Now - player.LastDeath).Seconds >= 3)
|
||||
/*if (CheckPlayerCollision(player.TileX, player.TileY))
|
||||
player.SendMessage("You are currently nocliping!", Color.Red);*/
|
||||
if (player.ForceSpawn && (DateTime.Now - player.LastDeath).Seconds >= 3)
|
||||
{
|
||||
player.Spawn();
|
||||
player.ForceSpawn = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue