Enable Op or mod override for breeding.

This commit is contained in:
tastybento 2021-12-22 13:43:45 -08:00
parent 38aa99b2c7
commit 0248c398f6
1 changed files with 10 additions and 10 deletions

View File

@ -87,15 +87,14 @@ public class EntityLimitListener implements Listener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBreed(final EntityBreedEvent e) { public void onBreed(final EntityBreedEvent e) {
if (e.getBreeder() != null && e.getBreeder() instanceof Player p && if (addon.inGameModeWorld(e.getEntity().getWorld())
!(p.isOp() || p.hasPermission(addon.getPlugin().getIWM().getPermissionPrefix(e.getEntity().getWorld()) + MOD_BYPASS))) { && e.getBreeder() != null
if (!checkLimit(e, e.getEntity(), SpawnReason.BREEDING, false)) { && e.getBreeder() instanceof Player p
// Breeding not allowed so stop the love fest && !(p.isOp() || p.hasPermission(addon.getPlugin().getIWM().getPermissionPrefix(e.getEntity().getWorld()) + MOD_BYPASS))
if (e.getFather() instanceof Animals f && e.getMother() instanceof Animals m) { && !checkLimit(e, e.getEntity(), SpawnReason.BREEDING, false)
f.setLoveModeTicks(0); && e.getFather() instanceof Animals f && e.getMother() instanceof Animals m) {
m.setLoveModeTicks(0); f.setLoveModeTicks(0);
} m.setLoveModeTicks(0);
}
} }
} }
@ -109,8 +108,9 @@ public class EntityLimitListener implements Listener {
justSpawned.remove(e.getEntity().getUniqueId()); justSpawned.remove(e.getEntity().getUniqueId());
return; return;
} }
if (e.getSpawnReason().equals(SpawnReason.SHOULDER_ENTITY)) { if (e.getSpawnReason().equals(SpawnReason.SHOULDER_ENTITY) || e.getSpawnReason().equals(SpawnReason.BREEDING)) {
// Special case - do nothing - jumping around spawns parrots as they drop off player's shoulder // Special case - do nothing - jumping around spawns parrots as they drop off player's shoulder
// Ignore breeding because it's handled in the EntityBreedEvent listener
return; return;
} }
// Some checks can be done async, some not // Some checks can be done async, some not