Hooks fixes

This commit is contained in:
Esophose 2019-04-27 21:45:57 -06:00
parent 0e1afcef84
commit a5b8fab267
3 changed files with 10 additions and 21 deletions

View File

@ -2,26 +2,21 @@ package com.songoda.ultimatetimber.hook;
import com.gmail.nossr50.api.AbilityAPI;
import com.gmail.nossr50.api.ExperienceAPI;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.songoda.ultimatetimber.tree.ITreeBlock;
import com.songoda.ultimatetimber.tree.TreeBlockSet;
import org.bukkit.GameMode;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import java.util.ArrayList;
public class McMMOHook implements TimberHook {
@Override
@ -29,14 +24,9 @@ public class McMMOHook implements TimberHook {
if (player.getGameMode().equals(GameMode.CREATIVE))
return;
int xp = 0;
for (ITreeBlock<Block> treeBlock : treeBlocks.getLogBlocks()) {
Block block = treeBlock.getBlock();
BlockData blockData = block.getBlockData();
xp += ExperienceConfig.getInstance().getXp(PrimarySkillType.WOODCUTTING, blockData);
}
ExperienceAPI.addXP(player, "woodcutting", xp, "pve");
ArrayList<BlockState> blockStates = new ArrayList<>();
treeBlocks.getLogBlocks().forEach(x -> blockStates.add(x.getBlock().getState()));
ExperienceAPI.addXpFromBlocksBySkill(blockStates, UserManager.getPlayer(player), PrimarySkillType.WOODCUTTING);
}
@Override

View File

@ -7,9 +7,9 @@ import com.songoda.ultimatetimber.hook.McMMOClassic12Hook;
import com.songoda.ultimatetimber.hook.McMMOClassic13Hook;
import com.songoda.ultimatetimber.hook.McMMOClassic8Hook;
import com.songoda.ultimatetimber.hook.McMMOHook;
import com.songoda.ultimatetimber.utils.NMSUtil;
import com.songoda.ultimatetimber.hook.TimberHook;
import com.songoda.ultimatetimber.tree.TreeBlockSet;
import com.songoda.ultimatetimber.utils.NMSUtil;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -110,7 +110,7 @@ public class HookManager extends Manager {
* @param player The player to check
*/
public boolean isUsingAbilityHooks(Player player) {
if (!ConfigurationManager.Setting.HOOKS_APPLY_EXTRA_DROPS.getBoolean() || this.hooks.isEmpty())
if (!ConfigurationManager.Setting.HOOKS_REQUIRE_ABILITY_ACTIVE.getBoolean() || this.hooks.isEmpty())
return true;
for (TimberHook hook : this.hooks)

View File

@ -118,11 +118,10 @@ public class TreeFallManager extends Manager implements Listener {
detectedTree.getDetectedTreeBlocks().remove(detectedTree.getDetectedTreeBlocks().getInitialLogBlock());
}
if (!player.getGameMode().equals(GameMode.CREATIVE)) {
if (!player.getGameMode().equals(GameMode.CREATIVE))
versionAdapter.applyToolDurability(player, toolDamage);
hookManager.applyExperienceHooks(player, detectedTree.getDetectedTreeBlocks());
}
hookManager.applyExperienceHooks(player, detectedTree.getDetectedTreeBlocks());
treeAnimationManager.runAnimation(detectedTree, player);
// Trigger fell event