Skip to content

Commit 60ac560

Browse files
added async to update and await function for task
1 parent d02aa39 commit 60ac560

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

BotCommands.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
using System.IO;
2-
using BepInEx;
1+
using BepInEx;
32
using BepInEx.Configuration;
3+
using System.IO;
4+
using System.Threading.Tasks;
45
using UnityEngine;
56

67
namespace BotCMDs
78
{
89
[BepInDependency("com.bepis.r2api")]
9-
[BepInPlugin("com.Rayss.BotCommands", "Bot Commands", "0.1.0")]
10+
[BepInPlugin("com.Rayss.BotCommands", "BotCommands", "0.1.1")]
1011
public class BotCommands : BaseUnityPlugin
1112
{
12-
1313
// Config
1414
private static ConfigEntry<string> Cmdpath { get; set; }
15+
1516
private string botcmd_path;
1617

1718
[System.Diagnostics.CodeAnalysis.SuppressMessage("Code Quality", "IDE0051:Remove unused private members")]
@@ -29,14 +30,14 @@ public void Awake()
2930
}
3031

3132
[System.Diagnostics.CodeAnalysis.SuppressMessage("Code Quality", "IDE0051:Remove unused private members")]
32-
private void Update()
33+
private async void Update()
3334
{
3435
using (StreamReader reader = new StreamReader(new FileStream(botcmd_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
3536
{
3637
//start at the end of the file
3738
long lastMaxOffset = reader.BaseStream.Length;
3839

39-
System.Threading.Thread.Sleep(100);
40+
await Task.Delay(5000);
4041

4142
//seek to the last max offset
4243
reader.BaseStream.Seek(lastMaxOffset, SeekOrigin.Begin);

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Retrieve and execute commands to a Risk of Rain 2 dedicated server from a text file
33

44
## Version History
5-
### 0.1
5+
### 0.1.1
6+
- Improved game responsiveness when using BotCommands
7+
### 0.1.0
68
- Initial commit
79
- Creates config file with variable used to define the file path of botcmd.txt

0 commit comments

Comments
 (0)