diff --git a/src/main/java/com/artillexstudios/axminions/config/Config.java b/src/main/java/com/artillexstudios/axminions/config/Config.java index f937698..6fe456a 100644 --- a/src/main/java/com/artillexstudios/axminions/config/Config.java +++ b/src/main/java/com/artillexstudios/axminions/config/Config.java @@ -32,6 +32,7 @@ public final class Config { public static boolean ASYNC_HAND_ANIMATION = false; public static int ASYNC_PROCESSOR_POOL_SIZE = 3; public static boolean REQUIRE_TOOL = true; + public static boolean INSTANT_KILL = false; public static String LANGUAGE = "en_US"; public static boolean USE_BSTATS = true; public static boolean DEBUG = false; @@ -82,6 +83,7 @@ public final class Config { ASYNC_HAND_ANIMATION = config.getBoolean("async-hand-animation", ASYNC_HAND_ANIMATION); ASYNC_PROCESSOR_POOL_SIZE = config.getInt("async-processor-pool-size", ASYNC_PROCESSOR_POOL_SIZE); REQUIRE_TOOL = config.getBoolean("require-tool", REQUIRE_TOOL); + INSTANT_KILL = config.getBoolean("instant-kill", INSTANT_KILL); LANGUAGE = config.getString("language", LANGUAGE); USE_BSTATS = config.getBoolean("use-bstats", USE_BSTATS); DEBUG = config.getBoolean("debug", DEBUG); diff --git a/src/main/java/com/artillexstudios/axminions/minions/actions/effects/implementation/DamageEntityEffect.java b/src/main/java/com/artillexstudios/axminions/minions/actions/effects/implementation/DamageEntityEffect.java index 128cd27..c1eb69d 100644 --- a/src/main/java/com/artillexstudios/axminions/minions/actions/effects/implementation/DamageEntityEffect.java +++ b/src/main/java/com/artillexstudios/axminions/minions/actions/effects/implementation/DamageEntityEffect.java @@ -5,15 +5,14 @@ import com.artillexstudios.axapi.loot.LootContextParams; import com.artillexstudios.axapi.loot.LootParams; import com.artillexstudios.axapi.loot.LootTables; import com.artillexstudios.axapi.nms.NMSHandlers; +import com.artillexstudios.axminions.config.Config; +import com.artillexstudios.axminions.integrations.Integrations; import com.artillexstudios.axminions.minions.Minion; import com.artillexstudios.axminions.minions.actions.effects.Effect; import com.artillexstudios.axminions.utils.ItemCollection; -import com.artillexstudios.axminions.utils.LogUtils; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import java.util.Collection; import java.util.Map; public class DamageEntityEffect extends Effect { @@ -25,21 +24,26 @@ public class DamageEntityEffect extends Effect { @Override public ItemCollection run(Minion minion, Entity argument) { - dummyPlayer.getInventory().setItemInMainHand(minion.tool()); - LootParams params = new LootParams.Builder(argument.getWorld()) - .withParameter(LootContextParams.THIS_ENTITY, argument) - .withParameter(LootContextParams.ORIGIN, argument.getLocation()) - .withParameter(LootContextParams.DAMAGE_SOURCE, dummyPlayer) - .withParameter(LootContextParams.ATTACKING_ENTITY, dummyPlayer) - .withParameter(LootContextParams.DIRECT_ATTACKING_ENTITY, dummyPlayer) - .withParameter(LootContextParams.LAST_DAMAGE_PLAYER, dummyPlayer) - .build(LootContextParamSets.ENTITY); + if (Config.INSTANT_KILL) { + // TODO: maybe we can get the loot of an entity with the stacker's api + long stackSize = Integrations.STACKER.getStackSize(argument); - Collection items = LootTables.entityLootTable(argument.getType()) - .randomItems(params); + dummyPlayer.getInventory().setItemInMainHand(minion.tool()); + // TODO: We need to handle looting enchantment + LootParams params = new LootParams.Builder(argument.getWorld()) + .withParameter(LootContextParams.THIS_ENTITY, argument) + .withParameter(LootContextParams.ORIGIN, argument.getLocation()) + .withParameter(LootContextParams.DAMAGE_SOURCE, dummyPlayer) + .withParameter(LootContextParams.ATTACKING_ENTITY, dummyPlayer) + .withParameter(LootContextParams.DIRECT_ATTACKING_ENTITY, dummyPlayer) + .withParameter(LootContextParams.LAST_DAMAGE_PLAYER, dummyPlayer) + .build(LootContextParamSets.ENTITY); - LogUtils.debug("DamageEntityEffect, {} items: {}", argument, items); - return new ItemCollection(items); + return new ItemCollection(LootTables.entityLootTable(argument.getType()) + .randomItems(params)); + } + + return ItemCollection.EMPTY; } @Override diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 7b24005..4216d89 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -37,6 +37,10 @@ async-processor-pool-size: 3 # If this option is false, the minion's default tool will be used require-tool: true +# If the minion should kill the entity instantly, and not +# deal the amount of damage the item would deal. +instant-kill: false + # What language file should we load from the lang folder? # You can create your own aswell! We would appreciate if you # contributed to the plugin by creating a pull request with your translation!