mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 08:27:29 -04:00
rename ChatComponent::legacyText, ChatComponent::ansi, optimizing
This commit is contained in:
parent
6cf00cfff9
commit
f5e3d29826
@ -36,7 +36,7 @@ class BlockTarget(
|
||||
val cursor = position - blockPosition
|
||||
|
||||
override fun toString(): String {
|
||||
return toText().legacyText
|
||||
return toText().legacy
|
||||
}
|
||||
|
||||
override fun toText(): ChatComponent {
|
||||
|
@ -32,7 +32,7 @@ class EntityTarget(
|
||||
) : GenericTarget(position, distance, direction), TextFormattable {
|
||||
|
||||
override fun toString(): String {
|
||||
return toText().legacyText
|
||||
return toText().legacy
|
||||
}
|
||||
|
||||
override fun toText(): ChatComponent {
|
||||
|
@ -34,7 +34,7 @@ class FluidTarget(
|
||||
) : GenericTarget(position, distance, direction), TextFormattable {
|
||||
|
||||
override fun toString(): String {
|
||||
return toText().legacyText
|
||||
return toText().legacy
|
||||
}
|
||||
|
||||
override fun toText(): ChatComponent {
|
||||
|
@ -138,20 +138,20 @@ class BaseComponent : ChatComponent {
|
||||
return BaseComponent(parts)
|
||||
}
|
||||
|
||||
override val ansiColoredMessage: String
|
||||
override val ansi: String
|
||||
get() {
|
||||
val stringBuilder = StringBuilder()
|
||||
val builder = StringBuilder()
|
||||
for (part in parts) {
|
||||
stringBuilder.append(part.ansiColoredMessage)
|
||||
builder.append(part.ansi)
|
||||
}
|
||||
return stringBuilder.toString()
|
||||
return builder.toString()
|
||||
}
|
||||
|
||||
override val legacyText: String
|
||||
override val legacy: String
|
||||
get() {
|
||||
val stringBuilder = StringBuilder()
|
||||
for (part in parts) {
|
||||
stringBuilder.append(part.legacyText)
|
||||
stringBuilder.append(part.legacy)
|
||||
}
|
||||
// ToDo: Remove §r suffix
|
||||
return stringBuilder.toString()
|
||||
@ -198,7 +198,7 @@ class BaseComponent : ChatComponent {
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return legacyText
|
||||
return legacy
|
||||
}
|
||||
|
||||
operator fun plusAssign(component: ChatComponent) {
|
||||
|
@ -33,12 +33,12 @@ interface ChatComponent {
|
||||
/**
|
||||
* @return Returns the message formatted with ANSI Formatting codes
|
||||
*/
|
||||
val ansiColoredMessage: String
|
||||
val ansi: String
|
||||
|
||||
/**
|
||||
* @return Returns the message formatted with minecraft formatting codes (§)
|
||||
*/
|
||||
val legacyText: String
|
||||
val legacy: String
|
||||
|
||||
/**
|
||||
* @return Returns the unformatted message
|
||||
|
@ -17,8 +17,8 @@ import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
import javafx.collections.ObservableList
|
||||
import javafx.scene.Node
|
||||
object EmptyComponent : ChatComponent {
|
||||
override val ansiColoredMessage: String get() = ""
|
||||
override val legacyText: String get() = ""
|
||||
override val ansi: String get() = ""
|
||||
override val legacy: String get() = ""
|
||||
override val message: String get() = ""
|
||||
|
||||
override fun getJson(): Any = emptyList<Any>()
|
||||
|
@ -80,7 +80,7 @@ open class TextComponent(
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return legacyText
|
||||
return legacy
|
||||
}
|
||||
|
||||
override fun setFallbackColor(color: RGBColor): TextComponent {
|
||||
@ -90,22 +90,22 @@ open class TextComponent(
|
||||
return this
|
||||
}
|
||||
|
||||
override val ansiColoredMessage: String
|
||||
override val ansi: String
|
||||
get() {
|
||||
val stringBuilder = StringBuilder()
|
||||
val builder = StringBuilder()
|
||||
this.color?.let {
|
||||
stringBuilder.append(it.ansi)
|
||||
builder.append(it.ansi)
|
||||
}
|
||||
|
||||
for (formattingCode in this.formatting) {
|
||||
stringBuilder.append(formattingCode.ansi)
|
||||
builder.append(formattingCode.ansi)
|
||||
}
|
||||
stringBuilder.append(this.message)
|
||||
stringBuilder.append(FormattingCodes.RESET.ansi)
|
||||
return stringBuilder.toString()
|
||||
builder.append(this.message)
|
||||
builder.append(FormattingCodes.RESET.ansi)
|
||||
return builder.toString()
|
||||
}
|
||||
|
||||
override val legacyText: String
|
||||
override val legacy: String
|
||||
get() {
|
||||
val builder = StringBuilder()
|
||||
ChatColors.getChar(color)?.let { builder.append(ProtocolDefinition.TEXT_COMPONENT_FORMATTING_PREFIX).append(it) }
|
||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.data.text.formatting.TextFormattable
|
||||
import org.checkerframework.common.value.qual.IntRange
|
||||
|
||||
class RGBColor(val rgba: Int) : TextFormattable {
|
||||
val ansi: String = ANSI.rgb(red, green, blue)
|
||||
val ansi: String get() = ANSI.rgb(red, green, blue)
|
||||
|
||||
@JvmOverloads
|
||||
constructor(red: Int, green: Int, blue: Int, alpha: Int = 0xFF) : this(alpha or (blue shl 8) or (green shl 16) or (red shl 24))
|
||||
|
@ -167,7 +167,7 @@ class ServerModifyDialog(
|
||||
descriptionFX.text = EDIT_DESCRIPTION
|
||||
modifyServerButtonFX.ctext = EDIT_UPDATE_BUTTON
|
||||
|
||||
serverNameFX.text = server.name.legacyText.removeSuffix("§r")
|
||||
serverNameFX.text = server.name.legacy.removeSuffix("§r")
|
||||
serverAddressFX.text = server.address
|
||||
|
||||
modifyServerButtonFX.isDisable = serverAddressFX.text.isBlank()
|
||||
|
@ -185,7 +185,10 @@ class Frustum(
|
||||
|
||||
fun containsAABB(aabb: AABB): Boolean {
|
||||
val offset = camera.offset.offset
|
||||
return containsRegion(Vec3(aabb.min - offset), Vec3(aabb.max - offset))
|
||||
return containsRegion(
|
||||
(aabb.min.x - offset.x).toFloat(), (aabb.min.y - offset.x).toFloat(), (aabb.min.z - offset.x).toFloat(),
|
||||
(aabb.max.x - offset.x).toFloat(), (aabb.max.x - offset.x).toFloat(), (aabb.max.x - offset.x).toFloat(),
|
||||
)
|
||||
}
|
||||
|
||||
operator fun contains(aabb: AABB) = containsAABB(aabb)
|
||||
|
@ -125,28 +125,27 @@ class WorldVisibilityGraph(
|
||||
if (!RenderConstants.OCCLUSION_CULLING_ENABLED) {
|
||||
return frustum.containsAABB(aabb)
|
||||
}
|
||||
val chunkPositions: MutableSet<Vec2i> = HashSet()
|
||||
val chunkPositions: MutableSet<Vec2i> = HashSet(4, 1.0f)
|
||||
val sectionIndices = IntOpenHashSet()
|
||||
for (position in aabb.positions()) {
|
||||
for (position in aabb.positions()) { // TODO: use ChunkPosition iterator
|
||||
chunkPositions += position.chunkPosition
|
||||
sectionIndices += position.sectionHeight - minSection
|
||||
}
|
||||
var visible = false
|
||||
chunkPositions@ for (chunkPosition in chunkPositions) {
|
||||
|
||||
for (chunkPosition in chunkPositions) {
|
||||
val visibility = getChunkVisibility(chunkPosition) ?: continue
|
||||
for (index in sectionIndices.intIterator()) {
|
||||
if (index < 0 || index > maxIndex) {
|
||||
visible = true // ToDo: Not 100% correct, image looking from > maxIndex to < 0
|
||||
break@chunkPositions
|
||||
// ToDo: Not 100% correct, image looking from > maxIndex to < 0
|
||||
return false
|
||||
}
|
||||
if (visibility[index + 1]) {
|
||||
visible = true
|
||||
break@chunkPositions
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !visible
|
||||
return true
|
||||
}
|
||||
|
||||
fun isAABBVisible(aabb: AABB): Boolean {
|
||||
|
@ -140,7 +140,7 @@ class TabListEntryElement(
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return displayName.legacyText
|
||||
return displayName.legacy
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -41,7 +41,7 @@ object ChatComponentColorSerializer : SimpleModule() {
|
||||
object Serializer : StdSerializer<ChatComponent>(ChatComponent::class.java) {
|
||||
|
||||
override fun serialize(value: ChatComponent?, generator: JsonGenerator, provider: SerializerProvider?) {
|
||||
generator.writeString(value?.legacyText?.removeSuffix(ProtocolDefinition.TEXT_COMPONENT_FORMATTING_PREFIX.toString() + FormattingCodes.RESET.char.toString()))
|
||||
generator.writeString(value?.legacy?.removeSuffix(ProtocolDefinition.TEXT_COMPONENT_FORMATTING_PREFIX.toString() + FormattingCodes.RESET.char.toString()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,8 +102,8 @@ object Log {
|
||||
SYSTEM_OUT_STREAM
|
||||
}
|
||||
|
||||
val prefix = message.ansiColoredMessage.removeSuffix(RESET) // reset suffix
|
||||
for (line in this.message.ansiColoredMessage.lineSequence()) {
|
||||
val prefix = message.ansi.removeSuffix(RESET) // reset suffix
|
||||
for (line in this.message.ansi.lineSequence()) {
|
||||
stream.println(prefix + line + RESET)
|
||||
}
|
||||
stream.flush()
|
||||
|
@ -95,7 +95,7 @@ class LanguageTest {
|
||||
@Test
|
||||
fun formatting() {
|
||||
val language = create("§eHi %s, welcome!")
|
||||
assertEquals(language.translate(KEY, data = arrayOf("§aMoritz"))?.legacyText, "§eHi §r§aMoritz§r§e, welcome!§r")
|
||||
assertEquals(language.translate(KEY, data = arrayOf("§aMoritz"))?.legacy, "§eHi §r§aMoritz§r§e, welcome!§r")
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -107,7 +107,7 @@ class LanguageTest {
|
||||
@Test
|
||||
fun parent() {
|
||||
val language = create("Hi %s, welcome!")
|
||||
assertEquals(language.translate(KEY, parent = TextComponent("").color(ChatColors.YELLOW), data = arrayOf("§aMoritz"))?.legacyText, "§eHi §r§aMoritz§r§e, welcome!§r")
|
||||
assertEquals(language.translate(KEY, parent = TextComponent("").color(ChatColors.YELLOW), data = arrayOf("§aMoritz"))?.legacy, "§eHi §r§aMoritz§r§e, welcome!§r")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user