From 5e504deebdad33a515919c513246fb7a08f36a72 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 18 Sep 2023 14:01:22 -0700 Subject: [PATCH] remove useless Suppliers.memoize --- .../command/commands/NicknameCommand.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/NicknameCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/NicknameCommand.java index 57e92a801..76a4aa7be 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/NicknameCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/NicknameCommand.java @@ -23,9 +23,7 @@ import cloud.commandframework.arguments.standard.StringArgument; import cloud.commandframework.minecraft.extras.MinecraftExtrasMetaKeys; import cloud.commandframework.minecraft.extras.RichDescription; -import com.google.common.base.Suppliers; import com.google.inject.Inject; -import java.util.function.Supplier; import net.draycia.carbon.api.users.CarbonPlayer; import net.draycia.carbon.common.command.ArgumentFactory; import net.draycia.carbon.common.command.CarbonCommand; @@ -126,29 +124,27 @@ private void resetNickname(final Commander sender, final CarbonPlayer target) { } private void applyNickname(final Commander sender, final CarbonPlayer target, final String nick) { - - // Lazy since the sender might not have permission to set the nickname - final Supplier parsedNick = Suppliers.memoize(() -> parseNickname(sender, nick)); + final Component parsedNick = parseNickname(sender, nick); // If the nickname is caught in the character limit, return without setting a nickname. - final int nickNameLength = PlainTextComponentSerializer.plainText().serialize(parsedNick.get()).length(); + final int nickNameLength = PlainTextComponentSerializer.plainText().serialize(parsedNick).length(); final int minLength = this.config.primaryConfig().nickname().minLength(); final int maxLength = this.config.primaryConfig().nickname().maxLength(); if (nickNameLength < minLength || maxLength < nickNameLength) { - this.carbonMessages.nicknameErrorCharacterLimit(sender, parsedNick.get(), minLength, maxLength); + this.carbonMessages.nicknameErrorCharacterLimit(sender, parsedNick, minLength, maxLength); return; } - target.nickname(parsedNick.get()); + target.nickname(parsedNick); if (sender instanceof PlayerCommander playerCommander && playerCommander.carbonPlayer().uuid().equals(target.uuid())) { // Setting own nickname - this.carbonMessages.nicknameSet(sender, parsedNick.get()); + this.carbonMessages.nicknameSet(sender, parsedNick); } else { // Setting other player's nickname - this.carbonMessages.nicknameSet(target, parsedNick.get()); - this.carbonMessages.nicknameSetOthers(sender, target.username(), parsedNick.get()); + this.carbonMessages.nicknameSet(target, parsedNick); + this.carbonMessages.nicknameSetOthers(sender, target.username(), parsedNick); } }