Fix "pointers" for players never being used lol & Type pointers (#674)

* Fix "pointers" for players never being used lol

* Added Platform Facet API to add Type pointers

* Remove duplicate
This commit is contained in:
OOP-778
2022-04-01 05:09:10 +03:00
committed by GitHub
parent 05d1938476
commit 9f77431f36
3 changed files with 14 additions and 1 deletions

View File

@@ -68,6 +68,7 @@ dependencies {
implementation(platform("net.kyori:adventure-bom:${adventureVersion}"))
implementation("net.kyori:adventure-nbt")
implementation("net.kyori:adventure-platform-facet:4.0.0")
implementation 'org.asynchttpclient:async-http-client:2.12.3'

View File

@@ -88,6 +88,8 @@ import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.permission.PermissionChecker;
import net.kyori.adventure.platform.facet.FacetPointers;
import net.kyori.adventure.platform.facet.FacetPointers.Type;
import net.kyori.adventure.pointer.Pointers;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TranslatableComponent;
@@ -145,6 +147,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
.withDynamic(Identity.UUID, this::getUniqueId)
.withDynamic(Identity.NAME, this::getUsername)
.withStatic(PermissionChecker.POINTER, getPermissionChecker())
.withStatic(FacetPointers.TYPE, Type.PLAYER)
.build();
private @Nullable String clientBrand;
private @Nullable Locale effectiveLocale;
@@ -256,6 +259,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
server.getEventManager().fireAndForget(new PlayerModInfoEvent(this, modInfo));
}
@Override
public @NotNull Pointers pointers() {
return this.pointers;
}
@Override
public InetSocketAddress getRemoteAddress() {
return (InetSocketAddress) connection.getRemoteAddress();

View File

@@ -29,6 +29,8 @@ import java.util.List;
import java.util.Locale;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.permission.PermissionChecker;
import net.kyori.adventure.platform.facet.FacetPointers;
import net.kyori.adventure.platform.facet.FacetPointers.Type;
import net.kyori.adventure.pointer.Pointers;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
@@ -52,7 +54,9 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
private final VelocityServer server;
private PermissionFunction permissionFunction = ALWAYS_TRUE;
private final @NotNull Pointers pointers = ConsoleCommandSource.super.pointers().toBuilder()
.withDynamic(PermissionChecker.POINTER, this::getPermissionChecker).build();
.withDynamic(PermissionChecker.POINTER, this::getPermissionChecker)
.withStatic(FacetPointers.TYPE, Type.CONSOLE)
.build();
public VelocityConsole(VelocityServer server) {
this.server = server;