Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added /staff #519

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion MCGalaxy/Chat/Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ public enum ChatScope {

public delegate bool ChatMessageFilter(Player pl, object arg);
public static class Chat {


public static ItemPerms StaffPerms {
get {
ItemPerms perms = CommandExtraPerms.Find("Staff", 1);
return perms != null ? perms : new ItemPerms(LevelPermission.Operator, null, null);
}
}

public static ItemPerms OpchatPerms {
get {
ItemPerms perms = CommandExtraPerms.Find("OpChat", 1);
Expand Down Expand Up @@ -112,6 +119,11 @@ public static ChatMessageFilter FilterVisible(Player source) {

public static void MessageAll(string msg) { Message(ChatScope.All, msg, null, null); }
public static void MessageGlobal(string msg) { Message(ChatScope.Global, msg, null, null); }

public static void MessageStaff(string msg) {
Message(ChatScope.Perms, msg, StaffPerms, null);
}

public static void MessageOps(string msg) {
Message(ChatScope.Perms, msg, OpchatPerms, null);
}
Expand Down
13 changes: 9 additions & 4 deletions MCGalaxy/Chat/ChatModes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,23 @@ public static bool Handle(Player p, string text) {
}
return false;
}

public static void MessageStaff(Player p, string message) {
if (!MessageCmd.CanSpeak(p, "Staff")) return;
MessageGroup(p, message, Chat.StaffPerms, "Staff");
}

public static void MessageOps(Player p, string message) {
if (!MessageCmd.CanSpeak(p, "OpChat")) return;
MessageStaff(p, message, Chat.OpchatPerms, "Ops");
MessageGroup(p, message, Chat.OpchatPerms, "Ops");
}

public static void MessageAdmins(Player p, string message) {
if (!MessageCmd.CanSpeak(p, "AdminChat")) return;
MessageStaff(p, message, Chat.AdminchatPerms, "Admins");
MessageGroup(p, message, Chat.AdminchatPerms, "Admins");
}

public static void MessageStaff(Player p, string message,
public static void MessageGroup(Player p, string message,
ItemPerms perms, string group) {
if (message.Length == 0) { p.Message("No message to send."); return; }

Expand Down
58 changes: 58 additions & 0 deletions MCGalaxy/Commands/Information/CmdStaff.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
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.Collections.Generic;
using MCGalaxy;

namespace MCGalaxy.Commands.Info {
public sealed class CmdStaff : Command2 {
public override string name { get { return "Staff"; } }
public override string type { get { return "information"; } }

public override CommandPerm[] ExtraPerms {
get { return new[] { new CommandPerm(LevelPermission.Operator, "are staff"),
new CommandPerm(LevelPermission.Operator, "can read staff messages") }; }
}

public override void Use(Player p, string message, CommandData data) {
string[] args = message.SplitSpaces(2);

if (args[0].Length > 0) {
ChatModes.MessageStaff(p, args[0]);
} else {
ItemPerms perms = CommandExtraPerms.Find("Staff", 1);

foreach (Group grp in Group.GroupList) {
if (grp.Permission < perms.MinRank) continue;
if (grp.Permission == LevelPermission.Nobody) continue;

List<string> players = grp.Players.All();
if (players.Count == 0) continue;

p.Message(grp.ColoredName + "%H: " + players.Join());

}
}
}

public override void Help(Player p) {
p.Message("%T/Staff %H- Shows a list of current staff.");
p.Message("%T/Staff [message] %H- Sends a message to online staff.");
}
}
}