mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-26 15:45:12 +01:00
Added MythicMobs integration to prevent Telekinesis from giving drop items from mobs with disabled drops.
This commit is contained in:
parent
d874d75c63
commit
b145d3d525
@ -39,6 +39,7 @@ allprojects {
|
||||
maven { url 'https://repo.mikeprimm.com/' }
|
||||
maven { url 'https://maven.sk89q.com/repo/' }
|
||||
maven { url 'https://github.com/factions-site/repo/raw/public/' }
|
||||
maven { url 'https://mvn.lumine.io/repository/maven-public/' }
|
||||
}
|
||||
|
||||
jar {
|
||||
|
@ -13,4 +13,5 @@ dependencies {
|
||||
compileOnly 'org.jetbrains.exposed:exposed-dao:0.34.1'
|
||||
compileOnly 'org.jetbrains.exposed:exposed-jdbc:0.34.1'
|
||||
compileOnly 'mysql:mysql-connector-java:5.1.48'
|
||||
compileOnly 'io.lumine.xikage:MythicMobs:4.9.1'
|
||||
}
|
@ -22,6 +22,7 @@ import com.willfp.ecoenchants.enchantments.support.obtaining.VillagerListeners;
|
||||
import com.willfp.ecoenchants.enchantments.util.ItemConversions;
|
||||
import com.willfp.ecoenchants.enchantments.util.TimedRunnable;
|
||||
import com.willfp.ecoenchants.enchantments.util.WatcherTriggers;
|
||||
import com.willfp.ecoenchants.integrations.mythicmobs.IntegrationMythicMobs;
|
||||
import com.willfp.ecoenchants.integrations.registration.RegistrationManager;
|
||||
import com.willfp.ecoenchants.integrations.registration.plugins.IntegrationEssentials;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -117,7 +118,8 @@ public class EcoEnchantsPlugin extends EcoPlugin {
|
||||
@Override
|
||||
protected List<IntegrationLoader> loadIntegrationLoaders() {
|
||||
return Arrays.asList(
|
||||
new IntegrationLoader("Essentials", () -> RegistrationManager.register(new IntegrationEssentials()))
|
||||
new IntegrationLoader("Essentials", () -> RegistrationManager.register(new IntegrationEssentials())),
|
||||
new IntegrationLoader("MythicMobs", IntegrationMythicMobs::init)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.integrations.mythicmobs.IntegrationMythicMobs;
|
||||
import io.lumine.xikage.mythicmobs.MythicMobs;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -141,6 +143,8 @@ public class Telekinesis extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IntegrationMythicMobs.canDropItems(entity)) return;
|
||||
|
||||
if (event.getKiller() instanceof Player) {
|
||||
player = (Player) event.getKiller();
|
||||
item = player.getInventory().getItemInMainHand();
|
||||
|
@ -0,0 +1,38 @@
|
||||
package com.willfp.ecoenchants.integrations.mythicmobs;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.MythicMobs;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class IntegrationMythicMobs {
|
||||
|
||||
/**
|
||||
* True if MythicMobs integration is enabled.
|
||||
*/
|
||||
private static boolean enabled = false;
|
||||
|
||||
/**
|
||||
* Initiate MythicMobs integration.
|
||||
*/
|
||||
public static void init() {
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Check if given entity should drop items or not.
|
||||
*
|
||||
* @param entity - The entity to check.
|
||||
* @return - If given entity can drop items or not.
|
||||
*/
|
||||
public static boolean canDropItems(Entity entity) {
|
||||
|
||||
if (!enabled) return true;
|
||||
|
||||
if (!MythicMobs.inst().getAPIHelper().isMythicMob(entity)) return true;
|
||||
|
||||
return !MythicMobs.inst().getAPIHelper().getMythicMobInstance(entity).getType().getPreventMobKillDrops()
|
||||
&& !MythicMobs.inst().getAPIHelper().getMythicMobInstance(entity).getType().getPreventOtherDrops();
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user