Skip to content

Commit

Permalink
Fixed PR (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Jan 22, 2024
1 parent dc07e12 commit f26fe8f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/raphimc/viabedrock/ViaBedrock.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void init(final ViaBedrockPlatform platform, final ViaBedrockConfi
ViaBedrock.platform = platform;
ViaBedrock.config = config;

if (config.getEnableResourcePack()) {
if (config.shouldTranslateResourcePacks()) {
try {
ViaBedrock.resourcePackServer = new ResourcePackHttpServer(new InetSocketAddress(config.getResourcePackHost(), config.getResourcePackPort()));
platform.getLogger().log(Level.INFO, "Started resource pack HTTP server on " + resourcePackServer.getUrl());
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/raphimc/viabedrock/ViaBedrockConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class ViaBedrockConfig extends Config implements net.raphimc.viabedrock.platform.ViaBedrockConfig {

private BlobCacheMode blobCacheMode;
private boolean enableResourcePack;
private boolean translateResourcePacks;
private String resourcePackHost;
private int resourcePackPort;
private String resourcePackUrl;
Expand All @@ -46,7 +46,7 @@ public void reload() {

private void loadFields() {
this.blobCacheMode = BlobCacheMode.byName(this.getString("blob-cache", "disk"));
this.enableResourcePack = this.getBoolean("enable-resource-pack", true);
this.translateResourcePacks = this.getBoolean("translate-resource-packs", true);
this.resourcePackHost = this.getString("resource-pack-host", "127.0.0.1");
this.resourcePackPort = this.getInt("resource-pack-port", 0);
this.resourcePackUrl = this.getString("resource-pack-url", "");
Expand All @@ -73,8 +73,8 @@ public BlobCacheMode getBlobCacheMode() {
}

@Override
public boolean getEnableResourcePack() {
return enableResourcePack;
public boolean shouldTranslateResourcePacks() {
return this.translateResourcePacks;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public interface ViaBedrockConfig extends Config {
BlobCacheMode getBlobCacheMode();

/**
* @return Whether we should host a resource pack HTTP server.
* @return If true, starts the resource pack HTTP server and enables resource pack translation
*/
boolean getEnableResourcePack();
boolean shouldTranslateResourcePacks();

/**
* @return The host to use for the resource pack HTTP server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public static void register(final BedrockProtocol protocol) {
wrapper.read(BedrockTypes.STRING); // remote url
}

if (wrapper.user().getProtocolInfo().getProtocolVersion() >= ProtocolConstants.JAVA_VERSION.getVersion()
&& ViaBedrock.config.getEnableResourcePack()) {
if (ViaBedrock.getConfig().shouldTranslateResourcePacks() && wrapper.user().getProtocolInfo().getProtocolVersion() >= ProtocolConstants.JAVA_VERSION.getVersion()) {
final UUID httpToken = UUID.randomUUID();
ViaBedrock.getResourcePackServer().addConnection(httpToken, wrapper.user());

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/viabedrock/viabedrock.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Controls blob caching (Reduces network usage and loading time), Valid options: "disabled", "memory", "disk"
blob-cache: "disk"
# If enabled, starts the resource pack HTTP server and enables resource pack translation
translate-resource-packs: true
# Resource pack HTTP server address
resource-pack-host: 127.0.0.1
# Resource pack HTTP server port (0 = random available port)
Expand Down

0 comments on commit f26fe8f

Please sign in to comment.