command rename: from Parcel SetMusicURL to SetParcelMusic,

also updates to the new shared code blocks
This commit is contained in:
Madpeter 2020-04-29 03:43:05 +01:00
parent ff579cba6d
commit 1ff8fd7228
2 changed files with 47 additions and 68 deletions

View file

@ -1,68 +0,0 @@
using BetterSecondBotShared.Static;
using OpenMetaverse;
using System;
using System.Collections.Generic;
using System.Text;
namespace BSB.Commands.CMD_Parcel
{
class ParcelSetMusicURL : CoreCommand
{
public override string[] ArgTypes { get { return new[] { "String" }; } }
public override string[] ArgHints { get { return new[] { "A vaild url" }; } }
public override string Helpfile { get { return "Updates the current parcels music url"; } }
public override bool CallFunction(string[] args)
{
int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition);
if (bot.GetClient.Network.CurrentSim.Parcels.ContainsKey(localid) == true)
{
Parcel p = bot.GetClient.Network.CurrentSim.Parcels[localid];
if (parcel_static.has_parcel_perm(p, bot) == true)
{
if (args.Length == 0)
{
if (p.MusicURL != "")
{
p.MusicURL = "";
p.Update(bot.GetClient.Network.CurrentSim, false);
return true;
}
else
{
return Failed("No change made");
}
}
else
{
if (args[0].StartsWith("http") == true)
{
if (p.MusicURL != args[0])
{
p.MusicURL = args[0];
p.Update(bot.GetClient.Network.CurrentSim, false);
return true;
}
else
{
return Failed("No change made");
}
}
else
{
return Failed("Invaild url");
}
}
}
else
{
return Failed("Required parcel perms missing!");
}
}
else
{
return Failed("Unable to find parcel in memory, please wait and try again");
}
}
}
}

View file

@ -0,0 +1,47 @@
using BetterSecondBotShared.Static;
using OpenMetaverse;
using System;
using System.Collections.Generic;
using System.Text;
namespace BSB.Commands.CMD_Parcel
{
class SetParcelMusic : ParcelCommand_RequirePerms
{
public override string[] ArgTypes { get { return new[] { "String" }; } }
public override string[] ArgHints { get { return new[] { "A vaild url" }; } }
public override string Helpfile { get { return "Updates the current parcels music url"; } }
protected bool set_parcel_music(string url)
{
if (targetparcel.MusicURL != url)
{
targetparcel.MusicURL = url;
targetparcel.Update(bot.GetClient.Network.CurrentSim, false);
}
return true;
}
public override bool CallFunction(string[] args)
{
if (base.CallFunction(args) == true)
{
if (args.Length == 0)
{
return set_parcel_music("");
}
else
{
if (args[0].StartsWith("http") == true)
{
return set_parcel_music(args[0]);
}
else
{
return Failed("Invaild url");
}
}
}
return false;
}
}
}