Javadoc (1/?)

This commit is contained in:
Auxilor 2020-12-28 17:27:48 +00:00
parent c13e874655
commit 6c47f38cb7
54 changed files with 206 additions and 69 deletions

View File

@ -32,6 +32,10 @@
-->
<module name="Checker">
<module name="SuppressionFilter">
<property name="file" value="config/checkstyle/suppression.xml"/>
</module>
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
@ -89,14 +93,12 @@
<!-- Checks for Javadoc comments. -->
<!-- See https://checkstyle.org/config_javadoc.html -->
<!--
<module name="InvalidJavadocPosition"/>
<module name="JavadocMethod"/>
<module name="JavadocType"/>
<module name="JavadocVariable"/>
<module name="JavadocStyle"/>
<module name="MissingJavadocMethod"/>
-->
<!-- Checks for Naming Conventions. -->
<!-- See https://checkstyle.org/config_naming.html -->
@ -166,7 +168,7 @@
<!-- See https://checkstyle.org/config_design.html -->
<!-- <module name="DesignForExtension"/> -->
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<!-- <module name="HideUtilityClassConstructor"/> -->
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>
<module name="RequireThis"/>

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress files="[\\/]enchantments[\\/]ecoenchants[\\/]" checks="MissingJavadocMethod"/>
<suppress files="[\\/]enchantments[\\/]ecoenchants[\\/]" checks="JavadocVariable"/>
</suppressions>

View File

@ -26,6 +26,11 @@ import java.util.stream.Collectors;
@SuppressWarnings("unchecked")
public class CommandEcodebug extends AbstractCommand {
/**
* Instantiate a new /ecodebug command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandEcodebug(@NotNull final AbstractEcoPlugin plugin) {
super(plugin, "ecodebug", "ecoenchants.ecodebug", false);
}

View File

@ -9,6 +9,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
public class CommandEcoreload extends AbstractCommand {
/**
* Instantiate a new /ecoreload command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandEcoreload(@NotNull final AbstractEcoPlugin plugin) {
super(plugin, "ecoreload", "ecoenchants.reload", false);
}

View File

@ -21,6 +21,11 @@ import java.util.List;
import java.util.Set;
public class CommandEnchantinfo extends AbstractCommand {
/**
* Instantiate a new /enchantinfo command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandEnchantinfo(@NotNull final AbstractEcoPlugin plugin) {
super(plugin, "enchantinfo", "ecoenchants.enchantinfo", false);
}

View File

@ -5,30 +5,34 @@ import com.willfp.eco.util.config.Configs;
import com.willfp.ecoenchants.display.options.interfaces.ThresholdedOption;
import com.willfp.ecoenchants.display.options.interfaces.ToggleableOption;
import com.willfp.ecoenchants.display.options.interfaces.UpdateableOption;
import lombok.Getter;
public class DescriptionOptions implements ThresholdedOption, ToggleableOption, UpdateableOption {
/**
* The threshold below which to describe enchantments.
*/
@Getter
private int threshold;
/**
* If the options are enabled.
*/
@Getter
private boolean enabled;
/**
* The description lines color.
*/
@Getter
private String color;
@Override
public int getThreshold() {
return threshold;
}
@Override
public boolean isEnabled() {
return enabled;
}
/**
* Update the options.
*/
@Override
public void update() {
threshold = Configs.CONFIG.getInt("lore.describe.before-lines");
enabled = Configs.CONFIG.getBool("lore.describe.enabled");
color = StringUtils.translate(Configs.LANG.getString("description-color"));
}
public String getColor() {
return color;
}
}

View File

@ -64,7 +64,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
private boolean enabled;
/**
* Create a new EcoEnchant
* Create a new EcoEnchant.
*
* @param key The key name of the enchantment
* @param type The type of the enchantment

View File

@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.eco.util.optional.Prerequisite;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class AshArtifact extends Artifact {
public AshArtifact() {
@ -13,7 +14,7 @@ public class AshArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.WHITE_ASH;
}
}

View File

@ -3,6 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Color;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class CloudsArtifact extends Artifact {
public CloudsArtifact() {
super(
@ -11,7 +13,7 @@ public class CloudsArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.REDSTONE;
}

View File

@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.eco.util.optional.Prerequisite;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class CrimsonArtifact extends Artifact {
public CrimsonArtifact() {
@ -13,7 +14,7 @@ public class CrimsonArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.CRIMSON_SPORE;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class DamageArtifact extends Artifact {
public DamageArtifact() {
super(
@ -10,7 +12,7 @@ public class DamageArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.DAMAGE_INDICATOR;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class DragonArtifact extends Artifact {
public DragonArtifact() {
super(
@ -10,7 +12,7 @@ public class DragonArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.DRAGON_BREATH;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class DustArtifact extends Artifact {
public DustArtifact() {
super(
@ -10,7 +12,7 @@ public class DustArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.CRIT;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class EmeraldArtifact extends Artifact {
public EmeraldArtifact() {
super(
@ -10,7 +12,7 @@ public class EmeraldArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.COMPOSTER;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class EnchantmentArtifact extends Artifact {
public EnchantmentArtifact() {
super(
@ -10,7 +12,7 @@ public class EnchantmentArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.ENCHANTMENT_TABLE;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class EndArtifact extends Artifact {
public EndArtifact() {
super(
@ -10,7 +12,7 @@ public class EndArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.END_ROD;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class FireArtifact extends Artifact {
public FireArtifact() {
super(
@ -10,7 +12,7 @@ public class FireArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.FLAME;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class HeartArtifact extends Artifact {
public HeartArtifact() {
super(
@ -10,7 +12,7 @@ public class HeartArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.HEART;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class HoneyArtifact extends Artifact {
public HoneyArtifact() {
super(
@ -10,7 +12,7 @@ public class HoneyArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.FALLING_HONEY;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class InkArtifact extends Artifact {
public InkArtifact() {
super(
@ -10,7 +12,7 @@ public class InkArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.SQUID_INK;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class LavaArtifact extends Artifact {
public LavaArtifact() {
super(
@ -10,7 +12,7 @@ public class LavaArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.DRIP_LAVA;
}
}

View File

@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Color;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class LimeArtifact extends Artifact {
public LimeArtifact() {
@ -12,7 +13,7 @@ public class LimeArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.REDSTONE;
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class MagicArtifact extends Artifact {
public MagicArtifact() {
super(
@ -10,7 +12,7 @@ public class MagicArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.CRIT_MAGIC;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class MagmaArtifact extends Artifact {
public MagmaArtifact() {
super(
@ -10,7 +12,7 @@ public class MagmaArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.LAVA;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class MusicArtifact extends Artifact {
public MusicArtifact() {
super(
@ -10,7 +12,7 @@ public class MusicArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.NOTE;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class NetherArtifact extends Artifact {
public NetherArtifact() {
super(
@ -10,7 +12,7 @@ public class NetherArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.PORTAL;
}
}

View File

@ -3,6 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Color;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class RedstoneArtifact extends Artifact {
public RedstoneArtifact() {
super(
@ -11,7 +13,7 @@ public class RedstoneArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.REDSTONE;
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class SmokeArtifact extends Artifact {
public SmokeArtifact() {
super(
@ -10,7 +12,7 @@ public class SmokeArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.CAMPFIRE_COSY_SMOKE;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class SnowArtifact extends Artifact {
public SnowArtifact() {
super(
@ -10,7 +12,7 @@ public class SnowArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.SNOWBALL;
}
}

View File

@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.eco.util.optional.Prerequisite;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class SoulArtifact extends Artifact {
public SoulArtifact() {
@ -13,7 +14,7 @@ public class SoulArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.SOUL;
}
}

View File

@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.eco.util.optional.Prerequisite;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class SoulFireArtifact extends Artifact {
public SoulFireArtifact() {
@ -13,7 +14,7 @@ public class SoulFireArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.SOUL_FIRE_FLAME;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class SparkleArtifact extends Artifact {
public SparkleArtifact() {
super(
@ -10,7 +12,7 @@ public class SparkleArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.FIREWORKS_SPARK;
}
}

View File

@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.eco.util.optional.Prerequisite;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class TearArtifact extends Artifact {
public TearArtifact() {
@ -13,7 +14,7 @@ public class TearArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.DRIPPING_OBSIDIAN_TEAR;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class TotemArtifact extends Artifact {
public TotemArtifact() {
super(
@ -10,7 +12,7 @@ public class TotemArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.TOTEM;
}
}

View File

@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.eco.util.optional.Prerequisite;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class WarpedArtifact extends Artifact {
public WarpedArtifact() {
@ -13,7 +14,7 @@ public class WarpedArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.WARPED_SPORE;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class WaterArtifact extends Artifact {
public WaterArtifact() {
super(
@ -10,7 +12,7 @@ public class WaterArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.DRIP_WATER;
}
}

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class WitchArtifact extends Artifact {
public WitchArtifact() {
super(
@ -10,7 +12,7 @@ public class WitchArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.SPELL_WITCH;
}
}

View File

@ -3,6 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Color;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class ZapArtifact extends Artifact {
public ZapArtifact() {
super(
@ -11,7 +13,7 @@ public class ZapArtifact extends Artifact {
}
@Override
public Particle getParticle() {
public @NotNull Particle getParticle() {
return Particle.REDSTONE;
}

View File

@ -15,6 +15,7 @@ public class Abattoir extends EcoEnchant {
"abattoir", EnchantmentType.NORMAL
);
}
@Override
public void onTridentDamage(@NotNull final LivingEntity attacker,
@NotNull final LivingEntity victim,

View File

@ -7,7 +7,6 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
public class Aerial extends EcoEnchant {

View File

@ -11,7 +11,6 @@ import org.bukkit.Particle;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;

View File

@ -8,7 +8,6 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
public class Cleave extends EcoEnchant {

View File

@ -11,7 +11,6 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;

View File

@ -12,7 +12,6 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;

View File

@ -8,7 +8,6 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
public class Marking extends EcoEnchant {

View File

@ -13,7 +13,6 @@ import org.bukkit.entity.Trident;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
public class Shockwave extends EcoEnchant {

View File

@ -12,7 +12,6 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;

View File

@ -7,7 +7,6 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
public class Weakening extends EcoEnchant {

View File

@ -8,7 +8,6 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
public class Carve extends EcoEnchant {

View File

@ -11,7 +11,6 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;

View File

@ -25,13 +25,24 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Wrapper for Artifact enchantments
* in order to reduce copying existing code between artifacts.
*/
public abstract class Artifact extends EcoEnchant {
/**
* The artifact particle.
*/
private Particle particle;
/**
* The extra particle dust options.
* <p>
* Used for redstone particles.
*/
@Nullable
private Particle.DustOptions extra;
protected Artifact(@NotNull final String key,
@ -47,12 +58,29 @@ public abstract class Artifact extends EcoEnchant {
this.extra = this.getDustOptions();
}
/**
* Get the artifact particle.
*
* @return The artifact particle.
*/
@NotNull
public abstract Particle getParticle();
/**
* The extra particle dust options.
*
* @return The dust options.
*/
@Nullable
public Particle.DustOptions getDustOptions() {
return null;
}
/**
* Called on block break.
*
* @param event The event to listen for.
*/
@EventHandler
public void onBreak(@NotNull final BlockBreakEvent event) {
Player player = event.getPlayer();
@ -70,6 +98,11 @@ public abstract class Artifact extends EcoEnchant {
block.getWorld().spawnParticle(particle, block.getLocation().add(0.5, 0.5, 0.5), amount, 0.4, 0.4, 0.4, 0, extra, false);
}
/**
* Called on player fly while wearing an elytra.
*
* @param event The event to listen for.
*/
@EventHandler
public void onElytra(@NotNull final PlayerMoveEvent event) {
Player player = event.getPlayer();
@ -96,6 +129,11 @@ public abstract class Artifact extends EcoEnchant {
player.getWorld().spawnParticle(particle, location2, 1, 0, 0, 0, 0, extra, true);
}
/**
* Called when a player hits an entity.
*
* @param event The event to listen for.
*/
@EventHandler
public void onHit(@NotNull final EntityDamageByEntityEvent event) {
if (!(event.getDamager() instanceof Player)) {
@ -136,6 +174,11 @@ public abstract class Artifact extends EcoEnchant {
}).runTaskTimer(0, 1);
}
/**
* Called on projectile launch.
*
* @param event The event to listen for.
*/
@EventHandler
public void onShoot(@NotNull final ProjectileLaunchEvent event) {
if (!(event.getEntity() instanceof AbstractArrow)) {

View File

@ -23,13 +23,30 @@ import java.util.Objects;
import java.util.UUID;
public class AnvilListeners extends PluginDependent implements Listener {
/**
* Map to prevent incrementing cost several times as inventory events are fired 3 times.
*/
private static final HashMap<UUID, Integer> ANTI_REPEAT = new HashMap<>();
/**
* Class for AnvilGUI wrappers to ignore them.
*/
private static final String ANVIL_GUI_CLASS = "net.wesjd.anvilgui.version.Wrapper" + ProxyConstants.NMS_VERSION.substring(1) + "$AnvilContainer";
/**
* Instantiate anvil listeners and link them to a specific plugin.
*
* @param plugin The plugin to link to.
*/
public AnvilListeners(@NotNull final AbstractEcoPlugin plugin) {
super(plugin);
}
/**
* Called when items are placed into an anvil.
*
* @param event The event to listen to.
*/
@EventHandler(priority = EventPriority.HIGHEST)
public void onAnvilPrepare(@NotNull final PrepareAnvilEvent event) {
ItemStack left = event.getInventory().getItem(0);

View File

@ -23,17 +23,19 @@ import java.util.concurrent.atomic.AtomicInteger;
@UtilityClass
public class AnvilMerge {
/**
* Config key for allowing unsafe levels.
*/
private static final String ALLOW_UNSAFE_KEY = "anvil.allow-unsafe-levels";
/**
* Merge items in anvil
*
* @param left The {@link ItemStack} on the left of the anvil
* @param right The {@link ItemStack} in the middle of the anvil
* @param old The previous {@link ItemStack} result
* @param name The anvil display name
* @param player The player merging (for permissions)
* Merge items in anvil.
*
* @param left The {@link ItemStack} on the left of the anvil.
* @param right The {@link ItemStack} in the middle of the anvil.
* @param old The previous {@link ItemStack} result.
* @param name The anvil display name.
* @param player The player merging (for permissions).
* @return The result, stored as a {@link Pair} of {@link ItemStack} and {@link Integer}.
*/
public Pair<ItemStack, Integer> doMerge(@Nullable final ItemStack left,
@ -127,7 +129,7 @@ public class AnvilMerge {
&& (rightLevel > enchantment.getMaxLevel() && Configs.CONFIG.getBool("anvil.allow-combining-unsafe"))
|| ((rightLevel + 1) <= enchantment.getMaxLevel()
|| Configs.CONFIG.getBool(ALLOW_UNSAFE_KEY))) {
level++;
level++;
}
rightEnchants.remove(enchantment);
}

View File

@ -22,7 +22,6 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;