-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Nexo custom block drops
- Loading branch information
Showing
5 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/gg/auroramc/collections/hooks/nexo/NexoHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ softdepend: | |
- LuckPerms | ||
- TopMinion | ||
- BeeMinions | ||
- Nexo | ||
|
||
website: https://auroramc.gg | ||
|
||
|