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;
|
||||
if (!addToList) Server.noEmotes.Remove(p.name);
|
||||
else Server.noEmotes.AddOrReplace(p.name);
|
||||
else Server.noEmotes.AddIfNotExists(p.name);
|
||||
Server.noEmotes.Save();
|
||||
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);
|
||||
Server.s.Log(who.name + " was frozen by " + frozenby);
|
||||
Player.AddNote(who.name, p, "F");
|
||||
Server.frozen.AddOrReplace(who.name);
|
||||
Server.frozen.AddIfNotExists(who.name);
|
||||
} else {
|
||||
Player.SendChatFrom(who, who.ColoredName + " %Swas &adefrosted %Sby " + frozenby + "%S.", false);
|
||||
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);
|
||||
Server.IRC.Say(p.DisplayName + " %Sleft the game (" + discMsg + "%S)");
|
||||
if (messageOps && !p.opchat) opchat.Use(p, message);
|
||||
Server.hidden.AddOrReplace(p.name);
|
||||
Server.hidden.AddIfNotExists(p.name);
|
||||
} else {
|
||||
Entities.GlobalSpawn(p, false);
|
||||
p.otherRankHidden = false;
|
||||
|
@ -50,7 +50,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
}
|
||||
who.muted = true;
|
||||
Player.SendChatFrom(who, who.ColoredName + " %Swas &8muted", false);
|
||||
Server.muted.AddOrReplace(who.name);
|
||||
Server.muted.AddIfNotExists(who.name);
|
||||
Player.AddNote(who.name, p, "M");
|
||||
}
|
||||
Server.muted.Save();
|
||||
|
@ -48,7 +48,7 @@ namespace MCGalaxy.Commands {
|
||||
Server.lockdown.Remove(args[1]);
|
||||
Chat.MessageOps("Unlocked by: " + srcName);
|
||||
} else {
|
||||
Server.lockdown.AddOrReplace(args[1]);
|
||||
Server.lockdown.AddIfNotExists(args[1]);
|
||||
Chat.MessageOps("Locked by: " + srcName);
|
||||
}
|
||||
Server.lockdown.Save();
|
||||
|
@ -51,5 +51,13 @@ namespace MCGalaxy.DB {
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using MCGalaxy.Commands;
|
||||
using MCGalaxy.DB;
|
||||
using Sharkbite.Irc;
|
||||
|
||||
namespace MCGalaxy {
|
||||
@ -301,7 +302,7 @@ namespace MCGalaxy {
|
||||
if (!whoCmd || (DateTime.UtcNow - last).TotalSeconds <= 1) return false;
|
||||
|
||||
try {
|
||||
Player p = MakeIRCPlayer(nick);
|
||||
Player p = MakeIRCPlayer(nick, null);
|
||||
CmdPlayers.DisplayPlayers(p, "", false, false);
|
||||
} catch (Exception e) {
|
||||
Server.ErrorLog(e);
|
||||
@ -312,13 +313,13 @@ namespace MCGalaxy {
|
||||
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);
|
||||
Player p = MakeIRCPlayer(nick);
|
||||
Player p = MakeIRCPlayer(nick, userNick);
|
||||
if (cmd == null) { Player.Message(p, "Unknown command!"); return false; }
|
||||
|
||||
string logCmd = cmdArgs == "" ? cmdName : cmdName + " " + cmdArgs;
|
||||
Server.s.Log("IRC Command: /" + logCmd + " (by " + logNick + ")");
|
||||
Server.s.Log("IRC Command: /" + logCmd + " (by " + userNick + ")");
|
||||
|
||||
try {
|
||||
if (!p.group.CanExecute(cmd)) { cmd.MessageCannotUse(p); return false; }
|
||||
@ -349,13 +350,17 @@ namespace MCGalaxy {
|
||||
return true;
|
||||
}
|
||||
|
||||
static Player MakeIRCPlayer(string ircNick) {
|
||||
static Player MakeIRCPlayer(string ircNick, string userNick) {
|
||||
Player p = new Player("IRC");
|
||||
p.group = Group.findPerm(Server.ircControllerRank);
|
||||
if (p.group == null)
|
||||
p.group = Group.findPerm(LevelPermission.Nobody);
|
||||
|
||||
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() {
|
||||
|
@ -51,16 +51,17 @@ namespace MCGalaxy {
|
||||
|
||||
public int Count { get { lock (locker) return players.Count; } }
|
||||
|
||||
/// <summary> Adds or replaces the given name,
|
||||
/// returning the index of the item within the list. </summary>
|
||||
public void AddOrReplace(string p) {
|
||||
/// <summary> Adds or replaces the given name. </summary>
|
||||
/// <returns> Whether the given player name was added to the list. </returns>
|
||||
public bool AddIfNotExists(string p) {
|
||||
p = p.ToLower();
|
||||
lock (locker) {
|
||||
int idx = players.IndexOf(p);
|
||||
if (idx >= 0) return;
|
||||
if (idx >= 0) return false;
|
||||
|
||||
players.Add(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public string FindMatches(Player p, string name, string type, out int matches) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
using System.Data;
|
||||
using MCGalaxy.DB;
|
||||
using MCGalaxy.SQL;
|
||||
|
||||
namespace MCGalaxy {
|
||||
@ -52,9 +53,7 @@ namespace MCGalaxy {
|
||||
string id = ids.Rows[0]["ID"].ToString();
|
||||
p.UserID = PlayerData.ParseInt(id);
|
||||
} else {
|
||||
Server.invalidIds.AddOrReplace(p.name);
|
||||
int index = Server.invalidIds.All().IndexOf(p.name.ToLower());
|
||||
p.UserID = int.MaxValue - index;
|
||||
p.UserID = NameConverter.InvalidNameID(p.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ namespace MCGalaxy.Tasks {
|
||||
for (int i = 0; i < files.Length; i++) {
|
||||
File.Delete(files[i]);
|
||||
string level = Path.GetFileName(files[i]);
|
||||
Server.lockdown.AddOrReplace(level);
|
||||
Server.lockdown.AddIfNotExists(level);
|
||||
}
|
||||
|
||||
Server.lockdown.Save();
|
||||
|
Loading…
x
Reference in New Issue
Block a user