├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── config.yml │ └── report-a-bug.md └── workflows │ └── publish-release.yml ├── eco-core ├── build.gradle.kts └── core-plugin │ ├── src │ └── main │ │ ├── resources │ │ ├── eco.yml │ │ ├── config.yml │ │ ├── lang.yml │ │ ├── plugin.yml │ │ ├── tiers │ │ │ ├── default.yml │ │ │ ├── iron.yml │ │ │ ├── diamond.yml │ │ │ ├── cobalt.yml │ │ │ ├── netherite.yml │ │ │ ├── ancient.yml │ │ │ ├── mythic.yml │ │ │ ├── osmium.yml │ │ │ ├── exotic.yml │ │ │ ├── manyullyn.yml │ │ │ └── _example.yml │ │ └── sets │ │ │ ├── reaper.yml │ │ │ ├── slayer.yml │ │ │ ├── angelic.yml │ │ │ ├── huntress.yml │ │ │ └── _example.yml │ │ └── kotlin │ │ └── com │ │ └── willfp │ │ └── ecoarmor │ │ ├── api │ │ └── event │ │ │ ├── ArmorSetEvent.kt │ │ │ ├── PlayerArmorSetEvent.kt │ │ │ ├── PlayerArmorSetEquipEvent.kt │ │ │ └── PlayerArmorSetUnequipEvent.kt │ │ ├── util │ │ ├── PlayableSound.kt │ │ └── DiscoverRecipeListener.kt │ │ ├── commands │ │ ├── CommandReload.kt │ │ ├── CommandEcoArmor.kt │ │ └── CommandGive.kt │ │ ├── sets │ │ ├── PreventSkullPlaceListener.kt │ │ ├── ArmorSetEquipSoundListeners.kt │ │ ├── EffectiveDurabilityListener.kt │ │ ├── ArmorSlot.kt │ │ ├── PlayerArmorSetEventListeners.kt │ │ ├── ArmorSets.kt │ │ ├── ArmorSet.kt │ │ └── ArmorUtils.kt │ │ ├── libreforge │ │ └── ConditionIsWearingSet.kt │ │ ├── upgrades │ │ ├── TierArgParser.kt │ │ ├── AdvancementShardListener.kt │ │ ├── Tiers.kt │ │ ├── CrystalListener.kt │ │ └── Tier.kt │ │ ├── EcoArmorPlugin.kt │ │ └── display │ │ └── ArmorDisplay.kt │ └── build.gradle.kts ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── .gitignore ├── settings.gradle.kts ├── README.md ├── gradlew.bat ├── gradlew └── LICENSE.md /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @WillFP 2 | -------------------------------------------------------------------------------- /eco-core/build.gradle.kts: -------------------------------------------------------------------------------- 1 | group = "com.willfp" 2 | version = rootProject.version 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Auxilor/EcoArmor/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | #libreforge-updater 2 | #Mon Oct 06 08:57:12 BST 2025 3 | kotlin.code.style=official 4 | libreforge-version=4.79.0 5 | version=8.78.0 6 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/eco.yml: -------------------------------------------------------------------------------- 1 | environment: 2 | - name: libreforge version 3 | value: ${libreforgeVersion} 4 | 5 | options: 6 | resource-id: 687 7 | bstats-id: 10002 8 | color: "&c" 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Discord 4 | url: https://discord.gg/ZcwpSsE/ 5 | about: Issues have moved to Discord, please join the server to get help! 6 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/ArmorSetEvent.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.api.event 2 | 3 | import com.willfp.ecoarmor.sets.ArmorSet 4 | 5 | interface ArmorSetEvent { 6 | val set: ArmorSet 7 | val advanced: Boolean 8 | } 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/report-a-bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Report a Bug 3 | about: Report an issue with the plugin 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | --- 8 | 9 | # Please report bugs on the discord! 10 | 11 | [Join by clicking here](https://discord.gg/ZcwpSsE/) 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Java 2 | *.class 3 | 4 | # Eclipse IDE 5 | .settings/ 6 | bin/ 7 | .classpath 8 | .project 9 | 10 | # IntelliJ IDEA 11 | .idea/ 12 | *.iml 13 | 14 | # Gradle 15 | .gradle 16 | **/build/ 17 | !src/**/build/ 18 | .gradletasknamecache 19 | !gradle-wrapper.jar 20 | gradle-app.setting 21 | 22 | # Mac OSX 23 | .DS_Store -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetEvent.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.api.event 2 | 3 | import com.willfp.ecoarmor.sets.ArmorSet 4 | import org.bukkit.entity.Player 5 | import org.bukkit.event.player.PlayerEvent 6 | 7 | abstract class PlayerArmorSetEvent( 8 | who: Player, 9 | override val set: ArmorSet, 10 | override val advanced: Boolean 11 | ) : PlayerEvent(who), ArmorSetEvent 12 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/util/PlayableSound.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.util 2 | 3 | import org.bukkit.Sound 4 | import org.bukkit.entity.Player 5 | 6 | class PlayableSound( 7 | private val sound: Sound, 8 | val volume: Double, 9 | private val pitch: Double 10 | ) { 11 | fun play(player: Player) { 12 | player.playSound(player.location, sound, volume.toFloat(), pitch.toFloat()) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | # 2 | # EcoArmor 3 | # by Auxilor 4 | # 5 | 6 | discover-recipes: true # If all recipes should be automatically discovered. 7 | update-item-names: true # If item names should be updated to match config (disable to allow renaming armor pieces in anvils) 8 | update-leather-colors: true # If leather colors should be updated to match config 9 | advanced-lore-only: false # If advanced armor should only show the advanced lore 10 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | mavenLocal() 5 | maven("https://repo.auxilor.io/repository/maven-public/") 6 | maven("https://repo.papermc.io/repository/maven-public/") 7 | } 8 | } 9 | 10 | plugins { 11 | id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" 12 | } 13 | 14 | rootProject.name = "EcoArmor" 15 | 16 | // Core 17 | include(":eco-core") 18 | include(":eco-core:core-plugin") 19 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/lang.yml: -------------------------------------------------------------------------------- 1 | messages: 2 | prefix: "&c&lEcoArmor&r &8» &r" 3 | no-permission: "&cYou don't have permission to do this!" 4 | not-player: "&cThis command must be run by a player" 5 | invalid-command: "&cUnknown subcommand!" 6 | reloaded: "Reloaded!" 7 | 8 | needs-player: "&cYou must specify a player" 9 | invalid-player: "&cInvalid player!" 10 | needs-item: "&cYou must specify an item!" 11 | invalid-item: "&cInvalid item!" 12 | give-success: "Gave &a%item%&r to &a%recipient%" -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/commands/CommandReload.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.commands 2 | 3 | import com.willfp.eco.core.EcoPlugin 4 | import com.willfp.eco.core.command.impl.Subcommand 5 | import org.bukkit.command.CommandSender 6 | 7 | class CommandReload(plugin: EcoPlugin) : Subcommand(plugin, "reload", "ecoarmor.command.reload", false) { 8 | override fun onExecute(sender: CommandSender, args: List) { 9 | plugin.reload() 10 | sender.sendMessage(plugin.langYml.getMessage("reloaded")) 11 | } 12 | } -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/PreventSkullPlaceListener.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.sets 2 | 3 | import org.bukkit.event.EventHandler 4 | import org.bukkit.event.EventPriority 5 | import org.bukkit.event.Listener 6 | import org.bukkit.event.block.BlockPlaceEvent 7 | 8 | class PreventSkullPlaceListener : Listener { 9 | @EventHandler(priority = EventPriority.HIGHEST) 10 | fun onPlace(event: BlockPlaceEvent) { 11 | if (ArmorUtils.getSetOnItem(event.itemInHand) != null) { 12 | event.isCancelled = true 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/commands/CommandEcoArmor.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.commands 2 | 3 | import com.willfp.eco.core.EcoPlugin 4 | import com.willfp.eco.core.command.impl.PluginCommand 5 | import org.bukkit.command.CommandSender 6 | 7 | class CommandEcoArmor(plugin: EcoPlugin) : PluginCommand(plugin, "ecoarmor", "ecoarmor.command.ecoarmor", false) { 8 | init { 9 | addSubcommand(CommandReload(plugin)) 10 | .addSubcommand(CommandGive(plugin)) 11 | } 12 | 13 | override fun onExecute(sender: CommandSender, args: List) { 14 | sender.sendMessage( 15 | plugin.langYml.getMessage("invalid-command") 16 | ) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetEquipEvent.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.api.event 2 | 3 | import com.willfp.ecoarmor.sets.ArmorSet 4 | import org.bukkit.entity.Player 5 | import org.bukkit.event.HandlerList 6 | 7 | class PlayerArmorSetEquipEvent( 8 | who: Player, 9 | override val set: ArmorSet, 10 | override val advanced: Boolean 11 | ) : PlayerArmorSetEvent(who, set, advanced) { 12 | override fun getHandlers(): HandlerList { 13 | return handlerList 14 | } 15 | 16 | companion object { 17 | private val handlerList = HandlerList() 18 | 19 | @JvmStatic 20 | fun getHandlerList(): HandlerList { 21 | return handlerList 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetUnequipEvent.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.api.event 2 | 3 | import com.willfp.ecoarmor.sets.ArmorSet 4 | import org.bukkit.entity.Player 5 | import org.bukkit.event.HandlerList 6 | 7 | class PlayerArmorSetUnequipEvent( 8 | who: Player, 9 | override val set: ArmorSet, 10 | override val advanced: Boolean 11 | ) : PlayerArmorSetEvent(who, set, advanced) { 12 | override fun getHandlers(): HandlerList { 13 | return handlerList 14 | } 15 | 16 | companion object { 17 | private val handlerList = HandlerList() 18 | 19 | @JvmStatic 20 | fun getHandlerList(): HandlerList { 21 | return handlerList 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorSetEquipSoundListeners.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.sets 2 | 3 | import com.willfp.ecoarmor.api.event.PlayerArmorSetEquipEvent 4 | import com.willfp.ecoarmor.api.event.PlayerArmorSetUnequipEvent 5 | import org.bukkit.event.EventHandler 6 | import org.bukkit.event.Listener 7 | 8 | class ArmorSetEquipSoundListeners: Listener { 9 | @EventHandler 10 | fun handleEquip(event: PlayerArmorSetEquipEvent) { 11 | val sound = (if (event.advanced) event.set.advancedEquipSound else event.set.equipSound) ?: return 12 | sound.play(event.player) 13 | } 14 | 15 | @EventHandler 16 | fun handleUnequip(event: PlayerArmorSetUnequipEvent) { 17 | val sound = event.set.unequipSound ?: return 18 | sound.play(event.player) 19 | } 20 | } -------------------------------------------------------------------------------- /.github/workflows/publish-release.yml: -------------------------------------------------------------------------------- 1 | name: Publish Packages 2 | on: 3 | workflow_dispatch: 4 | release: 5 | types: [ created ] 6 | push: 7 | tags: 8 | - '*' 9 | 10 | jobs: 11 | publish: 12 | runs-on: ubuntu-latest 13 | steps: 14 | 15 | - name: Checkout latest code 16 | uses: actions/checkout@v2 17 | 18 | - name: Set up JDK 21 19 | uses: actions/setup-java@v2 20 | with: 21 | distribution: 'temurin' 22 | java-version: 21 23 | 24 | - name: Change wrapper permissions 25 | run: chmod +x ./gradlew 26 | 27 | - name: Publish package 28 | uses: gradle/gradle-build-action@v2 29 | with: 30 | arguments: publish 31 | env: 32 | MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} 33 | MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} 34 | -------------------------------------------------------------------------------- /eco-core/core-plugin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | group = "com.willfp" 2 | version = rootProject.version 3 | 4 | dependencies { 5 | compileOnly("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT") 6 | } 7 | 8 | publishing { 9 | publications { 10 | register("maven") { 11 | groupId = project.group.toString() 12 | version = project.version.toString() 13 | artifactId = rootProject.name 14 | 15 | artifact(rootProject.tasks.shadowJar.get().archiveFile) 16 | } 17 | } 18 | 19 | repositories { 20 | maven { 21 | name = "auxilor" 22 | url = uri("https://repo.auxilor.io/repository/maven-releases/") 23 | credentials { 24 | username = System.getenv("MAVEN_USERNAME") 25 | password = System.getenv("MAVEN_PASSWORD") 26 | } 27 | } 28 | } 29 | } 30 | 31 | tasks { 32 | build { 33 | dependsOn(publishToMavenLocal) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/util/DiscoverRecipeListener.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.util 2 | 3 | import com.willfp.eco.core.EcoPlugin 4 | import org.bukkit.Bukkit 5 | import org.bukkit.Keyed 6 | import org.bukkit.event.EventHandler 7 | import org.bukkit.event.Listener 8 | import org.bukkit.event.player.PlayerJoinEvent 9 | import org.bukkit.inventory.Recipe 10 | 11 | class DiscoverRecipeListener(private val plugin: EcoPlugin) : Listener { 12 | @EventHandler 13 | fun onJoin(event: PlayerJoinEvent) { 14 | if (!plugin.configYml.getBool("discover-recipes")) { 15 | return 16 | } 17 | mutableListOf() 18 | .apply { Bukkit.getServer().recipeIterator().forEachRemaining(this::add) } 19 | .filterIsInstance().map { it.key } 20 | .filter { it.namespace == plugin.name.lowercase() } 21 | .filter { !it.key.contains("displayed") } 22 | .forEach { event.player.discoverRecipe(it) } 23 | } 24 | } -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: ${pluginName} 2 | version: ${version} 3 | main: com.willfp.ecoarmor.EcoArmorPlugin 4 | api-version: 1.17 5 | authors: [ Auxilor ] 6 | website: willfp.com 7 | depend: 8 | - eco 9 | softdepend: 10 | - libreforge 11 | 12 | commands: 13 | ecoarmor: 14 | description: Base Command 15 | permission: ecoarmor.command.ecoarmor 16 | 17 | permissions: 18 | ecoarmor.*: 19 | description: All ecoarmor permissions 20 | default: op 21 | children: 22 | ecoarmor.command.*: true 23 | ecoarmor.command.*: 24 | description: All commands 25 | default: op 26 | children: 27 | ecoarmor.command.reload: true 28 | ecoarmor.command.ecoarmor: true 29 | ecoarmor.command.give: true 30 | 31 | ecoarmor.command.reload: 32 | description: Allows reloading the config 33 | default: op 34 | ecoarmor.command.give: 35 | description: Allows the use of /ecoarmor give 36 | default: op 37 | ecoarmor.command.ecoarmor: 38 | description: Allows the user of /ecoarmor. 39 | default: true 40 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/libreforge/ConditionIsWearingSet.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.libreforge 2 | 3 | import com.willfp.eco.core.config.interfaces.Config 4 | import com.willfp.ecoarmor.sets.ArmorUtils 5 | import com.willfp.libreforge.Dispatcher 6 | import com.willfp.libreforge.NoCompileData 7 | import com.willfp.libreforge.ProvidedHolder 8 | import com.willfp.libreforge.arguments 9 | import com.willfp.libreforge.conditions.Condition 10 | import com.willfp.libreforge.get 11 | import org.bukkit.entity.Player 12 | 13 | object ConditionIsWearingSet : Condition("is_wearing_set") { 14 | override val arguments = arguments { 15 | require("set", "You must specify the set name!") 16 | } 17 | 18 | override fun isMet( 19 | dispatcher: Dispatcher<*>, 20 | config: Config, 21 | holder: ProvidedHolder, 22 | compileData: NoCompileData 23 | ): Boolean { 24 | val player = dispatcher.get() ?: return false 25 | 26 | return ArmorUtils.getSetOnPlayer(player)?.id == config.getString("set") 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/EffectiveDurabilityListener.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.sets 2 | 3 | import com.willfp.eco.core.EcoPlugin 4 | import com.willfp.eco.util.NumberUtils 5 | import org.bukkit.event.EventHandler 6 | import org.bukkit.event.Listener 7 | import org.bukkit.event.player.PlayerItemDamageEvent 8 | import org.bukkit.persistence.PersistentDataType 9 | 10 | class EffectiveDurabilityListener(private val plugin: EcoPlugin) : Listener { 11 | @EventHandler 12 | fun listener(event: PlayerItemDamageEvent) { 13 | val itemStack = event.item 14 | val meta = itemStack.itemMeta ?: return 15 | val container = meta.persistentDataContainer 16 | val effectiveDurability = 17 | container.get(plugin.namespacedKeyFactory.create("effective-durability"), PersistentDataType.INTEGER) 18 | ?: return 19 | val maxDurability = itemStack.type.maxDurability.toInt() 20 | val ratio = effectiveDurability.toDouble() / maxDurability 21 | val chance = 1 / ratio 22 | if (NumberUtils.randFloat(0.0, 1.0) > chance) { 23 | event.isCancelled = true 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/TierArgParser.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.upgrades 2 | 3 | import com.willfp.eco.core.items.args.LookupArgParser 4 | import com.willfp.ecoarmor.sets.ArmorUtils 5 | import org.bukkit.inventory.ItemStack 6 | import org.bukkit.inventory.meta.ItemMeta 7 | import java.util.function.Predicate 8 | 9 | class TierArgParser : LookupArgParser { 10 | override fun parseArguments( 11 | args: Array, 12 | meta: ItemMeta 13 | ): Predicate? { 14 | var tier: Tier? = null 15 | 16 | for (arg in args) { 17 | val split = arg.split(":").toTypedArray() 18 | if (split.size == 1 || !split[0].equals("tier", ignoreCase = true)) { 19 | continue 20 | } 21 | val match = Tiers.getByID(split[1].lowercase()) ?: continue 22 | tier = match 23 | break 24 | } 25 | 26 | tier ?: return null 27 | 28 | ArmorUtils.setTierKey(meta, tier) 29 | 30 | return Predicate { test -> 31 | val testMeta = test.itemMeta ?: return@Predicate false 32 | tier == ArmorUtils.getTier(testMeta) 33 | } 34 | } 35 | 36 | override fun serializeBack(meta: ItemMeta): String? { 37 | val tier = ArmorUtils.getTier(meta) ?: return null 38 | 39 | return "tier:${tier.id}" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorSlot.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.sets 2 | 3 | import org.bukkit.inventory.EquipmentSlot 4 | import org.bukkit.inventory.ItemStack 5 | import java.util.* 6 | 7 | enum class ArmorSlot( 8 | val slot: EquipmentSlot 9 | ) { 10 | HELMET(EquipmentSlot.HEAD), 11 | CHESTPLATE(EquipmentSlot.CHEST), 12 | ELYTRA(EquipmentSlot.CHEST), 13 | LEGGINGS(EquipmentSlot.LEGS), 14 | BOOTS(EquipmentSlot.FEET); 15 | 16 | companion object { 17 | @JvmStatic 18 | fun getSlot(itemStack: ItemStack?): ArmorSlot? { 19 | if (itemStack == null) { 20 | return null 21 | } 22 | val material = itemStack.type 23 | 24 | return getSlot(material.name) 25 | } 26 | 27 | @JvmStatic 28 | fun getSlot(name: String): ArmorSlot? { 29 | return when { 30 | name.contains("HELMET", true) || name.contains("HEAD", true) 31 | || name.contains("SKULL", true) 32 | || name.contains("PUMPKIN", true) -> HELMET 33 | name.contains("CHESTPLATE", true) -> CHESTPLATE 34 | name.contains("ELYTRA", true) -> ELYTRA 35 | name.contains("LEGGINGS", true) -> LEGGINGS 36 | name.contains("BOOTS", true) -> BOOTS 37 | else -> null 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/PlayerArmorSetEventListeners.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.sets 2 | 3 | import com.willfp.eco.core.events.ArmorChangeEvent 4 | import com.willfp.ecoarmor.api.event.PlayerArmorSetEquipEvent 5 | import com.willfp.ecoarmor.api.event.PlayerArmorSetUnequipEvent 6 | import com.willfp.ecoarmor.sets.ArmorUtils 7 | import org.bukkit.Bukkit 8 | import org.bukkit.event.EventHandler 9 | import org.bukkit.event.Listener 10 | 11 | class PlayerArmorSetEventListeners : Listener { 12 | // disgusting 13 | @EventHandler 14 | fun handle(event: ArmorChangeEvent) { 15 | val setBefore = ArmorUtils.getSetOn(event.before) 16 | val advancedBefore = ArmorUtils.isWearingAdvanced(event.before) 17 | val setAfter = ArmorUtils.getSetOn(event.after) 18 | val advancedAfter = ArmorUtils.isWearingAdvanced(event.after) 19 | 20 | if (setBefore == setAfter && advancedBefore == advancedAfter) { 21 | return 22 | } 23 | 24 | if (setBefore != null) { 25 | Bukkit.getPluginManager().callEvent( 26 | PlayerArmorSetUnequipEvent(event.player, setBefore, advancedBefore) 27 | ) 28 | } 29 | 30 | if (setAfter != null) { 31 | Bukkit.getPluginManager().callEvent( 32 | PlayerArmorSetEquipEvent(event.player, setAfter, advancedAfter) 33 | ) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/tiers/default.yml: -------------------------------------------------------------------------------- 1 | display: "&8&lDEFAULT" 2 | requiresTiers: [] 3 | crystal: 4 | item: end_crystal 5 | name: "&8Default Upgrade Crystal" 6 | craftable: false 7 | recipe: 8 | - air 9 | - leather 10 | - air 11 | - leather 12 | - leather_chestplate 13 | - leather 14 | - air 15 | - leather 16 | - air 17 | giveAmount: 1 18 | lore: 19 | - "&8Drop this onto an armor piece" 20 | - "&8to set its tier to:" 21 | - "&8&lDEFAULT" 22 | properties: 23 | helmet: 24 | armor: 1 25 | toughness: 0 26 | knockbackResistance: 0 27 | speedPercentage: 0 28 | attackSpeedPercentage: 0 29 | attackDamagePercentage: 0 30 | attackKnockbackPercentage: 0 31 | chestplate: 32 | armor: 3 33 | toughness: 0 34 | knockbackResistance: 0 35 | speedPercentage: 0 36 | attackSpeedPercentage: 0 37 | attackDamagePercentage: 0 38 | attackKnockbackPercentage: 0 39 | elytra: 40 | armor: 0 41 | toughness: 0 42 | knockbackResistance: 0 43 | speedPercentage: 0 44 | attackSpeedpercentage: 0 45 | attackDamagePercentage: 0 46 | attackKnockbackPercentage: 0 47 | leggings: 48 | armor: 2 49 | toughness: 0 50 | knockbackResistance: 0 51 | speedPercentage: 0 52 | attackSpeedPercentage: 0 53 | attackDamagePercentage: 0 54 | attackKnockbackPercentage: 0 55 | boots: 56 | armor: 1 57 | toughness: 0 58 | knockbackResistance: 0 59 | speedPercentage: 0 60 | attackSpeedPercentage: 0 61 | attackDamagePercentage: 0 62 | attackKnockbackPercentage: 0 -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorSets.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.sets 2 | 3 | import com.google.common.collect.ImmutableList 4 | import com.willfp.eco.core.config.interfaces.Config 5 | import com.willfp.eco.core.registry.Registry 6 | import com.willfp.ecoarmor.EcoArmorPlugin 7 | import com.willfp.libreforge.loader.LibreforgePlugin 8 | import com.willfp.libreforge.loader.configs.ConfigCategory 9 | import com.willfp.libreforge.loader.configs.LegacyLocation 10 | 11 | object ArmorSets : ConfigCategory("set", "sets") { 12 | /** 13 | * Registered armor sets. 14 | */ 15 | private val registry = Registry() 16 | 17 | override val legacyLocation = LegacyLocation( 18 | "ecoarmor.yml", 19 | "sets" 20 | ) 21 | 22 | /** 23 | * Get all registered [ArmorSet]s. 24 | * 25 | * @return A list of all [ArmorSet]s. 26 | */ 27 | @JvmStatic 28 | fun values(): List { 29 | return ImmutableList.copyOf(registry.values()) 30 | } 31 | 32 | /** 33 | * Get [ArmorSet] matching ID. 34 | * 35 | * @param name The name to search for. 36 | * @return The matching [ArmorSet], or null if not found. 37 | */ 38 | @JvmStatic 39 | fun getByID(name: String): ArmorSet? { 40 | return registry[name] 41 | } 42 | 43 | override fun clear(plugin: LibreforgePlugin) { 44 | registry.clear() 45 | } 46 | 47 | override fun acceptConfig(plugin: LibreforgePlugin, id: String, config: Config) { 48 | registry.register(ArmorSet(id, config, plugin as EcoArmorPlugin)) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/tiers/iron.yml: -------------------------------------------------------------------------------- 1 | display: "&7&lIRON" 2 | requiresTiers: 3 | - default 4 | crystal: 5 | item: end_crystal 6 | name: "&7Iron Upgrade Crystal" 7 | craftable: true 8 | recipe: 9 | - air 10 | - iron_block 11 | - air 12 | - iron_block 13 | - leather_chestplate 14 | - iron_block 15 | - air 16 | - iron_block 17 | - air 18 | giveAmount: 1 19 | lore: 20 | - "&8Drop this onto an armor piece" 21 | - "&8to set its tier to:" 22 | - "&7&lIRON" 23 | - '' 24 | - "&8&oRequires the armor to already have default tier" 25 | properties: 26 | helmet: 27 | armor: 2 28 | toughness: 0 29 | knockbackResistance: 0 30 | speedPercentage: 0 31 | attackSpeedPercentage: 0 32 | attackDamagePercentage: 0 33 | attackKnockbackPercentage: 0 34 | chestplate: 35 | armor: 6 36 | toughness: 0 37 | knockbackResistance: 0 38 | speedPercentage: 0 39 | attackSpeedPercentage: 0 40 | attackDamagePercentage: 0 41 | attackKnockbackPercentage: 0 42 | elytra: 43 | armor: 2 44 | toughness: 0 45 | knockbackResistance: 0 46 | speedPercentage: 0 47 | attackSpeedPercentage: 0 48 | attackDamagePercentage: 0 49 | attackKnockbackPercentage: 0 50 | leggings: 51 | armor: 5 52 | toughness: 0 53 | knockbackResistance: 0 54 | speedPercentage: 0 55 | attackSpeedPercentage: 0 56 | attackDamagePercentage: 0 57 | attackKnockbackPercentage: 0 58 | boots: 59 | armor: 2 60 | toughness: 0 61 | knockbackResistance: 0 62 | speedPercentage: 0 63 | attackSpeedPercentage: 0 64 | attackDamagePercentage: 0 65 | attackKnockbackPercentage: 0 -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/tiers/diamond.yml: -------------------------------------------------------------------------------- 1 | display: "&b&lDIAMOND" 2 | requiresTiers: 3 | - iron 4 | crystal: 5 | item: end_crystal 6 | name: "&bDiamond Upgrade Crystal" 7 | craftable: true 8 | recipe: 9 | - air 10 | - diamond_block 11 | - air 12 | - diamond_block 13 | - ecoarmor:upgrade_crystal_iron 14 | - diamond_block 15 | - air 16 | - diamond_block 17 | - air 18 | giveAmount: 1 19 | lore: 20 | - "&8Drop this onto an armor piece" 21 | - "&8to set its tier to:" 22 | - "&b&lDIAMOND" 23 | - '' 24 | - "&8&oRequires the armor to already have Iron tier" 25 | properties: 26 | helmet: 27 | armor: 3 28 | toughness: 2 29 | knockbackResistance: 0 30 | speedPercentage: 0 31 | attackSpeedPercentage: 0 32 | attackDamagePercentage: 0 33 | attackKnockbackPercentage: 0 34 | chestplate: 35 | armor: 8 36 | toughness: 2 37 | knockbackResistance: 0 38 | speedPercentage: 0 39 | attackSpeedPercentage: 0 40 | attackDamagePercentage: 0 41 | attackKnockbackPercentage: 0 42 | elytra: 43 | armor: 3 44 | toughness: 0 45 | knockbackResistance: 0 46 | speedPercentage: 0 47 | attackSpeedPercentage: 0 48 | attackDamagePercentage: 0 49 | attackKnockbackPercentage: 0 50 | leggings: 51 | armor: 6 52 | toughness: 2 53 | knockbackResistance: 0 54 | speedPercentage: 0 55 | attackSpeedPercentage: 0 56 | attackDamagePercentage: 0 57 | attackKnockbackPercentage: 0 58 | boots: 59 | armor: 3 60 | toughness: 2 61 | knockbackResistance: 0 62 | speedPercentage: 0 63 | attackSpeedPercentage: 0 64 | attackDamagePercentage: 0 65 | attackKnockbackPercentage: 0 -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/tiers/cobalt.yml: -------------------------------------------------------------------------------- 1 | display: "/ab&lCOBALT" 2 | requiresTiers: 3 | - iron 4 | crystal: 5 | item: end_crystal 6 | name: "/abCobalt Upgrade Crystal" 7 | craftable: true 8 | recipe: 9 | - air 10 | - obsidian 11 | - air 12 | - obsidian 13 | - ecoarmor:upgrade_crystal_iron 14 | - obsidian 15 | - air 16 | - obsidian 17 | - air 18 | giveAmount: 1 19 | lore: 20 | - "&8Drop this onto an armor piece" 21 | - "&8to set its tier to:" 22 | - "/ab&lCOBALT" 23 | - '' 24 | - "&8&oRequires the armor to already have Iron tier" 25 | properties: 26 | helmet: 27 | armor: 3 28 | toughness: 4 29 | knockbackResistance: 1 30 | speedPercentage: -10 31 | attackSpeedPercentage: -10 32 | attackDamagePercentage: 0 33 | attackKnockbackPercentage: 10 34 | chestplate: 35 | armor: 8 36 | toughness: 4 37 | knockbackResistance: 1 38 | speedPercentage: -10 39 | attackSpeedPercentage: -10 40 | attackDamagePercentage: 0 41 | attackKnockbackPercentage: 10 42 | elytra: 43 | armor: 6 44 | toughness: 2 45 | knockbackResistance: 1 46 | speedPercentage: -10 47 | attackSpeedPercentage: -10 48 | attackDamagePercentage: 0 49 | attackKnockbackPercentage: 10 50 | leggings: 51 | armor: 6 52 | toughness: 4 53 | knockbackResistance: 1 54 | speedPercentage: -10 55 | attackSpeedPercentage: -1 56 | attackDamagePercentage: 0 57 | attackKnockbackPercentage: 10 58 | boots: 59 | armor: 3 60 | toughness: 4 61 | knockbackResistance: 1 62 | speedPercentage: -10 63 | attackSpeedPercentage: -10 64 | attackDamagePercentage: 0 65 | attackKnockbackPercentage: 10 -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/tiers/netherite.yml: -------------------------------------------------------------------------------- 1 | display: "&c&lNETHERITE" 2 | requiresTiers: 3 | - diamond 4 | crystal: 5 | item: end_crystal 6 | name: "&cNetherite Upgrade Crystal" 7 | craftable: true 8 | recipe: 9 | - air 10 | - netherite_ingot 11 | - air 12 | - netherite_ingot 13 | - ecoarmor:upgrade_crystal_diamond 14 | - netherite_ingot 15 | - air 16 | - netherite_ingot 17 | - air 18 | giveAmount: 1 19 | lore: 20 | - "&8Drop this onto an armor piece" 21 | - "&8to set its tier to:" 22 | - "&c&lNETHERITE" 23 | - '' 24 | - "&8&oRequires the armor to already have Diamond tier" 25 | properties: 26 | helmet: 27 | armor: 3 28 | toughness: 3 29 | knockbackResistance: 1 30 | speedPercentage: 0 31 | attackSpeedPercentage: 0 32 | attackDamagePercentage: 0 33 | attackKnockbackPercentage: 0 34 | chestplate: 35 | armor: 8 36 | toughness: 3 37 | knockbackResistance: 1 38 | speedPercentage: 0 39 | attackSpeedPercentage: 0 40 | attackDamagePercentage: 0 41 | attackKnockbackPercentage: 0 42 | elytra: 43 | armor: 3 44 | toughness: 0 45 | knockbackResistance: 1 46 | speedPercentage: 0 47 | attackSpeedPercentage: 0 48 | attackDamagePercentage: 0 49 | attackKnockbackPercentage: 0 50 | leggings: 51 | armor: 6 52 | toughness: 3 53 | knockbackResistance: 1 54 | speedPercentage: 0 55 | attackSpeedPercentage: 0 56 | attackDamagePercentage: 0 57 | attackKnockbackPercentage: 0 58 | boots: 59 | armor: 3 60 | toughness: 3 61 | knockbackResistance: 1 62 | speedPercentage: 0 63 | attackSpeedPercentage: 0 64 | attackDamagePercentage: 0 65 | attackKnockbackPercentage: 0 -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/tiers/ancient.yml: -------------------------------------------------------------------------------- 1 | display: "&6&k!!&r &lANCIENT&r &6&k!!&r" 2 | requiresTiers: [] 3 | crystal: 4 | item: end_crystal 5 | name: "Ancient Upgrade Crystal" 6 | craftable: false 7 | recipe: 8 | - air 9 | - netherite_block 10 | - air 11 | - netherite_block 12 | - ecoarmor:upgrade_crystal_cobalt 13 | - netherite_block 14 | - air 15 | - netherite_block 16 | - air 17 | giveAmount: 1 18 | lore: 19 | - "&8Drop this onto an armor piece" 20 | - "&8to set its tier to:" 21 | - "&6&k!!&r &lANCIENT&r &6&k!!&r" 22 | properties: 23 | helmet: 24 | armor: 3 25 | toughness: 5 26 | knockbackResistance: 0 27 | speedPercentage: 5 28 | attackSpeedPercentage: 5 29 | attackDamagePercentage: 0 30 | attackKnockbackPercentage: 0 31 | chestplate: 32 | armor: 8 33 | toughness: 5 34 | knockbackResistance: 0 35 | speedPercentage: 5 36 | attackSpeedPercentage: 5 37 | attackDamagePercentage: 0 38 | attackKnockbackPercentage: 0 39 | elytra: 40 | armor: 3 41 | toughness: 5 42 | knockbackResistance: 0 43 | speedPercentage: 5 44 | attackSpeedPercentage: 5 45 | attackDamagePercentage: 0 46 | attackKnockbackPercentage: 0 47 | leggings: 48 | armor: 6 49 | toughness: 6 50 | knockbackResistance: 0 51 | speedPercentage: 5 52 | attackSpeedPercentage: 5 53 | attackDamagePercentage: 0 54 | attackKnockbackPercentage: 0 55 | boots: 56 | armor: 3 57 | toughness: 6 58 | knockbackResistance: 0 59 | speedPercentage: 5 60 | attackSpeedPercentage: 5 61 | attackDamagePercentage: 0 62 | attackKnockbackPercentage: 0 -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/tiers/mythic.yml: -------------------------------------------------------------------------------- 1 | display: "&1&k!!&r &lMYTHIC&r &1&k!!&r" 2 | requiresTiers: [] 3 | crystal: 4 | item: end_crystal 5 | name: "Mythic Upgrade Crystal" 6 | craftable: false 7 | recipe: 8 | - air 9 | - netherite_block 10 | - air 11 | - netherite_block 12 | - ecoarmor:upgrade_crystal_cobalt 13 | - netherite_block 14 | - air 15 | - netherite_block 16 | - air 17 | giveAmount: 1 18 | lore: 19 | - "&8Drop this onto an armor piece" 20 | - "&8to set its tier to:" 21 | - "&1&k!!&r &lMYTHIC&r &1&k!!&r" 22 | properties: 23 | helmet: 24 | armor: 3 25 | toughness: 7 26 | knockbackResistance: 0 27 | speedPercentage: 7 28 | attackSpeedPercentage: 8 29 | attackDamagePercentage: 2 30 | attackKnockbackPercentage: 2 31 | chestplate: 32 | armor: 8 33 | toughness: 7 34 | knockbackResistance: 0 35 | speedPercentage: 7 36 | attackSpeedPercentage: 8 37 | attackDamagePercentage: 2 38 | attackKnockbackPercentage: 2 39 | elytra: 40 | armor: 3 41 | toughness: 7 42 | knockbackResistance: 0 43 | speedPercentage: 7 44 | attackSpeedPercentage: 8 45 | attackDamagePercentage: 2 46 | attackKnockbackPercentage: 2 47 | leggings: 48 | armor: 6 49 | toughness: 7 50 | knockbackResistance: 0 51 | speedPercentage: 7 52 | attackSpeedPercentage: 8 53 | attackDamagePercentage: 2 54 | attackKnockbackPercentage: 2 55 | boots: 56 | armor: 3 57 | toughness: 7 58 | knockbackResistance: 0 59 | speedPercentage: 7 60 | attackSpeedPercentage: 8 61 | attackDamagePercentage: 2 62 | attackKnockbackPercentage: 2 -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/tiers/osmium.yml: -------------------------------------------------------------------------------- 1 | display: "&b&k!!&r &lOSMIUM&r &b&k!!" 2 | requiresTiers: 3 | - cobalt 4 | crystal: 5 | item: end_crystal 6 | name: "Osmium upgrade crystal" 7 | craftable: true 8 | recipe: 9 | - air 10 | - netherite_block 11 | - air 12 | - netherite_block 13 | - ecoarmor:upgrade_crystal_cobalt 14 | - netherite_block 15 | - air 16 | - netherite_block 17 | - air 18 | giveAmount: 1 19 | lore: 20 | - "&8Drop this onto an armor piece" 21 | - "&8to set its tier to:" 22 | - "&b&k!!&r &lOSMIUM&r &b&k!!" 23 | - '' 24 | - "&8&oRequires the armor to already have Cobalt tier" 25 | properties: 26 | helmet: 27 | armor: 3 28 | toughness: 6 29 | knockbackResistance: 3 30 | speedPercentage: -15 31 | attackSpeedPercentage: -15 32 | attackDamagePercentage: 5 33 | attackKnockbackPercentage: 25 34 | chestplate: 35 | armor: 8 36 | toughness: 6 37 | knockbackResistance: 3 38 | speedPercentage: -15 39 | attackSpeedPercentage: -15 40 | attackDamagePercentage: 5 41 | attackKnockbackPercentage: 25 42 | elytra: 43 | armor: 8 44 | toughness: 6 45 | knockbackResistance: 3 46 | speedPercentage: -15 47 | attackSpeedPercentage: -15 48 | attackDamagePercentage: 5 49 | attackKnockbackPercentage: 25 50 | leggings: 51 | armor: 6 52 | toughness: 6 53 | knockbackResistance: 3 54 | speedPercentage: -15 55 | attackSpeedPercentage: -15 56 | attackDamagePercentage: 5 57 | attackKnockbackPercentage: 25 58 | boots: 59 | armor: 3 60 | toughness: 6 61 | knockbackResistance: 3 62 | speedPercentage: -15 63 | attackSpeedPercentage: -15 64 | attackDamagePercentage: 5 65 | attackKnockbackPercentage: 25 -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/AdvancementShardListener.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.upgrades 2 | 3 | import com.willfp.eco.core.EcoPlugin 4 | import com.willfp.ecoarmor.sets.ArmorSets 5 | import com.willfp.ecoarmor.sets.ArmorUtils 6 | import org.bukkit.GameMode 7 | import org.bukkit.Material 8 | import org.bukkit.event.EventHandler 9 | import org.bukkit.event.Listener 10 | import org.bukkit.event.inventory.InventoryClickEvent 11 | import org.bukkit.inventory.ItemStack 12 | import org.bukkit.persistence.PersistentDataType 13 | 14 | class AdvancementShardListener(private val plugin: EcoPlugin) : Listener { 15 | @EventHandler 16 | fun onDrag(event: InventoryClickEvent) { 17 | if (event.whoClicked.gameMode == GameMode.CREATIVE) { 18 | return 19 | } 20 | val current = event.currentItem ?: return 21 | val cursor = event.cursor ?: return 22 | 23 | val cursorMeta = cursor.itemMeta ?: return 24 | 25 | val shardSet = cursorMeta.persistentDataContainer.get( 26 | plugin.namespacedKeyFactory.create("advancement-shard"), 27 | PersistentDataType.STRING 28 | ) ?: return 29 | 30 | val set = ArmorUtils.getSetOnItem(current) ?: return 31 | 32 | if (ArmorSets.getByID(shardSet)?.id != set.id) { 33 | return 34 | } 35 | 36 | if (current.type == Material.AIR) { 37 | return 38 | } 39 | 40 | if (ArmorUtils.isAdvanced(current)) { 41 | return 42 | } 43 | 44 | ArmorUtils.setAdvanced(current, true) 45 | 46 | if (cursor.amount > 1) { 47 | cursor.amount -= 1 48 | event.whoClicked.setItemOnCursor(cursor) 49 | } else { 50 | event.whoClicked.setItemOnCursor(ItemStack(Material.AIR)) 51 | } 52 | 53 | event.isCancelled = true 54 | } 55 | } -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/Tiers.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.upgrades 2 | 3 | import com.google.common.collect.ImmutableList 4 | import com.willfp.eco.core.config.interfaces.Config 5 | import com.willfp.eco.core.registry.Registry 6 | import com.willfp.ecoarmor.EcoArmorPlugin 7 | import com.willfp.libreforge.loader.LibreforgePlugin 8 | import com.willfp.libreforge.loader.configs.ConfigCategory 9 | import com.willfp.libreforge.loader.configs.LegacyLocation 10 | 11 | object Tiers : ConfigCategory("tier", "tiers") { 12 | /** 13 | * Registered tiers. 14 | */ 15 | private val registry = Registry() 16 | 17 | override val supportsSharing = false 18 | 19 | override val legacyLocation = LegacyLocation( 20 | "ecoarmor.yml", 21 | "tiers" 22 | ) 23 | 24 | /** 25 | * Default tier. 26 | */ 27 | @JvmStatic 28 | lateinit var defaultTier: Tier 29 | 30 | /** 31 | * Get [Tiers] matching ID. 32 | * 33 | * @param name The name to search for. 34 | * @return The matching [Tiers], or null if not found. 35 | */ 36 | @JvmStatic 37 | fun getByID(name: String?): Tier? { 38 | if (name == null) { 39 | return null 40 | } 41 | 42 | return registry[name] 43 | } 44 | 45 | /** 46 | * Get all registered [Tiers]s. 47 | * 48 | * @return A list of all [Tiers]s. 49 | */ 50 | @JvmStatic 51 | fun values(): List { 52 | return ImmutableList.copyOf(registry.values()) 53 | } 54 | 55 | override fun clear(plugin: LibreforgePlugin) { 56 | registry.clear() 57 | } 58 | 59 | override fun acceptConfig(plugin: LibreforgePlugin, id: String, config: Config) { 60 | registry.register(Tier(id, config, plugin as EcoArmorPlugin)) 61 | } 62 | 63 | override fun afterReload(plugin: LibreforgePlugin) { 64 | defaultTier = getByID("default")!! 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |
3 | EcoArmor logo 4 |
5 |

