mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 14:54:12 -04:00
Fix /xmodel not updating your own model when you are the only player in the world. (Thanks goodlyay)
This commit is contained in:
parent
49bd34918f
commit
e9b879d825
@ -1,72 +1,56 @@
|
||||
/*
|
||||
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;
|
||||
using System.IO;
|
||||
using MCGalaxy;
|
||||
|
||||
namespace MCGalaxy.Commands
|
||||
{
|
||||
public class CmdModel : Command
|
||||
{
|
||||
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; } }
|
||||
public CmdModel() { }
|
||||
static char[] trimChars = { ' ' };
|
||||
|
||||
public override void Use(Player p, string message)
|
||||
{
|
||||
if (message == "")
|
||||
{
|
||||
message = "normal";
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") message = "normal";
|
||||
Player who = p;
|
||||
string[] args = message.Split(trimChars, 2);
|
||||
|
||||
if (args.Length > 1) {
|
||||
who = PlayerInfo.Find(args[0]);
|
||||
if (who == null) { Player.SendMessage(p, "Player \"" + args[0] + "\" does not exist"); return; }
|
||||
} else {
|
||||
if (p == null) { Player.SendMessage(p, "Console can't use this command on itself."); return; }
|
||||
}
|
||||
|
||||
Player targetPlayer;
|
||||
string model;
|
||||
|
||||
if (message.Split(' ').Length > 1)
|
||||
{
|
||||
targetPlayer = PlayerInfo.Find(message.Split(' ')[0].Trim());
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
Player.SendMessage(p, "Player \"" + message.Split(' ')[0].Trim() + "\" does not exist");
|
||||
return;
|
||||
}
|
||||
model = message.Split(' ')[1].Trim();
|
||||
targetPlayer.model = model;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p == null)
|
||||
{
|
||||
Player.SendMessage(null, "Console can't use this command on itself.");
|
||||
return;
|
||||
}
|
||||
targetPlayer = p;
|
||||
model = message;
|
||||
p.model = model;
|
||||
}
|
||||
|
||||
foreach (Player pl in PlayerInfo.players)
|
||||
{
|
||||
if (pl.level == targetPlayer.level && pl.HasCpeExt(CpeExt.ChangeModel))
|
||||
{
|
||||
pl.SendChangeModel(targetPlayer.id, message);
|
||||
who.model = args[args.Length - 1];
|
||||
foreach (Player pl in PlayerInfo.players) {
|
||||
if (pl.level == who.level && pl.HasCpeExt(CpeExt.ChangeModel)) {
|
||||
byte id = (pl == who) ? (byte)0xFF : who.id;
|
||||
pl.SendChangeModel(id, who.model);
|
||||
}
|
||||
}
|
||||
|
||||
if (p == null)
|
||||
{
|
||||
targetPlayer.SendMessage("You're now a &c" + model);
|
||||
}
|
||||
else
|
||||
{
|
||||
Command.all.Find("aka").Use(targetPlayer, "");
|
||||
Player.GlobalMessage(targetPlayer.color + targetPlayer.DisplayName + "'s" + Server.DefaultColor + " model was changed to a &c" + model);
|
||||
}
|
||||
Player.GlobalMessage(who.color + who.DisplayName + "'s %Smodel was changed to a &c" + args[args.Length - 1]);
|
||||
}
|
||||
|
||||
public override void Help(Player p)
|
||||
{
|
||||
public override void Help(Player p) {
|
||||
Player.SendMessage(p, "/model <player> [model] - Changes your player model.");
|
||||
Player.SendMessage(p, "Available models: 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!");
|
||||
|
@ -1,42 +1,42 @@
|
||||
/*
|
||||
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;
|
||||
using System.IO;
|
||||
using MCGalaxy;
|
||||
|
||||
namespace MCGalaxy.Commands
|
||||
{
|
||||
public class CmdXModel : Command
|
||||
{
|
||||
namespace MCGalaxy.Commands {
|
||||
|
||||
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 CmdXModel() { }
|
||||
|
||||
public override void Use(Player p, string message)
|
||||
{
|
||||
if (p == null)
|
||||
{
|
||||
Player.SendMessage(p, "You cannot use this command from the console!");
|
||||
return;
|
||||
}
|
||||
if (message == "")
|
||||
{
|
||||
Command.all.Find("model").Use(p, p.name + " normal");
|
||||
}
|
||||
else
|
||||
{
|
||||
Command.all.Find("model").Use(p, p.name + " " + message);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
public override void Help(Player p) {
|
||||
Player.SendMessage(p, "/xm [model] - Changes your player model.");
|
||||
Player.SendMessage(p, "Available models: 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!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user