Implement missing Pointers (#694)

- Implement Player's LOCALE and DISPLAY_NAME pointers
- Implement VelocityConsole's LOCALE pointer
This commit is contained in:
4drian3d
2022-04-15 23:37:35 -05:00
committed by GitHub
parent d59d4505cb
commit 3cb10f6ad4
2 changed files with 4 additions and 0 deletions

View File

@@ -152,6 +152,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
private final @NotNull Pointers pointers = Player.super.pointers().toBuilder()
.withDynamic(Identity.UUID, this::getUniqueId)
.withDynamic(Identity.NAME, this::getUsername)
.withDynamic(Identity.DISPLAY_NAME, () -> Component.text(this.getUsername()))
.withDynamic(Identity.LOCALE, this::getEffectiveLocale)
.withStatic(PermissionChecker.POINTER, getPermissionChecker())
.withStatic(FacetPointers.TYPE, Type.PLAYER)
.build();

View File

@@ -55,6 +55,8 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
private PermissionFunction permissionFunction = ALWAYS_TRUE;
private final @NotNull Pointers pointers = ConsoleCommandSource.super.pointers().toBuilder()
.withDynamic(PermissionChecker.POINTER, this::getPermissionChecker)
.withDynamic(Identity.LOCALE, () -> ClosestLocaleMatcher.INSTANCE
.lookupClosest(Locale.getDefault()))
.withStatic(FacetPointers.TYPE, Type.CONSOLE)
.build();