public static void Main(string[] args) { Gimme.Register(new AsyncResourceProvider()); Gimme.Register(new SyncResourceProvider()); Gimme.Register(new ObservableResourceProvider()); int done = 0; //var ob = Gimme.Fetch<Thing>("Resource", new List<string> { "Resource 1", "Resource 2", "Resource 3", "Resource 4", "Resource 5" }); //ob.Subscribe(x => Console.WriteLine(x.Text), () => done++); var empty = Gimme.Fetch <Thing>("Invalid", null); empty.Subscribe(x => Console.WriteLine("this shouldn't happen"), () => { Console.WriteLine("Empty subscription worked."); done++; }); while (done < 2) { System.Threading.Thread.Sleep(500); Console.WriteLine("Doing some processing..."); } }
public static void Setup(TestContext context) { Gimme.Register(new BasicAsyncProvider(new[] { "One", "Two" })); Gimme.Register(new BasicAsyncProvider(new[] { "Three", "Four" })); Gimme.Register(new BasicObservableProvider(new[] { "One", "Two" })); Gimme.Register(new BasicObservableProvider(new[] { "Three", "Four" })); Gimme.Register(new BasicSyncProvider(new[] { "One", "Two" })); Gimme.Register(new BasicSyncProvider(new[] { "Three", "Four" })); }
public async Task Sync_FetchOneMissing() { var result = await Gimme.FetchOne <string>("Sync", "Missing"); Assert.IsNull(result); result = await Gimme.FetchOne <string>("Invalid", "One"); Assert.IsNull(result); }
public async Task Sync_AsyncFetchNone() { var called = 0; await Gimme.Fetch <string>("Sync", new List <string>(), x => { Assert.Fail(); called++; }); Assert.AreEqual(0, called); }
public async Task Sync_AsyncFetchSimple() { var called = 0; await Gimme.Fetch <string>("Sync", new List <string> { "One" }, x => { Assert.AreEqual("One", x); called++; }); Assert.AreEqual(1, called); }
public ConfigurationPresenter(IConfigurationView view) { this.view = view; this.view.SelectConfigurationFile += delegate { // The ISelectFilePresenter and ISelectFileView behaviors // are implicit here, but in a WinForms case, a call to // OpenFileDialog wouldn't be too far fetched... var selectFilePresenter = Gimme.The <ISelectFilePresenter>(); selectFilePresenter.ShowView(); this.configuration.FullPath = selectFilePresenter.FullPath; this.view.SetConfigurationFile(this.configuration.FullPath); }; }
public async Task Sync_ObservableFetchSimple() { var called = 0; var completed = false; var ob = Gimme.Fetch <string>("Sync", new List <string> { "One" }); ob.Subscribe(x => { called++; Assert.AreEqual("One", x); }, () => completed = true); await ob.ToTask(); Assert.AreEqual(1, called); Assert.IsTrue(completed); }
public async Task Sync_ObservableFetchNotFound() { var called = 0; var completed = false; var ob = Gimme.Fetch <string>("Sync", new List <string> { "Missing" }); ob.Subscribe(x => { Assert.Fail(); called++; }, () => completed = true); try { await ob.ToTask(); Assert.Fail(); } catch (InvalidOperationException) { } Assert.AreEqual(0, called); Assert.IsTrue(completed); completed = false; ob = Gimme.Fetch <string>("Invalid", new List <string> { "One" }); ob.Subscribe(x => { Assert.Fail(); called++; }, () => completed = true); try { await ob.ToTask(); Assert.Fail(); } catch (InvalidOperationException) { } Assert.AreEqual(0, called); Assert.IsTrue(completed); }
public async Task Sync_AsyncFetchNotFound() { var called = 0; await Gimme.Fetch <string>("Sync", new List <string> { "Missing" }, x => { Assert.Fail(); called++; }); await Gimme.Fetch <string>("Invalid", new List <string> { "One" }, x => { Assert.Fail(); called++; }); Assert.AreEqual(0, called); }
public async Task Observable_ObservableFetchNone() { var called = 0; var completed = false; var ob = Gimme.Fetch <string>("Observable", new List <string>()); ob.Subscribe(x => { called++; Assert.Fail(); }, () => completed = true); try { await ob.ToTask(); Assert.Fail(); } catch (InvalidOperationException) { } Assert.AreEqual(0, called); Assert.IsTrue(completed); }
public static void Load() { Timers.TimerStart(); if (TeleportCheck.IsEnabled) { TeleportCheck.DetectionLogsDir(); } if (FlightCheck.IsEnabled) { FlightCheck.DetectionLogsDir(); } if (HatchElevator.IsEnabled) { HatchElevator.DetectionLogsDir(); } if (PlayerLogs.IsEnabled) { PlayerLogs.PlayerLogsDir(); } if (Report.IsEnabled) { Report.ReportLogsDir(); } if (PlayerStatCheck.IsEnabled) { PlayerStatCheck.DetectionLogsDir(); } if (UndergroundCheck.IsEnabled) { UndergroundCheck.DetectionLogsDir(); } if (Bank.IsEnabled) { Bank.CreateFolder(); } if (AuctionBox.IsEnabled) { AuctionBox.CreateFolder(); } if (Bounties.IsEnabled) { Players.CreateFolder(); } if (CredentialCheck.IsEnabled) { CredentialCheck.CreateFolder(); } if (DupeLog.IsEnabled) { DupeLog.CreateFolder(); } Poll.CreateFolder(); if (PersistentContainer.Instance.PollOpen) { Poll.Check(); } if (ChatHook.Special_Player_Name_Coloring) { ChatHook.SpecialIdCheck(); } if (ClanManager.IsEnabled) { PersistentContainer.Instance.Players.GetClans(); ClanManager.BuildList(); } if (!ClanManager.IsEnabled) { PersistentContainer.Instance.Players.clans.Clear(); ClanManager.ClanMember.Clear(); } if (!InfoTicker.IsEnabled && InfoTicker.IsRunning) { InfoTicker.Unload(); } if (InfoTicker.IsEnabled && !InfoTicker.IsRunning) { InfoTicker.Load(); } if (Gimme.IsRunning && !Gimme.IsEnabled) { Gimme.Unload(); } if (!Gimme.IsRunning && Gimme.IsEnabled) { Gimme.Load(); } if (UndergroundCheck.IsRunning && !UndergroundCheck.IsEnabled) { UndergroundCheck.Unload(); } if (!UndergroundCheck.IsRunning && UndergroundCheck.IsEnabled) { UndergroundCheck.Load(); } if (Badwords.IsRunning && !Badwords.IsEnabled) { Badwords.Unload(); } if (!Badwords.IsRunning && Badwords.IsEnabled) { Badwords.Load(); } if (!LoginNotice.IsRunning && LoginNotice.IsEnabled) { LoginNotice.Load(); } if (LoginNotice.IsRunning && !LoginNotice.IsEnabled) { LoginNotice.Unload(); } if (!Zones.IsRunning && Zones.IsEnabled) { Zones.Load(); } if (Zones.IsRunning && !Zones.IsEnabled) { Zones.Unload(); } if (!VoteReward.IsRunning && VoteReward.IsEnabled) { VoteReward.Load(); } if (VoteReward.IsRunning && !VoteReward.IsEnabled) { VoteReward.Unload(); } if (!Watchlist.IsRunning && Watchlist.IsEnabled) { Watchlist.Load(); } if (Watchlist.IsRunning && !Watchlist.IsEnabled) { Watchlist.Unload(); } if (!ReservedSlots.IsRunning && ReservedSlots.IsEnabled) { ReservedSlots.Load(); } if (ReservedSlots.IsRunning && !ReservedSlots.IsEnabled) { ReservedSlots.Unload(); } if (!StartingItems.IsRunning && StartingItems.IsEnabled) { StartingItems.Load(); } if (StartingItems.IsRunning && !StartingItems.IsEnabled) { StartingItems.Unload(); } if (!Travel.IsRunning && Travel.IsEnabled) { Travel.Load(); } if (Travel.IsRunning && !Travel.IsEnabled) { Travel.Unload(); } if (!Shop.IsRunning && Shop.IsEnabled) { Shop.Load(); } if (Shop.IsRunning && !Shop.IsEnabled) { Shop.Unload(); } if (!Motd.IsRunning && Motd.IsEnabled) { Motd.Load(); } if (Motd.IsRunning && !Motd.IsEnabled) { Motd.Unload(); } if (InventoryCheck.IsRunning && !InventoryCheck.IsEnabled) { InventoryCheck.Unload(); } if (!InventoryCheck.IsRunning && InventoryCheck.IsEnabled) { InventoryCheck.Load(); } if (HighPingKicker.IsRunning && !HighPingKicker.IsEnabled) { HighPingKicker.Unload(); } if (!HighPingKicker.IsRunning && HighPingKicker.IsEnabled) { HighPingKicker.Load(); } if (CredentialCheck.IsRunning && !CredentialCheck.IsEnabled) { CredentialCheck.Unload(); } if (!CredentialCheck.IsRunning && CredentialCheck.IsEnabled) { CredentialCheck.Load(); } if (CustomCommands.IsRunning && !CustomCommands.IsEnabled) { CustomCommands.Unload(); } if (!CustomCommands.IsRunning && CustomCommands.IsEnabled) { CustomCommands.Load(); } if (DupeLog.IsRunning && !DupeLog.IsEnabled) { DupeLog.Unload(); } if (!DupeLog.IsRunning && DupeLog.IsEnabled) { DupeLog.Load(); } if (AuctionBox.IsEnabled) { AuctionBox.AuctionList(); } if (MutePlayer.IsEnabled) { MutePlayer.MuteList(); } if (Jail.IsEnabled) { Jail.JailList(); } if (Animals.IsEnabled) { Animals.AnimalList(); } if (AutoShutdown.IsEnabled) { AutoShutdown.ShutdownList(); } }
public static void Load() { PersistentOperations.SetInstallFolder(); if (!DiscordBot.TokenLoaded) { DiscordBot.BuildToken(); } if (!RunTimePatch.Applied) { RunTimePatch.PatchAll(); } if (!Timers.IsRunning) { Timers.TimerStart(); } if (!Triggers.IsRunning) { Triggers.Load(); } if (Poll.IsEnabled && PersistentContainer.Instance.PollOpen) { Poll.CheckTime(); } if (!ClanManager.IsEnabled) { ClanManager.Clans.Clear(); ClanManager.ClanMember.Clear(); } if (!InfoTicker.IsEnabled && InfoTicker.IsRunning) { InfoTicker.Unload(); } if (InfoTicker.IsEnabled && !InfoTicker.IsRunning) { InfoTicker.Load(); } if (Gimme.IsRunning && !Gimme.IsEnabled) { Gimme.Unload(); } if (!Gimme.IsRunning && Gimme.IsEnabled) { Gimme.Load(); } if (Badwords.IsRunning && !Badwords.IsEnabled) { Badwords.Unload(); } if (!Badwords.IsRunning && Badwords.IsEnabled) { Badwords.Load(); } if (!LoginNotice.IsRunning && LoginNotice.IsEnabled) { LoginNotice.Load(); } if (LoginNotice.IsRunning && !LoginNotice.IsEnabled) { LoginNotice.Unload(); } if (!Zones.IsRunning && Zones.IsEnabled) { Zones.Load(); } if (Zones.IsRunning && !Zones.IsEnabled) { Zones.Unload(); } if (!VoteReward.IsRunning && VoteReward.IsEnabled) { VoteReward.Load(); } if (VoteReward.IsRunning && !VoteReward.IsEnabled) { VoteReward.Unload(); } if (!Watchlist.IsRunning && Watchlist.IsEnabled) { Watchlist.Load(); } if (Watchlist.IsRunning && !Watchlist.IsEnabled) { Watchlist.Unload(); } if (!ReservedSlots.IsRunning && ReservedSlots.IsEnabled) { ReservedSlots.Load(); } if (ReservedSlots.IsRunning && !ReservedSlots.IsEnabled) { ReservedSlots.Unload(); } if (!StartingItems.IsRunning && StartingItems.IsEnabled) { StartingItems.Load(); } if (StartingItems.IsRunning && !StartingItems.IsEnabled) { StartingItems.Unload(); } if (!Travel.IsRunning && Travel.IsEnabled) { Travel.Load(); } if (Travel.IsRunning && !Travel.IsEnabled) { Travel.Unload(); } if (!Shop.IsRunning && Shop.IsEnabled) { Shop.Load(); } if (Shop.IsRunning && !Shop.IsEnabled) { Shop.Unload(); } if (!Motd.IsRunning && Motd.IsEnabled) { Motd.Load(); } if (Motd.IsRunning && !Motd.IsEnabled) { Motd.Unload(); } if (InvalidItems.IsRunning && !InvalidItems.IsEnabled) { InvalidItems.Unload(); } if (!InvalidItems.IsRunning && InvalidItems.IsEnabled) { InvalidItems.Load(); } if (HighPingKicker.IsRunning && !HighPingKicker.IsEnabled) { HighPingKicker.Unload(); } if (!HighPingKicker.IsRunning && HighPingKicker.IsEnabled) { HighPingKicker.Load(); } if (CredentialCheck.IsRunning && !CredentialCheck.IsEnabled) { CredentialCheck.Unload(); } if (!CredentialCheck.IsRunning && CredentialCheck.IsEnabled) { CredentialCheck.Load(); } if (CustomCommands.IsRunning && !CustomCommands.IsEnabled) { CustomCommands.Unload(); } if (!CustomCommands.IsRunning && CustomCommands.IsEnabled) { CustomCommands.Load(); } if (DupeLog.IsRunning && !DupeLog.IsEnabled) { DupeLog.Unload(); } if (!DupeLog.IsRunning && DupeLog.IsEnabled) { DupeLog.Load(); } if (ChatColorPrefix.IsRunning && !ChatColorPrefix.IsEnabled) { ChatColorPrefix.Unload(); } if (!ChatColorPrefix.IsRunning && ChatColorPrefix.IsEnabled) { ChatColorPrefix.Load(); } if (KillNotice.IsRunning && !KillNotice.IsEnabled) { KillNotice.Unload(); } if (!KillNotice.IsRunning && KillNotice.IsEnabled) { KillNotice.Load(); } if (Prayer.IsRunning && !Prayer.IsEnabled) { Prayer.Unload(); } if (!Prayer.IsRunning && Prayer.IsEnabled) { Prayer.Load(); } if (BloodmoonWarrior.IsRunning && !BloodmoonWarrior.IsEnabled) { BloodmoonWarrior.Unload(); } else if (!BloodmoonWarrior.IsRunning && BloodmoonWarrior.IsEnabled) { BloodmoonWarrior.Load(); } if (ProtectedSpaces.IsRunning && !ProtectedSpaces.IsEnabled) { ProtectedSpaces.Unload(); } else if (!ProtectedSpaces.IsRunning && ProtectedSpaces.IsEnabled) { ProtectedSpaces.Load(); } if (ClanManager.IsEnabled) { ClanManager.ClanList(); } if (Auction.IsEnabled) { Auction.AuctionList(); } if (Mute.IsEnabled) { Mute.ClientMuteList(); Mute.MuteList(); } if (Jail.IsEnabled) { Jail.JailList(); } if (WebAPI.IsEnabled && !WebAPI.IsRunning) { WebAPI.Load(); } else if (WebAPI.IsRunning && !WebAPI.IsEnabled) { WebAPI.Unload(); } }
public static bool Hook(ClientInfo _cInfo, string _message, string _playerName, string _secondaryName, bool _localizeSecondary) { if (!string.IsNullOrEmpty(_message) && _cInfo != null && _playerName != "Server" && _secondaryName != "ServerTools") { if (ChatFlood) { if (_message.Length > 500) { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Message to long.[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); return(false); } } if (ChatLog.IsEnabled) { ChatLog.Log(_message, _playerName); } if (MutePlayer.Dict.ContainsKey(_cInfo.playerId)) { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, "You are muted.", "Server", false, "ServerTools", false)); return(false); } if (AdminNameColoring && !_message.StartsWith("/") && !_message.StartsWith("@") && _secondaryName != "ServerTools1" && GameManager.Instance.adminTools.IsAdmin(_cInfo.playerId)) { AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId); if (Admin.PermissionLevel == AdminLevel) { _playerName = string.Format("{0}{1} {2}[-]", AdminColor, AdminPrefix, _playerName); GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, _message, _playerName, false, "ServerTools1", false); return(false); } if (Admin.PermissionLevel == ModLevel) { _playerName = string.Format("{0}{1} {2}[-]", ModColor, ModPrefix, _playerName); GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, _message, _playerName, false, "ServerTools1", false); return(false); } } if (Badwords.IsEnabled) { bool _hasBadWord = false; string _message1 = _message.ToLower(); foreach (string _word in Badwords.List) { if (_message1.Contains(_word)) { string _replace = ""; for (int i = 0; i < _word.Length; i++) { _replace = string.Format("{0}*", _replace); } _message1 = _message1.Replace(_word, _replace); _hasBadWord = true; } } if (_hasBadWord) { GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, _message1, _playerName, false, "ServerTools", false); return(false); } } if (_message.StartsWith("/") || _message.StartsWith("!")) { bool _announce = false; if (_message.StartsWith("!")) { _announce = true; _message = _message.Replace("!", ""); } if (_message.StartsWith("/")) { _message = _message.Replace("/", ""); } if (_message.StartsWith("w ") || _message.StartsWith("W ") || _message.StartsWith("pm ") || _message.StartsWith("PM ")) { if (CustomCommands.IsEnabled) { Whisper.Send(_cInfo, _message); return(false); } } if (_message.StartsWith("r ") || _message.StartsWith("R ") || _message.StartsWith("RE ") || _message.StartsWith("re ")) { if (CustomCommands.IsEnabled) { Whisper.Reply(_cInfo, _message); return(false); } } _message = _message.ToLower(); if (_message == "sethome") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("!{0}", _message), _playerName, false, "ServerTools", true); } if (TeleportHome.IsEnabled) { TeleportHome.SetHome(_cInfo); } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Sethome is not enabled.[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); } return(false); } if (_message == "home") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("!{0}", _message), _playerName, false, "ServerTools", true); } if (TeleportHome.IsEnabled) { TeleportHome.TeleHome(_cInfo); } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Home is not enabled.[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); } return(false); } if (AdminChat.IsEnabled) { if (_message.StartsWith("mute ") || _message.StartsWith("unmute ")) { if (_message.StartsWith("mute ")) { MutePlayer.Add(_cInfo, _message); } if (_message.StartsWith("unmute ")) { MutePlayer.Remove(_cInfo, _message); } return(false); } } if (_message == "commands") { string _commands = CustomCommands.GetChatCommands(_cInfo); if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("!{0}", _message), _playerName, false, "ServerTools", true); GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, _commands, "Server", false, "ServerTools", false); } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, _commands, "Server", false, "ServerTools", false)); } return(false); } if (_message == "day7") { if (Day7.IsEnabled) { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("!{0}", _message), _playerName, false, "ServerTools", true); } Day7.GetInfo(_cInfo, _announce); return(false); } } if (_message == "killme" || _message == "wrist" || _message == "suicide") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("!{0}", _message), _playerName, false, "ServerTools", true); } if (KillMe.IsEnabled) { KillMe.CheckPlayer(_cInfo, _announce); } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Killme is not enabled.[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); } return(false); } if (_message == "gimme" || _message == "gimmie") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("!{0}", _message), _playerName, false, "ServerTools", true); } if (Gimme.AlwaysShowResponse && !_announce) { GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("/{0}", _message), _playerName, false, "ServerTools", true); } if (Gimme.IsEnabled) { Gimme.Checkplayer(_cInfo, _announce, _playerName); } else { return(true); } return(false); } if (_message.StartsWith("clanadd") || _message == "clandel" || _message.StartsWith("claninvite") || _message == "clanaccept" || _message == "clandecline" || _message.StartsWith("clanremove") || _message.StartsWith("clanpromote") || _message.StartsWith("clandemote") || _message.StartsWith("clan") || _message.StartsWith("c") || _message == "clancommands") { if (ClanManager.IsEnabled) { if (_message == "clancommands") { ClanManager.GetChatCommands(_cInfo); return(false); } if (_message.StartsWith("clanadd")) { if (_message == "clanadd") { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Usage: /clanadd clanName[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); } else { _message = _message.Replace("clanadd ", ""); ClanManager.AddClan(_cInfo, _message); } return(false); } if (_message == "clandel") { ClanManager.RemoveClan(_cInfo); return(false); } if (_message.StartsWith("claninvite")) { if (_message == "claninvite") { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Usage: /claninvite playerName[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); } else { _message = _message.Replace("claninvite ", ""); ClanManager.InviteMember(_cInfo, _message); } return(false); } if (_message == "clanaccept") { ClanManager.InviteAccept(_cInfo); return(false); } if (_message == "clandecline") { ClanManager.InviteDecline(_cInfo); return(false); } if (_message.StartsWith("clanremove")) { if (_message == "clanremove") { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Usage: /clanremove playerName[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); } else { _message = _message.Replace("clanremove ", ""); ClanManager.RemoveMember(_cInfo, _message); } return(false); } if (_message.StartsWith("clanpromote")) { if (_message == "clanpromote") { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Usage: /clanpromote playerName[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); } else { _message = _message.Replace("clanpromote ", ""); ClanManager.PromoteMember(_cInfo, _message); } return(false); } if (_message.StartsWith("clandemote")) { if (_message == "clandemote") { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Usage: /clandemote playerName[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); } else { _message = _message.Replace("clandemote ", ""); ClanManager.DemoteMember(_cInfo, _message); } return(false); } if (_message == "clanleave") { ClanManager.LeaveClan(_cInfo); return(false); } if (_message.StartsWith("clan")) { if (_message == "clan") { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Usage: /clan message[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); } else { _message = _message.Replace("clan ", ""); ClanManager.Clan(_cInfo, _message); } return(false); } if (_message.StartsWith("c")) { if (_message == "c") { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}Usage: /c message[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); } else { _message = _message.Replace("c ", ""); ClanManager.Clan(_cInfo, _message); } return(false); } } else { return(true); } } if (CustomCommands.IsEnabled && CustomCommands.Dict.Count > 0 && CustomCommands.Dict.ContainsKey(_message)) { string[] _r; if (CustomCommands.Dict.TryGetValue(_message, out _r)) { string _response = _r[0]; _response = _response.Replace("{EntityId}", _cInfo.entityId.ToString()); _response = _response.Replace("{SteamId}", _cInfo.playerId); _response = _response.Replace("{PlayerName}", _playerName); if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("!{0}", _message), _playerName, false, "ServerTools", true); } if (_response.StartsWith("say ")) { if (_announce) { SdtdConsole.Instance.ExecuteSync(_response, _cInfo); } else { _response = _response.Replace("say ", ""); _response = _response.Replace("\"", ""); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format(_response), "Server", false, "ServerTools", false)); } } else { SdtdConsole.Instance.ExecuteSync(_response, _cInfo); } } return(false); } } if (_message.StartsWith("@")) { if (_message.StartsWith("@admins ") || _message.StartsWith("@ADMINS ")) { if (!AdminChat.IsEnabled) { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}AdminChat is not enabled.[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); } else { AdminChat.SendAdmins(_cInfo, _message); } return(false); } if (_message.StartsWith("@all ") || _message.StartsWith("@ALL ")) { if (!AdminChat.IsEnabled) { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}AdminChat is not enabled.[-]", CustomCommands.ChatColor), "Server", false, "ServerTools", false)); } else { AdminChat.SendAll(_cInfo, _message); } return(false); } } } return(true); }
public async Task Observable_FetchOne() { var result = await Gimme.FetchOne <string>("Observable", "One"); Assert.AreEqual("One", result); }
public async Task Sync_FetchOne() { var result = await Gimme.FetchOne <string>("Sync", "One"); Assert.AreEqual("One", result); }
public static void Load() { if (AutoSaveWorld.IsRunning && !AutoSaveWorld.IsEnabled) { AutoSaveWorld.Stop(); } if (!AutoSaveWorld.IsRunning && AutoSaveWorld.IsEnabled) { AutoSaveWorld.Start(); } if (Badwords.IsRunning && !Badwords.IsEnabled) { Badwords.Unload(); } if (!Badwords.IsRunning && Badwords.IsEnabled) { Badwords.Load(); } if (ClanManager.IsEnabled) { PersistentContainer.Instance.Players.GetClans(); } if (!ClanManager.IsEnabled) { PersistentContainer.Instance.Players.clans.Clear(); } if (CustomCommands.IsRunning && !CustomCommands.IsEnabled) { CustomCommands.Unload(); } if (!CustomCommands.IsRunning && CustomCommands.IsEnabled) { CustomCommands.Load(); } if (Gimme.IsRunning && !Gimme.IsEnabled) { Gimme.Unload(); } if (!Gimme.IsRunning && Gimme.IsEnabled) { Gimme.Load(); } if (HighPingKicker.IsRunning && !HighPingKicker.IsEnabled) { HighPingKicker.Unload(); } if (!HighPingKicker.IsRunning && HighPingKicker.IsEnabled) { HighPingKicker.Load(); } if (InfoTicker.IsRunning && !InfoTicker.IsEnabled) { InfoTicker.Unload(); } if (!InfoTicker.IsRunning && InfoTicker.IsEnabled) { InfoTicker.Load(); } if (InventoryCheck.IsRunning && !InventoryCheck.IsEnabled) { InventoryCheck.Unload(); } if (!InventoryCheck.IsRunning && InventoryCheck.IsEnabled) { InventoryCheck.Load(); } if (!Watchlist.IsRunning && Watchlist.IsEnabled) { Watchlist.Load(); } if (Watchlist.IsRunning && !Watchlist.IsEnabled) { Watchlist.Unload(); } if (!ReservedSlots.IsRunning && ReservedSlots.IsEnabled) { ReservedSlots.Load(); } if (ReservedSlots.IsRunning && !ReservedSlots.IsEnabled) { ReservedSlots.Unload(); } }
public static void Init() { GameItems.LoadGameItems(); if (CustomCommands.IsRunning && !CustomCommands.IsEnabled) { CustomCommands._fileWatcher.Dispose(); CustomCommands.IsRunning = false; } if (!CustomCommands.IsRunning && CustomCommands.IsEnabled) { CustomCommands.Init(); } if (KillMe.IsEnabled) { KillMe.Init(); } if (Gimme.IsRunning && !Gimme.IsEnabled) { Gimme._fileWatcher.Dispose(); Gimme.IsRunning = false; } if (!Gimme.IsRunning && Gimme.IsEnabled) { Gimme.Init(); } if (HighPingKicker.IsRunning && !HighPingKicker.IsEnabled) { HighPingKicker._fileWatcher.Dispose(); HighPingKicker.IsRunning = false; } if (!HighPingKicker.IsRunning && HighPingKicker.IsEnabled) { HighPingKicker.Init(); } if (InventoryCheck.IsRunning && !InventoryCheck.IsEnabled) { InventoryCheck._fileWatcher.Dispose(); InventoryCheck.IsRunning = false; } if (!InventoryCheck.IsRunning && InventoryCheck.IsEnabled) { InventoryCheck.Init(); } if (TeleportHome.IsEnabled) { TeleportHome.Init(); } if (TeleportReturn.IsEnabled) { TeleportReturn.Init(); } if (Badwords.IsRunning && !Badwords.IsEnabled) { Badwords._fileWatcher.Dispose(); Badwords.IsRunning = false; } if (!Badwords.IsRunning && Badwords.IsEnabled) { Badwords.Init(); } if (SaveWorld.IsRunning && !SaveWorld.IsEnabled) { SaveWorld.th.Abort(); SaveWorld.IsRunning = false; } if (!SaveWorld.IsRunning && SaveWorld.IsEnabled) { SaveWorld.Init(); } if (InfoTicker.IsRunning && !InfoTicker.IsEnabled) { InfoTicker.th.Abort(); InfoTicker.IsRunning = false; } if (!InfoTicker.IsEnabled && !Motd.IsEnabled && InfoTicker.IsConfigLoaded) { InfoTicker._fileWatcher.Dispose(); InfoTicker.IsConfigLoaded = false; } if (!InfoTicker.IsRunning && InfoTicker.IsEnabled) { InfoTicker.Init(); } if (!InfoTicker.IsConfigLoaded && Motd.IsEnabled) { InfoTicker.Init(); } if (ClanManager.IsEnabled) { ClanData.Init(); } }
public static bool IsCommand(ClientInfo _cInfo, string _message, string _playerName) { if (!string.IsNullOrEmpty(_message) && _cInfo != null && _playerName != "" && _playerName != "Server") { if (AdminChat.MutedPlayersList.Contains(_cInfo.playerId)) { _cInfo.SendPackage(new NetPackageGameMessage(string.Format("{0}You are currently muted.[-]", CustomCommands._chatcolor), "Server")); return(false); } string _filter = "[ffffffff][/url][/b][/i][/u][/s][/sub][/sup][ff]"; if (_message.EndsWith(_filter + _filter)) { _message = _message.Remove(_message.Length - 2 * _filter.Length); } if (ChatLog.IsEnabled && !_message.EndsWith(_filter)) { ChatLog.Send(_message, _playerName); } if (Badwords.IsEnabled && !_message.EndsWith(_filter)) { string _message1 = _message.ToLower(); foreach (string _word in Badwords.BadWordslist) { if (_message1.Contains(_word)) { _message1 = _message1.Replace(_word, "*****"); GameManager.Instance.GameMessageServer(_cInfo, _message1, _playerName); return(false); } } } if (_message.StartsWith("/") || _message.StartsWith("!") || _message.StartsWith("@")) { bool _announce = false; if (_message.StartsWith("!")) { _announce = true; _message = _message.Replace("!", ""); } if (_message.StartsWith("/")) { _message = _message.Replace("/", ""); } if (_message.StartsWith("mute ") || _message.StartsWith("unmute ")) { if (AdminChat.IsEnabled) { if (_message.StartsWith("mute ")) { _message = _message.Replace("mute ", ""); AdminChat.MutePlayer(_cInfo, _message); } if (_message.StartsWith("unmute ")) { _message = _message.Replace("unmute ", ""); AdminChat.UnMutePlayer(_cInfo, _message); } } else { _cInfo.SendPackage(new NetPackageGameMessage(string.Format("{0}AdminChat is not enabled.[-]", CustomCommands._chatcolor), "Server")); } return(false); } if (_message.StartsWith("clanadd ") || _message == "clandel" || _message.StartsWith("claninvite ") || _message == "clanaccept" || _message == "clandecline" || _message.StartsWith("clanremove ") || _message.StartsWith("clanpromote ") || _message.StartsWith("clandemote ")) { if (ClanManager.IsEnabled) { if (_message.StartsWith("clanadd ")) { _message = _message.Replace("clanadd ", ""); ClanManager.AddClan(_cInfo, _message); } if (_message == "clandel") { ClanManager.RemoveClan(_cInfo); } if (_message.StartsWith("claninvite ")) { _message = _message.Replace("claninvite ", ""); ClanManager.InviteMember(_cInfo, _message); } if (_message == "clanaccept") { ClanManager.InviteAccept(_cInfo); } if (_message == "clandecline") { ClanManager.InviteDecline(_cInfo); } if (_message.StartsWith("clanremove ")) { _message = _message.Replace("clanremove ", ""); ClanManager.RemoveMember(_cInfo, _message); } if (_message.StartsWith("clanpromote ")) { _message = _message.Replace("clanpromote ", ""); ClanManager.PromoteMember(_cInfo, _message); } if (_message.StartsWith("clandemote ")) { _message = _message.Replace("clandemote ", ""); ClanManager.DemoteMember(_cInfo, _message); } if (_message == "clanleave") { ClanManager.LeaveClan(_cInfo); } } else { _cInfo.SendPackage(new NetPackageGameMessage(string.Format("{0}ClanManager is not enabled.[-]", CustomCommands._chatcolor), "Server")); } return(false); } if (_message.StartsWith("@admins ") || _message.StartsWith("@all ") || _message.StartsWith("@ADMINS ") || _message.StartsWith("@ALL ")) { if (!AdminChat.IsEnabled) { _cInfo.SendPackage(new NetPackageGameMessage(string.Format("{0}AdminChat is not enabled.[-]", CustomCommands._chatcolor), "Server")); } else { if (_message.StartsWith("@ADMINS ")) { _message = _message.Replace("@ADMINS ", ""); AdminChat.SendAdmins(_cInfo, _message); } if (_message.StartsWith("@admins ")) { _message = _message.Replace("@admins ", ""); _message = "hello " + _message; AdminChat.SendAdmins(_cInfo, _message); } if (_message.StartsWith("@ALL ")) { _message = _message.Replace("@ALL ", ""); AdminChat.SendAll(_cInfo, _message); } if (_message.StartsWith("@all ")) { _message = _message.Replace("@all ", ""); AdminChat.SendAll(_cInfo, _message); } } return(false); } if (_message.StartsWith("w ") || _message.StartsWith("W ") || _message.StartsWith("pm ") || _message.StartsWith("PM ")) { if (_message.StartsWith("PM ")) { _message = _message.Replace("PM ", ""); } if (_message.StartsWith("pm ")) { _message = _message.Replace("pm ", ""); } if (_message.StartsWith("W ")) { _message = _message.Replace("W ", ""); } if (_message.StartsWith("w ")) { _message = _message.Replace("w ", ""); } Whisper.Send(_cInfo, _message); return(false); } _message = _message.ToLower(); if (_message == "info" || _message == "help" || _message == "commands") { string _commands = CustomCommands.GetChatCommands(_cInfo); if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, string.Format("!{0}", _message), _playerName); GameManager.Instance.GameMessageServer(_cInfo, _commands, "Server"); } else { _cInfo.SendPackage(new NetPackageGameMessage(_commands, "Server")); } return(false); } if (_message == "killme" || _message == "wrist" || _message == "suicide") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, string.Format("!{0}", _message), _playerName); } if (KillMe.IsEnabled) { KillMe.KillPlayer(_cInfo, _announce, _message, _playerName); } else { _cInfo.SendPackage(new NetPackageGameMessage(string.Format("{0}Killme is not enabled.[-]", CustomCommands._chatcolor), "Server")); } return(false); } if (_message == "gimme" || _message == "gimmie") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, string.Format("!{0}", _message), _playerName); } if (Gimme.AlwaysShowResponse && !_announce) { GameManager.Instance.GameMessageServer(_cInfo, string.Format("/{0}", _message), _playerName); } if (Gimme.IsEnabled) { Gimme.Checkplayer(_cInfo, _announce, _playerName); } else { _cInfo.SendPackage(new NetPackageGameMessage(string.Format("{0}Gimme is not enabled.[-]", CustomCommands._chatcolor), "Server")); } return(false); } if (_message == "sethome") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, string.Format("!{0}", _message), _playerName); } if (TeleportHome.IsEnabled) { TeleportHome.SetHome(_cInfo); } else { _cInfo.SendPackage(new NetPackageGameMessage(string.Format("{0}Sethome is not enabled.[-]", CustomCommands._chatcolor), "Server")); } return(false); } if (_message == "delhome") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, string.Format("!{0}", _message), _playerName); } if (TeleportHome.IsEnabled) { TeleportHome.DelHome(_cInfo); } else { _cInfo.SendPackage(new NetPackageGameMessage(string.Format("{0}Delhome is not enabled.[-]", CustomCommands._chatcolor), "Server")); } return(false); } if (_message == "home") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, string.Format("!{0}", _message), _playerName); } if (TeleportHome.IsEnabled) { TeleportHome.TeleHome(_cInfo); } else { _cInfo.SendPackage(new NetPackageGameMessage(string.Format("{0}Home is not enabled.[-]", CustomCommands._chatcolor), "Server")); } return(false); } if (_message == "setreturn") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, string.Format("!{0}", _message), _playerName); } if (TeleportReturn.IsEnabled) { TeleportReturn.SetReturn(_cInfo); } else { _cInfo.SendPackage(new NetPackageGameMessage(string.Format("{0}SetReturn is not enabled.[-]", CustomCommands._chatcolor), "Server")); } return(false); } if (_message == "delreturn") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, string.Format("!{0}", _message), _playerName); } if (TeleportReturn.IsEnabled) { TeleportReturn.DelReturn(_cInfo); } else { _cInfo.SendPackage(new NetPackageGameMessage(string.Format("{0}DelReturn is not enabled.[-]", CustomCommands._chatcolor), "Server")); } return(false); } if (_message == "return") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, string.Format("!{0}", _message), _playerName); } if (TeleportReturn.IsEnabled) { TeleportReturn.TeleReturn(_cInfo); } else { _cInfo.SendPackage(new NetPackageGameMessage(string.Format("{0}Return is not enabled.[-]", CustomCommands._chatcolor), "Server")); } return(false); } if (_message == "day7") { if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, string.Format("!{0}", _message), _playerName); } if (Day7.IsEnabled) { Day7.GetInfo(_cInfo, _announce); } return(false); } if (_message == "clancommands") { if (ClanManager.IsEnabled) { ClanManager.GetChatCommands(_cInfo); } return(false); } string _response = null; if (CustomCommands.IsEnabled && CustomCommands._customCommands.TryGetValue(_message, out _response)) { _response = _response.Replace("{0}", _cInfo.entityId.ToString()); _response = _response.Replace("{1}", _cInfo.playerId); _response = _response.Replace("{2}", _playerName); _response = _response.Replace("{EntityId}", _cInfo.entityId.ToString()); _response = _response.Replace("{SteamId}", _cInfo.playerId); _response = _response.Replace("{PlayerName}", _playerName); if (_announce) { GameManager.Instance.GameMessageServer(_cInfo, string.Format("!{0}", _message), _playerName); } if (_response.StartsWith("say ")) { if (_announce) { SdtdConsole.Instance.ExecuteSync(_response, _cInfo); } else { _response = _response.Replace("say ", ""); _response = _response.Replace("\"", ""); _cInfo.SendPackage(new NetPackageGameMessage(string.Format(_response), "Server")); } } else { SdtdConsole.Instance.ExecuteSync(_response, _cInfo); } return(false); } } } return(true); }
public static void Load() { DiscordBot.BuildToken(); if (!Timers.CoreIsRunning) { Timers.CoreTimerStart(); } if (XRayDetector.IsEnabled && !Timers.HalfSecondIsRunning) { Timers.HalfSecondTimerStart(); } if (!XRayDetector.IsEnabled && Timers.HalfSecondIsRunning) { Timers.HalfSecondTimerStop(); } if (Poll.IsEnabled && PersistentContainer.Instance.PollOpen) { Poll.CheckTime(); } if (!ClanManager.IsEnabled) { ClanManager.Clans.Clear(); ClanManager.ClanMember.Clear(); } if (!InfoTicker.IsEnabled && InfoTicker.IsRunning) { InfoTicker.Unload(); } if (InfoTicker.IsEnabled && !InfoTicker.IsRunning) { InfoTicker.Load(); } if (Gimme.IsRunning && !Gimme.IsEnabled) { Gimme.Unload(); } if (!Gimme.IsRunning && Gimme.IsEnabled) { Gimme.Load(); } if (Badwords.IsRunning && !Badwords.IsEnabled) { Badwords.Unload(); } if (!Badwords.IsRunning && Badwords.IsEnabled) { Badwords.Load(); } if (!LoginNotice.IsRunning && LoginNotice.IsEnabled) { LoginNotice.Load(); } if (LoginNotice.IsRunning && !LoginNotice.IsEnabled) { LoginNotice.Unload(); } if (!Zones.IsRunning && Zones.IsEnabled) { Zones.Load(); } if (Zones.IsRunning && !Zones.IsEnabled) { Zones.Unload(); } if (!VoteReward.IsRunning && VoteReward.IsEnabled) { VoteReward.Load(); } if (VoteReward.IsRunning && !VoteReward.IsEnabled) { VoteReward.Unload(); } if (!WatchList.IsRunning && WatchList.IsEnabled) { WatchList.Load(); } if (WatchList.IsRunning && !WatchList.IsEnabled) { WatchList.Unload(); } if (!ReservedSlots.IsRunning && ReservedSlots.IsEnabled) { ReservedSlots.Load(); } if (ReservedSlots.IsRunning && !ReservedSlots.IsEnabled) { ReservedSlots.Unload(); } if (!StartingItems.IsRunning && StartingItems.IsEnabled) { StartingItems.Load(); } if (StartingItems.IsRunning && !StartingItems.IsEnabled) { StartingItems.Unload(); } if (!Travel.IsRunning && Travel.IsEnabled) { Travel.Load(); } if (Travel.IsRunning && !Travel.IsEnabled) { Travel.Unload(); } if (!Shop.IsRunning && Shop.IsEnabled) { Shop.Load(); } if (Shop.IsRunning && !Shop.IsEnabled) { Shop.Unload(); } if (!Motd.IsRunning && Motd.IsEnabled) { Motd.Load(); } if (Motd.IsRunning && !Motd.IsEnabled) { Motd.Unload(); } if (InvalidItems.IsRunning && !InvalidItems.IsEnabled) { InvalidItems.Unload(); } if (!InvalidItems.IsRunning && InvalidItems.IsEnabled) { InvalidItems.Load(); } if (HighPingKicker.IsRunning && !HighPingKicker.IsEnabled) { HighPingKicker.Unload(); } if (!HighPingKicker.IsRunning && HighPingKicker.IsEnabled) { HighPingKicker.Load(); } if (CustomCommands.IsRunning && !CustomCommands.IsEnabled) { CustomCommands.Unload(); } if (!CustomCommands.IsRunning && CustomCommands.IsEnabled) { CustomCommands.Load(); } if (DupeLog.IsRunning && !DupeLog.IsEnabled) { DupeLog.Unload(); } if (!DupeLog.IsRunning && DupeLog.IsEnabled) { DupeLog.Load(); } if (ChatColor.IsRunning && !ChatColor.IsEnabled) { ColorList.Unload(); ChatColor.Unload(); } if (!ChatColor.IsRunning && ChatColor.IsEnabled) { ColorList.Load(); ChatColor.Load(); } if (KillNotice.IsRunning && !KillNotice.IsEnabled) { KillNotice.Unload(); } if (!KillNotice.IsRunning && KillNotice.IsEnabled) { KillNotice.Load(); } if (Prayer.IsRunning && !Prayer.IsEnabled) { Prayer.Unload(); } if (!Prayer.IsRunning && Prayer.IsEnabled) { Prayer.Load(); } if (BloodmoonWarrior.IsRunning && !BloodmoonWarrior.IsEnabled) { BloodmoonWarrior.Unload(); } else if (!BloodmoonWarrior.IsRunning && BloodmoonWarrior.IsEnabled) { BloodmoonWarrior.Load(); } if (Waypoints.IsRunning && !Waypoints.Public_Waypoints) { Waypoints.Unload(); } else if (!Waypoints.IsRunning && Waypoints.Public_Waypoints) { Waypoints.Load(); } if (LevelUp.IsRunning && !LevelUp.IsEnabled) { LevelUp.Unload(); } else if (!LevelUp.IsRunning && LevelUp.IsEnabled) { LevelUp.Load(); } if (BotResponse.IsRunning && !BotResponse.IsEnabled) { BotResponse.Unload(); } else if (!BotResponse.IsRunning && BotResponse.IsEnabled) { BotResponse.Load(); } if (ProtectedZones.IsRunning && !ProtectedZones.IsEnabled) { ProtectedZones.Unload(); } else if (!ProtectedZones.IsRunning && ProtectedZones.IsEnabled) { ProtectedZones.Load(); } if (ClanManager.IsEnabled) { ClanManager.ClanList(); } if (Auction.IsEnabled) { Auction.AuctionList(); } if (Mute.IsEnabled) { Mute.ClientMuteList(); Mute.MuteList(); } if (Jail.IsEnabled) { Jail.JailList(); } if (WebAPI.IsEnabled && !WebAPI.IsRunning) { if (!PersistentOperations.ThirtySeconds) { Log.Out("[SERVERTOOLS] Web_API will go live thirty seconds after the server finishes loading"); } else { WebAPI.Load(); } } else if (WebAPI.IsRunning && !WebAPI.IsEnabled) { WebAPI.Unload(); } }