i have no idea what im doing

This commit is contained in:
Telesphoreo 2022-04-06 19:18:12 -05:00
parent 2105f51b44
commit f62e0a42d1
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,44 @@
package dev.plex.cache.notes;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import dev.plex.Plex;
import dev.plex.cache.player.PlayerCache;
import dev.plex.player.PlexPlayer;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.UUID;
public class PlayerNotes
{
private final String SELECT = "SELECT * FROM `notes` WHERE uuid=?";
//private final String UPDATE = "UPDATE `notes` SET name=?, written_by=?, note=? WHERE uuid=?";
private final String INSERT = "INSERT INTO `notes` (`uuid`, `name`, `written_by`, `note`) VALUES (?, ?, ?, ?);";
public PlexPlayer getByUUID(UUID uuid)
{
try (Connection con = Plex.get().getSqlConnection().getCon())
{
PreparedStatement statement = con.prepareStatement(SELECT);
statement.setString(1, uuid.toString());
ResultSet set = statement.executeQuery();
PlexPlayer plexPlayer = new PlexPlayer(uuid);
while (set.next())
{
String name = set.getString("name");
String writtenBy = set.getString("written_by");
String note = set.getString("note");
}
return plexPlayer;
}
catch (SQLException throwables)
{
throwables.printStackTrace();
}
return null;
}
}

View File

@ -76,6 +76,12 @@ public class SQLConnection extends PlexBase
"`active` BOOLEAN, " +
"`endDate` BIGINT" +
");").execute();
con.prepareStatement("CREATE TABLE IF NOT EXISTS `notes` (" +
"`uuid` VARCHAR(46) NOT NULL, " +
"`name` VARCHAR(18), " +
"`written_by` VARCHAR(16), " +
"`note` VARCHAR(2000), " +
");").execute();
}
catch (SQLException throwables)
{