Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add permission for Moondial and unrecognized SFX #3027

Open
wants to merge 6 commits into
base: general-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 51 additions & 7 deletions TShockAPI/GetDataHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3462,15 +3462,23 @@ private static bool HandleSpecial(GetDataHandlerArgs args)
if (OnNPCSpecial(args.Player, args.Data, id, type))
return true;

if (type == 1 && TShock.Config.Settings.DisableDungeonGuardian)
if (type == 1)
{
TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpecial rejected type 1 for {0}", args.Player.Name));
args.Player.SendMessage(GetString("The Dungeon Guardian returned you to your spawn point."), Color.Purple);
args.Player.Spawn(PlayerSpawnContext.RecallFromItem);
return true;
}
if (!args.Player.HasPermission(Permissions.summonboss))
{
args.Player.SendErrorMessage(GetString("You do not have permission to summon the Skeletron."));
TShock.Log.ConsoleDebug(GetString($"GetDataHandlers / HandleNpcStrike rejected Skeletron summon from {args.Player.Name}"));
return true;
}

if (type == 3)
return false;
}
else if (type == 2)
{
// Plays SoundID.Item1
return false;
}
else if (type == 3)
{
if (!args.Player.HasPermission(Permissions.usesundial))
{
Expand All @@ -3490,6 +3498,42 @@ private static bool HandleSpecial(GetDataHandlerArgs args)
return true;
}
}
else if (type == 4)
{
// Big Mimic Spawn Smoke
return false;
}
else if (type == 5)
{
// Register Kill for Torch God in Bestiary
return false;
}
else if (type == 6)
{
if (!args.Player.HasPermission(Permissions.usemoondial))
{
TShock.Log.ConsoleDebug(GetString($"GetDataHandlers / HandleSpecial rejected enchanted moondial permission {args.Player.Name}"));
args.Player.SendErrorMessage(GetString("You do not have permission to use the Enchanted Moondial."));
return true;
}
else if (TShock.Config.Settings.ForceTime != "normal")
{
TShock.Log.ConsoleDebug(GetString($"GetDataHandlers / HandleSpecial rejected enchanted moondial permission (ForceTime) {args.Player.Name}"));
if (!args.Player.HasPermission(Permissions.cfgreload))
{
args.Player.SendErrorMessage(GetString("You cannot use the Enchanted Moondial because time is stopped."));
}
else
args.Player.SendErrorMessage(GetString("You must set ForceTime to normal via config to use the Enchanted Moondial."));
return true;
}
}
else if (!args.Player.HasPermission($"tshock.specialeffects.{type}"))
{
args.Player.SendErrorMessage(GetString("You do not have permission to use this effect."));
TShock.Log.ConsoleError(GetString("Unrecognized special effect (Packet 51). Please report this to the TShock developers."));
return true;
}

return false;
}
Expand Down
3 changes: 3 additions & 0 deletions TShockAPI/Permissions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ public static class Permissions
[Description("Player can use the Enchanted Sundial item.")]
public static readonly string usesundial = "tshock.world.time.usesundial";

[Description("Player can use the Enchanted Moondial item.")]
public static readonly string usemoondial = "tshock.world.time.usemoondial";

[Description("User can grow plants.")]
public static readonly string grow = "tshock.world.grow";

Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ Use past tense when adding new entries; sign your name off when you add or chang
* Fixed typo in `/gbuff`. (@sgkoishi, #2955)
* Rewrote the `.dockerignore` file into a denylist. (@timschumi)
* Added CI for Docker images. (@timschumi)
* Added a new permission, `tshock.world.time.usemoondial`, for regulating use of Enchanted Moondial. (@Arthri)
* Added a set of new permissions, `tshock.specialeffects.{type}`, for regulating use of new special effects(Packet 51) which are not yet recognized by TShock. (@Arthri)
* Added check for `tshock.npc.summonboss` permission for Skeletron summoning. (@Arthri)
* Fixed `DisableDungeonGuardian` disabling Skeletron summon instead. The config option is useless as of writing. (@Arthri)

## TShock 5.2
* An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK)
Expand Down
Loading