adds master_uuid auto loading

getMaster_uuid (public) value
and master key2name avatar storage protection
This commit is contained in:
Madpeter 2020-04-26 03:01:04 +01:00
parent 2849b615e6
commit dfd99d8c26

View file

@ -9,6 +9,9 @@ namespace BSB.bottypes
{ {
public abstract class AVstorageBot : AtHome public abstract class AVstorageBot : AtHome
{ {
protected UUID master_uuid = UUID.Zero;
public UUID getMaster_uuid { get { return master_uuid; } }
protected Dictionary<string, long> AvatarStorageLastUsed = new Dictionary<string, long>(); protected Dictionary<string, long> AvatarStorageLastUsed = new Dictionary<string, long>();
protected Dictionary<string, UUID> AvatarName2Key = new Dictionary<string, UUID>(); protected Dictionary<string, UUID> AvatarName2Key = new Dictionary<string, UUID>();
protected Dictionary<UUID, string> AvatarKey2Name = new Dictionary<UUID, string>(); protected Dictionary<UUID, string> AvatarKey2Name = new Dictionary<UUID, string>();
@ -136,6 +139,8 @@ namespace BSB.bottypes
} }
} }
foreach(string purge in PurgeAvatars) foreach(string purge in PurgeAvatars)
{
if (purge != myconfig.master)
{ {
AvatarStorageLastUsed.Remove(purge); AvatarStorageLastUsed.Remove(purge);
UUID avuuid = AvatarName2Key[purge]; UUID avuuid = AvatarName2Key[purge];
@ -143,6 +148,7 @@ namespace BSB.bottypes
AvatarKey2Name.Remove(avuuid); AvatarKey2Name.Remove(avuuid);
} }
} }
}
protected override void AfterBotLoginHandler() protected override void AfterBotLoginHandler()
{ {
@ -151,6 +157,10 @@ namespace BSB.bottypes
{ {
Client.Avatars.UUIDNameReply += Key2NameEvent; Client.Avatars.UUIDNameReply += Key2NameEvent;
Client.Directory.DirPeopleReply += Name2KeyEvent; Client.Directory.DirPeopleReply += Name2KeyEvent;
if(helpers.notempty(myconfig.master) == true)
{
FindAvatarName2Key(myconfig.master);
}
} }
} }
@ -187,6 +197,13 @@ namespace BSB.bottypes
PendingAvatarFinds_viauuid.Remove(av_uuid); PendingAvatarFinds_viauuid.Remove(av_uuid);
} }
} }
if (helpers.notempty(myconfig.master) == true)
{
if(myconfig.master == av_name)
{
master_uuid = av_uuid;
}
}
} }
} }