Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 15:00:11 +01:00
Address reviews
Dieser Commit ist enthalten in:
Ursprung
1faaea756c
Commit
18776a8000
@ -96,9 +96,6 @@ public interface GeyserConfiguration {
|
||||
|
||||
boolean isForceResourcePacks();
|
||||
|
||||
// TODO configurate - till then, api only
|
||||
//List<String> getResourcePackUrls();
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
boolean isXboxAchievementsEnabled();
|
||||
|
||||
|
@ -136,9 +136,6 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
||||
@JsonProperty("force-resource-packs")
|
||||
private boolean forceResourcePacks = true;
|
||||
|
||||
// @JsonProperty("resource-pack-urls")
|
||||
// private List<String> resourcePackUrls = new ArrayList<>();
|
||||
|
||||
@JsonProperty("xbox-achievements-enabled")
|
||||
private boolean xboxAchievementsEnabled = false;
|
||||
|
||||
|
@ -39,7 +39,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
public class GeyserDefineResourcePacksEventImpl extends GeyserDefineResourcePacksEvent {
|
||||
@ -51,7 +50,7 @@ public class GeyserDefineResourcePacksEventImpl extends GeyserDefineResourcePack
|
||||
|
||||
@Override
|
||||
public @NonNull List<ResourcePack> resourcePacks() {
|
||||
return packs.values().stream().map(ResourcePackHolder::pack).collect(Collectors.toUnmodifiableList());
|
||||
return packs.values().stream().map(ResourcePackHolder::resourcePack).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,9 +51,7 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SessionLoadResourcePacksEventImpl extends SessionLoadResourcePacksEvent {
|
||||
|
||||
@ -69,7 +67,7 @@ public class SessionLoadResourcePacksEventImpl extends SessionLoadResourcePacksE
|
||||
|
||||
@Override
|
||||
public @NonNull List<ResourcePack> resourcePacks() {
|
||||
return packs.values().stream().map(ResourcePackHolder::pack).collect(Collectors.toUnmodifiableList());
|
||||
return packs.values().stream().map(ResourcePackHolder::resourcePack).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,13 +136,12 @@ public class SessionLoadResourcePacksEventImpl extends SessionLoadResourcePacksE
|
||||
// Methods used internally for e.g. ordered packs, or resource pack entries
|
||||
|
||||
public List<ResourcePackStackPacket.Entry> orderedPacks() {
|
||||
TreeSet<Map.Entry<GeyserResourcePack, Double>> sortedPacks = packs.values().stream()
|
||||
return packs.values().stream()
|
||||
// Map each ResourcePack to a pair of (GeyserResourcePack, Priority)
|
||||
.map(holder -> new AbstractMap.SimpleEntry<>(holder.pack(), priority(holder.pack())))
|
||||
// Sort by priority in ascending order
|
||||
.collect(Collectors.toCollection(() -> new TreeSet<>(Map.Entry.comparingByValue(Comparator.naturalOrder()))));
|
||||
|
||||
return sortedPacks.stream()
|
||||
.sorted(Map.Entry.comparingByValue(Comparator.naturalOrder()))
|
||||
// Map the sorted entries to ResourcePackStackPacket.Entry
|
||||
.map(entry -> {
|
||||
ResourcePackManifest.Header header = entry.getKey().manifest().header();
|
||||
return new ResourcePackStackPacket.Entry(
|
||||
|
@ -26,6 +26,7 @@
|
||||
package org.geysermc.geyser.pack;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.pack.ResourcePack;
|
||||
import org.geysermc.geyser.pack.option.OptionHolder;
|
||||
|
||||
public record ResourcePackHolder(
|
||||
@ -36,4 +37,8 @@ public record ResourcePackHolder(
|
||||
public static ResourcePackHolder of(GeyserResourcePack pack) {
|
||||
return new ResourcePackHolder(pack, new OptionHolder());
|
||||
}
|
||||
|
||||
public ResourcePack resourcePack() {
|
||||
return this.pack;
|
||||
}
|
||||
}
|
||||
|
@ -130,11 +130,16 @@ public class ResourcePackLoader implements RegistryLoader<Path, Map<UUID, Resour
|
||||
}
|
||||
}
|
||||
|
||||
// Load all remote resource packs before firing the new event
|
||||
packMap.putAll(loadRemotePacks());
|
||||
// Load all remote resource packs from the config before firing the new event
|
||||
// TODO configurate
|
||||
//packMap.putAll(loadRemotePacks());
|
||||
|
||||
GeyserDefineResourcePacksEventImpl defineEvent = new GeyserDefineResourcePacksEventImpl(packMap);
|
||||
GeyserImpl.getInstance().eventBus().fire(defineEvent);
|
||||
|
||||
// After loading the new resource packs: let's clean up the old url packs
|
||||
cleanupRemotePacks();
|
||||
|
||||
return defineEvent.getPacks();
|
||||
}
|
||||
|
||||
@ -249,9 +254,6 @@ public class ResourcePackLoader implements RegistryLoader<Path, Map<UUID, Resour
|
||||
}
|
||||
}
|
||||
|
||||
// After loading the new resource packs: let's clean up the old
|
||||
cleanupRemotePacks();
|
||||
|
||||
return packMap;
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren