· 5 years ago · Jun 06, 2020, 04:42 AM
1public class WarningSQL extends MySQL {
2
3 public WarningSQL() {
4 super(TLBWarnings.get().getConfig().getString("sql.host"), TLBWarnings.get().getConfig().getString("sql.database"), TLBWarnings.get().getConfig().getString("sql.username"), TLBWarnings.get().getConfig().getString("sql.password"));
5 }
6
7 public void warn(OfflinePlayer p, WarningCategory category, String notes) {
8 SQLColumn[] sqlColumns = {
9 new SQLColumn("id", "NOT NULL AUTO_INCREMENT"),
10 new SQLColumn("category", "VARCHAR(255)"),
11 new SQLColumn("date", "VARCHAR(255)"),
12 new SQLColumn("notes", "VARCHAR(255)")
13 };
14 getHelper().createTable(p.getUniqueId().toString(), true, sqlColumns);
15
16// "CREATE TABLE IF NOT EXISTS name (id NOT NULL AUTO_INCREMENT, category VARCHAR(255), date VARCHAR(255), notes VARCHAR(255)"
17
18 SQLColumn[] adjusted = {
19 new SQLColumn("category", category.getCategory())
20 };
21
22 getHelper().insert(p.getUniqueId().toString(), false, true, adjusted, category.getCategory());
23// VALUESSB ""
24// SQLSB "INSERT INTO name (category) VALUES (?)"
25// SQLSBUPDATED " ON DUPLICATE KEY UPDATE category=VALUES(<category.getCategory()>)"
26
27 }
28
29}