mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 23:02:04 -04:00
Using /repeat now works with /static, also /last should show time of use. (Thanks Zingan)
This commit is contained in:
parent
ba111e1676
commit
c9722526a4
@ -1,24 +1,23 @@
|
||||
/*
|
||||
Copyright 2011 MCForge
|
||||
|
||||
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.
|
||||
Copyright 2011 MCForge
|
||||
|
||||
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.
|
||||
*/
|
||||
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 == "")
|
||||
{
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in players)
|
||||
{
|
||||
if (pl.lastCMD.Contains("setpass") || pl.lastCMD.Contains("pass"))
|
||||
{
|
||||
pl.lastCMD = "";
|
||||
}
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
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)");
|
||||
}
|
||||
|
@ -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]);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user