Hook stuff, event priority stuff

This commit is contained in:
Esophose 2019-04-15 14:33:31 -06:00
parent 314d6fcb2b
commit 0db463378b
5 changed files with 20 additions and 10 deletions

View File

@ -14,7 +14,7 @@ import org.bukkit.entity.Player;
public class CurrentJobsHook implements TimberHook { public class CurrentJobsHook implements TimberHook {
@Override @Override
public void apply(Player player, TreeBlockSet<Block> treeBlocks) throws Exception { public void apply(Player player, TreeBlockSet<Block> treeBlocks) {
if (player.getGameMode().equals(GameMode.CREATIVE)) if (player.getGameMode().equals(GameMode.CREATIVE))
return; return;

View File

@ -50,7 +50,6 @@ public class CurrentMcMMOHook implements TimberHook {
for (ITreeBlock<Block> treeBlock : treeBlocks.getLogBlocks()) { for (ITreeBlock<Block> treeBlock : treeBlocks.getLogBlocks()) {
Block block = treeBlock.getBlock(); Block block = treeBlock.getBlock();
Material material = block.getType(); Material material = block.getType();
if (!material.name().endsWith("LOG")) continue;
xp += (int) this.getXpMethod.invoke(ExperienceConfig.getInstance(), this.woodcuttingEnum, material); xp += (int) this.getXpMethod.invoke(ExperienceConfig.getInstance(), this.woodcuttingEnum, material);
} }

View File

@ -1,8 +1,11 @@
package com.songoda.ultimatetimber.manager; package com.songoda.ultimatetimber.manager;
import com.songoda.ultimatetimber.UltimateTimber; import com.songoda.ultimatetimber.UltimateTimber;
import com.songoda.ultimatetimber.adapter.VersionAdapterType;
import com.songoda.ultimatetimber.adapter.current.hooks.CurrentJobsHook; import com.songoda.ultimatetimber.adapter.current.hooks.CurrentJobsHook;
import com.songoda.ultimatetimber.adapter.current.hooks.CurrentMcMMOHook; import com.songoda.ultimatetimber.adapter.current.hooks.CurrentMcMMOHook;
import com.songoda.ultimatetimber.adapter.legacy.hooks.LegacyJobsHook;
import com.songoda.ultimatetimber.adapter.legacy.hooks.LegacyMcMMOHook;
import com.songoda.ultimatetimber.hook.TimberHook; import com.songoda.ultimatetimber.hook.TimberHook;
import com.songoda.ultimatetimber.tree.TreeBlockSet; import com.songoda.ultimatetimber.tree.TreeBlockSet;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -25,8 +28,13 @@ public class HookManager extends Manager {
public void reload() { public void reload() {
this.hooks.clear(); this.hooks.clear();
if (this.ultimateTimber.getVersionAdapter().getVersionAdapterType().equals(VersionAdapterType.CURRENT)) {
this.tryHook("mcMMO", CurrentMcMMOHook.class); this.tryHook("mcMMO", CurrentMcMMOHook.class);
this.tryHook("Jobs", CurrentJobsHook.class); this.tryHook("Jobs", CurrentJobsHook.class);
} else {
this.tryHook("mcMMO", LegacyMcMMOHook.class);
this.tryHook("Jobs", LegacyJobsHook.class);
}
} }
@Override @Override

View File

@ -257,7 +257,7 @@ public class TreeDefinitionManager extends Manager {
} }
// Add to inventory or drop on ground // Add to inventory or drop on ground
if (addToInventory) { if (addToInventory && player.getWorld().equals(treeBlock.getLocation().getWorld())) {
Set<ItemStack> extraItems = new HashSet<>(); Set<ItemStack> extraItems = new HashSet<>();
for (ItemStack lootedItem : lootedItems) for (ItemStack lootedItem : lootedItems)
extraItems.addAll(player.getInventory().addItem(lootedItem).values()); extraItems.addAll(player.getInventory().addItem(lootedItem).values());

View File

@ -32,8 +32,11 @@ public class TreeFallManager extends Manager implements Listener {
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
if (event.isCancelled())
return;
TreeDefinitionManager treeDefinitionManager = this.ultimateTimber.getTreeDefinitionManager(); TreeDefinitionManager treeDefinitionManager = this.ultimateTimber.getTreeDefinitionManager();
TreeDetectionManager treeDetectionManager = this.ultimateTimber.getTreeDetectionManager(); TreeDetectionManager treeDetectionManager = this.ultimateTimber.getTreeDetectionManager();
TreeAnimationManager treeAnimationManager = this.ultimateTimber.getTreeAnimationManager(); TreeAnimationManager treeAnimationManager = this.ultimateTimber.getTreeAnimationManager();