Using /repeat now works with /static, also /last should show time of use. (Thanks Zingan)

This commit is contained in:
UnknownShadow200 2016-03-31 11:54:32 +11:00
parent ba111e1676
commit c9722526a4
5 changed files with 43 additions and 51 deletions

View File

@ -15,10 +15,9 @@
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
namespace MCGalaxy.Commands
{
public sealed class CmdLastCmd : Command
{
namespace MCGalaxy.Commands {
public sealed class CmdLastCmd : Command {
public override string name { get { return "lastcmd"; } }
public override string shortcut { get { return "last"; } }
public override string type { get { return CommandTypes.Information; } }
@ -26,36 +25,28 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public CmdLastCmd() { }
public override void Use(Player p, string message)
{
if (message == "")
{
public override void Use(Player p, string message) {
if (message == "") {
Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players)
{
if (pl.lastCMD.Contains("setpass") || pl.lastCMD.Contains("pass"))
{
pl.lastCMD = "";
}
foreach (Player pl in players) {
if (Player.CanSee(p, pl))
{
Player.SendMessage(p, pl.color + pl.DisplayName + " %Slast used \"" + pl.lastCMD + "\"");
ShowLastCommand(p, pl);
}
}
}
else
{
} else {
Player who = PlayerInfo.FindOrShowMatches(p, message);
if (who == null) return;
if (who.lastCMD.Contains("setpass") || who.lastCMD.Contains("pass"))
{
who.lastCMD = "";
}
Player.SendMessage(p, who.color + who.DisplayName + " %Slast used \"" + who.lastCMD + "\"");
if (who != null)
ShowLastCommand(p, who);
}
}
public override void Help(Player p)
{
static void ShowLastCommand(Player p, Player who) {
if (who.lastCMD == "")
Player.SendMessage(p, who.color + who.DisplayName + " %Shas not used any commands yet.");
else
Player.SendMessage(p, who.color + who.DisplayName + " %Slast used \"" + who.lastCMD + "\" on " + who.lastCmdTime);
}
public override void Help(Player p) {
Player.SendMessage(p, "/last [user] - Shows last command used by [user]");
Player.SendMessage(p, "/last by itself will show all last commands (SPAMMY)");
}

View File

@ -32,7 +32,7 @@ namespace MCGalaxy.Commands {
p.modeType = 0;
Player.SendMessage(p, "Static mode: &a" + p.staticCommands);
if (message == "") return;
if (message == "" || !p.staticCommands) return;
string[] parts = message.Split(new char[] { ' ' }, 2);
Command cmd = Command.all.Find(parts[0]);

View File

@ -28,11 +28,8 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) {
if (p.lastCMD == "") { Player.SendMessage(p, "No commands used yet."); return; }
if (p.lastCMD.Length > 5 && p.lastCMD.Substring(0, 6) == "static") {
Player.SendMessage(p, "Can't repeat static"); return;
}
Player.SendMessage(p, "Using &b/" + p.lastCMD);
Player.SendMessage(p, "Repeating &b/" + p.lastCMD);
int argsIndex = p.lastCMD.IndexOf(' ');
string cmdName = argsIndex == -1 ? p.lastCMD : p.lastCMD.Substring(0, argsIndex);
string cmdMsg = argsIndex == -1 ? "" : p.lastCMD.Substring(argsIndex + 1);

View File

@ -91,7 +91,7 @@ namespace MCGalaxy {
int Diff = Math.Abs((pos[0] / 32) - x) + Math.Abs((pos[1] / 32) - y)
+ Math.Abs((pos[2] / 32) - z);
if ((Diff > ReachDistance + 4) && lastCMD != "click") {
if ((Diff > ReachDistance + 4) && (lastCMD == "click" || lastCMD == "mark")) {
Server.s.Log(name + " attempted to build with a " + Diff + " distance offset");
SendMessage("You can't build that far away.");
RevertBlock(x, y, z); return;
@ -1498,7 +1498,10 @@ return;
SendMessage("The game or economy associated with this command is not running, " +
"so this command is disabled."); return;
}
if (cmd != "repeat") lastCMD = cmd + " " + message;
if (!(cmd == "repeat" || cmd == "pass" || cmd == "setpass")) {
lastCMD = cmd + " " + message;
lastCmdTime = DateTime.Now;
}
if (level.IsMuseum && !command.museumUsable ) {
SendMessage("Cannot use this command while in a museum!"); return;

View File

@ -238,6 +238,7 @@ namespace MCGalaxy {
public string[] cmdBind = new string[10];
public string[] messageBind = new string[10];
public string lastCMD = "";
public DateTime lastCmdTime;
public sbyte c4circuitNumber = -1;
public Level level = Server.mainLevel;