mirror of
https://github.com/songoda/UltimateTimber.git
synced 2025-01-09 17:27:58 +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 {
|
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;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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());
|
||||||
|
@ -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();
|
||||||
|
Loading…
Reference in New Issue
Block a user