mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Allow changing the colour of a bot with /color. (Thanks goodlyay)
This commit is contained in:
parent
e26d0c707d
commit
e723b38f9c
@ -15,6 +15,7 @@
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using MCGalaxy.Bots;
|
||||
using MCGalaxy.SQL;
|
||||
|
||||
namespace MCGalaxy.Commands {
|
||||
@ -39,14 +40,33 @@ namespace MCGalaxy.Commands {
|
||||
args[0] = p.name;
|
||||
}
|
||||
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
Player who = null;
|
||||
PlayerBot pBot = null;
|
||||
bool isBot = message.CaselessStarts("bot ");
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
if (isBot)
|
||||
pBot = PlayerBot.FindMatches(p, args[1]);
|
||||
else
|
||||
who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (pBot == null && who == null) return;
|
||||
|
||||
if (p != null && who != null && who.group.Permission > p.group.Permission) {
|
||||
MessageTooHighRank(p, "change the color of", true); return;
|
||||
}
|
||||
if ((isBot || who != p) && !CheckExtraPerm(p)) { MessageNeedPerms(p, "can change the color of others."); return; }
|
||||
SetColor(who, args);
|
||||
if (isBot) SetBotColor(p, pBot, args);
|
||||
else SetColor(p, who, args);
|
||||
}
|
||||
|
||||
static void SetBotColor(Player p, PlayerBot pBot, string[] args) {
|
||||
ParameterisedQuery query = ParameterisedQuery.Create();
|
||||
string color = args.Length == 2 ? "&1" : Colors.Parse(args[2]);
|
||||
if (color == "") { Player.Message(p, "There is no color \"" + args[2] + "\"."); return; }
|
||||
pBot.color = color;
|
||||
|
||||
pBot.GlobalDespawn();
|
||||
pBot.GlobalSpawn();
|
||||
Player.GlobalMessage("Bot " + pBot.name + "'s %Scolor was changed to " + color + Colors.Name(color));
|
||||
BotsFile.UpdateBot(pBot);
|
||||
}
|
||||
|
||||
static void SetColor(Player p, Player who, string[] args) {
|
||||
|
@ -48,7 +48,7 @@ namespace MCGalaxy.Commands {
|
||||
SetTColor(p, who, args);
|
||||
}
|
||||
|
||||
static void SetTColor(Player p, player who, string[] args) {
|
||||
static void SetTColor(Player p, Player who, string[] args) {
|
||||
ParameterisedQuery query = ParameterisedQuery.Create();
|
||||
if (args.Length == 1) {
|
||||
Player.SendChatFrom(who, who.ColoredName + " %Shad their title color removed.", false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user