Merge pull request #3067 from sgkoishi/fix523

Fix some confusion introduced by 98eed42 and b184133
This commit is contained in:
Lucas Nicodemus 2025-03-15 17:31:25 +09:00 committed by GitHub
commit 695cf67c41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 5 deletions

View file

@ -79,7 +79,7 @@ namespace TShockAPI.DB
public PlayerData GetPlayerData(TSPlayer player, int acctid) public PlayerData GetPlayerData(TSPlayer player, int acctid)
{ {
PlayerData playerData = new PlayerData(false); PlayerData playerData = new PlayerData(true);
try try
{ {

View file

@ -74,6 +74,7 @@ namespace TShockAPI.DB
Permissions.canchangepassword, Permissions.canchangepassword,
Permissions.canlogout, Permissions.canlogout,
Permissions.summonboss, Permissions.summonboss,
Permissions.worldupgrades,
Permissions.whisper, Permissions.whisper,
Permissions.wormhole, Permissions.wormhole,
Permissions.canpaint, Permissions.canpaint,

View file

@ -3619,8 +3619,9 @@ namespace TShockAPI
return false; return false;
} }
private static readonly int[] invasions = { -1, -2, -3, -4, -5, -6, -7, -8, -10, -11 }; private static readonly int[] invasions = { -1, -2, -3, -4, -5, -6, -7, -8, -10 };
private static readonly int[] pets = { -12, -13, -14, -15 }; private static readonly int[] pets = { -12, -13, -14, -15 };
private static readonly int[] upgrades = { -11, -17, -18 };
private static bool HandleSpawnBoss(GetDataHandlerArgs args) private static bool HandleSpawnBoss(GetDataHandlerArgs args)
{ {
if (args.Player.IsBouncerThrottled()) if (args.Player.IsBouncerThrottled())
@ -3632,8 +3633,8 @@ namespace TShockAPI
var plr = args.Data.ReadInt16(); var plr = args.Data.ReadInt16();
var thingType = args.Data.ReadInt16(); var thingType = args.Data.ReadInt16();
var isKnownBoss = thingType > 0 && thingType < Terraria.ID.NPCID.Count && NPCID.Sets.MPAllowedEnemies[thingType]; var isKnownBoss = (thingType > 0 && thingType < Terraria.ID.NPCID.Count && NPCID.Sets.MPAllowedEnemies[thingType]) || thingType == -16;
if ((isKnownBoss || thingType == -16) && !args.Player.HasPermission(Permissions.summonboss)) if (isKnownBoss && !args.Player.HasPermission(Permissions.summonboss))
{ {
TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpawnBoss rejected boss {0} {1}", args.Player.Name, thingType)); TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpawnBoss rejected boss {0} {1}", args.Player.Name, thingType));
args.Player.SendErrorMessage(GetString("You do not have permission to summon bosses.")); args.Player.SendErrorMessage(GetString("You do not have permission to summon bosses."));
@ -3654,6 +3655,13 @@ namespace TShockAPI
return true; return true;
} }
if (upgrades.Contains(thingType) && !args.Player.HasPermission(Permissions.worldupgrades))
{
TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpawnBoss rejected upgrade {0} {1}", args.Player.Name, thingType));
args.Player.SendErrorMessage(GetString("You do not have permission to use permanent boosters."));
return true;
}
if (plr != args.Player.Index) if (plr != args.Player.Index)
return true; return true;
@ -3720,7 +3728,7 @@ namespace TShockAPI
break; break;
} }
if (NPCID.Sets.MPAllowedEnemies[thingType]) if (thingType < 0 || isKnownBoss)
{ {
if (TShock.Config.Settings.AnonymousBossInvasions) if (TShock.Config.Settings.AnonymousBossInvasions)
TShock.Utils.SendLogs(thing, Color.PaleVioletRed, args.Player); TShock.Utils.SendLogs(thing, Color.PaleVioletRed, args.Player);

View file

@ -346,9 +346,13 @@ namespace TShockAPI
[Description("User can change the homes of NPCs.")] [Description("User can change the homes of NPCs.")]
public static readonly string movenpc = "tshock.world.movenpc"; public static readonly string movenpc = "tshock.world.movenpc";
[Obsolete("Feature no longer available.")]
[Description("User can convert hallow into corruption and vice-versa.")] [Description("User can convert hallow into corruption and vice-versa.")]
public static readonly string converthardmode = "tshock.world.converthardmode"; public static readonly string converthardmode = "tshock.world.converthardmode";
[Description("User can use world-based permanent boosters like Advanced Combat Techniques")]
public static readonly string worldupgrades = "tshock.world.worldupgrades";
[Description("User can force the server to Halloween mode.")] [Description("User can force the server to Halloween mode.")]
public static readonly string halloween = "tshock.world.sethalloween"; public static readonly string halloween = "tshock.world.sethalloween";