public override void Initialize() { _config = UserSpecificFunctionsConfig.ReadOrCreate(ConfigPath); _database = new DatabaseManager(); _database.Load(); AccountHooks.AccountDelete += OnAccountDelete; GeneralHooks.ReloadEvent += OnReload; PlayerHooks.PlayerPermission += OnPlayerPermission; ServerApi.Hooks.ServerChat.Register(this, OnServerChat); ServerApi.Hooks.ServerLeave.Register(this, OnLeave); PlayerHooks.PlayerCommand += OnPlayerCommand; Commands.ChatCommands.Add(new Command("us.cmd", UsCommand, "us")); Commands.ChatCommands.Add(new Command("permission.cmd", PermissionCommand, "permission")); Action <Command> Add = c => { Commands.ChatCommands.RemoveAll(c2 => c2.Names.Exists(s2 => c.Names.Contains(s2))); Commands.ChatCommands.Add(c); }; Add(new Command(TShockAPI.Permissions.cantalkinthird, ThirdPerson, "me")); Add(new Command(TShockAPI.Permissions.whisper, Reply, "reply", "r")); Add(new Command(TShockAPI.Permissions.whisper, Whisper, "whisper", "w", "tell")); }
/// <summary> /// Reads the configuration file from the given path, or creates one if it doesn't exist. /// </summary> /// <param name="configPath">The path.</param> /// <returns>The config.</returns> public static UserSpecificFunctionsConfig ReadOrCreate(string configPath) { if (File.Exists(configPath)) { return(JsonConvert.DeserializeObject <UserSpecificFunctionsConfig>(File.ReadAllText(configPath))); } var config = new UserSpecificFunctionsConfig(); File.WriteAllText(configPath, JsonConvert.SerializeObject(config, Formatting.Indented)); return(config); }
/// <summary> /// Initializes the plugin. /// </summary> public override void Initialize() { _config = UserSpecificFunctionsConfig.ReadOrCreate(ConfigPath); _database = new DatabaseManager(); _database.Load(); AccountHooks.AccountDelete += OnAccountDelete; GeneralHooks.ReloadEvent += OnReload; PlayerHooks.PlayerPermission += OnPlayerPermission; ServerApi.Hooks.ServerChat.Register(this, OnServerChat); Commands.ChatCommands.Add(new Command(UsCommandHandler, "us")); Commands.ChatCommands.Add(new Command(UsPermissionCommandHandler, "permission")); }
private void OnReload(ReloadEventArgs e) { _config = UserSpecificFunctionsConfig.ReadOrCreate(ConfigPath); _database.Load(); }