values() {
return ImmutableList.copyOf(BY_KEY.values());
}
/**
- * Gets {@link EcoEnchant} from {@link Enchantment}
- *
- * @param enchantment The enchantment
+ * Gets {@link EcoEnchant} from {@link Enchantment}.
*
+ * @param enchantment The enchantment.
* @return The matching {@link EcoEnchant}, or null if not found.
*/
public static EcoEnchant getFromEnchantment(@NotNull final Enchantment enchantment) {
@@ -491,10 +489,9 @@ public final class EcoEnchants implements Updatable {
}
/**
- * Get {@link EcoEnchant} matching display name
- *
- * @param name The display name to search for
+ * Get {@link EcoEnchant} matching display name.
*
+ * @param name The display name to search for.
* @return The matching {@link EcoEnchant}, or null if not found.
*/
public static EcoEnchant getByName(@NotNull final String name) {
@@ -503,10 +500,9 @@ public final class EcoEnchants implements Updatable {
}
/**
- * Get {@link EcoEnchant} matching permission name
- *
- * @param permissionName The permission name to search for
+ * Get {@link EcoEnchant} matching permission name.
*
+ * @param permissionName The permission name to search for.
* @return The matching {@link EcoEnchant}, or null if not found.
*/
public static EcoEnchant getByPermission(@NotNull final String permissionName) {
@@ -515,10 +511,9 @@ public final class EcoEnchants implements Updatable {
}
/**
- * Get {@link EcoEnchant} matching key
- *
- * @param key The NamespacedKey to search for
+ * Get {@link EcoEnchant} matching key.
*
+ * @param key The NamespacedKey to search for.
* @return The matching {@link EcoEnchant}, or null if not found.
*/
public static EcoEnchant getByKey(@NotNull final NamespacedKey key) {
@@ -526,11 +521,10 @@ public final class EcoEnchants implements Updatable {
}
/**
- * Get if {@link ItemStack} has any {@link EcoEnchant} matching specified {@link EnchantmentType}
- *
- * @param item The {@link ItemStack} to check
- * @param type The {@link EnchantmentType} to match
+ * Get if {@link ItemStack} has any {@link EcoEnchant} matching specified {@link EnchantmentType}.
*
+ * @param item The {@link ItemStack} to check.
+ * @param type The {@link EnchantmentType} to match.
* @return True if has, false if doesn't have.
*/
public static boolean hasAnyOfType(@NotNull final ItemStack item,
@@ -554,8 +548,7 @@ public final class EcoEnchants implements Updatable {
}
/**
- * Update all {@link EcoEnchant}s
- * Called on /ecoreload
+ * Update all {@link EcoEnchant}s.
*/
@ConfigUpdater
public static void update() {
@@ -565,10 +558,11 @@ public final class EcoEnchants implements Updatable {
}
/**
- * Add new {@link EcoEnchant} to EcoEnchants
+ * Add new {@link EcoEnchant} to EcoEnchants.
+ *
* Only for internal use, enchantments are automatically added in the constructor.
*
- * @param enchant The {@link EcoEnchant} to add
+ * @param enchant The {@link EcoEnchant} to add.
*/
public static void addNewEcoEnchant(@NotNull final EcoEnchant enchant) {
BY_KEY.remove(enchant.getKey());
@@ -576,15 +570,11 @@ public final class EcoEnchants implements Updatable {
}
/**
- * Remove {@link EcoEnchant} from EcoEnchants
+ * Remove {@link EcoEnchant} from EcoEnchants.
*
- * @param enchant The {@link EcoEnchant} to remove
+ * @param enchant The {@link EcoEnchant} to remove.
*/
public static void removeEcoEnchant(@NotNull final EcoEnchant enchant) {
BY_KEY.remove(enchant.getKey());
}
-
- private EcoEnchants() {
- throw new UnsupportedOperationException("Utility class cannot be instantiated!");
- }
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java
index 50a9c2f4..05a8c630 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java
@@ -29,6 +29,9 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
public class EnchantingListeners extends PluginDependent implements Listener {
+ /**
+ * All enchantments that by default cannot be enchanted in a table but are in EcoEnchants.
+ */
private static final Set SECONDARY_ENCHANTABLE = new ImmutableSet.Builder()
.add(Material.ELYTRA)
.add(Material.SHIELD)
@@ -36,17 +39,35 @@ public class EnchantingListeners extends PluginDependent implements Listener {
.add(Material.SHEARS)
.add(Material.CARROT_ON_A_STICK).build();
+ /**
+ * All players currently enchanting a secondary item.
+ */
public static final Map CURRENTLY_ENCHANTING_SECONDARY = new HashMap<>();
+ /**
+ * Instantiate enchanting listeners and link them to a specific plugin.
+ *
+ * @param plugin The plugin to link to.
+ */
public EnchantingListeners(@NotNull final AbstractEcoPlugin plugin) {
super(plugin);
}
+ /**
+ * Called on player leave.
+ *
+ * @param event The event to listen to.
+ */
@EventHandler
public void onPlayerLeave(@NotNull final PlayerQuitEvent event) {
CURRENTLY_ENCHANTING_SECONDARY.remove(event.getPlayer());
}
+ /**
+ * Called on player enchant item.
+ *
+ * @param event The event to listen to.
+ */
@EventHandler
public void enchantItem(@NotNull final EnchantItemEvent event) {
Player player = event.getEnchanter();
@@ -99,7 +120,7 @@ public class EnchantingListeners extends PluginDependent implements Listener {
if (!enchantment.isEnabled()) {
continue;
}
- if (!enchantment.canGetFromTable()) {
+ if (!enchantment.isAvailableFromTable()) {
continue;
}
if (!player.hasPermission("ecoenchants.fromtable." + enchantment.getPermissionName())) {
@@ -161,7 +182,7 @@ public class EnchantingListeners extends PluginDependent implements Listener {
}
toAdd.forEach(event.getEnchantsToAdd()::putIfAbsent);
- if (SECONDARY_ENCHANTABLE.contains(event.getItem().getType()) && !toAdd.containsKey(EcoEnchants.INDESTRUCTIBILITY)) {
+ if (SECONDARY_ENCHANTABLE.contains(event.getItem().getType()) && !toAdd.containsKey(EcoEnchants.INDESTRUCTIBILITY)) {
event.getEnchantsToAdd().put(Enchantment.DURABILITY, CURRENTLY_ENCHANTING_SECONDARY.get(player)[event.whichButton()]);
CURRENTLY_ENCHANTING_SECONDARY.remove(player);
}
@@ -188,6 +209,12 @@ public class EnchantingListeners extends PluginDependent implements Listener {
}, 1);
}
+ /**
+ * Called on prepare enchant.
+ * For secondary enchantments, generates unbreaking tooltips.
+ *
+ * @param event The event to listen to.
+ */
@EventHandler
public void secondaryEnchant(@NotNull final PrepareItemEnchantEvent event) {
int maxLevel = Configs.CONFIG.getInt("enchanting-table.maximum-obtainable-level");
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java
index e53a62b2..c7d252f7 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java
@@ -28,9 +28,16 @@ import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
public class LootPopulator extends BlockPopulator {
+ /**
+ * Populate a chunk's loot chests.
+ *
+ * @param world The world to populate.
+ * @param random Bukkit parity.
+ * @param chunk The chunk to populate.
+ */
public void populate(@NotNull final World world,
- final @NotNull Random random,
- final @NotNull Chunk chunk) {
+ @NotNull final Random random,
+ @NotNull final Chunk chunk) {
if (!Configs.CONFIG.getBool("loot.enabled")) {
return;
}
@@ -78,7 +85,7 @@ public class LootPopulator extends BlockPopulator {
continue;
}
- if (!enchantment.canGetFromLoot()) {
+ if (!enchantment.isAvailableFromLoot()) {
continue;
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java
index 72c79a1f..5f26e959 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java
@@ -25,8 +25,11 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
public class VillagerListeners implements Listener {
-
- // For books
+ /**
+ * Called on villager gain trade.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler
public void onVillagerGainBookTrade(@NotNull final VillagerAcquireTradeEvent event) {
if (!event.getRecipe().getResult().getType().equals(Material.ENCHANTED_BOOK)) {
@@ -61,7 +64,7 @@ public class VillagerListeners implements Listener {
continue;
}
- if (!enchantment.canGetFromVillager()) {
+ if (!enchantment.isAvailableFromVillager()) {
continue;
}
@@ -97,7 +100,11 @@ public class VillagerListeners implements Listener {
event.setRecipe(recipe);
}
- // For tools
+ /**
+ * Called on villager gain trade.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler
public void onVillagerGainItemTrade(@NotNull final VillagerAcquireTradeEvent event) {
@@ -139,7 +146,7 @@ public class VillagerListeners implements Listener {
continue;
}
- if (!enchantment.canGetFromVillager()) {
+ if (!enchantment.isAvailableFromVillager()) {
continue;
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantChecks.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantChecks.java
index 0c64f04f..98e5a52d 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantChecks.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantChecks.java
@@ -23,12 +23,12 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
-/**
- * Utility class to simplify enchantment fetching
- */
@SuppressWarnings("unchecked")
@UtilityClass
public class EnchantChecks {
+ /**
+ * Proxy instance of FastGetEnchants.
+ */
private static final FastGetEnchantsProxy PROXY = ProxyUtils.getProxy(FastGetEnchantsProxy.class);
/**
@@ -36,7 +36,6 @@ public class EnchantChecks {
*
* @param item The {@link ItemStack} to check
* @param enchantment The enchantment to query
- *
* @return If the item has the queried enchantment
*/
public static boolean item(@Nullable final ItemStack item,
@@ -49,7 +48,6 @@ public class EnchantChecks {
*
* @param item The {@link ItemStack} to check
* @param enchantment The enchantment to query
- *
* @return The level of the enchantment, or 0 if not found
*/
public static int getItemLevel(@Nullable final ItemStack item,
@@ -65,11 +63,10 @@ public class EnchantChecks {
}
/**
- * Get all {@link EcoEnchant}s on a specified ItemStack
+ * Get all {@link EcoEnchant}s on a specified ItemStack.
*
- * @param item The ItemStack to query
- *
- * @return A {@link HashMap} of all EcoEnchants, where the key represents the level
+ * @param item The ItemStack to query.
+ * @return A {@link HashMap} of all EcoEnchants, where the key represents the level.
*/
public static Map getEnchantsOnItem(@Nullable final ItemStack item) {
if (item == null) {
@@ -93,12 +90,11 @@ public class EnchantChecks {
/**
* Does the specified Arrow have a certain Enchantment present?
*
- * EcoEnchants automatically gives an arrow NBT data consisting of the enchantments present to avoid switching errors
+ * EcoEnchants automatically gives an arrow NBT data consisting of the enchantments present to avoid switching errors.
*
- * @param arrow The {@link Arrow} to check
- * @param enchantment The enchantment to query
- *
- * @return If the arrow has the queried enchantment
+ * @param arrow The {@link Arrow} to check.
+ * @param enchantment The enchantment to query.
+ * @return If the arrow has the queried enchantment.
*/
public static boolean arrow(@NotNull final Arrow arrow,
@NotNull final Enchantment enchantment) {
@@ -108,12 +104,11 @@ public class EnchantChecks {
/**
* What level specified Arrow has of a certain Enchantment present?
*
- * EcoEnchants automatically gives an arrow NBT data consisting of the enchantments present to avoid switching errors
+ * EcoEnchants automatically gives an arrow NBT data consisting of the enchantments present to avoid switching errors.
*
- * @param arrow The {@link Arrow} to check
- * @param enchantment The enchantment to query
- *
- * @return The level found on the arrow, or 0 if not found
+ * @param arrow The {@link Arrow} to check.
+ * @param enchantment The enchantment to query.
+ * @return The level found on the arrow, or 0 if not found.
*/
public static int getArrowLevel(@NotNull final Arrow arrow,
@NotNull final Enchantment enchantment) {
@@ -137,11 +132,10 @@ public class EnchantChecks {
}
/**
- * Get all {@link EcoEnchant}s on a specified Arrow
+ * Get all {@link EcoEnchant}s on a specified Arrow.
*
- * @param arrow The Arrow to query
- *
- * @return A {@link HashMap} of all EcoEnchants, where the key represents the level
+ * @param arrow The Arrow to query.
+ * @return A {@link HashMap} of all EcoEnchants, where the key represents the level.
*/
public static Map getEnchantsOnArrow(@NotNull final Arrow arrow) {
if (arrow.getMetadata("enchantments").isEmpty()) {
@@ -166,10 +160,9 @@ public class EnchantChecks {
/**
* Does the specified {@link LivingEntity} have a certain Enchantment present on the item in their main hand?
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- *
- * @return If the LivingEntity has the enchantment
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @return If the LivingEntity has the enchantment.
*/
public static boolean mainhand(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment) {
@@ -179,10 +172,9 @@ public class EnchantChecks {
/**
* What level of the specified enchantment does the queried {@link LivingEntity} have on their main hand item?
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- *
- * @return The level found on the mainhand item, or 0 if not found
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @return The level found on the mainhand item, or 0 if not found.
*/
public static int getMainhandLevel(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment) {
@@ -196,11 +188,10 @@ public class EnchantChecks {
}
/**
- * Get all {@link EcoEnchant}s on a queried {@link LivingEntity}s main hand item
+ * Get all {@link EcoEnchant}s on a queried {@link LivingEntity}s main hand item.
*
- * @param entity The entity to query
- *
- * @return A {@link HashMap} of all EcoEnchants, where the key represents the level
+ * @param entity The entity to query.
+ * @return A {@link HashMap} of all EcoEnchants, where the key represents the level.
*/
public static Map getEnchantsOnMainhand(@NotNull final LivingEntity entity) {
if (entity.getEquipment() == null) {
@@ -215,10 +206,9 @@ public class EnchantChecks {
/**
* Does the specified {@link LivingEntity} have a certain Enchantment present on the item in their offhand?
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- *
- * @return If the LivingEntity has the enchantment
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @return If the LivingEntity has the enchantment.
*/
public static boolean offhand(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment) {
@@ -228,10 +218,9 @@ public class EnchantChecks {
/**
* What level of the specified enchantment does the queried {@link LivingEntity} have on their offhand item?
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- *
- * @return The level found on the offhand item, or 0 if not found
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @return The level found on the offhand item, or 0 if not found.
*/
public static int getOffhandLevel(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment) {
@@ -245,11 +234,10 @@ public class EnchantChecks {
}
/**
- * Get all {@link EcoEnchant}s on a queried {@link LivingEntity}s offhand item
+ * Get all {@link EcoEnchant}s on a queried {@link LivingEntity}s offhand item.
*
- * @param entity The entity to query
- *
- * @return A {@link HashMap} of all EcoEnchants, where the key represents the level
+ * @param entity The entity to query.
+ * @return A {@link HashMap} of all EcoEnchants, where the key represents the level.
*/
public static Map getEnchantsOnOffhand(@NotNull final LivingEntity entity) {
if (entity.getEquipment() == null) {
@@ -262,11 +250,10 @@ public class EnchantChecks {
}
/**
- * Get a cumulative total of all levels on a {@link LivingEntity}s armor of a certain enchantment
- *
- * @param entity The entity to query
- * @param enchantment The enchantment to check
+ * Get a cumulative total of all levels on a {@link LivingEntity}s armor of a certain enchantment.
*
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
* @return The cumulative total of all levels, ie 4 pieces all with level 3 returns 12
*/
public static int getArmorPoints(@NotNull final LivingEntity entity,
@@ -275,15 +262,14 @@ public class EnchantChecks {
}
/**
- * Get a cumulative total of all levels on a {@link LivingEntity}s armor of a certain enchantment
+ * Get a cumulative total of all levels on a {@link LivingEntity}s armor of a certain enchantment.
*
- * Then, apply a specified amount of damage to all items with said enchantment
+ * Then, apply a specified amount of damage to all items with said enchantment.
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- * @param damage The amount of damage to deal to all armor pieces
- *
- * @return The cumulative total of all levels, ie 4 pieces all with level 3 returns 12
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @param damage The amount of damage to deal to all armor pieces.
+ * @return The cumulative total of all levels, ie 4 pieces all with level 3 returns 12.
*/
public static int getArmorPoints(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment,
@@ -322,11 +308,10 @@ public class EnchantChecks {
}
/**
- * Get all {@link EcoEnchant}s on a queried {@link LivingEntity}s armor
+ * Get all {@link EcoEnchant}s on a queried {@link LivingEntity}s armor.
*
- * @param entity The entity to query
- *
- * @return A {@link HashMap} of all EcoEnchants, where the key represents the cumulative total levels
+ * @param entity The entity to query.
+ * @return A {@link HashMap} of all EcoEnchants, where the key represents the cumulative total levels.
*/
public static Map getEnchantsOnArmor(@NotNull final LivingEntity entity) {
if (entity.getEquipment() == null) {
@@ -347,10 +332,9 @@ public class EnchantChecks {
/**
* Does the specified {@link LivingEntity} have a certain Enchantment present on their helmet?
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- *
- * @return If the LivingEntity has the enchantment
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @return If the LivingEntity has the enchantment.
*/
public static boolean helmet(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment) {
@@ -360,10 +344,9 @@ public class EnchantChecks {
/**
* What level of the specified enchantment does the queried {@link LivingEntity} have on their helmet?
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- *
- * @return The level found, or 0 if not found
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @return The level found, or 0 if not found.
*/
public static int getHelmetLevel(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment) {
@@ -379,10 +362,9 @@ public class EnchantChecks {
/**
* Does the specified {@link LivingEntity} have a certain Enchantment present on their chestplate?
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- *
- * @return If the LivingEntity has the enchantment
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @return If the LivingEntity has the enchantment.
*/
public static boolean chestplate(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment) {
@@ -392,10 +374,9 @@ public class EnchantChecks {
/**
* What level of the specified enchantment does the queried {@link LivingEntity} have on their chestplate?
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- *
- * @return The level found, or 0 if not found
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @return The level found, or 0 if not found.
*/
public static int getChestplateLevel(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment) {
@@ -411,10 +392,9 @@ public class EnchantChecks {
/**
* Does the specified {@link LivingEntity} have a certain Enchantment present on their leggings?
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- *
- * @return If the LivingEntity has the enchantment
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @return If the LivingEntity has the enchantment.
*/
public static boolean leggings(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment) {
@@ -424,10 +404,9 @@ public class EnchantChecks {
/**
* What level of the specified enchantment does the queried {@link LivingEntity} have on their leggings?
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- *
- * @return The level found, or 0 if not found
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @return The level found, or 0 if not found.
*/
public static int getLeggingsLevel(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment) {
@@ -443,10 +422,9 @@ public class EnchantChecks {
/**
* Does the specified {@link LivingEntity} have a certain Enchantment present on their boots?
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- *
- * @return If the LivingEntity has the enchantment
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @return If the LivingEntity has the enchantment.
*/
public static boolean boots(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment) {
@@ -456,10 +434,9 @@ public class EnchantChecks {
/**
* What level of the specified enchantment does the queried {@link LivingEntity} have on their boots?
*
- * @param entity The entity to query
- * @param enchantment The enchantment to check
- *
- * @return The level found, or 0 if not found
+ * @param entity The entity to query.
+ * @param enchantment The enchantment to check.
+ * @return The level found, or 0 if not found.
*/
public static int getBootsLevel(@NotNull final LivingEntity entity,
@NotNull final Enchantment enchantment) {
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java
index 55ff5925..efa310b5 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java
@@ -13,11 +13,23 @@ import org.jetbrains.annotations.NotNull;
@UtilityClass
public class EnchantmentUtils {
+ /**
+ * If the enchantment has successfully passed its specified chance.
+ *
+ * @param enchantment The enchantment to query.
+ * @param level The level to base the chance off of.
+ * @return If the enchantment should then be executed.
+ */
public static boolean passedChance(@NotNull final EcoEnchant enchantment,
final int level) {
return NumberUtils.randFloat(0, 1) < ((enchantment.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level") * level) / 100);
}
+ /**
+ * Register the placeholders for an enchantment.
+ *
+ * @param enchantment The enchantment to register placeholders for.
+ */
public static void registerPlaceholders(@NotNull final EcoEnchant enchantment) {
PlaceholderManager.registerPlaceholder(
new PlaceholderEntry(
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellRunnable.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellRunnable.java
index a12792a5..a407df68 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellRunnable.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellRunnable.java
@@ -3,41 +3,63 @@ package com.willfp.ecoenchants.enchantments.util;
import com.willfp.eco.util.lambda.Callable;
import com.willfp.ecoenchants.enchantments.itemtypes.Spell;
+import lombok.Getter;
+import lombok.Setter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class SpellRunnable {
+ /**
+ * The spell that this runnable is for.
+ */
+ @Getter
private final Spell spell;
+
+ /**
+ * The player that this runnable is for.
+ */
private final Player player;
+
+ /**
+ * The end time of the runnable, in unix time.
+ */
+ @Getter
private long endTime = 0;
+
+ /**
+ * The actual task to be executed.
+ *
+ * Must be set before execution.
+ */
+ @Setter
private Callable callable = () -> {
// Empty as must be set using this#setTask
};
+ /**
+ * Create a new Spell Runnable.
+ *
+ * @param spell The spell.
+ * @param player The player.
+ */
public SpellRunnable(@NotNull final Spell spell,
@NotNull final Player player) {
this.spell = spell;
this.player = player;
}
- public Spell getSpell() {
- return spell;
- }
-
+ /**
+ * Run the runnable.
+ */
public void run() {
callable.call();
updateEndTime();
}
- public long getEndTime() {
- return endTime;
- }
-
+ /**
+ * Update the end time of the spell runnable.
+ */
public void updateEndTime() {
endTime = System.currentTimeMillis() + (long) ((spell.getCooldownTime() * 1000L) * Spell.getCooldownMultiplier(player));
}
-
- public void setTask(@NotNull final Callable callable) {
- this.callable = callable;
- }
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java
index e373337c..c5c1b7ad 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java
@@ -36,14 +36,30 @@ import java.util.UUID;
@SuppressWarnings("deprecation")
public class WatcherTriggers extends PluginDependent implements Listener {
+ /**
+ * For jump listeners.
+ */
private static final Set PREVIOUS_PLAYERS_ON_GROUND = Sets.newHashSet();
+
+ /**
+ * For jump listeners.
+ */
private static final DecimalFormat FORMAT = new DecimalFormat("0.00");
-
+ /**
+ * Create new listener for watcher events.
+ *
+ * @param plugin The plugin to link the events to.
+ */
public WatcherTriggers(@NotNull final AbstractEcoPlugin plugin) {
super(plugin);
}
+ /**
+ * Called when an entity shoots another entity with an arrow.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onArrowDamage(@NotNull final EntityDamageByEntityEvent event) {
if (McmmoManager.isFake(event)) {
@@ -99,6 +115,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
}));
}
+ /**
+ * Called when an entity damages another entity with a trident throw.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onTridentDamage(@NotNull final EntityDamageByEntityEvent event) {
if (McmmoManager.isFake(event)) {
@@ -156,6 +177,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
}));
}
+ /**
+ * Called when a player jumps.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onJump(@NotNull final PlayerMoveEvent event) {
if (McmmoManager.isFake(event)) {
@@ -197,6 +223,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
}
}
+ /**
+ * Called when an entity attacks another entity with a melee attack.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onMeleeAttack(@NotNull final EntityDamageByEntityEvent event) {
if (McmmoManager.isFake(event)) {
@@ -243,6 +274,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
});
}
+ /**
+ * Called when an entity shoots a bow.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onBowShoot(@NotNull final EntityShootBowEvent event) {
if (McmmoManager.isFake(event)) {
@@ -273,6 +309,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
});
}
+ /**
+ * Called when an entity takes fall damage.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onFallDamage(@NotNull final EntityDamageEvent event) {
if (McmmoManager.isFake(event)) {
@@ -306,6 +347,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
});
}
+ /**
+ * Called when an arrow hits a block or entity.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onArrowHit(@NotNull final ProjectileHitEvent event) {
if (McmmoManager.isFake(event)) {
@@ -340,6 +386,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
}));
}
+ /**
+ * Called when a trident hits a block or entity.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onTridentHit(@NotNull final ProjectileHitEvent event) {
if (McmmoManager.isFake(event)) {
@@ -375,6 +426,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
}));
}
+ /**
+ * Called when a player breaks a block.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(@NotNull final BlockBreakEvent event) {
if (McmmoManager.isFake(event)) {
@@ -409,6 +465,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
});
}
+ /**
+ * Called when an entity takes damage wearing armor.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onDamageWearingArmor(@NotNull final EntityDamageEvent event) {
if (McmmoManager.isFake(event)) {
@@ -438,6 +499,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
});
}
+ /**
+ * Called when an entity puts on or takes off armor with an enchantment.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onArmorEquip(@NotNull final ArmorEquipEvent event) {
if (McmmoManager.isFake(event)) {
@@ -464,6 +530,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
}), 1);
}
+ /**
+ * Called when a player damages a block.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onDamageBlock(@NotNull final BlockDamageEvent event) {
if (McmmoManager.isFake(event)) {
@@ -494,6 +565,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
});
}
+ /**
+ * Called when an entity throws a trident.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onTridentLaunch(@NotNull final ProjectileLaunchEvent event) {
if (McmmoManager.isFake(event)) {
@@ -529,6 +605,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
});
}
+ /**
+ * Called when a player blocks an attack with a shield.
+ *
+ * @param event The event to listen for.
+ */
@EventHandler(ignoreCancelled = true)
public void onDeflect(@NotNull final EntityDamageByEntityEvent event) {
if (McmmoManager.isFake(event)) {