Using global operations.

This commit is contained in:
2025-05-24 20:52:10 +01:00
parent ea813acb2f
commit 43fb2f9a0a

View File

@ -18,7 +18,7 @@ import java.util.concurrent.ThreadLocalRandom;
public class OnBlockBreakEventHandler { public class OnBlockBreakEventHandler {
@SubscribeEvent @SubscribeEvent
public void OnBlockBreakEvent(BlockEvent.BreakEvent event) { public void OnBlockBreakEvent(BlockEvent.BreakEvent event) {
float xpToDrop = (Config.Server.blockBreakDefaultNoXp.get()) ? 0 : event.getExpToDrop(); float xpToDrop = event.getExpToDrop();
List<OperationItem> operations = new ArrayList<>(); List<OperationItem> operations = new ArrayList<>();
// Collect operations on relevant block_id // Collect operations on relevant block_id
@ -45,6 +45,9 @@ public class OnBlockBreakEventHandler {
// Sort operations based on priority // Sort operations based on priority
operations.sort(Comparator.comparingInt(OperationItem::getPriority)); operations.sort(Comparator.comparingInt(OperationItem::getPriority));
// Add global operations before all others
operations.addAll(0, Config.Server.blockBreakGlobalOperationItems);
// Apply operations to xp drops // Apply operations to xp drops
for (OperationItem operation : operations) { for (OperationItem operation : operations) {
// Calculate operation value // Calculate operation value