6 | 7 |

Source code for EcoArmor, a premium spigot plugin.

8 | 9 |

10 | 11 | spigot 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |

26 | 27 | 28 | [![Title](https://i.imgur.com/jcBbZhG.png)]() 29 | [![Features](https://i.imgur.com/ikQaAHr.png)]() 30 | [![Docs](https://i.imgur.com/oXdVuIw.png)](https://ecoarmor.willfp.com/) 31 | [![Compatibility](https://i.imgur.com/Q9Gko0q.png)]() 32 | 33 | ## License 34 | *Click here to read [the entire license](https://github.com/Auxilor/EcoArmor/blob/master/LICENSE.md).* 35 | 36 |

37 |
38 | 39 | supps banner 40 | 41 | 42 | dedimc banner 43 | 44 |
45 |

46 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/tiers/exotic.yml: -------------------------------------------------------------------------------- 1 | display: "&6&k!!&r &lEXOTIC&r &6&k!!&r" 2 | requiresTiers: 3 | - netherite 4 | crystal: 5 | item: end_crystal 6 | name: "Exotic Upgrade Crystal" 7 | craftable: true 8 | recipe: 9 | - ecoarmor:upgrade_crystal_netherite 10 | - turtle_egg 11 | - ecoarmor:upgrade_crystal_netherite 12 | - turtle_egg 13 | - ecoarmor:upgrade_crystal_cobalt 14 | - turtle_egg 15 | - ecoarmor:upgrade_crystal_netherite 16 | - turtle_egg 17 | - ecoarmor:upgrade_crystal_netherite 18 | giveAmount: 1 19 | lore: 20 | - "&8Drop this onto an armor piece" 21 | - "&8to set its tier to:" 22 | - "&6&k!!&r &lEXOTIC&r &6&k!!&r" 23 | - '' 24 | - "&8&oRequires the armor to already have Netherite tier" 25 | properties: 26 | helmet: 27 | armor: 3 28 | toughness: 2 29 | knockbackResistance: 0 30 | speedPercentage: 5 31 | attackSpeedPercentage: 10 32 | attackDamagePercentage: -5 33 | attackKnockbackPercentage: -20 34 | chestplate: 35 | armor: 8 36 | toughness: 2 37 | knockbackResistance: 0 38 | speedPercentage: 5 39 | attackSpeedPercentage: 10 40 | attackDamagePercentage: -5 41 | attackKnockbackPercentage: -20 42 | elytra: 43 | armor: 3 44 | toughness: 0 45 | knockbackResistance: 0 46 | speedPercentage: 5 47 | attackSpeedPercentage: 10 48 | attackDamagePercentage: -5 49 | attackKnockbackPercentage: -20 50 | leggings: 51 | armor: 6 52 | toughness: 2 53 | knockbackResistance: 0 54 | speedPercentage: 5 55 | attackSpeedPercentage: 10 56 | attackDamagePercentage: -5 57 | attackKnockbackPercentage: -20 58 | boots: 59 | armor: 3 60 | toughness: 2 61 | knockbackResistance: 0 62 | speedPercentage: 5 63 | attackSpeedPercentage: 10 64 | attackDamagePercentage: -5 65 | attackKnockbackPercentage: -20 -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/CrystalListener.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.upgrades 2 | 3 | import com.willfp.ecoarmor.sets.ArmorUtils 4 | import org.bukkit.GameMode 5 | import org.bukkit.Material 6 | import org.bukkit.event.EventHandler 7 | import org.bukkit.event.Listener 8 | import org.bukkit.event.block.BlockPlaceEvent 9 | import org.bukkit.event.inventory.InventoryClickEvent 10 | import org.bukkit.inventory.ItemStack 11 | 12 | class CrystalListener : Listener { 13 | @EventHandler 14 | fun onDrag(event: InventoryClickEvent) { 15 | if (event.whoClicked.gameMode == GameMode.CREATIVE) { 16 | return 17 | } 18 | val current = event.currentItem ?: return 19 | val cursor = event.cursor ?: return 20 | 21 | val crystalTier = ArmorUtils.getCrystalTier(cursor) ?: return 22 | 23 | if (ArmorUtils.getSetOnItem(current) == null) { 24 | return 25 | } 26 | 27 | if (current.type == Material.AIR) { 28 | return 29 | } 30 | val previousTier = ArmorUtils.getTier(current) 31 | var allowed = false 32 | val requiredTiers = crystalTier.getRequiredTiersForApplication() 33 | if (requiredTiers.isEmpty() || requiredTiers.contains(previousTier)) { 34 | allowed = true 35 | } 36 | if (!allowed) { 37 | return 38 | } 39 | ArmorUtils.setTier(current, crystalTier) 40 | if (cursor.amount > 1) { 41 | cursor.amount = cursor.amount - 1 42 | event.whoClicked.setItemOnCursor(cursor) 43 | } else { 44 | event.whoClicked.setItemOnCursor(ItemStack(Material.AIR)) 45 | } 46 | event.isCancelled = true 47 | } 48 | 49 | @EventHandler 50 | fun onPlaceCrystal(event: BlockPlaceEvent) { 51 | val item = event.itemInHand 52 | if (ArmorUtils.getCrystalTier(item) != null) { 53 | event.isCancelled = true 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/tiers/manyullyn.yml: -------------------------------------------------------------------------------- 1 | display: "&d&k!!&r &lMANYULLYN&r &d&k!!&r" 2 | requiresTiers: 3 | - netherite 4 | crystal: 5 | item: end_crystal 6 | name: "Manyullyn Upgrade Crystal" 7 | craftable: true 8 | recipe: 9 | - ecoarmor:upgrade_crystal_netherite 10 | - enchanted_golden_apple 11 | - ecoarmor:upgrade_crystal_netherite 12 | - enchanted_golden_apple 13 | - ecoarmor:upgrade_crystal_netherite 14 | - enchanted_golden_apple 15 | - ecoarmor:upgrade_crystal_netherite 16 | - enchanted_golden_apple 17 | - ecoarmor:upgrade_crystal_netherite 18 | giveAmount: 1 19 | lore: 20 | - "&8Drop this onto an armor piece" 21 | - "&8to set its tier to:" 22 | - "&d&k!!&r &lMANYULLYN&r &d&k!!&r" 23 | - '' 24 | - "&8&oRequires the armor to already have Netherite tier" 25 | properties: 26 | helmet: 27 | armor: 3 28 | toughness: 5 29 | knockbackResistance: 2 30 | speedPercentage: 0 31 | attackSpeedPercentage: 0 32 | attackDamagePercentage: 0 33 | attackKnockbackPercentage: 0 34 | chestplate: 35 | armor: 8 36 | toughness: 5 37 | knockbackResistance: 2 38 | speedPercentage: 0 39 | attackSpeedPercentage: 0 40 | attackDamagePercentage: 0 41 | attackKnockbackPercentage: 0 42 | elytra: 43 | armor: 3 44 | toughness: 0 45 | knockbackResistance: 2 46 | speedPercentage: 0 47 | attackSpeedPercentage: 0 48 | attackDamagePercentage: 0 49 | attackKnockbackPercentage: 0 50 | leggings: 51 | armor: 6 52 | toughness: 5 53 | knockbackResistance: 2 54 | speedPercentage: 0 55 | attackSpeedPercentage: 0 56 | attackDamagePercentage: 0 57 | attackKnockbackPercentage: 0 58 | boots: 59 | armor: 3 60 | toughness: 5 61 | knockbackResistance: 2 62 | speedPercentage: 0 63 | attackSpeedPercentage: 0 64 | attackDamagePercentage: 0 65 | attackKnockbackPercentage: 0 -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/tiers/_example.yml: -------------------------------------------------------------------------------- 1 | # The ID of the tier is the name of the .yml file, 2 | # for example diamond.yml has the ID of diamond 3 | # You can place tiers anywhere in this folder, 4 | # including in subfolders if you want to organize your tier configs 5 | # _example.yml is not loaded. 6 | 7 | display: "&c&lNETHERITE" # The display in-game 8 | requiresTiers: # If this tier requires a prior tier 9 | - diamond # Tier ID 10 | - iron 11 | crystal: 12 | item: end_crystal # The crystal item, read more here: https://plugins.auxilor.io/all-plugins/the-item-lookup-system 13 | name: "&cNetherite Upgrade Crystal" # The name shown in-game. 14 | lore: # The lore shown in-game. Set to `lore: []` to remove lore. 15 | - "&8Drop this onto an armor piece" 16 | - "&8to set its tier to:" 17 | - "&c&lNETHERITE" 18 | - '' 19 | - "&8&oRequires the armor to already have Diamond tier" 20 | craftable: true # If the armor piece is craftable 21 | crafting-permission: "permission" # (Optional) The permission required to craft this recipe. 22 | recipe: # The recipe, read here for more: https://plugins.auxilor.io/all-plugins/the-item-lookup-system#crafting-recipes 23 | - air 24 | - netherite_ingot 25 | - air 26 | - netherite_ingot 27 | - ecoarmor:upgrade_crystal_diamond 28 | - netherite_ingot 29 | - air 30 | - netherite_ingot 31 | - air 32 | giveAmount: 1 # Optional, set the amount of items to give in the recipe 33 | properties: 34 | helmet: 35 | armor: 3 # The armor attribute 36 | toughness: 3 # the toughness attribute 37 | knockbackResistance: 1 # The knockback resistance attribute 38 | speedPercentage: 0 # The movement speed attribute 39 | attackSpeedPercentage: 0 # The attack speed attribute 40 | attackDamagePercentage: 0 # The damage attribute 41 | attackKnockbackPercentage: 0 # The knockback attribute 42 | chestplate: 43 | armor: 8 44 | toughness: 3 45 | knockbackResistance: 1 46 | speedPercentage: 0 47 | attackSpeedPercentage: 0 48 | attackDamagePercentage: 0 49 | attackKnockbackPercentage: 0 50 | elytra: 51 | armor: 3 52 | toughness: 0 53 | knockbackResistance: 1 54 | speedPercentage: 0 55 | attackSpeedPercentage: 0 56 | attackDamagePercentage: 0 57 | attackKnockbackPercentage: 0 58 | leggings: 59 | armor: 6 60 | toughness: 3 61 | knockbackResistance: 1 62 | speedPercentage: 0 63 | attackSpeedPercentage: 0 64 | attackDamagePercentage: 0 65 | attackKnockbackPercentage: 0 66 | boots: 67 | armor: 3 68 | toughness: 3 69 | knockbackResistance: 1 70 | speedPercentage: 0 71 | attackSpeedPercentage: 0 72 | attackDamagePercentage: 0 73 | attackKnockbackPercentage: 0: 0 -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/EcoArmorPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor 2 | 3 | import com.willfp.eco.core.command.impl.PluginCommand 4 | import com.willfp.eco.core.display.DisplayModule 5 | import com.willfp.eco.core.items.Items 6 | import com.willfp.ecoarmor.sets.PlayerArmorSetEventListeners 7 | import com.willfp.ecoarmor.commands.CommandEcoArmor 8 | import com.willfp.ecoarmor.display.ArmorDisplay 9 | import com.willfp.ecoarmor.libreforge.ConditionIsWearingSet 10 | import com.willfp.ecoarmor.sets.ArmorSetEquipSoundListeners 11 | import com.willfp.ecoarmor.sets.ArmorSets 12 | import com.willfp.ecoarmor.sets.ArmorUtils 13 | import com.willfp.ecoarmor.sets.EffectiveDurabilityListener 14 | import com.willfp.ecoarmor.sets.PreventSkullPlaceListener 15 | import com.willfp.ecoarmor.upgrades.AdvancementShardListener 16 | import com.willfp.ecoarmor.upgrades.CrystalListener 17 | import com.willfp.ecoarmor.upgrades.TierArgParser 18 | import com.willfp.ecoarmor.upgrades.Tiers 19 | import com.willfp.ecoarmor.util.DiscoverRecipeListener 20 | import com.willfp.libreforge.SimpleProvidedHolder 21 | import com.willfp.libreforge.conditions.Conditions 22 | import com.willfp.libreforge.loader.LibreforgePlugin 23 | import com.willfp.libreforge.loader.configs.ConfigCategory 24 | import com.willfp.libreforge.registerHolderProvider 25 | import com.willfp.libreforge.registerSpecificHolderProvider 26 | import org.bukkit.entity.Player 27 | import org.bukkit.event.Listener 28 | 29 | class EcoArmorPlugin : LibreforgePlugin() { 30 | init { 31 | instance = this 32 | Items.registerArgParser(TierArgParser()) 33 | } 34 | 35 | override fun handleLoad() { 36 | Conditions.register(ConditionIsWearingSet) 37 | } 38 | 39 | override fun handleEnable() { 40 | registerSpecificHolderProvider { 41 | ArmorUtils.getActiveHolders(it) 42 | } 43 | } 44 | 45 | override fun loadConfigCategories(): List { 46 | return listOf( 47 | Tiers, 48 | ArmorSets 49 | ) 50 | } 51 | 52 | override fun loadPluginCommands(): List { 53 | return listOf( 54 | CommandEcoArmor(this) 55 | ) 56 | } 57 | 58 | override fun loadListeners(): List { 59 | return listOf( 60 | CrystalListener(), 61 | AdvancementShardListener(this), 62 | EffectiveDurabilityListener(this), 63 | DiscoverRecipeListener(this), 64 | PreventSkullPlaceListener(), 65 | PlayerArmorSetEventListeners(), 66 | ArmorSetEquipSoundListeners() 67 | ) 68 | } 69 | 70 | override fun createDisplayModule(): DisplayModule { 71 | return ArmorDisplay(this) 72 | } 73 | 74 | companion object { 75 | @JvmStatic 76 | lateinit var instance: EcoArmorPlugin 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/display/ArmorDisplay.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.display 2 | 3 | import com.willfp.eco.core.EcoPlugin 4 | import com.willfp.eco.core.display.Display 5 | import com.willfp.eco.core.display.DisplayModule 6 | import com.willfp.eco.core.display.DisplayPriority 7 | import com.willfp.eco.core.fast.FastItemStack 8 | import com.willfp.eco.core.placeholder.context.placeholderContext 9 | import com.willfp.eco.util.formatEco 10 | import com.willfp.ecoarmor.sets.ArmorSlot 11 | import com.willfp.ecoarmor.sets.ArmorUtils 12 | import com.willfp.libreforge.SimpleProvidedHolder 13 | import org.bukkit.entity.Player 14 | import org.bukkit.inventory.ItemStack 15 | import org.bukkit.inventory.meta.LeatherArmorMeta 16 | 17 | class ArmorDisplay(plugin: EcoPlugin) : DisplayModule(plugin, DisplayPriority.LOWEST) { 18 | override fun display( 19 | itemStack: ItemStack, 20 | player: Player?, 21 | vararg args: Any 22 | ) { 23 | val meta = itemStack.itemMeta ?: return 24 | 25 | val fis = FastItemStack.wrap(itemStack) 26 | 27 | val set = ArmorUtils.getSetOnItem(meta) 28 | 29 | if (set == null) { 30 | val crystalTier = ArmorUtils.getCrystalTier(meta) 31 | 32 | if (crystalTier != null) { 33 | val lore = fis.lore 34 | lore.addAll(FastItemStack.wrap(crystalTier.crystal).lore) 35 | fis.lore = lore 36 | } 37 | 38 | val shardSet = ArmorUtils.getShardSet(meta) 39 | 40 | if (shardSet != null) { 41 | val lore = fis.lore 42 | lore.addAll(FastItemStack.wrap(shardSet.advancementShardItem).lore) 43 | itemStack.itemMeta = shardSet.advancementShardItem.itemMeta 44 | FastItemStack.wrap(itemStack).lore = lore 45 | } 46 | 47 | return 48 | } 49 | 50 | val slot = ArmorSlot.getSlot(itemStack) ?: return 51 | 52 | val slotStack: ItemStack = if (ArmorUtils.isAdvanced(meta)) { 53 | set.getAdvancedItemStack(slot) 54 | } else { 55 | set.getItemStack(slot) 56 | } 57 | 58 | val slotMeta = slotStack.itemMeta ?: return 59 | 60 | val tier = ArmorUtils.getTier(meta) ?: return 61 | 62 | val context = placeholderContext( 63 | player = player, 64 | item = itemStack 65 | ) 66 | 67 | val lore = FastItemStack.wrap(slotStack).lore 68 | .map { it.replace("%tier%", tier.displayName) } 69 | .formatEco(context) 70 | .toMutableList() 71 | 72 | meta.addItemFlags(*slotMeta.itemFlags.toTypedArray()) 73 | 74 | if (meta.hasLore()) { 75 | lore.addAll(fis.lore) 76 | } 77 | 78 | if (player != null) { 79 | val lines = mutableListOf() 80 | 81 | lines.addAll(if (ArmorUtils.isAdvanced(meta)) { 82 | SimpleProvidedHolder(set.advancedHolder) 83 | .getNotMetLines(player) 84 | .map { Display.PREFIX + it } 85 | } else { 86 | SimpleProvidedHolder(set.regularHolder) 87 | .getNotMetLines(player) 88 | .map { Display.PREFIX + it } 89 | }) 90 | 91 | // Lovely. 92 | lines.addAll( 93 | set.getSpecificHolder(itemStack)?.getNotMetLines(player) 94 | ?.map { Display.PREFIX + it } 95 | ?: emptyList() 96 | ) 97 | 98 | if (lines.isNotEmpty()) { 99 | lore.add(Display.PREFIX) 100 | lore.addAll(lines) 101 | } 102 | } 103 | 104 | if (this.plugin.configYml.getBool("update-item-names")) { 105 | @Suppress("DEPRECATION") 106 | meta.setDisplayName(slotMeta.displayName) 107 | } 108 | 109 | if (meta is LeatherArmorMeta && slotMeta is LeatherArmorMeta 110 | && this.plugin.configYml.getBool("update-leather-colors") 111 | ) { 112 | meta.setColor(slotMeta.color) 113 | } 114 | 115 | itemStack.itemMeta = meta 116 | FastItemStack.wrap(itemStack).lore = lore 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/Tier.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.upgrades 2 | 3 | import com.willfp.eco.core.EcoPlugin 4 | import com.willfp.eco.core.config.interfaces.Config 5 | import com.willfp.eco.core.display.Display 6 | import com.willfp.eco.core.items.CustomItem 7 | import com.willfp.eco.core.items.Items 8 | import com.willfp.eco.core.recipe.Recipes 9 | import com.willfp.eco.core.recipe.recipes.ShapedCraftingRecipe 10 | import com.willfp.eco.core.registry.Registrable 11 | import com.willfp.eco.util.StringUtils 12 | import com.willfp.ecoarmor.sets.ArmorSlot 13 | import com.willfp.ecoarmor.sets.ArmorUtils.getCrystalTier 14 | import com.willfp.libreforge.notNullMapOf 15 | import com.willfp.libreforge.notNullMutableMapOf 16 | import org.bukkit.inventory.ItemStack 17 | import org.bukkit.persistence.PersistentDataType 18 | import java.util.* 19 | 20 | 21 | @Suppress("DEPRECATION") 22 | class Tier( 23 | val id: String, 24 | private val config: Config, 25 | plugin: EcoPlugin 26 | ) : Registrable { 27 | /** 28 | * The display name of the crystal. 29 | */ 30 | val displayName: String 31 | 32 | /** 33 | * The names of the tiers required for application. 34 | */ 35 | private val requiredTiersForApplication: List 36 | 37 | /** 38 | * If the crafting recipe is enabled. 39 | */ 40 | val craftable: Boolean 41 | 42 | /** 43 | * The ItemStack of the crystal. 44 | */ 45 | val crystal: ItemStack 46 | 47 | /** 48 | * Item properties. 49 | */ 50 | val properties = notNullMutableMapOf() 51 | 52 | /** 53 | * Create a new Tier. 54 | */ 55 | init { 56 | craftable = this.config.getBool("crystal.craftable") 57 | displayName = this.config.getFormattedString("display") 58 | requiredTiersForApplication = this.config.getStrings("requiresTiers") 59 | val key = plugin.namespacedKeyFactory.create("upgrade_crystal") 60 | val out = Items.lookup(this.config.getString("crystal.item")).item 61 | val outMeta = out.itemMeta!! 62 | val container = outMeta.persistentDataContainer 63 | container.set(key, PersistentDataType.STRING, id) 64 | @Suppress("UsePropertyAccessSyntax") 65 | outMeta.setDisplayName(this.config.getFormattedString("crystal.name")) 66 | val lore: MutableList = ArrayList() 67 | for (loreLine in this.config.getStrings("crystal.lore")) { 68 | lore.add(Display.PREFIX + StringUtils.format(loreLine!!)) 69 | } 70 | outMeta.lore = lore 71 | out.itemMeta = outMeta 72 | out.amount = 1 // who knows 73 | crystal = out 74 | for (slot in ArmorSlot.values()) { 75 | properties[slot] = TierProperties( 76 | this.config.getInt("properties." + slot.name.lowercase(Locale.getDefault()) + ".armor"), 77 | this.config.getInt("properties." + slot.name.lowercase(Locale.getDefault()) + ".toughness"), 78 | this.config 79 | .getInt("properties." + slot.name.lowercase(Locale.getDefault()) + ".knockbackResistance"), 80 | this.config.getInt("properties." + slot.name.lowercase(Locale.getDefault()) + ".speedPercentage"), 81 | this.config 82 | .getInt("properties." + slot.name.lowercase(Locale.getDefault()) + ".attackSpeedPercentage"), 83 | this.config 84 | .getInt("properties." + slot.name.lowercase(Locale.getDefault()) + ".attackDamagePercentage"), 85 | this.config 86 | .getInt("properties." + slot.name.lowercase(Locale.getDefault()) + ".attackKnockbackPercentage") 87 | ) 88 | } 89 | 90 | CustomItem( 91 | plugin.namespacedKeyFactory.create("crystal_" + id.lowercase(Locale.getDefault())), 92 | { test: ItemStack? -> this == getCrystalTier(test!!) }, 93 | out 94 | ).register() 95 | 96 | if (this.craftable) { 97 | val recipeOut = out.clone().apply { 98 | amount = config.getInt("crystal.giveAmount") 99 | } 100 | Recipes.createAndRegisterRecipe( 101 | plugin, 102 | "upgrade_crystal_$id", 103 | recipeOut, 104 | config.getStrings("crystal.recipe"), 105 | config.getStringOrNull("crystal.crafting-permission") 106 | ) 107 | } else null 108 | } 109 | 110 | /** 111 | * Get the required tiers for application. 112 | * 113 | * @return The tiers, or a blank list if always available. 114 | */ 115 | fun getRequiredTiersForApplication(): List { 116 | return requiredTiersForApplication.mapNotNull { Tiers.getByID(it) } 117 | } 118 | 119 | override fun getID(): String { 120 | return this.id 121 | } 122 | 123 | override fun equals(other: Any?): Boolean { 124 | if (other !is Tier) { 125 | return false 126 | } 127 | return this.id == other.id 128 | } 129 | 130 | override fun hashCode(): Int { 131 | return Objects.hash(this.id) 132 | } 133 | } 134 | 135 | data class TierProperties( 136 | val armor: Int, 137 | val toughness: Int, 138 | val knockback: Int, 139 | val speed: Int, 140 | val attackSpeed: Int, 141 | val attackDamage: Int, 142 | val attackKnockback: Int 143 | ) 144 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/sets/reaper.yml: -------------------------------------------------------------------------------- 1 | conditions: [] 2 | effects: 3 | - id: damage_multiplier 4 | args: 5 | multiplier: 1.25 6 | triggers: 7 | - melee_attack 8 | - bow_attack 9 | - trident_attack 10 | advancedEffects: 11 | - id: damage_multiplier 12 | args: 13 | multiplier: 1.25 14 | triggers: 15 | - melee_attack 16 | - bow_attack 17 | - trident_attack 18 | - id: damage_multiplier 19 | args: 20 | multiplier: 0.9 21 | triggers: 22 | - take_damage 23 | sounds: 24 | equip: 25 | enabled: false 26 | sound: "" 27 | volume: 1 28 | pitch: 1 29 | advancedEquip: 30 | enabled: false 31 | sound: "" 32 | volume: 1 33 | pitch: 1 34 | unequip: 35 | enabled: false 36 | sound: "" 37 | volume: 1 38 | pitch: 1 39 | advancedLore: 40 | - '' 41 | - "&lADVANCED BONUS" 42 | - "&8» &6Take 10% less damage" 43 | - "&8&oRequires full set to be worn" 44 | shard: 45 | item: prismarine_shard unbreaking:1 hide_enchants 46 | name: "Advancement Shard: &cReaper" 47 | lore: 48 | - "&8Drop this onto &cReaper Armor" 49 | - "&8to make it Advanced." 50 | craftable: false 51 | recipe: 52 | - prismarine_shard 53 | - ecoarmor:set_reaper_helmet 54 | - prismarine_shard 55 | - ecoarmor:set_reaper_chestplate 56 | - nether_star 57 | - ecoarmor:set_reaper_leggings 58 | - prismarine_shard 59 | - ecoarmor:set_reaper_boots 60 | - prismarine_shard 61 | helmet: 62 | item: leather_helmet color:#303030 hide_dye 63 | name: "&cReaper Helmet" 64 | advancedName: "Advanced&c Reaper Helmet" 65 | effectiveDurability: 2048 66 | effects: [] 67 | advancedEffects: [] 68 | conditions: [] 69 | lore: 70 | - "&c&lREAPER SET BONUS" 71 | - "&8» &cDeal 25% more damage" 72 | - "&8&oRequires full set to be worn" 73 | - '' 74 | - "&fTier: %tier%" 75 | - "&8&oUpgrade with an Upgrade Crystal" 76 | craftable: true 77 | defaultTier: default 78 | recipe: 79 | - ecoitems:armor_core ? air 80 | - nether_star 81 | - ecoitems:armor_core ? air 82 | - nether_star 83 | - netherite_helmet 84 | - nether_star 85 | - air 86 | - nether_star 87 | - air 88 | chestplate: 89 | item: leather_chestplate color:#303030 hide_dye 90 | name: "&cReaper Chestplate" 91 | advancedName: "Advanced&c Reaper Chestplate" 92 | effectiveDurability: 2048 93 | effects: [] 94 | advancedEffects: [] 95 | conditions: [] 96 | lore: 97 | - "&c&lREAPER SET BONUS" 98 | - "&8» &cDeal 25% more damage" 99 | - "&8&oRequires full set to be worn" 100 | - '' 101 | - "&fTier: %tier%" 102 | - "&8&oUpgrade with an Upgrade Crystal" 103 | craftable: true 104 | defaultTier: default 105 | recipe: 106 | - ecoitems:armor_core ? air 107 | - nether_star 108 | - ecoitems:armor_core ? air 109 | - nether_star 110 | - netherite_chestplate 111 | - nether_star 112 | - air 113 | - nether_star 114 | - air 115 | elytra: 116 | item: elytra 117 | name: "&cReaper Elytra" 118 | advancedName: "Advanced&c Reaper Elytra" 119 | effectiveDurability: 2048 120 | effects: [] 121 | advancedEffects: [] 122 | conditions: [] 123 | lore: 124 | - "&c&lREAPER SET BONUS" 125 | - "&8» &cDeal 25% more damage" 126 | - "&8&oRequires full set to be worn" 127 | - '' 128 | - "&fTier: %tier%" 129 | - "&8&oUpgrade with an Upgrade Crystal" 130 | craftable: true 131 | defaultTier: default 132 | recipe: 133 | - ecoitems:armor_core ? air 134 | - nether_star 135 | - ecoitems:armor_core ? air 136 | - nether_star 137 | - elytra 138 | - nether_star 139 | - air 140 | - nether_star 141 | - air 142 | leggings: 143 | item: leather_leggings color:#303030 hide_dye 144 | name: "&cReaper Leggings" 145 | advancedName: "Advanced&c Reaper Leggings" 146 | effectiveDurability: 2048 147 | effects: [] 148 | advancedEffects: [] 149 | conditions: [] 150 | lore: 151 | - "&c&lREAPER SET BONUS" 152 | - "&8» &cDeal 25% more damage" 153 | - "&8&oRequires full set to be worn" 154 | - '' 155 | - "&fTier: %tier%" 156 | - "&8&oUpgrade with an Upgrade Crystal" 157 | craftable: true 158 | defaultTier: default 159 | recipe: 160 | - ecoitems:armor_core ? air 161 | - nether_star 162 | - ecoitems:armor_core ? air 163 | - nether_star 164 | - netherite_leggings 165 | - nether_star 166 | - air 167 | - nether_star 168 | - air 169 | boots: 170 | item: leather_boots color:#303030 hide_dye 171 | name: "&cReaper Boots" 172 | advancedName: "Advanced&c Reaper Boots" 173 | effectiveDurability: 2048 174 | effects: [] 175 | advancedEffects: [] 176 | conditions: [] 177 | lore: 178 | - "&c&lREAPER SET BONUS" 179 | - "&8» &cDeal 25% more damage" 180 | - "&8&oRequires full set to be worn" 181 | - '' 182 | - "&fTier: %tier%" 183 | - "&8&oUpgrade with an Upgrade Crystal" 184 | craftable: true 185 | defaultTier: default 186 | recipe: 187 | - ecoitems:armor_core ? air 188 | - nether_star 189 | - ecoitems:armor_core ? air 190 | - nether_star 191 | - netherite_boots 192 | - nether_star 193 | - air 194 | - nether_star 195 | - air -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/sets/slayer.yml: -------------------------------------------------------------------------------- 1 | conditions: [] 2 | effects: 3 | - id: damage_multiplier 4 | args: 5 | multiplier: 1.5 6 | triggers: 7 | - melee_attack 8 | - bow_attack 9 | - trident_attack 10 | filters: 11 | onlyBosses: true 12 | - id: damage_multiplier 13 | args: 14 | multiplier: 0.9 15 | triggers: 16 | - take_damage 17 | advancedEffects: 18 | - id: damage_multiplier 19 | args: 20 | multiplier: 0.8 21 | triggers: 22 | - take_damage 23 | - id: damage_multiplier 24 | args: 25 | multiplier: 2 26 | triggers: 27 | - melee_attack 28 | - bow_attack 29 | - trident_attack 30 | filters: 31 | onlyBosses: true 32 | sounds: 33 | equip: 34 | enabled: false 35 | sound: "" 36 | volume: 1 37 | pitch: 1 38 | advancedEquip: 39 | enabled: false 40 | sound: "" 41 | volume: 1 42 | pitch: 1 43 | unequip: 44 | enabled: false 45 | sound: "" 46 | volume: 1 47 | pitch: 1 48 | advancedLore: 49 | - '' 50 | - "&lADVANCED BONUS" 51 | - "&8» &4Take 20% less damage" 52 | - "&8» &4Deal 2x damage to bosses" 53 | - "&8&oRequires full set to be worn" 54 | shard: 55 | item: prismarine_shard unbreaking:1 hide_enchants 56 | name: "Advancement Shard: &4Slayer" 57 | lore: 58 | - "&8Drop this onto &4Slayer Armor" 59 | - "&8to make it Advanced." 60 | craftable: false 61 | recipe: 62 | - prismarine_shard 63 | - ecoarmor:set_slayer_helmet 64 | - prismarine_shard 65 | - ecoarmor:set_slayer_chestplate 66 | - nether_star 67 | - ecoarmor:set_slayer_leggings 68 | - prismarine_shard 69 | - ecoarmor:set_slayer_boots 70 | - prismarine_shard 71 | helmet: 72 | item: leather_helmet color:#750909 hide_dye 73 | name: "&4Slayer Helmet" 74 | advancedName: "Advanced&4 Slayer Helmet" 75 | effectiveDurability: 768 76 | effects: [] 77 | advancedEffects: [] 78 | conditions: [] 79 | lore: 80 | - "&4&lSLAYER SET BONUS" 81 | - "&8» &4Deal 50% more damage to bosses" 82 | - "&8» &4Take 10% less damage" 83 | - "&8&oRequires full set to be worn" 84 | - '' 85 | - "&fTier: %tier%" 86 | - "&8&oUpgrade with an Upgrade Crystal" 87 | craftable: true 88 | defaultTier: default 89 | recipe: 90 | - air 91 | - netherite_helmet 92 | - air 93 | - ecoitems:boss_core ? heart_of_the_sea 94 | - air 95 | - ecoitems:boss_core ? heart_of_the_sea 96 | - obsidian 97 | - ecoitems:armor_core ? nether_star 98 | - obsidian 99 | chestplate: 100 | item: leather_chestplate color:#750909 hide_dye 101 | leatherColor: "#750909" 102 | name: "&4Slayer Chestplate" 103 | advancedName: "Advanced&4 Slayer Chestplate" 104 | effectiveDurability: 1024 105 | effects: [] 106 | advancedEffects: [] 107 | conditions: [] 108 | lore: 109 | - "&4&lSLAYER SET BONUS" 110 | - "&8» &4Deal 50% more damage to bosses" 111 | - "&8» &4Take 10% less damage" 112 | - "&8&oRequires full set to be worn" 113 | - '' 114 | - "&fTier: %tier%" 115 | - "&8&oUpgrade with an Upgrade Crystal" 116 | craftable: true 117 | defaultTier: default 118 | recipe: 119 | - air 120 | - netherite_chestplate 121 | - air 122 | - ecoitems:boss_core ? heart_of_the_sea 123 | - air 124 | - ecoitems:boss_core ? heart_of_the_sea 125 | - obsidian 126 | - ecoitems:armor_core ? nether_star 127 | - obsidian 128 | elytra: 129 | item: elytra 130 | name: "&4Slayer Elytra" 131 | advancedName: "Advanced &4Slayer Elytra" 132 | effectiveDurability: 1024 133 | effects: [] 134 | advancedEffects: [] 135 | conditions: [] 136 | lore: 137 | - "&4&lSLAYER SET BONUS" 138 | - "&8» &4Deal 50% more damage to bosses" 139 | - "&8» &4Take 10% less damage" 140 | - "&8&oRequires full set to be worn" 141 | - '' 142 | - "&fTier: %tier%" 143 | - "&8&oUpgrade with an Upgrade Crystal" 144 | craftable: true 145 | defaultTier: default 146 | recipe: 147 | - air 148 | - elytra 149 | - air 150 | - ecoitems:boss_core ? heart_of_the_sea 151 | - air 152 | - ecoitems:boss_core ? heart_of_the_sea 153 | - obsidian 154 | - ecoitems:armor_core ? nether_star 155 | - obsidian 156 | leggings: 157 | item: leather_leggings color:#750909 hide_dye 158 | name: "&4Slayer Leggings" 159 | advancedName: "Advanced&4 Slayer Leggings" 160 | effectiveDurability: 1024 161 | effects: [] 162 | advancedEffects: [] 163 | conditions: [] 164 | lore: 165 | - "&4&lSLAYER SET BONUS" 166 | - "&8» &4Deal 50% more damage to bosses" 167 | - "&8» &4Take 10% less damage" 168 | - "&8&oRequires full set to be worn" 169 | - '' 170 | - "&fTier: %tier%" 171 | - "&8&oUpgrade with an Upgrade Crystal" 172 | craftable: true 173 | defaultTier: default 174 | recipe: 175 | - air 176 | - netherite_leggings 177 | - air 178 | - ecoitems:boss_core ? heart_of_the_sea 179 | - air 180 | - ecoitems:boss_core ? heart_of_the_sea 181 | - obsidian 182 | - ecoitems:armor_core ? nether_star 183 | - obsidian 184 | boots: 185 | item: leather_boots color:#750909 hide_dye 186 | name: "&4Slayer Boots" 187 | advancedName: "Advanced&4 Slayer Boots" 188 | effectiveDurability: 1024 189 | effects: [] 190 | advancedEffects: [] 191 | conditions: [] 192 | lore: 193 | - "&4&lSLAYER SET BONUS" 194 | - "&8» &4Deal 50% more damage to bosses" 195 | - "&8» &4Take 10% less damage" 196 | - "&8&oRequires full set to be worn" 197 | - '' 198 | - "&fTier: %tier%" 199 | - "&8&oUpgrade with an Upgrade Crystal" 200 | craftable: false 201 | defaultTier: default 202 | recipe: 203 | - air 204 | - netherite_boots 205 | - air 206 | - ecoitems:boss_core ? heart_of_the_sea 207 | - air 208 | - ecoitems:boss_core ? heart_of_the_sea 209 | - obsidian 210 | - ecoitems:armor_core ? nether_star 211 | - obsidian -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/sets/angelic.yml: -------------------------------------------------------------------------------- 1 | conditions: [] 2 | effects: 3 | - id: bonus_health 4 | args: 5 | health: 10 6 | - id: damage_multiplier 7 | args: 8 | multiplier: 0.9 9 | triggers: 10 | - melee_attack 11 | - id: permanent_potion_effect 12 | args: 13 | effect: regeneration 14 | level: 1 15 | advancedEffects: 16 | - id: bonus_health 17 | args: 18 | health: 20 19 | - id: hunger_multiplier 20 | args: 21 | multiplier: 0.5 22 | - id: permanent_potion_effect 23 | args: 24 | effect: regeneration 25 | level: 1 26 | sounds: 27 | equip: 28 | enabled: false 29 | sound: "" 30 | volume: 1 31 | pitch: 1 32 | advancedEquip: 33 | enabled: false 34 | sound: "" 35 | volume: 1 36 | pitch: 1 37 | unequip: 38 | enabled: false 39 | sound: "" 40 | volume: 1 41 | pitch: 1 42 | advancedLore: 43 | - '' 44 | - "&lADVANCED BONUS" 45 | - "&8» &dGet 20 more hearts" 46 | - "&8» &dReduce hunger loss by 50%" 47 | - "&8&oRequires full set to be worn" 48 | shard: 49 | item: prismarine_shard unbreaking:1 hide_enchants 50 | name: "Advancement Shard: &5Angelic" 51 | lore: 52 | - "&8Drop this onto &5Angelic Armor" 53 | - "&8to make it Advanced." 54 | craftable: false 55 | recipe: 56 | - prismarine_shard 57 | - ecoarmor:set_angelic_helmet 58 | - prismarine_shard 59 | - ecoarmor:set_angelic_chestplate 60 | - nether_star 61 | - ecoarmor:set_angelic_leggings 62 | - prismarine_shard 63 | - ecoarmor:set_angelic_boots 64 | - prismarine_shard 65 | helmet: 66 | item: leather_helmet color:#bd15a9 hide_dye 67 | name: "&5Angelic Helmet" 68 | advancedName: "Advanced&5 Angelic Helmet" 69 | effectiveDurability: 768 70 | effects: [] 71 | advancedEffects: [] 72 | conditions: [] 73 | lore: 74 | - "&5&lANGELIC SET BONUS" 75 | - "&8» &dGain 10 more hearts" 76 | - "&8» &dPermanent regeneration" 77 | - "&8» &dDeal 10% less melee damage" 78 | - "&8&oRequires full set to be worn" 79 | - '' 80 | - "&fTier: %tier%" 81 | - "&8&oUpgrade with an Upgrade Crystal" 82 | craftable: true 83 | defaultTier: default 84 | recipe: 85 | - netherite_block 86 | - ecoitems:enchanted_ender_eye ? netherite_ingot 87 | - diamond_block 88 | - air 89 | - golden_helmet 90 | - air 91 | - gold_block 92 | - ecoitems:armor_core ? enchanted_book mending:1 93 | - gold_block 94 | chestplate: 95 | item: leather_chestplate color:#bd15a9 hide_dye 96 | name: "&5Angelic Chestplate" 97 | advancedName: "Advanced&5 Angelic Chestplate" 98 | effectiveDurability: 1024 99 | effects: [] 100 | advancedEffects: [] 101 | conditions: [] 102 | lore: 103 | - "&5&lANGELIC SET BONUS" 104 | - "&8» &dGain 10 more hearts" 105 | - "&8» &dPermanent regeneration" 106 | - "&8» &dDeal 10% less melee damage" 107 | - "&8&oRequires full set to be worn" 108 | - '' 109 | - "&fTier: %tier%" 110 | - "&8&oUpgrade with an Upgrade Crystal" 111 | craftable: true 112 | defaultTier: default 113 | recipe: 114 | - netherite_block 115 | - ecoitems:enchanted_ender_eye ? netherite_ingot 116 | - diamond_block 117 | - air 118 | - golden_chestplate 119 | - air 120 | - gold_block 121 | - ecoitems:armor_core ? enchanted_book mending:1 122 | - gold_block 123 | elytra: 124 | item: elytra 125 | name: "&5Angelic Elytra" 126 | advancedName: "Advanced&5 Angelic Elytra" 127 | effectiveDurability: 1024 128 | effects: [] 129 | advancedEffects: [] 130 | conditions: [] 131 | lore: 132 | - "&5&lANGELIC SET BONUS" 133 | - "&8» &dGain 10 more hearts" 134 | - "&8» &dPermanent regeneration" 135 | - "&8» &dDeal 10% less melee damage" 136 | - "&8&oRequires full set to be worn" 137 | - '' 138 | - "&fTier: %tier%" 139 | - "&8&oUpgrade with an Upgrade Crystal" 140 | craftable: true 141 | defaultTier: default 142 | recipe: 143 | - netherite_block 144 | - ecoitems:enchanted_ender_eye ? netherite_ingot 145 | - diamond_block 146 | - air 147 | - elytra 148 | - air 149 | - gold_block 150 | - ecoitems:armor_core ? enchanted_book mending:1 151 | - gold_block 152 | leggings: 153 | item: leather_leggings color:#bd15a9 hide_dye 154 | name: "&5Angelic Leggings" 155 | advancedName: "Advanced&5 Angelic Leggings" 156 | effectiveDurability: 1024 157 | effects: [] 158 | advancedEffects: [] 159 | conditions: [] 160 | lore: 161 | - "&5&lANGELIC SET BONUS" 162 | - "&8» &dGain 10 more hearts" 163 | - "&8» &dPermanent regeneration" 164 | - "&8» &dDeal 10% less melee damage" 165 | - "&8&oRequires full set to be worn" 166 | - '' 167 | - "&fTier: %tier%" 168 | - "&8&oUpgrade with an Upgrade Crystal" 169 | craftable: true 170 | defaultTier: default 171 | recipe: 172 | - netherite_block 173 | - ecoitems:enchanted_ender_eye ? netherite_ingot 174 | - diamond_block 175 | - air 176 | - golden_leggings 177 | - air 178 | - gold_block 179 | - ecoitems:armor_core ? enchanted_book mending:1 180 | - gold_block 181 | boots: 182 | item: leather_boots color:#bd15a9 hide_dye 183 | name: "&5Angelic Boots" 184 | advancedName: "Advanced&5 Angelic Boots" 185 | effectiveDurability: 1024 186 | effects: [] 187 | advancedEffects: [] 188 | conditions: [] 189 | lore: 190 | - "&5&lANGELIC SET BONUS" 191 | - "&8» &dGain 10 more hearts" 192 | - "&8» &dPermanent regeneration" 193 | - "&8» &dDeal 10% less melee damage" 194 | - "&8&oRequires full set to be worn" 195 | - '' 196 | - "&fTier: %tier%" 197 | - "&8&oUpgrade with an Upgrade Crystal" 198 | craftable: true 199 | defaultTier: default 200 | recipe: 201 | - netherite_block 202 | - ecoitems:enchanted_ender_eye ? netherite_ingot 203 | - diamond_block 204 | - air 205 | - golden_boots 206 | - air 207 | - gold_block 208 | - ecoitems:armor_core ? enchanted_book mending:1 209 | - gold_block -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/sets/huntress.yml: -------------------------------------------------------------------------------- 1 | conditions: [] 2 | effects: 3 | - id: damage_multiplier 4 | args: 5 | multiplier: 0.85 6 | triggers: 7 | - melee_attack 8 | - id: damage_multiplier 9 | args: 10 | multiplier: 2.5 11 | triggers: 12 | - trident_attack 13 | - id: damage_multiplier 14 | args: 15 | multiplier: 1.5 16 | triggers: 17 | - bow_attack 18 | advancedEffects: 19 | - id: damage_multiplier 20 | args: 21 | multiplier: 3.5 22 | triggers: 23 | - trident_attack 24 | - id: damage_multiplier 25 | args: 26 | multiplier: 1.75 27 | triggers: 28 | - bow_attack 29 | sounds: 30 | equip: 31 | enabled: false 32 | sound: "" 33 | volume: 1 34 | pitch: 1 35 | advancedEquip: 36 | enabled: false 37 | sound: "" 38 | volume: 1 39 | pitch: 1 40 | unequip: 41 | enabled: false 42 | sound: "" 43 | volume: 1 44 | pitch: 1 45 | advancedLore: 46 | - '' 47 | - "&lADVANCED BONUS" 48 | - "&8» &bDeal 3.5x trident damage" 49 | - "&8» &bDeal 1.75x bow damage" 50 | - "&8» &bNo melee damage penalty" 51 | - "&8&oRequires full set to be worn" 52 | shard: 53 | item: prismarine_shard unbreaking:1 hide_enchants 54 | name: "Advancement Shard: &bHuntress" 55 | lore: 56 | - "&8Drop this onto &bHuntress Armor" 57 | - "&8to make it Advanced." 58 | craftable: false 59 | recipe: 60 | - prismarine_shard 61 | - ecoarmor:set_huntress_helmet 62 | - prismarine_shard 63 | - ecoarmor:set_huntress_chestplate 64 | - nether_star 65 | - ecoarmor:set_huntress_leggings 66 | - prismarine_shard 67 | - ecoarmor:set_huntress_boots 68 | - prismarine_shard 69 | helmet: 70 | item: leather_helmet color:#96fbfc hide_dye 71 | name: "&bHuntress Helmet" 72 | advancedName: "Advanced&b Huntress Helmet" 73 | effectiveDurability: 1024 74 | effects: [] 75 | advancedEffects: [] 76 | conditions: [] 77 | lore: 78 | - "&b&lHUNTRESS SET BONUS" 79 | - "&8» &bDeal 2.5x trident damage" 80 | - "&8» &bDeal 1.5x bow damage" 81 | - "&8» &bDeal 15% less melee damage damage" 82 | - "&8&oRequires full set to be worn" 83 | - '' 84 | - "&fTier: %tier%" 85 | - "&8&oUpgrade with an Upgrade Crystal" 86 | craftable: true 87 | defaultTier: default 88 | recipe: 89 | - ecoitems:armor_core ? crossbow 90 | - trident 91 | - ecoitems:armor_core ? crossbow 92 | - air 93 | - iron_helmet 94 | - air 95 | - spectral_arrow 96 | - enchanted_book power:5 97 | - spectral_arrow 98 | chestplate: 99 | item: leather_chestplate color:#97fbfc hide_dye 100 | name: "&bHuntress Chestplate" 101 | advancedName: "Advanced&b Huntress Chestplate" 102 | effectiveDurability: 2048 103 | effects: [] 104 | conditions: [] 105 | lore: 106 | - "&b&lHUNTRESS SET BONUS" 107 | - "&8» &bDeal 2.5x trident damage" 108 | - "&8» &bDeal 1.5x bow damage" 109 | - "&8» &bDeal 15% less melee damage damage" 110 | - "&8&oRequires full set to be worn" 111 | - '' 112 | - "&fTier: %tier%" 113 | - "&8&oUpgrade with an Upgrade Crystal" 114 | craftable: true 115 | defaultTier: default 116 | recipe: 117 | - ecoitems:armor_core ? crossbow 118 | - trident 119 | - ecoitems:armor_core ? crossbow 120 | - air 121 | - iron_chestplate 122 | - air 123 | - spectral_arrow 124 | - enchanted_book power:5 125 | - spectral_arrow 126 | elytra: 127 | item: elytra 128 | name: "&bHuntress Elytra" 129 | advancedName: "Advanced&b Huntress Elytra" 130 | effectiveDurability: 2048 131 | effects: [] 132 | advancedEffects: [] 133 | conditions: [] 134 | lore: 135 | - "&b&lHUNTRESS SET BONUS" 136 | - "&8» &bDeal 2.5x trident damage" 137 | - "&8» &bDeal 1.5x bow damage" 138 | - "&8» &bDeal 15% less melee damage damage" 139 | - "&8&oRequires full set to be worn" 140 | - '' 141 | - "&fTier: %tier%" 142 | - "&8&oUpgrade with an Upgrade Crystal" 143 | craftable: true 144 | defaultTier: default 145 | recipe: 146 | - ecoitems:armor_core ? crossbow 147 | - trident 148 | - ecoitems:armor_core ? crossbow 149 | - air 150 | - feather 151 | - air 152 | - spectral_arrow 153 | - enchanted_book power:5 154 | - spectral_arrow 155 | leggings: 156 | item: leather_leggings color:#97fbfc hide_dye 157 | name: "&bHuntress Leggings" 158 | advancedName: "Advanced&b Huntress Leggings" 159 | effectiveDurability: 2048 160 | effects: [] 161 | advancedEffects: [] 162 | conditions: [] 163 | lore: 164 | - "&b&lHUNTRESS SET BONUS" 165 | - "&8» &bDeal 2.5x trident damage" 166 | - "&8» &bDeal 1.5x bow damage" 167 | - "&8» &bDeal 15% less melee damage damage" 168 | - "&8&oRequires full set to be worn" 169 | - '' 170 | - "&fTier: %tier%" 171 | - "&8&oUpgrade with an Upgrade Crystal" 172 | craftable: true 173 | defaultTier: default 174 | recipe: 175 | - ecoitems:armor_core ? crossbow 176 | - trident 177 | - ecoitems:armor_core ? crossbow 178 | - air 179 | - iron_leggings 180 | - air 181 | - spectral_arrow 182 | - enchanted_book power:5 183 | - spectral_arrow 184 | boots: 185 | item: leather_boots color:#97fbfc hide_dye 186 | name: "&bHuntress Boots" 187 | advancedName: "Advanced&b Huntress Boots" 188 | effectiveDurability: 2048 189 | effects: [] 190 | advancedEffects: [] 191 | conditions: [] 192 | lore: 193 | - "&b&lHUNTRESS SET BONUS" 194 | - "&8» &bDeal 2.5x trident damage" 195 | - "&8» &bDeal 1.5x bow damage" 196 | - "&8» &bDeal 15% less melee damage damage" 197 | - "&8&oRequires full set to be worn" 198 | - '' 199 | - "&fTier: %tier%" 200 | - "&8&oUpgrade with an Upgrade Crystal" 201 | craftable: true 202 | defaultTier: default 203 | recipe: 204 | - ecoitems:armor_core ? crossbow 205 | - trident 206 | - ecoitems:armor_core ? crossbow 207 | - air 208 | - iron_boots 209 | - air 210 | - spectral_arrow 211 | - enchanted_book power:5 212 | - spectral_arrow -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/resources/sets/_example.yml: -------------------------------------------------------------------------------- 1 | # The ID of the armor set is the name of the .yml file, 2 | # for example huntress.yml has the ID of huntress 3 | # You can place sets anywhere in this folder, 4 | # including in subfolders if you want to organize your set configs 5 | # _example.yml is not loaded. 6 | 7 | # The effects of the set (i.e. the functionality) 8 | # See here: https://plugins.auxilor.io/effects/configuring-an-effect 9 | effects: 10 | - id: damage_multiplier 11 | args: 12 | multiplier: 1.25 13 | triggers: 14 | - melee_attack 15 | - bow_attack 16 | - trident_attack 17 | 18 | # The effects of the set (i.e. the functionality) 19 | # See here: https://plugins.auxilor.io/effects/configuring-an-effect 20 | advancedEffects: 21 | - id: damage_multiplier 22 | args: 23 | multiplier: 1.25 24 | triggers: 25 | - melee_attack 26 | - bow_attack 27 | - trident_attack 28 | - id: damage_multiplier 29 | args: 30 | multiplier: 0.9 31 | triggers: 32 | - take_damage 33 | 34 | sounds: 35 | equip: 36 | enabled: false # If a sound should play when armor is equipped. 37 | sound: "" # The sound to play, sounds: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html 38 | volume: 1 39 | pitch: 1 40 | advancedEquip: 41 | enabled: false # If a sound should play when advanced armor is equipped. 42 | sound: "" # The sound to play, sounds: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html 43 | volume: 1 44 | pitch: 1 45 | unequip: 46 | enabled: false # If a sound should play when armor is unequipped. 47 | sound: "" # The sound to play, sounds: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html 48 | volume: 1 49 | pitch: 1 50 | 51 | advancedLore: # Lore to be added to the armor piece when it has been advanced. 52 | - '' 53 | - "&lADVANCED BONUS" 54 | - "&8» &6Take 10% less damage" 55 | - "&8&oRequires full set to be worn" 56 | 57 | shard: 58 | item: prismarine_shard unbreaking:1 hide_enchants # The shard item, read more here: https://plugins.auxilor.io/all-plugins/the-item-lookup-system 59 | name: "Advancement Shard: &cReaper" # The in-game name of the shard. 60 | lore: # The lore shown in-game on the shard. Set to `lore: []` to remove lore. 61 | - "&8Drop this onto &cReaper Armor" 62 | - "&8to make it Advanced." 63 | craftable: false # If the shard is craftable 64 | crafting-permission: "permission" # (Optional) The permission required to craft this recipe. 65 | recipe: # The recipe, read here for more: https://plugins.auxilor.io/all-plugins/the-item-lookup-system#crafting-recipes 66 | - prismarine_shard 67 | - ecoarmor:set_reaper_helmet 68 | - prismarine_shard 69 | 70 | - ecoarmor:set_reaper_chestplate 71 | - nether_star 72 | - ecoarmor:set_reaper_leggings 73 | 74 | - prismarine_shard 75 | - ecoarmor:set_reaper_boots 76 | - prismarine_shard 77 | 78 | helmet: 79 | item: leather_helmet color:#303030 hide_dye # https://plugins.auxilor.io/all-plugins/the-item-lookup-system 80 | name: "&cReaper Helmet" # The name shown in-game. 81 | advancedName: "Advanced&c Reaper Helmet" # The advanced name shown in-game. 82 | lore: # The lore shown in-game. Set to `lore: []` to remove lore. 83 | - "&c&lREAPER SET BONUS" 84 | - "&8» &cDeal 25% more damage" 85 | - "&8&oRequires full set to be worn" 86 | - '' 87 | - "&fTier: %tier%" 88 | - "&8&oUpgrade with an Upgrade Crystal" 89 | craftable: true # If the armor piece is craftable 90 | crafting-permission: "permission" # (Optional) The permission required to craft this recipe. 91 | recipe: # The recipe, read here for more: https://plugins.auxilor.io/all-plugins/the-item-lookup-system#crafting-recipes 92 | - ecoitems:armor_core ? air 93 | - nether_star 94 | - ecoitems:armor_core ? air 95 | 96 | - nether_star 97 | - netherite_helmet 98 | - nether_star 99 | 100 | - air 101 | - nether_star 102 | - air 103 | defaultTier: default # The default tier of the armor 104 | 105 | # The actual item durability isn't set (because it can't be changed), but instead 106 | # this scales how quickly the item wears to act as if it had this durability. 107 | # For example, let's say the actual durability is 350, but you set this to 700, 108 | # it will wear at half the normal rate. 109 | 110 | effectiveDurability: 2048 # Optional, set the durability 111 | 112 | # The effects of the item (i.e. the functionality) 113 | # See here: https://plugins.auxilor.io/effects/configuring-an-effect 114 | effects: [] 115 | advancedEffects: [] 116 | 117 | # The conditions required for the effects to activate 118 | conditions: [] # The conditions for the effects to be ru 119 | 120 | chestplate: 121 | item: leather_chestplate color:#303030 hide_dye 122 | name: "&cReaper Chestplate" 123 | advancedName: "Advanced&c Reaper Chestplate" 124 | lore: 125 | - "&c&lREAPER SET BONUS" 126 | - "&8» &cDeal 25% more damage" 127 | - "&8&oRequires full set to be worn" 128 | - '' 129 | - "&fTier: %tier%" 130 | - "&8&oUpgrade with an Upgrade Crystal" 131 | craftable: true 132 | crafting-permission: "permission" 133 | recipe: 134 | - ecoitems:armor_core ? air 135 | - nether_star 136 | - ecoitems:armor_core ? air 137 | 138 | - nether_star 139 | - netherite_chestplate 140 | - nether_star 141 | 142 | - air 143 | - nether_star 144 | - air 145 | defaultTier: default 146 | effectiveDurability: 2048 147 | effects: [] 148 | advancedEffects: [] 149 | conditions: [] 150 | 151 | elytra: 152 | item: elytra 153 | name: "&cReaper Elytra" 154 | advancedName: "Advanced&c Reaper Elytra" 155 | lore: 156 | - "&c&lREAPER SET BONUS" 157 | - "&8» &cDeal 25% more damage" 158 | - "&8&oRequires full set to be worn" 159 | - '' 160 | - "&fTier: %tier%" 161 | - "&8&oUpgrade with an Upgrade Crystal" 162 | craftable: true 163 | crafting-permission: "permission" 164 | recipe: 165 | - ecoitems:armor_core ? air 166 | - nether_star 167 | - ecoitems:armor_core ? air 168 | 169 | - nether_star 170 | - elytra 171 | - nether_star 172 | 173 | - air 174 | - nether_star 175 | - air 176 | defaultTier: default 177 | effectiveDurability: 2048 178 | effects: [] 179 | advancedEffects: [] 180 | conditions: [] 181 | 182 | leggings: 183 | item: leather_leggings color:#303030 hide_dye 184 | name: "&cReaper Leggings" 185 | advancedName: "Advanced&c Reaper Leggings" 186 | lore: 187 | - "&c&lREAPER SET BONUS" 188 | - "&8» &cDeal 25% more damage" 189 | - "&8&oRequires full set to be worn" 190 | - '' 191 | - "&fTier: %tier%" 192 | - "&8&oUpgrade with an Upgrade Crystal" 193 | craftable: true 194 | crafting-permission: "permission" 195 | recipe: 196 | - ecoitems:armor_core ? air 197 | - nether_star 198 | - ecoitems:armor_core ? air 199 | 200 | - nether_star 201 | - netherite_leggings 202 | - nether_star 203 | 204 | - air 205 | - nether_star 206 | - air 207 | defaultTier: default 208 | effectiveDurability: 2048 209 | effects: [] 210 | advancedEffects: [] 211 | conditions: [] 212 | 213 | boots: 214 | item: leather_boots color:#303030 hide_dye 215 | name: "&cReaper Boots" 216 | advancedName: "Advanced&c Reaper Boots" 217 | lore: 218 | - "&c&lREAPER SET BONUS" 219 | - "&8» &cDeal 25% more damage" 220 | - "&8&oRequires full set to be worn" 221 | - '' 222 | - "&fTier: %tier%" 223 | - "&8&oUpgrade with an Upgrade Crystal" 224 | craftable: true 225 | crafting-permission: "permission" 226 | recipe: 227 | - ecoitems:armor_core ? air 228 | - nether_star 229 | - ecoitems:armor_core ? air 230 | 231 | - nether_star 232 | - netherite_boots 233 | - nether_star 234 | 235 | - air 236 | - nether_star 237 | - air 238 | defaultTier: default 239 | effectiveDurability: 2048 240 | effects: [] 241 | advancedEffects: [] 242 | conditions: [] 243 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/commands/CommandGive.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.commands 2 | 3 | import com.willfp.eco.core.EcoPlugin 4 | import com.willfp.eco.core.command.impl.Subcommand 5 | import com.willfp.ecoarmor.sets.ArmorSets 6 | import com.willfp.ecoarmor.sets.ArmorSlot 7 | import com.willfp.ecoarmor.sets.ArmorSlot.Companion.getSlot 8 | import com.willfp.ecoarmor.sets.ArmorUtils 9 | import com.willfp.ecoarmor.upgrades.Tier 10 | import com.willfp.ecoarmor.upgrades.Tiers 11 | import org.bukkit.Bukkit 12 | import org.bukkit.command.CommandSender 13 | import org.bukkit.inventory.ItemStack 14 | import org.bukkit.util.StringUtil 15 | 16 | class CommandGive(plugin: EcoPlugin) : Subcommand(plugin, "give", "ecoarmor.command.give", false) { 17 | private val items: Collection 18 | get() = ArmorSets.values().map { "set:${it.id}" } union ArmorSets.values() 19 | .map { "shard:${it.id}" } union Tiers.values().map { "crystal:${it.id}" } 20 | 21 | private val slots: Collection 22 | get() = ArmorSlot.values().map { it.name.lowercase() }.toMutableList().apply { add("full") } 23 | 24 | private val tiers: Collection 25 | get() = Tiers.values().map { it.id } 26 | 27 | private val numbers = listOf( 28 | "1", 29 | "2", 30 | "3", 31 | "4", 32 | "5", 33 | "10", 34 | "32", 35 | "64" 36 | ) 37 | 38 | override fun onExecute(sender: CommandSender, args: List) { 39 | if (args.isEmpty()) { 40 | sender.sendMessage(plugin.langYml.getMessage("needs-player")) 41 | return 42 | } 43 | 44 | if (args.size == 1) { 45 | sender.sendMessage(plugin.langYml.getMessage("needs-item")) 46 | return 47 | } 48 | 49 | val recieverName = args[0] 50 | val reciever = Bukkit.getPlayer(recieverName) 51 | 52 | if (reciever == null) { 53 | sender.sendMessage(plugin.langYml.getMessage("invalid-player")) 54 | return 55 | } 56 | 57 | val fullItemKey = args[1] 58 | 59 | if (!fullItemKey.contains(":")) { 60 | sender.sendMessage(plugin.langYml.getMessage("invalid-item")) 61 | return 62 | } 63 | 64 | val fullItemSplit = fullItemKey.split(":").toTypedArray() 65 | 66 | if (fullItemSplit.size == 1) { 67 | sender.sendMessage(plugin.langYml.getMessage("invalid-item")) 68 | return 69 | } 70 | 71 | val itemNamespace = fullItemSplit[0] 72 | val itemKey = fullItemSplit[1] 73 | val toGive = mutableListOf() 74 | var amount = 1 75 | 76 | if (itemNamespace.equals("set", ignoreCase = true)) { 77 | val set = ArmorSets.getByID(itemKey) 78 | 79 | if (set == null) { 80 | sender.sendMessage(plugin.langYml.getMessage("invalid-item")) 81 | return 82 | } 83 | 84 | var message = plugin.langYml.getMessage("give-success") 85 | 86 | message = message.replace("%item%", set.id + " Set").replace("%recipient%", reciever.name) 87 | 88 | sender.sendMessage(message) 89 | 90 | var advanced = false 91 | var tier: Tier? = null 92 | val slots = mutableListOf() 93 | if (args.size >= 3) { 94 | val slot = getSlot(args[2]) 95 | if (slot == null) { 96 | if (!args[2].equals("full", ignoreCase = true)) { 97 | sender.sendMessage(plugin.langYml.getMessage("invalid-item")) 98 | return 99 | } 100 | } 101 | if (slot == null) { 102 | slots.addAll(ArmorSlot.values()) 103 | } else { 104 | slots.add(slot) 105 | } 106 | } else { 107 | slots.addAll(ArmorSlot.values()) 108 | } 109 | if (args.size >= 4) { 110 | advanced = args[3].toBoolean() 111 | } 112 | if (args.size >= 5) { 113 | tier = Tiers.getByID(args[4]) 114 | } 115 | if (args.size >= 6) { 116 | amount = args[5].toIntOrNull() ?: amount 117 | } 118 | for (slot in slots) { 119 | toGive.add(if (advanced) set.getAdvancedItemStack(slot) else set.getItemStack(slot)) 120 | } 121 | for (item in ArrayList(toGive)) { 122 | val currTear = tier ?: set.getDefaultTier(getSlot(item)) 123 | toGive.remove(item) 124 | ArmorUtils.setTier(item, currTear) 125 | toGive.add(item) 126 | } 127 | } 128 | if (itemNamespace.equals("crystal", ignoreCase = true)) { 129 | val tier = Tiers.getByID(itemKey) 130 | if (tier == null) { 131 | sender.sendMessage(plugin.langYml.getMessage("invalid-item")) 132 | return 133 | } 134 | var message = plugin.langYml.getMessage("give-success") 135 | @Suppress("DEPRECATION") 136 | message = 137 | message.replace("%item%", tier.crystal.itemMeta!!.displayName).replace("%recipient%", reciever.name) 138 | sender.sendMessage(message) 139 | toGive.add(tier.crystal) 140 | if (args.size >= 3) { 141 | amount = args[2].toIntOrNull() ?: amount 142 | } 143 | } 144 | if (itemNamespace.equals("shard", ignoreCase = true)) { 145 | val set = ArmorSets.getByID(itemKey) 146 | if (set == null) { 147 | sender.sendMessage(plugin.langYml.getMessage("invalid-item")) 148 | return 149 | } 150 | var message = plugin.langYml.getMessage("give-success") 151 | @Suppress("DEPRECATION") 152 | message = message.replace("%item%", set.advancementShardItem.itemMeta!!.displayName) 153 | .replace("%recipient%", reciever.name) 154 | sender.sendMessage(message) 155 | toGive.add(set.advancementShardItem) 156 | if (args.size >= 3) { 157 | amount = args[2].toIntOrNull() ?: amount 158 | } 159 | } 160 | if (toGive.isEmpty()) { 161 | sender.sendMessage(plugin.langYml.getMessage("invalid-item")) 162 | return 163 | } 164 | for (item in toGive) { 165 | item.amount = amount 166 | reciever.inventory.addItem(item) 167 | } 168 | } 169 | 170 | override fun tabComplete(sender: CommandSender, args: List): List { 171 | val completions = mutableListOf() 172 | if (args.isEmpty()) { 173 | // Currently, this case is not ever reached 174 | return items.toList() 175 | } 176 | if (args.size == 1) { 177 | StringUtil.copyPartialMatches( 178 | args[0], 179 | Bukkit.getOnlinePlayers().map { it.name }, 180 | completions 181 | ) 182 | return completions 183 | } 184 | if (args.size == 2) { 185 | StringUtil.copyPartialMatches(args[1], items, completions) 186 | completions.sort() 187 | return completions 188 | } 189 | if (args[1].startsWith("set:")) { 190 | if (args.size == 3) { 191 | StringUtil.copyPartialMatches(args[2], slots, completions) 192 | completions.sort() 193 | return completions 194 | } 195 | if (args.size == 4) { 196 | StringUtil.copyPartialMatches(args[3], listOf("true", "false"), completions) 197 | completions.sort() 198 | return completions 199 | } 200 | if (args.size == 5) { 201 | StringUtil.copyPartialMatches(args[4], tiers, completions) 202 | completions.sort() 203 | return completions 204 | } 205 | if (args.size == 6) { 206 | StringUtil.copyPartialMatches(args[5], numbers, completions) 207 | return completions 208 | } 209 | } else { 210 | if (args.size == 3) { 211 | StringUtil.copyPartialMatches(args[2], numbers, completions) 212 | return completions 213 | } 214 | } 215 | return emptyList() 216 | } 217 | } -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorSet.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.sets 2 | 3 | import com.willfp.eco.core.EcoPlugin 4 | import com.willfp.eco.core.config.interfaces.Config 5 | import com.willfp.eco.core.display.Display 6 | import com.willfp.eco.core.items.CustomItem 7 | import com.willfp.eco.core.items.Items 8 | import com.willfp.eco.core.items.builder.ItemBuilder 9 | import com.willfp.eco.core.items.builder.ItemStackBuilder 10 | import com.willfp.eco.core.recipe.Recipes 11 | import com.willfp.eco.core.registry.Registrable 12 | import com.willfp.ecoarmor.sets.ArmorSlot.Companion.getSlot 13 | import com.willfp.ecoarmor.sets.ArmorUtils.getSetOnItem 14 | import com.willfp.ecoarmor.sets.ArmorUtils.getShardSet 15 | import com.willfp.ecoarmor.sets.ArmorUtils.isAdvanced 16 | import com.willfp.ecoarmor.sets.ArmorUtils.setAdvanced 17 | import com.willfp.ecoarmor.sets.ArmorUtils.setTier 18 | import com.willfp.ecoarmor.upgrades.Tier 19 | import com.willfp.ecoarmor.upgrades.Tiers 20 | import com.willfp.ecoarmor.util.PlayableSound 21 | import com.willfp.libreforge.Holder 22 | import com.willfp.libreforge.ItemProvidedHolder 23 | import com.willfp.libreforge.ProvidedHolder 24 | import com.willfp.libreforge.SimpleHolder 25 | import com.willfp.libreforge.ViolationContext 26 | import com.willfp.libreforge.conditions.Conditions 27 | import com.willfp.libreforge.effects.Effects 28 | import com.willfp.libreforge.notNullMapOf 29 | import com.willfp.libreforge.notNullMutableMapOf 30 | import org.bukkit.Bukkit 31 | import org.bukkit.Sound 32 | import org.bukkit.inventory.ItemStack 33 | import org.bukkit.persistence.PersistentDataType 34 | import java.util.Locale 35 | import java.util.Objects 36 | import java.util.stream.Collectors 37 | 38 | class ArmorSet( 39 | val id: String, 40 | val config: Config, 41 | private val plugin: EcoPlugin 42 | ) : Registrable { 43 | /** The advanced holder. */ 44 | val advancedHolder: Holder 45 | 46 | /** The regular holder. */ 47 | val regularHolder: Holder 48 | 49 | /** Items in set. */ 50 | private val items = notNullMutableMapOf() 51 | 52 | /** Holders in set. */ 53 | private val slotHolders = notNullMutableMapOf() 54 | 55 | /** Items in advanced set. */ 56 | private val advancedItems = notNullMutableMapOf() 57 | 58 | /** Holders in advanced set. */ 59 | private val advancedSlotHolders = notNullMutableMapOf() 60 | 61 | /** Advancement shard item. */ 62 | val advancementShardItem: ItemStack 63 | 64 | /* 65 | * Equip Sound 66 | */ 67 | val equipSound = if (config.getBool("sounds.equip.enabled")) { 68 | PlayableSound( 69 | Sound.valueOf(config.getString("sounds.equip.sound").uppercase()), 70 | config.getDouble("sounds.equip.volume"), 71 | config.getDouble("sounds.equip.pitch") 72 | ) 73 | } else null 74 | 75 | /* 76 | * Advanced equip Sound 77 | */ 78 | val advancedEquipSound = if (config.getBool("sounds.advancedEquip.enabled")) { 79 | PlayableSound( 80 | Sound.valueOf(config.getString("sounds.advancedEquip.sound").uppercase()), 81 | config.getDouble("sounds.advancedEquip.volume"), 82 | config.getDouble("sounds.advancedEquip.pitch") 83 | ) 84 | } else null 85 | 86 | /* 87 | * Unequip Sound 88 | */ 89 | val unequipSound = if (config.getBool("sounds.unequip.enabled")) { 90 | PlayableSound( 91 | Sound.valueOf(config.getString("sounds.unequip.sound").uppercase()), 92 | config.getDouble("sounds.unequip.volume"), 93 | config.getDouble("sounds.unequip.pitch") 94 | ) 95 | } else null 96 | 97 | /** Create a new Armor Set. */ 98 | init { 99 | val conditions = Conditions.compile( 100 | config.getSubsections("conditions"), 101 | ViolationContext(plugin, "Armor Set $id") 102 | ) 103 | 104 | val effects = Effects.compile( 105 | config.getSubsections("effects"), 106 | ViolationContext(plugin, "Armor Set $id") 107 | ) 108 | 109 | val advancedEffects = Effects.compile( 110 | config.getSubsections("advancedEffects"), 111 | ViolationContext(plugin, "Armor Set $id (advanced)") 112 | ) 113 | 114 | regularHolder = SimpleHolder(plugin.namespacedKeyFactory.create(id), effects, conditions) 115 | advancedHolder = SimpleHolder(plugin.namespacedKeyFactory.create("${id}_advanced"), advancedEffects, conditions) 116 | 117 | for (slot in ArmorSlot.values()) { 118 | val slotConfig = config.getSubsection(slot.name.lowercase(Locale.ENGLISH)) 119 | val item = construct(slot, slotConfig, false) 120 | items[slot] = item 121 | constructRecipe(slot, slotConfig, item) 122 | val advancedItem = construct(slot, slotConfig, true) 123 | advancedItems[slot] = advancedItem 124 | 125 | slotHolders[slot] = SimpleHolder( 126 | plugin.createNamespacedKey("${id}_${slot.name.lowercase()}"), 127 | Effects.compile( 128 | slotConfig.getSubsections("effects"), 129 | ViolationContext(plugin, "Armor Set $id)") 130 | .with(slot.name.lowercase()) 131 | ), 132 | Conditions.compile( 133 | slotConfig.getSubsections("conditions"), 134 | ViolationContext(plugin, "Armor Set $id)") 135 | .with(slot.name.lowercase()) 136 | ) 137 | ) 138 | 139 | advancedSlotHolders[slot] = SimpleHolder( 140 | plugin.createNamespacedKey("${id}_${slot.name.lowercase()}_advanced"), 141 | Effects.compile( 142 | slotConfig.getSubsections("advancedEffects"), 143 | ViolationContext(plugin, "Armor Set $id (advanced)") 144 | .with(slot.name.lowercase()) 145 | ), 146 | Conditions.compile( 147 | slotConfig.getSubsections("conditions"), 148 | ViolationContext(plugin, "Armor Set $id (advanced)") 149 | .with(slot.name.lowercase()) 150 | ) 151 | ) 152 | } 153 | 154 | advancementShardItem = constructShard() 155 | } 156 | 157 | private fun constructShard(): ItemStack { 158 | val shardLore = config.getStrings("shard.lore") 159 | shardLore.replaceAll { Display.PREFIX + it } 160 | val shard = ItemStackBuilder( 161 | Items.lookup(config.getString("shard.item")) 162 | ) 163 | .setDisplayName(config.getFormattedString("shard.name")) 164 | .addLoreLines(shardLore) 165 | .writeMetaKey(plugin.namespacedKeyFactory.create("advancement-shard"), PersistentDataType.STRING, id) 166 | .build() 167 | if (config.getBool("shard.craftable")) { 168 | Recipes.createAndRegisterRecipe( 169 | plugin, 170 | id + "_shard", 171 | shard, 172 | config.getStrings("shard.recipe"), 173 | config.getStringOrNull("shard.crafting-permission") 174 | ) 175 | } 176 | CustomItem( 177 | plugin.namespacedKeyFactory.create("shard_" + id.lowercase(Locale.getDefault())), 178 | { test: ItemStack? -> this == getShardSet(test!!) }, 179 | shard 180 | ).register() 181 | return shard 182 | } 183 | 184 | private fun construct( 185 | slot: ArmorSlot, 186 | slotConfig: Config, 187 | advanced: Boolean 188 | ): ItemStack { 189 | val builder: ItemBuilder = ItemStackBuilder(Items.lookup(slotConfig.getString("item")).item).apply { 190 | setDisplayName( 191 | if (advanced) slotConfig.getFormattedString("advancedName") else slotConfig.getFormattedString( 192 | "name" 193 | ) 194 | ) 195 | val defaultLore = slotConfig.getFormattedStrings("lore").stream().map { s: String -> Display.PREFIX + s } 196 | .collect(Collectors.toList()) 197 | val advancedLore = config.getFormattedStrings("advancedLore").stream() 198 | .map { s: String -> Display.PREFIX + s } 199 | .collect(Collectors.toList()) 200 | 201 | if (advanced) { 202 | if (!plugin.configYml.getBool("advanced-lore-only")) { 203 | addLoreLines(defaultLore) 204 | } 205 | addLoreLines(advancedLore) 206 | } else { 207 | addLoreLines(defaultLore) 208 | } 209 | 210 | setDisplayName { 211 | if (advanced) slotConfig.getFormattedString("advancedName") else slotConfig.getFormattedString( 212 | "name" 213 | ) 214 | } 215 | } 216 | builder.writeMetaKey( 217 | plugin.namespacedKeyFactory.create("set"), 218 | PersistentDataType.STRING, 219 | id 220 | ).writeMetaKey( 221 | plugin.namespacedKeyFactory.create("effective-durability"), 222 | PersistentDataType.INTEGER, 223 | slotConfig.getInt("effectiveDurability") 224 | ) 225 | val itemStack = builder.build() 226 | setAdvanced(itemStack, advanced) 227 | val defaultTier = Tiers.getByID(slotConfig.getString("defaultTier")) 228 | if (defaultTier == null) { 229 | Bukkit.getLogger() 230 | .warning("Default tier specified in " + id + " " + slot.name.lowercase(Locale.getDefault()) + " is invalid! Defaulting to 'default'") 231 | setTier(itemStack, Tiers.defaultTier) 232 | } else { 233 | setTier(itemStack, defaultTier) 234 | } 235 | if (advanced) { 236 | CustomItem( 237 | plugin.namespacedKeyFactory.create( 238 | "set_" + id.lowercase(Locale.getDefault()) + "_" + slot.name.lowercase( 239 | Locale.getDefault() 240 | ) + "_advanced" 241 | ), { test -> 242 | if (getSlot(test) !== getSlot(itemStack)) { 243 | return@CustomItem false 244 | } 245 | if (!isAdvanced(test)) { 246 | return@CustomItem false 247 | } 248 | if (getSetOnItem(test) == null) { 249 | return@CustomItem false 250 | } 251 | this == getSetOnItem(test) 252 | }, itemStack 253 | ).register() 254 | } else { 255 | CustomItem( 256 | plugin.namespacedKeyFactory.create( 257 | "set_" + id.lowercase(Locale.getDefault()) + "_" + slot.name.lowercase( 258 | Locale.getDefault() 259 | ) 260 | ), 261 | { test -> 262 | if (getSlot(test) !== getSlot(itemStack)) { 263 | return@CustomItem false 264 | } 265 | if (isAdvanced(test)) { 266 | return@CustomItem false 267 | } 268 | if (getSetOnItem(test) == null) { 269 | return@CustomItem false 270 | } 271 | this == getSetOnItem(test) 272 | }, itemStack 273 | ).register() 274 | } 275 | return itemStack 276 | } 277 | 278 | @Suppress("DEPRECATION") 279 | private fun constructRecipe( 280 | slot: ArmorSlot, 281 | slotConfig: Config, 282 | out: ItemStack 283 | ) { 284 | if (slotConfig.getBool("craftable")) { 285 | val formattedOut = out.clone() 286 | val meta = formattedOut.itemMeta ?: return 287 | val metaLore = meta.lore ?: emptyList() 288 | val lore = metaLore.map { it.replace("%tier%", Tiers.defaultTier.displayName) } 289 | meta.lore = lore 290 | formattedOut.itemMeta = meta 291 | plugin.scheduler.run { 292 | Recipes.createAndRegisterRecipe( 293 | plugin, 294 | id + "_" + slot.name.lowercase(Locale.getDefault()), 295 | formattedOut, 296 | slotConfig.getStrings("recipe"), 297 | slotConfig.getStringOrNull("crafting-permission") 298 | ) 299 | } 300 | } 301 | } 302 | 303 | /** 304 | * Get item stack from slot. 305 | * 306 | * @param slot The slot. 307 | * @return The item. 308 | */ 309 | fun getItemStack(slot: ArmorSlot): ItemStack { 310 | return items[slot] 311 | } 312 | 313 | /** 314 | * Get item stack from slot. 315 | * 316 | * @param slot The slot. 317 | * @return The item. 318 | */ 319 | fun getAdvancedItemStack(slot: ArmorSlot): ItemStack { 320 | return advancedItems[slot] 321 | } 322 | 323 | /** 324 | * Get default tier for slot. 325 | * 326 | * @param slot The slot. 327 | * @return The tier. 328 | */ 329 | fun getDefaultTier(slot: ArmorSlot?): Tier { 330 | slot ?: return Tiers.defaultTier 331 | val tier = Tiers.getByID(config.getSubsection(slot.name.lowercase()).getString("defaultTier")) 332 | return tier ?: Tiers.defaultTier 333 | } 334 | 335 | fun getSpecificHolder(itemStack: ItemStack): ItemProvidedHolder? { 336 | val slot = getSlot(itemStack) ?: return null 337 | val advanced = isAdvanced(itemStack) 338 | 339 | return if (advanced) { 340 | ItemProvidedHolder(advancedSlotHolders[slot], itemStack) 341 | } else { 342 | ItemProvidedHolder(slotHolders[slot], itemStack) 343 | } 344 | } 345 | 346 | override fun getID(): String { 347 | return this.id 348 | } 349 | 350 | override fun equals(other: Any?): Boolean { 351 | if (other !is ArmorSet) { 352 | return false 353 | } 354 | 355 | return id == other.id 356 | } 357 | 358 | override fun hashCode(): Int { 359 | return Objects.hash(id) 360 | } 361 | 362 | override fun toString(): String { 363 | return ("ArmorSet{" 364 | + id 365 | + "}") 366 | } 367 | } 368 | -------------------------------------------------------------------------------- /eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorUtils.kt: -------------------------------------------------------------------------------- 1 | package com.willfp.ecoarmor.sets 2 | 3 | import com.willfp.ecoarmor.EcoArmorPlugin.Companion.instance 4 | import com.willfp.ecoarmor.sets.ArmorSlot.Companion.getSlot 5 | import com.willfp.ecoarmor.upgrades.Tier 6 | import com.willfp.ecoarmor.upgrades.Tiers 7 | import com.willfp.libreforge.Holder 8 | import com.willfp.libreforge.ItemProvidedHolder 9 | import com.willfp.libreforge.ProvidedHolder 10 | import com.willfp.libreforge.SimpleProvidedHolder 11 | import org.bukkit.attribute.Attribute 12 | import org.bukkit.attribute.AttributeModifier 13 | import org.bukkit.entity.Player 14 | import org.bukkit.inventory.ItemStack 15 | import org.bukkit.inventory.meta.ItemMeta 16 | import org.bukkit.persistence.PersistentDataType 17 | import java.util.* 18 | 19 | object ArmorUtils { 20 | /** 21 | * Instance of EcoArmor. 22 | */ 23 | private val PLUGIN = instance 24 | 25 | /** 26 | * Get armor set on an item. 27 | * 28 | * @param itemStack The itemStack to check. 29 | * @return The set, or null if no set is found. 30 | */ 31 | @JvmStatic 32 | fun getSetOnItem(itemStack: ItemStack): ArmorSet? { 33 | val meta = itemStack.itemMeta ?: return null 34 | return getSetOnItem(meta) 35 | } 36 | 37 | /** 38 | * Get armor set on an item. 39 | * 40 | * @param meta The itemStack to check. 41 | * @return The set, or null if no set is found. 42 | */ 43 | @JvmStatic 44 | fun getSetOnItem(meta: ItemMeta): ArmorSet? { 45 | val container = meta.persistentDataContainer 46 | val setName = container.get( 47 | PLUGIN.namespacedKeyFactory.create("set"), 48 | PersistentDataType.STRING 49 | ) 50 | ?: return null 51 | return ArmorSets.getByID(setName) 52 | } 53 | 54 | /** 55 | * Get active holder for a player. 56 | * 57 | * @param player The player to check. 58 | * @return The holder, or null if not found. 59 | */ 60 | @JvmStatic 61 | fun getActiveSet(player: Player): Holder? { 62 | val armorSet = getSetOnPlayer(player) 63 | val advanced = isWearingAdvanced(player) 64 | return if (armorSet != null) { 65 | if (advanced) armorSet.advancedHolder else armorSet.regularHolder 66 | } else { 67 | null 68 | } 69 | } 70 | 71 | /** 72 | * Get all active armor holders for a player. 73 | * 74 | * @param player The player. 75 | * @return The holders. 76 | */ 77 | fun getActiveHolders(player: Player): Collection { 78 | val holders = mutableListOf() 79 | 80 | val set = getActiveSet(player) 81 | 82 | if (set != null) { 83 | holders.add(SimpleProvidedHolder(set)) 84 | } 85 | 86 | holders.addAll(getSlotHolders(player)) 87 | 88 | return holders 89 | } 90 | 91 | /** 92 | * Get active holder for a player. 93 | * 94 | * @param player The player to check. 95 | * @return The holder, or null if not found. 96 | */ 97 | private fun getSlotHolders(player: Player): Collection { 98 | val holders = mutableListOf() 99 | 100 | for (itemStack in player.inventory.armorContents) { 101 | if (itemStack == null) { 102 | continue 103 | } 104 | 105 | val set = getSetOnItem(itemStack) ?: continue 106 | val holder = set.getSpecificHolder(itemStack) ?: continue 107 | 108 | holders.add(holder) 109 | } 110 | 111 | return holders 112 | } 113 | 114 | /** 115 | * Get armor set that player is wearing. 116 | * 117 | * @param player The player to check. 118 | * @return The set, or null if no full set is worn. 119 | */ 120 | @JvmStatic 121 | fun getSetOnPlayer(player: Player): ArmorSet? { 122 | return getSetOn(player.inventory.armorContents.toList()) 123 | } 124 | 125 | /** 126 | * Get armor set that player is wearing. 127 | * 128 | * @param items The items to check. 129 | * @return The set, or null if no full set is worn. 130 | */ 131 | @JvmStatic 132 | fun getSetOn(items: List): ArmorSet? { 133 | val found: MutableList = ArrayList() 134 | for (itemStack in items) { 135 | if (itemStack == null) { 136 | continue 137 | } 138 | val set = getSetOnItem(itemStack) ?: continue 139 | found.add(set) 140 | } 141 | if (found.size < 4) { 142 | return null 143 | } 144 | var allEqual = true 145 | for (set in found) { 146 | if (set != found[0]) { 147 | allEqual = false 148 | break 149 | } 150 | } 151 | return if (allEqual) { 152 | found[0] 153 | } else null 154 | } 155 | 156 | /** 157 | * Get tier on upgrade crystal. 158 | * 159 | * @param itemStack The item to check. 160 | * @return The found tier, or null. 161 | */ 162 | @JvmStatic 163 | fun getCrystalTier(itemStack: ItemStack): Tier? { 164 | val meta = itemStack.itemMeta ?: return null 165 | return getCrystalTier(meta) 166 | } 167 | 168 | /** 169 | * Get tier on upgrade crystal. 170 | * 171 | * @param meta The item to check. 172 | * @return The found tier, or null. 173 | */ 174 | @JvmStatic 175 | fun getCrystalTier(meta: ItemMeta): Tier? { 176 | return if (meta.persistentDataContainer.has( 177 | PLUGIN.namespacedKeyFactory.create( 178 | "upgrade_crystal" 179 | ), PersistentDataType.STRING 180 | ) 181 | ) { 182 | Tiers.getByID( 183 | meta.persistentDataContainer.get( 184 | PLUGIN.namespacedKeyFactory.create( 185 | "upgrade_crystal" 186 | ), PersistentDataType.STRING 187 | ) 188 | ) 189 | } else null 190 | } 191 | 192 | /** 193 | * Get tier on item. 194 | * 195 | * @param itemStack The item to check. 196 | * @return The found tier, or null if not found. 197 | */ 198 | @JvmStatic 199 | fun getTier(itemStack: ItemStack): Tier? { 200 | val meta = itemStack.itemMeta ?: return null 201 | val tier = getTier(meta) 202 | return if (getSetOnItem(meta) != null && tier == null) { 203 | setTier(itemStack, Tiers.defaultTier) 204 | Tiers.defaultTier 205 | } else { 206 | tier 207 | } 208 | } 209 | 210 | /** 211 | * Get tier on item. 212 | * 213 | * @param meta The item to check. 214 | * @return The found tier, or null if not found. 215 | */ 216 | @JvmStatic 217 | fun getTier(meta: ItemMeta): Tier? { 218 | if (getSetOnItem(meta) == null) { 219 | return null 220 | } 221 | return if (meta.persistentDataContainer.has( 222 | PLUGIN.namespacedKeyFactory.create( 223 | "tier" 224 | ), PersistentDataType.STRING 225 | ) 226 | ) { 227 | Tiers.getByID( 228 | meta.persistentDataContainer.get( 229 | PLUGIN.namespacedKeyFactory.create( 230 | "tier" 231 | ), PersistentDataType.STRING 232 | ) 233 | ) 234 | } else null 235 | } 236 | 237 | /** 238 | * Set tier on item. 239 | * 240 | * @param itemStack The item to check. 241 | * @param tier The tier to set. 242 | */ 243 | @JvmStatic 244 | fun setTier( 245 | itemStack: ItemStack, 246 | tier: Tier 247 | ) { 248 | val meta = itemStack.itemMeta ?: return 249 | setTierKey(meta, tier) 250 | val slot = getSlot(itemStack) ?: return 251 | val armor = tier.properties[slot].armor 252 | val toughness = tier.properties[slot].toughness 253 | val knockback = tier.properties[slot].knockback 254 | val speed = tier.properties[slot].speed 255 | val attackSpeed = tier.properties[slot].attackSpeed 256 | val attackDamage = tier.properties[slot].attackDamage 257 | val attackKnockback = tier.properties[slot].attackKnockback 258 | meta.removeAttributeModifier(Attribute.GENERIC_ARMOR) 259 | meta.removeAttributeModifier(Attribute.GENERIC_ARMOR_TOUGHNESS) 260 | meta.removeAttributeModifier(Attribute.GENERIC_KNOCKBACK_RESISTANCE) 261 | meta.removeAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED) 262 | meta.removeAttributeModifier(Attribute.GENERIC_ATTACK_SPEED) 263 | meta.removeAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE) 264 | meta.removeAttributeModifier(Attribute.GENERIC_ATTACK_KNOCKBACK) 265 | if (armor > 0) { 266 | meta.addAttributeModifier( 267 | Attribute.GENERIC_ARMOR, 268 | AttributeModifier( 269 | UUID.randomUUID(), 270 | "ecoarmor-armor", 271 | armor.toDouble(), 272 | AttributeModifier.Operation.ADD_NUMBER, 273 | slot.slot 274 | ) 275 | ) 276 | } 277 | if (toughness > 0) { 278 | meta.addAttributeModifier( 279 | Attribute.GENERIC_ARMOR_TOUGHNESS, 280 | AttributeModifier( 281 | UUID.randomUUID(), 282 | "ecoarmor-toughness", 283 | toughness.toDouble(), 284 | AttributeModifier.Operation.ADD_NUMBER, 285 | slot.slot 286 | ) 287 | ) 288 | } 289 | if (knockback > 0) { 290 | meta.addAttributeModifier( 291 | Attribute.GENERIC_KNOCKBACK_RESISTANCE, 292 | AttributeModifier( 293 | UUID.randomUUID(), 294 | "ecoarmor-knockback", 295 | knockback.toDouble() / 10, 296 | AttributeModifier.Operation.ADD_NUMBER, 297 | slot.slot 298 | ) 299 | ) 300 | } 301 | if (speed != 0) { 302 | meta.addAttributeModifier( 303 | Attribute.GENERIC_MOVEMENT_SPEED, 304 | AttributeModifier( 305 | UUID.randomUUID(), 306 | "ecoarmor-speed", 307 | speed.toDouble() / 100, 308 | AttributeModifier.Operation.ADD_SCALAR, 309 | slot.slot 310 | ) 311 | ) 312 | } 313 | if (attackSpeed != 0) { 314 | meta.addAttributeModifier( 315 | Attribute.GENERIC_ATTACK_SPEED, 316 | AttributeModifier( 317 | UUID.randomUUID(), 318 | "ecoarmor-attackspeed", 319 | attackSpeed.toDouble() / 100, 320 | AttributeModifier.Operation.ADD_SCALAR, 321 | slot.slot 322 | ) 323 | ) 324 | } 325 | if (attackDamage != 0) { 326 | meta.addAttributeModifier( 327 | Attribute.GENERIC_ATTACK_DAMAGE, 328 | AttributeModifier( 329 | UUID.randomUUID(), 330 | "ecoarmor-attackdamage", 331 | attackDamage.toDouble() / 100, 332 | AttributeModifier.Operation.ADD_SCALAR, 333 | slot.slot 334 | ) 335 | ) 336 | } 337 | if (attackKnockback != 0) { 338 | meta.addAttributeModifier( 339 | Attribute.GENERIC_ATTACK_KNOCKBACK, 340 | AttributeModifier( 341 | UUID.randomUUID(), 342 | "ecoarmor-attackknockback", 343 | attackKnockback.toDouble() / 100, 344 | AttributeModifier.Operation.ADD_SCALAR, 345 | slot.slot 346 | ) 347 | ) 348 | } 349 | 350 | itemStack.itemMeta = meta 351 | } 352 | 353 | /** 354 | * Set tier on item. 355 | * 356 | * @param meta The item to check. 357 | * @param tier The tier to set. 358 | */ 359 | @JvmStatic 360 | fun setTierKey( 361 | meta: ItemMeta, 362 | tier: Tier 363 | ) { 364 | if (!meta.persistentDataContainer.has( 365 | PLUGIN.namespacedKeyFactory.create("set"), 366 | PersistentDataType.STRING 367 | ) 368 | ) { 369 | return 370 | } 371 | meta.persistentDataContainer.set( 372 | PLUGIN.namespacedKeyFactory.create("tier"), 373 | PersistentDataType.STRING, 374 | tier.id 375 | ) 376 | } 377 | 378 | /** 379 | * Get if player is wearing advanced set. 380 | * 381 | * @param player The player to check. 382 | * @return If advanced. 383 | */ 384 | @JvmStatic 385 | fun isWearingAdvanced(player: Player): Boolean { 386 | return isWearingAdvanced(player.inventory.armorContents.toList()) 387 | } 388 | 389 | /** 390 | * Get if player is wearing advanced set. 391 | * 392 | * @param items The items to check. 393 | * @return If advanced. 394 | */ 395 | @JvmStatic 396 | fun isWearingAdvanced(items: List): Boolean { 397 | if (getSetOn(items) == null) { 398 | return false 399 | } 400 | for (itemStack in items) { 401 | if (itemStack == null) { 402 | return false 403 | } 404 | if (!isAdvanced(itemStack)) { 405 | return false 406 | } 407 | } 408 | return true 409 | } 410 | 411 | /** 412 | * Get if item is advanced. 413 | * 414 | * @param itemStack The item to check. 415 | * @return If advanced. 416 | */ 417 | @JvmStatic 418 | fun isAdvanced(itemStack: ItemStack): Boolean { 419 | val meta = itemStack.itemMeta ?: return false 420 | return isAdvanced(meta) 421 | } 422 | 423 | /** 424 | * Get if item is advanced. 425 | * 426 | * @param meta The item to check. 427 | * @return If advanced. 428 | */ 429 | @JvmStatic 430 | fun isAdvanced(meta: ItemMeta): Boolean { 431 | return if (meta.persistentDataContainer.has( 432 | PLUGIN.namespacedKeyFactory.create("advanced"), 433 | PersistentDataType.INTEGER 434 | ) 435 | ) { 436 | meta.persistentDataContainer.get( 437 | PLUGIN.namespacedKeyFactory.create("advanced"), 438 | PersistentDataType.INTEGER 439 | ) == 1 440 | } else false 441 | } 442 | 443 | /** 444 | * Set if item is advanced. 445 | * 446 | * @param itemStack The item to set. 447 | * @param advanced If the item should be advanced. 448 | */ 449 | @JvmStatic 450 | fun setAdvanced( 451 | itemStack: ItemStack, 452 | advanced: Boolean 453 | ) { 454 | val meta = itemStack.itemMeta ?: return 455 | meta.persistentDataContainer.set( 456 | PLUGIN.namespacedKeyFactory.create("advanced"), 457 | PersistentDataType.INTEGER, 458 | if (advanced) 1 else 0 459 | ) 460 | itemStack.itemMeta = meta 461 | } 462 | 463 | /** 464 | * Get the set from a shard. 465 | * 466 | * @param itemStack The item to check. 467 | * @return The set, or null if not a shard. 468 | */ 469 | @JvmStatic 470 | fun getShardSet(itemStack: ItemStack): ArmorSet? { 471 | val meta = itemStack.itemMeta ?: return null 472 | return getShardSet(meta) 473 | } 474 | 475 | /** 476 | * Get the set from a shard. 477 | * 478 | * @param meta The item to check. 479 | * @return The set, or null if not a shard. 480 | */ 481 | @JvmStatic 482 | fun getShardSet(meta: ItemMeta): ArmorSet? { 483 | val shardSet = meta.persistentDataContainer.get( 484 | PLUGIN.namespacedKeyFactory.create( 485 | "advancement-shard" 486 | ), PersistentDataType.STRING 487 | ) 488 | ?: return null 489 | return ArmorSets.getByID(shardSet) 490 | } 491 | } 492 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------