mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-10 17:58:03 +01:00
Fix raids and patrols not respecting natual spawning
This commit is contained in:
parent
75b23c0956
commit
fdb0669176
@ -42,6 +42,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -697,7 +698,7 @@ public class Entity implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SpawnReason reason = event.getSpawnReason();
|
SpawnReason reason = event.getSpawnReason();
|
||||||
Set<SpawnReason> reasons = Sets.newHashSet(SpawnReason.NATURAL, SpawnReason.JOCKEY, SpawnReason.MOUNT, SpawnReason.valueOf("RAID"), SpawnReason.valueOf("PATROL"));
|
Set<SpawnReason> reasons = Sets.newHashSet(SpawnReason.NATURAL, SpawnReason.JOCKEY, SpawnReason.MOUNT, getSpawnReason("RAID"), getSpawnReason("PATROL"));
|
||||||
// Check that the reason of this event is not any of these above.
|
// Check that the reason of this event is not any of these above.
|
||||||
if (!reasons.stream().filter(r -> r != null).anyMatch(r -> r == reason))
|
if (!reasons.stream().filter(r -> r != null).anyMatch(r -> r == reason))
|
||||||
return;
|
return;
|
||||||
@ -723,4 +724,12 @@ public class Entity implements Listener {
|
|||||||
event.setCancelled(true); // For other plugin API reasons.
|
event.setCancelled(true); // For other plugin API reasons.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SpawnReason getSpawnReason(String reason) {
|
||||||
|
try {
|
||||||
|
return SpawnReason.valueOf(reason);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user