This commit is contained in:
nulli0n 2022-12-22 01:34:09 +06:00
parent a4cc0bfd88
commit befeda87fb
29 changed files with 305 additions and 48 deletions

22
.gitignore vendored
View File

@ -1,17 +1,15 @@
/Core/pom.xml.versionsBackup
/pom.xml.versionsBackup
/NMS/pom.xml.versionsBackup
/V1_16_R1/pom.xml.versionsBackup
/V1_17_R1/pom.xml.versionsBackup
/V1_18_R1/pom.xml.versionsBackup
/Core/target/
/NMS/target/
/V1_16_R1/target/
/V1_17_R1/target/
/V1_18_R1/target/
/.idea/
/target/
/V1_18_R2/pom.xml.versionsBackup
/pom.xml.versionsBackup
/Core/target/
/Core/pom.xml.versionsBackup
/NMS/target/
/NMS/pom.xml.versionsBackup
/V1_17_R1/target/
/V1_17_R1/pom.xml.versionsBackup
/V1_18_R2/target/
/V1_18_R2/pom.xml.versionsBackup
/V1_19_R1/target/
/V1_19_R1/pom.xml.versionsBackup
/V1_19_R2/target/
/V1_19_R2/pom.xml.versionsBackup

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.8</version>
<version>3.2.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -31,27 +31,32 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<version>1.19.3-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.2.8</version>
<version>3.2.11</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_17_R1</artifactId>
<version>3.2.8</version>
<version>3.2.11</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_18_R2</artifactId>
<version>3.2.8</version>
<version>3.2.11</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_19_R1</artifactId>
<version>3.2.8</version>
<version>3.2.11</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_19_R2</artifactId>
<version>3.2.11</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>

View File

@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.nms.EnchantNMS;
import su.nightexpress.excellentenchants.nms.v1_17_R1.V1_17_R1;
import su.nightexpress.excellentenchants.nms.v1_18_R2.V1_18_R2;
import su.nightexpress.excellentenchants.nms.v1_19_R1.V1_19_R1;
import su.nightexpress.excellentenchants.nms.v1_19_R2.V1_19_R2;
public class ExcellentEnchants extends NexPlugin<ExcellentEnchants> {
@ -57,6 +58,7 @@ public class ExcellentEnchants extends NexPlugin<ExcellentEnchants> {
case V1_17_R1 -> new V1_17_R1();
case V1_18_R2 -> new V1_18_R2();
case V1_19_R1 -> new V1_19_R1();
case V1_19_R2 -> new V1_19_R2();
};
return true;
}

View File

