From 1d496059c49a010a9e98b9b1e61bf5f0dab601e4 Mon Sep 17 00:00:00 2001 From: TwistedTail <8784231+TwistedTail@users.noreply.github.com> Date: Sun, 18 Feb 2024 19:43:38 -0300 Subject: [PATCH] Updated a few serverside hooks - ACF_OnPlayerLoaded => ACF_OnLoadPlayer - ACF_IsLegal => ACF_OnCheckLegal - ACF_KEShove => ACF_OnPushEntity --- lua/acf/core/globals.lua | 4 ++-- lua/acf/core/networking/data_vars/data_vars_sv.lua | 2 +- lua/acf/core/validation_sv.lua | 2 +- lua/acf/core/version/version_sv.lua | 2 +- lua/acf/damage/damage_sv.lua | 2 +- lua/acf/damage/ke_shove_sv.lua | 2 +- lua/acf/hooks/hooks_sv.lua | 6 +++--- lua/acf/menu/operations/acf_copy.lua | 2 +- lua/tests/acf/core/validation_sv/is_legal.lua | 6 +++--- lua/tests/acf/damage/damage_sv/acf_keshove.lua | 4 ++-- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lua/acf/core/globals.lua b/lua/acf/core/globals.lua index 8a9e89141..2c1a8c4be 100644 --- a/lua/acf/core/globals.lua +++ b/lua/acf/core/globals.lua @@ -220,7 +220,7 @@ do -- Player loaded hook util.AddNetworkString("ACF_PlayerLoaded") net.Receive("ACF_PlayerLoaded", function(_, Player) - hook.Run("ACF_OnPlayerLoaded", Player) + hook.Run("ACF_OnLoadPlayer", Player) end) else hook.Add("InitPostEntity", "ACF Player Loaded", function() @@ -280,7 +280,7 @@ do -- Smoke/Wind ----------------------------------- end end) - hook.Add("ACF_OnPlayerLoaded", "ACF Send Smoke Wind", function(Player) + hook.Add("ACF_OnLoadPlayer", "ACF Send Smoke Wind", function(Player) net.Start("acf_smokewind") net.WriteFloat(ACF.SmokeWind) net.Send(Player) diff --git a/lua/acf/core/networking/data_vars/data_vars_sv.lua b/lua/acf/core/networking/data_vars/data_vars_sv.lua index 693959844..8d364b884 100644 --- a/lua/acf/core/networking/data_vars/data_vars_sv.lua +++ b/lua/acf/core/networking/data_vars/data_vars_sv.lua @@ -119,7 +119,7 @@ do -- Data syncronization end }) - hook.Add("ACF_OnPlayerLoaded", "ACF Data Var Syncronization", function(Player) + hook.Add("ACF_OnLoadPlayer", "ACF Data Var Syncronization", function(Player) -- Server data var syncronization for Key in pairs(Server) do NetworkData(Key, Player) diff --git a/lua/acf/core/validation_sv.lua b/lua/acf/core/validation_sv.lua index dd613d24d..ca3559d78 100644 --- a/lua/acf/core/validation_sv.lua +++ b/lua/acf/core/validation_sv.lua @@ -48,7 +48,7 @@ function ACF.IsLegal(Entity) if Entity.IsACFWeapon and not ACF.GunsCanFire then return false, "Cannot fire", "Firing disabled by the servers ACF settings." end if Entity.IsRack and not ACF.RacksCanFire then return false, "Cannot fire", "Firing disabled by the servers ACF settings." end - local Legal, Reason, Message, Timeout = hook.Run("ACF_IsLegal", Entity) + local Legal, Reason, Message, Timeout = hook.Run("ACF_OnCheckLegal", Entity) if not Legal then return Legal, Reason, Message, Timeout end diff --git a/lua/acf/core/version/version_sv.lua b/lua/acf/core/version/version_sv.lua index ce0623ba8..6e66c8a47 100644 --- a/lua/acf/core/version/version_sv.lua +++ b/lua/acf/core/version/version_sv.lua @@ -121,7 +121,7 @@ end do -- Client syncronization util.AddNetworkString("ACF_VersionSync") - hook.Add("ACF_OnPlayerLoaded", "ACF_VersionSync", function(Player) + hook.Add("ACF_OnLoadPlayer", "ACF_VersionSync", function(Player) local JSON = util.TableToJSON(Repos) net.Start("ACF_VersionSync") diff --git a/lua/acf/damage/damage_sv.lua b/lua/acf/damage/damage_sv.lua index bfca5ad72..b2d564dc4 100644 --- a/lua/acf/damage/damage_sv.lua +++ b/lua/acf/damage/damage_sv.lua @@ -170,7 +170,7 @@ function Damage.dealDamage(Entity, DmgResult, DmgInfo) return HitRes or DmgResult:GetBlank() end -hook.Add("ACF_OnPlayerLoaded", "ACF Render Damage", function(Player) +hook.Add("ACF_OnLoadPlayer", "ACF Render Damage", function(Player) for _, Entity in ipairs(ents.GetAll()) do local Data = Entity.ACF diff --git a/lua/acf/damage/ke_shove_sv.lua b/lua/acf/damage/ke_shove_sv.lua index a8a28574a..beafb3fcf 100644 --- a/lua/acf/damage/ke_shove_sv.lua +++ b/lua/acf/damage/ke_shove_sv.lua @@ -6,7 +6,7 @@ local Clock = ACF.Utilities.Clock function ACF.KEShove(Target, Pos, Vec, KE) if not IsValid(Target) then return end - if hook.Run("ACF_KEShove", Target, Pos, Vec, KE) == false then return end + if hook.Run("ACF_OnPushEntity", Target, Pos, Vec, KE) == false then return end local Ancestor = ACF_GetAncestor(Target) local Phys = Ancestor:GetPhysicsObject() diff --git a/lua/acf/hooks/hooks_sv.lua b/lua/acf/hooks/hooks_sv.lua index 34bce19ca..6cc2b98fb 100644 --- a/lua/acf/hooks/hooks_sv.lua +++ b/lua/acf/hooks/hooks_sv.lua @@ -5,7 +5,7 @@ Hooks.Add("ACF_Base_Server", function(Gamemode) --- Called when the player has properly loaded onto the server. -- It's possible to use network messages in this hook, unlike PlayerInitialSpawn. -- @param Player The player entity that just finished loading. - function Gamemode:ACF_OnPlayerLoaded() + function Gamemode:ACF_OnLoadPlayer() end --- Called when the bullet will attempt to use the default flight behavior @@ -24,7 +24,7 @@ Hooks.Add("ACF_Base_Server", function(Gamemode) -- @return The reason why the entity is illegal. Not required if legal. -- @return A short explanation on why the entity is illegal. Not required if legal. -- @return Optionally, the amount of time in seconds the entity will remain illegal for. Not required if legal. - function Gamemode:ACF_IsLegal() + function Gamemode:ACF_OnCheckLegal() return true end @@ -76,7 +76,7 @@ Hooks.Add("ACF_Base_Server", function(Gamemode) -- @param Direction The direction in which the entity is attempting to be pushed. -- @param Energy The kinetic energy that's attempting to be applied to the entity. -- @return True if the entity should be pushed by kinetic energy, false otherwise. - function Gamemode:ACF_KEShove() + function Gamemode:ACF_OnPushEntity() return true end diff --git a/lua/acf/menu/operations/acf_copy.lua b/lua/acf/menu/operations/acf_copy.lua index e8e5597b6..2af2b36a8 100644 --- a/lua/acf/menu/operations/acf_copy.lua +++ b/lua/acf/menu/operations/acf_copy.lua @@ -24,7 +24,7 @@ if SERVER then DisabledData[Data] = State end) - hook.Add("ACF_OnPlayerLoaded", "ACF Copy Data", function(Player) + hook.Add("ACF_OnLoadPlayer", "ACF Copy Data", function(Player) CopiedData[Player] = {} Disabled[Player] = {} end) diff --git a/lua/tests/acf/core/validation_sv/is_legal.lua b/lua/tests/acf/core/validation_sv/is_legal.lua index f13c7a8ac..2ea219f63 100644 --- a/lua/tests/acf/core/validation_sv/is_legal.lua +++ b/lua/tests/acf/core/validation_sv/is_legal.lua @@ -154,9 +154,9 @@ return { }, { - name = "Is not Legal when ACF_IsLegal hook returns", + name = "Is not Legal when ACF_OnCheckLegal hook returns", func = function( State ) - hook.Add( "ACF_IsLegal", "TestFailure", function() + hook.Add( "ACF_OnCheckLegal", "TestFailure", function() return false, "Test reason", "Test message", "Test timeout" end ) @@ -169,7 +169,7 @@ return { expect( Timeout ).to.equal( "Test timeout" ) end, - cleanup = function() hook.Remove( "ACF_IsLegal", "TestFailure" ) end + cleanup = function() hook.Remove( "ACF_OnCheckLegal", "TestFailure" ) end }, { diff --git a/lua/tests/acf/damage/damage_sv/acf_keshove.lua b/lua/tests/acf/damage/damage_sv/acf_keshove.lua index 88460ea61..0fe796155 100644 --- a/lua/tests/acf/damage/damage_sv/acf_keshove.lua +++ b/lua/tests/acf/damage/damage_sv/acf_keshove.lua @@ -52,7 +52,7 @@ return { { name = "Does not shove the entity if ACF_KEShove hook returns false", func = function( State ) - hook.Add( "ACF_KEShove", "Test", function() return false end ) + hook.Add( "ACF_OnPushEntity", "Test", function() return false end ) local Ent = State.Ent ACF.KEShove( Ent, Ones, Ones, 1 ) @@ -61,7 +61,7 @@ return { end, cleanup = function() - hook.Remove( "ACF_KEShove", "Test" ) + hook.Remove( "ACF_OnPushEntity", "Test" ) end },