mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-21 19:42:37 -04:00
Fix messages sometimes wrongly going to IRC opchannel from chat rewrite
This commit is contained in:
parent
f559e38fef
commit
5a748f9e19
@ -46,7 +46,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public static BlockID Parse(Player p, string input) {
|
||||
BlockDefinition[] defs = p == null ? BlockDefinition.GlobalDefs : p.level.CustomBlockDefs;
|
||||
BlockDefinition[] defs = Player.IsSuper(p) ? BlockDefinition.GlobalDefs : p.level.CustomBlockDefs;
|
||||
BlockID block;
|
||||
// raw ID is treated specially, before names
|
||||
if (BlockID.TryParse(input, out block)) {
|
||||
|
@ -83,7 +83,7 @@ namespace MCGalaxy {
|
||||
|
||||
public static bool FilterAll(Player pl, object arg) { return true; }
|
||||
public static bool FilterGlobal(Player pl, object arg) {
|
||||
return pl.level.SeesServerWideChat && !pl.Ignores.All && pl.Chatroom == null;
|
||||
return pl.SuperUser || (pl.level.SeesServerWideChat && !pl.Ignores.All && pl.Chatroom == null);
|
||||
}
|
||||
|
||||
public static bool FilterLevel(Player pl, object arg) {
|
||||
|
@ -131,7 +131,7 @@ namespace MCGalaxy {
|
||||
static string TokenPlaytime(Player p) { return p.TotalTime.Shorten(); }
|
||||
static string TokenFirst(Player p) { return p.FirstLogin.ToString(); }
|
||||
static string TokenVisits(Player p) { return p.TimesVisited.ToString(); }
|
||||
static string TokenKicked(Player p) { return p.TimesBeenKicked.ToString(); }
|
||||
static string TokenKicked(Player p) { return p.TimesBeenKicked.ToString(); }
|
||||
static string TokenIP(Player p) { return p.ip; }
|
||||
static string TokenModel(Player p) { return p.Model; }
|
||||
static string TokenSkin(Player p) { return p.SkinName; }
|
||||
|
@ -26,7 +26,7 @@ namespace MCGalaxy.Commands.Bots {
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Builder; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
Level lvl = p == null ? null : p.level;
|
||||
Level lvl = Player.IsSuper(p) ? null : p.level;
|
||||
string[] args = message.SplitSpaces(2);
|
||||
int ignored, offset = 0;
|
||||
|
||||
|
@ -73,7 +73,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
}
|
||||
UpdateGlobal(p);
|
||||
} else if (scope == "level" || scope == "levelzip") {
|
||||
if (!LevelInfo.ValidateAction(p, p.level, "set texture of this level")) return;
|
||||
if (!LevelInfo.ValidateAction(p, p.level, "set texture of this level")) return;
|
||||
p.level.Config.Terrain = "";
|
||||
p.level.Config.TexturePack = "";
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
target = GetFreeBlock(global, p == null ? null : p.level);
|
||||
target = GetFreeBlock(global, Player.IsSuper(p) ? null : p.level);
|
||||
if (target == Block.Invalid) {
|
||||
Player.Message(p, "There are no custom block ids left, " +
|
||||
"you must " + cmd +" remove a custom block first.");
|
||||
@ -251,7 +251,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
if (!ExistsInScope(def, block, global)) { MessageNoBlock(p, block, global, cmd); return; }
|
||||
|
||||
RemoveBlockProps(global, block, p);
|
||||
BlockDefinition.Remove(def, defs, p == null ? null : p.level);
|
||||
BlockDefinition.Remove(def, defs, Player.IsSuper(p) ? null : p.level);
|
||||
|
||||
string scope = global ? "global" : "level";
|
||||
Player.Message(p, "Removed " + scope + " custom block " + def.Name + "(" + def.BlockID + ")");
|
||||
@ -382,7 +382,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
string value = parts[3], blockName = def.Name;
|
||||
float fTemp;
|
||||
bool temp = false, changedFallback = false;
|
||||
Level level = p == null ? null : p.level;
|
||||
Level level = Player.IsSuper(p) ? null : p.level;
|
||||
|
||||
string arg = MapPropertyName(parts[2].ToLower());
|
||||
switch (arg) {
|
||||
@ -515,7 +515,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
|
||||
// in case the list is modified before we finish the command.
|
||||
if (old != null) {
|
||||
block = GetFreeBlock(global, p == null ? null : p.level);
|
||||
block = GetFreeBlock(global, Player.IsSuper(p) ? null : p.level);
|
||||
if (block == Block.Invalid) {
|
||||
Player.Message(p, "There are no custom block ids left, " +
|
||||
"you must " + cmd + " remove a custom block first.");
|
||||
@ -531,7 +531,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
Player.Message(p, "Created a new " + scope + " custom block " + def.Name + "(" + def.BlockID + ")");
|
||||
|
||||
block = def.GetBlock();
|
||||
BlockDefinition.Add(def, defs, p == null ? null : p.level);
|
||||
BlockDefinition.Add(def, defs, Player.IsSuper(p) ? null : p.level);
|
||||
UpdateBlockProps(global, p, block, props);
|
||||
return true;
|
||||
}
|
||||
|
@ -23,11 +23,11 @@ using MCGalaxy.Tasks;
|
||||
using BlockID = System.UInt16;
|
||||
|
||||
namespace MCGalaxy.Commands.Fun {
|
||||
public abstract class WeaponCmd : Command {
|
||||
|
||||
public abstract class WeaponCmd : Command {
|
||||
public override string type { get { return CommandTypes.Other; } }
|
||||
public override bool museumUsable { get { return false; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
protected abstract string Weapon { get; }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy.Commands.Maintenance {
|
||||
string[] args = message.SplitSpaces();
|
||||
if (args.Length == 1 && Player.IsSuper(p)) { SuperRequiresArgs(p, "map name"); return; }
|
||||
|
||||
Level lvl = p == null ? null : p.level;
|
||||
Level lvl = Player.IsSuper(p) ? null : p.level;
|
||||
if (args.Length > 1) {
|
||||
lvl = Matcher.FindLevels(p, args[1]);
|
||||
if (lvl == null) return;
|
||||
|
@ -28,7 +28,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message.Length == 0) {
|
||||
if (Player.IsSuper(p)) { SuperRequiresArgs(p, "name"); return; }
|
||||
if (Player.IsSuper(p)) { SuperRequiresArgs(p, "player name"); return; }
|
||||
message = p.name;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public override string name { get { return "Zone"; } }
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override bool museumUsable { get { return false; } }
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||
public override CommandAlias[] Aliases {
|
||||
get { return new[] { new CommandAlias("ZRemove", "del"), new CommandAlias("ZDelete", "del"),
|
||||
@ -181,6 +182,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public override string name { get { return "ZoneTest"; } }
|
||||
public override string shortcut { get { return "ZTest"; } }
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
Player.Message(p, "Place or delete a block where you would like to check for zones.");
|
||||
@ -216,6 +218,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public override string name { get { return "ZoneList"; } }
|
||||
public override string shortcut { get { return "Zones"; } }
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
public override bool UseableWhenFrozen { get { return true; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
@ -239,6 +242,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public override string shortcut { get { return "ZMark"; } }
|
||||
public override string type { get { return CommandTypes.Building; } }
|
||||
public override bool museumUsable { get { return false; } }
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
public override CommandAlias[] Aliases {
|
||||
get { return new[] { new CommandAlias("zm") }; }
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ namespace MCGalaxy.Commands.World {
|
||||
string optName = null, value = null;
|
||||
|
||||
if (IsMapOption(args)) {
|
||||
if (Player.IsSuper(p)) { SuperRequiresArgs(p, "level"); return; }
|
||||
if (Player.IsSuper(p)) { SuperRequiresArgs(p, "level name"); return; }
|
||||
lvl = p.level;
|
||||
|
||||
optName = args[0];
|
||||
|
@ -26,7 +26,8 @@ namespace MCGalaxy.Commands.World {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
int seconds = 30;
|
||||
Level lvl = p != null ? p.level : Server.mainLevel;
|
||||
Level lvl = Player.IsSuper(p) ? Server.mainLevel : p.level;
|
||||
|
||||
if (message.Length > 0) {
|
||||
string[] parts = message.SplitSpaces();
|
||||
if (parts.Length == 1) {
|
||||
|
@ -30,17 +30,18 @@ namespace MCGalaxy.Commands.World {
|
||||
if (message.CaselessEq("kill")) { KillPhysics(p); return; }
|
||||
|
||||
string[] args = message.SplitSpaces();
|
||||
Level level = p != null ? p.level : Server.mainLevel;
|
||||
int state = 0, stateIndex = args.Length == 1 ? 0 : 1;
|
||||
if (!CommandParser.GetInt(p, args[stateIndex], "Physics state", ref state, 0, 5)) return;
|
||||
Level lvl = Player.IsSuper(p) ? Server.mainLevel : p.level;
|
||||
|
||||
int state = 0, stateI = args.Length == 1 ? 0 : 1;
|
||||
if (!CommandParser.GetInt(p, args[stateI], "Physics state", ref state, 0, 5)) return;
|
||||
|
||||
if (args.Length == 2) {
|
||||
level = Matcher.FindLevels(p, args[0]);
|
||||
if (level == null) return;
|
||||
lvl = Matcher.FindLevels(p, args[0]);
|
||||
if (lvl == null) return;
|
||||
}
|
||||
|
||||
if (!LevelInfo.ValidateAction(p, level, "set physics of this level")) return;
|
||||
SetPhysics(level, state);
|
||||
if (!LevelInfo.ValidateAction(p, lvl, "set physics of this level")) return;
|
||||
SetPhysics(lvl, state);
|
||||
}
|
||||
|
||||
internal static string[] states = new string[] { "&cOFF", "&aNormal", "&aAdvanced",
|
||||
|
@ -36,12 +36,10 @@ namespace MCGalaxy.Commands.World {
|
||||
lvl = Matcher.FindLevels(p, args[1]);
|
||||
if (lvl == null) return;
|
||||
} else {
|
||||
if (p != null && p.level != null) {
|
||||
lvl = p.level;
|
||||
} else {
|
||||
Player.Message(p, "You must provide a level name when using /restore from console.");
|
||||
return;
|
||||
if (Player.IsSuper(p)) {
|
||||
SuperRequiresArgs(p, "level name"); return;
|
||||
}
|
||||
lvl = p.level;
|
||||
}
|
||||
|
||||
if (!LevelInfo.ValidateAction(p, lvl, "restore a backup of this level")) return;
|
||||
@ -98,9 +96,9 @@ namespace MCGalaxy.Commands.World {
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/Restore %H- lists all backups for the current map");
|
||||
Player.Message(p, "%T/Restore [number] [name]");
|
||||
Player.Message(p, "%T/Restore [number] <map>");
|
||||
Player.Message(p, "%HRestores a previous backup for the given map.");
|
||||
Player.Message(p, "%H If [name] is not given, your current map is used.");
|
||||
Player.Message(p, "%H If <map> is not given, your current map is used.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override string type { get { return CommandTypes.Building; } }
|
||||
public override bool museumUsable { get { return false; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
ushort dist = 20;
|
||||
|
@ -27,6 +27,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override string shortcut { get { return "ra"; } }
|
||||
public override string type { get { return CommandTypes.Building; } }
|
||||
public override bool museumUsable { get { return false; } }
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
|
@ -109,7 +109,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
internal static TimeSpan GetDelta(Player p, string name, string[] parts, int offset) {
|
||||
TimeSpan delta = TimeSpan.Zero;
|
||||
string timespan = parts.Length > offset ? parts[parts.Length - 1] : "30m";
|
||||
bool canAll = p == null || p.name.CaselessEq(name) || p.group.MaxUndo == undoMax;
|
||||
bool canAll = p == null || p.name.CaselessEq(name) || p.group.MaxUndo == undoMax;
|
||||
|
||||
if (timespan.CaselessEq("all")) {
|
||||
return TimeSpan.FromSeconds(canAll ? int.MaxValue : p.group.MaxUndo);
|
||||
|
@ -19,6 +19,7 @@ namespace MCGalaxy.Commands.Misc {
|
||||
public sealed class CmdBack : Command {
|
||||
public override string name { get { return "Back"; } }
|
||||
public override string type { get { return CommandTypes.Other; } }
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (p.PreTeleportMap == null) {
|
||||
|
@ -22,6 +22,7 @@ namespace MCGalaxy.Commands.Misc {
|
||||
public sealed class CmdTpA : Command {
|
||||
public override string name { get { return "TPA"; } }
|
||||
public override string type { get { return CommandTypes.Other; } }
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
public override CommandAlias[] Aliases {
|
||||
get { return new[] { new CommandAlias("TPAccept", "accept"), new CommandAlias("TPDeny", "deny") }; }
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ namespace MCGalaxy.Games {
|
||||
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
foreach (Player p in online) {
|
||||
if (p.level == null || p.level != Map || p.Game.Referee) continue;
|
||||
if (p.level != Map || p.Game.Referee) continue;
|
||||
Alive.Add(p);
|
||||
}
|
||||
Infected.Clear();
|
||||
|
@ -32,9 +32,10 @@ namespace MCGalaxy.Network {
|
||||
|
||||
readonly IRCBot bot;
|
||||
readonly Player ircGuest = new Player("IRC");
|
||||
readonly Player ircOp = new Player("IRC");
|
||||
|
||||
public IRCHandlers(IRCBot bot) {
|
||||
this.bot = bot;
|
||||
public IRCHandlers(IRCBot bot) {
|
||||
this.bot = bot;
|
||||
ircGuest.group = Group.GuestRank;
|
||||
}
|
||||
|
||||
@ -131,8 +132,12 @@ namespace MCGalaxy.Network {
|
||||
if (scopeFilter(ircGuest, arg) && (filter == null || filter(ircGuest, arg))) {
|
||||
bot.Say(msg, false);
|
||||
} else {
|
||||
// TODO: Check filters!!!!!
|
||||
bot.Say(msg, true);
|
||||
ircOp.group = Group.Find(ServerConfig.IRCControllerRank);
|
||||
if (ircOp.group == null) ircOp.group = Group.NobodyRank;
|
||||
|
||||
if (scopeFilter(ircOp, arg) && (filter == null || filter(ircOp, arg))) {
|
||||
bot.Say(msg, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,6 +296,7 @@ namespace MCGalaxy.Network {
|
||||
cmd.Use(p, cmdArgs);
|
||||
} catch (Exception ex) {
|
||||
Player.Message(p, "CMD Error: " + ex);
|
||||
Logger.LogError(ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ namespace MCGalaxy {
|
||||
public DateTime lastCmdTime;
|
||||
public sbyte c4circuitNumber = -1;
|
||||
|
||||
public Level level = Server.mainLevel;
|
||||
public Level level;
|
||||
public bool Loading = true; //True if player is loading a map.
|
||||
internal int UsingGoto = 0, GeneratingMap = 0, LoadingMuseum = 0, UsingDelay = 0;
|
||||
public Vec3U16 lastClick = Vec3U16.Zero;
|
||||
|
@ -44,6 +44,7 @@ namespace MCGalaxy {
|
||||
if (cancelconnecting) { cancelconnecting = false; return; }
|
||||
|
||||
hasCpe = buffer[offset + 130] == 0x42 && ServerConfig.EnableCPE;
|
||||
level = Server.mainLevel;
|
||||
Loading = true;
|
||||
if (disconnected) return;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user