private void BeforeSaveEvent(object sender, EventArgs e) { Spawner.ClearMobs(); }
private static void DebugCommands(string msg, string sender) { if (msg.ToLower().Contains("$bits")) { MatchCollection matches = Regex.Matches(msg.ToLower(), "\\$bits([0-9]+)"); if (Config.ShowDebug()) { BNC_Core.Logger.Log($"DEBUGMODE: {matches.Count} cheer found from {sender}"); } if (matches.Count > 0) { int[] list = new int[matches.Count]; int i = 0; int totalBitsCounted = 0; foreach (Match match in matches) { int bitamt = 0; try { bitamt = int.Parse(match.Groups[1].ToString()); list[i++] = bitamt; totalBitsCounted += bitamt; } catch { BNC_Core.Logger.Log($"{match.Groups[1].ToString()} is not a valid number from {sender}"); } } foreach (int bitamt in list) { TwitchMobType?type = (TwitchMobType)Spawner.GetMonsterFromBits(bitamt); if (type != null) { if (Config.ShowDebug()) { BNC_Core.Logger.Log($"DEBUGMODE: Adding Monster:{type.ToString()}:{sender} to queue with {bitamt}bits"); } Spawner.AddMonsterToSpawnFromType((TwitchMobType)type, sender); } else if (Config.ShowDebug()) { BNC_Core.Logger.Log($"DEBUGMODE: Failed to add monster to queue with {bitamt}bits from {sender}"); } } } /* * BNC_Core.Logger.Log($"split {split.Length} length"); * if (split.Length >= 2) * { * int bitamt = 0; * * try * { * bitamt = int.Parse(split[1]); * } * catch{ BNC_Core.Logger.Log($"{split[1]} is not a valid number from {sender}"); } * * if(bitamt > 0) * { * TwitchMobType? type = (TwitchMobType?)Spawner.GetMonsterFromBits(bitamt); * * if (type != null) * { * if (Config.ShowDebug()) * BNC_Core.Logger.Log($"DEBUGMODE: Adding Monster:{type.ToString()}:{sender} to queue with {bitamt}bits"); * Spawner.AddMonsterToSpawnFromType((TwitchMobType)type, sender); * } * else if (Config.ShowDebug()) * BNC_Core.Logger.Log($"DEBUGMODE: Failed to add monster to queue with {bitamt}bits from {sender}"); * } * * } */ } else if (msg.StartsWith("$sub")) { if (BNC_Core.config.Spawn_Subscriber_Junimo) { Spawner.SpawnTwitchJunimo(sender); } else { BNC_Core.Logger.Log($"DEBUGMODE: 'Spawn_Subscriber_Junimo' Config option is turned off for subscribers"); } if (Config.ShowDebug() && BNC_Core.config.Spawn_Subscriber_Junimo) { BNC_Core.Logger.Log($"DEBUGMODE: Adding Junimo:{sender} to queue from a new sub"); } } else if (msg.StartsWith("$gift")) { if (BNC_Core.config.Spawn_GiftSub_Subscriber_Mobs) { Spawner.AddMonsterToSpawnFromType(TwitchMobType.Slime, sender, true); } else { BNC_Core.Logger.Log($"DEBUGMODE: 'Spawn_GiftSub_Subscriber_Mobs' Config option is turned off for gift subs"); } if (Config.ShowDebug()) { BNC_Core.Logger.Log($"DEBUGMODE: Adding GiftSub Slime:{sender} to queue..."); } } else if (msg.StartsWith("$resub")) { if (BNC_Core.config.Spawn_Subscriber_Junimo) { Spawner.SpawnTwitchJunimo(sender); } else { BNC_Core.Logger.Log($"DEBUGMODE: 'Spawn_Subscriber_Junimo' Config option is turned off for subscribers"); } if (Config.ShowDebug() && BNC_Core.config.Spawn_Subscriber_Junimo) { BNC_Core.Logger.Log($"DEBUGMODE: Adding Junimo:{sender} to queue from a new resubs"); } } else if (msg.StartsWith("$help") && DateTime.Now > lastHelp.AddSeconds(15)) { sendMessage("Current Debug Commands: '$bits <amt>', '$gift', '$resub', and '$sub'"); lastHelp = DateTime.Now; } }
private static void OnMessageReceived(object sender, OnMessageReceivedArgs e) { if (!Context.IsWorldReady) { return; } if (Config.IsDebugMode()) { bool flag = false; if (BNC_Core.config.Moderators_Can_Only_Use_Chat_Commands && (e.ChatMessage.IsModerator || e.ChatMessage.IsBroadcaster)) { flag = true; } else if (!BNC_Core.config.Moderators_Can_Only_Use_Chat_Commands) { flag = true; } if (flag) { DebugCommands(e.ChatMessage.Message, e.ChatMessage.DisplayName); } } if (hasMinePollStarted && !usersVoted.Contains(e.ChatMessage.UserId)) { List <MineBuffManager.AugmentOption> keysvalue = new List <MineBuffManager.AugmentOption>(augvotes.Keys); foreach (MineBuffManager.AugmentOption vote in keysvalue) { if (vote.id.ToLower().Equals(e.ChatMessage.Message.Trim().ToLower())) { augvotes[vote]++; if (Config.ShowDebug()) { BNC_Core.Logger.Log($"Recieved Vote for {vote.id} : #{augvotes[vote]}"); } usersVoted.Add(e.ChatMessage.UserId); UpdateVotingText(); } } } else if (hasPollStarted && !usersVoted.Contains(e.ChatMessage.UserId)) { List <BuffManager.BuffOption> keysvalue = new List <BuffManager.BuffOption>(votes.Keys); foreach (BuffManager.BuffOption vote in keysvalue) { if (vote.id.ToLower().Equals(e.ChatMessage.Message.Trim().ToLower())) { votes[vote]++; if (Config.ShowDebug()) { BNC_Core.Logger.Log($"Recieved Vote for {vote.id} : #{votes[vote]}"); } usersVoted.Add(e.ChatMessage.UserId); UpdateVotingText(); } } } else if (BNC_Core.config.Use_Bits_To_Spawn_Mobs && e.ChatMessage.Bits > 0) { BitCount += e.ChatMessage.Bits; MatchCollection matches = Regex.Matches(e.ChatMessage.Message.ToLower(), "cheer([0-9]+)"); if (matches.Count > 0) { if (Config.ShowDebug()) { BNC_Core.Logger.Log($"Found Cheers {matches.Count} in Message. Should == {e.ChatMessage.Bits}"); } int[] list = new int[matches.Count]; int i = 0; int totalBitsCounted = 0; foreach (Match match in matches) { int bitamt = 0; try { bitamt = int.Parse(match.Groups[1].ToString()); list[i++] = bitamt; totalBitsCounted += bitamt; } catch { BNC_Core.Logger.Log($"{match.Groups[1].ToString()} is not a valid number from {sender}"); } } if (totalBitsCounted != e.ChatMessage.Bits) { BNC_Core.Logger.Log($"Could not match the Cheers to the total bit counts. Failed to parse data. {totalBitsCounted} != {e.ChatMessage.Bits}. Contact Developer if this was in error."); return; } foreach (int bitamt in list) { TwitchMobType?type = (TwitchMobType)Spawner.GetMonsterFromBits(bitamt); if (type != null) { if (Config.ShowDebug()) { BNC_Core.Logger.Log($"Adding monster to queue {type.ToString()} with {bitamt}bits"); } Spawner.AddMonsterToSpawnFromType((TwitchMobType)type, e.ChatMessage.DisplayName); } else if (Config.ShowDebug()) { BNC_Core.Logger.Log($"Failed to add monster to queue with {bitamt}bits from {e.ChatMessage.DisplayName}"); } } } } }
public static void SpawnTwitchJunimo(string name) { Junimo j = new TwitchJunimo(Vector2.Zero); Spawner.addSubToSpawn(j, name); }