Merge branch 'general-devel' into general-devel
This commit is contained in:
commit
2b50cbc7b9
6 changed files with 67 additions and 9 deletions
|
|
@ -832,10 +832,16 @@ namespace TShockAPI
|
|||
(usingUUID && account.UUID == args.Player.UUID && !TShock.Config.Settings.DisableUUIDLogin &&
|
||||
!String.IsNullOrWhiteSpace(args.Player.UUID)))
|
||||
{
|
||||
args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, account.ID);
|
||||
|
||||
var group = TShock.Groups.GetGroupByName(account.Group);
|
||||
|
||||
if (!TShock.Groups.AssertGroupValid(args.Player, group, false))
|
||||
{
|
||||
args.Player.SendErrorMessage("Login attempt failed - see the message above.");
|
||||
return;
|
||||
}
|
||||
|
||||
args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, account.ID);
|
||||
|
||||
args.Player.Group = group;
|
||||
args.Player.tempGroup = null;
|
||||
args.Player.Account = account;
|
||||
|
|
@ -5103,7 +5109,7 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
IEnumerable<string> cmdNames = from cmd in ChatCommands
|
||||
where cmd.CanRun(args.Player) && (cmd.Name != "auth" || TShock.SetupToken != 0)
|
||||
where cmd.CanRun(args.Player) && (cmd.Name != "setup" || TShock.SetupToken != 0)
|
||||
select Specifier + cmd.Name;
|
||||
|
||||
PaginationTools.SendPage(args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(cmdNames),
|
||||
|
|
|
|||
|
|
@ -200,6 +200,45 @@ namespace TShockAPI.DB
|
|||
LoadPermisions();
|
||||
|
||||
Group.DefaultGroup = GetGroupByName(TShock.Config.Settings.DefaultGuestGroupName);
|
||||
|
||||
AssertCoreGroupsPresent();
|
||||
}
|
||||
|
||||
internal void AssertCoreGroupsPresent()
|
||||
{
|
||||
if (!GroupExists(TShock.Config.Settings.DefaultGuestGroupName))
|
||||
{
|
||||
TShock.Log.ConsoleError("The guest group could not be found. This may indicate a typo in the configuration file, or that the group was renamed or deleted.");
|
||||
throw new Exception("The guest group could not be found.");
|
||||
}
|
||||
|
||||
if (!GroupExists(TShock.Config.Settings.DefaultRegistrationGroupName))
|
||||
{
|
||||
TShock.Log.ConsoleError("The default usergroup could not be found. This may indicate a typo in the configuration file, or that the group was renamed or deleted.");
|
||||
throw new Exception("The default usergroup could not be found.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asserts that the group reference can be safely assigned to the player object.
|
||||
/// <para>If this assertion fails, and <paramref name="kick"/> is true, the player is disconnected. If <paramref name="kick"/> is false, the player will receive an error message.</para>
|
||||
/// </summary>
|
||||
/// <param name="player">The player in question</param>
|
||||
/// <param name="group">The group we want to assign them</param>
|
||||
/// <param name="kick">Whether or not failing this check disconnects the player.</param>
|
||||
/// <returns></returns>
|
||||
public bool AssertGroupValid(TSPlayer player, Group group, bool kick)
|
||||
{
|
||||
if (group == null)
|
||||
{
|
||||
if (kick)
|
||||
player.Disconnect("Your account's group could not be loaded. Please contact server administrators about this.");
|
||||
else
|
||||
player.SendErrorMessage("Your account's group could not be loaded. Please contact server administrators about this.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void AddDefaultGroup(string name, string parent, string permissions)
|
||||
|
|
|
|||
|
|
@ -2456,10 +2456,13 @@ namespace TShockAPI
|
|||
args.Player.State = 2;
|
||||
NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index);
|
||||
|
||||
args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, account.ID);
|
||||
|
||||
var group = TShock.Groups.GetGroupByName(account.Group);
|
||||
|
||||
if (!TShock.Groups.AssertGroupValid(args.Player, group, true))
|
||||
return true;
|
||||
|
||||
args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, account.ID);
|
||||
|
||||
args.Player.Group = group;
|
||||
args.Player.tempGroup = null;
|
||||
args.Player.Account = account;
|
||||
|
|
@ -3037,6 +3040,9 @@ namespace TShockAPI
|
|||
|
||||
var group = TShock.Groups.GetGroupByName(account.Group);
|
||||
|
||||
if (!TShock.Groups.AssertGroupValid(args.Player, group, true))
|
||||
return true;
|
||||
|
||||
args.Player.Group = group;
|
||||
args.Player.tempGroup = null;
|
||||
args.Player.Account = account;
|
||||
|
|
@ -3240,6 +3246,7 @@ namespace TShockAPI
|
|||
{
|
||||
TShock.Log.ConsoleDebug($"GetDataHandlers / HandleSpecial rejected enchanted sundial permission {args.Player.Name}");
|
||||
args.Player.SendErrorMessage("You do not have permission to use the Enchanted Sundial.");
|
||||
return true;
|
||||
}
|
||||
else if (TShock.Config.Settings.ForceTime != "normal")
|
||||
{
|
||||
|
|
@ -3250,8 +3257,8 @@ namespace TShockAPI
|
|||
}
|
||||
else
|
||||
args.Player.SendErrorMessage("You must set ForceTime to normal via config to use the Enchanted Sundial.");
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -892,7 +892,7 @@ namespace TShockAPI
|
|||
CacheIP = RealPlayer ? (Netplay.Clients[Index].Socket.IsConnected()
|
||||
? TShock.Utils.GetRealIP(Netplay.Clients[Index].Socket.GetRemoteAddress().ToString())
|
||||
: "")
|
||||
: "";
|
||||
: "127.0.0.1";
|
||||
else
|
||||
return CacheIP;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -386,8 +386,8 @@ namespace TShockAPI
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("Fatal Startup Exception");
|
||||
Log.Error(ex.ToString());
|
||||
Log.ConsoleError("Fatal Startup Exception");
|
||||
Log.ConsoleError(ex.ToString());
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue