mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Fix automute, add data to OnPlayerCommand event.
This commit is contained in:
parent
f5de158981
commit
fc2f3da646
@ -48,7 +48,7 @@ namespace MCGalaxy.Core {
|
||||
}
|
||||
}
|
||||
|
||||
internal static void HandleCommand(Player p, string cmd, string args) {
|
||||
internal static void HandleCommand(Player p, string cmd, string args, CommandData data) {
|
||||
if (!ServerConfig.CoreSecretCommands) return;
|
||||
|
||||
// DO NOT REMOVE THE TWO COMMANDS BELOW, /PONY AND /RAINBOWDASHLIKESCOOLTHINGS. -EricKilla
|
||||
|
@ -63,15 +63,15 @@ namespace MCGalaxy.Events.PlayerEvents {
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void OnPlayerCommand(Player p, string cmd, string args);
|
||||
public delegate void OnPlayerCommand(Player p, string cmd, string args, CommandData data);
|
||||
/// <summary> Called whenever a player uses a command. </summary>
|
||||
/// <remarks> You must cancel this event to prevent "Unknown command!" being shown. </remarks>
|
||||
public sealed class OnPlayerCommandEvent : IEvent<OnPlayerCommand> {
|
||||
|
||||
public static void Call(Player p, string cmd, string args) {
|
||||
public static void Call(Player p, string cmd, string args, CommandData data) {
|
||||
IEvent<OnPlayerCommand>[] items = handlers.Items;
|
||||
for (int i = 0; i < items.Length; i++) {
|
||||
try { items[i].method(p, cmd, args); }
|
||||
try { items[i].method(p, cmd, args, data); }
|
||||
catch (Exception ex) { LogHandlerException(ex, items[i]); }
|
||||
}
|
||||
}
|
||||
|
@ -73,17 +73,17 @@ namespace MCGalaxy.Games {
|
||||
p.cancelchat = true;
|
||||
}
|
||||
|
||||
void HandlePlayerCommand(Player p, string cmd, string args) {
|
||||
void HandlePlayerCommand(Player p, string cmd, string args, CommandData data) {
|
||||
if (p.level != Map || cmd != "teamchat") return;
|
||||
CtfData data = Get(p);
|
||||
CtfData data_ = Get(p);
|
||||
|
||||
if (data.TeamChatting) {
|
||||
if (data_.TeamChatting) {
|
||||
p.Message("You are no longer chatting with your team!");
|
||||
} else {
|
||||
p.Message("You are now chatting with your team!");
|
||||
}
|
||||
|
||||
data.TeamChatting = !data.TeamChatting;
|
||||
data_.TeamChatting = !data_.TeamChatting;
|
||||
p.cancelcommand = true;
|
||||
}
|
||||
|
||||
|
@ -602,7 +602,7 @@ namespace MCGalaxy {
|
||||
public void HandleCommand(string cmd, string args, CommandData data) {
|
||||
cmd = cmd.ToLower();
|
||||
try {
|
||||
Command command = GetCommand(ref cmd, ref args);
|
||||
Command command = GetCommand(ref cmd, ref args, data);
|
||||
if (command == null) return;
|
||||
|
||||
Thread thread = new Thread(() => UseCommand(command, args, data));
|
||||
@ -623,7 +623,7 @@ namespace MCGalaxy {
|
||||
string cmd = parts[0].ToLower();
|
||||
string args = parts.Length > 1 ? parts[1] : "";
|
||||
|
||||
Command command = GetCommand(ref cmd, ref args);
|
||||
Command command = GetCommand(ref cmd, ref args, data);
|
||||
if (command == null) return;
|
||||
|
||||
messages.Add(args); commands.Add(command);
|
||||
@ -659,7 +659,7 @@ namespace MCGalaxy {
|
||||
return true;
|
||||
}
|
||||
|
||||
Command GetCommand(ref string cmdName, ref string cmdArgs) {
|
||||
Command GetCommand(ref string cmdName, ref string cmdArgs, CommandData data) {
|
||||
if (!CheckCommand(cmdName)) return null;
|
||||
Command.Search(ref cmdName, ref cmdArgs);
|
||||
|
||||
@ -674,7 +674,7 @@ namespace MCGalaxy {
|
||||
cmdArgs = cmdArgs.TrimEnd(' ');
|
||||
}
|
||||
|
||||
OnPlayerCommandEvent.Call(this, cmdName, cmdArgs);
|
||||
OnPlayerCommandEvent.Call(this, cmdName, cmdArgs, data);
|
||||
if (cancelcommand) { cancelcommand = false; return null; }
|
||||
|
||||
Command command = Command.Find(cmdName);
|
||||
|
@ -63,7 +63,7 @@ namespace MCGalaxy {
|
||||
return false;
|
||||
|
||||
TimeSpan duration = TimeSpan.FromSeconds(ServerConfig.ChatSpamMuteTime);
|
||||
ModAction action = new ModAction(p.name, null, ModActionType.Muted, "&0Auto mute for spamming", duration);
|
||||
ModAction action = new ModAction(p.name, Player.Console, ModActionType.Muted, "&0Auto mute for spamming", duration);
|
||||
OnModActionEvent.Call(action);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user