Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HoshiKurama committed Apr 22, 2021
1 parent ed13f7f commit 0abcb6f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ static void LaunchDatabase(final String host, final String port, final String db
config.setJdbcUrl("jdbc:mysql://" + host + ":" + port + "/" + dbname + "?serverTimezone=America/Chicago");
config.setUsername(username);
config.setPassword(password);
config.setDriverClassName("com.mysql.cj.jdbc.Driver"); //Might need to change?
config.setDriverClassName("com.mysql.cj.jdbc.Driver");
ds = new HikariDataSource(config);

DatabaseHandler.checkTables();
}

static void attemptConnection() throws SQLException {
ds.getConnection();
}

static Connection getConnection() throws SQLException {
return ds.getConnection();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
case "comment": commentTicketCommand(sender, args, performSilently, false); break;
case "close": closeTicketCommand(sender, args, performSilently); break;
case "assign": assignTicketCommand(sender, args, performSilently); break;
case "claim": assignTicketCommand(sender, new String[]{args[0], args[1], sender.getName()}, performSilently); break;
case "unassign": assignTicketCommand(sender, new String[]{args[0], args[1], " "}, performSilently); break;
case "claim": claimTicketCommand(sender, args,performSilently); break;
case "unassign": unassignTicketCommand(sender, args, performSilently); break;
case "setpriority": setPriorityTicketCommand(sender, args, performSilently); break;
case "teleport": teleportTicketCommand(sender, args); break;
case "reopen": reopenTicketCommand(sender, args, performSilently); break;
Expand All @@ -78,6 +78,16 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
}

// TicketManager command methods
void claimTicketCommand(CommandSender sender, String[] args, boolean performSilently) throws SQLException, TMInvalidDataException {
if (args.length <= 1) throw new TMInvalidDataException("Please at least have a ticket ID!");
assignTicketCommand(sender, new String[] {args[0], args[1], sender.getName()}, performSilently);
}

void unassignTicketCommand(CommandSender sender, String[] args, boolean performSilently) throws SQLException, TMInvalidDataException {
if (args.length <= 1) throw new TMInvalidDataException("Please at least have a ticket ID!");
assignTicketCommand(sender, new String[]{args[0], args[1], " "}, performSilently);
}

void listOpenTicketsCommand(CommandSender sender, String[] args) throws SQLException, TMInvalidDataException {
if (!senderHasPermission(sender, "ticketmanager.list"))
throw new TMInvalidDataException("You do not have permission to perform this command!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public void onEnable() {
config.getString("DB_Name"),
config.getString("Username"),
config.getString("Password"));
HikariCP.attemptConnection();
Connection connection = HikariCP.getConnection();
connection.close();

// Checks for detected conversion and initiates
if (DatabaseHandler.conversionIsRequired()) {
Expand Down Expand Up @@ -181,9 +182,9 @@ public void onPlayerJoin(PlayerJoinEvent event) {
}
} catch (Exception e) {
TMCommands.pushWarningNotification(e);
e.printStackTrace();
}
});

}

static Permission getPermissions() {
Expand Down

0 comments on commit 0abcb6f

Please sign in to comment.