From ab27ca52d3552739399a68c9df9f32dcfdc4ee7a Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Thu, 20 Jul 2023 17:32:46 +0200 Subject: [PATCH 01/27] Heavy code style changes and slight refactoring --- .../UltimateModeration.java | 89 ++++--- .../commands/CommandBan.java | 27 +- .../commands/CommandClearChat.java | 10 +- .../commands/CommandHelp.java | 13 +- .../commands/CommandKick.java | 6 +- .../commands/CommandMute.java | 21 +- .../commands/CommandRandomPlayer.java | 3 +- .../commands/CommandReload.java | 5 +- .../commands/CommandRunTemplate.java | 5 +- .../commands/CommandSettings.java | 4 +- .../commands/CommandSlowMode.java | 14 +- .../commands/CommandStaffChat.java | 20 +- .../commands/CommandTicket.java | 4 +- .../commands/CommandToggleChat.java | 19 +- .../commands/CommandUltimateModeration.java | 3 +- .../commands/CommandUnBan.java | 12 +- .../commands/CommandUnMute.java | 9 +- .../commands/CommandVanish.java | 19 +- .../commands/CommandWarn.java | 17 +- .../database/DataManager.java | 1 - .../migrations/_1_InitialMigration.java | 6 +- .../ultimatemoderation/gui/MainGui.java | 118 +++++---- .../ultimatemoderation/gui/ModerateGui.java | 14 +- .../gui/NotesManagerGui.java | 61 ++--- .../ultimatemoderation/gui/PlayerGui.java | 32 +-- .../ultimatemoderation/gui/PunishGui.java | 234 ++++++++++-------- .../gui/PunishmentsGui.java | 84 ++++--- .../gui/TemplateManagerGui.java | 42 ++-- .../gui/TemplateSelectorGui.java | 26 +- .../ultimatemoderation/gui/TicketGui.java | 67 ++--- .../gui/TicketManagerGui.java | 71 +++--- .../ultimatemoderation/gui/TicketTypeGui.java | 14 +- .../listeners/BlockListener.java | 24 +- .../listeners/ChatListener.java | 28 +-- .../listeners/CommandListener.java | 19 +- .../listeners/DeathListener.java | 10 +- .../listeners/DropListener.java | 5 +- .../listeners/InventoryListener.java | 10 +- .../listeners/LoginListener.java | 15 +- .../listeners/MobTargetLister.java | 12 +- .../listeners/MoveListener.java | 5 +- .../listeners/SkyBlockListener.java | 12 +- .../listeners/SpyingDismountListener.java | 26 +- .../moderate/AbstractModeration.java | 11 +- .../moderate/GenericModerationCommand.java | 14 +- .../moderate/ModerationManager.java | 1 - .../moderate/ModerationType.java | 2 - .../moderations/FreezeModeration.java | 15 +- .../moderations/InvSeeModeration.java | 1 - .../moderations/ReviveModeration.java | 10 +- .../moderate/moderations/SpyModeration.java | 19 +- .../moderations/ViewEnderChestModeration.java | 1 - .../punish/AppliedPunishment.java | 9 +- .../ultimatemoderation/punish/Punishment.java | 56 +++-- .../punish/PunishmentNote.java | 11 +- .../punish/PunishmentType.java | 15 +- .../punish/player/PlayerPunishData.java | 17 +- .../punish/player/PunishmentManager.java | 7 +- .../punish/template/Template.java | 5 +- .../punish/template/TemplateManager.java | 10 +- .../ultimatemoderation/settings/Settings.java | 65 +++-- .../staffchat/StaffChannel.java | 44 ++-- .../staffchat/StaffChatManager.java | 11 +- .../tasks/SlowModeTask.java | 25 +- .../ultimatemoderation/tickets/Ticket.java | 1 - .../tickets/TicketManager.java | 1 - .../tickets/TicketResponse.java | 1 - .../tickets/TicketStatus.java | 1 - .../ultimatemoderation/utils/Methods.java | 192 -------------- .../utils/VaultPermissions.java | 10 +- src/main/resources/plugin.yml | 20 +- 71 files changed, 858 insertions(+), 953 deletions(-) delete mode 100644 src/main/java/com/songoda/ultimatemoderation/utils/Methods.java diff --git a/src/main/java/com/songoda/ultimatemoderation/UltimateModeration.java b/src/main/java/com/songoda/ultimatemoderation/UltimateModeration.java index 8066683..5e808ef 100644 --- a/src/main/java/com/songoda/ultimatemoderation/UltimateModeration.java +++ b/src/main/java/com/songoda/ultimatemoderation/UltimateModeration.java @@ -11,10 +11,37 @@ import com.songoda.core.database.DatabaseConnector; import com.songoda.core.database.MySQLConnector; import com.songoda.core.database.SQLiteConnector; import com.songoda.core.gui.GuiManager; -import com.songoda.ultimatemoderation.commands.*; +import com.songoda.ultimatemoderation.commands.CommandBan; +import com.songoda.ultimatemoderation.commands.CommandClearChat; +import com.songoda.ultimatemoderation.commands.CommandHelp; +import com.songoda.ultimatemoderation.commands.CommandKick; +import com.songoda.ultimatemoderation.commands.CommandMute; +import com.songoda.ultimatemoderation.commands.CommandRandomPlayer; +import com.songoda.ultimatemoderation.commands.CommandReload; +import com.songoda.ultimatemoderation.commands.CommandRunTemplate; +import com.songoda.ultimatemoderation.commands.CommandSettings; +import com.songoda.ultimatemoderation.commands.CommandSlowMode; +import com.songoda.ultimatemoderation.commands.CommandStaffChat; +import com.songoda.ultimatemoderation.commands.CommandTicket; +import com.songoda.ultimatemoderation.commands.CommandToggleChat; +import com.songoda.ultimatemoderation.commands.CommandUltimateModeration; +import com.songoda.ultimatemoderation.commands.CommandUnBan; +import com.songoda.ultimatemoderation.commands.CommandUnMute; +import com.songoda.ultimatemoderation.commands.CommandVanish; +import com.songoda.ultimatemoderation.commands.CommandWarn; import com.songoda.ultimatemoderation.database.DataManager; import com.songoda.ultimatemoderation.database.migrations._1_InitialMigration; -import com.songoda.ultimatemoderation.listeners.*; +import com.songoda.ultimatemoderation.listeners.BlockListener; +import com.songoda.ultimatemoderation.listeners.ChatListener; +import com.songoda.ultimatemoderation.listeners.CommandListener; +import com.songoda.ultimatemoderation.listeners.DeathListener; +import com.songoda.ultimatemoderation.listeners.DropListener; +import com.songoda.ultimatemoderation.listeners.InventoryListener; +import com.songoda.ultimatemoderation.listeners.LoginListener; +import com.songoda.ultimatemoderation.listeners.MobTargetLister; +import com.songoda.ultimatemoderation.listeners.MoveListener; +import com.songoda.ultimatemoderation.listeners.SkyBlockListener; +import com.songoda.ultimatemoderation.listeners.SpyingDismountListener; import com.songoda.ultimatemoderation.moderate.ModerationManager; import com.songoda.ultimatemoderation.punish.AppliedPunishment; import com.songoda.ultimatemoderation.punish.PunishmentNote; @@ -28,12 +55,11 @@ import com.songoda.ultimatemoderation.tickets.Ticket; import com.songoda.ultimatemoderation.tickets.TicketManager; import org.bukkit.Bukkit; import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; import java.util.List; public class UltimateModeration extends SongodaPlugin { - private static UltimateModeration INSTANCE; - private final GuiManager guiManager = new GuiManager(this); private TicketManager ticketManager; private TemplateManager templateManager; @@ -45,13 +71,16 @@ public class UltimateModeration extends SongodaPlugin { private DatabaseConnector databaseConnector; private DataManager dataManager; + /** + * @deprecated Use {@link JavaPlugin#getPlugin(Class)} instead. + */ + @Deprecated public static UltimateModeration getInstance() { - return INSTANCE; + return getPlugin(UltimateModeration.class); } @Override public void onPluginLoad() { - INSTANCE = this; } @Override @@ -72,7 +101,7 @@ public class UltimateModeration extends SongodaPlugin { this.commandManager.addCommand(new CommandUltimateModeration(this)) .addSubCommands( new CommandReload(this), - new CommandSettings(this, guiManager), + new CommandSettings(this, this.guiManager), new CommandHelp(this) ); this.commandManager.addCommand(new CommandBan(this)); @@ -83,7 +112,7 @@ public class UltimateModeration extends SongodaPlugin { this.commandManager.addCommand(new CommandRunTemplate(this)); this.commandManager.addCommand(new CommandSlowMode(this)); this.commandManager.addCommand(new CommandStaffChat(this)); - this.commandManager.addCommand(new CommandTicket(this, guiManager)); + this.commandManager.addCommand(new CommandTicket(this, this.guiManager)); this.commandManager.addCommand(new CommandToggleChat(this)); this.commandManager.addCommand(new CommandUnBan(this)); this.commandManager.addCommand(new CommandUnMute(this)); @@ -116,8 +145,7 @@ public class UltimateModeration extends SongodaPlugin { } this.dataManager = new DataManager(this.databaseConnector, this); - DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager, - new _1_InitialMigration()); + DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager, new _1_InitialMigration(this)); dataMigrationManager.runMigrations(); } catch (Exception ex) { @@ -128,10 +156,10 @@ public class UltimateModeration extends SongodaPlugin { } // Register Listeners - guiManager.init(); + this.guiManager.init(); PluginManager pluginManager = Bukkit.getPluginManager(); pluginManager.registerEvents(new CommandListener(this), this); - pluginManager.registerEvents(new DeathListener(this), this); + pluginManager.registerEvents(new DeathListener(), this); pluginManager.registerEvents(new MoveListener(this), this); pluginManager.registerEvents(new DropListener(this), this); pluginManager.registerEvents(new InventoryListener(this), this); @@ -139,11 +167,13 @@ public class UltimateModeration extends SongodaPlugin { pluginManager.registerEvents(new LoginListener(this), this); pluginManager.registerEvents(new MobTargetLister(), this); pluginManager.registerEvents(new BlockListener(this), this); - if (pluginManager.isPluginEnabled("FabledSkyBlock")) - pluginManager.registerEvents(new SkyBlockListener(this), this); + if (pluginManager.isPluginEnabled("FabledSkyBlock")) { + pluginManager.registerEvents(new SkyBlockListener(), this); + } - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) - pluginManager.registerEvents(new SpyingDismountListener(), this); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { + pluginManager.registerEvents(new SpyingDismountListener(this), this); + } // Start tasks SlowModeTask.startTask(this); @@ -159,16 +189,19 @@ public class UltimateModeration extends SongodaPlugin { } }); this.dataManager.getAppliedPunishments((appliedPunishments) -> { - for (AppliedPunishment punishment : appliedPunishments) + for (AppliedPunishment punishment : appliedPunishments) { this.punishmentManager.getPlayer(punishment.getVictim()).addPunishment(punishment); + } }); this.dataManager.getNotes((notes) -> { - for (PunishmentNote note : notes) + for (PunishmentNote note : notes) { this.punishmentManager.getPlayer(note.getSubject()).addNotes(note); + } }); this.dataManager.getTickets((tickets) -> { - for (Ticket ticket : tickets.values()) + for (Ticket ticket : tickets.values()) { this.ticketManager.addTicket(ticket); + } }); }); } @@ -185,38 +218,38 @@ public class UltimateModeration extends SongodaPlugin { } public CommandManager getCommandManager() { - return commandManager; + return this.commandManager; } public TemplateManager getTemplateManager() { - return templateManager; + return this.templateManager; } public PunishmentManager getPunishmentManager() { - return punishmentManager; + return this.punishmentManager; } public TicketManager getTicketManager() { - return ticketManager; + return this.ticketManager; } public StaffChatManager getStaffChatManager() { - return staffChatManager; + return this.staffChatManager; } public DataManager getDataManager() { - return dataManager; + return this.dataManager; } public DatabaseConnector getDatabaseConnector() { - return databaseConnector; + return this.databaseConnector; } public GuiManager getGuiManager() { - return guiManager; + return this.guiManager; } public ModerationManager getModerationManager() { - return moderationManager; + return this.moderationManager; } } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandBan.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandBan.java index 6715d90..a52567b 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandBan.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandBan.java @@ -1,10 +1,10 @@ package com.songoda.ultimatemoderation.commands; import com.songoda.core.commands.AbstractCommand; +import com.songoda.core.utils.TimeUtils; import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.punish.Punishment; import com.songoda.ultimatemoderation.punish.PunishmentType; -import com.songoda.ultimatemoderation.utils.Methods; import com.songoda.ultimatemoderation.utils.VaultPermissions; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @@ -17,7 +17,6 @@ import java.util.Collections; import java.util.List; public class CommandBan extends AbstractCommand { - private final UltimateModeration plugin; public CommandBan(UltimateModeration plugin) { @@ -27,21 +26,23 @@ public class CommandBan extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { - if (args.length < 1) + if (args.length < 1) { return ReturnType.SYNTAX_ERROR; + } - // I dream of the day where someone creates a ticket because - // they can't ban someone for the reason "Stole me 2h sword". + // I dream of the day when someone creates a ticket because + // they can't ban someone for the reason "Stole me 2h sword" long duration = 0; StringBuilder reasonBuilder = new StringBuilder(); if (args.length > 1) { for (int i = 1; i < args.length; i++) { String line = args[i]; - long time = Methods.parseTime(line); - if (time != 0) + long time = TimeUtils.parseTime(line); + if (time != 0) { duration += time; - else + } else { reasonBuilder.append(line).append(" "); + } } } @@ -49,21 +50,21 @@ public class CommandBan extends AbstractCommand { OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); - if (plugin.getPunishmentManager().getPlayer(player).getActivePunishments() + if (this.plugin.getPunishmentManager().getPlayer(player).getActivePunishments() .stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) { - plugin.getLocale().newMessage("That player is already banned.").sendPrefixedMessage(sender); + this.plugin.getLocale().newMessage("That player is already banned.").sendPrefixedMessage(sender); return ReturnType.FAILURE; } if (duration == 0 && !sender.hasPermission("um.ban.permanent")) { - plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender); + this.plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender); return ReturnType.FAILURE; } long durationFinal = duration; - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> { if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.ban.exempt")) { - plugin.getLocale().newMessage("You cannot ban this player.").sendPrefixedMessage(sender); + this.plugin.getLocale().newMessage("You cannot ban this player.").sendPrefixedMessage(sender); return; } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandClearChat.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandClearChat.java index a31bd28..2fe9696 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandClearChat.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandClearChat.java @@ -11,7 +11,6 @@ import java.util.Collections; import java.util.List; public class CommandClearChat extends AbstractCommand { - private final UltimateModeration plugin; public CommandClearChat(UltimateModeration plugin) { @@ -21,9 +20,9 @@ public class CommandClearChat extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { - - if (args.length != 0 && !args[0].equalsIgnoreCase("force")) + if (args.length != 0 && !args[0].equalsIgnoreCase("force")) { return ReturnType.SYNTAX_ERROR; + } for (Player player : Bukkit.getOnlinePlayers()) { if (!player.hasPermission("um.clearchat.bypass") || isForced(args)) { @@ -32,13 +31,14 @@ public class CommandClearChat extends AbstractCommand { player.sendMessage(toSend); } - plugin.getLocale().getMessage("command.clearchat.cleared") + this.plugin.getLocale().getMessage("command.clearchat.cleared") .processPlaceholder("player", sender.getName()).sendPrefixedMessage(player); if (player.hasPermission("um.clearchat.bypass") && !isForced(args)) { - plugin.getLocale().getMessage("command.clearchat.immune").sendMessage(player); + this.plugin.getLocale().getMessage("command.clearchat.immune").sendMessage(player); } } + return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandHelp.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandHelp.java index 5997404..58e4d0a 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandHelp.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandHelp.java @@ -1,14 +1,13 @@ package com.songoda.ultimatemoderation.commands; import com.songoda.core.commands.AbstractCommand; +import com.songoda.core.utils.TextUtils; import com.songoda.ultimatemoderation.UltimateModeration; -import com.songoda.ultimatemoderation.utils.Methods; import org.bukkit.command.CommandSender; import java.util.List; public class CommandHelp extends AbstractCommand { - private final UltimateModeration plugin; public CommandHelp(UltimateModeration plugin) { @@ -19,15 +18,15 @@ public class CommandHelp extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { sender.sendMessage(""); - plugin.getLocale().getMessage("&7Version " + plugin.getDescription().getVersion() + " Created with <3 by &5&l&oSongoda") + this.plugin.getLocale().getMessage("&7Version " + this.plugin.getDescription().getVersion() + " Created with <3 by &5&l&oSongoda") .sendPrefixedMessage(sender); sender.sendMessage(""); - sender.sendMessage(Methods.formatText("&7Welcome to UltimateModeration! To get started try using the /um command to access the moderation panel.")); + sender.sendMessage(TextUtils.formatText("&7Welcome to UltimateModeration! To get started try using the /um command to access the moderation panel.")); sender.sendMessage(""); - sender.sendMessage(Methods.formatText("&6Commands:")); - for (AbstractCommand command : plugin.getCommandManager().getAllCommands()) { + sender.sendMessage(TextUtils.formatText("&6Commands:")); + for (AbstractCommand command : this.plugin.getCommandManager().getAllCommands()) { if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) { - sender.sendMessage(Methods.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription())); + sender.sendMessage(TextUtils.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription())); } } sender.sendMessage(""); diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandKick.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandKick.java index 6d7faa2..662e788 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandKick.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandKick.java @@ -14,7 +14,6 @@ import java.util.Collections; import java.util.List; public class CommandKick extends AbstractCommand { - private final UltimateModeration plugin; public CommandKick(UltimateModeration plugin) { @@ -24,8 +23,9 @@ public class CommandKick extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { - if (args.length < 1) + if (args.length < 1) { return ReturnType.SYNTAX_ERROR; + } StringBuilder reasonBuilder = new StringBuilder(); if (args.length > 1) { @@ -40,7 +40,7 @@ public class CommandKick extends AbstractCommand { OfflinePlayer player = Bukkit.getPlayer(args[0]); if (sender instanceof Player && player.getPlayer().hasPermission("um.kick.exempt")) { - plugin.getLocale().newMessage("You cannot kick this player.").sendPrefixedMessage(sender); + this.plugin.getLocale().newMessage("You cannot kick this player.").sendPrefixedMessage(sender); return ReturnType.FAILURE; } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandMute.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandMute.java index 18d2b9f..476037f 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandMute.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandMute.java @@ -1,10 +1,10 @@ package com.songoda.ultimatemoderation.commands; import com.songoda.core.commands.AbstractCommand; +import com.songoda.core.utils.TimeUtils; import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.punish.Punishment; import com.songoda.ultimatemoderation.punish.PunishmentType; -import com.songoda.ultimatemoderation.utils.Methods; import com.songoda.ultimatemoderation.utils.VaultPermissions; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @@ -17,7 +17,6 @@ import java.util.Collections; import java.util.List; public class CommandMute extends AbstractCommand { - private final UltimateModeration plugin; public CommandMute(UltimateModeration plugin) { @@ -27,21 +26,23 @@ public class CommandMute extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { - if (args.length < 1) + if (args.length < 1) { return ReturnType.SYNTAX_ERROR; + } - // I dream of the day where someone creates a ticket because + // I dream of the day when someone creates a ticket because // they can't ban someone for the reason "Stole me 2h sword". long duration = 0; StringBuilder reasonBuilder = new StringBuilder(); if (args.length > 1) { for (int i = 1; i < args.length; i++) { String line = args[i]; - long time = Methods.parseTime(line); - if (time != 0) + long time = TimeUtils.parseTime(line); + if (time != 0) { duration += time; - else + } else { reasonBuilder.append(line).append(" "); + } } } @@ -50,13 +51,13 @@ public class CommandMute extends AbstractCommand { OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.mute.exempt")) { - plugin.getLocale().newMessage("You cannot mute that player.").sendPrefixedMessage(sender); + this.plugin.getLocale().newMessage("You cannot mute that player.").sendPrefixedMessage(sender); return ReturnType.FAILURE; } - if (plugin.getPunishmentManager().getPlayer(player).getActivePunishments() + if (this.plugin.getPunishmentManager().getPlayer(player).getActivePunishments() .stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.MUTE)) { - plugin.getLocale().newMessage("That player is already muted.").sendPrefixedMessage(sender); + this.plugin.getLocale().newMessage("That player is already muted.").sendPrefixedMessage(sender); return ReturnType.FAILURE; } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandRandomPlayer.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandRandomPlayer.java index 10c2238..06471a7 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandRandomPlayer.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandRandomPlayer.java @@ -11,7 +11,6 @@ import java.util.Collections; import java.util.List; public class CommandRandomPlayer extends AbstractCommand { - private final UltimateModeration plugin; public CommandRandomPlayer(UltimateModeration plugin) { @@ -26,7 +25,7 @@ public class CommandRandomPlayer extends AbstractCommand { players.remove(sender); if (players.size() == 0) { - plugin.getLocale().newMessage("&cYou are the only one online!").sendPrefixedMessage(sender); + this.plugin.getLocale().newMessage("&cYou are the only one online!").sendPrefixedMessage(sender); return ReturnType.FAILURE; } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandReload.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandReload.java index b755739..da24a69 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandReload.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandReload.java @@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender; import java.util.List; public class CommandReload extends AbstractCommand { - private final UltimateModeration plugin; public CommandReload(UltimateModeration plugin) { @@ -17,8 +16,8 @@ public class CommandReload extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { - plugin.reloadConfig(); - plugin.getLocale().newMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender); + this.plugin.reloadConfig(); + this.plugin.getLocale().newMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender); return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandRunTemplate.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandRunTemplate.java index bb7f16e..af9986e 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandRunTemplate.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandRunTemplate.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.List; public class CommandRunTemplate extends AbstractCommand { - private final UltimateModeration plugin; public CommandRunTemplate(UltimateModeration plugin) { @@ -34,7 +33,7 @@ public class CommandRunTemplate extends AbstractCommand { } String templateStr = templateBuilder.toString().trim(); - Template template = plugin.getTemplateManager().getTemplate(templateStr); + Template template = this.plugin.getTemplateManager().getTemplate(templateStr); if (template == null) { sender.sendMessage("That template does not exist..."); @@ -56,7 +55,7 @@ public class CommandRunTemplate extends AbstractCommand { return players; } else if (args.length == 2) { List lines = new ArrayList<>(); - for (Template template : plugin.getTemplateManager().getTemplates()) { + for (Template template : this.plugin.getTemplateManager().getTemplates()) { lines.add(template.getName()); } } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandSettings.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandSettings.java index 1cadbde..3ad8db9 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandSettings.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandSettings.java @@ -10,7 +10,6 @@ import org.bukkit.entity.Player; import java.util.List; public class CommandSettings extends AbstractCommand { - private final UltimateModeration plugin; private final GuiManager guiManager; @@ -22,8 +21,7 @@ public class CommandSettings extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { - Player player = (Player) sender; - guiManager.showGUI((Player) sender, new PluginConfigGui(plugin)); + this.guiManager.showGUI((Player) sender, new PluginConfigGui(this.plugin)); return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandSlowMode.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandSlowMode.java index c1d6ece..a066a8f 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandSlowMode.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandSlowMode.java @@ -1,9 +1,9 @@ package com.songoda.ultimatemoderation.commands; import com.songoda.core.commands.AbstractCommand; +import com.songoda.core.utils.TimeUtils; import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.listeners.ChatListener; -import com.songoda.ultimatemoderation.utils.Methods; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.List; public class CommandSlowMode extends AbstractCommand { - private final UltimateModeration plugin; public CommandSlowMode(UltimateModeration plugin) { @@ -24,18 +23,19 @@ public class CommandSlowMode extends AbstractCommand { protected ReturnType runCommand(CommandSender sender, String... args) { if (args.length == 0) { ChatListener.setSlowModeOverride(0); - plugin.getLocale().getMessage("event.slowmode.disabled").sendPrefixedMessage(sender); + this.plugin.getLocale().getMessage("event.slowmode.disabled").sendPrefixedMessage(sender); return ReturnType.SUCCESS; - } else if (args.length != 1) + } else if (args.length != 1) { return ReturnType.SYNTAX_ERROR; + } - long delay = Methods.parseTime(args[0]); + long delay = TimeUtils.parseTime(args[0]); ChatListener.setSlowModeOverride(delay); Bukkit.getOnlinePlayers().forEach(player -> - plugin.getLocale().getMessage("event.slowmode.enabled") - .processPlaceholder("delay", Methods.makeReadable(delay)).sendPrefixedMessage(player)); + this.plugin.getLocale().getMessage("event.slowmode.enabled") + .processPlaceholder("delay", TimeUtils.makeReadable(delay)).sendPrefixedMessage(player)); return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandStaffChat.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandStaffChat.java index d8a7ba9..41fa5e2 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandStaffChat.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandStaffChat.java @@ -10,7 +10,6 @@ import java.util.ArrayList; import java.util.List; public class CommandStaffChat extends AbstractCommand { - private final UltimateModeration plugin; public CommandStaffChat(UltimateModeration plugin) { @@ -20,33 +19,36 @@ public class CommandStaffChat extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { - if (args.length != 1) + if (args.length != 1) { return ReturnType.SYNTAX_ERROR; + } String channelName = args[0]; Player player = (Player) sender; if (channelName.trim().equalsIgnoreCase("leave")) { - for (StaffChannel channel : plugin.getStaffChatManager().getChats().values()) { - if (!channel.listMembers().contains(player.getUniqueId())) continue; + for (StaffChannel channel : this.plugin.getStaffChatManager().getChats().values()) { + if (!channel.listMembers().contains(player.getUniqueId())) { + continue; + } channel.removeMember(player); - plugin.getLocale().getMessage("event.staffchat.leave") + this.plugin.getLocale().getMessage("event.staffchat.leave") .processPlaceholder("channel", channel.getChannelName()).sendPrefixedMessage(player); return ReturnType.SUCCESS; } - plugin.getLocale().getMessage("event.staffchat.nochannels").sendPrefixedMessage(player); + this.plugin.getLocale().getMessage("event.staffchat.nochannels").sendPrefixedMessage(player); return ReturnType.FAILURE; } - plugin.getLocale().getMessage("event.staffchat.join") + this.plugin.getLocale().getMessage("event.staffchat.join") .processPlaceholder("channel", channelName).sendPrefixedMessage(player); - plugin.getStaffChatManager().getChat(channelName).addMember(player); + this.plugin.getStaffChatManager().getChat(channelName).addMember(player); return ReturnType.SUCCESS; } @Override protected List onTab(CommandSender sender, String... args) { - return new ArrayList<>(plugin.getStaffChatManager().getChats().keySet()); + return new ArrayList<>(this.plugin.getStaffChatManager().getChats().keySet()); } @Override diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandTicket.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandTicket.java index 41d1eec..972c95b 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandTicket.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandTicket.java @@ -10,7 +10,6 @@ import org.bukkit.entity.Player; import java.util.List; public class CommandTicket extends AbstractCommand { - private final UltimateModeration plugin; private final GuiManager guiManager; @@ -23,7 +22,7 @@ public class CommandTicket extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { Player senderP = ((Player) sender); - guiManager.showGUI(senderP, new TicketManagerGui(plugin, senderP, senderP)); + this.guiManager.showGUI(senderP, new TicketManagerGui(this.plugin, senderP, senderP)); return ReturnType.SUCCESS; } @@ -46,5 +45,4 @@ public class CommandTicket extends AbstractCommand { public String getDescription() { return "Opens the ticket interface."; } - } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandToggleChat.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandToggleChat.java index 7967f1e..745861d 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandToggleChat.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandToggleChat.java @@ -11,7 +11,6 @@ import org.bukkit.entity.Player; import java.util.List; public class CommandToggleChat extends AbstractCommand { - private final UltimateModeration plugin; /* @@ -26,25 +25,25 @@ public class CommandToggleChat extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { - toggled = !toggled; + this.toggled = !this.toggled; - Message message = toggled ? plugin.getLocale().getMessage("command.togglechat.toggledOn") - : plugin.getLocale().getMessage("command.togglechat.toggledOff"); + Message message = this.toggled ? this.plugin.getLocale().getMessage("command.togglechat.toggledOn") + : this.plugin.getLocale().getMessage("command.togglechat.toggledOff"); - ChatListener.setChatToggled(toggled); + ChatListener.setChatToggled(this.toggled); for (Player player : Bukkit.getOnlinePlayers()) { - message.sendPrefixedMessage(player); - if (!player.hasPermission(getPermissionNode() + ".bypass")) + if (!player.hasPermission(getPermissionNode() + ".bypass")) { continue; - - plugin.getLocale().getMessage("command.togglechat.bypass").sendMessage(player); + } + this.plugin.getLocale().getMessage("command.togglechat.bypass").sendMessage(player); } - if (!(sender instanceof Player)) + if (!(sender instanceof Player)) { message.sendPrefixedMessage(sender); + } return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandUltimateModeration.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandUltimateModeration.java index b077705..1ff0e13 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandUltimateModeration.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandUltimateModeration.java @@ -9,7 +9,6 @@ import org.bukkit.entity.Player; import java.util.List; public class CommandUltimateModeration extends AbstractCommand { - private final UltimateModeration plugin; public CommandUltimateModeration(UltimateModeration plugin) { @@ -19,7 +18,7 @@ public class CommandUltimateModeration extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { - plugin.getGuiManager().showGUI((Player) sender, new MainGui(plugin, (Player) sender)); + this.plugin.getGuiManager().showGUI((Player) sender, new MainGui(this.plugin, (Player) sender)); return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandUnBan.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandUnBan.java index edf9ca9..8ab782f 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandUnBan.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandUnBan.java @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.List; public class CommandUnBan extends AbstractCommand { - private final UltimateModeration plugin; public CommandUnBan(UltimateModeration plugin) { @@ -23,22 +22,23 @@ public class CommandUnBan extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { - if (args.length != 1) + if (args.length != 1) { return ReturnType.SYNTAX_ERROR; + } OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); - if (!plugin.getPunishmentManager().getPlayer(player).getActivePunishments() + if (!this.plugin.getPunishmentManager().getPlayer(player).getActivePunishments() .stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) { - plugin.getLocale().newMessage("That player isn't banned.").sendPrefixedMessage(sender); + this.plugin.getLocale().newMessage("That player isn't banned.").sendPrefixedMessage(sender); return ReturnType.FAILURE; } - PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(player); + PlayerPunishData playerPunishData = this.plugin.getPunishmentManager().getPlayer(player); playerPunishData.expirePunishments(PunishmentType.BAN); - plugin.getLocale().getMessage("event.unban.success") + this.plugin.getLocale().getMessage("event.unban.success") .processPlaceholder("player", player.getName()).sendPrefixedMessage(sender); return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandUnMute.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandUnMute.java index 061477f..6f78b7d 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandUnMute.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandUnMute.java @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.List; public class CommandUnMute extends AbstractCommand { - private final UltimateModeration plugin; public CommandUnMute(UltimateModeration plugin) { @@ -28,17 +27,17 @@ public class CommandUnMute extends AbstractCommand { OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); - if (!plugin.getPunishmentManager().getPlayer(player).getActivePunishments() + if (!this.plugin.getPunishmentManager().getPlayer(player).getActivePunishments() .stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.MUTE)) { - plugin.getLocale().newMessage("That player isn't muted.").sendPrefixedMessage(sender); + this.plugin.getLocale().newMessage("That player isn't muted.").sendPrefixedMessage(sender); return ReturnType.FAILURE; } - PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(player); + PlayerPunishData playerPunishData = this.plugin.getPunishmentManager().getPlayer(player); playerPunishData.expirePunishments(PunishmentType.MUTE); - plugin.getLocale().newMessage(plugin.getLocale().getMessage("event.unmute.success") + this.plugin.getLocale().newMessage(this.plugin.getLocale().getMessage("event.unmute.success") .processPlaceholder("player", player.getName()).getMessage()).sendPrefixedMessage(sender); return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandVanish.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandVanish.java index bc30f21..7a7db70 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandVanish.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandVanish.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.UUID; public class CommandVanish extends AbstractCommand { - private static final List inVanish = new ArrayList<>(); public CommandVanish() { @@ -28,7 +27,9 @@ public class CommandVanish extends AbstractCommand { public static void registerVanishedPlayers(Player player) { for (UUID uuid : inVanish) { Player vanished = Bukkit.getPlayer(uuid); - if (vanished == null) continue; + if (vanished == null) { + continue; + } if (player.hasPermission("um.vanish.bypass")) { player.showPlayer(vanished); } else { @@ -44,15 +45,17 @@ public class CommandVanish extends AbstractCommand { if (inVanish.contains(uuid)) { inVanish.remove(uuid); - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { player.setInvulnerable(false); + } player.setCanPickupItems(true); instance.getLocale().getMessage("command.vanish.toggledOff").sendPrefixedMessage(player); } else { inVanish.add(uuid); player.setCanPickupItems(false); - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { player.setInvulnerable(true); + } instance.getLocale().getMessage("command.vanish.toggledOn").sendPrefixedMessage(player); } @@ -74,15 +77,17 @@ public class CommandVanish extends AbstractCommand { float xx = (float) (0 + (Math.random() * 1)); float yy = (float) (0 + (Math.random() * 2)); float zz = (float) (0 + (Math.random() * 1)); - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) { player.getWorld().spawnParticle(Particle.valueOf(Settings.VANISH_PARTICLE.getString()), player.getLocation().add(0, 1, 0), 35, xx, yy, zz, 0); + } } for (Player p : Bukkit.getOnlinePlayers()) { - if (inVanish.contains(uuid)) + if (inVanish.contains(uuid)) { registerVanishedPlayers(p); - else + } else { p.showPlayer(player); + } } for (Entity e : player.getNearbyEntities(30, 30, 30)) { if (e instanceof Monster) { diff --git a/src/main/java/com/songoda/ultimatemoderation/commands/CommandWarn.java b/src/main/java/com/songoda/ultimatemoderation/commands/CommandWarn.java index 771a19a..82d523d 100644 --- a/src/main/java/com/songoda/ultimatemoderation/commands/CommandWarn.java +++ b/src/main/java/com/songoda/ultimatemoderation/commands/CommandWarn.java @@ -1,10 +1,10 @@ package com.songoda.ultimatemoderation.commands; import com.songoda.core.commands.AbstractCommand; +import com.songoda.core.utils.TimeUtils; import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.punish.Punishment; import com.songoda.ultimatemoderation.punish.PunishmentType; -import com.songoda.ultimatemoderation.utils.Methods; import com.songoda.ultimatemoderation.utils.VaultPermissions; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @@ -17,7 +17,6 @@ import java.util.Collections; import java.util.List; public class CommandWarn extends AbstractCommand { - private final UltimateModeration plugin; public CommandWarn(UltimateModeration plugin) { @@ -27,21 +26,23 @@ public class CommandWarn extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { - if (args.length < 1) + if (args.length < 1) { return ReturnType.SYNTAX_ERROR; + } - // I dream of the day where someone creates a ticket because + // I dream of the day when someone creates a ticket because // they can't ban someone for the reason "Stole me 2h sword". long duration = 0; StringBuilder reasonBuilder = new StringBuilder(); if (args.length > 1) { for (int i = 1; i < args.length; i++) { String line = args[i]; - long time = Methods.parseTime(line); - if (time != 0) + long time = TimeUtils.parseTime(line); + if (time != 0) { duration += time; - else + } else { reasonBuilder.append(line).append(" "); + } } } @@ -50,7 +51,7 @@ public class CommandWarn extends AbstractCommand { OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.warning.exempt")) { - plugin.getLocale().newMessage("You cannot warn that player.").sendPrefixedMessage(sender); + this.plugin.getLocale().newMessage("You cannot warn that player.").sendPrefixedMessage(sender); return ReturnType.FAILURE; } diff --git a/src/main/java/com/songoda/ultimatemoderation/database/DataManager.java b/src/main/java/com/songoda/ultimatemoderation/database/DataManager.java index 709a646..3e6a792 100644 --- a/src/main/java/com/songoda/ultimatemoderation/database/DataManager.java +++ b/src/main/java/com/songoda/ultimatemoderation/database/DataManager.java @@ -25,7 +25,6 @@ import java.util.UUID; import java.util.function.Consumer; public class DataManager extends DataManagerAbstract { - public DataManager(DatabaseConnector databaseConnector, Plugin plugin) { super(databaseConnector, plugin); } diff --git a/src/main/java/com/songoda/ultimatemoderation/database/migrations/_1_InitialMigration.java b/src/main/java/com/songoda/ultimatemoderation/database/migrations/_1_InitialMigration.java index af9d89f..3ddc1ea 100644 --- a/src/main/java/com/songoda/ultimatemoderation/database/migrations/_1_InitialMigration.java +++ b/src/main/java/com/songoda/ultimatemoderation/database/migrations/_1_InitialMigration.java @@ -9,14 +9,16 @@ import java.sql.SQLException; import java.sql.Statement; public class _1_InitialMigration extends DataMigration { + private final UltimateModeration plugin; - public _1_InitialMigration() { + public _1_InitialMigration(UltimateModeration plugin) { super(1); + this.plugin = plugin; } @Override public void migrate(Connection connection, String tablePrefix) throws SQLException { - String autoIncrement = UltimateModeration.getInstance().getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : ""; + String autoIncrement = this.plugin.getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : ""; // Create templates table try (Statement statement = connection.createStatement()) { diff --git a/src/main/java/com/songoda/ultimatemoderation/gui/MainGui.java b/src/main/java/com/songoda/ultimatemoderation/gui/MainGui.java index 408e3ee..ad94264 100644 --- a/src/main/java/com/songoda/ultimatemoderation/gui/MainGui.java +++ b/src/main/java/com/songoda/ultimatemoderation/gui/MainGui.java @@ -24,7 +24,6 @@ import java.util.UUID; import java.util.stream.Collectors; public class MainGui extends Gui { - private final UltimateModeration plugin; private Online currentOnline = Online.ONLINE; @@ -38,11 +37,14 @@ public class MainGui extends Gui { setDefaultItem(null); this.viewer = viewer; - for (Player player : Bukkit.getOnlinePlayers()) - players.add(player.getUniqueId()); + for (Player player : Bukkit.getOnlinePlayers()) { + this.players.add(player.getUniqueId()); + } for (UUID uuid : plugin.getPunishmentManager().getPunishments().keySet()) { - if (Bukkit.getOfflinePlayer(uuid).isOnline()) continue; - players.add(uuid); + if (Bukkit.getOfflinePlayer(uuid).isOnline()) { + continue; + } + this.players.add(uuid); } setTitle(plugin.getLocale().getMessage("gui.players.title").getMessage()); @@ -51,8 +53,9 @@ public class MainGui extends Gui { } private void showPage() { - if (inventory != null) - inventory.clear(); + if (this.inventory != null) { + this.inventory.clear(); + } setActionForRange(0, 53, null); // decorate the edges @@ -69,14 +72,16 @@ public class MainGui extends Gui { mirrorFill(0, 1, true, true, glass2); setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ENDER_PEARL, - plugin.getLocale().getMessage("gui.players.search").getMessage()), + this.plugin.getLocale().getMessage("gui.players.search").getMessage()), (event) -> { AnvilGui gui = new AnvilGui(event.player, this); gui.setAction(event2 -> { - List players = new ArrayList<>(plugin.getPunishmentManager().getPunishments().keySet()); + List players = new ArrayList<>(this.plugin.getPunishmentManager().getPunishments().keySet()); for (Player p : Bukkit.getOnlinePlayers()) { - if (players.contains(p.getUniqueId())) continue; + if (players.contains(p.getUniqueId())) { + continue; + } players.add(p.getUniqueId()); } @@ -87,115 +92,118 @@ public class MainGui extends Gui { this.players.addAll(found); showPage(); } else { - plugin.getLocale().getMessage("gui.players.nonefound").sendMessage(event.player); + this.plugin.getLocale().getMessage("gui.players.nonefound").sendMessage(event.player); } event2.player.closeInventory(); }); ItemStack item = new ItemStack(Material.PAPER); ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(plugin.getLocale().getMessage("gui.players.name").getMessage()); + meta.setDisplayName(this.plugin.getLocale().getMessage("gui.players.name").getMessage()); item.setItemMeta(meta); gui.setInput(item); - guiManager.showGUI(event.player, gui); + this.guiManager.showGUI(event.player, gui); }); - setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.HOPPER, TextUtils.formatText("&6" + currentOnline.getTranslation())), + setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.HOPPER, TextUtils.formatText("&6" + this.currentOnline.getTranslation())), (event) -> { - this.currentOnline = currentOnline.next(); + this.currentOnline = this.currentOnline.next(); this.page = 1; showPage(); }); - if (viewer.hasPermission("um.tickets")) + if (this.viewer.hasPermission("um.tickets")) { setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.CHEST, - plugin.getLocale().getMessage("gui.players.button.tickets").getMessage()), - (event) -> guiManager.showGUI(event.player, new TicketManagerGui(plugin, null, viewer))); + this.plugin.getLocale().getMessage("gui.players.button.tickets").getMessage()), + (event) -> this.guiManager.showGUI(event.player, new TicketManagerGui(this.plugin, null, this.viewer))); + } - if (viewer.hasPermission("um.templates")) + if (this.viewer.hasPermission("um.templates")) { setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.MAP, - plugin.getLocale().getMessage("gui.players.button.templatemanager").getMessage()), - (events) -> guiManager.showGUI(events.player, new TemplateManagerGui(plugin, viewer))); + this.plugin.getLocale().getMessage("gui.players.button.templatemanager").getMessage()), + (events) -> this.guiManager.showGUI(events.player, new TemplateManagerGui(this.plugin, this.viewer))); + } - List toUse = players.stream() - .filter(u -> currentOnline == Online.BOTH - || currentOnline == Online.ONLINE && Bukkit.getOfflinePlayer(u).isOnline() - || currentOnline == Online.OFFLINE && !Bukkit.getOfflinePlayer(u).isOnline()).collect(Collectors.toList()); + List toUse = this.players.stream() + .filter(u -> this.currentOnline == Online.BOTH + || this.currentOnline == Online.ONLINE && Bukkit.getOfflinePlayer(u).isOnline() + || this.currentOnline == Online.OFFLINE && !Bukkit.getOfflinePlayer(u).isOnline()).collect(Collectors.toList()); this.pages = (int) Math.max(1, Math.ceil(toUse.size() / ((double) 28))); - final List toUseFinal = toUse.stream().skip((page - 1) * 28).limit(28).collect(Collectors.toList()); + final List toUseFinal = toUse.stream().skip((this.page - 1) * 28).limit(28).collect(Collectors.toList()); - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> { int num = 11; for (UUID uuid : toUseFinal) { - if (num == 16 || num == 36) + if (num == 16 || num == 36) { num = num + 2; + } OfflinePlayer pl = Bukkit.getOfflinePlayer(uuid); ItemStack skull = ItemUtils.getPlayerSkull(pl); setItem(num, skull); - PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(pl); + PlayerPunishData playerPunishData = this.plugin.getPunishmentManager().getPlayer(pl); ArrayList lore = new ArrayList<>(); - lore.add(plugin.getLocale().getMessage("gui.players.click").getMessage()); + lore.add(this.plugin.getLocale().getMessage("gui.players.click").getMessage()); lore.add(""); - int ticketAmt = (int) plugin.getTicketManager().getTicketsAbout(pl).stream() + int ticketAmt = (int) this.plugin.getTicketManager().getTicketsAbout(pl).stream() .filter(t -> t.getStatus() == TicketStatus.OPEN).count(); - if (ticketAmt == 0) - lore.add(plugin.getLocale().getMessage("gui.players.notickets").getMessage()); - else { - if (ticketAmt == 1) - lore.add(plugin.getLocale().getMessage("gui.players.ticketsone").getMessage()); - else - lore.add(plugin.getLocale().getMessage("gui.players.tickets") + if (ticketAmt == 0) { + lore.add(this.plugin.getLocale().getMessage("gui.players.notickets").getMessage()); + } else { + if (ticketAmt == 1) { + lore.add(this.plugin.getLocale().getMessage("gui.players.ticketsone").getMessage()); + } else { + lore.add(this.plugin.getLocale().getMessage("gui.players.tickets") .processPlaceholder("amount", ticketAmt).getMessage()); + } } int warningAmt = playerPunishData.getActivePunishments(PunishmentType.WARNING).size(); - if (warningAmt == 0) - lore.add(plugin.getLocale().getMessage("gui.players.nowarnings").getMessage()); - else { - if (warningAmt == 1) - lore.add(plugin.getLocale().getMessage("gui.players.warningsone").getMessage()); - else - lore.add(plugin.getLocale().getMessage("gui.players.warnings") + if (warningAmt == 0) { + lore.add(this.plugin.getLocale().getMessage("gui.players.nowarnings").getMessage()); + } else { + if (warningAmt == 1) { + lore.add(this.plugin.getLocale().getMessage("gui.players.warningsone").getMessage()); + } else { + lore.add(this.plugin.getLocale().getMessage("gui.players.warnings") .processPlaceholder("amount", warningAmt).getMessage()); + } } setButton(num, GuiUtils.createButtonItem(skull, TextUtils.formatText("&7&l" + pl.getName()), lore), - (event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, pl, viewer))); + (event) -> this.guiManager.showGUI(event.player, new PlayerGui(this.plugin, pl, this.viewer))); num++; } }); // enable page events - setNextPage(4, 7, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage())); - setPrevPage(4, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage())); + setNextPage(4, 7, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage())); + setPrevPage(4, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage())); setOnPage((event) -> showPage()); } private enum Online { - ONLINE, OFFLINE, BOTH; - private static Online[] vals = values(); - public Online next() { - return vals[(this.ordinal() != vals.length - 1 ? this.ordinal() + 1 : 0)]; + return values()[(this.ordinal() != values().length - 1 ? this.ordinal() + 1 : 0)]; } public String getTranslation() { - return UltimateModeration.getInstance().getLocale() - .getMessage("gui.players.online." + this.name().toLowerCase()).getMessage(); + return UltimateModeration.getPlugin(UltimateModeration.class) + .getLocale() + .getMessage("gui.players.online." + this.name().toLowerCase()) + .getMessage(); } } - } diff --git a/src/main/java/com/songoda/ultimatemoderation/gui/ModerateGui.java b/src/main/java/com/songoda/ultimatemoderation/gui/ModerateGui.java index ac2d360..35ad2a9 100644 --- a/src/main/java/com/songoda/ultimatemoderation/gui/ModerateGui.java +++ b/src/main/java/com/songoda/ultimatemoderation/gui/ModerateGui.java @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.List; public class ModerateGui extends Gui { - public ModerateGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) { super(5); setDefaultItem(null); @@ -38,8 +37,8 @@ public class ModerateGui extends Gui { mirrorFill(0, 1, true, true, glass2); setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, - plugin.getLocale().getMessage("gui.general.back").getMessage()), - (event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player))); + plugin.getLocale().getMessage("gui.general.back").getMessage()), + (event) -> this.guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player))); int[] slots = new int[]{11, 13, 15, 29, 31, 33}; @@ -47,11 +46,14 @@ public class ModerateGui extends Gui { int i = 0; for (AbstractModeration moderation : moderations) { - if (!moderation.hasPermission(player) || moderation.isExempt(toModerate)) continue; + if (!moderation.hasPermission(player) || moderation.isExempt(toModerate)) { + continue; + } + int slot = slots[i]; setButton(slot, GuiUtils.createButtonItem(moderation.getIcon(), - TextUtils.formatText("&6&l" + moderation.getProper()), - TextUtils.formatText("&7" + moderation.getDescription())), + TextUtils.formatText("&6&l" + moderation.getProper()), + TextUtils.formatText("&7" + moderation.getDescription())), (event) -> moderation.runPreModeration(player, toModerate)); i++; } diff --git a/src/main/java/com/songoda/ultimatemoderation/gui/NotesManagerGui.java b/src/main/java/com/songoda/ultimatemoderation/gui/NotesManagerGui.java index 365c78d..39ebc82 100644 --- a/src/main/java/com/songoda/ultimatemoderation/gui/NotesManagerGui.java +++ b/src/main/java/com/songoda/ultimatemoderation/gui/NotesManagerGui.java @@ -20,7 +20,6 @@ import java.util.List; import java.util.stream.Collectors; public class NotesManagerGui extends Gui { - private final UltimateModeration plugin; private final OfflinePlayer toModerate; @@ -42,19 +41,20 @@ public class NotesManagerGui extends Gui { } private void showPage() { - if (inventory != null) - inventory.clear(); + if (this.inventory != null) { + this.inventory.clear(); + } setActionForRange(0, 53, null); - int numNotes = plugin.getPunishmentManager().getPlayer(toModerate).getNotes().size(); + int numNotes = this.plugin.getPunishmentManager().getPlayer(this.toModerate).getNotes().size(); this.pages = (int) Math.max(1, Math.ceil(numNotes / ((double) 28))); - List notes = plugin.getPunishmentManager().getPlayer(toModerate).getNotes().stream() - .skip((page - 1) * 28).limit(28).collect(Collectors.toList()); + List notes = this.plugin.getPunishmentManager().getPlayer(this.toModerate).getNotes().stream() + .skip((this.page - 1) * 28).limit(28).collect(Collectors.toList()); // enable page events - setNextPage(0, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage())); - setPrevPage(0, 3, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage())); + setNextPage(0, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage())); + setPrevPage(0, 3, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage())); setOnPage((event) -> showPage()); // decorate the edges @@ -71,37 +71,40 @@ public class NotesManagerGui extends Gui { mirrorFill(0, 1, true, true, glass2); setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, - plugin.getLocale().getMessage("gui.general.back").getMessage()), - (event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player))); + this.plugin.getLocale().getMessage("gui.general.back").getMessage()), + (event) -> this.guiManager.showGUI(event.player, new PlayerGui(this.plugin, this.toModerate, event.player))); - if (create) + if (this.create) { setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE, - plugin.getLocale().getMessage("gui.notes.create").getMessage()), + this.plugin.getLocale().getMessage("gui.notes.create").getMessage()), (event) -> { - ChatPrompt.showPrompt(plugin, event.player, - plugin.getLocale().getMessage("gui.notes.type").getMessage(), + ChatPrompt.showPrompt(this.plugin, event.player, + this.plugin.getLocale().getMessage("gui.notes.type").getMessage(), (response) -> { PunishmentNote note = new PunishmentNote(response.getMessage(), - event.player.getUniqueId(), toModerate.getUniqueId(), + event.player.getUniqueId(), this.toModerate.getUniqueId(), System.currentTimeMillis()); - plugin.getPunishmentManager().getPlayer(toModerate).addNotes(note); - plugin.getDataManager().createNote(note); + this.plugin.getPunishmentManager().getPlayer(this.toModerate).addNotes(note); + this.plugin.getDataManager().createNote(note); showPage(); - }).setOnClose(() -> guiManager.showGUI(event.player, new NotesManagerGui(plugin, toModerate, event.player))); + }).setOnClose(() -> this.guiManager.showGUI(event.player, new NotesManagerGui(this.plugin, this.toModerate, event.player))); }); + } int num = 11; for (PunishmentNote note : notes) { - if (num == 16 || num == 36) + if (num == 16 || num == 36) { num = num + 2; + } String noteStr = note.getNote(); ArrayList lore = new ArrayList<>(); int lastIndex = 0; for (int n = 0; n < noteStr.length(); n++) { - if (n - lastIndex < 20) + if (n - lastIndex < 20) { continue; + } if (noteStr.charAt(n) == ' ') { lore.add("&6" + noteStr.substring(lastIndex, n).trim()); @@ -109,8 +112,9 @@ public class NotesManagerGui extends Gui { } } - if (lastIndex - noteStr.length() < 20) + if (lastIndex - noteStr.length() < 20) { lore.add("&6" + noteStr.substring(lastIndex).trim()); + } String name = lore.get(0); lore.remove(0); @@ -119,25 +123,26 @@ public class NotesManagerGui extends Gui { SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy"); - lore.add(plugin.getLocale().getMessage("gui.notes.createdby") + lore.add(this.plugin.getLocale().getMessage("gui.notes.createdby") .processPlaceholder("player", Bukkit.getOfflinePlayer(note.getAuthor()).getName()) .getMessage()); - lore.add(plugin.getLocale().getMessage("gui.notes.createdon") + lore.add(this.plugin.getLocale().getMessage("gui.notes.createdon") .processPlaceholder("sent", format.format(new Date(note.getCreationDate()))) .getMessage()); - if (delete) lore.add(plugin.getLocale().getMessage("gui.notes.remove").getMessage()); + if (this.delete) { + lore.add(this.plugin.getLocale().getMessage("gui.notes.remove").getMessage()); + } setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText(name), TextUtils.formatText(lore)), (event) -> { - if (delete) { - plugin.getPunishmentManager().getPlayer(toModerate).removeNotes(note); - plugin.getDataManager().deleteNote(note); + if (this.delete) { + this.plugin.getPunishmentManager().getPlayer(this.toModerate).removeNotes(note); + this.plugin.getDataManager().deleteNote(note); showPage(); } }); num++; } - } } diff --git a/src/main/java/com/songoda/ultimatemoderation/gui/PlayerGui.java b/src/main/java/com/songoda/ultimatemoderation/gui/PlayerGui.java index ff81ecf..189d89e 100644 --- a/src/main/java/com/songoda/ultimatemoderation/gui/PlayerGui.java +++ b/src/main/java/com/songoda/ultimatemoderation/gui/PlayerGui.java @@ -12,7 +12,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public class PlayerGui extends Gui { - public PlayerGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) { super(6); setDefaultItem(null); @@ -48,35 +47,40 @@ public class PlayerGui extends Gui { : "&c" + plugin.getLocale().getMessage("gui.players.online.offline").getMessage()))); setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, - plugin.getLocale().getMessage("gui.general.back").getMessage()), - (event) -> guiManager.showGUI(event.player, new MainGui(plugin, event.player))); + plugin.getLocale().getMessage("gui.general.back").getMessage()), + (event) -> this.guiManager.showGUI(event.player, new MainGui(plugin, event.player))); - if (punish) + if (punish) { setButton(38, GuiUtils.createButtonItem(CompatibleMaterial.ANVIL, - plugin.getLocale().getMessage("gui.player.punish").getMessage()), + plugin.getLocale().getMessage("gui.player.punish").getMessage()), (event) -> plugin.getGuiManager().showGUI(player, new PunishGui(plugin, toModerate, null, event.player))); + } - if (tickets) + if (tickets) { setButton(30, GuiUtils.createButtonItem(CompatibleMaterial.CHEST, - plugin.getLocale().getMessage("gui.player.tickets").getMessage()), + plugin.getLocale().getMessage("gui.player.tickets").getMessage()), (event) -> plugin.getGuiManager().showGUI(player, new TicketManagerGui(plugin, toModerate, event.player))); + } - if (toModerate.isOnline() && punishments) + if (toModerate.isOnline() && punishments) { setButton(32, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD, - plugin.getLocale().getMessage("gui.player.punishments").getMessage()), + plugin.getLocale().getMessage("gui.player.punishments").getMessage()), (event) -> plugin.getGuiManager().showGUI(player, new PunishmentsGui(plugin, toModerate))); + } - if (notes) + if (notes) { setButton(42, GuiUtils.createButtonItem(CompatibleMaterial.MAP, - plugin.getLocale().getMessage("gui.player.notes").getMessage()), + plugin.getLocale().getMessage("gui.player.notes").getMessage()), (event) -> plugin.getGuiManager().showGUI(player, new NotesManagerGui(plugin, toModerate, event.player))); + } - if (moderate) + if (moderate) { setButton(40, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_CHESTPLATE, - plugin.getLocale().getMessage("gui.player.moderate").getMessage()), - (event) -> guiManager.showGUI(player, new ModerateGui(plugin, toModerate, event.player))); + plugin.getLocale().getMessage("gui.player.moderate").getMessage()), + (event) -> this.guiManager.showGUI(player, new ModerateGui(plugin, toModerate, event.player))); + } } } diff --git a/src/main/java/com/songoda/ultimatemoderation/gui/PunishGui.java b/src/main/java/com/songoda/ultimatemoderation/gui/PunishGui.java index a0aadea..6f2ab94 100644 --- a/src/main/java/com/songoda/ultimatemoderation/gui/PunishGui.java +++ b/src/main/java/com/songoda/ultimatemoderation/gui/PunishGui.java @@ -6,12 +6,12 @@ import com.songoda.core.gui.Gui; import com.songoda.core.gui.GuiUtils; import com.songoda.core.utils.ItemUtils; import com.songoda.core.utils.TextUtils; +import com.songoda.core.utils.TimeUtils; import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.punish.Punishment; import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.template.Template; import com.songoda.ultimatemoderation.settings.Settings; -import com.songoda.ultimatemoderation.utils.Methods; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -23,7 +23,6 @@ import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; public class PunishGui extends Gui { - private final UltimateModeration plugin; private final Player player; private final OfflinePlayer toModerate; @@ -56,15 +55,18 @@ public class PunishGui extends Gui { setTitle(toModerate == null ? plugin.getLocale().getMessage("gui.punish.title.template").getMessage() : plugin.getLocale().getMessage("gui.punish.title") .processPlaceholder("toModerate", toModerate.getName()).getMessage()); - if (toModerate != null) runTask(); + if (toModerate != null) { + runTask(); + } - setOnClose((event) -> Bukkit.getScheduler().cancelTask(task)); + setOnClose((event) -> Bukkit.getScheduler().cancelTask(this.task)); paint(); } public void paint() { - if (inventory != null) - inventory.clear(); + if (this.inventory != null) { + this.inventory.clear(); + } setActionForRange(0, 53, null); // decorate the edges @@ -81,180 +83,197 @@ public class PunishGui extends Gui { mirrorFill(2, 0, false, true, glass2); mirrorFill(0, 1, true, true, glass2); - if (toModerate != null) - setItem(13, GuiUtils.createButtonItem(ItemUtils.getPlayerSkull(toModerate), - TextUtils.formatText("&6&l" + toModerate.getName()))); + if (this.toModerate != null) { + setItem(13, GuiUtils.createButtonItem(ItemUtils.getPlayerSkull(this.toModerate), + TextUtils.formatText("&6&l" + this.toModerate.getName()))); + } - if (player.hasPermission("um." + type.toString().toLowerCase())) + if (this.player.hasPermission("um." + this.type.toString().toLowerCase())) { setButton(22, GuiUtils.createButtonItem(CompatibleMaterial.EMERALD_BLOCK, - plugin.getLocale().getMessage("gui.punish.submit").getMessage()), + this.plugin.getLocale().getMessage("gui.punish.submit").getMessage()), (event) -> { - if (!player.hasPermission("um." + type.toString().toLowerCase())) return; - if (duration == -1 && type == PunishmentType.BAN && !player.hasPermission("um.ban.permanent")) + if (!this.player.hasPermission("um." + this.type.toString().toLowerCase())) { return; + } + if (this.duration == -1 && this.type == PunishmentType.BAN && !this.player.hasPermission("um.ban.permanent")) { + return; + } - if (toModerate == null) { - if (reason == null || templateName == null) return; + if (this.toModerate == null) { + if (this.reason == null || this.templateName == null) { + return; + } - if (template == null) + if (this.template == null) { finishTemplate(); - else + } else { updateTemplate(); + } return; } - switch (type) { + switch (this.type) { case BAN: case MUTE: case WARNING: - new Punishment(type, duration, reason).execute(player, toModerate); + new Punishment(this.type, this.duration, this.reason).execute(this.player, this.toModerate); break; case KICK: - new Punishment(type, reason).execute(player, toModerate); + new Punishment(this.type, this.reason).execute(this.player, this.toModerate); break; } - player.closeInventory(); + this.player.closeInventory(); }); + } setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, - plugin.getLocale().getMessage("gui.general.back").getMessage()), + this.plugin.getLocale().getMessage("gui.general.back").getMessage()), (event) -> { - if (toModerate != null) - guiManager.showGUI(player, new PlayerGui(plugin, toModerate, player)); - else - guiManager.showGUI(player, new TemplateManagerGui(plugin, player)); + if (this.toModerate != null) { + this.guiManager.showGUI(this.player, new PlayerGui(this.plugin, this.toModerate, this.player)); + } else { + this.guiManager.showGUI(this.player, new TemplateManagerGui(this.plugin, this.player)); + } }); setButton(28, GuiUtils.createButtonItem(CompatibleMaterial.ANVIL, - plugin.getLocale().getMessage("gui.punish.type.punishment").getMessage(), - TextUtils.formatText("&7" + type.getTranslation()), - "", - plugin.getLocale().getMessage("gui.punish.type.punishment.click").getMessage()), + this.plugin.getLocale().getMessage("gui.punish.type.punishment").getMessage(), + TextUtils.formatText("&7" + this.type.getTranslation()), + "", + this.plugin.getLocale().getMessage("gui.punish.type.punishment.click").getMessage()), (event) -> { this.type = this.type.next(); - justSaved = false; + this.justSaved = false; paint(); }); - ItemStack templateItem = toModerate != null ? GuiUtils.createButtonItem(CompatibleMaterial.MAP, - plugin.getLocale().getMessage("gui.punish.type.template").getMessage(), - plugin.getLocale().getMessage("gui.punish.type.template.current") + ItemStack templateItem = this.toModerate != null ? GuiUtils.createButtonItem(CompatibleMaterial.MAP, + this.plugin.getLocale().getMessage("gui.punish.type.template").getMessage(), + this.plugin.getLocale().getMessage("gui.punish.type.template.current") .processPlaceholder("template", - template == null - ? plugin.getLocale().getMessage("gui.general.none").getMessage() - : template.getName()).getMessage(), + this.template == null + ? this.plugin.getLocale().getMessage("gui.general.none").getMessage() + : this.template.getName()).getMessage(), "", - plugin.getLocale().getMessage(plugin.getTemplateManager().getTemplates().size() == 0 + this.plugin.getLocale().getMessage(this.plugin.getTemplateManager().getTemplates().size() == 0 ? "gui.punish.type.template.none" : "gui.punish.type.template.click").getMessage()) : GuiUtils.createButtonItem(CompatibleMaterial.MAP, - plugin.getLocale().getMessage("gui.punish.type.name").getMessage(), - plugin.getLocale().getMessage("gui.punish.type.name.current") + this.plugin.getLocale().getMessage("gui.punish.type.name").getMessage(), + this.plugin.getLocale().getMessage("gui.punish.type.name.current") .processPlaceholder("name", - templateName == null - ? plugin.getLocale().getMessage("gui.punish.type.name.current").getMessage() - : templateName).getMessage(), + this.templateName == null + ? this.plugin.getLocale().getMessage("gui.punish.type.name.current").getMessage() + : this.templateName).getMessage(), "", - plugin.getLocale().getMessage("gui.punish.type.name.current.click").getMessage()); + this.plugin.getLocale().getMessage("gui.punish.type.name.current.click").getMessage()); setButton(30, templateItem, (event) -> { - if (toModerate == null) { + if (this.toModerate == null) { nameTemplate(); return; } - if (plugin.getTemplateManager().getTemplates().size() == 0) return; + if (this.plugin.getTemplateManager().getTemplates().size() == 0) { + return; + } - if (player.hasPermission("um.templates.use")) - guiManager.showGUI(player, new TemplateSelectorGui(plugin, this, player)); + if (this.player.hasPermission("um.templates.use")) { + this.guiManager.showGUI(this.player, new TemplateSelectorGui(this.plugin, this, this.player)); + } }); - if (type != PunishmentType.KICK) { + if (this.type != PunishmentType.KICK) { setButton(32, GuiUtils.createButtonItem(CompatibleMaterial.CLOCK, - plugin.getLocale().getMessage("gui.punish.type.duration").getMessage(), - plugin.getLocale().getMessage("gui.punish.type.duration.leftclick").getMessage(), - plugin.getLocale().getMessage("gui.punish.type.duration.rightclick").getMessage(), - "", - plugin.getLocale().getMessage("gui.punish.type.duration.current").getMessage(), - TextUtils.formatText("&6" + (duration == -1 ? plugin.getLocale().getMessage("gui.general.permanent").getMessage() - : Methods.makeReadable(duration)))), + this.plugin.getLocale().getMessage("gui.punish.type.duration").getMessage(), + this.plugin.getLocale().getMessage("gui.punish.type.duration.leftclick").getMessage(), + this.plugin.getLocale().getMessage("gui.punish.type.duration.rightclick").getMessage(), + "", + this.plugin.getLocale().getMessage("gui.punish.type.duration.current").getMessage(), + TextUtils.formatText("&6" + (this.duration == -1 ? this.plugin.getLocale().getMessage("gui.general.permanent").getMessage() + : TimeUtils.makeReadable(this.duration)))), (event) -> { - if (this.type == PunishmentType.KICK) return; + if (this.type == PunishmentType.KICK) { + return; + } if (event.clickType == ClickType.LEFT) { - AnvilGui gui = new AnvilGui(player, this); + AnvilGui gui = new AnvilGui(this.player, this); gui.setAction(evt -> { - this.duration = Methods.parseTime(gui.getInputText()); - justSaved = false; - guiManager.showGUI(player, this); + this.duration = TimeUtils.parseTime(gui.getInputText()); + this.justSaved = false; + this.guiManager.showGUI(this.player, this); paint(); }); ItemStack item = new ItemStack(Material.PAPER); ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(duration == -1 || duration == 0 ? "1d 1h 1m" : Methods.makeReadable(duration)); + meta.setDisplayName(this.duration == -1 || this.duration == 0 ? "1d 1h 1m" : TimeUtils.makeReadable(this.duration)); item.setItemMeta(meta); gui.setInput(item); - guiManager.showGUI(player, gui); + this.guiManager.showGUI(this.player, gui); } else { - duration = -1; + this.duration = -1; paint(); } }); } setButton(34, GuiUtils.createButtonItem(CompatibleMaterial.PAPER, - plugin.getLocale().getMessage("gui.punish.type.reason").getMessage(), - plugin.getLocale().getMessage("gui.punish.type.reason.click").getMessage(), + this.plugin.getLocale().getMessage("gui.punish.type.reason").getMessage(), + this.plugin.getLocale().getMessage("gui.punish.type.reason.click").getMessage(), "", - plugin.getLocale().getMessage("gui.punish.type.reason.current").getMessage(), - TextUtils.formatText("&6" + reason)), (event) -> { + this.plugin.getLocale().getMessage("gui.punish.type.reason.current").getMessage(), + TextUtils.formatText("&6" + this.reason)), (event) -> { - AnvilGui gui = new AnvilGui(player, this); + AnvilGui gui = new AnvilGui(this.player, this); gui.setAction(evnt -> { this.reason = gui.getInputText(); - justSaved = false; - guiManager.showGUI(player, this); + this.justSaved = false; + this.guiManager.showGUI(this.player, this); paint(); }); ItemStack item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER, - reason == null ? plugin.getLocale().getMessage("gui.general.reason").getMessage() : reason); + this.reason == null ? this.plugin.getLocale().getMessage("gui.general.reason").getMessage() : this.reason); gui.setInput(item); - guiManager.showGUI(player, gui); + this.guiManager.showGUI(this.player, gui); }); } private void notifyTemplate() { - if (reason == null || (justSaved && template != null)) { - inventory.setItem(4, null); + if (this.reason == null || (this.justSaved && this.template != null)) { + this.inventory.setItem(4, null); return; } CompatibleMaterial material = CompatibleMaterial.WHITE_WOOL; - String name = plugin.getLocale().getMessage("gui.punish.template.create").getMessage(); + String name = this.plugin.getLocale().getMessage("gui.punish.template.create").getMessage(); ArrayList lore = new ArrayList<>(); - lore.add(plugin.getLocale().getMessage("gui.punish.template.create2").getMessage()); + lore.add(this.plugin.getLocale().getMessage("gui.punish.template.create2").getMessage()); - if (!justSaved && template != null) { - name = plugin.getLocale().getMessage("gui.punish.template.leftclick").getMessage(); + if (!this.justSaved && this.template != null) { + name = this.plugin.getLocale().getMessage("gui.punish.template.leftclick").getMessage(); lore.clear(); - lore.add(plugin.getLocale().getMessage("gui.punish.template.leftclick2") - .processPlaceholder("template", template.getName()).getMessage()); + lore.add(this.plugin.getLocale().getMessage("gui.punish.template.leftclick2") + .processPlaceholder("template", this.template.getName()).getMessage()); lore.add(""); - lore.add(plugin.getLocale().getMessage("gui.punish.template.rightclick").getMessage()); + lore.add(this.plugin.getLocale().getMessage("gui.punish.template.rightclick").getMessage()); } - if (getItem(4) != null && CompatibleMaterial.getMaterial(getItem(4)) == CompatibleMaterial.WHITE_WOOL) + if (getItem(4) != null && CompatibleMaterial.getMaterial(getItem(4)) == CompatibleMaterial.WHITE_WOOL) { material = CompatibleMaterial.YELLOW_WOOL; + } setButton(4, GuiUtils.createButtonItem(material, name, lore), (event) -> { - if (reason == null || duration == 0) return; + if (this.reason == null || this.duration == 0) { + return; + } - if (template != null && event.clickType == ClickType.LEFT) { + if (this.template != null && event.clickType == ClickType.LEFT) { updateTemplate(); return; } @@ -263,51 +282,54 @@ public class PunishGui extends Gui { } public void runTask() { - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::notifyTemplate, 10L, 10L); + this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(this.plugin, this::notifyTemplate, 10L, 10L); } private void nameTemplate() { - AnvilGui gui = new AnvilGui(player, this); + AnvilGui gui = new AnvilGui(this.player, this); gui.setAction(event -> { this.templateName = gui.getInputText(); - if (reason != null && templateName != null) { - if (template == null) + if (this.reason != null && this.templateName != null) { + if (this.template == null) { finishTemplate(); - else + } else { updateTemplate(); + } } - justSaved = true; - guiManager.showGUI(player, this); + this.justSaved = true; + this.guiManager.showGUI(this.player, this); paint(); }); ItemStack item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER, - template == null ? plugin.getLocale().getMessage("gui.general.templatename").getMessage() : template.getName()); + this.template == null ? this.plugin.getLocale().getMessage("gui.general.templatename").getMessage() : this.template.getName()); gui.setInput(item); - guiManager.showGUI(player, gui); + this.guiManager.showGUI(this.player, gui); } private void updateTemplate() { Template template = new Template(this.type, this.duration, this.reason, this.template.getCreator(), this.templateName); - plugin.getTemplateManager().removeTemplate(this.template); - plugin.getTemplateManager().addTemplate(template); - plugin.getDataManager().deleteTemplate(this.template); - plugin.getDataManager().createTemplate(template); - justSaved = true; - if (toModerate == null) - guiManager.showGUI(player, new TemplateManagerGui(plugin, player)); + this.plugin.getTemplateManager().removeTemplate(this.template); + this.plugin.getTemplateManager().addTemplate(template); + this.plugin.getDataManager().deleteTemplate(this.template); + this.plugin.getDataManager().createTemplate(template); + this.justSaved = true; + if (this.toModerate == null) { + this.guiManager.showGUI(this.player, new TemplateManagerGui(this.plugin, this.player)); + } } private void finishTemplate() { - Template template = new Template(this.type, this.duration, this.reason, player, templateName); - plugin.getTemplateManager().addTemplate(template); - plugin.getDataManager().createTemplate(template); + Template template = new Template(this.type, this.duration, this.reason, this.player, this.templateName); + this.plugin.getTemplateManager().addTemplate(template); + this.plugin.getDataManager().createTemplate(template); this.template = template; - if (toModerate == null) - guiManager.showGUI(player, new TemplateManagerGui(plugin, player)); + if (this.toModerate == null) { + this.guiManager.showGUI(this.player, new TemplateManagerGui(this.plugin, this.player)); + } } public void setTemplate(Template template) { diff --git a/src/main/java/com/songoda/ultimatemoderation/gui/PunishmentsGui.java b/src/main/java/com/songoda/ultimatemoderation/gui/PunishmentsGui.java index a0e3e71..c8d3b00 100644 --- a/src/main/java/com/songoda/ultimatemoderation/gui/PunishmentsGui.java +++ b/src/main/java/com/songoda/ultimatemoderation/gui/PunishmentsGui.java @@ -4,12 +4,12 @@ import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.gui.Gui; import com.songoda.core.gui.GuiUtils; import com.songoda.core.utils.TextUtils; +import com.songoda.core.utils.TimeUtils; import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.punish.AppliedPunishment; import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.player.PlayerPunishData; import com.songoda.ultimatemoderation.settings.Settings; -import com.songoda.ultimatemoderation.utils.Methods; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.inventory.ItemStack; @@ -19,7 +19,6 @@ import java.util.List; import java.util.stream.Collectors; public class PunishmentsGui extends Gui { - private final UltimateModeration plugin; private final OfflinePlayer toModerate; @@ -39,13 +38,14 @@ public class PunishmentsGui extends Gui { } protected void showPage() { - if (inventory != null) - inventory.clear(); + if (this.inventory != null) { + this.inventory.clear(); + } setActionForRange(0, 53, null); - setNextPage(0, 5, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage())); - setPrevPage(0, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage())); + setNextPage(0, 5, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.next").getMessage())); + setPrevPage(0, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, this.plugin.getLocale().getMessage("gui.general.back").getMessage())); setOnPage((event) -> showPage()); // decorate the edges @@ -61,25 +61,27 @@ public class PunishmentsGui extends Gui { mirrorFill(1, 0, true, true, glass2); mirrorFill(0, 1, true, true, glass2); - PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(toModerate); + PlayerPunishData playerPunishData = this.plugin.getPunishmentManager().getPlayer(this.toModerate); List punishments = new ArrayList<>(); - if (currentActivity == Activity.ACTIVE || currentActivity == Activity.BOTH) { + if (this.currentActivity == Activity.ACTIVE || this.currentActivity == Activity.BOTH) { for (AppliedPunishment punishment : playerPunishData.getActivePunishments()) { - if (punishmentType != PunishmentType.ALL) { - if (punishment.getPunishmentType() != punishmentType) + if (this.punishmentType != PunishmentType.ALL) { + if (punishment.getPunishmentType() != this.punishmentType) { continue; + } } punishments.add(new PunishmentHolder(Activity.ACTIVE, punishment)); } } - if (currentActivity == Activity.EXPIRED || currentActivity == Activity.BOTH) { + if (this.currentActivity == Activity.EXPIRED || this.currentActivity == Activity.BOTH) { for (AppliedPunishment punishment : playerPunishData.getExpiredPunishments()) { - if (punishmentType != PunishmentType.ALL) { - if (punishment.getPunishmentType() != punishmentType) + if (this.punishmentType != PunishmentType.ALL) { + if (punishment.getPunishmentType() != this.punishmentType) { continue; + } } punishments.add(new PunishmentHolder(Activity.EXPIRED, punishment)); } @@ -88,66 +90,67 @@ public class PunishmentsGui extends Gui { int numNotes = punishments.size(); this.pages = (int) Math.floor(numNotes / 28.0); - punishments = punishments.stream().skip((page - 1) * 28).limit(28) + punishments = punishments.stream().skip((this.page - 1) * 28).limit(28) .collect(Collectors.toList()); setButton(5, 4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, - plugin.getLocale().getMessage("gui.general.back").getMessage()), - (event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player))); + this.plugin.getLocale().getMessage("gui.general.back").getMessage()), + (event) -> this.guiManager.showGUI(event.player, new PlayerGui(this.plugin, this.toModerate, event.player))); - setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.APPLE, Methods.formatText("&6" + currentActivity.getTranslation())), + setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.APPLE, TextUtils.formatText("&6" + this.currentActivity.getTranslation())), (event) -> { - this.currentActivity = currentActivity.next(); + this.currentActivity = this.currentActivity.next(); this.page = 1; showPage(); }); - setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name())), + setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD, TextUtils.formatText("&6" + this.punishmentType.name())), (event) -> { - this.punishmentType = punishmentType.nextFilter(); + this.punishmentType = this.punishmentType.nextFilter(); this.page = 1; showPage(); }); int num = 11; for (PunishmentHolder punishmentHolder : punishments) { - if (num == 16 || num == 36) + if (num == 16 || num == 36) { num = num + 2; + } AppliedPunishment appliedPunishment = punishmentHolder.getAppliedPunishment(); Activity activity = punishmentHolder.getActivity(); ArrayList lore = new ArrayList<>(); lore.add(""); - lore.add(plugin.getLocale().getMessage("gui.punishments.reason").getMessage()); + lore.add(this.plugin.getLocale().getMessage("gui.punishments.reason").getMessage()); lore.add("&7" + appliedPunishment.getReason()); if (appliedPunishment.getPunishmentType() != PunishmentType.KICK) { lore.add(""); - lore.add(plugin.getLocale().getMessage("gui.punishments.duration").getMessage()); + lore.add(this.plugin.getLocale().getMessage("gui.punishments.duration").getMessage()); lore.add("&7" + (appliedPunishment.getDuration() != -1 - ? Methods.makeReadable(appliedPunishment.getDuration()) - : plugin.getLocale().getMessage("gui.general.permanent").getMessage())); + ? TimeUtils.makeReadable(appliedPunishment.getDuration()) + : this.plugin.getLocale().getMessage("gui.general.permanent").getMessage())); lore.add(""); - lore.add(plugin.getLocale().getMessage("gui.punishments.punisher").getMessage()); + lore.add(this.plugin.getLocale().getMessage("gui.punishments.punisher").getMessage()); lore.add("&7" + (appliedPunishment.getPunisher() == null ? "Console" : Bukkit.getOfflinePlayer(appliedPunishment.getPunisher()).getName())); if (activity == Activity.ACTIVE) { lore.add(""); if (appliedPunishment.getDuration() != -1) { - lore.add(plugin.getLocale().getMessage("gui.punishments.remaining").getMessage()); - lore.add("&7" + Methods.makeReadable(appliedPunishment.getTimeRemaining())); + lore.add(this.plugin.getLocale().getMessage("gui.punishments.remaining").getMessage()); + lore.add("&7" + TimeUtils.makeReadable(appliedPunishment.getTimeRemaining())); lore.add(""); } - lore.add(plugin.getLocale().getMessage("gui.punishments.click").getMessage()); + lore.add(this.plugin.getLocale().getMessage("gui.punishments.click").getMessage()); } } lore.add(""); setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, - TextUtils.formatText("&6&l" + appliedPunishment.getPunishmentType().getTranslation() + " - &7&l" + activity.getTranslation()), - TextUtils.formatText(lore)), + TextUtils.formatText("&6&l" + appliedPunishment.getPunishmentType().getTranslation() + " - &7&l" + activity.getTranslation()), + TextUtils.formatText(lore)), (event) -> { if (appliedPunishment.getPunishmentType() != PunishmentType.KICK && activity == Activity.ACTIVE) { appliedPunishment.expire(); - plugin.getDataManager().updateAppliedPunishment(appliedPunishment); + this.plugin.getDataManager().updateAppliedPunishment(appliedPunishment); showPage(); } }); @@ -158,8 +161,7 @@ public class PunishmentsGui extends Gui { } - private class PunishmentHolder { - + private static class PunishmentHolder { private final Activity activity; private final AppliedPunishment appliedPunishment; @@ -169,26 +171,26 @@ public class PunishmentsGui extends Gui { } public Activity getActivity() { - return activity; + return this.activity; } public AppliedPunishment getAppliedPunishment() { - return appliedPunishment; + return this.appliedPunishment; } } private enum Activity { - BOTH, ACTIVE, EXPIRED; - private static Activity[] vals = values(); - public Activity next() { - return vals[(this.ordinal() != vals.length - 1 ? this.ordinal() + 1 : 0)]; + return values()[(this.ordinal() != values().length - 1 ? this.ordinal() + 1 : 0)]; } public String getTranslation() { - return UltimateModeration.getInstance().getLocale().getMessage("gui.punishments.activity." + this.name().toLowerCase()).getMessage(); + return UltimateModeration.getPlugin(UltimateModeration.class) + .getLocale() + .getMessage("gui.punishments.activity." + this.name().toLowerCase()) + .getMessage(); } } } diff --git a/src/main/java/com/songoda/ultimatemoderation/gui/TemplateManagerGui.java b/src/main/java/com/songoda/ultimatemoderation/gui/TemplateManagerGui.java index 2bc84c4..564a1c1 100644 --- a/src/main/java/com/songoda/ultimatemoderation/gui/TemplateManagerGui.java +++ b/src/main/java/com/songoda/ultimatemoderation/gui/TemplateManagerGui.java @@ -8,7 +8,6 @@ import com.songoda.ultimatemoderation.UltimateModeration; import com.songoda.ultimatemoderation.punish.PunishmentType; import com.songoda.ultimatemoderation.punish.template.Template; import com.songoda.ultimatemoderation.settings.Settings; -import com.songoda.ultimatemoderation.utils.Methods; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; @@ -17,7 +16,6 @@ import java.util.List; import java.util.stream.Collectors; public class TemplateManagerGui extends Gui { - private final UltimateModeration plugin; private PunishmentType punishmentType = PunishmentType.ALL; @@ -52,13 +50,13 @@ public class TemplateManagerGui extends Gui { } private void toCurrentPage() { - if (inventory != null) { - inventory.clear(); + if (this.inventory != null) { + this.inventory.clear(); } setActionForRange(0, 53, null); - int numTemplates = plugin.getTemplateManager().getTemplates().size(); + int numTemplates = this.plugin.getTemplateManager().getTemplates().size(); this.pages = (int) Math.floor(numTemplates / 28.0); // decorate the edges @@ -74,21 +72,21 @@ public class TemplateManagerGui extends Gui { mirrorFill(1, 0, true, true, glass2); mirrorFill(0, 1, true, true, glass2); - setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name())), + setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD, TextUtils.formatText("&6" + this.punishmentType.name())), (event) -> { - this.punishmentType = punishmentType.nextFilter(); + this.punishmentType = this.punishmentType.nextFilter(); this.page = 1; toCurrentPage(); }); setButton(5, 4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR, - plugin.getLocale().getMessage("gui.general.back").getMessage()), - (event) -> guiManager.showGUI(event.player, new MainGui(plugin, event.player))); + this.plugin.getLocale().getMessage("gui.general.back").getMessage()), + (event) -> this.guiManager.showGUI(event.player, new MainGui(this.plugin, event.player))); - if (player.hasPermission("um.templates.create")) { + if (this.player.hasPermission("um.templates.create")) { setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE, - plugin.getLocale().getMessage("gui.templatemanager.create").getMessage()), - (event) -> guiManager.showGUI(event.player, new PunishGui(plugin, null, null, player))); + this.plugin.getLocale().getMessage("gui.templatemanager.create").getMessage()), + (event) -> this.guiManager.showGUI(event.player, new PunishGui(this.plugin, null, null, this.player))); } List