cool stuff
This commit is contained in:
parent
2769fbac42
commit
2386ea44a2
4 changed files with 71 additions and 16 deletions
16
README.md
16
README.md
|
@ -1,15 +1 @@
|
||||||
# Skystone
|
# TODO: update this
|
||||||
A PaperMC plugin that turns the whole world into stone platforms. A few extra recipes and things are added for playability.
|
|
||||||
|
|
||||||
Vague inspiration: https://www.curseforge.com/minecraft/mc-mods/dirt-platform
|
|
||||||
|
|
||||||
## Using
|
|
||||||
Download this plugin into the ``plugins`` folder of your PaperMC installation directory. Afterwards, edit bukkit.yml to look something like this:
|
|
||||||
|
|
||||||
```
|
|
||||||
(...)
|
|
||||||
worlds:
|
|
||||||
world:
|
|
||||||
generator: MinzeoPlugin
|
|
||||||
biome-provider: MinzeoPlugin
|
|
||||||
```
|
|
|
@ -27,6 +27,7 @@ dependencies {
|
||||||
|
|
||||||
// This dependency is used by the application.
|
// This dependency is used by the application.
|
||||||
implementation(libs.guava)
|
implementation(libs.guava)
|
||||||
|
implementation("org.json:json:20090211")
|
||||||
|
|
||||||
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
package net.xuyezo.main;
|
package net.xuyezo.main;
|
||||||
|
import com.sun.net.httpserver.HttpServer;
|
||||||
|
import com.sun.net.httpserver.HttpHandler;
|
||||||
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -13,6 +18,7 @@ public class Main extends JavaPlugin {
|
||||||
String host = this.getConfig().getString("dbhost");
|
String host = this.getConfig().getString("dbhost");
|
||||||
String pass = this.getConfig().getString("dbpass");
|
String pass = this.getConfig().getString("dbpass");
|
||||||
String user = this.getConfig().getString("dbuser");
|
String user = this.getConfig().getString("dbuser");
|
||||||
|
|
||||||
Connection c = null;
|
Connection c = null;
|
||||||
try {
|
try {
|
||||||
c = DriverManager
|
c = DriverManager
|
||||||
|
@ -26,6 +32,18 @@ public class Main extends JavaPlugin {
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(new Handler(c), this);
|
Bukkit.getPluginManager().registerEvents(new Handler(c), this);
|
||||||
|
|
||||||
Server server = getServer();
|
Server serverS = getServer();
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpServer server = HttpServer.create(new InetSocketAddress(8787), 0);
|
||||||
|
server.createContext("/messages", new ServHandler(c));
|
||||||
|
|
||||||
|
// Start the server
|
||||||
|
server.setExecutor(null); // Use the default executor
|
||||||
|
server.start();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
50
app/src/main/java/net/xuyezo/main/ServHandler.java
Normal file
50
app/src/main/java/net/xuyezo/main/ServHandler.java
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
package net.xuyezo.main;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
|
import com.sun.net.httpserver.HttpHandler;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
public class ServHandler implements HttpHandler {
|
||||||
|
Connection cc;
|
||||||
|
public ServHandler(Connection c) {
|
||||||
|
this.cc = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(HttpExchange exchange) throws IOException
|
||||||
|
{
|
||||||
|
PreparedStatement stmt;
|
||||||
|
JSONArray outObject = new JSONArray();
|
||||||
|
try {
|
||||||
|
stmt = cc.prepareStatement("SELECT * FROM main.text ORDER BY date DESC");
|
||||||
|
ResultSet rs = stmt.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
|
JSONObject mainObject = new JSONObject();
|
||||||
|
mainObject.put("username", rs.getString("username"));
|
||||||
|
mainObject.put("date", rs.getLong("date"));
|
||||||
|
mainObject.put("content", rs.getString("content"));
|
||||||
|
outObject.add(mainObject);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle the request
|
||||||
|
String response = outObject.toString();
|
||||||
|
exchange.sendResponseHeaders(200, response.length());
|
||||||
|
OutputStream os = exchange.getResponseBody();
|
||||||
|
os.write(response.getBytes());
|
||||||
|
os.close();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue