Skip to content

Commit 2be686e

Browse files
For maximum laziness, auto convert dropbox texture pack urls into the appropriate form.
1 parent b52430c commit 2be686e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

fCraft/Commands/CpeCommands.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ static void EnvHandler(Player player, CommandReader cmd) {
879879
case "tex":
880880
case "terrain":
881881
case "texture":
882+
FilterURL(ref value);
882883
if (value.CaselessEquals("default")) {
883884
player.Message("Reset texture for {0}&S to {1}", world.ClassyName, Server.DefaultTerrain);
884885
value = "Default";
@@ -891,6 +892,7 @@ static void EnvHandler(Player player, CommandReader cmd) {
891892
} else {
892893
player.Message("Set texture for {0}&S to {1}", world.ClassyName, value);
893894
}
895+
894896
world.Texture = value;
895897
foreach (Player p in world.Players) {
896898
if (p.Supports(CpeExt.EnvMapAspect))
@@ -934,6 +936,17 @@ static void EnvHandler(Player player, CommandReader cmd) {
934936
return;
935937
}
936938
WorldManager.SaveWorldList();
939+
}
940+
941+
static void FilterURL(ref string url) {
942+
// a lot of people try linking to the dropbox page instead of directly to file, so we auto correct them
943+
if (url.StartsWith("http://www.dropbox")) {
944+
url = "http://dl.dropbox" + url.Substring("http://www.dropbox".Length);
945+
url = url.Replace("?dl=0", "");
946+
} else if (url.StartsWith("https://www.dropbox")) {
947+
url = "https://dl.dropbox" + url.Substring("https://www.dropbox".Length);
948+
url = url.Replace("?dl=0", "");
949+
}
937950
}
938951

939952
static void ShowEnvSettings(Player player, World world) {

0 commit comments

Comments
 (0)