mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 23:02:04 -04:00
DB: now block changes by IRC properly log to BlockDB, including the irc user's nick.
This commit is contained in:
parent
8f89e79afe
commit
9e419f71fb
@ -30,7 +30,7 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
bool addToList = p.parseEmotes != Server.parseSmiley;
|
bool addToList = p.parseEmotes != Server.parseSmiley;
|
||||||
if (!addToList) Server.noEmotes.Remove(p.name);
|
if (!addToList) Server.noEmotes.Remove(p.name);
|
||||||
else Server.noEmotes.AddOrReplace(p.name);
|
else Server.noEmotes.AddIfNotExists(p.name);
|
||||||
Server.noEmotes.Save();
|
Server.noEmotes.Save();
|
||||||
Player.Message(p, "Emote parsing is {0}.", p.parseEmotes ? "enabled" : "disabled");
|
Player.Message(p, "Emote parsing is {0}.", p.parseEmotes ? "enabled" : "disabled");
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ namespace MCGalaxy.Commands
|
|||||||
Player.SendChatFrom(who, who.ColoredName + " %Swas &bfrozen %Sby " + frozenby + "%S.", false);
|
Player.SendChatFrom(who, who.ColoredName + " %Swas &bfrozen %Sby " + frozenby + "%S.", false);
|
||||||
Server.s.Log(who.name + " was frozen by " + frozenby);
|
Server.s.Log(who.name + " was frozen by " + frozenby);
|
||||||
Player.AddNote(who.name, p, "F");
|
Player.AddNote(who.name, p, "F");
|
||||||
Server.frozen.AddOrReplace(who.name);
|
Server.frozen.AddIfNotExists(who.name);
|
||||||
} else {
|
} else {
|
||||||
Player.SendChatFrom(who, who.ColoredName + " %Swas &adefrosted %Sby " + frozenby + "%S.", false);
|
Player.SendChatFrom(who, who.ColoredName + " %Swas &adefrosted %Sby " + frozenby + "%S.", false);
|
||||||
Server.s.Log(who.name + " was defrosted by " + frozenby);
|
Server.s.Log(who.name + " was defrosted by " + frozenby);
|
||||||
|
@ -66,7 +66,7 @@ namespace MCGalaxy.Commands {
|
|||||||
Player.SendChatFrom(p, "&c- " + p.FullName + " %S" + discMsg, false);
|
Player.SendChatFrom(p, "&c- " + p.FullName + " %S" + discMsg, false);
|
||||||
Server.IRC.Say(p.DisplayName + " %Sleft the game (" + discMsg + "%S)");
|
Server.IRC.Say(p.DisplayName + " %Sleft the game (" + discMsg + "%S)");
|
||||||
if (messageOps && !p.opchat) opchat.Use(p, message);
|
if (messageOps && !p.opchat) opchat.Use(p, message);
|
||||||
Server.hidden.AddOrReplace(p.name);
|
Server.hidden.AddIfNotExists(p.name);
|
||||||
} else {
|
} else {
|
||||||
Entities.GlobalSpawn(p, false);
|
Entities.GlobalSpawn(p, false);
|
||||||
p.otherRankHidden = false;
|
p.otherRankHidden = false;
|
||||||
|
@ -50,7 +50,7 @@ namespace MCGalaxy.Commands.Moderation {
|
|||||||
}
|
}
|
||||||
who.muted = true;
|
who.muted = true;
|
||||||
Player.SendChatFrom(who, who.ColoredName + " %Swas &8muted", false);
|
Player.SendChatFrom(who, who.ColoredName + " %Swas &8muted", false);
|
||||||
Server.muted.AddOrReplace(who.name);
|
Server.muted.AddIfNotExists(who.name);
|
||||||
Player.AddNote(who.name, p, "M");
|
Player.AddNote(who.name, p, "M");
|
||||||
}
|
}
|
||||||
Server.muted.Save();
|
Server.muted.Save();
|
||||||
|
@ -48,7 +48,7 @@ namespace MCGalaxy.Commands {
|
|||||||
Server.lockdown.Remove(args[1]);
|
Server.lockdown.Remove(args[1]);
|
||||||
Chat.MessageOps("Unlocked by: " + srcName);
|
Chat.MessageOps("Unlocked by: " + srcName);
|
||||||
} else {
|
} else {
|
||||||
Server.lockdown.AddOrReplace(args[1]);
|
Server.lockdown.AddIfNotExists(args[1]);
|
||||||
Chat.MessageOps("Locked by: " + srcName);
|
Chat.MessageOps("Locked by: " + srcName);
|
||||||
}
|
}
|
||||||
Server.lockdown.Save();
|
Server.lockdown.Save();
|
||||||
|
@ -51,5 +51,13 @@ namespace MCGalaxy.DB {
|
|||||||
}
|
}
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int InvalidNameID(string name) {
|
||||||
|
bool added = Server.invalidIds.AddIfNotExists(name);
|
||||||
|
if (added) Server.invalidIds.Save();
|
||||||
|
|
||||||
|
int index = Server.invalidIds.All().IndexOf(name.ToLower());
|
||||||
|
return int.MaxValue - index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,12 +14,13 @@
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using MCGalaxy.Commands;
|
using MCGalaxy.Commands;
|
||||||
|
using MCGalaxy.DB;
|
||||||
using Sharkbite.Irc;
|
using Sharkbite.Irc;
|
||||||
|
|
||||||
namespace MCGalaxy {
|
namespace MCGalaxy {
|
||||||
@ -83,8 +84,8 @@ namespace MCGalaxy {
|
|||||||
UpdateState();
|
UpdateState();
|
||||||
connection.connectionArgs = args;
|
connection.connectionArgs = args;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
connection.Connect();
|
connection.Connect();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Server.s.Log("Failed to connect to IRC!");
|
Server.s.Log("Failed to connect to IRC!");
|
||||||
Server.ErrorLog(e);
|
Server.ErrorLog(e);
|
||||||
@ -95,7 +96,7 @@ namespace MCGalaxy {
|
|||||||
if (!IsConnected()) return;
|
if (!IsConnected()) return;
|
||||||
if (hookedEvents) UnhookEvents();
|
if (hookedEvents) UnhookEvents();
|
||||||
|
|
||||||
connection.Disconnect(reason);
|
connection.Disconnect(reason);
|
||||||
Server.s.Log("Disconnected from IRC!");
|
Server.s.Log("Disconnected from IRC!");
|
||||||
users.Clear();
|
users.Clear();
|
||||||
}
|
}
|
||||||
@ -151,8 +152,8 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
#region In-game event handlers
|
#region In-game event handlers
|
||||||
|
|
||||||
void Player_PlayerAction(Player p, PlayerAction action,
|
void Player_PlayerAction(Player p, PlayerAction action,
|
||||||
string message, bool stealth) {
|
string message, bool stealth) {
|
||||||
if (!Server.irc ||!IsConnected()) return;
|
if (!Server.irc ||!IsConnected()) return;
|
||||||
string msg = null;
|
string msg = null;
|
||||||
|
|
||||||
@ -192,7 +193,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
string name = Server.ircPlayerTitles ? p.FullName : p.group.prefix + p.ColoredName;
|
string name = Server.ircPlayerTitles ? p.FullName : p.group.prefix + p.ColoredName;
|
||||||
Say(name + "%S: " + message, p.opchat);
|
Say(name + "%S: " + message, p.opchat);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@ -249,7 +250,7 @@ namespace MCGalaxy {
|
|||||||
if (!CheckIRCCommand(user, cmdName, chan, out error)) {
|
if (!CheckIRCCommand(user, cmdName, chan, out error)) {
|
||||||
if (error != null) Pm(user.Nick, error);
|
if (error != null) Pm(user.Nick, error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HandleIRCCommand(user.Nick, user.Nick, cmdName, cmdArgs);
|
HandleIRCCommand(user.Nick, user.Nick, cmdName, cmdArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,15 +271,15 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
if (channel.CaselessEq(opchannel)) {
|
if (channel.CaselessEq(opchannel)) {
|
||||||
Server.s.Log(String.Format("(OPs): [IRC] {0}: {1}", user.Nick, message));
|
Server.s.Log(String.Format("(OPs): [IRC] {0}: {1}", user.Nick, message));
|
||||||
Chat.MessageOps(String.Format("To Ops &f-%I[IRC] {0}&f- {1}", user.Nick,
|
Chat.MessageOps(String.Format("To Ops &f-%I[IRC] {0}&f- {1}", user.Nick,
|
||||||
Server.profanityFilter ? ProfanityFilter.Parse(message) : message));
|
Server.profanityFilter ? ProfanityFilter.Parse(message) : message));
|
||||||
} else {
|
} else {
|
||||||
Server.s.Log(String.Format("[IRC] {0}: {1}", user.Nick, message));
|
Server.s.Log(String.Format("[IRC] {0}: {1}", user.Nick, message));
|
||||||
Player.GlobalIRCMessage(String.Format("%I[IRC] {0}: &f{1}", user.Nick,
|
Player.GlobalIRCMessage(String.Format("%I[IRC] {0}: &f{1}", user.Nick,
|
||||||
Server.profanityFilter ? ProfanityFilter.Parse(message) : message));
|
Server.profanityFilter ? ProfanityFilter.Parse(message) : message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandlePublicCommand(UserInfo user, string channel, string message,
|
bool HandlePublicCommand(UserInfo user, string channel, string message,
|
||||||
string[] parts, bool opchat) {
|
string[] parts, bool opchat) {
|
||||||
string cmdName = parts.Length > 1 ? parts[1].ToLower() : "";
|
string cmdName = parts.Length > 1 ? parts[1].ToLower() : "";
|
||||||
@ -301,7 +302,7 @@ namespace MCGalaxy {
|
|||||||
if (!whoCmd || (DateTime.UtcNow - last).TotalSeconds <= 1) return false;
|
if (!whoCmd || (DateTime.UtcNow - last).TotalSeconds <= 1) return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Player p = MakeIRCPlayer(nick);
|
Player p = MakeIRCPlayer(nick, null);
|
||||||
CmdPlayers.DisplayPlayers(p, "", false, false);
|
CmdPlayers.DisplayPlayers(p, "", false, false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Server.ErrorLog(e);
|
Server.ErrorLog(e);
|
||||||
@ -312,13 +313,13 @@ namespace MCGalaxy {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleIRCCommand(string nick, string logNick, string cmdName, string cmdArgs) {
|
bool HandleIRCCommand(string nick, string userNick, string cmdName, string cmdArgs) {
|
||||||
Command cmd = Command.all.Find(cmdName);
|
Command cmd = Command.all.Find(cmdName);
|
||||||
Player p = MakeIRCPlayer(nick);
|
Player p = MakeIRCPlayer(nick, userNick);
|
||||||
if (cmd == null) { Player.Message(p, "Unknown command!"); return false; }
|
if (cmd == null) { Player.Message(p, "Unknown command!"); return false; }
|
||||||
|
|
||||||
string logCmd = cmdArgs == "" ? cmdName : cmdName + " " + cmdArgs;
|
string logCmd = cmdArgs == "" ? cmdName : cmdName + " " + cmdArgs;
|
||||||
Server.s.Log("IRC Command: /" + logCmd + " (by " + logNick + ")");
|
Server.s.Log("IRC Command: /" + logCmd + " (by " + userNick + ")");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!p.group.CanExecute(cmd)) { cmd.MessageCannotUse(p); return false; }
|
if (!p.group.CanExecute(cmd)) { cmd.MessageCannotUse(p); return false; }
|
||||||
@ -349,13 +350,17 @@ namespace MCGalaxy {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Player MakeIRCPlayer(string ircNick) {
|
static Player MakeIRCPlayer(string ircNick, string userNick) {
|
||||||
Player p = new Player("IRC");
|
Player p = new Player("IRC");
|
||||||
p.group = Group.findPerm(Server.ircControllerRank);
|
p.group = Group.findPerm(Server.ircControllerRank);
|
||||||
if (p.group == null)
|
if (p.group == null)
|
||||||
p.group = Group.findPerm(LevelPermission.Nobody);
|
p.group = Group.findPerm(LevelPermission.Nobody);
|
||||||
|
|
||||||
p.ircNick = ircNick;
|
p.ircNick = ircNick;
|
||||||
p.color = "&a"; return p;
|
p.color = "&a";
|
||||||
|
if (userNick != null)
|
||||||
|
p.UserID = NameConverter.InvalidNameID("(IRC " + userNick + ")");
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Listener_OnRegistered() {
|
void Listener_OnRegistered() {
|
||||||
@ -428,7 +433,7 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Listener_OnNames(string channel, string[] nicks, bool last) {
|
void Listener_OnNames(string channel, string[] nicks, bool last) {
|
||||||
List<string> chanNicks = GetNicks(channel);
|
List<string> chanNicks = GetNicks(channel);
|
||||||
foreach (string n in nicks)
|
foreach (string n in nicks)
|
||||||
UpdateNick(n, chanNicks);
|
UpdateNick(n, chanNicks);
|
||||||
@ -442,7 +447,7 @@ namespace MCGalaxy {
|
|||||||
List<string> chanNicks = GetNicks(channel);
|
List<string> chanNicks = GetNicks(channel);
|
||||||
RemoveNick(user.Nick, chanNicks);
|
RemoveNick(user.Nick, chanNicks);
|
||||||
Server.s.Log(user.Nick + " kicked " + kickee + " from IRC");
|
Server.s.Log(user.Nick + " kicked " + kickee + " from IRC");
|
||||||
Player.GlobalIRCMessage("%I[IRC] " + user.Nick + " kicked " + kickee);
|
Player.GlobalIRCMessage("%I[IRC] " + user.Nick + " kicked " + kickee);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Listener_OnKill(UserInfo user, string nick, string reason) {
|
void Listener_OnKill(UserInfo user, string nick, string reason) {
|
||||||
@ -507,9 +512,9 @@ namespace MCGalaxy {
|
|||||||
int GetPrefixLength(string nick) {
|
int GetPrefixLength(string nick) {
|
||||||
int prefixChars = 0;
|
int prefixChars = 0;
|
||||||
for (int i = 0; i < nick.Length; i++) {
|
for (int i = 0; i < nick.Length; i++) {
|
||||||
if (!IsNickChar(nick[i]))
|
if (!IsNickChar(nick[i]))
|
||||||
prefixChars++;
|
prefixChars++;
|
||||||
else
|
else
|
||||||
return prefixChars;
|
return prefixChars;
|
||||||
}
|
}
|
||||||
return prefixChars;
|
return prefixChars;
|
||||||
@ -575,7 +580,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
void UnhookEvents() {
|
void UnhookEvents() {
|
||||||
hookedEvents = false;
|
hookedEvents = false;
|
||||||
// Register events for outgoing
|
// Register events for outgoing
|
||||||
Player.PlayerChat -= Player_PlayerChat;
|
Player.PlayerChat -= Player_PlayerChat;
|
||||||
Player.PlayerConnect -= Player_PlayerConnect;
|
Player.PlayerConnect -= Player_PlayerConnect;
|
||||||
Player.PlayerDisconnect -= Player_PlayerDisconnect;
|
Player.PlayerDisconnect -= Player_PlayerDisconnect;
|
||||||
|
@ -51,16 +51,17 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public int Count { get { lock (locker) return players.Count; } }
|
public int Count { get { lock (locker) return players.Count; } }
|
||||||
|
|
||||||
/// <summary> Adds or replaces the given name,
|
/// <summary> Adds or replaces the given name. </summary>
|
||||||
/// returning the index of the item within the list. </summary>
|
/// <returns> Whether the given player name was added to the list. </returns>
|
||||||
public void AddOrReplace(string p) {
|
public bool AddIfNotExists(string p) {
|
||||||
p = p.ToLower();
|
p = p.ToLower();
|
||||||
lock (locker) {
|
lock (locker) {
|
||||||
int idx = players.IndexOf(p);
|
int idx = players.IndexOf(p);
|
||||||
if (idx >= 0) return;
|
if (idx >= 0) return false;
|
||||||
|
|
||||||
players.Add(p);
|
players.Add(p);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string FindMatches(Player p, string name, string type, out int matches) {
|
public string FindMatches(Player p, string name, string type, out int matches) {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using MCGalaxy.DB;
|
||||||
using MCGalaxy.SQL;
|
using MCGalaxy.SQL;
|
||||||
|
|
||||||
namespace MCGalaxy {
|
namespace MCGalaxy {
|
||||||
@ -52,9 +53,7 @@ namespace MCGalaxy {
|
|||||||
string id = ids.Rows[0]["ID"].ToString();
|
string id = ids.Rows[0]["ID"].ToString();
|
||||||
p.UserID = PlayerData.ParseInt(id);
|
p.UserID = PlayerData.ParseInt(id);
|
||||||
} else {
|
} else {
|
||||||
Server.invalidIds.AddOrReplace(p.name);
|
p.UserID = NameConverter.InvalidNameID(p.name);
|
||||||
int index = Server.invalidIds.All().IndexOf(p.name.ToLower());
|
|
||||||
p.UserID = int.MaxValue - index;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ namespace MCGalaxy.Tasks {
|
|||||||
for (int i = 0; i < files.Length; i++) {
|
for (int i = 0; i < files.Length; i++) {
|
||||||
File.Delete(files[i]);
|
File.Delete(files[i]);
|
||||||
string level = Path.GetFileName(files[i]);
|
string level = Path.GetFileName(files[i]);
|
||||||
Server.lockdown.AddOrReplace(level);
|
Server.lockdown.AddIfNotExists(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
Server.lockdown.Save();
|
Server.lockdown.Save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user