--- a/net/minecraft/world/entity/raid/Raids.java
+++ b/net/minecraft/world/entity/raid/Raids.java
@@ -25,7 +_,7 @@
 
 public class Raids extends SavedData {
     private static final String RAID_FILE_ID = "raids";
-    private final Map<Integer, Raid> raidMap = Maps.newHashMap();
+    public final Map<Integer, Raid> raidMap = Maps.newHashMap();
     private final ServerLevel level;
     private int nextAvailableID;
     private int tick;
@@ -112,11 +_,23 @@
                 }
 
                 Raid raid = this.getOrCreateRaid(player.serverLevel(), blockPos);
+                /* CraftBukkit - moved down
                 if (!raid.isStarted() && !this.raidMap.containsKey(raid.getId())) {
                     this.raidMap.put(raid.getId(), raid);
                 }
-
-                if (!raid.isStarted() || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) {
+                */
+
+                if (!raid.isStarted() || (raid.isInProgress() && raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel())) { // CraftBukkit - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished
+                    // CraftBukkit start
+                    if (!org.bukkit.craftbukkit.event.CraftEventFactory.callRaidTriggerEvent(raid, player)) {
+                        player.removeEffect(net.minecraft.world.effect.MobEffects.RAID_OMEN);
+                        return null;
+                    }
+
+                    if (!raid.isStarted() && !this.raidMap.containsKey(raid.getId())) {
+                        this.raidMap.put(raid.getId(), raid);
+                    }
+                    // CraftBukkit end
                     raid.absorbRaidOmen(player);
                 }
 
