public static DonationPluginSettings ReadFromFile(string xmlConfigurationFile) { DonationPluginSettings result = new DonationPluginSettings(); XDocument configDocument = XDocument.Load(xmlConfigurationFile); if (configDocument.Root == null) { throw new ConfigurationErrorsException("Could not find root node in file: " + xmlConfigurationFile); } result.DonationTargetLogin = ReadConfigString(configDocument.Root, "DonationTargetLogin", DONATION_TARGET_LOGIN, xmlConfigurationFile); result.MinDonationValue = ReadConfigUInt(configDocument.Root, "MinDonationValue", MIN_DONATION_VALUE, xmlConfigurationFile); result.DonationToSmallMessage = ReadConfigString(configDocument.Root, "DonationToSmallMessage", DONATION_TO_SMALL_MSG, xmlConfigurationFile); result.PlayerHasNoUnitedAccountMessage = ReadConfigString(configDocument.Root, "PlayerHasNoUnitedAccountMessage", PLAYER_HAS_NO_UNITED_ACCOUNT_MSG, xmlConfigurationFile); result.DonationHint = ReadConfigString(configDocument.Root, "DonationHint", DONATION_HINT, xmlConfigurationFile); result.RefuseMessage = ReadConfigString(configDocument.Root, "RefuseMessage", REFUSE_MSG, xmlConfigurationFile); result.DonationErrorMessage = ReadConfigString(configDocument.Root, "DonationErrorMessage", DONATION_ERROR_MSG, xmlConfigurationFile); result.DonationThanksMessage = ReadConfigString(configDocument.Root, "DonationThanksMessage", DONATION_THANKSR_MSG, xmlConfigurationFile); return(result); }
protected override void Init() { Settings = DonationPluginSettings.ReadFromFile(PluginSettingsFilePath); InitializationAborted = true; if (Settings.IsServerTargetLogin && Context.ServerInfo.Version.Name != "TmForever") { Logger.WarnToUI("Plugin not started, because the server is not a forever-server"); return; } if (!Context.ServerInfo.PlayerInfo.IsUnitedAccount) { Logger.WarnToUI("Plugin not started, because the server is not running with an united account."); return; } InitializationAborted = false; BillDictionary = new Dictionary <int, DonationInfo>(); Context.RPCClient.Callbacks.PlayerChat += Callbacks_PlayerChat; Context.RPCClient.Callbacks.BillUpdated += Callbacks_BillUpdated; }