diff --git a/.github/workflows/ci-otapi3-nuget.yml b/.github/workflows/ci-otapi3-nuget.yml index 04b03a95..7834ccf0 100644 --- a/.github/workflows/ci-otapi3-nuget.yml +++ b/.github/workflows/ci-otapi3-nuget.yml @@ -11,13 +11,13 @@ jobs: environment: release steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.400 + dotnet-version: 9.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/ci-otapi3.yml b/.github/workflows/ci-otapi3.yml index e72d8c22..f7e50037 100644 --- a/.github/workflows/ci-otapi3.yml +++ b/.github/workflows/ci-otapi3.yml @@ -7,13 +7,13 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: 'recursive' - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.100' + dotnet-version: 9.0.x - name: Run tests run: dotnet test @@ -25,13 +25,13 @@ jobs: arch: ["win-x64", "osx-x64", "linux-x64", "linux-arm64", "linux-arm"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: 'recursive' - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.100' + dotnet-version: 9.0.x - name: Install msgfmt run: sudo apt-get install -y gettext @@ -39,27 +39,27 @@ jobs: - name: Produce installer run: | cd TShockInstaller - dotnet publish -r ${{ matrix.arch }} -f net6.0 -c Release -p:PublishSingleFile=true --self-contained true + dotnet publish -r ${{ matrix.arch }} -f net9.0 -c Release -p:PublishSingleFile=true --self-contained true - name: Produce build run: | cd TShockLauncher - dotnet publish -r ${{ matrix.arch }} -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false + dotnet publish -r ${{ matrix.arch }} -f net9.0 -c Release -p:PublishSingleFile=true --self-contained false - name: Chmod scripts if: ${{ matrix.arch != 'win-x64' }} run: | - chmod +x TShockLauncher/bin/Release/net6.0/${{ matrix.arch }}/publish/TShock.Server + chmod +x TShockLauncher/bin/Release/net9.0/${{ matrix.arch }}/publish/TShock.Server - name: Copy installer run: | - cp TShockInstaller/bin/Release/net6.0/${{ matrix.arch }}/publish/* TShockLauncher/bin/Release/net6.0/${{ matrix.arch }}/publish/ + cp TShockInstaller/bin/Release/net9.0/${{ matrix.arch }}/publish/* TShockLauncher/bin/Release/net9.0/${{ matrix.arch }}/publish/ # preserve file perms: https://github.com/actions/upload-artifact#maintaining-file-permissions-and-case-sensitive-files - name: Tarball artifact (non-Windows) if: ${{ matrix.arch != 'win-x64' }} run: | - cd TShockLauncher/bin/Release/net6.0/${{ matrix.arch }}/publish/ + cd TShockLauncher/bin/Release/net9.0/${{ matrix.arch }}/publish/ tar -cvf ../../../../../../TShock-Beta-${{ matrix.arch }}-Release.tar * - name: Upload artifact (non-Windows) @@ -74,4 +74,4 @@ jobs: if: ${{ matrix.arch == 'win-x64' }} with: name: TShock-Beta-${{ matrix.arch }}-Release - path: TShockLauncher/bin/Release/net6.0/${{ matrix.arch }}/publish/ + path: TShockLauncher/bin/Release/net9.0/${{ matrix.arch }}/publish/ diff --git a/.github/workflows/wiki-notify.yml b/.github/workflows/wiki-notify.yml new file mode 100644 index 00000000..835c5b40 --- /dev/null +++ b/.github/workflows/wiki-notify.yml @@ -0,0 +1,13 @@ +name: Wiki Changed Discord Notification + +on: + gollum + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - uses: 'oznu/gh-wiki-edit-discord-notification@dfc866fd048f04c239ad113eef3c6c73504d333e' + with: + discord-webhook-url: ${{ secrets.DISCORD_WEBHOOK_WIKI_EDIT }} + ignore-collaborators: false diff --git a/.vscode/launch.json b/.vscode/launch.json index a4795b3a..43386a5d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,12 +9,9 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/TShockLauncher/bin/Debug/net6.0/TShock.Run.dll", - "windows": { - "program": "${workspaceFolder}/TShockLauncher/bin/Debug/net6.0/TShock.dll", - }, + "program": "${workspaceFolder}/TShockLauncher/bin/Debug/net9.0/TShock.Server.dll", "args": [], - "cwd": "${workspaceFolder}/TShockLauncher/bin/Debug/net6.0/", + "cwd": "${workspaceFolder}/TShockLauncher/bin/Debug/net9.0/", "console": "integratedTerminal", "stopAtEntry": false }, diff --git a/.vscode/tasks.json b/.vscode/tasks.json index e8db5b18..a9081116 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -35,7 +35,7 @@ { "label": "Remote Publish", "options": { - "cwd": "TShockLauncher/bin/Debug/net6.0/linux-arm64" + "cwd": "TShockLauncher/bin/Debug/net9.0/linux-arm64" }, "command": "C:\\Program Files\\PuTTY\\pscp.exe", "type": "process", diff --git a/Dockerfile b/Dockerfile index 87024fb9..f489d46c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # TARGETPLATFORM and BUILDPLATFORM are automatically filled in by Docker buildx. # They should not be set in the global scope manually. -FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:6.0 AS builder +FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:9.0 AS builder # Copy build context WORKDIR /TShock @@ -27,10 +27,14 @@ RUN \ *) echo "Error: Unsupported platform ${TARGETPLATFORM}" && exit 1 \ ;; \ esac && \ - dotnet publish -o output/ -r "${ARCH}" -v m -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false + dotnet publish -o output/ -r "${ARCH}" -v m -f net9.0 -c Release -p:PublishSingleFile=true --self-contained false # Runtime image -FROM --platform=${TARGETPLATFORM} mcr.microsoft.com/dotnet/runtime:6.0 AS runner +FROM mcr.microsoft.com/dotnet/runtime:9.0 AS linux_base +FROM mcr.microsoft.com/dotnet/runtime:9.0-nanoserver-ltsc2022 AS windows_base + +FROM ${TARGETOS}_base AS final + WORKDIR /server COPY --from=builder /TShock/TShockLauncher/output ./ diff --git a/README.md b/README.md index 0369df53..bf738a07 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,9 @@ If you want to run the `TShockLauncher` (which runs a server), run: To produce a packaged release (suitable for distribution), run: 1. `cd TShockLauncher` -1. `dotnet publish -r win-x64 -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false` +1. `dotnet publish -r win-x64 -f net9.0 -c Release -p:PublishSingleFile=true --self-contained false` -Note that in this example, you'd be building for `win-x64`. You can build for `win-x64`, `osx-x64`, `linux-x64`, `linux-arm64`, `linux-arm`. Your release will be in the `TShockLauncher/bin/Release/net6.0/` folder under the architecture you specified. +Note that in this example, you'd be building for `win-x64`. You can build for `win-x64`, `osx-x64`, `linux-x64`, `linux-arm64`, `linux-arm`. Your release will be in the `TShockLauncher/bin/Release/net9.0/` folder under the architecture you specified. ### Working with Terraria diff --git a/README_cn.md b/README_cn.md index 65c5eba6..a31c9345 100644 --- a/README_cn.md +++ b/README_cn.md @@ -30,9 +30,9 @@ TShock是为泰拉瑞亚服务器和社区开发的一个工具箱。这个工 如果要生成打包后的发行版,运行: 1. `cd TShockLauncher` -1. `dotnet publish -r win-x64 -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false` +1. `dotnet publish -r win-x64 -f net9.0 -c Release -p:PublishSingleFile=true --self-contained false` -注意在这个例子中你将会生成`win-x64`架构的版本。你也可以生成`win-x64`、`osx-x64`、`linux-x64`、`linux-arm64`、`linux-arm`的版本。你可以在`TShockLauncher/bin/Release/net6.0/`文件夹下对应架构的文件夹里找到生成后的发行版。 +注意在这个例子中你将会生成`win-x64`架构的版本。你也可以生成`win-x64`、`osx-x64`、`linux-x64`、`linux-arm64`、`linux-arm`的版本。你可以在`TShockLauncher/bin/Release/net9.0/`文件夹下对应架构的文件夹里找到生成后的发行版。 ### 跟泰拉瑞亚本体代码交互 diff --git a/TShockAPI/DB/GroupManager.cs b/TShockAPI/DB/GroupManager.cs index 4a9f8afb..44f0c994 100644 --- a/TShockAPI/DB/GroupManager.cs +++ b/TShockAPI/DB/GroupManager.cs @@ -74,6 +74,7 @@ namespace TShockAPI.DB Permissions.canchangepassword, Permissions.canlogout, Permissions.summonboss, + Permissions.spawnpets, Permissions.worldupgrades, Permissions.whisper, Permissions.wormhole, diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index bd2a113e..3ba1cea4 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -63,7 +63,7 @@ namespace TShockAPI /// VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info. public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version; /// VersionCodename - The version codename is displayed when the server starts. Inspired by software codenames conventions. - public static readonly string VersionCodename = "Stargazer"; + public static readonly string VersionCodename = "Hopefully SSC works somewhat correctly now edition"; /// SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins). public static string SavePath = "tshock"; @@ -428,8 +428,6 @@ namespace TShockAPI Hooks.AccountHooks.AccountDelete += OnAccountDelete; Hooks.AccountHooks.AccountCreate += OnAccountCreate; - On.Terraria.RemoteClient.Reset += RemoteClient_Reset; - GetDataHandlers.InitGetDataHandler(); Commands.InitCommands(); @@ -449,7 +447,7 @@ namespace TShockAPI // Initialize the AchievementManager, which is normally only done on clients. Game._achievements = new AchievementManager(); - IL.Terraria.Initializers.AchievementInitializer.Load += OnAchievementInitializerLoad; + OTAPI.Hooks.Initializers.AchievementInitializerLoad += OnAchievementInitializerLoad; // Actually call AchievementInitializer.Load, which is also normally only done on clients. AchievementInitializer.Load(); @@ -498,17 +496,9 @@ namespace TShockAPI } } - private static void RemoteClient_Reset(On.Terraria.RemoteClient.orig_Reset orig, RemoteClient client) + private static void OnAchievementInitializerLoad(object sender, OTAPI.Hooks.Initializers.AchievementInitializerLoadEventArgs args) { - client.ClientUUID = null; - orig(client); - } - - private static void OnAchievementInitializerLoad(ILContext il) - { - // Modify AchievementInitializer.Load to remove the Main.netMode == 2 check (occupies the first 4 IL instructions) - for (var i = 0; i < 4; i++) - il.Body.Instructions.RemoveAt(0); + args.ShouldLoad = true; } protected void CrashReporter_HeapshotRequesting(object sender, EventArgs e) @@ -532,7 +522,7 @@ namespace TShockAPI } SaveManager.Instance.Dispose(); - IL.Terraria.Initializers.AchievementInitializer.Load -= OnAchievementInitializerLoad; + OTAPI.Hooks.Initializers.AchievementInitializerLoad -= OnAchievementInitializerLoad; ModuleManager.Dispose(); @@ -1469,8 +1459,8 @@ namespace TShockAPI Hooks.PlayerHooks.OnPlayerLogout(tsplr); } - // The last player will leave after this hook is executed. - if (Utils.GetActivePlayerCount() == 1) + // If this is the last player online, update the console title and save the world if needed + if (Utils.GetActivePlayerCount() == 0) { if (Config.Settings.SaveWorldOnLastPlayerExit) SaveManager.Instance.SaveWorld(); diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index a01bb022..82fc5aec 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -3,7 +3,7 @@ Library - net6.0 + net9.0 true True - 5.2.3 + 5.2.4 TShock for Terraria Pryaxis & TShock Contributors TShockAPI - Copyright © Pryaxis & TShock Contributors 2011-2023 + Copyright © Pryaxis & TShock Contributors 2011-2025 True GPL-3.0-or-later @@ -33,9 +33,9 @@ - - - + + + diff --git a/TShockInstaller/Program.cs b/TShockInstaller/Program.cs index 03606b51..09ad8bf6 100644 --- a/TShockInstaller/Program.cs +++ b/TShockInstaller/Program.cs @@ -27,11 +27,11 @@ if (arch is null) string? url = null; if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - url = $"https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.11/dotnet-runtime-6.0.11-osx-{arch}.tar.gz"; + url = $"https://dotnetcli.azureedge.net/dotnet/Runtime/9.0.0/dotnet-runtime-9.0.0-osx-{arch}.tar.gz"; else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - url = $"https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.11/dotnet-runtime-6.0.11-win-{arch}.zip"; + url = $"https://dotnetcli.azureedge.net/dotnet/Runtime/9.0.0/dotnet-runtime-9.0.0-win-{arch}.zip"; else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - url = $"https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.11/dotnet-runtime-6.0.11-linux-{arch}.tar.gz"; + url = $"https://dotnetcli.azureedge.net/dotnet/Runtime/9.0.0/dotnet-runtime-9.0.0-linux-{arch}.tar.gz"; if(url is null) { diff --git a/TShockInstaller/TShockInstaller.csproj b/TShockInstaller/TShockInstaller.csproj index ac3bfff4..bae99fa0 100644 --- a/TShockInstaller/TShockInstaller.csproj +++ b/TShockInstaller/TShockInstaller.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net9.0 enable enable 5.0.0 diff --git a/TShockLauncher.Tests/GroupTests.cs b/TShockLauncher.Tests/GroupTests.cs index 5eff651f..01a058ca 100644 --- a/TShockLauncher.Tests/GroupTests.cs +++ b/TShockLauncher.Tests/GroupTests.cs @@ -21,17 +21,17 @@ public class GroupTests groups.AddPermissions("test", new() { "abc" }); var hasperm = groups.GetGroupByName("test").Permissions.Contains("abc"); - Assert.IsTrue(hasperm); + Assert.That(hasperm, Is.True); groups.DeletePermissions("test", new() { "abc" }); hasperm = groups.GetGroupByName("test").Permissions.Contains("abc"); - Assert.IsFalse(hasperm); + Assert.That(hasperm, Is.False); groups.DeleteGroup("test"); var g = groups.GetGroupByName("test"); - Assert.IsNull(g); + Assert.That(g, Is.Null); } } diff --git a/TShockLauncher.Tests/ServerInitTests.cs b/TShockLauncher.Tests/ServerInitTests.cs index dc5f6731..2ab72bd1 100644 --- a/TShockLauncher.Tests/ServerInitTests.cs +++ b/TShockLauncher.Tests/ServerInitTests.cs @@ -14,20 +14,21 @@ public class ServerInitTests public void EnsureBoots() { var are = new AutoResetEvent(false); - On.Terraria.Main.hook_DedServ cb = (On.Terraria.Main.orig_DedServ orig, Terraria.Main instance) => + HookEvents.HookDelegate cb = (instance, args) => { + args.ContinueExecution = false; are.Set(); Debug.WriteLine("Server init process successful"); }; - On.Terraria.Main.DedServ += cb; + HookEvents.Terraria.Main.DedServ += cb; - new Thread(() => TerrariaApi.Server.Program.Main(new string[] { })).Start(); + new Thread(() => TerrariaApi.Server.Program.Main([])).Start(); var hit = are.WaitOne(TimeSpan.FromSeconds(10)); - On.Terraria.Main.DedServ -= cb; + HookEvents.Terraria.Main.DedServ -= cb; - Assert.IsTrue(hit); + Assert.That(hit, Is.True); } } diff --git a/TShockLauncher.Tests/TShockLauncher.Tests.csproj b/TShockLauncher.Tests/TShockLauncher.Tests.csproj index 6267eb1e..9be3968a 100644 --- a/TShockLauncher.Tests/TShockLauncher.Tests.csproj +++ b/TShockLauncher.Tests/TShockLauncher.Tests.csproj @@ -1,17 +1,20 @@ - net6.0 + net9.0 enable false - - - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/TShockLauncher/Program.cs b/TShockLauncher/Program.cs index 0163cc2d..0bd305fc 100644 --- a/TShockLauncher/Program.cs +++ b/TShockLauncher/Program.cs @@ -47,20 +47,11 @@ if (File.Exists("TerrariaServer.exe")) return 1; } -if (args.Length > 0 && args[0].ToLower() == "plugins") -{ - var items = args.ToList(); - items.RemoveAt(0); - await NugetCLI.Main(items); - return 0; -} - - Dictionary _cache = new Dictionary(); System.Runtime.Loader.AssemblyLoadContext.Default.Resolving += Default_Resolving; -return Start(); +return await StartAsync(); /// /// Resolves a module from the ./bin folder, either with a .dll by preference or .exe @@ -71,6 +62,7 @@ Assembly? Default_Resolving(System.Runtime.Loader.AssemblyLoadContext arg1, Asse if (_cache.TryGetValue(arg2.Name, out Assembly? asm) && asm is not null) return asm; var loc = Path.Combine(AppContext.BaseDirectory, "bin", arg2.Name + ".dll"); + if (File.Exists(loc)) asm = arg1.LoadFromAssemblyPath(loc); @@ -88,8 +80,16 @@ Assembly? Default_Resolving(System.Runtime.Loader.AssemblyLoadContext arg1, Asse /// Initiates the TSAPI server. /// /// This method exists so that the resolver can attach before TSAPI needs its dependencies. -int Start() +async Task StartAsync() { + if (args.Length > 0 && args[0].ToLower() == "plugins") + { + var items = args.ToList(); + items.RemoveAt(0); + await TShockPluginManager.NugetCLI.Main(items); + return 0; + } + TerrariaApi.Server.Program.Main(args); return 0; } diff --git a/TShockLauncher/TShockLauncher.csproj b/TShockLauncher/TShockLauncher.csproj index fbe428bb..875e6287 100644 --- a/TShockLauncher/TShockLauncher.csproj +++ b/TShockLauncher/TShockLauncher.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net9.0 enable enable TShock.Server @@ -30,22 +30,22 @@ - - - - + + + + - - + + PreserveNewest true - + PreserveNewest true - + PreserveNewest true @@ -91,7 +91,13 @@ - + + + + + + + diff --git a/TShockPluginManager/Nuget.cs b/TShockPluginManager/Nuget.cs index 1d00fe1c..8ba73338 100644 --- a/TShockPluginManager/Nuget.cs +++ b/TShockPluginManager/Nuget.cs @@ -52,7 +52,7 @@ namespace TShockPluginManager public Nugetter() { FrameworkReducer = new FrameworkReducer(); - NuGetFramework = NuGetFramework.ParseFolder("net6.0"); + NuGetFramework = NuGetFramework.ParseFolder("net9.0"); Settings = NuGet.Configuration.Settings.LoadDefaultSettings(root: null); PathContext = NuGetPathContext.Create(Settings); PackageSourceProvider = new PackageSourceProvider(Settings); diff --git a/TShockPluginManager/TShockPluginManager.csproj b/TShockPluginManager/TShockPluginManager.csproj index 1d53f320..7ad2429f 100644 --- a/TShockPluginManager/TShockPluginManager.csproj +++ b/TShockPluginManager/TShockPluginManager.csproj @@ -1,18 +1,18 @@ - net6.0 + net9.0 enable enable - - - + + + - - + + diff --git a/TerrariaServerAPI b/TerrariaServerAPI index d4bb7e3a..29dc46f4 160000 --- a/TerrariaServerAPI +++ b/TerrariaServerAPI @@ -1 +1 @@ -Subproject commit d4bb7e3a21e875cfeb23bcf5cf847c85d9470ccf +Subproject commit 29dc46f4e1c7b41f9e88e41187dd8d5b208e257a diff --git a/appveyor.yml b/appveyor.yml index a96c0049..7b71d778 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,5 +9,5 @@ build_script: dotnet test artifacts: -- path: ./TShockLauncher/bin/Debug/net6.0 +- path: ./TShockLauncher/bin/Debug/net9.0 name: TShockAVDebug