Merge pull request #102

Famine enchantment changes & MythicMobs integration && blacklisted-blocks option for Instantaneous enchantment
This commit is contained in:
Will FP
2021-11-06 18:47:12 +00:00
committed by GitHub
9 changed files with 70 additions and 6 deletions

View File

@@ -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 {

View File

@@ -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'
}

View File

@@ -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)
);
}

View File

@@ -1,6 +1,7 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
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.EnchantmentUtils;
import org.bukkit.entity.LivingEntity;
@@ -35,7 +36,6 @@ public class Famine extends EcoEnchant {
return;
}
victim.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, level * 40, level));
victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, level * 40, level));
victim.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, level * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION+"ticks-per-level"), level));
}
}

View File

@@ -2,6 +2,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.eco.core.integrations.anticheat.AnticheatManager;
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.EnchantmentUtils;
import org.bukkit.Material;
@@ -10,6 +11,9 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockDamageEvent;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class Instantaneous extends EcoEnchant {
public Instantaneous() {
super(
@@ -39,7 +43,13 @@ public class Instantaneous extends EcoEnchant {
return;
}
if (block.getType() == Material.BEDROCK) {
List<Material> blacklist = new ArrayList<>();
for (String s : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks")) {
blacklist.add(Material.getMaterial(s));
}
if (blacklist.contains(block.getType())) {
return;
}

View File

@@ -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();

View File

@@ -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();
}
}

View File

@@ -26,4 +26,6 @@ general-config:
config:
allow-not-fully-charged: false
chance-per-level: 1.5
chance-per-level: 1.5
ticks-per-level: 40
amplifier-per-levl: 1

View File

@@ -28,4 +28,10 @@ general-config:
maximum-level: 7
config:
chance-per-level: 3
chance-per-level: 3
blacklisted-blocks:
- BEDROCK
- OBSIDIAN
- END_PORTAL
- END_PORTAL_GATE
- NETHER_PORTAL