mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-12-31 21:07:47 +01:00
Fix compatibility issues with 3rd party loot plugins
This commit is contained in:
parent
4576a5c53c
commit
91e31c24c3
@ -58,27 +58,30 @@ public class DeathListeners implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
|
boolean custom = Settings.CUSTOM_DROPS.getBoolean();
|
||||||
|
|
||||||
|
if (!custom) return; //Compatibility with other plugins
|
||||||
|
|
||||||
LivingEntity entity = event.getEntity();
|
LivingEntity entity = event.getEntity();
|
||||||
|
|
||||||
|
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||||
|
&& !entity.getWorld().getGameRuleValue(GameRule.DO_MOB_LOOT)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.getEntityType() == EntityType.PLAYER
|
if (event.getEntityType() == EntityType.PLAYER
|
||||||
|| event.getEntityType() == EntityType.ARMOR_STAND) return;
|
|| event.getEntityType() == EntityType.ARMOR_STAND) return;
|
||||||
|
|
||||||
//Respect MythicMobs
|
//Respect MythicMobs
|
||||||
if (plugin.getCustomEntityManager().isCustomEntity(entity)) return;
|
if (plugin.getCustomEntityManager().isCustomEntity(entity)) return;
|
||||||
|
|
||||||
boolean custom = Settings.CUSTOM_DROPS.getBoolean();
|
|
||||||
List<Drop> drops = custom ? plugin.getLootablesManager().getDrops(event.getEntity())
|
|
||||||
: event.getDrops().stream().map(Drop::new).collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (custom) {
|
List<Drop> drops = plugin.getLootablesManager().getDrops(event.getEntity());
|
||||||
|
|
||||||
for (ItemStack item : new ArrayList<>(event.getDrops())) {
|
for (ItemStack item : new ArrayList<>(event.getDrops())) {
|
||||||
if (shouldDrop(event.getEntity(), item.getType()))
|
if (shouldDrop(event.getEntity(), item.getType()))
|
||||||
drops.add(new Drop(item));
|
drops.add(new Drop(item));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
|
||||||
&& !entity.getWorld().getGameRuleValue(GameRule.DO_MOB_LOOT))
|
|
||||||
drops.clear();
|
|
||||||
|
|
||||||
if (plugin.getCustomEntityManager().getCustomEntity(entity) == null) {
|
if (plugin.getCustomEntityManager().getCustomEntity(entity) == null) {
|
||||||
//replace %player% in drop commands with the last player to damage the entity
|
//replace %player% in drop commands with the last player to damage the entity
|
||||||
@ -86,12 +89,11 @@ public class DeathListeners implements Listener {
|
|||||||
runCommands(entity, drops);
|
runCommands(entity, drops);
|
||||||
|
|
||||||
if (plugin.getEntityStackManager().isStackedEntity(event.getEntity())) {
|
if (plugin.getEntityStackManager().isStackedEntity(event.getEntity())) {
|
||||||
plugin.getEntityStackManager().getStack(event.getEntity()).onDeath(entity, drops, custom, event.getDroppedExp(), event);
|
plugin.getEntityStackManager().getStack(event.getEntity()).onDeath(entity, drops, true, event.getDroppedExp(), event);
|
||||||
} else {
|
} else {
|
||||||
DropUtils.processStackedDrop(event.getEntity(), drops, event);
|
DropUtils.processStackedDrop(event.getEntity(), drops, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finalItems.remove(entity.getUniqueId());
|
finalItems.remove(entity.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user