mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Work properly when opchannel is unused, also use generic RaisePlayerAction event instead of hardcoding IRC behaviour.
This commit is contained in:
parent
0407666986
commit
958a16dc25
@ -38,7 +38,7 @@ namespace MCGalaxy.Commands
|
|||||||
Chat.GlobalChatLevel(p, "<Level>" + p.color + "*" + Colors.StripColours(p.DisplayName) + " " + message, false);
|
Chat.GlobalChatLevel(p, "<Level>" + p.color + "*" + Colors.StripColours(p.DisplayName) + " " + message, false);
|
||||||
} else {
|
} else {
|
||||||
Player.SendChatFrom(p, p.color + "*" + Colors.StripColours(p.DisplayName) + " " + message, false);
|
Player.SendChatFrom(p, p.color + "*" + Colors.StripColours(p.DisplayName) + " " + message, false);
|
||||||
Server.IRC.Say("*" + p.DisplayName + " " + message);
|
Player.RaisePlayerAction(p, PlayerAction.Me, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ namespace MCGalaxy.Commands
|
|||||||
p.afkMessage = message;
|
p.afkMessage = message;
|
||||||
p.IsAfk = true;
|
p.IsAfk = true;
|
||||||
Player.GlobalMessage("-" + p.ColoredName + "%S- is AFK " + message);
|
Player.GlobalMessage("-" + p.ColoredName + "%S- is AFK " + message);
|
||||||
Server.IRC.Say(p.DisplayName + " is AFK " + message);
|
Player.RaisePlayerAction(p, PlayerAction.AFK, message);
|
||||||
} else {
|
} else {
|
||||||
p.IsAfk = false;
|
p.IsAfk = false;
|
||||||
p.afkMessage = null;
|
p.afkMessage = null;
|
||||||
Player.GlobalMessage("-" + p.ColoredName + "%S- is no longer AFK");
|
Player.GlobalMessage("-" + p.ColoredName + "%S- is no longer AFK");
|
||||||
Server.IRC.Say(p.DisplayName + " is no longer AFK");
|
Player.RaisePlayerAction(p, PlayerAction.UnAFK, message);
|
||||||
}
|
}
|
||||||
TabList.Update(p, true);
|
TabList.Update(p, true);
|
||||||
}
|
}
|
||||||
|
@ -47,14 +47,14 @@ namespace MCGalaxy.Commands {
|
|||||||
} else {
|
} else {
|
||||||
Player.SendChatFrom(who, who.ColoredName + " %Sis now a &aJ&bo&ck&5e&9r%S.", false);
|
Player.SendChatFrom(who, who.ColoredName + " %Sis now a &aJ&bo&ck&5e&9r%S.", false);
|
||||||
}
|
}
|
||||||
Server.IRC.Say(who.ColoredName + " %Sis now a &aJ&bo&ck&5e&9r%S.", stealth);
|
Player.RaisePlayerAction(p, PlayerAction.Joker, null, stealth);
|
||||||
} else {
|
} else {
|
||||||
if (stealth) {
|
if (stealth) {
|
||||||
Chat.GlobalMessageOps(who.ColoredName + " %Sis now STEALTH unjokered.");
|
Chat.GlobalMessageOps(who.ColoredName + " %Sis now STEALTH unjokered.");
|
||||||
} else {
|
} else {
|
||||||
Player.SendChatFrom(who, who.ColoredName + " %Sis no longer a &aJ&bo&ck&5e&9r%S.", false);
|
Player.SendChatFrom(who, who.ColoredName + " %Sis no longer a &aJ&bo&ck&5e&9r%S.", false);
|
||||||
}
|
}
|
||||||
Server.IRC.Say(who.ColoredName + " %Sis no longer a &aJ&bo&ck&5e&9r%S.", stealth);
|
Player.RaisePlayerAction(p, PlayerAction.Unjoker, null, stealth);
|
||||||
}
|
}
|
||||||
who.joker = !who.joker;
|
who.joker = !who.joker;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ namespace MCGalaxy.Commands {
|
|||||||
bool showJoin = p.level.ShouldSaveChanges() || (oldLevel != null && oldLevel.ShouldSaveChanges());
|
bool showJoin = p.level.ShouldSaveChanges() || (oldLevel != null && oldLevel.ShouldSaveChanges());
|
||||||
if (!p.hidden && showJoin) {
|
if (!p.hidden && showJoin) {
|
||||||
Player.SendChatFrom(p, p.color + "*" + p.DisplayName + " %Swent to &b" + lvl.name, false);
|
Player.SendChatFrom(p, p.color + "*" + p.DisplayName + " %Swent to &b" + lvl.name, false);
|
||||||
Server.IRC.Say(p.ColoredName + " %rwent to &8" + lvl.name, false, true);
|
Player.RaisePlayerAction(p, PlayerAction.JoinWorld, lvl.name);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -53,15 +53,13 @@ namespace MCGalaxy.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
level.setPhysics(state);
|
level.setPhysics(state);
|
||||||
if (state == 0)
|
if (state == 0) level.ClearPhysics();
|
||||||
level.ClearPhysics();
|
|
||||||
string stateDesc = states[state];
|
string stateDesc = states[state];
|
||||||
Player.GlobalMessage("Physics are now " + stateDesc + "%S on &b" + level.name + "%S.");
|
level.ChatLevel("Physics are now " + stateDesc + "%S on &b" + level.name + "%S.");
|
||||||
stateDesc = stateDesc.Substring( 2 );
|
|
||||||
|
|
||||||
|
stateDesc = stateDesc.Substring( 2 );
|
||||||
string logInfo = "Physics are now " + stateDesc + " on " + level.name + ".";
|
string logInfo = "Physics are now " + stateDesc + " on " + level.name + ".";
|
||||||
Server.s.Log(logInfo);
|
Server.s.Log(logInfo);
|
||||||
Server.IRC.Say(logInfo);
|
|
||||||
level.changed = true;
|
level.changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,9 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
namespace MCGalaxy {
|
namespace MCGalaxy {
|
||||||
|
public enum PlayerAction { Joker, Unjoker, AFK, UnAFK, JoinWorld, Me };
|
||||||
|
|
||||||
/// <summary> This is the player object </summary>
|
/// <summary> This is the player object </summary>
|
||||||
public sealed partial class Player {
|
public sealed partial class Player {
|
||||||
|
|
||||||
internal bool cancelcommand = false;
|
internal bool cancelcommand = false;
|
||||||
internal bool cancelchat = false;
|
internal bool cancelchat = false;
|
||||||
internal bool cancelmove = false;
|
internal bool cancelmove = false;
|
||||||
@ -133,5 +135,16 @@ namespace MCGalaxy {
|
|||||||
public static event OnPlayerRotate PlayerRotate = null;
|
public static event OnPlayerRotate PlayerRotate = null;
|
||||||
/// <summary> Called when the player rotates. </summary>
|
/// <summary> Called when the player rotates. </summary>
|
||||||
public event OnPlayerRotate OnRotate = null;
|
public event OnPlayerRotate OnRotate = null;
|
||||||
|
|
||||||
|
/// <summary> Called when the player performs an action. </summary>
|
||||||
|
public delegate void OnPlayerAction(Player p, PlayerAction action,
|
||||||
|
string message, bool stealth);
|
||||||
|
/// <summary> Called when a player performs an action. </summary>
|
||||||
|
public static event OnPlayerAction DoPlayerAction = null;
|
||||||
|
public static void RaisePlayerAction(Player p, PlayerAction action,
|
||||||
|
string message = null, bool stealth = false) {
|
||||||
|
OnPlayerAction change = DoPlayerAction;
|
||||||
|
if (change != null) change(p, action, message, stealth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ namespace MCGalaxy {
|
|||||||
Player.PlayerChat += Player_PlayerChat;
|
Player.PlayerChat += Player_PlayerChat;
|
||||||
Player.PlayerConnect += Player_PlayerConnect;
|
Player.PlayerConnect += Player_PlayerConnect;
|
||||||
Player.PlayerDisconnect += Player_PlayerDisconnect;
|
Player.PlayerDisconnect += Player_PlayerDisconnect;
|
||||||
|
Player.DoPlayerAction += Player_PlayerAction;
|
||||||
|
|
||||||
// Regster events for incoming
|
// Regster events for incoming
|
||||||
connection.Listener.OnNick += Listener_OnNick;
|
connection.Listener.OnNick += Listener_OnNick;
|
||||||
@ -81,7 +82,9 @@ namespace MCGalaxy {
|
|||||||
File.Delete("text/ircbancmd.txt");
|
File.Delete("text/ircbancmd.txt");
|
||||||
} else {
|
} else {
|
||||||
if (!File.Exists("text/irccmdblacklist.txt"))
|
if (!File.Exists("text/irccmdblacklist.txt"))
|
||||||
File.WriteAllLines("text/irccmdblacklist.txt", new String[] { "#Here you can put commands that cannot be used from the IRC bot.", "#Lines starting with \"#\" are ignored." });
|
File.WriteAllLines("text/irccmdblacklist.txt", new [] {
|
||||||
|
"#Here you can put commands that cannot be used from the IRC bot.",
|
||||||
|
"#Lines starting with \"#\" are ignored." });
|
||||||
foreach (string line in File.ReadAllLines("text/irccmdblacklist.txt"))
|
foreach (string line in File.ReadAllLines("text/irccmdblacklist.txt"))
|
||||||
if (line[0] != '#') banCmd.Add(line);
|
if (line[0] != '#') banCmd.Add(line);
|
||||||
}
|
}
|
||||||
@ -91,7 +94,10 @@ namespace MCGalaxy {
|
|||||||
public void Say(string message, bool opchat = false, bool color = true) {
|
public void Say(string message, bool opchat = false, bool color = true) {
|
||||||
if (!Server.irc || !IsConnected()) return;
|
if (!Server.irc || !IsConnected()) return;
|
||||||
message = ConvertMessage(message, color);
|
message = ConvertMessage(message, color);
|
||||||
connection.Sender.PublicMessage(opchat ? opchannel : channel, message);
|
|
||||||
|
string chan = opchat ? opchannel : channel;
|
||||||
|
if (!String.IsNullOrEmpty(chan))
|
||||||
|
connection.Sender.PublicMessage(chan, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Pm(string user, string message, bool color = true) {
|
public void Pm(string user, string message, bool color = true) {
|
||||||
@ -159,6 +165,27 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
#region In-game event handlers
|
#region In-game event handlers
|
||||||
|
|
||||||
|
void Player_PlayerAction(Player p, PlayerAction action,
|
||||||
|
string message, bool stealth) {
|
||||||
|
if (!Server.irc || !IsConnected()) return;
|
||||||
|
string msg = null;
|
||||||
|
if (action == PlayerAction.AFK)
|
||||||
|
msg = p.ColoredName + " %ris AFK " + message;
|
||||||
|
else if (action == PlayerAction.UnAFK)
|
||||||
|
msg = p.ColoredName + " %ris no longer AFK";
|
||||||
|
else if (action == PlayerAction.Joker)
|
||||||
|
msg = p.ColoredName + " %ris now a &aJ&bo&ck&5e&9r%S";
|
||||||
|
else if (action == PlayerAction.Unjoker)
|
||||||
|
msg = p.ColoredName + " %ris no longer a &aJ&bo&ck&5e&9r%S";
|
||||||
|
else if (action == PlayerAction.JoinWorld)
|
||||||
|
msg = p.ColoredName + " %rwent to &8" + message;
|
||||||
|
else if (action == PlayerAction.Me)
|
||||||
|
msg = "*" + p.DisplayName + " " + message;
|
||||||
|
|
||||||
|
if (msg != null)
|
||||||
|
Say(msg, stealth);
|
||||||
|
}
|
||||||
|
|
||||||
void Player_PlayerDisconnect(Player p, string reason) {
|
void Player_PlayerDisconnect(Player p, string reason) {
|
||||||
if (!Server.irc || !IsConnected()) return;
|
if (!Server.irc || !IsConnected()) return;
|
||||||
if (!Server.guestLeaveNotify && p.group.Permission <= LevelPermission.Guest) return;
|
if (!Server.guestLeaveNotify && p.group.Permission <= LevelPermission.Guest) return;
|
||||||
|
@ -1013,7 +1013,7 @@ try { SendBlockchange(pos1.x, pos1.y, pos1.z, Block.waterstill); } catch { }
|
|||||||
IsAfk = false;
|
IsAfk = false;
|
||||||
afkMessage = null;
|
afkMessage = null;
|
||||||
Player.GlobalMessage("-" + ColoredName + "%S- is no longer AFK");
|
Player.GlobalMessage("-" + ColoredName + "%S- is no longer AFK");
|
||||||
Server.IRC.Say(DisplayName + " is no longer AFK");
|
RaisePlayerAction(this, PlayerAction.UnAFK, null, false);
|
||||||
TabList.Update(this, true);
|
TabList.Update(this, true);
|
||||||
}
|
}
|
||||||
// Typing //Command appears in chat as /command
|
// Typing //Command appears in chat as /command
|
||||||
|
Loading…
x
Reference in New Issue
Block a user