Skip to content

Commit

Permalink
Ability to disable fetching a list of community servers (#10283)
Browse files Browse the repository at this point in the history
* Ability to disable fetching a list of community servers

* Addressing review comments
  • Loading branch information
sasha0552 authored Feb 4, 2025
1 parent ede036a commit 1ecdcb1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/assets/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,7 @@ setting.mutemusic.name = Mute Music
setting.sfxvol.name = SFX Volume
setting.mutesound.name = Mute Sound
setting.crashreport.name = Send Anonymous Crash Reports
setting.communityservers.name = Fetch Community Server List
setting.savecreate.name = Auto-Create Saves
setting.steampublichost.name = Public Game Visibility
setting.playerlimit.name = Player Limit
Expand Down
1 change: 1 addition & 0 deletions core/assets/contributors
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,4 @@ Mythril
hexagon-recursion
JasonP01
BlueTheCube
sasha0552
18 changes: 14 additions & 4 deletions core/src/mindustry/ui/dialogs/JoinDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ void refreshAll(){

refreshLocal();
refreshRemote();
refreshCommunity();
if(Core.settings.getBool("communityservers", true)){
refreshCommunity();
}
}

void setupRemote(){
Expand Down Expand Up @@ -317,7 +319,9 @@ void setup(){

section(steam ? "@servers.local.steam" : "@servers.local", local, 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);
pane.setFadeScrollBars(false);
Expand Down Expand Up @@ -631,12 +635,18 @@ private void loadServers(){
Core.settings.remove("server-list");
}

fetchServers();
}

public static void fetchServers(){
var urls = Version.type.equals("bleeding-edge") || Vars.forceBeServers ? serverJsonBeURLs : serverJsonURLs;

fetchServers(urls, 0);
if(Core.settings.getBool("communityservers", true)){
fetchServers(urls, 0);
}
}

private void fetchServers(String[] urls, int index){
private static void fetchServers(String[] urls, int index){
if(index >= urls.length) return;

//get servers
Expand Down
7 changes: 7 additions & 0 deletions core/src/mindustry/ui/dialogs/SettingsMenuDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,13 @@ void addSettings(){
game.checkPref("crashreport", true);
}

game.checkPref("communityservers", true, val -> {
defaultServers.clear();
if(val){
JoinDialog.fetchServers();
}
});

game.checkPref("savecreate", true);
game.checkPref("blockreplace", true);
game.checkPref("conveyorpathfinding", true);
Expand Down

0 comments on commit 1ecdcb1

Please sign in to comment.