1
0
Fork 0

Added ExperienceAmount variable to HOOK_PLAYER_FISHING and HOOK_PLAYER_FISHED (#5345)

* Implemented cServer::ScheduleTask() and cServer::TickQueuedTasks()

* Fixed formatting and added ScheduleTask to APIDesc

* Added feyokorenhof to contributors

* Added ExperienceAmount variable to all the hook calls.

* Made ExperienceAmount int reference instead of int in HOOK_PLAYER_FISHING. Fixed bug: a_Reward is now a reference

* Add documentation, change ItemFishingRod to pass in experience

Co-authored-by: Alexander Harkness <me@bearbin.net>
master
Feyo Korenhof 1 year ago committed by GitHub
parent 7c7890c658
commit 1be14ebf7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      Server/Plugins/APIDump/Classes/Plugins.lua
  2. 4
      src/Bindings/Plugin.h
  3. 8
      src/Bindings/PluginLua.cpp
  4. 4
      src/Bindings/PluginLua.h
  5. 8
      src/Bindings/PluginManager.cpp
  6. 4
      src/Bindings/PluginManager.h
  7. 8
      src/Items/ItemFishingRod.h

@ -847,11 +847,11 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
},
HOOK_PLAYER_FISHED =
{
Notes = "Called when the player reels the fishing rod back in, after the server decides the player's fishing reward.",
Notes = "Called when the player reels the fishing rod back in, after the server decides the player's fishing reward and the experience to grant.",
},
HOOK_PLAYER_FISHING =
{
Notes = "Called when the player reels the fishing rod back in, plugins may alter the fishing reward.",
Notes = "Called when the player reels the fishing rod back in, plugins may alter the fishing reward and the experience granted to the player.",
},
HOOK_PLAYER_FOOD_LEVEL_CHANGE =
{

@ -76,8 +76,8 @@ public:
virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
virtual bool OnPlayerDestroyed (cPlayer & a_Player) = 0;
virtual bool OnPlayerEating (cPlayer & a_Player) = 0;
virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) = 0;
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) = 0;
virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward, const int ExperienceAmount) = 0;
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward, int & ExperienceAmount) = 0;
virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) = 0;
virtual bool OnPlayerJoined (cPlayer & a_Player) = 0;
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) = 0;

@ -632,19 +632,19 @@ bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel)
bool cPluginLua::OnPlayerFished(cPlayer & a_Player, const cItems & a_Reward)
bool cPluginLua::OnPlayerFished(cPlayer & a_Player, const cItems & a_Reward, const int ExperienceAmount)
{
cItems reward(a_Reward);
return CallSimpleHooks(cPluginManager::HOOK_PLAYER_FISHED, &a_Player, &reward);
return CallSimpleHooks(cPluginManager::HOOK_PLAYER_FISHED, &a_Player, &reward, ExperienceAmount);
}
bool cPluginLua::OnPlayerFishing(cPlayer & a_Player, cItems & a_Reward)
bool cPluginLua::OnPlayerFishing(cPlayer & a_Player, cItems & a_Reward, int & ExperienceAmount)
{
return CallSimpleHooks(cPluginManager::HOOK_PLAYER_FISHING, &a_Player, &a_Reward);
return CallSimpleHooks(cPluginManager::HOOK_PLAYER_FISHING, &a_Player, &a_Reward, &ExperienceAmount);
}

@ -96,8 +96,8 @@ public:
virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
virtual bool OnPlayerDestroyed (cPlayer & a_Player) override;
virtual bool OnPlayerEating (cPlayer & a_Player) override;
virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) override;
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) override;
virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward, const int ExperienceAmount) override;
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward, int & ExperienceAmount) override;
virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) override;
virtual bool OnPlayerJoined (cPlayer & a_Player) override;
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) override;

@ -775,11 +775,11 @@ bool cPluginManager::CallHookPlayerFoodLevelChange(cPlayer & a_Player, int a_New
bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems & a_Reward)
bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems & a_Reward, const int ExperienceAmount)
{
return GenericCallHook(HOOK_PLAYER_FISHED, [&](cPlugin * a_Plugin)
{
return a_Plugin->OnPlayerFished(a_Player, a_Reward);
return a_Plugin->OnPlayerFished(a_Player, a_Reward, ExperienceAmount);
}
);
}
@ -788,11 +788,11 @@ bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems & a_R
bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems a_Reward)
bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems & a_Reward, int & ExperienceAmount)
{
return GenericCallHook(HOOK_PLAYER_FISHING, [&](cPlugin * a_Plugin)
{
return a_Plugin->OnPlayerFishing(a_Player, a_Reward);
return a_Plugin->OnPlayerFishing(a_Player, a_Reward, ExperienceAmount);
}
);
}

@ -269,8 +269,8 @@ public:
bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
bool CallHookPlayerDestroyed (cPlayer & a_Player);
bool CallHookPlayerEating (cPlayer & a_Player);
bool CallHookPlayerFished (cPlayer & a_Player, const cItems & a_Reward);
bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward);
bool CallHookPlayerFished (cPlayer & a_Player, const cItems & a_Reward, const int ExperienceAmount);
bool CallHookPlayerFishing (cPlayer & a_Player, cItems & a_Reward, int & ExperienceAmount);
bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel);
bool CallHookPlayerJoined (cPlayer & a_Player);
bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status);

@ -287,8 +287,10 @@ public:
a_Player.GetStatistics().Custom[CustomStatistic::FishCaught]++;
}
auto Experience = Random.RandInt(1, 6);
// Check with plugins if this loot is acceptable:
if (cRoot::Get()->GetPluginManager()->CallHookPlayerFishing(a_Player, Drops))
if (cRoot::Get()->GetPluginManager()->CallHookPlayerFishing(a_Player, Drops, Experience))
{
return;
}
@ -298,10 +300,10 @@ public:
const float FISH_SPEED_MULT = 2.25f;
Vector3d FlyDirection = (a_Player.GetEyePosition() - FloaterPos).addedY(1.0f) * FISH_SPEED_MULT;
a_World.SpawnItemPickups(Drops, FloaterPos, FlyDirection);
a_World.SpawnExperienceOrb(a_Player.GetPosition(), Random.RandInt(1, 6));
a_World.SpawnExperienceOrb(a_Player.GetPosition(), Experience);
a_Player.UseEquippedItem(1);
// Notify plugins
cRoot::Get()->GetPluginManager()->CallHookPlayerFished(a_Player, Drops);
cRoot::Get()->GetPluginManager()->CallHookPlayerFished(a_Player, Drops, Experience);
}
} ;

Loading…
Cancel
Save