mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-04 02:52:21 -04:00
101 lines
4.7 KiB
C#
101 lines
4.7 KiB
C#
/*
|
|
Copyright 2015 MCGalaxy
|
|
|
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
|
not use this file except in compliance with the Licenses. You may
|
|
obtain a copy of the Licenses at
|
|
|
|
http://www.opensource.org/licenses/ecl2.php
|
|
http://www.gnu.org/licenses/gpl-3.0.html
|
|
|
|
Unless required by applicable law or agreed to in writing,
|
|
software distributed under the Licenses are distributed on an "AS IS"
|
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
or implied. See the Licenses for the specific language governing
|
|
permissions and limitations under the Licenses.
|
|
*/
|
|
using System;
|
|
|
|
namespace MCGalaxy.Commands {
|
|
|
|
public class CmdModel : Command {
|
|
|
|
public override string name { get { return "model"; } }
|
|
public override string shortcut { get { return "setmodel"; } }
|
|
public override string type { get { return CommandTypes.Other; } }
|
|
public override bool museumUsable { get { return true; } }
|
|
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
|
static char[] trimChars = { ' ' };
|
|
|
|
public override void Use(Player p, string message) {
|
|
if (message == "") message = "normal";
|
|
Player who = p;
|
|
PlayerBot pBot = null;
|
|
bool isBot = message.CaselessStarts("bot ");
|
|
string[] args = message.Split(trimChars, isBot ? 3 : 2);
|
|
|
|
if (args.Length > 1) {
|
|
if (isBot && args.Length > 2) {
|
|
pBot = PlayerBot.Find(args[1]);
|
|
if (pBot == null) { Player.SendMessage(p, "There is no bot with that name."); return; }
|
|
} else {
|
|
isBot = false;
|
|
who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
|
if (who == null) return;
|
|
}
|
|
} else if (p == null) {
|
|
Player.SendMessage(p, "Console can't use this command on itself."); return;
|
|
}
|
|
|
|
string model = args[args.Length - 1];
|
|
if (isBot) {
|
|
pBot.model = model;
|
|
UpdateModel(pBot.id, model, pBot.level, null);
|
|
Player.GlobalMessage("Bot " + pBot.name + "'s %Smodel was changed to a &c" + model);
|
|
} else {
|
|
who.model = model;
|
|
UpdateModel(who.id, model, who.level, who);
|
|
Player.GlobalMessage(who.color + who.DisplayName + "'s %Smodel was changed to a &c" + model);
|
|
}
|
|
}
|
|
|
|
void UpdateModel(byte id, string model, Level level, Player who) {
|
|
Player[] players = PlayerInfo.Online.Items;
|
|
foreach (Player pl in players) {
|
|
if (pl.level != level || !pl.HasCpeExt(CpeExt.ChangeModel)) continue;
|
|
byte sendId = (pl == who) ? (byte)0xFF : id;
|
|
pl.SendChangeModel(sendId, model);
|
|
}
|
|
}
|
|
|
|
public override void Help(Player p) {
|
|
Player.SendMessage(p, "/model [name] [model] - Sets the model of that player.");
|
|
Player.SendMessage(p, "/model bot [name] [model] - Sets the model of that bot.");
|
|
Player.SendMessage(p, "Available models: Chibi, Chicken, Creeper, Croc, Humanoid, Pig, Printer, Sheep, Spider, Skeleton, Zombie.");
|
|
Player.SendMessage(p, "You can also place a block ID instead of a model name, to change your model into a block!");
|
|
}
|
|
}
|
|
|
|
public class CmdXModel : Command {
|
|
|
|
public override string name { get { return "xmodel"; } }
|
|
public override string shortcut { get { return "xm"; } }
|
|
public override string type { get { return CommandTypes.Other; } }
|
|
public override bool museumUsable { get { return true; } }
|
|
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
|
|
|
public override void Use(Player p, string message) {
|
|
if (p == null) { MessageInGameOnly(p); }
|
|
string model = message == "" ? "normal" : message;
|
|
Command.all.Find("model").Use(p, p.name + " " + model);
|
|
}
|
|
|
|
public override void Help(Player p) {
|
|
Player.SendMessage(p, "/xm [model] - Sets your own model.");
|
|
Player.SendMessage(p, "Available models: Chibi, Chicken, Creeper, Croc, Humanoid, Pig, Printer, Sheep, Spider, Skeleton, Zombie.");
|
|
Player.SendMessage(p, "You can also place a block ID instead of a model name, to change your model into a block!");
|
|
}
|
|
}
|
|
}
|