mirror of
https://github.com/nulli0n/ExcellentEnchants-spigot.git
synced 2024-11-22 11:35:18 +01:00
v3.5.2
This commit is contained in:
parent
e57e2ab26e
commit
a952a70f01
@ -9,6 +9,6 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment;
|
||||
|
||||
public interface BlockDropEnchant extends IEnchantment {
|
||||
|
||||
boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer,
|
||||
boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer,
|
||||
@NotNull Player player, @NotNull ItemStack item, int level);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nexmedia.engine.Version;
|
||||
import su.nexmedia.engine.utils.Reflex;
|
||||
import su.nightexpress.excellentenchants.ExcellentEnchants;
|
||||
import su.nightexpress.excellentenchants.config.Config;
|
||||
@ -123,6 +124,11 @@ public class EnchantRegistry {
|
||||
this.register(EnchantPoisonedArrows.ID, () -> new EnchantPoisonedArrows(plugin));
|
||||
this.register(EnchantWitheredArrows.ID, () -> new EnchantWitheredArrows(plugin));
|
||||
|
||||
if (Version.isAbove(Version.V1_18_R2)) {
|
||||
this.register(DarknessArrowsEnchant.ID, () -> new DarknessArrowsEnchant(plugin));
|
||||
this.register(DarknessCloakEnchant.ID, () -> new DarknessCloakEnchant(plugin));
|
||||
}
|
||||
|
||||
// Universal
|
||||
this.register(EnchantCurseOfFragility.ID, () -> new EnchantCurseOfFragility(plugin));
|
||||
this.register(CurseOfMediocrityEnchant.ID, () -> new CurseOfMediocrityEnchant(plugin));
|
||||
|
@ -0,0 +1,81 @@
|
||||
package su.nightexpress.excellentenchants.enchantment.impl.armor;
|
||||
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.enchantments.EnchantmentTarget;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.api.particle.SimpleParticle;
|
||||
import su.nightexpress.excellentenchants.ExcellentEnchants;
|
||||
import su.nightexpress.excellentenchants.Placeholders;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority;
|
||||
|
||||
public class DarknessCloakEnchant extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant {
|
||||
|
||||
public static final String ID = "darkness_cloak";
|
||||
|
||||
private ChanceImplementation chanceImplementation;
|
||||
private PotionImplementation potionImplementation;
|
||||
|
||||
public DarknessCloakEnchant(@NotNull ExcellentEnchants plugin) {
|
||||
super(plugin, ID, EnchantPriority.MEDIUM);
|
||||
this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to apply " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) on attacker.");
|
||||
this.getDefaults().setLevelMax(3);
|
||||
this.getDefaults().setTier(0.2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadSettings() {
|
||||
super.loadSettings();
|
||||
this.chanceImplementation = ChanceImplementation.create(this,
|
||||
"20.0 * " + Placeholders.ENCHANTMENT_LEVEL + " * 0.75");
|
||||
|
||||
this.potionImplementation = PotionImplementation.create(this, PotionEffectType.DARKNESS, false,
|
||||
"2.5" + Placeholders.ENCHANTMENT_LEVEL,
|
||||
Placeholders.ENCHANTMENT_LEVEL);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ChanceImplementation getChanceImplementation() {
|
||||
return chanceImplementation;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PotionImplementation getPotionImplementation() {
|
||||
return potionImplementation;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
return EnchantmentTarget.ARMOR_TORSO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) {
|
||||
if (!this.isAvailableToUse(victim)) return false;
|
||||
if (!this.checkTriggerChance(level)) return false;
|
||||
if (!this.addEffect(damager, level)) return false;
|
||||
|
||||
if (this.hasVisualEffects()) {
|
||||
SimpleParticle.of(Particle.ASH).play(damager.getEyeLocation(), 0.75, 0.1, 30);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -12,7 +12,9 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -28,6 +30,7 @@ import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -75,6 +78,10 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable {
|
||||
BLOCKS_TO_DESTROY.put(block, Pair.of(System.currentTimeMillis() + (long) seconds * 1000L, Rnd.get(100)));
|
||||
}
|
||||
|
||||
public static boolean isBlock(@NotNull Block block) {
|
||||
return BLOCKS_TO_DESTROY.containsKey(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
@ -111,14 +118,34 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFlameWalkerBlock(BlockBreakEvent e) {
|
||||
if (BLOCKS_TO_DESTROY.containsKey(e.getBlock())) {
|
||||
e.setDropItems(false);
|
||||
e.setExpToDrop(0);
|
||||
e.getBlock().setType(Material.LAVA);
|
||||
public void onFlameWalkerBlock(BlockBreakEvent event) {
|
||||
if (isBlock(event.getBlock())) {
|
||||
event.setDropItems(false);
|
||||
event.setExpToDrop(0);
|
||||
event.getBlock().setType(Material.LAVA);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockExplode(EntityExplodeEvent event) {
|
||||
this.processExplosion(event.blockList());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockExplode2(BlockExplodeEvent event) {
|
||||
this.processExplosion(event.blockList());
|
||||
}
|
||||
|
||||
private void processExplosion(@NotNull List<Block> blocks) {
|
||||
blocks.removeIf(block -> {
|
||||
if (isBlock(block)) {
|
||||
block.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onMagmaDamage(EntityDamageEvent e) {
|
||||
if (e.getCause() != EntityDamageEvent.DamageCause.HOT_FLOOR) return;
|
||||
|
@ -0,0 +1,98 @@
|
||||
package su.nightexpress.excellentenchants.enchantment.impl.bow;
|
||||
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.enchantments.EnchantmentTarget;
|
||||
import org.bukkit.entity.AbstractArrow;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.api.particle.SimpleParticle;
|
||||
import su.nightexpress.excellentenchants.ExcellentEnchants;
|
||||
import su.nightexpress.excellentenchants.Placeholders;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority;
|
||||
|
||||
public class DarknessArrowsEnchant extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant {
|
||||
|
||||
public static final String ID = "darkness_arrows";
|
||||
|
||||
private ArrowImplementation arrowImplementation;
|
||||
private ChanceImplementation chanceImplementation;
|
||||
private PotionImplementation potionImplementation;
|
||||
|
||||
public DarknessArrowsEnchant(@NotNull ExcellentEnchants plugin) {
|
||||
super(plugin, ID, EnchantPriority.MEDIUM);
|
||||
this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)");
|
||||
this.getDefaults().setLevelMax(3);
|
||||
this.getDefaults().setTier(0.1);
|
||||
this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadSettings() {
|
||||
super.loadSettings();
|
||||
this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.ASH));
|
||||
this.chanceImplementation = ChanceImplementation.create(this,
|
||||
"25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5.0");
|
||||
this.potionImplementation = PotionImplementation.create(this, PotionEffectType.DARKNESS, false,
|
||||
"4.0 + " + Placeholders.ENCHANTMENT_LEVEL,
|
||||
Placeholders.ENCHANTMENT_LEVEL);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArrowImplementation getArrowImplementation() {
|
||||
return arrowImplementation;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ChanceImplementation getChanceImplementation() {
|
||||
return chanceImplementation;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PotionImplementation getPotionImplementation() {
|
||||
return potionImplementation;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) {
|
||||
if (!this.isAvailableToUse(shooter)) return false;
|
||||
if (!(e.getProjectile() instanceof Arrow arrow)) return false;
|
||||
if (!this.checkTriggerChance(level)) return false;
|
||||
|
||||
arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
|
||||
return arrow.addCustomEffect(this.createEffect(level), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) {
|
||||
return this.isOurProjectile(projectile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) {
|
||||
return this.isOurProjectile(projectile);
|
||||
}
|
||||
}
|
@ -37,7 +37,8 @@ public class EnchantBomber extends ExcellentEnchant implements Chanced, BowEncha
|
||||
EnchantEnderBow.ID, EnchantGhast.ID,
|
||||
EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID,
|
||||
EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID,
|
||||
EnchantHover.ID,
|
||||
DarknessArrowsEnchant.ID,
|
||||
EnchantHover.ID, FlareEnchant.ID,
|
||||
Enchantment.ARROW_FIRE.getKey().getKey(),
|
||||
Enchantment.ARROW_KNOCKBACK.getKey().getKey(),
|
||||
Enchantment.ARROW_DAMAGE.getKey().getKey()
|
||||
|
@ -38,11 +38,7 @@ public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced,
|
||||
this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)");
|
||||
this.getDefaults().setLevelMax(3);
|
||||
this.getDefaults().setTier(0.1);
|
||||
this.getDefaults().setConflicts(
|
||||
EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID, EnchantHover.ID,
|
||||
EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID,
|
||||
EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID
|
||||
);
|
||||
this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,12 +47,7 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced
|
||||
this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an dragonfire arrow (R=" + PLACEHOLDER_FIRE_RADIUS + ", " + PLACEHOLDER_FIRE_DURATION + "s).");
|
||||
this.getDefaults().setLevelMax(3);
|
||||
this.getDefaults().setTier(0.7);
|
||||
|
||||
this.getDefaults().setConflicts(
|
||||
EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID,
|
||||
EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID,
|
||||
EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID
|
||||
);
|
||||
this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,12 +42,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance
|
||||
this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an electrified arrow.");
|
||||
this.getDefaults().setLevelMax(3);
|
||||
this.getDefaults().setTier(0.3);
|
||||
|
||||
this.getDefaults().setConflicts(
|
||||
EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID,
|
||||
EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID,
|
||||
EnchantWitheredArrows.ID, EnchantDragonfireArrows.ID
|
||||
);
|
||||
this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,7 +33,8 @@ public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Cha
|
||||
EnchantBomber.ID, EnchantGhast.ID,
|
||||
EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID,
|
||||
EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID,
|
||||
EnchantHover.ID,
|
||||
DarknessArrowsEnchant.ID,
|
||||
EnchantHover.ID, FlareEnchant.ID,
|
||||
Enchantment.ARROW_FIRE.getKey().getKey(),
|
||||
Enchantment.ARROW_KNOCKBACK.getKey().getKey(),
|
||||
Enchantment.ARROW_DAMAGE.getKey().getKey()
|
||||
|
@ -47,12 +47,7 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced,
|
||||
this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an explosive arrow.");
|
||||
this.getDefaults().setLevelMax(3);
|
||||
this.getDefaults().setTier(0.7);
|
||||
|
||||
this.getDefaults().setConflicts(
|
||||
EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID,
|
||||
EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID,
|
||||
EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID
|
||||
);
|
||||
this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,7 +40,8 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance
|
||||
EnchantEnderBow.ID, EnchantBomber.ID,
|
||||
EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID,
|
||||
EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID,
|
||||
EnchantHover.ID,
|
||||
DarknessArrowsEnchant.ID,
|
||||
EnchantHover.ID, FlareEnchant.ID,
|
||||
Enchantment.ARROW_FIRE.getKey().getKey(),
|
||||
Enchantment.ARROW_KNOCKBACK.getKey().getKey(),
|
||||
Enchantment.ARROW_DAMAGE.getKey().getKey()
|
||||
|
@ -38,11 +38,7 @@ public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed,
|
||||
this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)");
|
||||
this.getDefaults().setLevelMax(3);
|
||||
this.getDefaults().setTier(0.1);
|
||||
this.getDefaults().setConflicts(
|
||||
EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID,
|
||||
EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID,
|
||||
EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID
|
||||
);
|
||||
this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,12 +38,7 @@ public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced,
|
||||
this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)");
|
||||
this.getDefaults().setLevelMax(3);
|
||||
this.getDefaults().setTier(0.1);
|
||||
|
||||
this.getDefaults().setConflicts(
|
||||
EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID,
|
||||
EnchantExplosiveArrows.ID, EnchantConfusingArrows.ID,
|
||||
EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID
|
||||
);
|
||||
this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,12 +38,7 @@ public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced,
|
||||
this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)");
|
||||
this.getDefaults().setLevelMax(3);
|
||||
this.getDefaults().setTier(0.5);
|
||||
|
||||
this.getDefaults().setConflicts(
|
||||
EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID,
|
||||
EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID,
|
||||
EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID
|
||||
);
|
||||
this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,12 +62,12 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer,
|
||||
public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer,
|
||||
@NotNull Player player, @NotNull ItemStack item, int level) {
|
||||
if (!this.isAvailableToUse(player)) return false;
|
||||
if (!this.checkTriggerChance(level)) return false;
|
||||
|
||||
e.getItems().forEach(drop -> {
|
||||
event.getItems().forEach(drop -> {
|
||||
ItemStack stack = drop.getItemStack();
|
||||
ItemUtil.mapMeta(stack, meta -> {
|
||||
meta.getEnchants().keySet().forEach(meta::removeEnchant);
|
||||
|
@ -102,8 +102,8 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) {
|
||||
BlockState state = e.getBlockState();
|
||||
public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) {
|
||||
BlockState state = event.getBlockState();
|
||||
Block block = state.getBlock();
|
||||
if (!block.hasMetadata(META_HANDLE)) return false;
|
||||
if (!(state instanceof CreatureSpawner spawnerBlock)) return false;
|
||||
|
@ -130,23 +130,29 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) {
|
||||
BlockState state = e.getBlockState();
|
||||
public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer,
|
||||
@NotNull Player player, @NotNull ItemStack item, int level) {
|
||||
BlockState state = event.getBlockState();
|
||||
Block block = state.getBlock();
|
||||
|
||||
if (!this.isAvailableToUse(player)) return false;
|
||||
if (!(state instanceof Chest chest)) return false;
|
||||
|
||||
// Добавляем в сундук обратно предметы из дроп листа, кроме самого сундука.
|
||||
e.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType() && drop.getItemStack().getAmount() == 1);
|
||||
chest.getBlockInventory().addItem(e.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0]));
|
||||
event.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType() && drop.getItemStack().getAmount() == 1);
|
||||
chest.getBlockInventory().addItem(event.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0]));
|
||||
|
||||
if (chest.getBlockInventory().isEmpty()) {
|
||||
dropContainer.getDrop().add(new ItemStack(chest.getType()));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Добавляем кастомный сундук в кастомный дроп лист.
|
||||
dropContainer.getDrop().add(this.getSilkChest(chest));
|
||||
|
||||
// Очищаем инвентарь сундука и дефолтный дроп лист.
|
||||
chest.getBlockInventory().clear();
|
||||
e.getItems().clear();
|
||||
event.getItems().clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -89,18 +89,18 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) {
|
||||
if (e.getBlockState() instanceof Container) return false;
|
||||
public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) {
|
||||
if (event.getBlockState() instanceof Container) return false;
|
||||
if (!this.isAvailableToUse(player)) return false;
|
||||
if (!this.checkTriggerChance(level)) return false;
|
||||
if (e.getItems().stream().noneMatch(drop -> this.isSmeltable(drop.getItemStack().getType()))) return false;
|
||||
if (event.getItems().stream().noneMatch(drop -> this.isSmeltable(drop.getItemStack().getType()))) return false;
|
||||
|
||||
e.getItems().forEach(drop -> {
|
||||
event.getItems().forEach(drop -> {
|
||||
Material material = this.smeltingTable.get(drop.getItemStack().getType());
|
||||
if (material != null) drop.getItemStack().setType(material);
|
||||
});
|
||||
|
||||
Block block = e.getBlockState().getBlock();
|
||||
Block block = event.getBlockState().getBlock();
|
||||
if (this.hasVisualEffects()) {
|
||||
Location location = LocationUtil.getCenter(block.getLocation(), true);
|
||||
LocationUtil.sound(location, this.sound);
|
||||
|
@ -58,18 +58,18 @@ public class EnchantTelekinesis extends ExcellentEnchant implements Chanced, Blo
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) {
|
||||
public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) {
|
||||
if (!this.isAvailableToUse(player)) return false;
|
||||
if (!this.checkTriggerChance(level)) return false;
|
||||
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
drops.addAll(e.getItems().stream().map(Item::getItemStack).toList());
|
||||
drops.addAll(event.getItems().stream().map(Item::getItemStack).toList());
|
||||
drops.addAll(dropContainer.getDrop());
|
||||
drops.removeIf(Objects::isNull);
|
||||
drops.forEach(drop -> PlayerUtil.addItem(player, drop));
|
||||
|
||||
dropContainer.getDrop().clear();
|
||||
e.getItems().clear();
|
||||
event.getItems().clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -136,8 +136,8 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) {
|
||||
Block block = e.getBlockState().getBlock();
|
||||
public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) {
|
||||
Block block = event.getBlockState().getBlock();
|
||||
if (block.hasMetadata(META)) {
|
||||
block.removeMetadata(META, plugin);
|
||||
return false;
|
||||
@ -145,7 +145,7 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block
|
||||
if (!this.isAvailableToUse(player)) return false;
|
||||
if (!this.checkTriggerChance(level)) return false;
|
||||
|
||||
dropContainer.getDrop().addAll(this.getTreasures(e.getBlockState().getType()));
|
||||
dropContainer.getDrop().addAll(this.getTreasures(event.getBlockState().getType()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,6 @@
|
||||
# +---------------------------------------------------------+
|
||||
# | Официальная русская версия. |
|
||||
# | Публикация на помойках rubukkit и spigotru ЗАПРЕЩЕНА. |
|
||||
# +---------------------------------------------------------+
|
||||
Command:
|
||||
List:
|
||||
Desc: 'Список всех нестандартных зачарований.'
|
||||
Desc: 'Меню дополнительных зачарований.'
|
||||
Enchant:
|
||||
Usage: '<зачарование> <уровень>'
|
||||
Desc: 'Зачарование предмета в руке.'
|
||||
|
Loading…
Reference in New Issue
Block a user