Add url codec creation method with no content key, remove boolean return to registerAll, fix typo

This commit is contained in:
onebeastchris 2024-06-20 12:28:08 +02:00
parent 2683b59406
commit ba78dbaf34
6 changed files with 22 additions and 25 deletions

View file

@ -62,9 +62,8 @@ public abstract class SessionLoadResourcePacksEvent extends ConnectionEvent {
* Registers a collection of {@link ResourcePack} to be sent to clients.
*
* @param resourcePacks collection of resourcePack's that will be sent to clients.
* @return true if resource packs were added successfully, false if at least one failed
*/
public abstract boolean registerAll(@NonNull Collection<ResourcePack> resourcePacks);
public abstract void registerAll(@NonNull Collection<ResourcePack> resourcePacks);
/**
* Unregisters a {@link ResourcePack} from being sent to the client.

View file

@ -58,9 +58,8 @@ public abstract class GeyserDefineResourcePacksEvent implements Event {
* Registers a collection of {@link ResourcePack} to be sent to clients.
*
* @param resourcePacks collection of resourcePack's that will be sent to clients.
* @return true if resource packs were added successfully, false if at least one failed
*/
public abstract boolean registerAll(@NonNull Collection<ResourcePack> resourcePacks);
public abstract void registerAll(@NonNull Collection<ResourcePack> resourcePacks);
/**

View file

@ -81,6 +81,17 @@ public abstract class PackCodec {
return GeyserApi.api().provider(PathPackCodec.class, path);
}
/**
* Creates a new pack provider from the given url with no content key.
*
* @param url the url to create the pack provider from
* @return the new pack provider
*/
@NonNull
public static PackCodec url(@NonNull String url) {
return url(url, null);
}
/**
* Creates a new pack provider from the given url and content key.
*

View file

@ -60,14 +60,8 @@ public class GeyserDefineResourcePacksEventImpl extends GeyserDefineResourcePack
}
@Override
public boolean registerAll(@NonNull Collection<ResourcePack> resourcePacks) {
boolean successful = true;
for (ResourcePack pack : resourcePacks) {
if (!this.register(pack)) {
successful = false;
}
}
return successful;
public void registerAll(@NonNull Collection<ResourcePack> resourcePacks) {
resourcePacks.forEach(this::register);
}
@Override

View file

@ -61,14 +61,8 @@ public class SessionLoadResourcePacksEventImpl extends SessionLoadResourcePacksE
}
@Override
public boolean registerAll(@NonNull Collection<ResourcePack> resourcePacks) {
boolean successful = true;
for (ResourcePack pack : resourcePacks) {
if (!this.register(pack)) {
successful = false;
}
}
return successful;
public void registerAll(@NonNull Collection<ResourcePack> resourcePacks) {
resourcePacks.forEach(this::register);
}
@Override

View file

@ -70,7 +70,7 @@ import java.util.OptionalInt;
public class UpstreamPacketHandler extends LoggingPacketHandler {
private boolean networkSettingsRequested = false;
private final Deque<String> packsToSent = new ArrayDeque<>();
private final Deque<String> packsToSend = new ArrayDeque<>();
private final CompressionStrategy compressionStrategy;
private SessionLoadResourcePacksEventImpl resourcePackLoadEvent;
@ -227,8 +227,8 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.connect", session.getAuthData().name()));
}
case SEND_PACKS -> {
packsToSent.addAll(packet.getPackIds());
sendPackDataInfo(packsToSent.pop());
packsToSend.addAll(packet.getPackIds());
sendPackDataInfo(packsToSend.pop());
}
case HAVE_ALL_PACKS -> {
ResourcePackStackPacket stackPacket = new ResourcePackStackPacket();
@ -329,8 +329,8 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
session.sendUpstreamPacket(data);
// Check if it is the last chunk and send next pack in queue when available.
if (remainingSize <= GeyserResourcePack.CHUNK_SIZE && !packsToSent.isEmpty()) {
sendPackDataInfo(packsToSent.pop());
if (remainingSize <= GeyserResourcePack.CHUNK_SIZE && !packsToSend.isEmpty()) {
sendPackDataInfo(packsToSend.pop());
}
return PacketSignal.HANDLED;