Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions common/src/main/java/de/the_build_craft/maplink/common/HTTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
* @author Leander Knüttel
* @author eatmyvenom
* @author yqs112358
* @version 07.01.2026
* @author Ömer Ferhat Şenel
* @version 13.01.2026
*/
public class HTTP {
private static final int TIMEOUT_MS = 10_000;
Expand Down Expand Up @@ -93,11 +94,19 @@ public static HttpURLConnection openHTTPConnection(URL url, String contentType)
HttpURLConnection request = (HttpURLConnection) url.openConnection();
request.setRequestMethod("GET");
request.setRequestProperty("Accept", contentType);
request.setRequestProperty("User-Agent", AbstractModInitializer.MOD_NAME);
request.setRequestProperty("User-Agent",
!config.general.userAgent.isEmpty() ? config.general.userAgent : AbstractModInitializer.MOD_NAME);
request.setInstanceFollowRedirects(true);
request.setConnectTimeout(TIMEOUT_MS);
request.setReadTimeout(TIMEOUT_MS);

// add cf_clearance if user defined it
// this is to "bypass" Cloudflare's bot protection. it uses a already verified cookie from Cloudflare.
if (!config.general.cloudflareClearanceCookie.isEmpty()) {
request.setRequestProperty("Cookie",
String.format("cf_clearance=%s", config.general.cloudflareClearanceCookie));
}

// completely insecure and should normally not be used!
if (config.general.ignoreCertificatesUseAtYourOwnRisk && request instanceof HttpsURLConnection) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@

/**
* @author Leander Knüttel
* @version 02.01.2026
* @author Ömer Ferhat Şenel
* @version 13.01.2026
*/
@Config(name = "maplink")
#if MC_VER < MC_1_20_6
Expand Down Expand Up @@ -207,6 +208,12 @@ public static class General implements ConfigData {

public boolean chatLogInDebugMode = false;

@ConfigEntry.Gui.Tooltip
public String userAgent = "";

@ConfigEntry.Gui.Tooltip
public String cloudflareClearanceCookie = "";

@ConfigEntry.Gui.Excluded
public boolean ignoreCertificatesUseAtYourOwnRisk = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

import de.the_build_craft.maplink.common.wrappers.Text;
import me.shedaniel.clothconfig2.api.*;
import me.shedaniel.clothconfig2.gui.entries.*;
import me.shedaniel.clothconfig2.gui.entries.BooleanListEntry;
import me.shedaniel.clothconfig2.gui.entries.MultiElementListEntry;
import me.shedaniel.clothconfig2.gui.entries.NestedListListEntry;
import me.shedaniel.clothconfig2.gui.entries.TooltipListEntry;
import me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerData;
Expand All @@ -34,15 +37,19 @@
#endif
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static de.the_build_craft.maplink.common.CommonModConfig.config;

/**
* @author Leander Knüttel
* @version 02.01.2026
* @author Ömer Ferhat Şenel
* @version 13.01.2026
*/
@SuppressWarnings({"UnstableApiUsage", "rawtypes"})
public class ModConfigGui {
Expand Down Expand Up @@ -184,7 +191,9 @@ public static ConfigBuilder getConfigBuilder() {
SubCategoryBuilder devOptions = entryBuilder.startSubCategory(Text.translatable("maplink.option.general.debugMode.@PrefixText"));
devOptions.addAll(Arrays.asList(
entryBuilder.startBooleanToggle(Text.translatable("maplink.option.general.debugMode"), config.general.debugMode).setDefaultValue(defaultConfig.general.debugMode).setSaveConsumer(b -> config.general.debugMode = b).build(),
entryBuilder.startBooleanToggle(Text.translatable("maplink.option.general.chatLogInDebugMode"), config.general.chatLogInDebugMode).setDefaultValue(defaultConfig.general.debugMode).setSaveConsumer(b -> config.general.chatLogInDebugMode = b).build()
entryBuilder.startBooleanToggle(Text.translatable("maplink.option.general.chatLogInDebugMode"), config.general.chatLogInDebugMode).setDefaultValue(defaultConfig.general.debugMode).setSaveConsumer(b -> config.general.chatLogInDebugMode = b).build(),
entryBuilder.startStrField(Text.translatable("maplink.option.general.userAgent"), config.general.userAgent).setDefaultValue(defaultConfig.general.userAgent).setSaveConsumer(s -> config.general.userAgent = s).build(),
entryBuilder.startStrField(Text.translatable("maplink.option.general.cloudflareClearanceCookie"), config.general.cloudflareClearanceCookie).setDefaultValue(defaultConfig.general.cloudflareClearanceCookie).setSaveConsumer(s -> config.general.cloudflareClearanceCookie = s).build()
));
autoTooltip(devOptions);
general.addEntry(devOptions.build());
Expand Down
4 changes: 4 additions & 0 deletions common/src/main/resources/assets/maplink/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
"maplink.option.general.debugMode": "Debug Mode",
"maplink.option.general.debugMode.@PrefixText": "Dev Options - please ignore",
"maplink.option.general.chatLogInDebugMode": "Chat Logs in Debug Mode - Chat Spam...",
"maplink.option.general.userAgent": "HTTP User Agent",
"maplink.option.general.userAgent.@Tooltip": "This is used to change user agent of requests.",
"maplink.option.general.cloudflareClearanceCookie": "Cloudflare Clearance Cookie",
"maplink.option.general.cloudflareClearanceCookie.@Tooltip": "You don't need this unless map website is protected with Cloudflare. The user agent that used to get this cookie MUST match with the user agent above.",


"maplink.option.ServerEntry": "Server Entry",
Expand Down