code clean up (style)

This commit is contained in:
Christian Koop 2023-08-15 23:24:07 +02:00
parent fa62c5e522
commit 653395c152
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
5 changed files with 11 additions and 21 deletions

View File

@ -5,10 +5,8 @@ import com.craftaro.core.SongodaPlugin;
import com.craftaro.core.commands.CommandManager;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.configuration.Config;
import com.craftaro.core.database.DatabaseConnector;
import com.craftaro.core.gui.GuiManager;
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.ultimatemoderation.settings.Settings;
import com.craftaro.ultimatemoderation.commands.CommandBan;
import com.craftaro.ultimatemoderation.commands.CommandClearChat;
import com.craftaro.ultimatemoderation.commands.CommandHelp;
@ -46,6 +44,7 @@ import com.craftaro.ultimatemoderation.punish.PunishmentNote;
import com.craftaro.ultimatemoderation.punish.player.PunishmentManager;
import com.craftaro.ultimatemoderation.punish.template.Template;
import com.craftaro.ultimatemoderation.punish.template.TemplateManager;
import com.craftaro.ultimatemoderation.settings.Settings;
import com.craftaro.ultimatemoderation.staffchat.StaffChatManager;
import com.craftaro.ultimatemoderation.tasks.SlowModeTask;
import com.craftaro.ultimatemoderation.tickets.Ticket;
@ -122,9 +121,8 @@ public class UltimateModeration extends SongodaPlugin {
this.staffChatManager = new StaffChatManager();
this.moderationManager = new ModerationManager(this);
try {
initDatabase(Arrays.asList(new _1_InitialMigration(this)));
initDatabase(Arrays.asList(new _1_InitialMigration()));
this.dataHelper = new DataHelper(getDataManager(), this);
} catch (Exception ex) {
@ -225,6 +223,6 @@ public class UltimateModeration extends SongodaPlugin {
}
public DataHelper getDataHelper() {
return dataHelper;
return this.dataHelper;
}
}

View File

@ -33,15 +33,14 @@ public class DataHelper {
this.dataManager = dataManager;
this.databaseConnector = dataManager.getDatabaseConnector();
this.plugin = plugin;
}
private void runAsync(Runnable runnable) {
dataManager.getAsyncPool().execute(runnable);
this.dataManager.getAsyncPool().execute(runnable);
}
private void sync(Runnable runnable) {
Bukkit.getScheduler().runTask(plugin, runnable);
Bukkit.getScheduler().runTask(this.plugin, runnable);
}
private String getTablePrefix() {
@ -51,7 +50,7 @@ public class DataHelper {
public void createTemplate(Template template) {
this.runAsync(() -> {
try (Connection connection = this.databaseConnector.getConnection()) {
int nextId = dataManager.getNextId("templates");
int nextId = this.dataManager.getNextId("templates");
String createTemplate = "INSERT INTO " + this.getTablePrefix() + "templates (punishment_type, duration, reason, name, creator) VALUES (?, ?, ?, ?, ?)";
PreparedStatement statement = connection.prepareStatement(createTemplate);
@ -111,7 +110,7 @@ public class DataHelper {
public void createAppliedPunishment(AppliedPunishment punishment) {
this.runAsync(() -> {
try (Connection connection = this.databaseConnector.getConnection()) {
int nextId = dataManager.getNextId("punishments");
int nextId = this.dataManager.getNextId("punishments");
String createPunishment = "INSERT INTO " + this.getTablePrefix() + "punishments (type, duration, reason, victim, punisher, expiration) VALUES (?, ?, ?, ?, ?, ?)";
PreparedStatement statement = connection.prepareStatement(createPunishment);
@ -190,7 +189,7 @@ public class DataHelper {
public void createNote(PunishmentNote note) {
this.runAsync(() -> {
try (Connection connection = this.databaseConnector.getConnection()) {
int nextId = dataManager.getNextId("notes");
int nextId = this.dataManager.getNextId("notes");
String createNote = "INSERT INTO " + this.getTablePrefix() + "notes (note, author, subject, creation) VALUES (?, ?, ?, ?)";
PreparedStatement statement = connection.prepareStatement(createNote);
@ -246,7 +245,7 @@ public class DataHelper {
public void createTicket(Ticket ticket) {
this.runAsync(() -> {
try (Connection connection = this.databaseConnector.getConnection()) {
int nextId = dataManager.getNextId("tickets");
int nextId = this.dataManager.getNextId("tickets");
String createTicket = "INSERT INTO " + this.getTablePrefix() + "tickets (victim, subject, type, status, world, x, y, z, pitch, yaw) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
PreparedStatement statement = connection.prepareStatement(createTicket);

View File

@ -1,8 +1,6 @@
package com.craftaro.ultimatemoderation.database.migrations;
import com.craftaro.core.database.DataMigration;
import com.craftaro.core.database.DatabaseConnector;
import com.craftaro.core.database.MySQLConnector;
import com.craftaro.ultimatemoderation.UltimateModeration;
import java.sql.Connection;
@ -10,11 +8,8 @@ import java.sql.SQLException;
import java.sql.Statement;
public class _1_InitialMigration extends DataMigration {
private final UltimateModeration plugin;
public _1_InitialMigration(UltimateModeration plugin) {
public _1_InitialMigration() {
super(1);
this.plugin = plugin;
}
@Override
@ -84,5 +79,4 @@ public class _1_InitialMigration extends DataMigration {
")");
}
}
}

View File

@ -87,7 +87,7 @@ public class MainGui extends Gui {
List<UUID> found = players.stream().filter(uuid -> Bukkit.getOfflinePlayer(uuid).getName().toLowerCase().contains(gui.getInputText().toLowerCase())).collect(Collectors.toList());
if (found.size() >= 1) {
if (!found.isEmpty()) {
this.players.clear();
this.players.addAll(found);
showPage();

View File

@ -147,7 +147,6 @@ public class TicketGui extends Gui {
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
lore.add(this.plugin.getLocale().getMessage("gui.ticket.postedby")
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticketResponse.getAuthor()).getName()).getMessage());
lore.add(this.plugin.getLocale().getMessage("gui.ticket.createdon")