diff --git a/src/main/java/uk/betacraft/legacyfix/LegacyFixAgent.java b/src/main/java/uk/betacraft/legacyfix/LegacyFixAgent.java index e36ab95..a947c7c 100644 --- a/src/main/java/uk/betacraft/legacyfix/LegacyFixAgent.java +++ b/src/main/java/uk/betacraft/legacyfix/LegacyFixAgent.java @@ -78,4 +78,8 @@ public static boolean isDebug() { public static String getGameDir() { return getSettings().containsKey("lf.gameDir") ? (String) getSettings().get("lf.gameDir") : "minecraft"; } + + public static String getAssetsDir() { + return getSettings().containsKey("lf.assetsDir") ? (String) getSettings().get("lf.assetsDir") : "assets"; + } } diff --git a/src/main/java/uk/betacraft/legacyfix/protocol/http/Handler.java b/src/main/java/uk/betacraft/legacyfix/protocol/http/Handler.java index c2cfaa8..6441c81 100644 --- a/src/main/java/uk/betacraft/legacyfix/protocol/http/Handler.java +++ b/src/main/java/uk/betacraft/legacyfix/protocol/http/Handler.java @@ -25,7 +25,8 @@ public class Handler extends URLStreamHandler { BetaAntiPiracyHandler.class, LevelListHandler.class, LevelSaveHandler.class, - LevelLoadHandler.class + LevelLoadHandler.class, + Minecraft1_6AvailableHandler.class ); @Override diff --git a/src/main/java/uk/betacraft/legacyfix/protocol/impl/LevelListHandler.java b/src/main/java/uk/betacraft/legacyfix/protocol/impl/LevelListHandler.java index 8167097..0693983 100644 --- a/src/main/java/uk/betacraft/legacyfix/protocol/impl/LevelListHandler.java +++ b/src/main/java/uk/betacraft/legacyfix/protocol/impl/LevelListHandler.java @@ -10,10 +10,12 @@ @SuppressWarnings("all") public class LevelListHandler extends HandlerBase { - public static final String EMPTY_LEVEL = "-"; - protected static final String LEVELS_DIR_PATH = System.getProperty("lf.levelsDir", LegacyFixAgent.getGameDir() + "/levels"); private static final Pattern LEVEL_LIST_PATTERN = Pattern.compile("(http:\\/\\/(www\\.)?minecraft\\.net(:(.+)?)?\\/game\\/listmaps\\.jsp\\?user=(.+)?)"); + protected static final String LEVELS_DIR_PATH = System.getProperty("lf.levelsDir", LegacyFixAgent.getGameDir() + "/levels"); + + public static final String EMPTY_LEVEL = "-"; + public LevelListHandler(URL u, Pattern patternUsed) { super(u, patternUsed); } diff --git a/src/main/java/uk/betacraft/legacyfix/protocol/impl/Minecraft1_6AvailableHandler.java b/src/main/java/uk/betacraft/legacyfix/protocol/impl/Minecraft1_6AvailableHandler.java new file mode 100644 index 0000000..54287f9 --- /dev/null +++ b/src/main/java/uk/betacraft/legacyfix/protocol/impl/Minecraft1_6AvailableHandler.java @@ -0,0 +1,37 @@ +package uk.betacraft.legacyfix.protocol.impl; + +import uk.betacraft.legacyfix.LegacyFixAgent; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; + +@SuppressWarnings("all") +public class Minecraft1_6AvailableHandler extends HandlerBase { + private static final Pattern FLAG_PATTERN = Pattern.compile("(http:\\/\\/assets\\.minecraft\\.net\\/1_6_has_been_released\\.flag)"); + + private static final boolean SHOW_NOTICE = "true".equals(LegacyFixAgent.getSettings().get("lf.showNotice")); + + public Minecraft1_6AvailableHandler(URL u, Pattern patternUsed) { + super(u, patternUsed); + + byte[] response; + if (SHOW_NOTICE) { + response = "https://web.archive.org/web/20130702232237if_/https://mojang.com/2013/07/minecraft-the-horse-update/".getBytes(); + } else { + response = new byte[0]; + } + + this.stream = new ByteArrayInputStream(response); + } + + public static List regexPatterns() { + return Arrays.asList( + FLAG_PATTERN + ); + } +}