mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-01 09:36:03 -04:00
Simplify some use of ItemPerms
This commit is contained in:
parent
5386ad74b4
commit
466f1c9f68
@ -72,8 +72,7 @@ namespace MCGalaxy {
|
||||
|
||||
public static bool CanEditAny(Player p) {
|
||||
if (LevelInfo.IsRealmOwner(p.name, p.level.name)) { return true; }
|
||||
ItemPerms perms = CommandExtraPerms.Find("Bot", 1);
|
||||
perms = perms == null ? new ItemPerms(LevelPermission.Operator, null, null) : perms;
|
||||
ItemPerms perms = CommandExtraPerms.Find("Bot", 1) ?? new ItemPerms(LevelPermission.Operator);
|
||||
if (perms.UsableBy(p.Rank)) { return true; }
|
||||
return false;
|
||||
}
|
||||
@ -308,10 +307,10 @@ namespace MCGalaxy {
|
||||
ScaleZ == 0 ? "none" : ScaleZ.ToString()
|
||||
);
|
||||
}
|
||||
if (String.IsNullOrEmpty(ClickedOnText)) { return; }
|
||||
ItemPerms perms = CommandExtraPerms.Find("About", 1);
|
||||
perms = perms == null ? new ItemPerms(LevelPermission.AdvBuilder, null, null) : perms;
|
||||
if (!perms.UsableBy(p.Rank)) { return; } //don't show bot's ClickedOnText if player isn't allowed to see message block contents
|
||||
|
||||
if (String.IsNullOrEmpty(ClickedOnText)) return;
|
||||
ItemPerms perms = CommandExtraPerms.Find("About", 1) ?? new ItemPerms(LevelPermission.AdvBuilder);
|
||||
if (!perms.UsableBy(p.Rank)) return; //don't show bot's ClickedOnText if player isn't allowed to see message block contents
|
||||
p.Message(" Clicked-on text: {0}", ClickedOnText);
|
||||
}
|
||||
|
||||
|
@ -46,14 +46,14 @@ namespace MCGalaxy {
|
||||
public static ItemPerms OpchatPerms {
|
||||
get {
|
||||
ItemPerms perms = CommandExtraPerms.Find("OpChat", 1);
|
||||
return perms != null ? perms : new ItemPerms(LevelPermission.Operator, null, null);
|
||||
return perms ?? new ItemPerms(LevelPermission.Operator);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemPerms AdminchatPerms {
|
||||
get {
|
||||
ItemPerms perms = CommandExtraPerms.Find("AdminChat", 1);
|
||||
return perms != null ? perms : new ItemPerms(LevelPermission.Admin, null, null);
|
||||
return perms ?? new ItemPerms(LevelPermission.Admin);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ namespace MCGalaxy.Commands.Eco {
|
||||
if (!ParseArgs(p, message, ref all, "pay", out trans)) return;
|
||||
|
||||
// Player can use /pay messages to bypass a mute
|
||||
// TODO: Make MessageCmd.CanSpeak more generic so that can be used here instead
|
||||
if (trans.Reason != null && !p.CanSpeak()) {
|
||||
p.Message("%WCannot specify a payment reason, as you cannot currently speak");
|
||||
return;
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
}
|
||||
|
||||
static void AnnounceOps(Player p, string msg) {
|
||||
ItemPerms perms = new ItemPerms(p.hideRank, null, null);
|
||||
ItemPerms perms = new ItemPerms(p.hideRank);
|
||||
Chat.MessageFrom(ChatScope.Perms, p, msg, perms, null, true);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@ namespace MCGalaxy {
|
||||
public LevelPermission MinRank;
|
||||
public List<LevelPermission> Allowed, Disallowed;
|
||||
|
||||
public ItemPerms(LevelPermission min) { Init(min, null, null); }
|
||||
|
||||
public ItemPerms(LevelPermission min, List<LevelPermission> allowed,
|
||||
List<LevelPermission> disallowed) {
|
||||
Init(min, allowed, disallowed);
|
||||
|
@ -25,9 +25,7 @@ namespace MCGalaxy {
|
||||
public static class Formatter {
|
||||
|
||||
public static void PrintCommandInfo(Player p, Command cmd) {
|
||||
ItemPerms perms = CommandPerms.Find(cmd.name);
|
||||
if (perms == null) perms = new ItemPerms(cmd.defaultRank, null, null);
|
||||
|
||||
ItemPerms perms = CommandPerms.Find(cmd.name) ?? new ItemPerms(cmd.defaultRank);
|
||||
p.Message("Usable by: " + perms.Describe());
|
||||
PrintAliases(p, cmd);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user