update parcel ban/unban to work
This commit is contained in:
parent
b890fdc54b
commit
61da8bf4cd
2 changed files with 50 additions and 29 deletions
|
|
@ -617,18 +617,52 @@ namespace OpenMetaverse
|
||||||
Update(client, client.Network.CurrentSim, wantReply);
|
Update(client, client.Network.CurrentSim, wantReply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// UpdateParcelAccessList - Update the parcel access or ban list on the simulator
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Client">The grid client we are using</param>
|
||||||
|
/// <param name="flags">what list to update sending AccessList.Both will result in a warning</param>
|
||||||
|
/// <param name="entries">list of avatar entry records</param>
|
||||||
public void UpdateParcelAccessList(
|
public void UpdateParcelAccessList(
|
||||||
GridClient Client,
|
GridClient Client,
|
||||||
AccessList flags,
|
AccessList flags,
|
||||||
List<ParcelManager.ParcelAccessEntry> entries)
|
List<ParcelManager.ParcelAccessEntry> entries)
|
||||||
{
|
{
|
||||||
if(Client == null) throw new InvalidOperationException("Client is null");
|
// based on Alchemy Viewer's implementation
|
||||||
if(Client.Network == null) throw new InvalidOperationException("Client.Network is null");
|
// might want to be cleaned up later
|
||||||
if(Client.Network.CurrentSim == null) throw new InvalidOperationException("Client.Network.CurrentSim is null");
|
if (flags == AccessList.Both)
|
||||||
|
{
|
||||||
|
Logger.Log("Warning: UpdateParcelAccessList called with AccessList.Both, this is not supported. " +
|
||||||
|
"Use AccessList.Access or AccessList.Ban", Helpers.LogLevel.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Client == null)
|
||||||
|
{
|
||||||
|
Logger.Log("Client is null", Helpers.LogLevel.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Client.Network == null)
|
||||||
|
{
|
||||||
|
Logger.Log("Client.Network is null", Helpers.LogLevel.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Client.Network.CurrentSim == null)
|
||||||
|
{
|
||||||
|
Logger.Log("Client.Network.CurrentSim is null", Helpers.LogLevel.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
Simulator simulator = Client.Network.CurrentSim;
|
Simulator simulator = Client.Network.CurrentSim;
|
||||||
if (simulator == null) throw new InvalidOperationException("No current simulator");
|
if (Client.Network.CurrentSim == null)
|
||||||
|
{
|
||||||
|
Logger.Log("simulator is null", Helpers.LogLevel.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
int parcelLocalId = LocalID;
|
int parcelLocalId = LocalID;
|
||||||
if (parcelLocalId == 0) throw new InvalidOperationException("Parcel LocalID is zero");
|
if (parcelLocalId == 0)
|
||||||
|
{
|
||||||
|
Logger.Log("Parcel LocalID is zero", Helpers.LogLevel.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (entries.Count == 0)
|
if (entries.Count == 0)
|
||||||
{
|
{
|
||||||
// send an empty block to clear the list
|
// send an empty block to clear the list
|
||||||
|
|
@ -659,7 +693,7 @@ namespace OpenMetaverse
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int PARCEL_MAX_ENTRIES_PER_PACKET = 48; // Set to your actual max
|
const int PARCEL_MAX_ENTRIES_PER_PACKET = 48; // ?? matching viewer's limit, but not documented anywhere
|
||||||
int count = entries.Count;
|
int count = entries.Count;
|
||||||
int numSections = (int)Math.Ceiling((double)count / PARCEL_MAX_ENTRIES_PER_PACKET);
|
int numSections = (int)Math.Ceiling((double)count / PARCEL_MAX_ENTRIES_PER_PACKET);
|
||||||
int sequenceId = 1;
|
int sequenceId = 1;
|
||||||
|
|
|
||||||
|
|
@ -591,15 +591,7 @@ namespace SecondBotEvents.Commands
|
||||||
{
|
{
|
||||||
return Failure("Invaild avatar", [avatar]);
|
return Failure("Invaild avatar", [avatar]);
|
||||||
}
|
}
|
||||||
bool alreadyBanned = false;
|
bool alreadyBanned = targetparcel.AccessBlackList.Any(e => e.AgentID == avataruuid);
|
||||||
foreach (ParcelAccessEntry E in targetparcel.AccessBlackList)
|
|
||||||
{
|
|
||||||
if (E.AgentID == avataruuid)
|
|
||||||
{
|
|
||||||
alreadyBanned = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (alreadyBanned == true)
|
if (alreadyBanned == true)
|
||||||
{
|
{
|
||||||
return BasicReply("Avatar is in the blacklist", [avatar]);
|
return BasicReply("Avatar is in the blacklist", [avatar]);
|
||||||
|
|
@ -611,7 +603,7 @@ namespace SecondBotEvents.Commands
|
||||||
Time = new System.DateTime(3030, 03, 03)
|
Time = new System.DateTime(3030, 03, 03)
|
||||||
};
|
};
|
||||||
targetparcel.AccessBlackList.Add(entry);
|
targetparcel.AccessBlackList.Add(entry);
|
||||||
targetparcel.Update(GetClient());
|
targetparcel.UpdateParcelAccessList(GetClient(), AccessList.Ban, targetparcel.AccessBlackList);
|
||||||
return BasicReply("ok", [avatar]);
|
return BasicReply("ok", [avatar]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -635,23 +627,18 @@ namespace SecondBotEvents.Commands
|
||||||
{
|
{
|
||||||
return Failure("Invaild avatar", [avatar]);
|
return Failure("Invaild avatar", [avatar]);
|
||||||
}
|
}
|
||||||
bool alreadyBanned = false;
|
bool alreadyBanned = targetparcel.AccessBlackList.Any(e => e.AgentID == avataruuid);
|
||||||
ParcelAccessEntry removeentry = new();
|
|
||||||
foreach (ParcelAccessEntry E in targetparcel.AccessBlackList)
|
|
||||||
{
|
|
||||||
if (E.AgentID == avataruuid)
|
|
||||||
{
|
|
||||||
alreadyBanned = true;
|
|
||||||
removeentry = E;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (alreadyBanned == false)
|
if (alreadyBanned == false)
|
||||||
{
|
{
|
||||||
return BasicReply("Avatar is already unbanned", [avatar]);
|
return BasicReply("Avatar is already unbanned", [avatar]);
|
||||||
}
|
}
|
||||||
targetparcel.AccessBlackList.Remove(removeentry);
|
// Find the entry to remove
|
||||||
targetparcel.Update(GetClient());
|
var entryToRemove = targetparcel.AccessBlackList.FirstOrDefault(e => e.AgentID == avataruuid);
|
||||||
|
if (entryToRemove.AgentID != UUID.Zero)
|
||||||
|
{
|
||||||
|
targetparcel.AccessBlackList.Remove(entryToRemove);
|
||||||
|
}
|
||||||
|
targetparcel.UpdateParcelAccessList(GetClient(), AccessList.Ban, targetparcel.AccessBlackList);
|
||||||
return BasicReply("ok", [avatar]);
|
return BasicReply("ok", [avatar]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue