diff --git a/.idea/artifacts/CreeperSQL_jar.xml b/.idea/artifacts/CreeperSQL_jar.xml new file mode 100644 index 0000000..057cb1d --- /dev/null +++ b/.idea/artifacts/CreeperSQL_jar.xml @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/out/artifacts/CreeperSQL_jar + + + + + \ No newline at end of file diff --git a/DOCUMENT.MD b/DOCUMENT.MD new file mode 100644 index 0000000..39805b1 --- /dev/null +++ b/DOCUMENT.MD @@ -0,0 +1,97 @@ +# CreeperSQL + +CreeperSQL is a standalone Java MySQL library designed for Minecraft plugins. +It has **no Bukkit/Spigot dependency**, supports automatic configuration reading/creation, and provides simple SQL methods. + +--- + +## Features + +- Pure Java MySQL library +- Automatic configuration file (`plugins/MySQLConnection/config.yml`) creation +- Supports all standard SQL actions: SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, DROP TABLE +- Config must be set or read before connecting +- Simple, intuitive API for plugin developers +- Can be used in any Minecraft plugin project + +--- + +## Installation + +1. Build the CreeperSQL JAR (see Build section). +2. Import the JAR into your plugin project: + - IntelliJ: File → Project Structure → Libraries → `+` → Java → select `CreeperSQL.jar` +3. Add MySQL Connector/J to your project if not included in the JAR. + +--- + +## Usage + +### 1. Set or read configuration + +- **Option 1: Manual configuration** + +Set host, user, password, and database manually: + +CreeperSQL mysql = new CreeperSQL(); +mysql.setConfig("127.0.0.1:3306", "root", "password", "testdb"); + +- **Option 2: Read from config.yml** + +CreeperSQL mysql = new CreeperSQL(); +mysql.readMinecraftConfig(); + +> Note: Config must be fully filled out before connecting. + +--- + +### 2. Connect to the database + +mysql.connect(); + +--- + +### 3. Execute SQL actions + +- `getTables()` → returns a list of table names in the database +- `sqlAction(String sql)` → executes any SQL query, returns a QueryResult object +- `createTable(String sql)` → executes a CREATE TABLE statement +- `dropTable(String tableName)` → drops the specified table +- `insert(String sql)` → executes an INSERT statement +- `update(String sql)` → executes an UPDATE statement +- `delete(String sql)` → executes a DELETE statement +- `close()` → closes the database connection + +--- + +### 4. QueryResult Object + +Returned by `sqlAction()`: + +- `rows` → list of rows (each row is a list of strings) +- `affectedRows` → number of rows affected by INSERT/UPDATE/DELETE +- `error` → error message if SQL failed +- `hasError()` → returns true if there was an error +- `hasRows()` → returns true if the query returned rows + +--- + +## Build Instructions + +1. Open IntelliJ and create a Java project (SDK 17+ recommended) +2. Add `CreeperSQL.java` to `src` +3. Add MySQL Connector/J as a library +4. Create a JAR artifact: + - File → Project Structure → Artifacts → `+` → JAR → From modules with dependencies +5. Build → Build Artifacts → Build +6. The output JAR can now be imported into any Minecraft plugin project + +--- + +## Notes + +- Always call `setConfig()` or `readMinecraftConfig()` **before `connect()`** +- The library is fully standalone and does not depend on Bukkit/Spigot +- For heavy queries, run on an async thread to prevent server lag + +---