Use config.yml + you can now hit enter to search

This commit is contained in:
Telesphoreo 2022-04-13 23:49:12 -05:00
parent 803710b674
commit c4ad009a34
6 changed files with 39 additions and 71 deletions

View File

@ -32,12 +32,12 @@ dependencies {
implementation("org.projectlombok:lombok:1.18.22") implementation("org.projectlombok:lombok:1.18.22")
annotationProcessor("org.projectlombok:lombok:1.18.22") annotationProcessor("org.projectlombok:lombok:1.18.22")
implementation("io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT") implementation("io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT")
implementation("dev.plex:Plex:1.0") implementation("dev.plex:Plex:1.0.2-SNAPSHOT")
implementation("org.json:json:20220320") implementation("org.json:json:20220320")
implementation("org.reflections:reflections:0.10.2") implementation("org.reflections:reflections:0.10.2")
implementation("org.eclipse.jetty:jetty-server:11.0.8") implementation("org.eclipse.jetty:jetty-server:11.0.9")
implementation("org.eclipse.jetty:jetty-servlet:11.0.8") implementation("org.eclipse.jetty:jetty-servlet:11.0.9")
implementation("org.eclipse.jetty:jetty-proxy:11.0.8") implementation("org.eclipse.jetty:jetty-proxy:11.0.9")
implementation("com.github.MilkBowl:VaultAPI:1.7") implementation("com.github.MilkBowl:VaultAPI:1.7")
} }
@ -68,28 +68,6 @@ publishing {
} }
tasks.getByName<Jar>("jar") { tasks.getByName<Jar>("jar") {
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveBaseName.set("Plex-HTTPD") archiveBaseName.set("Plex-HTTPD")
archiveVersion.set("") archiveVersion.set("")
// from("src/main/resources") {
// include("**/**")
// }
// from("src/main/java") {
// include("**/**")
// }
} }
sourceSets {
main {
resources {
srcDirs("src/main/java", "src/main/resources")
include("**/**")
exclude("**/**.java")
}
}
}
tasks.getByName<Copy>("processResources") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

View File

@ -7,8 +7,6 @@ import dev.plex.request.impl.IndefBansEndpoint;
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.util.PlexLog; import dev.plex.util.PlexLog;
import java.io.File;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import lombok.Getter; import lombok.Getter;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
@ -37,7 +35,8 @@ public class HTTPDModule extends PlexModule
@Override @Override
public void load() public void load()
{ {
moduleConfig = new ModuleConfig(this, "settings.yml"); // Move it from /httpd/config.yml to /plugins/Plex/modules/Plex-HTTPD/config.yml
moduleConfig = new ModuleConfig(this, "httpd/config.yml", "config.yml");
} }
@Override @Override

View File

@ -12,14 +12,14 @@ import dev.plex.util.PlexLog;
import dev.plex.util.adapter.LocalDateTimeSerializer; import dev.plex.util.adapter.LocalDateTimeSerializer;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import java.time.LocalDateTime;
import java.util.UUID;
public class PunishmentsEndpoint extends AbstractServlet public class PunishmentsEndpoint extends AbstractServlet
{ {
@GetMapping(endpoint = "/api/punishments/") @GetMapping(endpoint = "/api/punishments/")
@ -32,11 +32,10 @@ public class PunishmentsEndpoint extends AbstractServlet
} }
if (request.getPathInfo() == null) if (request.getPathInfo() == null)
{ {
/*StringBuilder contentBuilder = new StringBuilder(); StringBuilder contentBuilder = new StringBuilder();
PlexLog.log(this.getClass().getClassLoader().getResource("punishments.html").getPath());
try try
{ {
BufferedReader in = new BufferedReader(new FileReader(this.getClass().getClassLoader().getResource("punishments.html").getFile().replace("!", ""))); BufferedReader in = new BufferedReader(new InputStreamReader(Objects.requireNonNull(this.getClass().getResourceAsStream("/httpd/punishments.html"))));
String str; String str;
while ((str = in.readLine()) != null) while ((str = in.readLine()) != null)
{ {
@ -47,24 +46,7 @@ public class PunishmentsEndpoint extends AbstractServlet
catch (IOException ignored) catch (IOException ignored)
{ {
} }
return contentBuilder.toString();*/ return contentBuilder.toString();
return """
<!DOCTYPE html>
<body>
<div style="text-align: center;">
<h2 style="font-family:Helvetica">Enter the UUID or username of the player you want to check</h2>
<input id="test" type="text" autofocus>
<button type="button" onclick="redirect()">Submit</button>
<script>
function redirect() {
var url = document.getElementById('test').value
window.location = "punishments/" + url
}
</script>
</div>
</body>
</html>""";
} }
UUID pathUUID; UUID pathUUID;
String pathPlexPlayer; String pathPlexPlayer;

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<body>
<div style="text-align: center;">
<h2 style="font-family:Helvetica,serif">Enter the UUID or username of the player you want to lookup</h2>
<input type="text"
id="uuid"
autofocus
onkeydown="if (event.keyCode === 13)
document.getElementById('submit').click()"/>
<input type="button"
id="submit"
value="Submit"
onclick="redirect();"/>
<script>
function redirect() {
const url = document.getElementById('uuid').value;
window.location = "punishments/" + url
}
</script>
</div>
</body>
</html>

View File

@ -1,16 +0,0 @@
<!DOCTYPE html>
<body>
<div style="text-align: center;">
<h2 style="font-family:Helvetica">Enter the UUID or username of the player you want to check</h2>
<input id="test" type="text" autofocus>
<button type="button" onclick="redirect()">Submit</button>
<script>
function redirect() {
var url = document.getElementById('test').value
window.location = "punishments/" + url
}
</script>
</div>
</body>
</html>