-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c89052
commit c2f7cdb
Showing
12 changed files
with
226 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
src/main/kotlin/com/fardragi/nyaruko/auth/messages/LoginMessage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/kotlin/com/fardragi/nyaruko/auth/messages/WelcomeMessage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.fardragi.nyaruko.auth.messages | ||
|
||
import com.fardragi.nyaruko.shared.messages.MessageBuilder | ||
import net.minecraft.event.ClickEvent | ||
import net.minecraft.util.ChatComponentText | ||
import net.minecraft.util.EnumChatFormatting | ||
|
||
object WelcomeMessage { | ||
fun create(name: String, isRegistered: Boolean): Array<ChatComponentText> { | ||
val messageBuilder = MessageBuilder() | ||
.addDividerLine() | ||
.add { builder -> | ||
builder.append(" ") | ||
builder.append("123", EnumChatFormatting.AQUA) { | ||
it.obfuscated() | ||
} | ||
builder.append(" Seja bem vindo ao servidor ") | ||
builder.append("123", EnumChatFormatting.AQUA) { | ||
it.obfuscated() | ||
} | ||
} | ||
.addEmptyLine() | ||
.add { builder -> | ||
if (isRegistered) { | ||
builder.append("Logue usando /login <senha>", EnumChatFormatting.YELLOW) | ||
} else { | ||
builder.append("Registre-se usando /register <senha> <repetir senha>", EnumChatFormatting.YELLOW) | ||
} | ||
} | ||
.addEmptyLine() | ||
.add { builder -> | ||
builder.append("Discord: ", EnumChatFormatting.DARK_PURPLE) | ||
builder.append("https://discord.gg/8KxJNzTJzq", EnumChatFormatting.BLUE) { | ||
it.clickEvent(ClickEvent.Action.OPEN_URL, "https://discord.gg/8KxJNzTJzq") | ||
} | ||
} | ||
.addDividerLine() | ||
|
||
return messageBuilder.build() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/com/fardragi/nyaruko/extensions/ChatComponentText.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.fardragi.nyaruko.extensions | ||
|
||
import net.minecraft.command.ICommandSender | ||
import net.minecraft.entity.player.EntityPlayer | ||
import net.minecraft.util.ChatComponentText | ||
|
||
fun EntityPlayer.addChatMessages(messages: Array<ChatComponentText>) { | ||
messages.forEach { | ||
this.addChatMessage(it) | ||
} | ||
} | ||
|
||
fun ICommandSender.addChatMessages(messages: Array<ChatComponentText>) { | ||
messages.forEach { | ||
this.addChatMessage(it) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/com/fardragi/nyaruko/shared/messages/DefaultMessage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.fardragi.nyaruko.shared.messages | ||
|
||
import net.minecraft.event.ClickEvent | ||
import net.minecraft.util.ChatComponentText | ||
import net.minecraft.util.ChatStyle | ||
import net.minecraft.util.EnumChatFormatting | ||
|
||
object DefaultMessage { | ||
fun usage(usage: String, command: String): ChatComponentText { | ||
val textComponent = ChatComponentText("Falha em executar o comando") | ||
textComponent.chatStyle = ChatStyle().setColor(EnumChatFormatting.RED) | ||
|
||
val usageComponent = ChatComponentText("[$usage]") | ||
usageComponent.chatStyle = ChatStyle().setColor(EnumChatFormatting.GOLD) | ||
.setChatClickEvent(ClickEvent(ClickEvent.Action.RUN_COMMAND, "/help $command")) | ||
|
||
textComponent.appendSibling(usageComponent) | ||
|
||
return textComponent | ||
} | ||
|
||
fun error(message: String): ChatComponentText { | ||
val textComponent = ChatComponentText(message) | ||
textComponent.chatStyle = ChatStyle().setColor(EnumChatFormatting.RED) | ||
|
||
return textComponent | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
src/main/kotlin/com/fardragi/nyaruko/shared/messages/FailCommandMessage.kt
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
src/main/kotlin/com/fardragi/nyaruko/shared/messages/MessageBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.fardragi.nyaruko.shared.messages | ||
|
||
import net.minecraft.util.ChatComponentText | ||
import net.minecraft.util.EnumChatFormatting | ||
|
||
class MessageBuilder { | ||
private val messages = mutableListOf<ChatComponentText>() | ||
|
||
fun build(): Array<ChatComponentText> { | ||
return messages.toTypedArray() | ||
} | ||
|
||
fun add(block: (TextBuilder) -> Unit): MessageBuilder { | ||
val textBuilder = TextBuilder() | ||
block(textBuilder) | ||
messages.add(textBuilder.build()) | ||
|
||
return this | ||
} | ||
|
||
fun addEmptyLine(): MessageBuilder { | ||
add { builder -> | ||
builder.append("") | ||
} | ||
|
||
return this | ||
} | ||
|
||
fun addDividerLine(): MessageBuilder { | ||
add { builder -> | ||
builder.append("-----------------------------------------------------", EnumChatFormatting.GOLD) | ||
.strikethrough() | ||
} | ||
|
||
return this | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/kotlin/com/fardragi/nyaruko/shared/messages/TextBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.fardragi.nyaruko.shared.messages | ||
|
||
import net.minecraft.event.ClickEvent | ||
import net.minecraft.util.ChatComponentText | ||
import net.minecraft.util.ChatStyle | ||
import net.minecraft.util.EnumChatFormatting | ||
|
||
class TextBuilder { | ||
private val componentText = ChatComponentText("").apply { | ||
chatStyle = ChatStyle() | ||
} | ||
|
||
fun build(): ChatComponentText { | ||
return componentText | ||
} | ||
|
||
fun append( | ||
text: String, | ||
color: EnumChatFormatting = EnumChatFormatting.RESET | ||
): TextBuilder { | ||
val textBuilder = TextBuilder() | ||
textBuilder.text(text, color) | ||
|
||
componentText.appendSibling(textBuilder.build()) | ||
|
||
return this | ||
} | ||
|
||
fun append( | ||
text: String, | ||
color: EnumChatFormatting = EnumChatFormatting.RESET, | ||
block: (TextBuilder) -> Unit | ||
): TextBuilder { | ||
val textBuilder = TextBuilder() | ||
textBuilder.text(text, color) | ||
block(textBuilder) | ||
|
||
componentText.appendSibling(textBuilder.build()) | ||
|
||
return this | ||
} | ||
|
||
private fun text(text: String, color: EnumChatFormatting = EnumChatFormatting.RESET): TextBuilder { | ||
componentText.appendText(text) | ||
componentText.chatStyle.color = color | ||
|
||
return this | ||
} | ||
|
||
fun obfuscated(): TextBuilder { | ||
componentText.chatStyle.obfuscated = true | ||
|
||
return this | ||
} | ||
|
||
fun strikethrough(): TextBuilder { | ||
componentText.chatStyle.strikethrough = true | ||
|
||
return this | ||
} | ||
|
||
fun clickEvent(action: ClickEvent.Action, value: String): TextBuilder { | ||
componentText.chatStyle.chatClickEvent = ClickEvent(action, value) | ||
|
||
return this | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,3 @@ object Minecraft { | |
return File(baseDir, "/DragiUtils") | ||
} | ||
} | ||
|