mirror of
https://github.com/songoda/UltimateModeration.git
synced 2024-11-22 10:15:55 +01:00
code clean up (style)
This commit is contained in:
parent
fa62c5e522
commit
653395c152
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
")");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user