Skip to content

Commit

Permalink
Update to 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
BluSpring committed Nov 18, 2022
1 parent cf6c109 commit 6da6b0d
Show file tree
Hide file tree
Showing 29 changed files with 126 additions and 144 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {

version = project.mod_version
group = project.maven_group
cloth_config_version = project.cloth_config_version

repositories {
// Add repositories to retrieve artifacts from in here.
Expand Down Expand Up @@ -39,9 +40,9 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"
modImplementation "com.terraformersmc:modmenu:3.0.1"
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"

modApi("me.shedaniel.cloth:cloth-config-fabric:6.4.90") {
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
}
Expand Down
12 changes: 7 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.18.1
yarn_mappings=1.18.1+build.22
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.22
loader_version=0.14.9
# Mod Properties
mod_version=1.0.1+1.18
mod_version=1.0.1+1.19
maven_group=xyz.bluspring
archives_base_name=Nicknamer
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.46.6+1.18
fabric_version=0.66.0+1.19.2
fabric_kotlin_version=1.8.5+kotlin.1.7.20
spruceui_version=3.3.3+1.18

modmenu_version=4.1.0
cloth_config_version=8.2.88
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package xyz.bluspring.nicknamer.duck;

import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;

public interface ExtendedPlayerListEntry {
default Text getOriginalDisplayName() {
return new LiteralText("that didn't work");
return Text.literal("that didn't work");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.mojang.authlib.GameProfile;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
Expand Down Expand Up @@ -36,7 +35,7 @@ public void replaceDisplayName(CallbackInfoReturnable<Text> cir) {
Nicknamer.Companion.setText(
this.profile,
ConfigManager.INSTANCE.getConfig().getPlayerListFormat(),
cir.getReturnValue() != null ? cir.getReturnValue() : new LiteralText(this.profile.getName())
cir.getReturnValue() != null ? cir.getReturnValue() : Text.literal(this.profile.getName())
)
);
}
Expand Down
9 changes: 4 additions & 5 deletions src/main/kotlin/xyz/bluspring/nicknamer/Nicknamer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.mojang.util.UUIDTypeAdapter
import net.fabricmc.api.ModInitializer
import net.fabricmc.loader.api.FabricLoader
import net.minecraft.client.MinecraftClient
import net.minecraft.text.LiteralText
import net.minecraft.text.Text
import net.minecraft.text.Texts
import org.slf4j.Logger
Expand Down Expand Up @@ -45,10 +44,10 @@ class Nicknamer : ModInitializer {
if (it == '%') {
if (isInFormatting) {
formedName += it
newText.add(replacements[formedName] ?: LiteralText(formedName))
newText.add(replacements[formedName] ?: Text.literal(formedName))
formedName = ""
} else {
newText.add(LiteralText(formedName))
newText.add(Text.literal(formedName))
formedName = "$it"
}

Expand All @@ -58,9 +57,9 @@ class Nicknamer : ModInitializer {
}

// Add a missing bit that gets missed
newText.add(LiteralText(formedName))
newText.add(Text.literal(formedName))

return Texts.join(newText, LiteralText(""))
return Texts.join(newText, Text.literal(""))
}

fun setText(profile: GameProfile, config: Map<NameFormat, String>, displayName: Text): Text {
Expand Down
24 changes: 10 additions & 14 deletions src/main/kotlin/xyz/bluspring/nicknamer/client/NicknamerClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@ package xyz.bluspring.nicknamer.client

import com.mojang.brigadier.arguments.StringArgumentType
import net.fabricmc.api.ClientModInitializer
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents
import net.minecraft.command.argument.TextArgumentType
import xyz.bluspring.nicknamer.Nicknamer
import xyz.bluspring.nicknamer.config.pronouns.PronounManager
import xyz.bluspring.nicknamer.commands.nick.*
import xyz.bluspring.nicknamer.commands.pronouns.*
import xyz.bluspring.nicknamer.commands.pronouns.color.*
import xyz.bluspring.nicknamer.commands.pronouns.PronounsGetCommand
import xyz.bluspring.nicknamer.commands.pronouns.PronounsSetCommand
import xyz.bluspring.nicknamer.commands.pronouns.color.PronounsColorComplimentCommand
import xyz.bluspring.nicknamer.commands.pronouns.color.PronounsColorGetCommand
import xyz.bluspring.nicknamer.commands.pronouns.color.PronounsColorSetCommand
import xyz.bluspring.nicknamer.commands.pronouns.profile.*
import xyz.bluspring.nicknamer.config.nickname.NicknameManager
import xyz.bluspring.nicknamer.config.pronouns.PronounManager

class NicknamerClient : ClientModInitializer {
override fun onInitializeClient() {
registerCommands()

ClientPlayConnectionEvents.JOIN.register { handler, _, client ->
val name: String = if (handler.connection.isLocal)
handler.world.server?.singlePlayerName ?: "unknown"
else
handler.connection.address.toString()
ClientPlayConnectionEvents.JOIN.register { _, _, _ ->
registerCommands()
}
}

private fun registerCommands() {
val dispatcher = ClientCommandManager.DISPATCHER
val dispatcher = ClientCommandManager.getActiveDispatcher() ?: return

dispatcher.register(
ClientCommandManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.mojang.brigadier.arguments.ArgumentType
import com.mojang.brigadier.context.CommandContext
import com.mojang.brigadier.suggestion.Suggestions
import com.mojang.brigadier.suggestion.SuggestionsBuilder
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.command.CommandSource
import net.minecraft.command.EntitySelector
import net.minecraft.command.EntitySelectorReader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package xyz.bluspring.nicknamer.commands.nick
import com.mojang.brigadier.Command
import com.mojang.brigadier.arguments.StringArgumentType
import com.mojang.brigadier.context.CommandContext
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource
import net.minecraft.client.MinecraftClient
import net.minecraft.text.LiteralText
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.text.Text
import xyz.bluspring.nicknamer.players.PlayerHelper

Expand All @@ -14,7 +12,7 @@ class NickGetCommand<T : FabricClientCommandSource> : Command<T> {
val playerName = StringArgumentType.getString(context, "player")
val player = PlayerHelper.getPlayer(playerName)

context.source.sendFeedback(LiteralText("Nickname for ${player.profile.name} is ").append(player.displayName))
context.source.sendFeedback(Text.literal("Nickname for ${player.profile.name} is ").append(player.displayName))

return 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package xyz.bluspring.nicknamer.commands.nick
import com.mojang.brigadier.Command
import com.mojang.brigadier.arguments.StringArgumentType
import com.mojang.brigadier.context.CommandContext
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource
import net.minecraft.client.MinecraftClient
import net.minecraft.text.LiteralText
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.text.Text
import xyz.bluspring.nicknamer.config.nickname.NicknameManager
import xyz.bluspring.nicknamer.players.PlayerHelper

Expand All @@ -16,7 +15,7 @@ class NickResetCommand<T : FabricClientCommandSource> : Command<T> {

NicknameManager.nicknames.remove(player.profile.id)

context.source.sendFeedback(LiteralText("Reset nickname for ${player.profile.name}!"))
context.source.sendFeedback(Text.literal("Reset nickname for ${player.profile.name}!"))
NicknameManager.save()

return 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package xyz.bluspring.nicknamer.commands.nick
import com.mojang.brigadier.Command
import com.mojang.brigadier.arguments.StringArgumentType
import com.mojang.brigadier.context.CommandContext
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource
import net.minecraft.client.MinecraftClient
import net.minecraft.text.LiteralText
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.text.Text
import xyz.bluspring.nicknamer.config.nickname.NicknameManager
import xyz.bluspring.nicknamer.players.PlayerHelper

Expand All @@ -16,9 +15,9 @@ class NickSetCommand<T : FabricClientCommandSource> : Command<T> {

val nickname = StringArgumentType.getString(context, "nickname")

NicknameManager.nicknames[player.profile.id] = LiteralText(nickname)
NicknameManager.nicknames[player.profile.id] = Text.literal(nickname)

context.source.sendFeedback(LiteralText("Set nickname for ${player.profile.name} to ").append(NicknameManager.nicknames[player.profile.id]))
context.source.sendFeedback(Text.literal("Set nickname for ${player.profile.name} to ").append(NicknameManager.nicknames[player.profile.id]))
NicknameManager.save()

return 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ package xyz.bluspring.nicknamer.commands.nick
import com.mojang.brigadier.Command
import com.mojang.brigadier.arguments.StringArgumentType
import com.mojang.brigadier.context.CommandContext
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource
import net.minecraft.client.MinecraftClient
import net.minecraft.text.LiteralText
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.text.Text
import xyz.bluspring.nicknamer.config.nickname.NicknameManager
import xyz.bluspring.nicknamer.duck.ExtendedPlayerListEntry
import xyz.bluspring.nicknamer.players.PlayerHelper

class NickSetFromDisplayNameCommand<T : FabricClientCommandSource> : Command<T> {
override fun run(context: CommandContext<T>): Int {
val playerName = StringArgumentType.getString(context, "player")
val player = PlayerHelper.getPlayer(playerName)

NicknameManager.nicknames[player.profile.id] = player.originalDisplayName ?: LiteralText(player.profile.name)
NicknameManager.nicknames[player.profile.id] = player.originalDisplayName ?: Text.literal(player.profile.name)

context.source.sendFeedback(LiteralText("Set nickname for ${player.profile.name} to ").append(NicknameManager.nicknames[player.profile.id]))
context.source.sendFeedback(Text.literal("Set nickname for ${player.profile.name} to ").append(NicknameManager.nicknames[player.profile.id]))
NicknameManager.save()

return 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package xyz.bluspring.nicknamer.commands.nick
import com.mojang.brigadier.Command
import com.mojang.brigadier.arguments.StringArgumentType
import com.mojang.brigadier.context.CommandContext
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource
import net.minecraft.client.MinecraftClient
import net.minecraft.text.LiteralText
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.text.Text
import xyz.bluspring.nicknamer.config.nickname.NicknameManager
import xyz.bluspring.nicknamer.players.PlayerHelper
Expand All @@ -19,7 +17,7 @@ class NickSetRawCommand<T : FabricClientCommandSource> : Command<T> {

NicknameManager.nicknames[player.profile.id] = nickname

context.source.sendFeedback(LiteralText("Set nickname for ${player.profile.name} to ").append(NicknameManager.nicknames[player.profile.id]))
context.source.sendFeedback(Text.literal("Set nickname for ${player.profile.name} to ").append(NicknameManager.nicknames[player.profile.id]))
NicknameManager.save()

return 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package xyz.bluspring.nicknamer.commands.nick
import com.mojang.brigadier.Command
import com.mojang.brigadier.arguments.StringArgumentType
import com.mojang.brigadier.context.CommandContext
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource
import net.minecraft.client.MinecraftClient
import net.minecraft.text.LiteralText
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.text.Text
import net.minecraft.util.Formatting
import xyz.bluspring.nicknamer.config.nickname.NicknameManager
import xyz.bluspring.nicknamer.players.PlayerHelper
Expand All @@ -23,8 +22,8 @@ class NickToggleCommand<T : FabricClientCommandSource> : Command<T> {
NicknameManager.disabled.add(player.profile.id)

context.source.sendFeedback(
LiteralText(if (toggle) "Enabled" else "Disabled").formatted(if (toggle) Formatting.GREEN else Formatting.RED)
.append(LiteralText(" nicknames for ${player.profile.name}!"))
Text.literal(if (toggle) "Enabled" else "Disabled").formatted(if (toggle) Formatting.GREEN else Formatting.RED)
.append(Text.literal(" nicknames for ${player.profile.name}!"))
)
NicknameManager.save()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package xyz.bluspring.nicknamer.commands.pronouns
import com.mojang.brigadier.Command
import com.mojang.brigadier.arguments.StringArgumentType
import com.mojang.brigadier.context.CommandContext
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource
import net.minecraft.text.LiteralText
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.text.Text
import xyz.bluspring.nicknamer.Nicknamer
import xyz.bluspring.nicknamer.config.pronouns.PronounManager

Expand All @@ -14,13 +14,13 @@ class PronounsGetCommand<T : FabricClientCommandSource> : Command<T> {
val playerUUID = Nicknamer.getPlayerUUID(playerName)

if (playerUUID == null) {
context.source.sendError(LiteralText("Could not find player $playerName!"))
context.source.sendError(Text.literal("Could not find player $playerName!"))

return 0
}

context.source.sendFeedback(
LiteralText("$playerName's pronouns are ")
Text.literal("$playerName's pronouns are ")
.append(PronounManager.getPronounsText(playerUUID))
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package xyz.bluspring.nicknamer.commands.pronouns
import com.mojang.brigadier.Command
import com.mojang.brigadier.arguments.StringArgumentType
import com.mojang.brigadier.context.CommandContext
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource
import net.minecraft.text.LiteralText
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.text.Text
import xyz.bluspring.nicknamer.Nicknamer
import xyz.bluspring.nicknamer.config.pronouns.PronounManager

Expand All @@ -14,7 +14,7 @@ class PronounsSetCommand<T : FabricClientCommandSource> : Command<T> {
val playerUUID = Nicknamer.getPlayerUUID(playerName)

if (playerUUID == null) {
context.source.sendError(LiteralText("Could not find player $playerName!"))
context.source.sendError(Text.literal("Could not find player $playerName!"))

return 0
}
Expand All @@ -28,7 +28,7 @@ class PronounsSetCommand<T : FabricClientCommandSource> : Command<T> {
}

context.source.sendFeedback(
LiteralText("Successfully set $playerName's pronouns to ")
Text.literal("Successfully set $playerName's pronouns to ")
.append(PronounManager.getPronounsText(playerUUID))
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package xyz.bluspring.nicknamer.commands.pronouns.color
import com.mojang.brigadier.Command
import com.mojang.brigadier.arguments.StringArgumentType
import com.mojang.brigadier.context.CommandContext
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource
import net.minecraft.text.LiteralText
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.text.Text
import net.minecraft.util.Formatting
import xyz.bluspring.nicknamer.Nicknamer
import xyz.bluspring.nicknamer.config.pronouns.PronounManager
Expand All @@ -15,7 +15,7 @@ class PronounsColorComplimentCommand<T : FabricClientCommandSource> : Command<T>
val complimenting = StringArgumentType.getString(context, "complimentingPronoun")

if (!PronounManager.pronounColors.contains(complimenting.lowercase())) {
context.source.sendError(LiteralText("Compliment pronoun $complimenting is not registered!").formatted(Formatting.RED))
context.source.sendError(Text.literal("Compliment pronoun $complimenting is not registered!").formatted(Formatting.RED))

return 0
}
Expand All @@ -25,9 +25,9 @@ class PronounsColorComplimentCommand<T : FabricClientCommandSource> : Command<T>
PronounManager.pronounColors[pronoun.lowercase()] = color

context.source.sendFeedback(
LiteralText("Set pronoun color to ")
Text.literal("Set pronoun color to ")
.append(
LiteralText(
Text.literal(
Nicknamer.toTitleCase(pronoun.lowercase())
).styled {
it.withColor(color)
Expand Down
Loading

0 comments on commit 6da6b0d

Please sign in to comment.