Skip to content

Commit

Permalink
Support minimessage in horse names
Browse files Browse the repository at this point in the history
  • Loading branch information
aikovdp committed Apr 3, 2024
1 parent 65c10d5 commit 54dd746
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.rokucraft.rokuhorses.command.RokuHorsesCommand;
import com.rokucraft.rokuhorses.horses.HorseManager;
import net.kyori.adventure.text.Component;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Horse;
Expand All @@ -11,6 +10,7 @@
import javax.inject.Inject;
import java.util.Optional;

import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
import static org.incendo.cloud.bukkit.parser.OfflinePlayerParser.offlinePlayerParser;
import static org.incendo.cloud.parser.standard.EnumParser.enumParser;
import static org.incendo.cloud.parser.standard.StringParser.greedyStringParser;
Expand Down Expand Up @@ -80,7 +80,7 @@ public void init(CommandManager<CommandSender> manager) {
ctx.sender().sendMessage("This player does not have a horse.");
return;
}
horse.name(name.map(Component::text).orElse(null));
horse.name(name.map(miniMessage()::deserialize).orElse(null));
horseManager.save(horse);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Optional;

import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
import static org.incendo.cloud.parser.standard.StringParser.greedyStringParser;

public class NameCommand implements RokuHorsesCommand {
Expand All @@ -34,7 +35,7 @@ public void init(CommandManager<CommandSender> manager) {
.handler(ctx -> {
Optional<String> name = ctx.optional("name");
Player player = ctx.sender();
renameHorse(player, name.map(Component::text).orElse(null));
renameHorse(player, name.map(miniMessage()::deserialize).orElse(null));
}));
}

Expand Down

0 comments on commit 54dd746

Please sign in to comment.