summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Server/Plugins/APIDump/Classes/Plugins.lua4
-rw-r--r--src/Bindings/Plugin.h4
-rw-r--r--src/Bindings/PluginLua.cpp8
-rw-r--r--src/Bindings/PluginLua.h4
-rw-r--r--src/Bindings/PluginManager.cpp8
-rw-r--r--src/Bindings/PluginManager.h4
-rw-r--r--src/Items/ItemFishingRod.h8
7 files changed, 21 insertions, 19 deletions
diff --git a/Server/Plugins/APIDump/Classes/Plugins.lua b/Server/Plugins/APIDump/Classes/Plugins.lua
index adc6bf0b3..26c8c9c76 100644
--- a/Server/Plugins/APIDump/Classes/Plugins.lua
+++ b/Server/Plugins/APIDump/Classes/Plugins.lua
@@ -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 =
{
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index 47f8820e8..2b5abfca9 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -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;
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 5e29319ca..393516c95 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -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);
}
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index 6c59bbe1b..855813cc4 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -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;
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index d790562dc..5a287136b 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -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);
}
);
}
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index c1f798291..417246d07 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -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);
diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h
index 183c9756c..909f892c3 100644
--- a/src/Items/ItemFishingRod.h
+++ b/src/Items/ItemFishingRod.h
@@ -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);
}
} ;