mirror of
https://github.com/songoda/UltimateTimber.git
synced 2025-01-08 08:47:51 +01:00
Hook stuff, event priority stuff
This commit is contained in:
parent
314d6fcb2b
commit
0db463378b
@ -14,7 +14,7 @@ import org.bukkit.entity.Player;
|
||||
public class CurrentJobsHook implements TimberHook {
|
||||
|
||||
@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))
|
||||
return;
|
||||
|
||||
|
@ -16,7 +16,7 @@ public class CurrentMcMMOHook implements TimberHook {
|
||||
|
||||
private Enum<?> woodcuttingEnum;
|
||||
private Method getXpMethod;
|
||||
|
||||
|
||||
public CurrentMcMMOHook() throws NoSuchMethodException, SecurityException, ClassNotFoundException {
|
||||
try { // Try to find mcMMO Overhaul
|
||||
Class<?> primarySkillTypeClass = Class.forName("com.gmail.nossr50.datatypes.skills.PrimarySkillType");
|
||||
@ -43,17 +43,16 @@ public class CurrentMcMMOHook implements TimberHook {
|
||||
|
||||
@Override
|
||||
public void apply(Player player, TreeBlockSet<Block> treeBlocks) throws Exception {
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE))
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE))
|
||||
return;
|
||||
|
||||
|
||||
int xp = 0;
|
||||
for (ITreeBlock<Block> treeBlock : treeBlocks.getLogBlocks()) {
|
||||
Block block = treeBlock.getBlock();
|
||||
Material material = block.getType();
|
||||
if (!material.name().endsWith("LOG")) continue;
|
||||
xp += (int) this.getXpMethod.invoke(ExperienceConfig.getInstance(), this.woodcuttingEnum, material);
|
||||
}
|
||||
|
||||
|
||||
ExperienceAPI.addXP(player, "woodcutting", xp, "pve");
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
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.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.tree.TreeBlockSet;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -25,8 +28,13 @@ public class HookManager extends Manager {
|
||||
public void reload() {
|
||||
this.hooks.clear();
|
||||
|
||||
this.tryHook("mcMMO", CurrentMcMMOHook.class);
|
||||
this.tryHook("Jobs", CurrentJobsHook.class);
|
||||
if (this.ultimateTimber.getVersionAdapter().getVersionAdapterType().equals(VersionAdapterType.CURRENT)) {
|
||||
this.tryHook("mcMMO", CurrentMcMMOHook.class);
|
||||
this.tryHook("Jobs", CurrentJobsHook.class);
|
||||
} else {
|
||||
this.tryHook("mcMMO", LegacyMcMMOHook.class);
|
||||
this.tryHook("Jobs", LegacyJobsHook.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -257,7 +257,7 @@ public class TreeDefinitionManager extends Manager {
|
||||
}
|
||||
|
||||
// Add to inventory or drop on ground
|
||||
if (addToInventory) {
|
||||
if (addToInventory && player.getWorld().equals(treeBlock.getLocation().getWorld())) {
|
||||
Set<ItemStack> extraItems = new HashSet<>();
|
||||
for (ItemStack lootedItem : lootedItems)
|
||||
extraItems.addAll(player.getInventory().addItem(lootedItem).values());
|
||||
|
@ -32,8 +32,11 @@ public class TreeFallManager extends Manager implements Listener {
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
TreeDefinitionManager treeDefinitionManager = this.ultimateTimber.getTreeDefinitionManager();
|
||||
TreeDetectionManager treeDetectionManager = this.ultimateTimber.getTreeDetectionManager();
|
||||
TreeAnimationManager treeAnimationManager = this.ultimateTimber.getTreeAnimationManager();
|
||||
|
Loading…
Reference in New Issue
Block a user