Initial commit
This commit is contained in:
113
Plugins/Webpanel/.gitignore
vendored
Normal file
113
Plugins/Webpanel/.gitignore
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
target/
|
||||
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
.flattened-pom.xml
|
||||
|
||||
# Common working directory
|
||||
run/
|
||||
74
Plugins/Webpanel/pom.xml
Normal file
74
Plugins/Webpanel/pom.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>de.craftix</groupId>
|
||||
<artifactId>Serverpanel</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Serverpanel</name>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc-repo</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<!-- <scope>provided</scope> -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,52 @@
|
||||
package de.craftix.serverpanel;
|
||||
|
||||
import de.craftix.serverpanel.utils.WebFileManager;
|
||||
import de.craftix.serverpanel.utils.WebServerManager;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class Serverpanel {
|
||||
public static void main(String[] args) {
|
||||
new Serverpanel().onEnable();
|
||||
}
|
||||
|
||||
private static Serverpanel instance;
|
||||
private static WebServerManager webServerManager;
|
||||
private static WebFileManager webFileManager;
|
||||
|
||||
public static List<String> log = new ArrayList<>();
|
||||
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
webServerManager = new WebServerManager(40);
|
||||
webFileManager = new WebFileManager();
|
||||
webServerManager.getServer().start();
|
||||
log.add("Server started successfully");
|
||||
}
|
||||
|
||||
public static byte[] getFileContent(String fileName) {
|
||||
try {
|
||||
return Files.readAllBytes(new File("src/main/resources/" + fileName).toPath());
|
||||
}catch (Exception e) {
|
||||
System.err.println("Client tried to access invalid path: " + fileName);
|
||||
}
|
||||
return getFileContent("index.html");
|
||||
}
|
||||
|
||||
public static String getLogContents() {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (String s : log) {
|
||||
out.insert(0, s + "<br>");
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static Serverpanel getInstance() { return instance; }
|
||||
|
||||
public static WebServerManager getWebServerManager() { return webServerManager; }
|
||||
|
||||
public static WebFileManager getWebFileManager() { return webFileManager; }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package de.craftix.serverpanel.utils;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
import de.craftix.serverpanel.Serverpanel;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Console implements HttpHandler {
|
||||
|
||||
public static String getLog() { return Serverpanel.getLogContents(); }
|
||||
|
||||
public static void sendCommand(String command) { Serverpanel.log.add(command); }
|
||||
|
||||
@Override
|
||||
public void handle(HttpExchange exchange) throws IOException {
|
||||
if (exchange.getRequestURI().getPath().equals("/console_send")) {
|
||||
sendCommand(exchange.getRequestURI().getQuery());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package de.craftix.serverpanel.utils;
|
||||
|
||||
import com.sun.net.httpserver.BasicAuthenticator;
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
import de.craftix.serverpanel.Serverpanel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class WebFileManager implements HttpHandler {
|
||||
private BasicAuthenticator authenticator;
|
||||
|
||||
public WebFileManager() {
|
||||
load();
|
||||
authenticator = new BasicAuthenticator("get") {
|
||||
@Override
|
||||
public boolean checkCredentials(String username, String password) {
|
||||
return username.equals("leon.hoppe") && password.equals("1234567890");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void load() {
|
||||
Serverpanel.getWebServerManager().getServer().createContext("/", this).setAuthenticator(authenticator);
|
||||
Serverpanel.getWebServerManager().getServer().createContext("/console_send", new Console()).setAuthenticator(authenticator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(HttpExchange exchange) throws IOException {
|
||||
String path = exchange.getRequestURI().getPath();
|
||||
byte[] response = Serverpanel.getFileContent(exchange.getRequestURI().getPath());
|
||||
if (!path.endsWith(".png")) {
|
||||
String out = new String(response);
|
||||
out = out.replace("%console_view%", Console.getLog());
|
||||
response = out.getBytes();
|
||||
}
|
||||
exchange.sendResponseHeaders(200, response.length);
|
||||
OutputStream out = exchange.getResponseBody();
|
||||
out.write(response);
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package de.craftix.serverpanel.utils;
|
||||
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
public class WebServerManager {
|
||||
|
||||
private HttpServer server;
|
||||
|
||||
public WebServerManager(int port) {
|
||||
try {
|
||||
server = HttpServer.create(new InetSocketAddress(port), 0);
|
||||
}catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
|
||||
public void stop() { server.stop(0); }
|
||||
|
||||
public HttpServer getServer() { return server; }
|
||||
}
|
||||
BIN
Plugins/Webpanel/src/main/resources/background.png
Normal file
BIN
Plugins/Webpanel/src/main/resources/background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 808 KiB |
47
Plugins/Webpanel/src/main/resources/console.html
Normal file
47
Plugins/Webpanel/src/main/resources/console.html
Normal file
@@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Webpanel</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="index.html">Startseite</a></li>
|
||||
<li><a href="console.html">Konsole</a></li>
|
||||
<li><a>Account</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div>
|
||||
<h1>Konsole</h1>
|
||||
<section id="console_send"></section>
|
||||
<form>
|
||||
<input type="text" placeholder=">" id="command">
|
||||
<input type="button" value="Senden" id="send">
|
||||
</form>
|
||||
<section id="console_view"></section>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function updateConsole() {
|
||||
$('#console_view').load("console_view.html");
|
||||
}
|
||||
$(document).ready(function () {
|
||||
updateConsole();
|
||||
window.setInterval("updateConsole()", 2000);
|
||||
})
|
||||
$('#send').click(function () {
|
||||
const cmd = $('#command');
|
||||
$('#console_send').load('console_send?' + cmd.val());
|
||||
cmd.val("");
|
||||
updateConsole();
|
||||
})
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
1
Plugins/Webpanel/src/main/resources/console_view.html
Normal file
1
Plugins/Webpanel/src/main/resources/console_view.html
Normal file
@@ -0,0 +1 @@
|
||||
<P>%console_view%</P>
|
||||
59
Plugins/Webpanel/src/main/resources/index.html
Normal file
59
Plugins/Webpanel/src/main/resources/index.html
Normal file
@@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Webpanel</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="index.html">Startseite</a></li>
|
||||
<li><a href="console.html">Konsole</a></li>
|
||||
<li><a>Account</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div>
|
||||
<h1>Statistiken</h1>
|
||||
<p>Spieler Rekorde der letzten Woche!</p>
|
||||
<canvas id="playeronline_chart" width="100%" height="40"></canvas>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
const canvas = document.getElementById("playeronline_chart");
|
||||
const data = {
|
||||
labels: ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"],
|
||||
datasets: [
|
||||
{
|
||||
label: "Spieler Online",
|
||||
backgroundColor: "rgba(33, 150, 243, 0.5)",
|
||||
borderColor: "rgba(33, 150, 243, 1)",
|
||||
borderWidth: 2,
|
||||
hoverBackgroundColor: "rgba(33, 150, 243, 1)",
|
||||
hoverBorderColor: "rgba(33, 150, 243, 0.5)",
|
||||
data: [65, 59, 30, 81, 56, 55, 40]
|
||||
}
|
||||
]
|
||||
};
|
||||
const option = {
|
||||
animation: {
|
||||
duration: 1000
|
||||
}
|
||||
};
|
||||
Chart.defaults.global.defaultFontColor = '#fff';
|
||||
Chart.defaults.global.legend.display = false;
|
||||
|
||||
Chart.Bar(canvas, {
|
||||
data: data,
|
||||
options: option
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
3
Plugins/Webpanel/src/main/resources/plugin.yml
Normal file
3
Plugins/Webpanel/src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
name: Serverpanel
|
||||
version: '${project.version}'
|
||||
main: de.craftix.serverpanel.Serverpanel
|
||||
90
Plugins/Webpanel/src/main/resources/style.css
Normal file
90
Plugins/Webpanel/src/main/resources/style.css
Normal file
@@ -0,0 +1,90 @@
|
||||
@import url('https://fonts.googleapis.com/css?family=Fjalla+One');
|
||||
|
||||
* {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: "Fjalla One", Arial;
|
||||
}
|
||||
|
||||
body, html {
|
||||
background-image: url("background.png");
|
||||
background-attachment: fixed;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
/* Navigation */
|
||||
|
||||
nav {
|
||||
background-color: rgba(17,17,17,0.5);
|
||||
padding-top: 20px;
|
||||
padding-bottom: 20px;
|
||||
min-width: 100%;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
nav ul li {
|
||||
text-align: left;
|
||||
list-style: none;
|
||||
display: inline-block;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
nav ul li a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
transition: 200ms;
|
||||
}
|
||||
|
||||
nav ul li a:hover {
|
||||
color: cyan;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Content */
|
||||
|
||||
div {
|
||||
background-color: rgba(17, 17, 17, 0.5);
|
||||
min-width: calc(100% - 40px);
|
||||
padding: 20px;
|
||||
top: 100px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
div h1 {
|
||||
color: white;
|
||||
font-size: 30px;
|
||||
margin-bottom: 30px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
div p {
|
||||
color: white;
|
||||
}
|
||||
|
||||
input[type=text] {
|
||||
width: 84%;
|
||||
padding: 12px 20px;
|
||||
margin: 8px 0;
|
||||
display: inline-block;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
input[type=button] {
|
||||
width: 15%;
|
||||
background-color: #039BE5;
|
||||
color: white;
|
||||
padding: 14px 20px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
transition: 200ms;
|
||||
}
|
||||
|
||||
input[type=button]:hover {
|
||||
background-color: #03A9F4;
|
||||
cursor: pointer;
|
||||
}
|
||||
Reference in New Issue
Block a user