feat: Improve protect item message
This commit is contained in:
@@ -6,6 +6,10 @@ import net.minecraft.screen.slot.SlotActionType
|
|||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
import moe.nea.firmament.util.CommonSoundEffects
|
import moe.nea.firmament.util.CommonSoundEffects
|
||||||
import moe.nea.firmament.util.MC
|
import moe.nea.firmament.util.MC
|
||||||
|
import moe.nea.firmament.util.grey
|
||||||
|
import moe.nea.firmament.util.hover
|
||||||
|
import moe.nea.firmament.util.red
|
||||||
|
import moe.nea.firmament.util.tr
|
||||||
|
|
||||||
data class IsSlotProtectedEvent(
|
data class IsSlotProtectedEvent(
|
||||||
val slot: Slot?,
|
val slot: Slot?,
|
||||||
@@ -35,6 +39,7 @@ data class IsSlotProtectedEvent(
|
|||||||
INVENTORY_MOVE
|
INVENTORY_MOVE
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object : FirmamentEventBus<IsSlotProtectedEvent>() {
|
companion object : FirmamentEventBus<IsSlotProtectedEvent>() {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
@@ -47,7 +52,11 @@ data class IsSlotProtectedEvent(
|
|||||||
val event = IsSlotProtectedEvent(slot, action, false, itemStackOverride, origin)
|
val event = IsSlotProtectedEvent(slot, action, false, itemStackOverride, origin)
|
||||||
publish(event)
|
publish(event)
|
||||||
if (event.isProtected && !event.silent) {
|
if (event.isProtected && !event.silent) {
|
||||||
MC.sendChat(Text.translatable("firmament.protectitem").append(event.itemStack.name))
|
MC.sendChat(tr("firmament.protectitem", "Firmament protected your item: ${event.itemStack.name}.\n")
|
||||||
|
.red()
|
||||||
|
.append(tr("firmament.protectitem.hoverhint", "Hover for more info.").grey())
|
||||||
|
.hover(tr("firmament.protectitem.hint",
|
||||||
|
"To unlock this item use the Lock Slot or Lock Item keybind from Firmament while hovering over this item.")))
|
||||||
CommonSoundEffects.playFailure()
|
CommonSoundEffects.playFailure()
|
||||||
}
|
}
|
||||||
return event.isProtected
|
return event.isProtected
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package moe.nea.firmament.util
|
|||||||
|
|
||||||
import java.util.Optional
|
import java.util.Optional
|
||||||
import net.minecraft.text.ClickEvent
|
import net.minecraft.text.ClickEvent
|
||||||
|
import net.minecraft.text.HoverEvent
|
||||||
import net.minecraft.text.MutableText
|
import net.minecraft.text.MutableText
|
||||||
import net.minecraft.text.OrderedText
|
import net.minecraft.text.OrderedText
|
||||||
import net.minecraft.text.PlainTextContent
|
import net.minecraft.text.PlainTextContent
|
||||||
@@ -126,6 +127,7 @@ fun MutableText.darkGrey() = withColor(Formatting.DARK_GRAY)
|
|||||||
fun MutableText.red() = withColor(Formatting.RED)
|
fun MutableText.red() = withColor(Formatting.RED)
|
||||||
fun MutableText.white() = withColor(Formatting.WHITE)
|
fun MutableText.white() = withColor(Formatting.WHITE)
|
||||||
fun MutableText.bold(): MutableText = styled { it.withBold(true) }
|
fun MutableText.bold(): MutableText = styled { it.withBold(true) }
|
||||||
|
fun MutableText.hover(text: Text): MutableText = styled {it.withHoverEvent(HoverEvent(HoverEvent.Action.SHOW_TEXT, text))}
|
||||||
|
|
||||||
|
|
||||||
fun MutableText.clickCommand(command: String): MutableText {
|
fun MutableText.clickCommand(command: String): MutableText {
|
||||||
|
|||||||
@@ -314,7 +314,6 @@
|
|||||||
"firmament.price.lowestbin": "Lowest BIN: %s",
|
"firmament.price.lowestbin": "Lowest BIN: %s",
|
||||||
"firmament.pristine-profit.collection": "Collection: %s/h",
|
"firmament.pristine-profit.collection": "Collection: %s/h",
|
||||||
"firmament.pristine-profit.money": "Money: %s/h",
|
"firmament.pristine-profit.money": "Money: %s/h",
|
||||||
"firmament.protectitem": "Firmament protected your item: ",
|
|
||||||
"firmament.pv.lookingup": "Looking up %s",
|
"firmament.pv.lookingup": "Looking up %s",
|
||||||
"firmament.pv.noplayer": "%s is not a Minecraft player",
|
"firmament.pv.noplayer": "%s is not a Minecraft player",
|
||||||
"firmament.pv.noprofile": "%s has no SkyBlock profiles",
|
"firmament.pv.noprofile": "%s has no SkyBlock profiles",
|
||||||
|
|||||||
Reference in New Issue
Block a user