Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 22:40:18 +01:00
Add a registerAll method to register a collection of resource packs easily
Dieser Commit ist enthalten in:
Ursprung
303327a388
Commit
d2622a477b
@ -30,6 +30,7 @@ import org.geysermc.geyser.api.connection.GeyserConnection;
|
||||
import org.geysermc.geyser.api.event.connection.ConnectionEvent;
|
||||
import org.geysermc.geyser.api.pack.ResourcePack;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -57,6 +58,14 @@ public abstract class SessionLoadResourcePacksEvent extends ConnectionEvent {
|
||||
*/
|
||||
public abstract boolean register(@NonNull ResourcePack resourcePack);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Unregisters a {@link ResourcePack} from being sent to the client.
|
||||
*
|
||||
|
@ -29,6 +29,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.event.Event;
|
||||
import org.geysermc.geyser.api.pack.ResourcePack;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -53,6 +54,15 @@ public abstract class GeyserDefineResourcePacksEvent implements Event {
|
||||
*/
|
||||
public abstract boolean register(@NonNull ResourcePack resourcePack);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
|
||||
/**
|
||||
* Unregisters a {@link ResourcePack} from being sent to clients.
|
||||
*
|
||||
|
@ -30,6 +30,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineResourcePacksEvent;
|
||||
import org.geysermc.geyser.api.pack.ResourcePack;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -58,6 +59,17 @@ public class GeyserDefineResourcePacksEventImpl extends GeyserDefineResourcePack
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerAll(@NonNull Collection<ResourcePack> resourcePacks) {
|
||||
boolean successful = true;
|
||||
for (ResourcePack pack : resourcePacks) {
|
||||
if (!this.register(pack)) {
|
||||
successful = false;
|
||||
}
|
||||
}
|
||||
return successful;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unregister(@NonNull UUID uuid) {
|
||||
return packs.remove(uuid.toString()) != null;
|
||||
|
@ -31,6 +31,7 @@ import org.geysermc.geyser.api.event.bedrock.SessionLoadResourcePacksEvent;
|
||||
import org.geysermc.geyser.api.pack.ResourcePack;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -59,6 +60,17 @@ public class SessionLoadResourcePacksEventImpl extends SessionLoadResourcePacksE
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerAll(@NonNull Collection<ResourcePack> resourcePacks) {
|
||||
boolean successful = true;
|
||||
for (ResourcePack pack : resourcePacks) {
|
||||
if (!this.register(pack)) {
|
||||
successful = false;
|
||||
}
|
||||
}
|
||||
return successful;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unregister(@NonNull UUID uuid) {
|
||||
return packs.remove(uuid.toString()) != null;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren