diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..869c5a8e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,37 @@ +# How to contribute to EcoEnchants + +## Codestyle + +1. The EcoEnchants checkstyle is in /config/checkstyle.xml + +- The pull request must not have any checkstyle issues. +- Every method and field must have a javadoc attached. + +2. Use lombok wherever possible. + +- As of 6.0.0, EcoEnchants is now built with lombok. +- @Getter, @Setter, @ToString, @EqualsAndHashCode, @UtilityClass are the most important. + +3. Use JetBrains annotations + +- Every parameter should be annotated with @NotNull or @Nullable +- Use @NotNull over lombok @NonNull + +4. Imports + +- No group (*) imports. +- No static imports. + +## Dependency Injection + +- EcoEnchants uses Dependency Injection since 6.0.0. +- Any calls to AbstractEcoPlugin#getInstance are code smells and should never be used unless **absolutely necessary**. +- NamespacedKeys, FixedMetadataValues, Runnables, and Schedules should be managed using EcoEnchantsPlugin through DI. +- Any DI class should extend PluginDependent where possible. If the class extends another, then you **must** store the + plugin instance in a private final variable called **plugin** with a private or protected getter. + +## Other + +- All drops **must** be sent through a DropQueue - calls to World#dropItem will get your PR rejected. +- EcoEnchants is built with java 8. Usage of J9+ will get your PR rejected. +- Any non-plugin-specific changes **must** be made to eco-util, or core-proxy, rather than core-plugin. \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java index b31ffd21..73e444bc 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java @@ -4,11 +4,23 @@ import com.willfp.eco.core.AbstractPacketAdapter; import com.willfp.eco.core.EcoPlugin; import com.willfp.eco.core.command.AbstractCommand; import com.willfp.eco.core.integrations.IntegrationLoader; -import com.willfp.ecoskills.classes.SkillClasses; import com.willfp.ecoskills.command.CommandClasses; import com.willfp.ecoskills.command.CommandEsreload; +import com.willfp.ecoskills.enchantments.EcoEnchants; +import com.willfp.ecoskills.enchantments.meta.EnchantmentRarity; +import com.willfp.ecoskills.enchantments.meta.EnchantmentTarget; +import com.willfp.ecoskills.enchantments.meta.EnchantmentType; +import com.willfp.ecoskills.enchantments.support.merging.anvil.AnvilListeners; +import com.willfp.ecoskills.enchantments.support.merging.grindstone.GrindstoneListeners; +import com.willfp.ecoskills.enchantments.support.obtaining.EnchantingListeners; +import com.willfp.ecoskills.enchantments.support.obtaining.LootPopulator; +import com.willfp.ecoskills.enchantments.support.obtaining.VillagerListeners; +import com.willfp.ecoskills.enchantments.util.ItemConversions; +import com.willfp.ecoskills.enchantments.util.WatcherTriggers; import lombok.Getter; +import org.bukkit.Bukkit; import org.bukkit.event.Listener; +import org.bukkit.generator.BlockPopulator; import java.util.ArrayList; import java.util.Arrays; @@ -44,7 +56,7 @@ public class EcoSkillsPlugin extends EcoPlugin { this.getExtensionLoader().getLoadedExtensions().forEach(extension -> this.getLogger().info("- " + extension.getName() + " v" + extension.getVersion())); } - this.getLogger().info(SkillClasses.values().size() + " Classes Loaded"); + this.getLogger().info(EcoEnchants.values().size() + " Enchantments Loaded"); } /** @@ -52,6 +64,15 @@ public class EcoSkillsPlugin extends EcoPlugin { */ @Override public void disable() { + Bukkit.getServer().getWorlds().forEach(world -> { + List populators = new ArrayList<>(world.getPopulators()); + populators.forEach((blockPopulator -> { + if (blockPopulator instanceof LootPopulator) { + world.getPopulators().remove(blockPopulator); + } + })); + }); + this.getExtensionLoader().unloadExtensions(); } @@ -92,7 +113,7 @@ public class EcoSkillsPlugin extends EcoPlugin { } /** - * Ec0oSkills-specific commands. + * EcoEnchants-specific commands. * * @return A list of all commands. */ @@ -105,7 +126,7 @@ public class EcoSkillsPlugin extends EcoPlugin { } /** - * Packet Adapters display. + * Packet Adapters for enchant display. * * @return A list of packet adapters. */ @@ -115,21 +136,30 @@ public class EcoSkillsPlugin extends EcoPlugin { } /** - * EcoSkills-specific listeners. + * EcoEnchants-specific listeners. * * @return A list of all listeners. */ @Override public List getListeners() { return Arrays.asList( - + new EnchantingListeners(this), + new GrindstoneListeners(this), + new AnvilListeners(this), + new WatcherTriggers(this), + new VillagerListeners(this), + new ItemConversions(this) ); } @Override public List> getUpdatableClasses() { return Arrays.asList( - + EnchantmentRarity.class, + EnchantmentTarget.class, + EcoEnchants.class, + EnchantmentType.class, + WatcherTriggers.class ); } } diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index d80cc361..b198f0ce 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -1,4 +1,133 @@ # -# EcoSkills +# EcoEnchants # by Auxilor # + +allow-on-npc: false # If enchantments should activate against NPCs. + +commands: + enchantinfo: + show-target-group: true # Show name of target group rather than individual items + +anvil: + rework-cost: false # Use vanilla rework penalty + allow-unsafe-levels: false # Allow unsafe enchantments like Sharpness 6 by combining 2 Sharp 5. + allow-combining-unsafe: true # Allow further combining unsafe levels, eg Sharp 6 + Sharp 6 = Sharp 7. + allow-existing-unsafe-levels: true # Allow combining existing unsafe enchantments like Sharpness 6 + + cost-exponent: # Increase value of each extra level by the exponent^levels + enabled: true # Use exponent + exponent: 0.95 # Exponent. Beware that slight changes to this value may cause huge changes in cost. + + hard-cap: # Completely limit the amount of enchantments that can be placed on an item + enabled: false # Enable a hard cap + cap: 10 # Most enchantments allowed on an item + +lore: + use-numerals: true + use-numbers-above-threshold: 10 #After level 10, enchantments will display as Name Number, eg: Sharpness 25 instead of Sharpness XXV + + sort-by-type: false # Sort enchantments by type + sort-by-length: false # Sort enchantments by length + sort-by-rarity: false # Sort enchantments by rarity. + # Any combination of the above options is valid + + require-target: true # Only display items included in target.yml + + type-ordering: # Only used if sort-by-type is enabled - top to bottom + - normal + - special + - artifact + - spell + - curse + + rarity-ordering: # Only used if sort-by-rarity is enabled - top to bottom + - common + - uncommon + - rare + - epic + - legendary + - special + - veryspecial + + describe: # Describe enchantments in lore + enabled: false + before-lines: 5 # Describe before or equal to number of enchantments + wrap: 30 # Word wrap after number of characters + + # Ensure that describe and shrink have no overlap as this may cause errors + + shrink: # Collapse large amount of enchantments + enabled: true + after-lines: 9 # Collapse after number of enchantments + maximum-per-line: 2 # Maximum number of enchantments to have in 1 line + +enchanting-table: + enabled: true #Enable EcoEnchants through an enchanting table + book-times-less-likely: 2 #Times less likely to get an EcoEnchant on a book to balance them out. Don't recommend editing. + maximum-obtainable-level: 30 #Max level for enchanting table. Vanilla default is 30, change if you have a plugin that edits this. + special-bias: 0.7 # Value between 0-1 dictating rarity of high-level special enchantments. 0 is no extra bias, 1 is only level 1. + notify-on-special: true # Tell player in chat when they get a special enchantment + + cap-amount: # Prevent getting above a certain amount of enchantments + enabled: true # Enable capping + limit: 5 # Cap at amount + + reduce-probability: # Reduce probability of adding new enchantment by factor after each enchantment added + enabled: true # Enable reduction + factor: 2.2 # Factor to reduce probability by. Done as compound, so second pass is (factor) times less likely than first, third less likely than second, etc + +villager: + enabled: true #Enable EcoEnchants through villagers + book-times-less-likely: 7 # Times less likely to get an enchantment from a book with a villager. Recommended to be higher as books can only have one enchantment on them. + + reduce-probability: # Reduce probability of adding new enchantment by factor after each enchantment added. Does not apply to books as they only ever contain one enchantment. + enabled: true # Enable reduction + factor: 5 # Factor to reduce probability by. Done as compound, so second pass is (factor) times less likely than first, third less likely than second, etc + +loot: + enabled: true #Enable EcoEnchants through loot chests + book-times-less-likely: 2 + + reduce-probability: # Reduce probability of adding new enchantment by factor after each enchantment added. Does not apply to books as they only ever contain one enchantment. + enabled: true # Enable reduction + factor: 7.5 # Factor to reduce probability by. Done as compound, so second pass is (factor) times less likely than first, third less likely than second, etc + +types: + special: + allow-multiple: false # Allow multiple special enchantments on a single item + artifact: + allow-multiple: false # Allow multiple artifacts on a single item (can cause lag!) + +rarity: + vanilla-rarity: uncommon # Vanilla enchantments do not have an EcoEnchants rarity - what rarity should they have? + vanilla-treasure-rarity: legendary # Treasure enchantments do not appear in vanilla enchanting tables (Mending, Soul Speed, Frost Walker) + # The above options *do not* affect actual enchantment rarities. They are purely for cosmetic purposes, like in item lores. + +advanced: + force-dropqueue: true + # When combined with collate, this massively reduces calls to getItemMeta, which can hurt performance when many enchants are on an item. + # Enabling this option makes all drops go through telekinesis listeners + lore-getter: + # This converts enchantments with matching names from other enchantment plugins from lore into real enchantments. + # This is experimental not recommended to be used for extended periods of time: enchantments are automatically converted. + # Only use this if absolutely necessary as it may cause some bugs. + enabled: false + aggressive: false + # Aggressive mode converts all items in all inventories when opened. + # This will most likely have a significant performance penalty. + hide-fixer: + # Fixes some items obtained in older versions with a bug that caused enchantments to be hidden. + # Works both in packets to display the enchants to the client as well as changing the server-side item too. + # Only use this option if you've encountered this bug as it may strip HideEnchants from items that you might not expect it to. + enabled: false + aggressive: false + # Aggressive mode converts all items in all inventories whenever revealed. + # This may impact performance. + force: false # If **all** items should have hide enchants removed - absolute last ditch effort, most likely to break other things. + hard-disable: + # Fixes potential problems with other plugins where the enchantments are still present when disabled. + # Enabling this prevents the enchantments from being registered with the server at all when disabled. + # There may be some unknown problems with this, but will fix bugs with plugins such as Slimefun. + # Hard disabled enchantments will not update on /ecoreload. You will have to restart your server. + enabled: false \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/lang.yml b/eco-core/core-plugin/src/main/resources/lang.yml index d94fe01c..f6a43416 100644 --- a/eco-core/core-plugin/src/main/resources/lang.yml +++ b/eco-core/core-plugin/src/main/resources/lang.yml @@ -1,5 +1,191 @@ +# INFO: Use the permission name of enchantments if you want to add them to this file (ie damageartifact, not damage_artifact) + messages: - prefix: "&3&lEcoSkills &r&8» &r" + prefix: "&a&lEcoEnchants &r&8» &r" no-permission: "&cYou don't have permission to do this!" not-player: "&cThis command must be run by a player" - reloaded: "Reloaded!" \ No newline at end of file + reloaded: "Reloaded!" + got-special: "You got a &dSpecial &fenchantment!" + skip-added: "&aAdded &flore skip to item!" + skip-removed: "&cRemoved &flore skip from item!" + missing-enchant: "&cYou must specify an enchantment!" + not-found: "&cCannot find an enchantment matching name: &f%name%." + enchantinfo: | + %name%: &r%description% + &9Max Level: &r%maxlevel% + &9Can be applied to: &r%target% + &9Conflicts with: &r%conflicts% + on-cooldown: "&fThis spell is on cooldown! Wait &a%seconds% Seconds&f to use &a%name%&f again." + used-spell: "&fUsed &a%name%&f spell!" + must-hold-item: "&cYou must be holding an enchantable item!" + no-enchants-available: "&fNo available enchantments found for this item!" + applied-random-enchant: "&fAdded %enchantment% to your item!" + gave-random-book: "&fGave %enchantment% book!" + received-random-book: "&fYou have received a %enchantment% book!" + invalid-player: "&cInvalid Player!" + requires-player: "&cRequires a Player!" + must-hold-item-other: "&cPlayer is not holding an enchantable item!" + +no-targets: "&cCannot be applied" +no-conflicts: "&cNo conflicts" + +curse-color: "&c" +not-curse-color: "&7" +special-color: "&d" +artifact-color: "&e" +spell-color: "&9" + +description-color: "&8" + +enchantments: + protection: + name: "Protection" + description: Reduces most types of damage. + + fire_protection: + name: "Fire Protection" + description: Reduces fire damage and burn time. + + feather_falling: + name: "Feather Falling" + description: Reduces fall damage. + + blast_protection: + name: "Blast Protection" + description: Reduces explosion damage and knockback. + + projectile_protection: + name: "Projectile Protection" + description: Reduces projectile damage. + + respiration: + name: "Respiration" + description: Extends underwater breathing time. + + aqua_affinity: + name: "Aqua Affinity" + description: Increases underwater mining speed. + + thorns: + name: "Thorns" + description: Reflects some of the damage taken when hit. + + depth_strider: + name: "Depth Strider" + description: Increases underwater movement speed. + + frost_walker: + name: "Frost Walker" + description: Turns water beneath the player into ice. + + binding_curse: + name: "Curse of Binding" + description: Items cannot be removed from armor slots. + + sharpness: + name: "Sharpness" + description: Increases damage. + + smite: + name: "Smite" + description: Increases damage against undead mobs. + + bane_of_arthropods: + name: "Bane of Arthropods" + description: Increases damage and slows arthropod mobs. + + knockback: + name: "Knockback" + description: Increases knockback. + + fire_aspect: + name: "Fire Aspect" + description: Sets target on fire. + + looting: + name: "Looting" + description: Increases mob loot. + + sweeping: + name: "Sweeping Edge" + description: Increases sweeping attack damage. + + efficiency: + name: "Efficiency" + description: Increases mining speed. + + silk_touch: + name: "Silk Touch" + description: Mined blocks drop themselves exactly. + + unbreaking: + name: "Unbreaking" + description: Increases item durability. + + fortune: + name: "Fortune" + description: Increases certain block drops. + + power: + name: "Power" + description: Increases arrow damage. + + punch: + name: "Punch" + description: Increases arrow knockback. + + flame: + name: "Flame" + description: Arrows set target on fire. + + infinity: + name: "Infinity" + description: Shooting consumes no regular arrows. + + luck_of_the_sea: + name: "Luck of the Sea" + description: Increases rate of good loot. + + lure: + name: "Lure" + description: Decreases fishing wait time. + + loyalty: + name: "Loyalty" + description: Trident returns after being thrown. + + impaling: + name: "Impaling" + description: Trident deals additional damage to ocean mobs. + + riptide: + name: "Riptide" + description: Trident launches player when thrown in water or while raining. + + channeling: + name: "Channeling" + description: Strikes lightning where trident lands during thunderstorms. + + multishot: + name: "Multishot" + description: Shoots 3 arrows. + + quick_charge: + name: "Quick Charge" + description: Decreases crossbow charging time. + + piercing: + name: "Piercing" + description: Arrows pass through multiple entities. + + mending: + name: "Mending" + description: Repair the item while gaining XP orbs. + + vanishing_curse: + name: "Curse of Vanishing" + description: Item destroyed on death. + + soul_speed: + name: "Soul Speed" + description: Increases walking speed on soul sand and soul soil.