mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Provide more helpful and consistent messages when using commands from IRC/console that require a specific player/level/etc name (as own player cannot be used).
This commit is contained in:
parent
374b53e0cd
commit
d97aeb508a
@ -30,12 +30,8 @@ namespace MCGalaxy.Commands.CPE {
|
||||
static char[] trimChars = { ' ' };
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") {
|
||||
if (p == null) {
|
||||
Player.Message(p, "Console must provide a player or bot name."); return;
|
||||
}
|
||||
message = p.name;
|
||||
}
|
||||
if (CheckSuper(p, message, "player or bot name")) return;
|
||||
message = p.name;
|
||||
|
||||
Player who = p;
|
||||
PlayerBot pBot = null;
|
||||
@ -55,7 +51,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
} else {
|
||||
isBot = false;
|
||||
who = p;
|
||||
if (who == null) { Player.Message(p, "Console must provide a player name."); return; }
|
||||
if (who == null) { SuperRequiresArgs(p, "player name"); return; }
|
||||
model = message;
|
||||
}
|
||||
model = model.ToLower();
|
||||
|
@ -30,12 +30,8 @@ namespace MCGalaxy.Commands.CPE {
|
||||
static char[] trimChars = { ' ' };
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") {
|
||||
if (p == null) {
|
||||
Player.Message(p, "Console must provide a player or bot name."); return;
|
||||
}
|
||||
message = p.truename;
|
||||
}
|
||||
if (CheckSuper(p, message, "player or bot name")) return;
|
||||
message = p.truename;
|
||||
|
||||
Player who = p;
|
||||
PlayerBot pBot = null;
|
||||
@ -55,7 +51,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
} else {
|
||||
isBot = false;
|
||||
who = p;
|
||||
if (who == null) { Player.Message(p, "Console must provide a player name."); return; }
|
||||
if (who == null) { SuperRequiresArgs(p, "player name"); return; }
|
||||
skin = message;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,18 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
protected void MessageInGameOnly(Player p) {
|
||||
Player.Message(p, "/" + name + " can only be used in-game.");
|
||||
Player.Message(p, "/{0} can only be used in-game.", name);
|
||||
}
|
||||
|
||||
protected bool CheckSuper(Player p, string message, string type) {
|
||||
if (message != "" || (p != null && p.ircNick == null)) return false;
|
||||
SuperRequiresArgs(p, type);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void SuperRequiresArgs(Player p, string type) {
|
||||
string src = p == null ? "console" : "IRC";
|
||||
Player.Message(p, "When using /{0} from {2}, you must provide a {1}.", name, type, src);
|
||||
}
|
||||
|
||||
protected bool CheckExtraPerm(Player p, int num = 1) {
|
||||
@ -60,9 +71,9 @@ namespace MCGalaxy {
|
||||
protected void MessageNeedMinPerm(Player p, string action, int perm) {
|
||||
Group grp = Group.findPermInt(perm);
|
||||
if (grp == null)
|
||||
Player.Message(p, "Only ranks with permissions greater than &a" + perm + "%Scan " + action);
|
||||
Player.Message(p, "Only ranks with permissions greater than &a{0}%Scan {1}", perm, action);
|
||||
else
|
||||
Player.Message(p, "Only " + grp.ColoredName + "%S+ can " + action);
|
||||
Player.Message(p, "Only {0}%S+ can {1}", grp.ColoredName, action);
|
||||
}
|
||||
|
||||
protected void MessageTooHighRank(Player p, string action, bool canAffectOwnRank) {
|
||||
@ -71,9 +82,9 @@ namespace MCGalaxy {
|
||||
|
||||
protected void MessageTooHighRank(Player p, string action, Group grp, bool canAffectGroup) {
|
||||
if (canAffectGroup)
|
||||
Player.Message(p, "Can only " + action + " players ranked " + grp.ColoredName + " %Sor below");
|
||||
Player.Message(p, "Can only {0} players ranked {1} %Sor below", action, grp.ColoredName);
|
||||
else
|
||||
Player.Message(p, "Can only " + action + " players ranked below " + grp.ColoredName);
|
||||
Player.Message(p, "Can only {0} players ranked below {1}", action, grp.ColoredName);
|
||||
}
|
||||
|
||||
internal void MessageCannotUse(Player p) {
|
||||
@ -85,14 +96,14 @@ namespace MCGalaxy {
|
||||
StringBuilder builder = new StringBuilder("Only ");
|
||||
if (perms.allow.Count > 0) {
|
||||
foreach (LevelPermission perm in perms.allow) {
|
||||
Group grp = Group.findPermInt((int)perm);
|
||||
Group grp = Group.findPermInt((int)perm);
|
||||
if (grp == null) continue;
|
||||
builder.Append(grp.ColoredName).Append("%S, ");
|
||||
}
|
||||
if (builder.Length > "Only ".Length) {
|
||||
if (builder.Length > "Only ".Length) {
|
||||
builder.Remove(builder.Length - 2, 2);
|
||||
builder.Append(", and ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Group minGrp = Group.findPermInt((int)perms.lowestRank);
|
||||
|
@ -30,9 +30,7 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
Economy.EcoStats ecos;
|
||||
if (p == null && message == "") {
|
||||
Player.Message(p, "You must provide a name when using the command from console."); return;
|
||||
}
|
||||
if (CheckSuper(p, message, "player name")) return;
|
||||
|
||||
int matches = 1;
|
||||
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message, out matches);
|
||||
|
@ -25,10 +25,8 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public CmdBanInfo() { }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") {
|
||||
if (p == null) { Player.Message(p, "Console must provide a player name."); return; }
|
||||
message = p.name;
|
||||
}
|
||||
if (CheckSuper(p, message, "player name")) return;
|
||||
if (message == "") message = p.name;
|
||||
bool banned = Group.IsBanned(message);
|
||||
string msg = message;
|
||||
string ip = PlayerInfo.FindIP(message);
|
||||
|
@ -38,9 +38,7 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") {
|
||||
if (p == null) {
|
||||
Player.Message(p, "Console must provide a rank name."); return;
|
||||
}
|
||||
if (CheckSuper(p, message, "rank name")) return;
|
||||
|
||||
Group next = null;
|
||||
int index = Group.GroupList.IndexOf(p.group);
|
||||
|
@ -30,13 +30,9 @@ namespace MCGalaxy.Commands {
|
||||
public CmdAllowGuns() { }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
Level lvl = null;
|
||||
if (message == "") {
|
||||
if (p == null) {
|
||||
Player.Message(p, "You must provide a level name when using this command from console."); return;
|
||||
}
|
||||
lvl = p.level;
|
||||
} else {
|
||||
if (CheckSuper(p, message, "level name")) return;
|
||||
Level lvl = p.level;
|
||||
if (message != "") {
|
||||
lvl = LevelInfo.FindOrShowMatches(p, message);
|
||||
if (lvl == null) return;
|
||||
}
|
||||
|
@ -31,12 +31,8 @@ namespace MCGalaxy.Commands {
|
||||
if (!Server.LogNotes) {
|
||||
Player.Message(p, "The server does not have notes logging enabled."); return;
|
||||
}
|
||||
if (message == "") {
|
||||
if (p == null) {
|
||||
Player.Message(p, "Console must provide a player name."); return;
|
||||
}
|
||||
message = p.name;
|
||||
}
|
||||
if (CheckSuper(p, message, "player name")) return;
|
||||
if (message == "") message = p.name;
|
||||
|
||||
int matches = 1;
|
||||
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message, out matches);
|
||||
|
@ -31,9 +31,7 @@ namespace MCGalaxy.Commands.World {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
string[] args = message.Split(' ');
|
||||
if (args.Length == 1 && p == null) {
|
||||
Player.Message(p, "You must provide a map name when running the command from console."); return;
|
||||
}
|
||||
if (args.Length == 1 && p == null) { SuperRequiresArgs(p, "map name"); return; }
|
||||
args[0] = args[0].ToLower();
|
||||
|
||||
Level lvl = p == null ? null : p.level;
|
||||
|
@ -37,9 +37,9 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (CheckSuper(p, message, "player name")) return;
|
||||
int ignored = 0;
|
||||
if (message == "") {
|
||||
if (p == null) { Player.Message(null, "Console doesn't have an undo buffer."); return; }
|
||||
UndoSelf(p); return;
|
||||
} else if (p != null && int.TryParse(message, out ignored)) {
|
||||
message = p.name.ToLower() + " " + message;
|
||||
|
@ -25,10 +25,12 @@ namespace MCGalaxy.Commands {
|
||||
public override string type { get { return CommandTypes.Other; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||
public override CommandAlias[] Aliases {
|
||||
get { return new[] { new CommandAlias("colour") }; }
|
||||
public override CommandPerm[] AdditionalPerms {
|
||||
get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can change color of other players") }; }
|
||||
}
|
||||
public override CommandAlias[] Aliases {
|
||||
get { return new[] { new CommandAlias("colour"), new CommandAlias("xcolor") }; }
|
||||
}
|
||||
public CmdColor() { }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
|
@ -202,7 +202,7 @@ namespace MCGalaxy {
|
||||
SW.WriteLine("MOTD = " + grp.MOTD);
|
||||
SW.WriteLine("FileName = " + grp.fileName);
|
||||
SW.WriteLine("OSMaps = " + grp.OverseerMaps);
|
||||
SW.WriteLine("Prefix = " + grp.prefix);
|
||||
SW.WriteLine("Prefix = " + CP437Writer.ConvertToUnicode(grp.prefix));
|
||||
SW.WriteLine();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user