aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon <brandon.wamboldt@gmail.com>2023-10-15 10:33:55 -0300
committerGitHub <noreply@github.com>2023-10-15 15:33:55 +0200
commit29904921c5d2c81b8d7cb37dcd57af9fd0761343 (patch)
tree27071d1df08073a2356454e6992321cd534dc591
parent9755df0878023c73ac18ffc7aa07706b6c0a77c0 (diff)
downloadskyhanni-29904921c5d2c81b8d7cb37dcd57af9fd0761343.tar.gz
skyhanni-29904921c5d2c81b8d7cb37dcd57af9fd0761343.tar.bz2
skyhanni-29904921c5d2c81b8d7cb37dcd57af9fd0761343.zip
Feature: Show alerts when the player catches a legendary sea creature (#530)
dded Alerts when the player catches a legendary sea creature. #530
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/FishingConfig.java33
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt43
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt30
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityOutlineRenderer.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/SeaCreatureJson.java32
15 files changed, 166 insertions, 45 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
index 661728742..a05d2de5d 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity
import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.misc.update.UpdateManager
import at.hannibal2.skyhanni.utils.LorenzLogger
+import at.hannibal2.skyhanni.utils.LorenzRarity
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
@@ -86,6 +87,15 @@ class ConfigManager {
return reader.nextString().asInternalName()
}
}.nullSafe())
+ .registerTypeAdapter(LorenzRarity::class.java, object : TypeAdapter<LorenzRarity>() {
+ override fun write(out: JsonWriter, value: LorenzRarity) {
+ out.value(value.name)
+ }
+
+ override fun read(reader: JsonReader): LorenzRarity {
+ return LorenzRarity.valueOf(reader.nextString())
+ }
+ }.nullSafe())
.enableComplexMapKeySerialization()
.create()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
index f7929c46b..1479e5037 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
@@ -43,6 +43,7 @@ import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.test.command.TestChatCommand
import at.hannibal2.skyhanni.utils.APIUtil
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.SoundUtils
import net.minecraft.client.Minecraft
import net.minecraft.command.ICommandSender
import net.minecraft.event.ClickEvent
@@ -266,6 +267,10 @@ object Commands {
"shpartydebug",
"List persons into the chat SkyHanni thinks are in your party."
) { PartyAPI.listMembers() }
+ registerCommand(
+ "shplaysound",
+ "Play the specified sound effect at the given pitch and volume."
+ ) { SoundUtils.command(it) }
}
private fun internalCommands() {
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/FishingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/FishingConfig.java
index 70957e0ea..edca0b432 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/FishingConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/FishingConfig.java
@@ -257,10 +257,35 @@ public class FishingConfig {
}
@Expose
- @ConfigOption(name = "Highlight Rare", desc = "Highlight Rare Sea Creatures in blue color.")
- @ConfigEditorBoolean
- @FeatureToggle
- public boolean rareSeaCreatureHighlight = false;
+ @ConfigOption(name = "Rare Sea Creatures", desc = "")
+ @Accordion
+ public RareCatches rareCatches = new RareCatches();
+
+ public static class RareCatches {
+
+ @Expose
+ @ConfigOption(name = "Alert (Own Sea Creatures)", desc = "Show an alert on screen when you catch a rare sea creature.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean alertOwnCatches = true;
+
+ @Expose
+ @ConfigOption(name = "Alert (Other Sea Creatures)", desc = "Show an alert on screen when other players nearby catch a rare sea creature.")
+ @ConfigEditorBoolean
+ public boolean alertOtherCatches = false;
+
+ @Expose
+ @ConfigOption(name = "Play Sound Alert", desc = "Play a sound effect when rare sea creature alerts are displayed.")
+ @ConfigEditorBoolean
+ public boolean playSound = true;
+
+ @Expose
+ @ConfigOption(name = "Highlight", desc = "Highlight nearby rare sea creatures.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean highlight = false;
+
+ }
@Expose
@ConfigOption(
diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt
index 6e49b53d3..2438a9be3 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt
@@ -11,6 +11,7 @@ import java.io.InputStreamReader
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.util.zip.ZipInputStream
+import java.lang.reflect.Type
object RepoUtils {
@@ -83,7 +84,7 @@ object RepoUtils {
return false
}
- fun <T> getConstant(repo: File, constant: String, gson: Gson, clazz: Class<T>?): T? {
+ fun <T> getConstant(repo: File, constant: String, gson: Gson, clazz: Class<T>?, type: Type? = null): T? {
if (!repo.exists()) return null
val jsonFile = File(repo, "constants/$constant.json")
@@ -100,7 +101,11 @@ object RepoUtils {
StandardCharsets.UTF_8
)
).use { reader ->
- return gson.fromJson(reader, clazz)
+ if (type == null) {
+ return gson.fromJson(reader, clazz)
+ } else {
+ return gson.fromJson(reader, type)
+ }
}
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt
index 18ff50b0a..8010564a0 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt
@@ -5,12 +5,13 @@ import at.hannibal2.skyhanni.test.command.ErrorManager
import com.google.gson.Gson
import com.google.gson.JsonObject
import java.io.File
+import java.lang.reflect.Type
class RepositoryReloadEvent(val repoLocation: File, val gson: Gson) : LorenzEvent() {
fun getConstant(constant: String) = getConstant<JsonObject>(constant)
- inline fun <reified T : Any> getConstant(constant: String) = try {
- RepoUtils.getConstant(repoLocation, constant, gson, T::class.java)
+ inline fun <reified T : Any> getConstant(constant: String, type: Type? = null) = try {
+ RepoUtils.getConstant(repoLocation, constant, gson, T::class.java, type)
} catch (e: Exception) {
ErrorManager.logError(
Exception("Repo parsing error while trying to read constant '$constant'", e),
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt
index 2531b97bc..e90e550b9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt
@@ -74,7 +74,7 @@ class FishingTimer {
.map { entity ->
val name = entity.name
val isSummonedSoul = name.contains("'")
- val hasFishingMobName = SeaCreatureManager.allFishingMobNames.any { name.contains(it) }
+ val hasFishingMobName = SeaCreatureManager.allFishingMobs.keys.any { name.contains(it) }
if (hasFishingMobName && !isSummonedSoul) {
if (name == "Sea Emperor" || name == "Rider of the Deep") 2 else 1
} else 0
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt
index 987a57d00..18ff93cc9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt
@@ -1,18 +1,17 @@
package at.hannibal2.skyhanni.features.fishing
+import at.hannibal2.skyhanni.utils.LorenzRarity
+
data class SeaCreature(
- val displayName: String,
+ val name: String,
val fishingExperience: Int,
val chatColor: String,
val rare: Boolean,
+ val rarity: LorenzRarity,
) {
- override fun toString(): String {
- return chatColor + rare() + displayName
- }
+ val displayName by lazy { chatColor + rare() + name }
- private fun rare(): String {
- return if (rare) "§l" else ""
- }
+ private fun rare() = if (rare) "§l" else ""
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt
index be4df98e4..a545a87a4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt
@@ -1,9 +1,12 @@
package at.hannibal2.skyhanni.features.fishing
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
+import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent
+import at.hannibal2.skyhanni.events.SeaCreatureFishEvent
import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
@@ -13,17 +16,22 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.SoundUtils
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.monster.EntityGuardian
+import net.minecraft.entity.monster.EntityIronGolem
+import net.minecraft.entity.monster.EntitySkeleton
import net.minecraft.entity.monster.EntityZombie
import net.minecraft.entity.player.EntityPlayer
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-
+import kotlin.time.Duration.Companion.seconds
class SeaCreatureFeatures {
- private val config get() = SkyHanniMod.feature.fishing
+ private val config get() = SkyHanniMod.feature.fishing.rareCatches
private var rareSeaCreatures = listOf<EntityLivingBase>()
+ private var lastRareCatch = SimpleTimeMark.farPast()
@SubscribeEvent
fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) {
@@ -39,8 +47,25 @@ class SeaCreatureFeatures {
rareSeaCreatures = rareSeaCreatures.editCopy { add(entity) }
RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.RED.toColor().withAlpha(50))
- { config.rareSeaCreatureHighlight }
- RenderLivingEntityHelper.setNoHurtTime(entity) { config.rareSeaCreatureHighlight }
+ { config.highlight }
+ RenderLivingEntityHelper.setNoHurtTime(entity) { config.highlight }
+ if (config.alertOtherCatches && lastRareCatch.passedSince() > 1.seconds) {
+ val creature = SeaCreatureManager.allFishingMobs[creatureType.nametag]
+ TitleManager.sendTitle("${creature?.rarity?.chatColorCode ?: "§6"}RARE SEA CREATURE!", 1.5.seconds, 3.6)
+ if (config.playSound) SoundUtils.playBeepSound()
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onSeaCreatureFish(event: SeaCreatureFishEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!config.alertOwnCatches) return
+
+ if (event.seaCreature.rare) {
+ TitleManager.sendTitle("${event.seaCreature.rarity.chatColorCode}RARE CATCH!", 3.seconds, 3.6)
+ if (config.playSound) SoundUtils.playBeepSound()
+ lastRareCatch = SimpleTimeMark.now()
}
}
@@ -51,11 +76,16 @@ class SeaCreatureFeatures {
@SubscribeEvent
fun onRenderEntityOutlines(event: RenderEntityOutlineEvent) {
- if (isEnabled() && config.rareSeaCreatureHighlight && event.type === RenderEntityOutlineEvent.Type.XRAY) {
+ if (isEnabled() && config.highlight && event.type === RenderEntityOutlineEvent.Type.XRAY) {
event.queueEntitiesToOutline(getEntityOutlineColor)
}
}
+ @SubscribeEvent
+ fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
+ event.move(2, "fishing.rareSeaCreatureHighlight", "fishing.rareCatches.highlight")
+ }
+
private fun isEnabled() = LorenzUtils.inSkyBlock && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight
private val getEntityOutlineColor: (entity: Entity) -> Int? = { entity ->
@@ -71,12 +101,15 @@ class SeaCreatureFeatures {
) {
WATER_HYDRA(EntityZombie::class.java, "Water Hydra", 500_000),
SEA_EMPEROR(EntityGuardian::class.java, "Sea Emperor", 750_000, 800_000),
+ SEA_EMPEROR_RIDER(EntitySkeleton::class.java, "Sea Emperor", 750_000, 800_000),
ZOMBIE_MINER(EntityPlayer::class.java, "Zombie Miner", 2_000_000),
PHANTOM_FISHERMAN(EntityPlayer::class.java, "Phantom Fisher", 1_000_000),
GRIM_REAPER(EntityPlayer::class.java, "Grim Reaper", 3_000_000),
YETI(EntityPlayer::class.java, "Yeti", 2_000_000),
NUTCRACKER(EntityZombie::class.java, "Nutcracker", 4_000_000),
GREAT_WHITE_SHARK(EntityPlayer::class.java, "Great White Shark", 1_500_000),
+ THUNDER(EntityGuardian::class.java, "Thunder", 35_000_000),
+ LORD_JAWBUS(EntityIronGolem::class.java, "Lord Jawbus", 100_000_000),
;
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt
index e40ad43df..1fcca06f2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.events.SeaCreatureFishEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.jsonobjects.SeaCreatureJson
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class SeaCreatureManager {
@@ -34,26 +35,23 @@ class SeaCreatureManager {
var counter = 0
try {
- val data = event.getConstant("SeaCreatures") ?: return
+ val data = event.getConstant<Map<String, SeaCreatureJson.Variant>>("SeaCreatures", SeaCreatureJson.TYPE) ?: return
+ val allFishingMobs = mutableMapOf<String,SeaCreature>()
- val fishingMobNames = mutableListOf<String>()
- for (variant in data.entrySet().map { it.value.asJsonObject }) {
- val chatColor = variant["chat_color"].asString
- for ((displayName, value) in variant["sea_creatures"].asJsonObject.entrySet()) {
- val seaCreature = value.asJsonObject
- val chatMessage = seaCreature["chat_message"].asString
- val fishingExperience = seaCreature["fishing_experience"].asInt
+ for (variant in data.values) {
+ val chatColor = variant.chat_color
+ for ((displayName, seaCreature) in variant.sea_creatures) {
+ val chatMessage = seaCreature.chat_message
+ val fishingExperience = seaCreature.fishing_experience
+ val rarity = seaCreature.rarity
+ val rare = seaCreature.rare ?: false
- val rare = if (seaCreature.has("rare")) {
- seaCreature["rare"].asBoolean
- } else false
-
- seaCreatureMap[chatMessage] = SeaCreature(displayName, fishingExperience, chatColor, rare)
- fishingMobNames.add(displayName)
+ val creature = SeaCreature(displayName, fishingExperience, chatColor, rare, rarity)
+ seaCreatureMap[chatMessage] = creature
+ allFishingMobs[displayName] = creature
counter++
}
}
- allFishingMobNames = fishingMobNames
LorenzUtils.debug("Loaded $counter sea creatures from repo")
} catch (e: Exception) {
@@ -64,7 +62,7 @@ class SeaCreatureManager {
companion object {
private val seaCreatureMap = mutableMapOf<String, SeaCreature>()
- var allFishingMobNames = emptyList<String>()
+ var allFishingMobs = mutableMapOf<String, SeaCreature>()
private val doubleHookMessages = setOf(
"§eIt's a §r§aDouble Hook§r§e! Woot woot!",
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt
index 9226c46c2..f9cb0d861 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt
@@ -16,7 +16,7 @@ class SeaCreatureMessageShortener {
event.chatEvent.blockedReason = "sea_creature_caught"
var message = if (config.shortenFishingMessage) {
- "§9You caught a $seaCreature§9!"
+ "§9You caught a ${seaCreature.displayName}§9!"
} else event.chatEvent.message
if (config.compactDoubleHook && event.doubleHook) {
@@ -25,7 +25,7 @@ class SeaCreatureMessageShortener {
LorenzUtils.chat(message)
if (seaCreature.fishingExperience == 0) {
- LorenzUtils.debug("no fishing exp set for " + seaCreature.displayName)
+ LorenzUtils.debug("no fishing exp set for " + seaCreature.name)
}
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt
index becdddf16..c592e72a4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt
@@ -22,8 +22,7 @@ class SharkFishCounter {
fun onSeaCreatureFish(event: SeaCreatureFishEvent) {
if (!SkyHanniMod.feature.fishing.sharkFishCounter) return
- val displayName = event.seaCreature.displayName
- if (displayName.contains("Shark")) {
+ if (event.seaCreature.name.contains("Shark")) {
counter += if (event.doubleHook) 2 else 1
display = "§7Sharks caught: §e${counter.addSeparators()}"
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityOutlineRenderer.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityOutlineRenderer.kt
index 0bdf25a71..fbe2f1e96 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/EntityOutlineRenderer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityOutlineRenderer.kt
@@ -271,7 +271,7 @@ object EntityOutlineRenderer {
// Add new features that need the entity outline logic here
private fun isEnabled(): Boolean {
if (isMissingMixin) return false
- if (SkyHanniMod.feature.fishing.rareSeaCreatureHighlight) return true
+ if (SkyHanniMod.feature.fishing.rareCatches.highlight) return true
if (SkyHanniMod.feature.misc.glowingDroppedItems.enabled) return true
if (SkyHanniMod.feature.dungeon.highlightTeammates) return true
if (SkyHanniMod.feature.misc.highlightPartyMembers.enabled) return true
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt
index 306a54c50..d589df3ac 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt
@@ -19,7 +19,7 @@ enum class LorenzRarity(val color: LorenzColor, val id: Int) {
VERY_SPECIAL(LorenzColor.RED, 9),
;
- private val chatColorCode by lazy { color.getChatColor() }
+ val chatColorCode by lazy { color.getChatColor() }
private val rawName by lazy { name.replace("_", " ") }
private val normalName by lazy { "$chatColorCode§l$rawName" }
private val recombName by lazy { "$chatColorCode§l§ka§r $chatColorCode§l$chatColorCode§l$rawName" }
@@ -50,6 +50,7 @@ enum class LorenzRarity(val color: LorenzColor, val id: Int) {
companion object {
fun getById(id: Int) = entries.firstOrNull { it.ordinal == id }
+ fun getByName(name: String) = entries.firstOrNull { it.name == name }
fun readItemRarity(itemStack: ItemStack): LorenzRarity? {
for (line in itemStack.getLore()) {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
index 5e0e50d3f..d2403d4c6 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
@@ -35,10 +35,10 @@ object SoundUtils {
}
}
- fun createSound(name: String, pitch: Float): ISound {
+ fun createSound(name: String, pitch: Float, volume: Float = 50f): ISound {
val sound: ISound = object : PositionedSound(ResourceLocation(name)) {
init {
- volume = 50f
+ this.volume = volume
repeat = false
repeatDelay = 0
attenuationType = ISound.AttenuationType.NONE
@@ -56,6 +56,19 @@ object SoundUtils {
clickSound.playSound()
}
+ fun command(args: Array<String>) {
+ if (args.isEmpty()) {
+ LorenzUtils.chat("§c[SkyHanni] Specify a sound effect to test")
+ return
+ }
+
+ val soundName = args[0]
+ val pitch = args.getOrNull(1)?.toFloat() ?: 1.0f
+ val volume = args.getOrNull(2)?.toFloat() ?: 50.0f
+
+ createSound(soundName, pitch, volume).playSound()
+ }
+
fun playErrorSound() {
errorSound.playSound()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/SeaCreatureJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/SeaCreatureJson.java
new file mode 100644
index 000000000..52ed7f636
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/SeaCreatureJson.java
@@ -0,0 +1,32 @@
+package at.hannibal2.skyhanni.utils.jsonobjects;
+
+import at.hannibal2.skyhanni.utils.LorenzRarity;
+import com.google.gson.annotations.Expose;
+import com.google.gson.reflect.TypeToken;
+
+import java.lang.reflect.Type;
+import java.util.Map;
+
+public class SeaCreatureJson {
+
+ public static Type TYPE = new TypeToken<Map<String, SeaCreatureJson.Variant>>(){}.getType();
+
+ public static class Variant {
+ @Expose
+ public String chat_color;
+ @Expose
+ public Map<String, SeaCreature> sea_creatures;
+ }
+
+ public static class SeaCreature {
+ @Expose
+ public String chat_message;
+ @Expose
+ public int fishing_experience;
+ @Expose
+ public Boolean rare;
+ @Expose
+ public LorenzRarity rarity;
+ }
+
+}