@ -372,7 +372,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener
public final boolean canEnchantItem(@Nullable ItemStack item) {
if (item == null || item.getType().isAir()) return false;
if (EnchantManager.getItemEnchants(item).keySet().stream().anyMatch(e -> e.conflictsWith(this) || this.conflictsWith(e))) return false;
if (!item.containsEnchantment(this) && EnchantManager.getItemCustomEnchantsAmount(item) >= Config.ENCHANTMENTS_ITEM_CUSTOM_MAX) {
if (EnchantManager.getEnchantmentLevel(item, this) <= 0 && EnchantManager.getItemCustomEnchantsAmount(item) >= Config.ENCHANTMENTS_ITEM_CUSTOM_MAX) {
return false;
}
if (item.getType() == Material.BOOK || item.getType() == Material.ENCHANTED_BOOK) {

View File

@ -14,6 +14,7 @@ import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.manager.EnchantManager;
public abstract class IEnchantBowPotionTemplate extends IEnchantPotionTemplate implements BowEnchant {
@ -52,7 +53,7 @@ public abstract class IEnchantBowPotionTemplate extends IEnchantPotionTemplate i
if (!this.isEnchantmentAvailable(shooter)) return false;
if (!(e.getProjectile() instanceof Arrow arrow)) return false;
if (!this.checkTriggerChance(level)) return false;
if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false;
if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false;
this.setThisArrow(arrow);
arrow.addCustomEffect(this.getEffect(level), true);

View File

@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.manager.EnchantManager;
import su.nightexpress.excellentenchants.manager.tasks.ArrowTrailsTask;
public abstract class IEnchantBowTemplate extends IEnchantChanceTemplate implements BowEnchant {
@ -71,7 +72,7 @@ public abstract class IEnchantBowTemplate extends IEnchantChanceTemplate impleme
if (!this.isEnchantmentAvailable(shooter)) return false;
if (!(e.getProjectile() instanceof Projectile arrow)) return false;
if (!this.checkTriggerChance(level)) return false;
if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false;
if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false;
this.setThisArrow(arrow);
if (!this.arrowTrailName.isEmpty()) {

View File

@ -78,7 +78,9 @@ public abstract class IEnchantPotionTemplate extends IEnchantChanceTemplate {
public final boolean addEffect(@NotNull LivingEntity target, int level) {
if (this instanceof PassiveEnchant) {
this.plugin.getEnchantNMS().addEnchantmentEffect(target, this, this.getEffect(level));
if (!this.hasEffect(target)) {
this.plugin.getEnchantNMS().addEnchantmentEffect(target, this, this.getEffect(level));
}
}
else {
target.addPotionEffect(this.getEffect(level));

View File

@ -18,7 +18,10 @@ import java.util.stream.Collectors;
public class Config {
public static long TASKS_ARROW_TRAIL_TICKS_INTERVAL;
public static final JOption<Integer> TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL = JOption.create("General.Tasks.Passive_Potion_Effects.Apply_Interval", "Sets how often (in ticks) the plugin will apply permanent potion effects from enchanted items to an entity who wear them.\nThis setting does NOT refreshes currently active effects, but only attempts to add them if absent.", 150);
public static final JOption<Integer> TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL = JOption.create("General.Tasks.Passive_Potion_Effects.Apply_Interval", 150,
"Sets how often (in ticks) the plugin will apply permanent potion effects from enchanted items to an entity who wear them.",
"This setting does NOT refreshes currently active effects, but only attempts to add them if absent."
);
public static Set<String> ENCHANTMENTS_DISABLED;
public static Map<String, Set<String>> ENCHANTMENTS_DISABLED_IN_WORLDS;
@ -42,7 +45,7 @@ public class Config {
TASKS_ARROW_TRAIL_TICKS_INTERVAL = cfg.getLong(path + "Arrow_Trails.Ticks_Interval", 1);
path = "General.Enchantments.";
cfg.addMissing(path + "Disabled_In_Worlds.my_world", Collections.singletonList(Placeholders.MASK_ANY));
cfg.addMissing(path + "Disabled_In_Worlds.my_world", Collections.singletonList(Placeholders.WILDCARD));
cfg.addMissing(path + "Disabled_In_Worlds.other_world", Arrays.asList("enchant_name", "another_enchant"));
ENCHANTMENTS_DISABLED = cfg.getStringSet(path + "Disabled").stream().map(String::toLowerCase).collect(Collectors.toSet());
@ -132,7 +135,7 @@ public class Config {
public static boolean isEnchantmentDisabled(@NotNull ExcellentEnchant enchant, @NotNull String world) {
Set<String> disabled = ENCHANTMENTS_DISABLED_IN_WORLDS.getOrDefault(world, Collections.emptySet());
return disabled.contains(enchant.getKey().getKey()) || disabled.contains(Placeholders.MASK_ANY);
return disabled.contains(enchant.getKey().getKey()) || disabled.contains(Placeholders.WILDCARD);
}
@Nullable

View File

@ -249,6 +249,7 @@ public class EnchantManager extends AbstractManager<ExcellentEnchants> {
return EnchantManager.getItemCustomEnchants(item).size();
}
@Deprecated
public static int getItemEnchantLevel(@NotNull ItemStack item, @NotNull Enchantment enchantment) {
return getItemEnchants(item).getOrDefault(enchantment, 0);
}
@ -265,6 +266,10 @@ public class EnchantManager extends AbstractManager<ExcellentEnchants> {
return EnchantManager.getItemEnchants(item).size();
}
public static boolean hasEnchantment(@NotNull ItemStack item, @NotNull Enchantment enchantment) {
return getEnchantmentLevel(item, enchantment) > 0;
}
public static int getEnchantmentLevel(@NotNull ItemStack item, @NotNull Enchantment enchant) {
ItemMeta meta = item.getItemMeta();
if (meta == null) return 0;
@ -304,6 +309,7 @@ public class EnchantManager extends AbstractManager<ExcellentEnchants> {
Map<EquipmentSlot, ItemStack> equipment = EntityUtil.getEquippedItems(entity);
equipment.entrySet().stream().filter(entry -> {
if (entry.getValue() == null) return false;
if (entry.getValue().getType() == Material.ENCHANTED_BOOK) return false;
if ((entry.getKey() == EquipmentSlot.HAND || entry.getKey() == EquipmentSlot.OFF_HAND) && ItemUtil.isArmor(entry.getValue())) return false;
return true;

View File

@ -114,7 +114,7 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn
if (boots == null || boots.getType().isAir()) return;
//int level = boots.getEnchantmentLevel(this);
int level = EnchantManager.getItemEnchants(boots).getOrDefault(this, 0);
int level = EnchantManager.getEnchantmentLevel(boots, this);
if (level < 1) return;
Block bTo = to.getBlock().getRelative(BlockFace.DOWN);
@ -145,7 +145,7 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn
ItemStack boots = equipment.getBoots();
if (boots == null || boots.getType().isAir()) return;
int level = EnchantManager.getItemEnchantLevel(boots, this);
int level = EnchantManager.getEnchantmentLevel(boots, this);
if (level < 1) return;
if (!this.checkTriggerChance(level)) return;

View File

@ -16,6 +16,7 @@ import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.manager.EnchantManager;
import su.nightexpress.excellentenchants.manager.object.EnchantScaler;
import java.util.function.UnaryOperator;
@ -67,7 +68,7 @@ public class EnchantBomber extends IEnchantChanceTemplate implements BowEnchant
if (!this.isEnchantmentAvailable(shooter)) return false;
if (!this.checkTriggerChance(level)) return false;
if (!(e.getProjectile() instanceof Projectile projectile)) return false;
if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false;
if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false;
TNTPrimed primed = projectile.getWorld().spawn(projectile.getLocation(), TNTPrimed.class);
primed.setVelocity(projectile.getVelocity().multiply(e.getForce() * 1.25));

View File

@ -14,6 +14,7 @@ import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.manager.EnchantManager;
public class EnchantEnderBow extends IEnchantChanceTemplate implements BowEnchant {
@ -34,7 +35,7 @@ public class EnchantEnderBow extends IEnchantChanceTemplate implements BowEnchan
if (!this.isEnchantmentAvailable(shooter)) return false;
if (!this.checkTriggerChance(level)) return false;
if (!(e.getProjectile() instanceof Projectile projectile)) return false;
if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false;
if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false;
EnderPearl pearl = shooter.launchProjectile(EnderPearl.class);
pearl.setVelocity(projectile.getVelocity());

View File

@ -65,13 +65,13 @@ public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant {
if (!this.isEnchantmentAvailable(shooter)) return false;
if (!this.checkTriggerChance(level)) return false;
if (!(e.getProjectile() instanceof Projectile projectile)) return false;
if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false;
if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false;
Fireball fireball;
// Shoot small fireballs for the Multishot enchantment,
// as large ones has a slow speed and punches each other on shoot.
if (bow.containsEnchantment(Enchantment.MULTISHOT)) {
if (EnchantManager.hasEnchantment(bow, Enchantment.MULTISHOT)) {
fireball = shooter.launchProjectile(SmallFireball.class);
fireball.setVelocity(projectile.getVelocity().normalize().multiply(0.5f));
}

View File

@ -21,6 +21,7 @@ import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;
import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
import su.nightexpress.excellentenchants.hook.HookNCP;
import su.nightexpress.excellentenchants.manager.EnchantManager;
import su.nightexpress.excellentenchants.manager.EnchantRegister;
import su.nightexpress.excellentenchants.manager.object.EnchantScaler;
import su.nightexpress.excellentenchants.manager.type.FitItemType;
@ -94,8 +95,8 @@ public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockB
public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) {
if (!this.isEnchantmentAvailable(player)) return false;
if (EnchantRegister.VEINMINER != null && item.containsEnchantment(EnchantRegister.VEINMINER)) return false;
if (EnchantRegister.TUNNEL != null && item.containsEnchantment(EnchantRegister.TUNNEL)) return false;
if (EnchantRegister.VEINMINER != null && EnchantManager.hasEnchantment(item, EnchantRegister.VEINMINER)) return false;
if (EnchantRegister.TUNNEL != null && EnchantManager.hasEnchantment(item, EnchantRegister.TUNNEL)) return false;
Block block = e.getBlock();
if (block.hasMetadata(META_EXPLOSION_MINED)) return false;

View File

@ -124,7 +124,7 @@ public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockB
Player player = e.getPlayer();
ItemStack spawner = player.getInventory().getItem(e.getHand());
if (spawner.getType() != Material.SPAWNER || !(spawner.getItemMeta() instanceof BlockStateMeta meta)) return;
if (spawner == null || spawner.getType() != Material.SPAWNER || !(spawner.getItemMeta() instanceof BlockStateMeta meta)) return;
CreatureSpawner spawnerItem = (CreatureSpawner) meta.getBlockState();
CreatureSpawner spawnerBlock = (CreatureSpawner) block.getState();

View File

@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;
import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
import su.nightexpress.excellentenchants.hook.HookNCP;
import su.nightexpress.excellentenchants.manager.EnchantManager;
import su.nightexpress.excellentenchants.manager.EnchantRegister;
import su.nightexpress.excellentenchants.manager.type.FitItemType;
@ -71,8 +72,8 @@ public class EnchantTunnel extends IEnchantChanceTemplate implements BlockBreakE
Block block = e.getBlock();
if (!this.isEnchantmentAvailable(player)) return false;
if (this.disableOnSneak && player.isSneaking()) return false;
if (EnchantRegister.VEINMINER != null && item.containsEnchantment(EnchantRegister.VEINMINER)) return false;
if (EnchantRegister.BLAST_MINING != null && item.containsEnchantment(EnchantRegister.BLAST_MINING)) return false;
if (EnchantRegister.VEINMINER != null && EnchantManager.hasEnchantment(item, EnchantRegister.VEINMINER)) return false;
if (EnchantRegister.BLAST_MINING != null && EnchantManager.hasEnchantment(item, EnchantRegister.BLAST_MINING)) return false;
if (block.hasMetadata(META_BLOCK_TUNNEL)) return false;
if (block.getType().isInteractable() && !INTERACTABLE_BLOCKS.contains(block.getType())) return false;
if (block.getDrops(item).isEmpty()) return false;

View File

@ -19,6 +19,7 @@ import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;
import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
import su.nightexpress.excellentenchants.hook.HookNCP;
import su.nightexpress.excellentenchants.manager.EnchantManager;
import su.nightexpress.excellentenchants.manager.EnchantRegister;
import su.nightexpress.excellentenchants.manager.object.EnchantScaler;
import su.nightexpress.excellentenchants.manager.type.FitItemType;
@ -115,8 +116,8 @@ public class EnchantVeinminer extends IEnchantChanceTemplate implements BlockBre
@Override
public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack tool, int level) {
if (!this.isEnchantmentAvailable(player)) return false;
if (EnchantRegister.TUNNEL != null && tool.containsEnchantment(EnchantRegister.TUNNEL)) return false;
if (EnchantRegister.BLAST_MINING != null && tool.containsEnchantment(EnchantRegister.BLAST_MINING)) return false;
if (EnchantRegister.TUNNEL != null && EnchantManager.hasEnchantment(tool, EnchantRegister.TUNNEL)) return false;
if (EnchantRegister.BLAST_MINING != null && EnchantManager.hasEnchantment(tool, EnchantRegister.BLAST_MINING)) return false;
Block block = e.getBlock();
if (block.hasMetadata(META_BLOCK_VEINED)) return false;

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.8</version>
<version>3.2.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.nexmedia.engine.utils.EntityUtil;
import java.util.Arrays;
import java.util.Objects;
import java.util.Set;
public interface EnchantNMS {
@ -28,7 +28,7 @@ public interface EnchantNMS {
// TODO Move in 'API' module?
@Deprecated
static int getEquippedEnchantLevel(@NotNull LivingEntity entity, @NotNull Enchantment enchant) {
return Arrays.stream(EntityUtil.getEquipment(entity)).filter(enchant::canEnchantItem)
return EntityUtil.getEquippedItems(entity).values().stream().filter(Objects::nonNull).filter(enchant::canEnchantItem)
.map(item -> getEnchantmentLevel(item, enchant)).max(Integer::compareTo).orElse(0);
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.8</version>
<version>3.2.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.2.8</version>
<version>3.2.11</version>
</dependency>
</dependencies>

View File

@ -24,6 +24,17 @@ public class CustomEffectInstance extends MobEffectInstance {
return enchantment;
}
@Override
public boolean update(MobEffectInstance effect) {
/*if (effect instanceof CustomEffectInstance custom) {
return false;
}
if (effect.getAmplifier() > this.getAmplifier()) {
}*/
return false;
}
public boolean tick(LivingEntity entity, Runnable runnable) {
if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) {
return false;

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.8</version>
<version>3.2.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.2.8</version>
<version>3.2.11</version>
</dependency>
</dependencies>

View File

@ -24,6 +24,17 @@ public class CustomEffectInstance extends MobEffectInstance {
return enchantment;
}
@Override
public boolean update(MobEffectInstance effect) {
/*if (effect instanceof CustomEffectInstance custom) {
return false;
}
if (effect.getAmplifier() > this.getAmplifier()) {
}*/
return false;
}
public boolean tick(LivingEntity entity, Runnable runnable) {
if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) {
return false;

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.8</version>
<version>3.2.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.2.8</version>
<version>3.2.11</version>
</dependency>
</dependencies>

View File

@ -24,6 +24,17 @@ public class CustomEffectInstance extends MobEffectInstance {
return enchantment;
}
@Override
public boolean update(MobEffectInstance effect) {
/*if (effect instanceof CustomEffectInstance custom) {
return false;
}
if (effect.getAmplifier() > this.getAmplifier()) {
}*/
return false;
}
public boolean tick(LivingEntity entity, Runnable runnable) {
if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) {
return false;

70
V1_19_R2/pom.xml Normal file
View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>V1_19_R2</artifactId>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.2.11</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,50 @@
package su.nightexpress.excellentenchants.nms.v1_19_R2;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.LivingEntity;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.utils.Reflex;
import su.nightexpress.excellentenchants.nms.EnchantNMS;
public class CustomEffectInstance extends MobEffectInstance {
private static final int MIN = 60 * 60 * 20;
private final Enchantment enchantment;
public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) {
super(effect, Integer.MAX_VALUE, amplifier);
this.enchantment = enchantment;
}
@NotNull
public Enchantment getEnchantment() {
return enchantment;
}
@Override
public boolean update(MobEffectInstance effect) {
/*if (effect instanceof CustomEffectInstance custom) {
return false;
}
if (effect.getAmplifier() > this.getAmplifier()) {
}*/
return false;
}
public boolean tick(LivingEntity entity, Runnable runnable) {
if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) {
return false;
}
if (super.tick(entity, runnable)) {
if (this.getDuration() <= MIN) {
Reflex.setFieldValue(this, "c", Integer.MAX_VALUE);
}
return true;
}
return false;
}
}

View File

@ -0,0 +1,80 @@
package su.nightexpress.excellentenchants.nms.v1_19_R2;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_19_R2.event.CraftEventFactory;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.bukkit.potion.PotionEffect;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.nightexpress.excellentenchants.nms.EnchantNMS;
import java.util.HashSet;
import java.util.Set;
public class V1_19_R2 implements EnchantNMS {
@Override
public void addEnchantmentEffect(@NotNull LivingEntity entity, @NotNull Enchantment enchant, @NotNull PotionEffect effect) {
net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle();
entity1.addEffect(new CustomEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getAmplifier(), enchant), EntityPotionEffectEvent.Cause.PLUGIN);
}
@Override
@Nullable
public Enchantment getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect type) {
net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle();
MobEffectInstance handle = entity1.getEffect(MobEffect.byId(type.getType().getId()));
if (handle instanceof CustomEffectInstance instance) {
return instance.getEnchantment();
}
return null;
}
@Override
@NotNull
public Set<Block> handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) {
Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle();
BlockPos pos = new BlockPos(location.getX(), location.getY(), location.getZ());
ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle();
float radius = Math.min(16F, 2F + level);
BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState();
BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos();
Set<Block> blocks = new HashSet<>();
for (BlockPos posNear : BlockPos.betweenClosed(pos.offset(-radius, -1.0, -radius), pos.offset(radius, -1.0, radius))) {
if (!posNear.closerThan(entity.blockPosition(), radius)) continue;
posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ());
BlockState bLavaAbove = world.getBlockState(posAbove);
BlockState bLava = world.getBlockState(posNear);
if (!bLavaAbove.isAir()) continue;
if (!bLava.getBlock().equals(Blocks.LAVA)) continue;
if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue;
if (!bStone.canSurvive(world, posNear)) continue;
if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue;
if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue;
//world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120));
Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ());
blocks.add(bukkitLoc.getBlock());
}
return blocks;
}
}

View File

@ -7,13 +7,14 @@
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>ExcellentEnchants</artifactId>
<packaging>pom</packaging>
<version>3.2.8</version>
<version>3.2.11</version>
<modules>
<module>Core</module>
<module>NMS</module>
<module>V1_17_R1</module>
<module>V1_18_R2</module>
<module>V1_19_R1</module>
<module>V1_19_R2</module>
</modules>
<properties>