ArcanePlugins / LevelledMobs

Level-up mobs on your Spigot/Paper server, RPG-style!
https://www.spigotmc.org/resources/levelledmobs.74304/
GNU Affero General Public License v3.0
213 stars 43 forks source link

Ender Dragons & Phantoms don't get levelled #66

Closed lokka30 closed 3 years ago

lokka30 commented 4 years ago

Attempted fix in upcoming release

lokka30 commented 4 years ago

Attempted fix does not work.

lokka30 commented 3 years ago

@stumper66 would this be as simple a fix as for the magma cubes, ghasts, etc?

stumper66 commented 3 years ago

If the ender dragon is passed thru the mob spawn event I would think so. The question is, does it?

lokka30 commented 3 years ago

If the ender dragon is passed thru the mob spawn event I would think so. The question is, does it?

Confirmed that it isn't. I attempted to add ender dragon support at LevelManager.79 however my IDE told me that it is impossible for a LivingEntity to be instanceof EnderDragon.

stumper66 commented 3 years ago

https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EnderDragon.html extends ComplexLivingEntity, Boss ComplexLivingEntity extends LivingEntity I'm wondering if any of the generic attributes apply.

lokka30 commented 3 years ago

https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EnderDragon.html extends ComplexLivingEntity, Boss ComplexLivingEntity extends LivingEntity I'm wondering if any of the generic attributes apply.

An interesting thing is that you mentioned it extends Boss - the method already checks if it is instanceof Boss. Therefore when ender dragons spawn, the CreatureSpawnListener is not catching that. Possibly changing to EntitySpawnEvent could fix it, although it will require a few modifications to the listener since it otherwise would try to level non-creatures too.

stumper66 commented 3 years ago

I just did some quick testing and added the following code to the onMobSpawn event: if (e.getEntity() instanceof EnderDragon) { EnderDragon ed = (EnderDragon)e.getEntity(); instance.phantomLogger.log(LogLevel.INFO, "spawned ender dragon"); }

I saw it log the ender dragon soon as I went to the end

lokka30 commented 3 years ago

It could be completely possible that this issue is invalid after all considering it already checks if the entity is instanceof Boss.

lokka30 commented 3 years ago

My IDE doesn't say this is possible, so I'm not going to bother testing it. I believe it could be something to do with CreatureSpawnEvent - we may need to use EntitySpawnEvent for these two entities only (EnderDragon & phantom).

lokka30 commented 3 years ago

Merged with #108.

lokka30 commented 3 years ago

Commit pushed which now makes CreatureSpawnListener also listen to EntitySpawnEvent and potentially force Ender Dragons and Phantoms to be levelled. Needs testing to confirm it works.

lokka30 commented 3 years ago

Finally fixed..7 months later