geforkt von Mirrors/Velocity
Implement some missing resource pack API (#1206)
Dieser Commit ist enthalten in:
Ursprung
35137df76c
Commit
523d750f2b
@ -234,6 +234,11 @@ public interface Player extends
|
|||||||
* Gets the {@link ResourcePackInfo} of the currently applied
|
* Gets the {@link ResourcePackInfo} of the currently applied
|
||||||
* resource-pack or null if none.
|
* resource-pack or null if none.
|
||||||
*
|
*
|
||||||
|
* <p> Note that since 1.20.3 it is no longer recommended to use
|
||||||
|
* this method as it will only return the last applied
|
||||||
|
* resource pack. To get all applied resource packs, use
|
||||||
|
* {@link #getAppliedResourcePacks()} instead. </p>
|
||||||
|
*
|
||||||
* @return the applied resource pack or null if none.
|
* @return the applied resource pack or null if none.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -245,6 +250,11 @@ public interface Player extends
|
|||||||
* the user is currently downloading or is currently
|
* the user is currently downloading or is currently
|
||||||
* prompted to install or null if none.
|
* prompted to install or null if none.
|
||||||
*
|
*
|
||||||
|
* <p> Note that since 1.20.3 it is no longer recommended to use
|
||||||
|
* this method as it will only return the last pending
|
||||||
|
* resource pack. To get all pending resource packs, use
|
||||||
|
* {@link #getPendingResourcePacks()} instead. </p>
|
||||||
|
*
|
||||||
* @return the pending resource pack or null if none
|
* @return the pending resource pack or null if none
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -64,6 +64,7 @@ import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooterPacket;
|
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooterPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
|
import com.velocitypowered.proxy.protocol.packet.RemoveResourcePackPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatQueue;
|
import com.velocitypowered.proxy.protocol.packet.chat.ChatQueue;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatType;
|
import com.velocitypowered.proxy.protocol.packet.chat.ChatType;
|
||||||
@ -84,6 +85,8 @@ import io.netty.buffer.ByteBufUtil;
|
|||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -101,6 +104,9 @@ import net.kyori.adventure.permission.PermissionChecker;
|
|||||||
import net.kyori.adventure.platform.facet.FacetPointers;
|
import net.kyori.adventure.platform.facet.FacetPointers;
|
||||||
import net.kyori.adventure.platform.facet.FacetPointers.Type;
|
import net.kyori.adventure.platform.facet.FacetPointers.Type;
|
||||||
import net.kyori.adventure.pointer.Pointers;
|
import net.kyori.adventure.pointer.Pointers;
|
||||||
|
import net.kyori.adventure.resource.ResourcePackInfoLike;
|
||||||
|
import net.kyori.adventure.resource.ResourcePackRequest;
|
||||||
|
import net.kyori.adventure.resource.ResourcePackRequestLike;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
|
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
|
||||||
@ -153,6 +159,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
private final Queue<ResourcePackInfo> outstandingResourcePacks = new ArrayDeque<>();
|
private final Queue<ResourcePackInfo> outstandingResourcePacks = new ArrayDeque<>();
|
||||||
private @Nullable ResourcePackInfo pendingResourcePack;
|
private @Nullable ResourcePackInfo pendingResourcePack;
|
||||||
private @Nullable ResourcePackInfo appliedResourcePack;
|
private @Nullable ResourcePackInfo appliedResourcePack;
|
||||||
|
private @NotNull List<ResourcePackInfo> pendingResourcePacks = new ArrayList<>();
|
||||||
|
private @NotNull List<ResourcePackInfo> appliedResourcePacks = new ArrayList<>();
|
||||||
private final @NotNull Pointers pointers =
|
private final @NotNull Pointers pointers =
|
||||||
Player.super.pointers().toBuilder().withDynamic(Identity.UUID, this::getUniqueId)
|
Player.super.pointers().toBuilder().withDynamic(Identity.UUID, this::getUniqueId)
|
||||||
.withDynamic(Identity.NAME, this::getUsername)
|
.withDynamic(Identity.NAME, this::getUsername)
|
||||||
@ -974,6 +982,44 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearResourcePacks() {
|
||||||
|
if (this.getProtocolVersion().noLessThan(ProtocolVersion.MINECRAFT_1_20_3)) {
|
||||||
|
connection.write(new RemoveResourcePackPacket());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeResourcePacks(@NotNull UUID id, @NotNull UUID @NotNull ... others) {
|
||||||
|
if (this.getProtocolVersion().noLessThan(ProtocolVersion.MINECRAFT_1_20_3)) {
|
||||||
|
connection.write(new RemoveResourcePackPacket(id));
|
||||||
|
for (final UUID other : others) {
|
||||||
|
connection.write(new RemoveResourcePackPacket(other));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeResourcePacks(@NotNull ResourcePackRequest request) {
|
||||||
|
for (final net.kyori.adventure.resource.ResourcePackInfo resourcePackInfo : request.packs()) {
|
||||||
|
removeResourcePacks(resourcePackInfo.id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeResourcePacks(@NotNull ResourcePackRequestLike request) {
|
||||||
|
removeResourcePacks(request.asResourcePackRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("checkstyle:linelength")
|
||||||
|
public void removeResourcePacks(@NotNull ResourcePackInfoLike request, @NotNull ResourcePackInfoLike @NotNull ... others) {
|
||||||
|
removeResourcePacks(request.asResourcePackInfo().id());
|
||||||
|
for (final ResourcePackInfoLike other : others) {
|
||||||
|
removeResourcePacks(other.asResourcePackInfo().id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queues a resource-pack for sending to the player and sends it immediately if the queue is
|
* Queues a resource-pack for sending to the player and sends it immediately if the queue is
|
||||||
* empty.
|
* empty.
|
||||||
@ -1027,25 +1073,23 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public @Nullable ResourcePackInfo getAppliedResourcePack() {
|
public @Nullable ResourcePackInfo getAppliedResourcePack() {
|
||||||
//TODO which resource pack should be returned here?
|
|
||||||
return appliedResourcePack;
|
return appliedResourcePack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public @Nullable ResourcePackInfo getPendingResourcePack() {
|
public @Nullable ResourcePackInfo getPendingResourcePack() {
|
||||||
//TODO which resource pack should be returned here?
|
|
||||||
return pendingResourcePack;
|
return pendingResourcePack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ResourcePackInfo> getAppliedResourcePacks() {
|
public Collection<ResourcePackInfo> getAppliedResourcePacks() {
|
||||||
return Collections.EMPTY_LIST; //TODO
|
return new ArrayList<>(appliedResourcePacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ResourcePackInfo> getPendingResourcePacks() {
|
public Collection<ResourcePackInfo> getPendingResourcePacks() {
|
||||||
return Collections.EMPTY_LIST; //TODO
|
return new ArrayList<>(pendingResourcePacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1079,6 +1123,10 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
case ACCEPTED:
|
case ACCEPTED:
|
||||||
previousResourceResponse = true;
|
previousResourceResponse = true;
|
||||||
pendingResourcePack = queued;
|
pendingResourcePack = queued;
|
||||||
|
if (this.getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_20_3)) {
|
||||||
|
pendingResourcePacks.clear();
|
||||||
|
}
|
||||||
|
pendingResourcePacks.add(queued);
|
||||||
break;
|
break;
|
||||||
case DECLINED:
|
case DECLINED:
|
||||||
previousResourceResponse = false;
|
previousResourceResponse = false;
|
||||||
@ -1086,9 +1134,41 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
case SUCCESSFUL:
|
case SUCCESSFUL:
|
||||||
appliedResourcePack = queued;
|
appliedResourcePack = queued;
|
||||||
pendingResourcePack = null;
|
pendingResourcePack = null;
|
||||||
|
appliedResourcePacks.add(queued);
|
||||||
|
if (this.getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_20_3)) {
|
||||||
|
pendingResourcePacks.clear();
|
||||||
|
}
|
||||||
|
if (queued != null) {
|
||||||
|
pendingResourcePacks.removeIf(resourcePackInfo -> {
|
||||||
|
if (resourcePackInfo.getId() == null) {
|
||||||
|
return resourcePackInfo.getUrl().equals(queued.getUrl())
|
||||||
|
&& Arrays.equals(resourcePackInfo.getHash(), queued.getHash());
|
||||||
|
}
|
||||||
|
return resourcePackInfo.getId().equals(queued.getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case FAILED_DOWNLOAD:
|
case FAILED_DOWNLOAD:
|
||||||
pendingResourcePack = null;
|
pendingResourcePack = null;
|
||||||
|
if (this.getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_20_3)) {
|
||||||
|
pendingResourcePacks.clear();
|
||||||
|
}
|
||||||
|
if (queued != null) {
|
||||||
|
pendingResourcePacks.removeIf(resourcePackInfo -> {
|
||||||
|
if (resourcePackInfo.getId() == null) {
|
||||||
|
return resourcePackInfo.getUrl().equals(queued.getUrl())
|
||||||
|
&& Arrays.equals(resourcePackInfo.getHash(), queued.getHash());
|
||||||
|
}
|
||||||
|
return resourcePackInfo.getId().equals(queued.getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DISCARDED:
|
||||||
|
if (queued != null && queued.getId() != null) {
|
||||||
|
appliedResourcePacks.removeIf(resourcePackInfo -> {
|
||||||
|
return queued.getId().equals(resourcePackInfo.getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -146,7 +146,12 @@ public class ResourcePackRequestPacket implements MinecraftPacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ResourcePackRequest{" + "url='" + url + '\'' + ", hash='" + hash + '\'' +
|
return "ResourcePackRequestPacket{" +
|
||||||
", isRequired=" + isRequired + ", prompt='" + prompt + '\'' + '}';
|
"id=" + id +
|
||||||
|
", url='" + url + '\'' +
|
||||||
|
", hash='" + hash + '\'' +
|
||||||
|
", isRequired=" + isRequired +
|
||||||
|
", prompt=" + prompt +
|
||||||
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -83,6 +83,10 @@ public class ResourcePackResponsePacket implements MinecraftPacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ResourcePackResponse{" + "hash=" + hash + ", " + "status=" + status + '}';
|
return "ResourcePackResponsePacket{" +
|
||||||
|
"id=" + id +
|
||||||
|
", hash='" + hash + '\'' +
|
||||||
|
", status=" + status +
|
||||||
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren