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