Rosewood-Development / RoseStacker

A next-generation stacker plugin for Spigot and Paper servers
Other
139 stars 36 forks source link

LevelledMobs Compatibility #67

Closed lokka30 closed 2 months ago

lokka30 commented 1 year ago

Hi there!

LevelledMobs doesn't work nicely with mob stacking plugins. To patch this, RoseStacker could have a LevelledMobs hook which ensures mobs are not levelled by LM before they are stacked. This can be achieved solely through the Bukkit API, through this (untested and text-editor-derived) code:

private static NamespacedKey levelledMobsLevelKey = null;

public static boolean isLevelledMob(final @Nonnnull LivingEntity lent) {
    if(levelledMobsLevelKey == null) {
        final Plugin lmPlugin = Bukkit.getPluginManager().getPlugin("LevelledMobs");
        if(plugin == null) return false;

        levelledMobsLevelKey = new NamespacedKey(lmPlugin, "level")
    }

    return lent.getPersistentDataContainer().has(levelledMobsLevelKey, PersistentDataType.INTEGER);
}

Upon the release of LM version 4, there will be a lightweight API which can be used if preferred.

Thanks, Lachlan

deadspidervenom commented 2 months ago

ummm, from my testing the two work just fine. killing a level 30 mob takes longer when appeared on the stack than when killing a level 1 mob

deadspidervenom commented 2 months ago

unless this super old and never closed

Esophose commented 2 months ago

Finally implemented in 516db47cced5c8674ae1426c36159ebd2fe2336d

lokka30 commented 2 months ago

Awesome, thanks @Esophose!