Skip to content

Commit

Permalink
Prevent quest BLOCK_LOOT progression from naturally generated containers
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSzabo committed Nov 29, 2024
1 parent 3f380b3 commit 6ffe3c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
}

group = "gg.auroramc"
version = "1.3.9"
version = "1.3.10"

repositories {
flatDir {
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/gg/auroramc/quests/listener/MiningListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,33 @@
import gg.auroramc.aurora.api.item.TypeId;
import gg.auroramc.quests.AuroraQuests;
import gg.auroramc.quests.api.quest.TaskType;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockDropItemEvent;

import java.util.Map;
import java.util.Set;

public class MiningListener implements Listener {

private final Set<Material> blacklist = Set.of(
Material.CHEST, Material.TRAPPED_CHEST, Material.BARREL,
Material.HOPPER, Material.FURNACE, Material.SMOKER, Material.BLAST_FURNACE,
Material.DISPENSER, Material.ITEM_FRAME, Material.BEACON,
Material.DROPPER, Material.ARMOR_STAND, Material.BREWING_STAND,
Material.CAMPFIRE, Material.SOUL_CAMPFIRE, Material.FLOWER_POT,
Material.JUKEBOX, Material.LOOM, Material.CARTOGRAPHY_TABLE,
Material.DECORATED_POT
);

@EventHandler
public void onBlockBreak(BlockDropItemEvent e) {
if (AuroraAPI.getRegionManager().isPlacedBlock(e.getBlock())) return;
var player = e.getPlayer();

if (blacklist.contains(e.getBlockState().getType())) return;

for (var drop : e.getItems()) {
var item = drop.getItemStack();
AuroraQuests.getInstance().getQuestManager().progress(player, TaskType.BLOCK_LOOT, item.getAmount(), Map.of("type", TypeId.from(item.getType())));
Expand Down

0 comments on commit 6ffe3c0

Please sign in to comment.