mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Fix .x not working, if configured IRC channel name's capitalisation differs to its actual channel name capitalisation
This commit is contained in:
parent
5c0402d8b3
commit
c17e37315e
39
MCGalaxy/Commands/building/tc.cs
Normal file
39
MCGalaxy/Commands/building/tc.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using MCGalaxy.Commands;
|
||||
|
||||
namespace MCGalaxy.Commands {
|
||||
public sealed class CmdFixTP : Command {
|
||||
public override string name { get { return "FixTP"; } }
|
||||
public override string type { get { return CommandTypes.Building; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
string[] urls = message.SplitSpaces(2);
|
||||
if (urls.Length < 2) { Help(p); return; }
|
||||
int changed = 0;
|
||||
|
||||
string[] maps = LevelInfo.AllMapNames();
|
||||
Level lvl;
|
||||
foreach (string map in maps) {
|
||||
LevelConfig cfg = LevelInfo.GetConfig(map, out lvl);
|
||||
|
||||
if (cfg.Terrain.CaselessEq(urls[0])) {
|
||||
p.Message("Changed terrain.png of map " + cfg.Color + map);
|
||||
cfg.Terrain = urls[1];
|
||||
cfg.SaveFor(map);
|
||||
changed++;
|
||||
} else if (cfg.TexturePack.CaselessEq(urls[0])) {
|
||||
p.Message("Changed texture pack of map " + cfg.Color + map);
|
||||
cfg.TexturePack = urls[1];
|
||||
cfg.SaveFor(map);
|
||||
changed++;
|
||||
}
|
||||
}
|
||||
p.Message("Gone through all the maps. {0} were changed. ");
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
p.Message("%T/FixTP [source] [dest]");
|
||||
p.Message("%HReplaces any maps using [source] texture pack with [dest] texture pack");
|
||||
}
|
||||
}
|
||||
}
|
@ -397,14 +397,14 @@ namespace MCGalaxy.Network {
|
||||
|
||||
if (newNick.Trim().Length == 0) return;
|
||||
|
||||
foreach (var kvp in userMap) {
|
||||
int index = GetNickIndex(user.Nick, kvp.Value);
|
||||
foreach (var chans in userMap) {
|
||||
int index = GetNickIndex(user.Nick, chans.Value);
|
||||
if (index >= 0) {
|
||||
string prefix = GetPrefix(kvp.Value[index]);
|
||||
kvp.Value[index] = prefix + newNick;
|
||||
string prefix = GetPrefix(chans.Value[index]);
|
||||
chans.Value[index] = prefix + newNick;
|
||||
} else {
|
||||
// should never happen, but just in case.
|
||||
bot.connection.Sender.Names(kvp.Key);
|
||||
bot.connection.Sender.Names(chans.Key);
|
||||
}
|
||||
}
|
||||
|
||||
@ -436,12 +436,13 @@ namespace MCGalaxy.Network {
|
||||
}
|
||||
|
||||
List<string> GetNicks(string channel) {
|
||||
List<string> chanNicks;
|
||||
if (!userMap.TryGetValue(channel, out chanNicks)) {
|
||||
chanNicks = new List<string>();
|
||||
userMap[channel] = chanNicks;
|
||||
foreach (var chan in userMap) {
|
||||
if (chan.Key.CaselessEq(channel)) return chan.Value;
|
||||
}
|
||||
return chanNicks;
|
||||
|
||||
List<string> nicks = new List<string>();
|
||||
userMap[channel] = nicks;
|
||||
return nicks;
|
||||
}
|
||||
|
||||
void UpdateNick(string n, List<string> chanNicks) {
|
||||
@ -495,8 +496,8 @@ namespace MCGalaxy.Network {
|
||||
}
|
||||
|
||||
bool VerifyNick(string channel, string userNick, ref string error, ref bool foundAtAll) {
|
||||
List<string> chanNicks = null;
|
||||
if (!userMap.TryGetValue(channel, out chanNicks)) return false;
|
||||
List<string> chanNicks = GetNicks(channel);
|
||||
if (chanNicks.Count == 0) return false;
|
||||
|
||||
int index = GetNickIndex(userNick, chanNicks);
|
||||
if (index == -1) return false;
|
||||
@ -513,7 +514,8 @@ namespace MCGalaxy.Network {
|
||||
return true;
|
||||
} else {
|
||||
foreach (string chan in bot.opchannels) {
|
||||
if (!userMap.TryGetValue(chan, out chanNicks)) continue;
|
||||
chanNicks = GetNicks(chan);
|
||||
if (chanNicks.Count == 0) continue;
|
||||
|
||||
index = GetNickIndex(userNick, chanNicks);
|
||||
if (index != -1) return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user