Skip to content

Commit

Permalink
Fix xp-gain and custom-loot WorldGuard flags with Fishing loot (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
Intybyte authored Nov 22, 2024
1 parent 76cd50e commit 4ffee4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import dev.aurelium.auraskills.api.source.XpSource;
import dev.aurelium.auraskills.api.source.type.FishingXpSource;
import dev.aurelium.auraskills.bukkit.AuraSkills;
import dev.aurelium.auraskills.bukkit.hooks.WorldGuardFlags.FlagKey;
import dev.aurelium.auraskills.bukkit.hooks.WorldGuardHook;
import dev.aurelium.auraskills.api.loot.Loot;
import dev.aurelium.auraskills.api.loot.LootPool;
import dev.aurelium.auraskills.api.loot.LootTable;
Expand Down Expand Up @@ -43,12 +41,7 @@ public FishingLootHandler(AuraSkills plugin) {
public void onFish(PlayerFishEvent event) {
Player player = event.getPlayer();

if (plugin.getWorldManager().isInBlockedWorld(player.getLocation())) {
return;
}
if (plugin.getHookManager().isRegistered(WorldGuardHook.class)) {
plugin.getHookManager().getHook(WorldGuardHook.class).isBlocked(player.getLocation(), player, FlagKey.CUSTOM_LOOT);
}
if (failsChecks(player, player.getLocation())) return;

if (!(event.getCaught() instanceof Item)) return;
if (!event.getState().equals(PlayerFishEvent.State.CAUGHT_FISH)) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ protected Loot selectLoot(LootPool pool, @NotNull LootContext providedContext) {
}

private void giveXp(Player player, Loot loot, @Nullable XpSource source, Skill skill) {
if (plugin.getHookManager().isRegistered(WorldGuardHook.class)) {
// Check generic xp-gain and skill-specific flags
if (plugin.getHookManager().getHook(WorldGuardHook.class).isBlocked(player.getLocation(), player, skill)) {
return;
}
}

User user = plugin.getUser(player);
Object xpObj = loot.getValues().getOptions().get("xp");

Expand Down

0 comments on commit 4ffee4b

Please sign in to comment.