diff --git a/PerPlayerLoot/FakeChestDatabase.cs b/PerPlayerLoot/FakeChestDatabase.cs index 35e38ca..0960f32 100644 --- a/PerPlayerLoot/FakeChestDatabase.cs +++ b/PerPlayerLoot/FakeChestDatabase.cs @@ -9,9 +9,9 @@ using System.IO.Streams; using Newtonsoft.Json; -using System.Data.SQLite; using Newtonsoft.Json.Bson; using System.Runtime.Serialization.Formatters.Binary; +using Microsoft.Data.Sqlite; namespace PerPlayerLoot { @@ -32,7 +32,7 @@ public class FakeChestDatabase public static HashSet<(int, int)> playerPlacedChests = new HashSet<(int, int)>(); // tile x, y of player placed chests - private static string connString = "Data Source=perplayerloot.sqlite;Version=3;"; + private static string connString = "Data Source=tshock/perplayerloot.sqlite"; public FakeChestDatabase() { } @@ -45,7 +45,7 @@ public void Initialize() public void CreateTables() { TSPlayer.Server.SendInfoMessage("Setting up per-player chests database..."); - using (SQLiteConnection conn = new SQLiteConnection(connString)) + using (SqliteConnection conn = new SqliteConnection(connString)) { conn.Open(); @@ -66,7 +66,7 @@ PRIMARY KEY (x, y) ); "; - using (var cmd = new SQLiteCommand(sql, conn)) + using (var cmd = new SqliteCommand(sql, conn)) cmd.ExecuteNonQuery(); } @@ -77,14 +77,14 @@ public void LoadFakeChests() TSPlayer.Server.SendInfoMessage("Loading per-player loot chest inventories..."); int count = 0; - using (SQLiteConnection conn = new SQLiteConnection(connString)) + using (SqliteConnection conn = new SqliteConnection(connString)) { conn.Open(); // load loot chests - using (var cmd = new SQLiteCommand("SELECT id, playerUuid, x, y, items FROM chests;", conn)) + using (var cmd = new SqliteCommand("SELECT id, playerUuid, x, y, items FROM chests;", conn)) { - SQLiteDataReader reader = cmd.ExecuteReader(); + SqliteDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { @@ -138,9 +138,9 @@ public void LoadFakeChests() } // load tile exclusions - using (var cmd = new SQLiteCommand("SELECT x, y FROM placed;", conn)) + using (var cmd = new SqliteCommand("SELECT x, y FROM placed;", conn)) { - SQLiteDataReader reader = cmd.ExecuteReader(); + SqliteDataReader reader = cmd.ExecuteReader(); playerPlacedChests.Clear(); @@ -162,7 +162,7 @@ public void SaveFakeChests() TSPlayer.Server.SendInfoMessage("Saving per-player loot chest inventories..."); int count = 0; - using (SQLiteConnection conn = new SQLiteConnection(connString)) + using (SqliteConnection conn = new SqliteConnection(connString)) { conn.Open(); @@ -198,7 +198,7 @@ public void SaveFakeChests() var sql = @"REPLACE INTO chests (id, playerUuid, x, y, items) VALUES (@id, @playerUuid, @x, @y, @items);"; - using (var cmd = new SQLiteCommand(sql, conn)) + using (var cmd = new SqliteCommand(sql, conn)) { cmd.Parameters.AddWithValue("@id", chestId); cmd.Parameters.AddWithValue("@playerUuid", playerUuid); @@ -217,7 +217,7 @@ public void SaveFakeChests() { var sql = @"REPLACE INTO placed (x, y) VALUES (@x, @y);"; - using (var cmd = new SQLiteCommand(sql, conn)) + using (var cmd = new SqliteCommand(sql, conn)) { cmd.Parameters.AddWithValue("@x", x); cmd.Parameters.AddWithValue("@y", y); diff --git a/PerPlayerLoot/PPLPlugin.cs b/PerPlayerLoot/PPLPlugin.cs index 3a87e55..b60b244 100644 --- a/PerPlayerLoot/PPLPlugin.cs +++ b/PerPlayerLoot/PPLPlugin.cs @@ -16,7 +16,7 @@ public class PPLPlugin : TerrariaPlugin #region info public override string Name => "PerPlayerLoot"; - public override Version Version => new Version(1, 0); + public override Version Version => new Version(2, 0); public override string Author => "Codian"; diff --git a/PerPlayerLoot/PerPlayerLoot.csproj b/PerPlayerLoot/PerPlayerLoot.csproj index eba03d4..5ba124d 100644 --- a/PerPlayerLoot/PerPlayerLoot.csproj +++ b/PerPlayerLoot/PerPlayerLoot.csproj @@ -12,14 +12,6 @@ - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index d332510..f41dd84 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,14 @@ there for you to find! ## Installation 1. Copy `PerPlayerLoot.dll` into the `ServerPlugins` directory of your TShock - server. -2. Copy `System.Data.SQLite.dll` into the `bin` directory of your TShock server. + server. You can download this from the [GitHub Releases](https://github.com/xxcodianxx/PerPlayerLoot/releases/) of this repository. 3. Start a new world from scratch (yes, this is important, read below) and play! +> [!WARNING] +> If migrating from version `1.0` of the plugin, you need to move `perplayerloot.sqlite` +> from the server root directory to the `tshock` folder. You should see the file as `tshock/perplayerloot.sqlite`. +> If you do not do this, your existing world chests will behave like loot chests! + ## How it Works This plugin aims to not modify the server-side chest state (`Terraria.Main.chest`) on chest interactions, in the hope that it can be as @@ -58,4 +62,4 @@ possibly broken (which should rarely happen). In that case, the real chest in Debug use only! When in a disabled state, any chests you place will become loot chests, and any chest inventory accessed will be its **real inventory**, - not a per-player instanced one! \ No newline at end of file + not a per-player instanced one!