Skip to content

Commit

Permalink
Fix #17
Browse files Browse the repository at this point in the history
  • Loading branch information
CJCrafter committed Mar 15, 2024
1 parent 8f5c694 commit 52b0208
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

group = "com.cjcrafter"
version = "3.0.3"
version = "3.0.4"

plugins {
`java-library`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.cjcrafter.armormechanics.lib

import com.cjcrafter.armormechanics.ArmorMechanics
import io.lumine.mythic.api.adapters.AbstractItemStack
import io.lumine.mythic.api.config.MythicLineConfig
import io.lumine.mythic.api.drops.DropMetadata
Expand All @@ -15,16 +16,19 @@ class MythicMobsArmorDrop(config: MythicLineConfig, argument: String?) : IItemDr

// Since we want to ignore spelling/capitalization errors, we should
// make sure the given 'title' matches to an actual armor-title.
val startsWith: MutableList<String> = ArrayList()
val options: Set<String> = com.cjcrafter.armormechanics.ArmorMechanics.INSTANCE.armors.keys
val startsWith: MutableSet<String> = HashSet()
var options: Set<String> = ArmorMechanics.INSTANCE.armors.keys
for (temp in options) {
if (temp.lowercase().startsWith(title.lowercase())) startsWith.add(title)
}
armorTitle = StringUtil.didYouMean(title, if (startsWith.isEmpty()) options else startsWith)

// Added redundancy to make sure we don't have any empty options.
options = if (startsWith.isEmpty()) options else startsWith
armorTitle = if (options.isEmpty()) title else StringUtil.didYouMean(title, options)
}

override fun getDrop(dropMetadata: DropMetadata, v: Double): AbstractItemStack {
val item = com.cjcrafter.armormechanics.ArmorMechanics.INSTANCE.armors[armorTitle]
val item = ArmorMechanics.INSTANCE.armors[armorTitle]

// Just in case MythicMobs edits this item, we want to use a clone
// to avoid possible modification.
Expand Down

0 comments on commit 52b0208

Please sign in to comment.