Skip to content

Commit

Permalink
Add permission for Moondial and unrecognized SFX
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthri committed Apr 9, 2024
1 parent 5d585bb commit ad36e7e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
46 changes: 43 additions & 3 deletions TShockAPI/GetDataHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3469,8 +3469,12 @@ private static bool HandleSpecial(GetDataHandlerArgs args)
args.Player.Spawn(PlayerSpawnContext.RecallFromItem);
return true;
}

if (type == 3)
else if (type == 2)
{
// Plays SoundID.Item1
return false;
}
else if (type == 3)
{
if (!args.Player.HasPermission(Permissions.usesundial))
{
Expand All @@ -3490,6 +3494,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 Expand Up @@ -3785,7 +3825,7 @@ private static bool HandleTeleport(GetDataHandlerArgs args)
if (type == 0 && !args.Player.HasPermission(Permissions.rod))
{
TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleport rejected rod type {0} {1}", args.Player.Name, type));
args.Player.SendErrorMessage(GetString("You do not have permission to teleport using items.")); // Was going to write using RoD but Hook of Disonnance and Potion of Return both use the same teleport packet as RoD.
args.Player.SendErrorMessage(GetString("You do not have permission to teleport using items.")); // Was going to write using RoD but Hook of Disonnance and Potion of Return both use the same teleport packet as RoD.
args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y); // Suggest renaming rod permission unless someone plans to add separate perms for the other 2 tp items.
return true;
}
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

0 comments on commit ad36e7e

Please sign in to comment.