Merge branch 'general-devel' into netitem-changes

This commit is contained in:
Lucas Nicodemus 2025-01-26 09:02:51 +09:00 committed by GitHub
commit 18062c55e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 86 additions and 69 deletions

View file

@ -5,6 +5,10 @@ on: [push, pull_request]
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
attestations: write
id-token: write
packages: write
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -14,12 +18,43 @@ jobs:
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
- name: Set up buildx - name: Set up buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate version information
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag,enable=${{ !startsWith(github.ref, 'refs/tags/v') }}
type=ref,event=pr
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
flavor: |
latest=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Build image - name: Build image
uses: docker/build-push-action@v5 id: build
uses: docker/build-push-action@v6
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7,windows/amd64 platforms: linux/amd64,linux/arm64,linux/arm/v7,windows/amd64
push: false push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
pull: true pull: true
cache-from: type=gha, scope=${{ github.workflow }} cache-from: type=gha, scope=${{ github.workflow }}
cache-to: type=gha, scope=${{ github.workflow }} cache-to: type=gha, scope=${{ github.workflow }}
- name: Generate build provenance attestation
if: ${{ github.event_name != 'pull_request' }}
uses: actions/attest-build-provenance@v2
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: true

View file

@ -424,7 +424,7 @@ namespace TShockAPI
}; };
PlayerAddBuffWhitelist[BuffID.BrainOfConfusionBuff] = new BuffLimit PlayerAddBuffWhitelist[BuffID.BrainOfConfusionBuff] = new BuffLimit
{ {
MaxTicks = 240, MaxTicks = 60 * 4,
CanBeAddedWithoutHostile = true, CanBeAddedWithoutHostile = true,
CanOnlyBeAppliedToSender = true CanOnlyBeAppliedToSender = true
}; };
@ -434,6 +434,12 @@ namespace TShockAPI
CanBeAddedWithoutHostile = true, CanBeAddedWithoutHostile = true,
CanOnlyBeAppliedToSender = true CanOnlyBeAppliedToSender = true
}; };
PlayerAddBuffWhitelist[BuffID.ParryDamageBuff] = new BuffLimit
{
MaxTicks = 60 * 5,
CanBeAddedWithoutHostile = true,
CanOnlyBeAppliedToSender = true
};
#endregion Whitelist #endregion Whitelist
} }
@ -1878,7 +1884,7 @@ namespace TShockAPI
return; return;
} }
if (TShock.Players[id] == null) if (TShock.Players[id] == null || !TShock.Players[id].Active)
{ {
TShock.Log.ConsoleDebug(GetString( TShock.Log.ConsoleDebug(GetString(
"Bouncer / OnPlayerBuff rejected {0} ({1}) applying buff {2} to {3} for {4} ticks: target is null", args.Player.Name, "Bouncer / OnPlayerBuff rejected {0} ({1}) applying buff {2} to {3} for {4} ticks: target is null", args.Player.Name,
@ -2081,7 +2087,7 @@ namespace TShockAPI
short amount = args.Amount; short amount = args.Amount;
byte plr = args.TargetPlayerIndex; byte plr = args.TargetPlayerIndex;
if (amount <= 0 || Main.player[plr] == null || !Main.player[plr].active) if (amount <= 0 || TShock.Players[plr] == null || !TShock.Players[plr].Active)
{ {
TShock.Log.ConsoleDebug(GetString("Bouncer / OnHealOtherPlayer rejected null checks")); TShock.Log.ConsoleDebug(GetString("Bouncer / OnHealOtherPlayer rejected null checks"));
args.Handled = true; args.Handled = true;
@ -2589,7 +2595,7 @@ namespace TShockAPI
byte direction = args.Direction; byte direction = args.Direction;
PlayerDeathReason reason = args.PlayerDeathReason; PlayerDeathReason reason = args.PlayerDeathReason;
if (id >= Main.maxPlayers || TShock.Players[id] == null) if (id >= Main.maxPlayers || TShock.Players[id] == null || !TShock.Players[id].Active)
{ {
TShock.Log.ConsoleDebug(GetString("Bouncer / OnPlayerDamage rejected null check")); TShock.Log.ConsoleDebug(GetString("Bouncer / OnPlayerDamage rejected null check"));
args.Handled = true; args.Handled = true;

View file

@ -3070,12 +3070,12 @@ namespace TShockAPI
args.Player.SendErrorMessage(GetString("You do not have permission to teleport all other players.")); args.Player.SendErrorMessage(GetString("You do not have permission to teleport all other players."));
return; return;
} }
for (int i = 0; i < Main.maxPlayers; i++) foreach (var player in TShock.Players)
{ {
if (Main.player[i].active && (Main.player[i] != args.TPlayer)) if (player != null && player.Active && player.Index != args.Player.Index)
{ {
if (TShock.Players[i].Teleport(args.TPlayer.position.X, args.TPlayer.position.Y)) if (player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y))
TShock.Players[i].SendSuccessMessage(GetString("You were teleported to {0}.", args.Player.Name)); player.SendSuccessMessage(GetString("You were teleported to {0}.", args.Player.Name));
} }
} }
args.Player.SendSuccessMessage(GetString("Teleported everyone to yourself.")); args.Player.SendSuccessMessage(GetString("Teleported everyone to yourself."));
@ -4622,21 +4622,22 @@ namespace TShockAPI
{ {
if (args.Parameters.Count != 1) if (args.Parameters.Count != 1)
{ {
args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}wind <speed>.", Specifier)); args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}wind <speed in mph>.", Specifier));
return; return;
} }
int speed; float mph;
if (!int.TryParse(args.Parameters[0], out speed) || speed * 100 < 0) if (!float.TryParse(args.Parameters[0], out mph) || mph is < -40f or > 40f)
{ {
args.Player.SendErrorMessage(GetString("Invalid wind speed.")); args.Player.SendErrorMessage(GetString("Invalid wind speed (must be between -40 and 40)."));
return; return;
} }
float speed = mph / 50f; // -40 to 40 mph -> -0.8 to 0.8
Main.windSpeedCurrent = speed; Main.windSpeedCurrent = speed;
Main.windSpeedTarget = speed; Main.windSpeedTarget = speed;
TSPlayer.All.SendData(PacketTypes.WorldInfo); TSPlayer.All.SendData(PacketTypes.WorldInfo);
TSPlayer.All.SendInfoMessage(GetString("{0} changed the wind speed to {1}.", args.Player.Name, speed)); TSPlayer.All.SendInfoMessage(GetString("{0} changed the wind speed to {1}mph.", args.Player.Name, mph));
} }
#endregion Time/PvpFun Commands #endregion Time/PvpFun Commands

View file

@ -351,7 +351,6 @@ namespace Rests
{ {
str = string.Format("{0}({1});", jsonp, str); str = string.Format("{0}({1});", jsonp, str);
} }
e.Response.Connection.Type = ConnectionType.Close;
e.Response.ContentType = new ContentTypeHeader("application/json; charset=utf-8"); e.Response.ContentType = new ContentTypeHeader("application/json; charset=utf-8");
e.Response.Add(serverHeader); e.Response.Add(serverHeader);
var bytes = Encoding.UTF8.GetBytes(str); var bytes = Encoding.UTF8.GetBytes(str);

View file

@ -402,7 +402,7 @@ namespace TShockAPI
{"serverversion", Main.versionNumber}, {"serverversion", Main.versionNumber},
{"tshockversion", TShock.VersionNum}, {"tshockversion", TShock.VersionNum},
{"port", TShock.Config.Settings.ServerPort}, {"port", TShock.Config.Settings.ServerPort},
{"playercount", Main.player.Where(p => null != p && p.active).Count()}, {"playercount", TShock.Utils.GetActivePlayerCount()},
{"maxplayers", TShock.Config.Settings.MaxSlots}, {"maxplayers", TShock.Config.Settings.MaxSlots},
{"world", (TShock.Config.Settings.UseServerName ? TShock.Config.Settings.ServerName : Main.worldName)}, {"world", (TShock.Config.Settings.UseServerName ? TShock.Config.Settings.ServerName : Main.worldName)},
{"uptime", (DateTime.Now - System.Diagnostics.Process.GetCurrentProcess().StartTime).ToString(@"d'.'hh':'mm':'ss")}, {"uptime", (DateTime.Now - System.Diagnostics.Process.GetCurrentProcess().StartTime).ToString(@"d'.'hh':'mm':'ss")},
@ -944,8 +944,8 @@ namespace TShockAPI
[Token] [Token]
private object PlayerList(RestRequestArgs args) private object PlayerList(RestRequestArgs args)
{ {
var activeplayers = Main.player.Where(p => null != p && p.active).ToList(); var activeplayers = TShock.Players.Where(p => null != p && p.Active).Select(p => p.Name);
return new RestObject() { { "players", string.Join(", ", activeplayers.Select(p => p.name)) } }; return new RestObject() { { "players", string.Join(", ", activeplayers) } };
} }
[Description("Fetches detailed user information on all connected users, and can be filtered by specifying a key value pair filter users where the key is a field and the value is a users field value.")] [Description("Fetches detailed user information on all connected users, and can be filtered by specifying a key value pair filter users where the key is a field and the value is a users field value.")]

View file

@ -34,7 +34,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" /> <PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="GetText.NET" Version="1.7.14" /> <PackageReference Include="GetText.NET" Version="1.7.14" />
<PackageReference Include="MySql.Data" Version="8.0.31" /> <PackageReference Include="MySql.Data" Version="8.4.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.11" /> <PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.11" />
</ItemGroup> </ItemGroup>

View file

@ -172,7 +172,7 @@ namespace TShockAPI
foreach (TSPlayer player in TShock.Players) foreach (TSPlayer player in TShock.Players)
{ {
if (player != null && player != excludedPlayer && player.Active && player.HasPermission(Permissions.logs) && if (player != null && player != excludedPlayer && player.Active && player.HasPermission(Permissions.logs) &&
player.DisplayLogs && TShock.Config.Settings.DisableSpewLogs == false) player.DisplayLogs && !TShock.Config.Settings.DisableSpewLogs)
player.SendMessage(log, color); player.SendMessage(log, color);
} }
} }
@ -183,7 +183,7 @@ namespace TShockAPI
/// <returns>The number of active players on the server.</returns> /// <returns>The number of active players on the server.</returns>
public int GetActivePlayerCount() public int GetActivePlayerCount()
{ {
return Main.player.Where(p => null != p && p.active).Count(); return TShock.Players.Count(p => null != p && p.Active);
} }
//Random should not be generated in a method //Random should not be generated in a method

View file

@ -30,7 +30,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" /> <PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="MySql.Data" Version="8.0.31" /> <PackageReference Include="MySql.Data" Version="8.4.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.11" /> <PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.11" />
<PackageReference Include="ModFramework" Version="1.1.7" GeneratePathProperty="true" /> <!-- only used to extract out to ./bin. --> <PackageReference Include="ModFramework" Version="1.1.7" GeneratePathProperty="true" /> <!-- only used to extract out to ./bin. -->
<PackageReference Include="GetText.NET" Version="1.7.14" /> <!-- only used to extract out to ./bin. --> <PackageReference Include="GetText.NET" Version="1.7.14" /> <!-- only used to extract out to ./bin. -->

View file

@ -79,12 +79,15 @@ Use past tense when adding new entries; sign your name off when you add or chang
## Upcoming changes ## Upcoming changes
* Fixed `/dump-reference-data` mutate the command names. (#2943, @sgkoishi) * Fixed `/dump-reference-data` mutate the command names. (#2943, @sgkoishi)
* You know the drill * Added `ParryDamageBuff` (Striking Moment with Brand of the Inferno and shield) for player, updated `CursedInferno` buff for NPC (@sgkoishi, #3005)
* Changed the use of `Player.active` to `TSPlayer.Active` for consistency. (@sgkoishi, #2939)
* Fix typo in config for IP bans. (@redchess64) * Fix typo in config for IP bans. (@redchess64)
* Updated `TShockAPI.NetItem` (@AgaSpace): * Updated `TShockAPI.NetItem` (@AgaSpace):
* Added constructor overload with parameter `Terraria.Item`. * Added constructor overload with parameter `Terraria.Item`.
* Added the `ToItem` method to get a copy of `Terraria.Item`. * Added the `ToItem` method to get a copy of `Terraria.Item`.
* In the constructor `stack` and `prefix` are now optional parameters. * In the constructor `stack` and `prefix` are now optional parameters.
* Fixed unable to transfer long response body for REST API. (@sgkoishi, #2925)
* Fixed the `/wind` command not being very helpful. (@punchready)
## TShock 5.2.1 ## TShock 5.2.1
* Updated `TSPlayer.GodMode`. (@AgaSpace) * Updated `TSPlayer.GodMode`. (@AgaSpace)
@ -100,6 +103,7 @@ Use past tense when adding new entries; sign your name off when you add or chang
* Fixed bug where when the `UseSqlLogs` config property is true, an empty log file would still get created. (@ZakFahey) * Fixed bug where when the `UseSqlLogs` config property is true, an empty log file would still get created. (@ZakFahey)
* Fixed typo in `/gbuff`. (@sgkoishi, #2955) * Fixed typo in `/gbuff`. (@sgkoishi, #2955)
## TShock 5.2 ## TShock 5.2
* An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK)
* Corrected and updated deserialization of the following packets (@ATFGK): * Corrected and updated deserialization of the following packets (@ATFGK):
@ -132,7 +136,6 @@ Use past tense when adding new entries; sign your name off when you add or chang
* Relaxed custom death message restrictions to allow Inferno potions in PvP. (@drunderscore) * Relaxed custom death message restrictions to allow Inferno potions in PvP. (@drunderscore)
* Allowed Flower Boots to place Ash Flowers on Ash Grass blocks. (@punchready) * Allowed Flower Boots to place Ash Flowers on Ash Grass blocks. (@punchready)
* Removed unnecessary range check that artifically shortened quick stack reach. (@boddyn, #2885, @bcat) * Removed unnecessary range check that artifically shortened quick stack reach. (@boddyn, #2885, @bcat)
* Re-wrote tile rect handling from scratch, fixing a certain exploitable flaw in the old code and significantly reducing the potential exploit surface, potentially even down to zero. (@punchready)
## TShock 5.1.3 ## TShock 5.1.3
* Added support for Terraria 1.4.4.9 via OTAPI 3.1.20. (@SignatureBeef) * Added support for Terraria 1.4.4.9 via OTAPI 3.1.20. (@SignatureBeef)

View file

@ -14,32 +14,27 @@ Open ports can also be passed through using `-p <host_port>:<container_port>`.
For Example: For Example:
```bash ```bash
# Building the image using buildx and loading it into docker
docker buildx build -t tshock:latest --load .
# Running the image
docker run -p 7777:7777 -p 7878:7878 \ docker run -p 7777:7777 -p 7878:7878 \
-v /home/cider/tshock/:/tshock \ -v /home/cider/tshock/:/tshock \
-v /home/cider/.local/share/Terraria/Worlds:/worlds \ -v /home/cider/.local/share/Terraria/Worlds:/worlds \
-v /home/cider/tshock/plugins:/plugins \ -v /home/cider/tshock/plugins:/plugins \
--rm -it tshock:latest \ --rm -it ghcr.io/pryaxis/tshock:latest \
-world /worlds/backflip.wld -motd "OMFG DOCKER" -world /worlds/backflip.wld -motd "OMFG DOCKER"
``` ```
## Building for Other Platforms ## Building custom images
Using `docker buildx`, you could build [multi-platform images](https://docs.docker.com/build/building/multi-platform/) for TShock. Occasionally, it may be necessary to adjust TShock with customizations that are not included in the upstream project.
Therefore, these changes are also not available in the officially provided Docker images.
To build and load a Docker image from your local checkout, use the following `buildx` command:
For Example:
```bash ```bash
# Building the image using buildx and loading it into docker docker buildx build -t tshock:latest --load .
docker buildx build -t tshock:linux-arm64 --platform linux/arm64 --load . ```
# Running the image It is also possible to build [multi-platform images](https://docs.docker.com/build/building/multi-platform/) for TShock (e.g. an image targeting `arm64`, on a host that is not `arm64`):
docker run -p 7777:7777 -p 7878:7878 \
-v /home/cider/tshock/:/tshock \ ```bash
-v /home/cider/.local/share/Terraria/Worlds:/worlds \ docker buildx build -t tshock:linux-arm64 --platform linux/arm64 --load .
-v /home/cider/tshock/plugins:/plugins \
--rm -it tshock:linux-arm64 \
-world /worlds/backflip.wld -motd "ARM64 ftw"
``` ```

View file

@ -11,12 +11,7 @@
<body> <body>
<div id="app"></div> <div id="app"></div>
<script> <script>
window.$docsify = { window.location.replace("https://github.com/Pryaxis/TShock/wiki");
name: 'TShock for Terraria',
repo: 'pryaxis/tshock',
loadSidebar: true,
subMaxLevel: 9
}
</script> </script>
<!-- Docsify v4 --> <!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script> <script src="//cdn.jsdelivr.net/npm/docsify@4"></script>

View file

@ -1,17 +0,0 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"git-submodules": {
"enabled": true
},
"packageRules": [
{
"matchPackageNames": ["OTAPI.Upcoming", "ModFramework", "TerrariaServerAPI"],
"ignoreUnstable": "false",
"bumpVersion": "prerelease",
"groupName": "OTAPI things"
}
]
}