From c85a76c6c6cd72a9f0a7a868cd750688c9e585d6 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 2 Sep 2024 16:17:41 +0200 Subject: [PATCH] Enhance profile and group prefix/suffix handling Refactor prefix and suffix handling to support prioritized settings for profiles and groups. This update allows for more granular control over multiple prefixes and suffixes, improving the flexibility of the conversion process. --- .../service/command/ServiceConvertCommand.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugin/src/main/java/net/thenextlvl/service/command/ServiceConvertCommand.java b/plugin/src/main/java/net/thenextlvl/service/command/ServiceConvertCommand.java index 71644f8..48d1009 100644 --- a/plugin/src/main/java/net/thenextlvl/service/command/ServiceConvertCommand.java +++ b/plugin/src/main/java/net/thenextlvl/service/command/ServiceConvertCommand.java @@ -110,11 +110,11 @@ public void convert(OfflinePlayer player, BankController source, BankController private final class ChatConverter extends PlayerConverter { @Override public void convert(OfflinePlayer player, ChatController source, ChatController target) { - source.tryGetProfile(player).thenAccept(sourceProfile -> target.tryGetProfile(player) + source.tryGetProfile(player).thenAccept(profile -> target.tryGetProfile(player) .thenAccept(targetProfile -> { - sourceProfile.getPrefix().ifPresent(targetProfile::setPrefix); - sourceProfile.getSuffix().ifPresent(targetProfile::setSuffix); - sourceProfile.getDisplayName().ifPresent(targetProfile::setDisplayName); + profile.getPrefixes().forEach((priority, prefix) -> targetProfile.setPrefix(prefix, priority)); + profile.getSuffixes().forEach((priority, suffix) -> targetProfile.setSuffix(suffix, priority)); + profile.getDisplayName().ifPresent(targetProfile::setDisplayName); })); } } @@ -153,8 +153,8 @@ public void convert(GroupController source, GroupController target) { .thenAccept(targetGroup -> { group.getDisplayName().ifPresent(targetGroup::setDisplayName); group.getPermissions().forEach(targetGroup::setPermission); - group.getPrefix().ifPresent(targetGroup::setPrefix); - group.getSuffix().ifPresent(targetGroup::setSuffix); + group.getPrefixes().forEach((priority, prefix) -> targetGroup.setPrefix(prefix, priority)); + group.getSuffixes().forEach((priority, suffix) -> targetGroup.setSuffix(suffix, priority)); group.getWeight().ifPresent(targetGroup::setWeight); }))); super.convert(source, target);