Improved codestyle (8/?)
This commit is contained in:
@@ -11,18 +11,21 @@ import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PacketChat extends AbstractPacketAdapter {
|
||||
public PacketChat(AbstractEcoPlugin plugin) {
|
||||
public PacketChat(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin, PacketType.Play.Server.CHAT, ListenerPriority.MONITOR, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSend(@NotNull PacketContainer packet) {
|
||||
public void onSend(@NotNull final PacketContainer packet) {
|
||||
for (int i = 0; i < packet.getChatComponents().size(); i++) {
|
||||
WrappedChatComponent component = packet.getChatComponents().read(i);
|
||||
if (component == null)
|
||||
if (component == null) {
|
||||
continue;
|
||||
if (component.getHandle() == null)
|
||||
}
|
||||
|
||||
if (component.getHandle() == null) {
|
||||
return;
|
||||
}
|
||||
WrappedChatComponent newComponent = WrappedChatComponent.fromHandle(ProxyUtils.getProxy(ChatComponentProxy.class).modifyComponent(component.getHandle()));
|
||||
packet.getChatComponents().write(i, newComponent);
|
||||
}
|
||||
|
||||
@@ -18,18 +18,19 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PacketOpenWindowMerchant extends AbstractPacketAdapter {
|
||||
public PacketOpenWindowMerchant(AbstractEcoPlugin plugin) {
|
||||
public PacketOpenWindowMerchant(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin, PacketType.Play.Server.OPEN_WINDOW_MERCHANT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSend(@NotNull PacketContainer packet) {
|
||||
public void onSend(@NotNull final PacketContainer packet) {
|
||||
List<MerchantRecipe> recipes = packet.getMerchantRecipeLists().readSafely(0);
|
||||
|
||||
recipes = recipes.stream().peek(merchantRecipe -> {
|
||||
try {
|
||||
if (!EnchantmentTarget.ALL.getMaterials().contains(merchantRecipe.getResult().getType()))
|
||||
if (!EnchantmentTarget.ALL.getMaterials().contains(merchantRecipe.getResult().getType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Enables removing final modifier
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
|
||||
@@ -8,15 +8,12 @@ import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PacketSetCreativeSlot extends AbstractPacketAdapter {
|
||||
public PacketSetCreativeSlot(AbstractEcoPlugin plugin) {
|
||||
public PacketSetCreativeSlot(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin, PacketType.Play.Client.SET_CREATIVE_SLOT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(@NotNull PacketContainer packet) {
|
||||
packet.getItemModifier().modify(0, (item) -> {
|
||||
item = EnchantDisplay.revertDisplay(item);
|
||||
return item;
|
||||
});
|
||||
public void onReceive(@NotNull final PacketContainer packet) {
|
||||
packet.getItemModifier().modify(0, EnchantDisplay::revertDisplay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,17 +9,18 @@ import org.bukkit.inventory.ItemFlag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PacketSetSlot extends AbstractPacketAdapter {
|
||||
public PacketSetSlot(AbstractEcoPlugin plugin) {
|
||||
public PacketSetSlot(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin, PacketType.Play.Server.SET_SLOT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSend(@NotNull PacketContainer packet) {
|
||||
packet.getItemModifier().modify(0, (item) -> {
|
||||
public void onSend(@NotNull final PacketContainer packet) {
|
||||
packet.getItemModifier().modify(0, item -> {
|
||||
boolean hideEnchants = false;
|
||||
|
||||
if (item == null)
|
||||
return item;
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (item.getItemMeta() != null) {
|
||||
hideEnchants = item.getItemMeta().getItemFlags().contains(ItemFlag.HIDE_ENCHANTS);
|
||||
|
||||
@@ -9,17 +9,20 @@ import org.bukkit.inventory.ItemFlag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PacketWindowItems extends AbstractPacketAdapter {
|
||||
public PacketWindowItems(AbstractEcoPlugin plugin) {
|
||||
public PacketWindowItems(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin, PacketType.Play.Server.WINDOW_ITEMS, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSend(@NotNull PacketContainer packet) {
|
||||
packet.getItemListModifier().modify(0, (itemStacks) -> {
|
||||
if (itemStacks == null) return null;
|
||||
public void onSend(@NotNull final PacketContainer packet) {
|
||||
packet.getItemListModifier().modify(0, itemStacks -> {
|
||||
if (itemStacks == null) {
|
||||
return null;
|
||||
}
|
||||
itemStacks.forEach(item -> {
|
||||
if (item == null)
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean hideEnchants = false;
|
||||
|
||||
|
||||
@@ -20,9 +20,14 @@ public class Netheric extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
if(!attacker.getWorld().getEnvironment().equals(World.Environment.NETHER))
|
||||
public void onArrowDamage(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
@NotNull final Arrow arrow,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!attacker.getWorld().getEnvironment().equals(World.Environment.NETHER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
|
||||
|
||||
@@ -19,12 +19,17 @@ public class Nocturnal extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
if(!attacker.getWorld().getEnvironment().equals(World.Environment.NORMAL))
|
||||
public void onMeleeAttack(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!attacker.getWorld().getEnvironment().equals(World.Environment.NORMAL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(attacker.getWorld().getTime() > 12300 && attacker.getWorld().getTime() < 23850))
|
||||
if (!(attacker.getWorld().getTime() > 12300 && attacker.getWorld().getTime() < 23850)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
|
||||
|
||||
@@ -20,7 +20,11 @@ public class Optics extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
public void onArrowDamage(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
@NotNull final Arrow arrow,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
Location land = arrow.getLocation();
|
||||
Location source = attacker.getLocation();
|
||||
|
||||
|
||||
@@ -20,8 +20,13 @@ public class Oxygenate extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(@NotNull Player player, @NotNull Block block, int level, @NotNull BlockBreakEvent event) {
|
||||
if(player.getRemainingAir() == player.getMaximumAir()) return;
|
||||
public void onBlockBreak(@NotNull final Player player,
|
||||
@NotNull final Block block,
|
||||
final int level,
|
||||
@NotNull final BlockBreakEvent event) {
|
||||
if (player.getRemainingAir() == player.getMaximumAir()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int oxygenLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "oxygen-per-level");
|
||||
int oxygen = level * oxygenLevel;
|
||||
@@ -30,4 +35,4 @@ public class Oxygenate extends EcoEnchant {
|
||||
|
||||
player.setRemainingAir(newOxygen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,14 @@ public class Pacify extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onTridentDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Trident trident, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
if(!(victim instanceof Creeper)) return;
|
||||
public void onTridentDamage(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
@NotNull final Trident trident,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(victim instanceof Creeper)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double damage = event.getDamage();
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
|
||||
@@ -19,8 +19,13 @@ public class Paladin extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
if(!(attacker.getVehicle() instanceof Horse)) return;
|
||||
public void onMeleeAttack(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(attacker.getVehicle() instanceof Horse)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double damage = event.getDamage();
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
|
||||
@@ -22,11 +22,15 @@ public class Paralyze extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onDeflect(@NotNull Player blocker, @NotNull LivingEntity attacker, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
public void onDeflect(@NotNull final Player blocker,
|
||||
@NotNull final LivingEntity attacker,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
if (!EnchantmentUtils.passedChance(this, level)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int finalDuration = duration * level;
|
||||
|
||||
|
||||
@@ -20,7 +20,11 @@ public class Parasitic extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
public void onArrowDamage(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
@NotNull final Arrow arrow,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level");
|
||||
double amountToHeal = level * multiplier;
|
||||
double newHealth = attacker.getHealth() + amountToHeal;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Parry extends EcoEnchant {
|
||||
public Parry() {
|
||||
@@ -18,18 +19,24 @@ public class Parry extends EcoEnchant {
|
||||
// START OF LISTENERS
|
||||
|
||||
@EventHandler
|
||||
public void parryHit(EntityDamageByEntityEvent event) {
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
public void parryHit(@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.isCancelled())
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (!EnchantChecks.mainhand(player, this)) return;
|
||||
if (!EnchantChecks.mainhand(player, this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.getDisabledWorlds().contains(player.getWorld())) return;
|
||||
if (this.getDisabledWorlds().contains(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
int level = EnchantChecks.getMainhandLevel(player, this);
|
||||
|
||||
|
||||
@@ -21,8 +21,14 @@ public class Phantasm extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onTridentDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Trident trident, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
if(!(victim instanceof Zombie || victim instanceof Skeleton)) return;
|
||||
public void onTridentDamage(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
@NotNull final Trident trident,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(victim instanceof Zombie || victim instanceof Skeleton)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double damage = event.getDamage();
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
|
||||
@@ -22,11 +22,11 @@ public class Plasmic extends EcoEnchant {
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
private static final Material[] items;
|
||||
private static final Material[] ITEMS;
|
||||
|
||||
static {
|
||||
if(Prerequisite.MINIMUM_1_16.isMet()) {
|
||||
items = new Material[]{
|
||||
if (Prerequisite.MINIMUM_1_16.isMet()) {
|
||||
ITEMS = new Material[]{
|
||||
Material.DIAMOND_HELMET,
|
||||
Material.DIAMOND_CHESTPLATE,
|
||||
Material.DIAMOND_LEGGINGS,
|
||||
@@ -38,7 +38,7 @@ public class Plasmic extends EcoEnchant {
|
||||
Material.NETHERITE_BOOTS
|
||||
};
|
||||
} else {
|
||||
items = new Material[]{
|
||||
ITEMS = new Material[]{
|
||||
Material.DIAMOND_HELMET,
|
||||
Material.DIAMOND_CHESTPLATE,
|
||||
Material.DIAMOND_LEGGINGS,
|
||||
@@ -48,17 +48,28 @@ public class Plasmic extends EcoEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
public void onMeleeAttack(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
EntityEquipment equipment = victim.getEquipment();
|
||||
if(equipment == null) return;
|
||||
if (equipment == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int pieces = 0;
|
||||
for (ItemStack armorPiece : equipment.getArmorContents()) {
|
||||
if(armorPiece == null) continue;
|
||||
if(Arrays.asList(items).contains(armorPiece.getType())) pieces++;
|
||||
if (armorPiece == null) {
|
||||
continue;
|
||||
}
|
||||
if (Arrays.asList(ITEMS).contains(armorPiece.getType())) {
|
||||
pieces++;
|
||||
}
|
||||
}
|
||||
|
||||
if(pieces == 0) return;
|
||||
if (pieces == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
|
||||
|
||||
@@ -17,12 +17,21 @@ public class Protector extends EcoEnchant {
|
||||
// START OF LISTENERS
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity uncastVictim, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
if(!(uncastVictim instanceof Tameable)) return;
|
||||
public void onMeleeAttack(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity uncastVictim,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(uncastVictim instanceof Tameable)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tameable victim = (Tameable) uncastVictim;
|
||||
if(victim.getOwner() == null) return;
|
||||
if(!victim.getOwner().equals(attacker)) return;
|
||||
if (victim.getOwner() == null) {
|
||||
return;
|
||||
}
|
||||
if (!victim.getOwner().equals(attacker)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@@ -18,13 +18,17 @@ public class Proximity extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
public void onMeleeAttack(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
double distance = attacker.getLocation().distance(victim.getLocation());
|
||||
|
||||
double decreaseAfter = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "when-closer-than-blocks");
|
||||
|
||||
if(distance > decreaseAfter)
|
||||
if (distance > decreaseAfter) {
|
||||
return;
|
||||
}
|
||||
|
||||
double damage = event.getDamage();
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
|
||||
@@ -21,9 +21,14 @@ public class Puncture extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onTridentDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Trident trident, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
if(!(victim instanceof Turtle || victim instanceof Shulker))
|
||||
public void onTridentDamage(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
@NotNull final Trident trident,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(victim instanceof Turtle || victim instanceof Shulker)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double damage = event.getDamage();
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
|
||||
@@ -20,9 +20,14 @@ public class Quadrilateralism extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
if(!(victim instanceof Slime))
|
||||
public void onArrowDamage(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
@NotNull final Arrow arrow,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(victim instanceof Slime)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
|
||||
|
||||
@@ -22,16 +22,27 @@ public class Radiance extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
public void onArrowDamage(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
@NotNull final Arrow arrow,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
double radius = level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-multiplier");
|
||||
int duration = level * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level");
|
||||
|
||||
for (Entity e : arrow.getNearbyEntities(radius, radius, radius)) {
|
||||
if(e.hasMetadata("NPC")) continue;
|
||||
if (e.hasMetadata("NPC")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(e instanceof LivingEntity)) continue;
|
||||
if (!(e instanceof LivingEntity)) {
|
||||
continue;
|
||||
}
|
||||
LivingEntity entity = (LivingEntity) e;
|
||||
if(e.equals(attacker)) continue;
|
||||
|
||||
if (e.equals(attacker)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
entity.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, duration, 0, false, false, false));
|
||||
}
|
||||
|
||||
@@ -25,15 +25,22 @@ public class Rage extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
|
||||
if (!EnchantmentUtils.passedChance(this, level))
|
||||
public void onArrowDamage(@NotNull final LivingEntity attacker,
|
||||
@NotNull final LivingEntity victim,
|
||||
@NotNull final Arrow arrow,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!EnchantmentUtils.passedChance(this, level)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double distancePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level");
|
||||
final double distance = distancePerLevel * level;
|
||||
|
||||
for (Entity e : victim.getWorld().getNearbyEntities(victim.getLocation(), distance, distance, distance)) {
|
||||
if (!(e instanceof Monster)) continue;
|
||||
if (!(e instanceof Monster)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (e instanceof PigZombie) {
|
||||
((PigZombie) e).setAngry(true);
|
||||
|
||||
@@ -23,9 +23,14 @@ public class Pentashot extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onBowShoot(@NotNull LivingEntity shooter, @NotNull Arrow arrow, int level, @NotNull EntityShootBowEvent event) {
|
||||
public void onBowShoot(@NotNull final LivingEntity shooter,
|
||||
@NotNull final Arrow arrow,
|
||||
final int level,
|
||||
@NotNull final EntityShootBowEvent event) {
|
||||
for (int i = -2; i <= 2; i += 1) {
|
||||
if(i == 0) continue;
|
||||
if (i == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector velocity = event.getProjectile().getVelocity();
|
||||
|
||||
|
||||
@@ -18,12 +18,16 @@ public class Preservation extends EcoEnchant {
|
||||
|
||||
|
||||
@Override
|
||||
public void onDamageWearingArmor(@NotNull LivingEntity victim, int level, @NotNull EntityDamageEvent event) {
|
||||
if(event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) return;
|
||||
public void onDamageWearingArmor(@NotNull final LivingEntity victim,
|
||||
final int level,
|
||||
@NotNull final EntityDamageEvent event) {
|
||||
if (event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-less-per-level");
|
||||
|
||||
double multiplier = 1 - (reduction/100 * level);
|
||||
double multiplier = 1 - ((reduction / 100) * level);
|
||||
|
||||
event.setDamage(event.getDamage() * multiplier);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ public class Quake extends Spell {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUse(@NotNull Player player, int level, @NotNull PlayerInteractEvent event) {
|
||||
public void onUse(@NotNull final Player player,
|
||||
final int level,
|
||||
@NotNull final PlayerInteractEvent event) {
|
||||
int radius = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "radius-per-level") * level;
|
||||
int damage = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * level;
|
||||
|
||||
@@ -25,11 +27,15 @@ public class Quake extends Spell {
|
||||
Collection<Entity> entities = player.getWorld().getNearbyEntities(player.getLocation(), radius, 3, radius);
|
||||
|
||||
for (Entity entity : entities) {
|
||||
if (entity.equals(player))
|
||||
if (entity.equals(player)) {
|
||||
continue;
|
||||
if (!(entity instanceof LivingEntity)) continue;
|
||||
if (!AntigriefManager.canInjure(player, (LivingEntity) entity))
|
||||
}
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
continue;
|
||||
}
|
||||
if (!AntigriefManager.canInjure(player, (LivingEntity) entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
((LivingEntity) entity).damage(damage);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.willfp.eco.core.proxy;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@UtilityClass
|
||||
public class ProxyConstants {
|
||||
/**
|
||||
* The NMS version that the server is running on.
|
||||
|
||||
@@ -11,4 +11,4 @@ public interface OpenInventoryProxy extends AbstractProxy {
|
||||
* @return The NMS inventory container.
|
||||
*/
|
||||
Object getOpenInventory(@NotNull Player player);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user