mirror of
https://github.com/plexusorg/Module-HTTPD.git
synced 2024-10-31 17:37:10 +00:00
Start work on schematics
This commit is contained in:
parent
2ce0a1e698
commit
ef5ff6b540
@ -7,6 +7,7 @@ import dev.plex.request.impl.IndefBansEndpoint;
|
||||
import dev.plex.request.impl.IndexEndpoint;
|
||||
import dev.plex.request.impl.ListEndpoint;
|
||||
import dev.plex.request.impl.PunishmentsEndpoint;
|
||||
import dev.plex.request.impl.SchematicDownloadEndpoint;
|
||||
import dev.plex.util.PlexLog;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import lombok.Getter;
|
||||
@ -67,6 +68,7 @@ public class HTTPDModule extends PlexModule
|
||||
new IndexEndpoint();
|
||||
new ListEndpoint();
|
||||
new PunishmentsEndpoint();
|
||||
new SchematicDownloadEndpoint();
|
||||
|
||||
server.setConnectors(new Connector[]{connector});
|
||||
server.setHandler(context);
|
||||
|
@ -0,0 +1,50 @@
|
||||
package dev.plex.request.impl;
|
||||
|
||||
import dev.plex.request.AbstractServlet;
|
||||
import dev.plex.request.GetMapping;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class SchematicDownloadEndpoint extends AbstractServlet
|
||||
{
|
||||
@GetMapping(endpoint = "/api/schematics/download/")
|
||||
public String downloadSchematics(HttpServletRequest request)
|
||||
{
|
||||
return schematicHTML();
|
||||
}
|
||||
|
||||
private String schematicHTML()
|
||||
{
|
||||
String file = readFile(this.getClass().getResourceAsStream("/httpd/schematic_list.html"));
|
||||
File worldeditFolder;
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit"))
|
||||
{
|
||||
worldeditFolder = new File(Bukkit.getPluginManager().getPlugin("WorldEdit").getDataFolder() + "/schematics/");
|
||||
}
|
||||
else if (Bukkit.getPluginManager().isPluginEnabled("FastAsyncWorldEdit"))
|
||||
{
|
||||
worldeditFolder = new File(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit").getDataFolder() + "/schematics/");
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
File[] alphabetical = worldeditFolder.listFiles();
|
||||
if (alphabetical != null)
|
||||
{
|
||||
Arrays.sort(alphabetical);
|
||||
}
|
||||
for (File worldeditFile : alphabetical)
|
||||
{
|
||||
sb.append("<tr>" +
|
||||
"<th scope=\"row\">" + worldeditFile.getName() + "</th>" +
|
||||
"<td>" + worldeditFile.length() + "B" + "</td>" +
|
||||
"</tr>");
|
||||
}
|
||||
file = file.replace("${schematics}", sb.toString());
|
||||
return file;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package dev.plex.request.impl;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import dev.plex.request.AbstractServlet;
|
||||
import dev.plex.request.GetMapping;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SchematicIndexEndpoint extends AbstractServlet
|
||||
{
|
||||
@GetMapping(endpoint = "/api/list/")
|
||||
public String schematicIndex(HttpServletRequest request)
|
||||
{
|
||||
}
|
||||
}
|
@ -32,7 +32,10 @@
|
||||
<a class="nav-link" href="list/">List</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="punishments">Punishments</a>
|
||||
<a class="nav-link" href="punishments/">Punishments</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="schematics/">Schematics</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -32,7 +32,10 @@
|
||||
<a class="nav-link" href="../list/">List</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="../punishments">Punishments</a>
|
||||
<a class="nav-link" href="../punishments/">Punishments</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="schematics/">Schematics</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -32,7 +32,10 @@
|
||||
<a class="nav-link" href="api/list/">List</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="api/punishments">Punishments</a>
|
||||
<a class="nav-link" href="api/punishments/">Punishments</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="schematics/">Schematics</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -34,6 +34,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="schematics/">Schematics</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -34,6 +34,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="schematics/">Schematics</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -34,6 +34,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="schematics/">Schematics</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
60
src/main/resources/httpd/schematic_index.html
Normal file
60
src/main/resources/httpd/schematic_index.html
Normal file
@ -0,0 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
|
||||
crossorigin="anonymous"></script>
|
||||
<title>Schematics - Plex HTTPD</title>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">Plex HTTPD</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Admins</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="indefbans/">Indefinite Bans</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="list/">List</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="punishments/">Punishments</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Schematics</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div style="text-align: center;" class="col-auto m-0 row justify-content-center p-4">
|
||||
<h2>Plex HTTPD</h2>
|
||||
<h5>A list of schematics is below. You can click on the schematic name to download it.</h5>
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Name</th>
|
||||
<th scope="col">Size</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${schematics}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
53
src/main/resources/httpd/schematic_list.html
Normal file
53
src/main/resources/httpd/schematic_list.html
Normal file
@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
|
||||
crossorigin="anonymous"></script>
|
||||
<title>Schematic Download - Plex HTTPD</title>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">Plex HTTPD</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Admins</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="indefbans/">Indefinite Bans</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="list/">List</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="punishments/">Punishments</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Schematics</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div style="text-align: center;" class="col-auto m-0 row justify-content-center p-4">
|
||||
<h2>Plex HTTPD</h2>
|
||||
<h5>Welcome to the schematic page. Please select if you would like to download or upload a schematic.</h5>
|
||||
<div class="d-grid gap-2 col-2 mx-auto">
|
||||
<button type="button" class="btn btn-success btn-sm p-2">Download</button>
|
||||
<button type="button" class="btn btn-primary btn-sm p-2">Upload</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user