adds FriendsGetLocation
This commit is contained in:
parent
78bb59c9fe
commit
bb5b1b98b2
2 changed files with 74 additions and 0 deletions
|
|
@ -12,6 +12,33 @@ namespace SecondBotEvents.Commands
|
|||
{
|
||||
}
|
||||
|
||||
[About("Gets the location of a friend if map access was given \n also requests a update")]
|
||||
[ReturnHints("a json object of global region X,Y sim X,Y,Z and time it was updated")]
|
||||
[ReturnHintsFailure("avatar lookup")]
|
||||
[ReturnHintsFailure("not in friends list")]
|
||||
[ReturnHintsFailure("no map access or updating")]
|
||||
[ArgHints("avatar", "A avatar uuid or Firstname Lastname")]
|
||||
public object FieldGetLocation(string avatar)
|
||||
{
|
||||
ProcessAvatar(avatar);
|
||||
if (avataruuid == UUID.Zero)
|
||||
{
|
||||
return Failure("avatar lookup", new[] { avatar });
|
||||
}
|
||||
Dictionary<UUID, FriendInfo> FriendListCopy = GetClient().Friends.FriendList.Copy();
|
||||
if(FriendListCopy.ContainsKey(avataruuid) == false)
|
||||
{
|
||||
return Failure("not in friends list (updating)", new[] { avatar });
|
||||
}
|
||||
GetClient().Friends.MapFriend(avataruuid);
|
||||
FriendLocations loc = master.DataStoreService.GetFriendMap(avataruuid);
|
||||
if(loc == null)
|
||||
{
|
||||
return Failure("no map access or updating", new[] { avatar });
|
||||
}
|
||||
return BasicReply(JsonConvert.SerializeObject(loc), new[] { avatar });
|
||||
}
|
||||
|
||||
[About("Gets the friendslist")]
|
||||
[ReturnHints("array of FriendListEntry")]
|
||||
public object Friendslist()
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ namespace SecondBotEvents.Services
|
|||
|
||||
protected List<CommandHistory> commandHistories = new();
|
||||
|
||||
|
||||
|
||||
protected long lastCleanupKeyValueStore = 0;
|
||||
protected long lastCleanupAvatarStore = 0;
|
||||
|
||||
|
|
@ -847,6 +849,35 @@ namespace SecondBotEvents.Services
|
|||
}
|
||||
|
||||
List<UUID> estateBanlist = null;
|
||||
Dictionary<UUID, FriendLocations> FriendMapLocations = new Dictionary<UUID, FriendLocations>();
|
||||
|
||||
public FriendLocations GetFriendMap(UUID id)
|
||||
{
|
||||
if(FriendMapLocations.ContainsKey(id) == false)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return FriendMapLocations[id];
|
||||
}
|
||||
|
||||
protected void FindFriendReply(object o, FriendFoundReplyEventArgs e)
|
||||
{
|
||||
uint x, y;
|
||||
Utils.LongToUInts(e.RegionHandle, out x, out y);
|
||||
x /= 256;
|
||||
y /= 256;
|
||||
Dictionary<UUID, FriendInfo> FriendListCopy = GetClient().Friends.FriendList.Copy();
|
||||
if (FriendListCopy.ContainsKey(e.AgentID) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FriendLocations NewEntry = new FriendLocations(FriendListCopy[e.AgentID].Name, e.Location, new Vector3(x,y,10));
|
||||
if(FriendMapLocations.ContainsKey(e.AgentID) == false)
|
||||
{
|
||||
FriendMapLocations.Add(e.AgentID, NewEntry);
|
||||
}
|
||||
FriendMapLocations[e.AgentID] = NewEntry;
|
||||
}
|
||||
|
||||
protected void EstateBans(object o, EstateBansReplyEventArgs e)
|
||||
{
|
||||
|
|
@ -883,6 +914,7 @@ namespace SecondBotEvents.Services
|
|||
GetClient().Groups.GroupMembersReply += GroupMembers;
|
||||
GetClient().Groups.GroupRoleDataReply += GroupRoles;
|
||||
GetClient().Estate.EstateBansReply += EstateBans;
|
||||
GetClient().Friends.FriendFoundReply += FindFriendReply;
|
||||
GetClient().Groups.RequestCurrentGroups();
|
||||
GetClient().Self.RetrieveInstantMessages();
|
||||
}
|
||||
|
|
@ -1114,6 +1146,21 @@ namespace SecondBotEvents.Services
|
|||
Unixtime = setUnixtime;
|
||||
}
|
||||
}
|
||||
|
||||
public class FriendLocations
|
||||
{
|
||||
public string Name;
|
||||
public Vector3 Pos;
|
||||
public Vector3 RegionPos;
|
||||
public long time;
|
||||
public FriendLocations(string SetName, Vector3 setPos, Vector3 setRegionPos)
|
||||
{
|
||||
time = SecondbotHelpers.UnixTimeNow();
|
||||
Name = SetName;
|
||||
Pos = setPos;
|
||||
RegionPos = setRegionPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue