mirror of
https://github.com/plexusorg/Module-HTTPD.git
synced 2024-12-22 16:04:59 +00:00
merge
This commit is contained in:
parent
b6b5a7f227
commit
1a139034b5
10 changed files with 49 additions and 55 deletions
|
@ -8,8 +8,7 @@ import dev.plex.request.impl.IndefBansEndpoint;
|
||||||
import dev.plex.request.impl.IndexEndpoint;
|
import dev.plex.request.impl.IndexEndpoint;
|
||||||
import dev.plex.request.impl.ListEndpoint;
|
import dev.plex.request.impl.ListEndpoint;
|
||||||
import dev.plex.request.impl.PunishmentsEndpoint;
|
import dev.plex.request.impl.PunishmentsEndpoint;
|
||||||
import dev.plex.request.impl.SchematicDownloadEndpoint;
|
import dev.plex.request.impl.SchematicEndpoint;
|
||||||
import dev.plex.request.impl.SchematicIndexEndpoint;
|
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -72,8 +71,7 @@ public class HTTPDModule extends PlexModule
|
||||||
new IndexEndpoint();
|
new IndexEndpoint();
|
||||||
new ListEndpoint();
|
new ListEndpoint();
|
||||||
new PunishmentsEndpoint();
|
new PunishmentsEndpoint();
|
||||||
new SchematicDownloadEndpoint();
|
new SchematicEndpoint();
|
||||||
new SchematicIndexEndpoint();
|
|
||||||
|
|
||||||
server.setConnectors(new Connector[]{connector});
|
server.setConnectors(new Connector[]{connector});
|
||||||
server.setHandler(context);
|
server.setHandler(context);
|
||||||
|
|
|
@ -4,18 +4,17 @@ 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 jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
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.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class SchematicDownloadEndpoint extends AbstractServlet
|
public class SchematicEndpoint extends AbstractServlet
|
||||||
{
|
{
|
||||||
@GetMapping(endpoint = "/api/schematics/download/")
|
@GetMapping(endpoint = "/api/schematics/download/")
|
||||||
public String downloadSchematics(HttpServletRequest request, HttpServletResponse response)
|
public String schematicIndex(HttpServletRequest request, HttpServletResponse response)
|
||||||
{
|
{
|
||||||
if (request.getPathInfo() == null || request.getPathInfo().equals("/"))
|
if (request.getPathInfo() == null || request.getPathInfo().equals("/"))
|
||||||
{
|
{
|
||||||
|
@ -24,9 +23,12 @@ public class SchematicDownloadEndpoint extends AbstractServlet
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OutputStream outputStream = null;
|
OutputStream outputStream = null;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
outputStream = response.getOutputStream();
|
outputStream = response.getOutputStream();
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
schematicServe(request.getPathInfo().replace("/", ""), outputStream);
|
schematicServe(request.getPathInfo().replace("/", ""), outputStream);
|
||||||
|
@ -53,7 +55,10 @@ public class SchematicDownloadEndpoint extends AbstractServlet
|
||||||
private void schematicServe(String requestedSchematic, OutputStream outputStream)
|
private void schematicServe(String requestedSchematic, OutputStream outputStream)
|
||||||
{
|
{
|
||||||
File worldeditFolder = getWorldeditFolder();
|
File worldeditFolder = getWorldeditFolder();
|
||||||
if (worldeditFolder == null) return;
|
if (worldeditFolder == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
File[] schems = worldeditFolder.listFiles();
|
File[] schems = worldeditFolder.listFiles();
|
||||||
if (schems != null)
|
if (schems != null)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +68,10 @@ public class SchematicDownloadEndpoint extends AbstractServlet
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
outputStream.write(HTTPDModule.fileCache.getFile(schemFile));
|
outputStream.write(HTTPDModule.fileCache.getFile(schemFile));
|
||||||
} catch (IOException ignored) {}
|
}
|
||||||
|
catch (IOException ignored)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +80,10 @@ public class SchematicDownloadEndpoint extends AbstractServlet
|
||||||
{
|
{
|
||||||
String file = readFile(this.getClass().getResourceAsStream("/httpd/schematic_list.html"));
|
String file = readFile(this.getClass().getResourceAsStream("/httpd/schematic_list.html"));
|
||||||
File worldeditFolder = getWorldeditFolder();
|
File worldeditFolder = getWorldeditFolder();
|
||||||
if (worldeditFolder == null) return null;
|
if (worldeditFolder == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
File[] alphabetical = worldeditFolder.listFiles();
|
File[] alphabetical = worldeditFolder.listFiles();
|
||||||
if (alphabetical != null)
|
if (alphabetical != null)
|
|
@ -1,15 +0,0 @@
|
||||||
package dev.plex.request.impl;
|
|
||||||
|
|
||||||
import dev.plex.request.AbstractServlet;
|
|
||||||
import dev.plex.request.GetMapping;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
public class SchematicIndexEndpoint extends AbstractServlet
|
|
||||||
{
|
|
||||||
@GetMapping(endpoint = "/api/schematics/")
|
|
||||||
public String schematicIndex(HttpServletRequest request, HttpServletResponse response)
|
|
||||||
{
|
|
||||||
return readFile(this.getClass().getResourceAsStream("/httpd/schematic_list.html"));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,16 +26,16 @@
|
||||||
<a class="nav-link active" aria-current="page" href="#">Admins</a>
|
<a class="nav-link active" aria-current="page" href="#">Admins</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="indefbans/">Indefinite Bans</a>
|
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="list/">List</a>
|
<a class="nav-link" href="/api/list/">List</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="punishments/">Punishments</a>
|
<a class="nav-link" href="/api/punishments/">Punishments</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="schematics/">Schematics</a>
|
<a class="nav-link" href="/api/schematics/">Schematics</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -23,19 +23,19 @@
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="api/admins/">Admins</a>
|
<a class="nav-link" href="/api/admins/">Admins</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="api/indefbans/">Indefinite Bans</a>
|
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="api/list/">List</a>
|
<a class="nav-link" href="/api/list/">List</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="api/punishments/">Punishments</a>
|
<a class="nav-link" href="/api/punishments/">Punishments</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="schematics/">Schematics</a>
|
<a class="nav-link" href="/api/schematics/">Schematics</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -23,19 +23,19 @@
|
||||||
<a class="nav-link" href="/">Home</a>
|
<a class="nav-link" href="/">Home</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="admins/">Admins</a>
|
<a class="nav-link" href="/api/admins/">Admins</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="indefbans/">Indefinite Bans</a>
|
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="list/">List</a>
|
<a class="nav-link" href="/api/list/">List</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
|
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="schematics/">Schematics</a>
|
<a class="nav-link" href="/api/schematics/">Schematics</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -23,19 +23,19 @@
|
||||||
<a class="nav-link" href="/">Home</a>
|
<a class="nav-link" href="/">Home</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="../admins/">Admins</a>
|
<a class="nav-link" href="/api/admins/">Admins</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="../indefbans/">Indefinite Bans</a>
|
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="../list/">List</a>
|
<a class="nav-link" href="/api/list/">List</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
|
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="schematics/">Schematics</a>
|
<a class="nav-link" href="/api/schematics/">Schematics</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -23,19 +23,19 @@
|
||||||
<a class="nav-link" href="/">Home</a>
|
<a class="nav-link" href="/">Home</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="../admins/">Admins</a>
|
<a class="nav-link" href="/api/admins/">Admins</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="../indefbans/">Indefinite Bans</a>
|
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="../list/">List</a>
|
<a class="nav-link" href="/api/list/">List</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
|
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="schematics/">Schematics</a>
|
<a class="nav-link" href="/api/schematics/">Schematics</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,13 +26,13 @@
|
||||||
<a class="nav-link" href="#">Admins</a>
|
<a class="nav-link" href="#">Admins</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="indefbans/">Indefinite Bans</a>
|
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="list/">List</a>
|
<a class="nav-link" href="/api/list/">List</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="punishments/">Punishments</a>
|
<a class="nav-link" href="/api/punishments/">Punishments</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" aria-current="page" href="#">Schematics</a>
|
<a class="nav-link active" aria-current="page" href="#">Schematics</a>
|
||||||
|
|
|
@ -26,13 +26,13 @@
|
||||||
<a class="nav-link" href="#">Admins</a>
|
<a class="nav-link" href="#">Admins</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="indefbans/">Indefinite Bans</a>
|
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="list/">List</a>
|
<a class="nav-link" href="/api/list/">List</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="punishments/">Punishments</a>
|
<a class="nav-link" href="/api/punishments/">Punishments</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" aria-current="page" href="#">Schematics</a>
|
<a class="nav-link active" aria-current="page" href="#">Schematics</a>
|
||||||
|
|
Loading…
Reference in a new issue