Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ssl option to config so users can silence warnings when connnecting to databases without SSL #101

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ public VoteStorage initializeVoteStorage() throws IOException {
String database = configuration.getString("storage.mysql.database", "superbvote");
String table = configuration.getString("storage.mysql.table", "superbvote");
boolean readOnly = configuration.getBoolean("storage.mysql.read-only");
boolean ssl = configuration.getBoolean("storage.mysql.ssl");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here, the default value should be added as 'true' otherwise users without the config file updated, will not use SSL by default.


HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://" + host + ":" + port + "/" + database);
config.setJdbcUrl("jdbc:mysql://" + host + ":" + port + "/" + database + "?useSSL=" + ssl);
config.setUsername(username);
config.setPassword(password);
config.setMinimumIdle(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ public void onPlayerJoin(PlayerJoinEvent event) {
return;
}

Bukkit.getScheduler().runTaskAsynchronously(SuperbVote.getPlugin(), () -> {
long delay = 100L; // 100 ticks = 5 seconds to delay

Bukkit.getScheduler().runTaskLaterAsynchronously(SuperbVote.getPlugin(), () -> {
// Update names in MySQL, if it is being used.
if (SuperbVote.getPlugin().getVoteStorage() instanceof MysqlVoteStorage) {
((MysqlVoteStorage) SuperbVote.getPlugin().getVoteStorage()).updateName(event.getPlayer());
Expand All @@ -106,6 +108,10 @@ public void onPlayerJoin(PlayerJoinEvent event) {
PlayerVotes pv = SuperbVote.getPlugin().getVoteStorage().getVotes(event.getPlayer().getUniqueId());
List<Vote> votes = SuperbVote.getPlugin().getQueuedVotes().getAndRemoveVotes(event.getPlayer().getUniqueId());
if (!votes.isEmpty()) {
// Send message to player letting them know why they're receiving a bunch of random gifts
String queueMessage = ChatColor.translateAlternateColorCodes('&', SuperbVote.getPlugin().getConfig().getString("queue-message"));
event.getPlayer().sendMessage(queueMessage);

for (Vote vote : votes) {
processVote(pv, vote, false, false, true);
pv = new PlayerVotes(pv.getUuid(), event.getPlayer().getName(),pv.getVotes() + 1, PlayerVotes.Type.CURRENT);
Expand All @@ -120,7 +126,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
MessageContext context = new MessageContext(null, pv, event.getPlayer());
SuperbVote.getPlugin().getConfiguration().getReminderMessage().sendAsReminder(event.getPlayer(), context);
}
});
}, delay);
}

private void afterVoteProcessing() {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ storage:
database: superbvote
table: votes
read-only: false
ssl: true

# General vote configuration.
votes:
Expand Down Expand Up @@ -49,6 +50,7 @@ rewards:

# Whether or not players need to be online to vote. If set, offline player votes are queued for when the player next logs in.
require-online: true
queue-message: "&aThanks for voting recently! You will now receive your prizes."

# Broadcast settings:
broadcast:
Expand Down