Skip to content

Commit

Permalink
Add support for Nexo custom block drops
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSzabo committed Nov 23, 2024
1 parent 23441ec commit 231ec3b
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ repositories {
maven("https://jitpack.io/")
maven("https://nexus.phoenixdevt.fr/repository/maven-public/")
maven("https://repo.oraxen.com/snapshots")
maven("https://repo.nexomc.com/snapshots/")
}

dependencies {
Expand All @@ -51,6 +52,7 @@ dependencies {
compileOnly("io.th0rgal:oraxen:2.0-SNAPSHOT")
compileOnly("com.sarry20:TopMinion:2.4.3")
compileOnly("org.me.leo_s:BeeMinions:2.0.9-BETA")
compileOnly("com.nexomc:nexo:0.1.0-dev.0")

implementation("co.aikar:acf-paper:0.5.1-SNAPSHOT")
implementation("org.bstats:bstats-bukkit:3.0.2")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/gg/auroramc/collections/hooks/Hooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import gg.auroramc.collections.hooks.mmoitems.MMOItemsHook;
import gg.auroramc.collections.hooks.mmolib.MMOLibHook;
import gg.auroramc.collections.hooks.mythic.MythicHook;
import gg.auroramc.collections.hooks.nexo.NexoHook;
import gg.auroramc.collections.hooks.oraxen.OraxenHook;
import gg.auroramc.collections.hooks.topminions.TopMinionsHook;
import gg.auroramc.collections.hooks.worldguard.WorldGuardHook;
Expand All @@ -22,6 +23,7 @@ public enum Hooks {
MMOITEMS(MMOItemsHook.class, "MMOItems"),
MYTHIC_MOBS(MythicHook.class, "MythicMobs"),
ORAXEN(OraxenHook.class, "Oraxen"),
NEXO(NexoHook.class, "Nexo"),
WORLD_GUARD(WorldGuardHook.class, "WorldGuard"),
MMOLIB(MMOLibHook.class, "MythicLib"),
TOP_MINIONS(TopMinionsHook.class, "TopMinion"),
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/gg/auroramc/collections/hooks/nexo/NexoHook.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package gg.auroramc.collections.hooks.nexo;

import com.nexomc.nexo.api.events.custom_block.NexoCustomBlockDropLootEvent;
import com.nexomc.nexo.utils.drops.DroppedLoot;
import gg.auroramc.aurora.api.AuroraAPI;
import gg.auroramc.collections.AuroraCollections;
import gg.auroramc.collections.collection.Trigger;
import gg.auroramc.collections.hooks.Hook;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import java.util.List;

public class NexoHook implements Hook, Listener {
private AuroraCollections plugin;

@Override
public void hook(AuroraCollections plugin) {
this.plugin = plugin;
}

private boolean invalid(Player player, Block block) {
return player == null || block == null || AuroraAPI.getRegionManager().isPlacedBlock(block);
}

@EventHandler
public void onCustomBlockDrop(NexoCustomBlockDropLootEvent e) {
if (invalid(e.getPlayer(), e.getBlock())) return;
handleProgression(e.getPlayer(), e.getLoots());
}

private void handleProgression(Player player, List<DroppedLoot> droppedLootList) {
for (DroppedLoot droppedLoot : droppedLootList) {
var itemStack = droppedLoot.loot().itemStack();
var typeId = plugin.getItemManager().resolveId(itemStack);
plugin.getCollectionManager().progressCollections(player, typeId, droppedLoot.amount(), Trigger.BLOCK_LOOT);
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ softdepend:
- LuckPerms
- TopMinion
- BeeMinions
- Nexo

website: https://auroramc.gg

Expand Down

0 comments on commit 231ec3b

Please sign in to comment.