mirror of
https://github.com/plexusorg/Module-HTTPD.git
synced 2024-12-22 16:04:59 +00:00
i hate this
This commit is contained in:
parent
82238fa3ed
commit
a0ae4a9720
1 changed files with 32 additions and 12 deletions
|
@ -3,12 +3,15 @@ package dev.plex.request.impl;
|
||||||
import dev.plex.HTTPDModule;
|
import dev.plex.HTTPDModule;
|
||||||
import dev.plex.request.AbstractServlet;
|
import dev.plex.request.AbstractServlet;
|
||||||
import dev.plex.request.GetMapping;
|
import dev.plex.request.GetMapping;
|
||||||
|
import dev.plex.util.PlexLog;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SchematicDownloadEndpoint extends AbstractServlet
|
public class SchematicDownloadEndpoint extends AbstractServlet
|
||||||
{
|
{
|
||||||
|
@ -72,20 +75,37 @@ public class SchematicDownloadEndpoint extends AbstractServlet
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
File[] alphabetical = worldeditFolder.listFiles();
|
for (File worldeditFile : listFilesForFolder(worldeditFolder))
|
||||||
if (alphabetical != null)
|
|
||||||
{
|
{
|
||||||
Arrays.sort(alphabetical);
|
String fixedPath = worldeditFile.getPath().replace("plugins/FastAsyncWorldEdit/schematics/", "");
|
||||||
for (File worldeditFile : alphabetical)
|
fixedPath.replace("plugins/WorldEdit/schematics/", "");
|
||||||
{
|
String sanitizedName = fixedPath.replaceAll("<", "<").replaceAll(">", ">");
|
||||||
String sanitizedName = worldeditFile.getName().replaceAll("<","<").replaceAll(">",">");
|
sb.append(" <tr>\n" +
|
||||||
sb.append(" <tr>\n" +
|
" <th scope=\"row\">\n <a href=\"" + fixedPath + "\" download>" + sanitizedName + "</a>\n </th>\n" +
|
||||||
" <th scope=\"row\">\n <a href=\"" + worldeditFile.getName() + "\" download>" + sanitizedName + "</a>\n </th>\n" +
|
" <td>\n " + formattedSize(worldeditFile.length()) + "\n </td>\n" +
|
||||||
" <td>\n " + formattedSize(worldeditFile.length()) + "\n </td>\n" +
|
" </tr>\n");
|
||||||
" </tr>\n");
|
|
||||||
}
|
|
||||||
file = file.replace("${schematics}", sb.toString());
|
|
||||||
}
|
}
|
||||||
|
file = file.replace("${schematics}", sb.toString());
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<File> files = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<File> listFilesForFolder(final File folder)
|
||||||
|
{
|
||||||
|
for (File fileEntry : folder.listFiles())
|
||||||
|
{
|
||||||
|
if (fileEntry.isDirectory())
|
||||||
|
{
|
||||||
|
PlexLog.debug("Found directory");
|
||||||
|
listFilesForFolder(fileEntry);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
files.add(fileEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlexLog.debug(files.toString());
|
||||||
|
return files;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue