Ability to disable fetching a list of community servers (#10283)

* Ability to disable fetching a list of community servers

* Addressing review comments
This commit is contained in:
sasha0552
2025-02-04 22:09:27 +03:00
committed by GitHub
parent ede036a918
commit 1ecdcb14f2
4 changed files with 25 additions and 6 deletions

View File

@@ -1242,6 +1242,7 @@ setting.mutemusic.name = Mute Music
setting.sfxvol.name = SFX Volume setting.sfxvol.name = SFX Volume
setting.mutesound.name = Mute Sound setting.mutesound.name = Mute Sound
setting.crashreport.name = Send Anonymous Crash Reports setting.crashreport.name = Send Anonymous Crash Reports
setting.communityservers.name = Fetch Community Server List
setting.savecreate.name = Auto-Create Saves setting.savecreate.name = Auto-Create Saves
setting.steampublichost.name = Public Game Visibility setting.steampublichost.name = Public Game Visibility
setting.playerlimit.name = Player Limit setting.playerlimit.name = Player Limit

View File

@@ -170,3 +170,4 @@ Mythril
hexagon-recursion hexagon-recursion
JasonP01 JasonP01
BlueTheCube BlueTheCube
sasha0552

View File

@@ -138,7 +138,9 @@ public class JoinDialog extends BaseDialog{
refreshLocal(); refreshLocal();
refreshRemote(); refreshRemote();
refreshCommunity(); if(Core.settings.getBool("communityservers", true)){
refreshCommunity();
}
} }
void setupRemote(){ void setupRemote(){
@@ -317,7 +319,9 @@ public class JoinDialog extends BaseDialog{
section(steam ? "@servers.local.steam" : "@servers.local", local, false); section(steam ? "@servers.local.steam" : "@servers.local", local, false);
section("@servers.remote", remote, false); section("@servers.remote", remote, false);
section("@servers.global", global, true); if(Core.settings.getBool("communityservers", true)){
section("@servers.global", global, true);
}
ScrollPane pane = new ScrollPane(hosts); ScrollPane pane = new ScrollPane(hosts);
pane.setFadeScrollBars(false); pane.setFadeScrollBars(false);
@@ -631,12 +635,18 @@ public class JoinDialog extends BaseDialog{
Core.settings.remove("server-list"); Core.settings.remove("server-list");
} }
var urls = Version.type.equals("bleeding-edge") || Vars.forceBeServers ? serverJsonBeURLs : serverJsonURLs; fetchServers();
fetchServers(urls, 0);
} }
private void fetchServers(String[] urls, int index){ public static void fetchServers(){
var urls = Version.type.equals("bleeding-edge") || Vars.forceBeServers ? serverJsonBeURLs : serverJsonURLs;
if(Core.settings.getBool("communityservers", true)){
fetchServers(urls, 0);
}
}
private static void fetchServers(String[] urls, int index){
if(index >= urls.length) return; if(index >= urls.length) return;
//get servers //get servers

View File

@@ -333,6 +333,13 @@ public class SettingsMenuDialog extends BaseDialog{
game.checkPref("crashreport", true); game.checkPref("crashreport", true);
} }
game.checkPref("communityservers", true, val -> {
defaultServers.clear();
if(val){
JoinDialog.fetchServers();
}
});
game.checkPref("savecreate", true); game.checkPref("savecreate", true);
game.checkPref("blockreplace", true); game.checkPref("blockreplace", true);
game.checkPref("conveyorpathfinding", true); game.checkPref("conveyorpathfinding", true);