cool stuff

This commit is contained in:
biglyderv 2025-02-07 11:20:44 -05:00
parent 2769fbac42
commit 2386ea44a2
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
4 changed files with 71 additions and 16 deletions

View file

@ -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
```

View file

@ -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")
} }

View file

@ -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();
}
} }
} }

View 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();
}
}