Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 15:00:11 +01:00
Minor cleanup
Dieser Commit ist enthalten in:
Ursprung
6053b7dae8
Commit
2683b59406
@ -68,7 +68,7 @@ public abstract class PackCodec {
|
|||||||
* @return the new resource pack
|
* @return the new resource pack
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public abstract ResourcePack create();
|
protected abstract ResourcePack create();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new pack provider from the given path.
|
* Creates a new pack provider from the given path.
|
||||||
|
@ -235,10 +235,12 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
|||||||
stackPacket.setExperimentsPreviouslyToggled(false);
|
stackPacket.setExperimentsPreviouslyToggled(false);
|
||||||
stackPacket.setForcedToAccept(false); // Leaving this as false allows the player to choose to download or not
|
stackPacket.setForcedToAccept(false); // Leaving this as false allows the player to choose to download or not
|
||||||
stackPacket.setGameVersion(session.getClientData().getGameVersion());
|
stackPacket.setGameVersion(session.getClientData().getGameVersion());
|
||||||
|
|
||||||
for (ResourcePack pack : this.resourcePackLoadEvent.resourcePacks()) {
|
for (ResourcePack pack : this.resourcePackLoadEvent.resourcePacks()) {
|
||||||
ResourcePackManifest.Header header = pack.manifest().header();
|
ResourcePackManifest.Header header = pack.manifest().header();
|
||||||
stackPacket.getResourcePacks().add(new ResourcePackStackPacket.Entry(header.uuid().toString(), header.version().toString(), ""));
|
stackPacket.getResourcePacks().add(new ResourcePackStackPacket.Entry(header.uuid().toString(), header.version().toString(), ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GeyserImpl.getInstance().getConfig().isAddNonBedrockItems()) {
|
if (GeyserImpl.getInstance().getConfig().isAddNonBedrockItems()) {
|
||||||
// Allow custom items to work
|
// Allow custom items to work
|
||||||
stackPacket.getExperiments().add(new ExperimentData("data_driven_items", true));
|
stackPacket.getExperiments().add(new ExperimentData("data_driven_items", true));
|
||||||
|
@ -84,7 +84,7 @@ public class GeyserPathPackCodec extends PathPackCodec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull ResourcePack create() {
|
protected @NonNull ResourcePack create() {
|
||||||
return ResourcePackLoader.readPack(this.path);
|
return ResourcePackLoader.readPack(this.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,19 +212,20 @@ public class ResourcePackLoader implements RegistryLoader<Path, Map<String, Reso
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, ResourcePack> loadRemotePacks() {
|
private Map<String, ResourcePack> loadRemotePacks() {
|
||||||
|
GeyserImpl instance = GeyserImpl.getInstance();
|
||||||
// Unable to make this a static variable, as the test would fail
|
// Unable to make this a static variable, as the test would fail
|
||||||
final Path cachedCdnPacksDirectory = GeyserImpl.getInstance().getBootstrap().getConfigFolder().resolve("cache").resolve("remote_packs");
|
final Path cachedCdnPacksDirectory = instance.getBootstrap().getConfigFolder().resolve("cache").resolve("remote_packs");
|
||||||
|
|
||||||
if (!Files.exists(cachedCdnPacksDirectory)) {
|
if (!Files.exists(cachedCdnPacksDirectory)) {
|
||||||
try {
|
try {
|
||||||
Files.createDirectories(cachedCdnPacksDirectory);
|
Files.createDirectories(cachedCdnPacksDirectory);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
GeyserImpl.getInstance().getLogger().error("Could not create remote pack cache directory", e);
|
instance.getLogger().error("Could not create remote pack cache directory", e);
|
||||||
return new Object2ObjectOpenHashMap<>();
|
return new Object2ObjectOpenHashMap<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> remotePackUrls = GeyserImpl.getInstance().getConfig().getResourcePackUrls();
|
List<String> remotePackUrls = instance.getConfig().getResourcePackUrls();
|
||||||
Map<String, ResourcePack> packMap = new Object2ObjectOpenHashMap<>();
|
Map<String, ResourcePack> packMap = new Object2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
for (String url : remotePackUrls) {
|
for (String url : remotePackUrls) {
|
||||||
@ -233,8 +234,8 @@ public class ResourcePackLoader implements RegistryLoader<Path, Map<String, Reso
|
|||||||
ResourcePack pack = codec.create();
|
ResourcePack pack = codec.create();
|
||||||
packMap.put(pack.manifest().header().uuid().toString(), pack);
|
packMap.put(pack.manifest().header().uuid().toString(), pack);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.resource_pack.broken", url));
|
instance.getLogger().error(GeyserLocale.getLocaleStringLog("geyser.resource_pack.broken", url));
|
||||||
if (GeyserImpl.getInstance().getLogger().isDebug()) {
|
if (instance.getLogger().isDebug()) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren