-
Notifications
You must be signed in to change notification settings - Fork 7
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
Showing
32 changed files
with
366 additions
and
329 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
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
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
17 changes: 17 additions & 0 deletions
17
common/src/main/kotlin/com/rpmtw/rpmtw_platform_mod/command/LogoutRPMTWAccountCommand.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.rpmtw.rpmtw_platform_mod.command | ||
|
||
import com.mojang.brigadier.builder.LiteralArgumentBuilder | ||
import com.rpmtw.rpmtw_platform_mod.handlers.RPMTWAuthHandler | ||
import net.minecraft.commands.SharedSuggestionProvider | ||
|
||
class LogoutRPMTWAccountCommand : RPMTWCommand() { | ||
override fun register(): LiteralArgumentBuilder<SharedSuggestionProvider> { | ||
val command = literal("logout").executes { | ||
RPMTWAuthHandler.logout() | ||
|
||
return@executes CommandHandler.success | ||
} | ||
|
||
return command | ||
} | ||
} |
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
120 changes: 120 additions & 0 deletions
120
common/src/main/kotlin/com/rpmtw/rpmtw_platform_mod/config/RPMTWAccountEntry.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,120 @@ | ||
package com.rpmtw.rpmtw_platform_mod.config | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack | ||
import com.rpmtw.rpmtw_platform_mod.handlers.RPMTWAuthHandler | ||
import me.shedaniel.clothconfig2.api.AbstractConfigListEntry | ||
import net.minecraft.client.Minecraft | ||
import net.minecraft.client.gui.components.AbstractWidget | ||
import net.minecraft.client.gui.components.Button | ||
import net.minecraft.client.gui.components.events.GuiEventListener | ||
import net.minecraft.client.gui.narration.NarratableEntry | ||
import net.minecraft.client.resources.language.I18n | ||
import net.minecraft.network.chat.TextComponent | ||
import net.minecraft.network.chat.TranslatableComponent | ||
import java.util.* | ||
|
||
|
||
class RPMTWAccountEntry : AbstractConfigListEntry<Any?>( | ||
TextComponent( | ||
UUID.randomUUID().toString() | ||
), false | ||
) { | ||
private val widgets: MutableList<AbstractWidget?> = ArrayList() | ||
override fun getItemHeight(): Int { | ||
return 48 | ||
} | ||
|
||
override fun narratables(): List<NarratableEntry?> { | ||
return widgets | ||
} | ||
|
||
override fun getValue(): Any { | ||
return Any() | ||
} | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
override fun getDefaultValue(): Optional<Any?> { | ||
return Optional.of(Any()) as Optional<Any?> | ||
} | ||
|
||
override fun save() { | ||
|
||
} | ||
|
||
override fun isMouseInside(mouseX: Int, mouseY: Int, x: Int, y: Int, entryWidth: Int, entryHeight: Int): Boolean { | ||
return false | ||
} | ||
|
||
override fun render( | ||
matrices: PoseStack, | ||
index: Int, | ||
y: Int, | ||
x: Int, | ||
entryWidth: Int, | ||
entryHeight: Int, | ||
mouseX: Int, | ||
mouseY: Int, | ||
isHovered: Boolean, | ||
delta: Float | ||
) { | ||
super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta) | ||
|
||
val title = TranslatableComponent("auth.rpmtw_platform_mod.title") | ||
val isLogin = RPMTWConfig.get().isLogin() | ||
val authStatus: String = if (isLogin) { | ||
I18n.get("auth.rpmtw_platform_mod.status.logged_in") | ||
} else { | ||
I18n.get("auth.rpmtw_platform_mod.status.not_logged_in") | ||
} | ||
|
||
if (!isLogin) { | ||
val loginButton = Button(entryWidth / 2 + 20, | ||
y + 10, | ||
65, | ||
20, | ||
TranslatableComponent("auth.rpmtw_platform_mod.button.login"), | ||
{ | ||
RPMTWAuthHandler.login() | ||
}, | ||
{ _, matrixStack, i, j -> | ||
Minecraft.getInstance().screen?.renderTooltip( | ||
matrixStack, TranslatableComponent("auth.rpmtw_platform_mod.button.login.tooltip"), i, j | ||
) | ||
}) | ||
|
||
widgets.add(loginButton) | ||
loginButton.render(matrices, mouseX, mouseY, delta) | ||
} else { | ||
val logoutButton = Button( | ||
entryWidth / 2 + 20, y + 10, 65, 20, TranslatableComponent("auth.rpmtw_platform_mod.button.logout") | ||
) { | ||
RPMTWAuthHandler.logout() | ||
} | ||
|
||
widgets.add(logoutButton) | ||
logoutButton.render(matrices, mouseX, mouseY, delta) | ||
} | ||
|
||
val font = Minecraft.getInstance().font | ||
|
||
font.drawShadow( | ||
matrices, | ||
title, | ||
(x - 4 + entryWidth / 2 - Minecraft.getInstance().font.width(title) / 2).toFloat(), | ||
(y).toFloat(), | ||
-1 | ||
) | ||
|
||
font.drawShadow( | ||
matrices, | ||
authStatus, | ||
(x - 4 + entryWidth / 2 - Minecraft.getInstance().font.width(authStatus) / 2).toFloat(), | ||
(y + 33).toFloat(), | ||
-1 | ||
) | ||
} | ||
|
||
override fun children(): List<GuiEventListener?> { | ||
return widgets | ||
} | ||
} |
Oops, something went wrong.