Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using Newtonsoft.Json;
  3. namespace Oxide.Plugins
  4. {
  5. [Info("Config example", "Mughisi", 1.0)]
  6. class ConfigExample : RustPlugin
  7. {
  8. private ConfigExampleConfig config;
  9. public class ConfigExampleConfig
  10. {
  11. public bool Enabled;
  12. public int Timeout;
  13. public string IP;
  14. [JsonProperty(PropertyName = "Domain Names - Use Proxy")]
  15. public Dictionary<string, string> DomainNames;
  16.  
  17. public static ConfigExampleConfig DefaultConfig()
  18. {
  19. return new ConfigExampleConfig
  20. {
  21. Enabled = true,
  22. Timeout = 5,
  23. IP = "127.0.0.1",
  24. DomainNames = new Dictionary<string, string>
  25. {
  26. ["SomeDefaultKey"] = "SomeDefaultValue",
  27. ["SomeOtherDefaultKey"] = "SomeOtherDefaultValue"
  28. }
  29. };
  30. }
  31. }
  32.  
  33. protected override void LoadConfig()
  34. {
  35. base.LoadConfig();
  36. config = Config.ReadObject<ConfigExampleConfig>();
  37. }
  38. protected override void LoadDefaultConfig() => config = ConfigExampleConfig.DefaultConfig();
  39. protected override void SaveConfig() => Config.WriteObject(config);
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement