diff --git a/src/main/java/venture/Aust1n46/chat/api/events/MutePlayerEvent.java b/src/main/java/venture/Aust1n46/chat/api/events/MutePlayerEvent.java index 6f8ba97..0db8dd9 100644 --- a/src/main/java/venture/Aust1n46/chat/api/events/MutePlayerEvent.java +++ b/src/main/java/venture/Aust1n46/chat/api/events/MutePlayerEvent.java @@ -7,28 +7,28 @@ import org.bukkit.event.HandlerList; import venture.Aust1n46.chat.model.ChatChannel; -//This class is a custom event that is part of the plugins API. It is called when a player executes the mute command. -public class MutePlayerEvent extends Event implements Cancellable { //unimplemented +// TODO +public class MutePlayerEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private Player player; private ChatChannel channel; private int time; - + public MutePlayerEvent(Player player, ChatChannel channel, int time) { this.player = player; this.channel = channel; this.time = time; this.cancelled = false; } - + @Override public HandlerList getHandlers() { - return handlers; + return handlers; } - + public static HandlerList getHandlerList() { - return handlers; + return handlers; } @Override @@ -40,24 +40,24 @@ public class MutePlayerEvent extends Event implements Cancellable { //unimplemen public void setCancelled(boolean cancel) { this.cancelled = cancel; } - + public Player getPlayer() { return this.player; } - + public void setChannel(ChatChannel channel) { this.channel = channel; } - + public ChatChannel getChannel() { return this.channel; } - + public int getTime() { return this.time; } - + public void setTime(int time) { this.time = time; } -} \ No newline at end of file +} diff --git a/src/main/java/venture/Aust1n46/chat/api/events/VentureChatEvent.java b/src/main/java/venture/Aust1n46/chat/api/events/VentureChatEvent.java index 375116d..52c2ea2 100644 --- a/src/main/java/venture/Aust1n46/chat/api/events/VentureChatEvent.java +++ b/src/main/java/venture/Aust1n46/chat/api/events/VentureChatEvent.java @@ -26,7 +26,7 @@ public class VentureChatEvent extends Event { private final String playerPrimaryGroup; private final ChatChannel channel; private final Set recipients; - private final int recipientCount; // For not counting vanished players + private final int recipientCount; private final String format; private final String chat; private final String globalJSON; diff --git a/src/main/java/venture/Aust1n46/chat/initiators/listeners/ChatListener.java b/src/main/java/venture/Aust1n46/chat/initiators/listeners/ChatListener.java index e46a239..bcf0ee0 100644 --- a/src/main/java/venture/Aust1n46/chat/initiators/listeners/ChatListener.java +++ b/src/main/java/venture/Aust1n46/chat/initiators/listeners/ChatListener.java @@ -35,7 +35,6 @@ import venture.Aust1n46.chat.service.VentureChatFormatService; import venture.Aust1n46.chat.service.VentureChatPlayerApiService; import venture.Aust1n46.chat.utilities.FormatUtils; -//This class listens to chat through the chat event and handles the bulk of the chat channels and formatting. @SuppressWarnings("deprecation") @Singleton public class ChatListener implements Listener { diff --git a/src/main/java/venture/Aust1n46/chat/initiators/listeners/PacketListener.java b/src/main/java/venture/Aust1n46/chat/initiators/listeners/PacketListener.java index 9e5ab3d..5fc6a28 100644 --- a/src/main/java/venture/Aust1n46/chat/initiators/listeners/PacketListener.java +++ b/src/main/java/venture/Aust1n46/chat/initiators/listeners/PacketListener.java @@ -16,9 +16,6 @@ import venture.Aust1n46.chat.service.VentureChatFormatService; import venture.Aust1n46.chat.service.VentureChatPlayerApiService; import venture.Aust1n46.chat.xcut.VersionService; -//This class listens for chat packets and intercepts them before they are sent to the Player. -//The packets are modified to include advanced json formating and the message remover button if the -//player has permission to remove messages. @Singleton public class PacketListener extends PacketAdapter { @Inject @@ -27,8 +24,7 @@ public class PacketListener extends PacketAdapter { private VentureChatPlayerApiService playerApiService; @Inject private VersionService versionService; - - + @Inject public PacketListener(final VentureChat plugin) { super(plugin, ListenerPriority.MONITOR, new PacketType[] { PacketType.Play.Server.CHAT }); @@ -36,48 +32,45 @@ public class PacketListener extends PacketAdapter { @Override public void onPacketSending(PacketEvent event) { - if(event.isCancelled() || event.getPacketType() != PacketType.Play.Server.CHAT) { + if (event.isCancelled() || event.getPacketType() != PacketType.Play.Server.CHAT) { return; } - + VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(event.getPlayer()); - if(mcp == null) { + if (mcp == null) { return; } - + PacketContainer packet = event.getPacket(); WrappedChatComponent chat = packet.getChatComponents().read(0); - if(chat == null) { + if (chat == null) { return; } - + try { - if(versionService.is1_7()) { + if (versionService.is1_7()) { packet.getBooleans().getField(0).setAccessible(true); - if(!((boolean) packet.getBooleans().getField(0).get(packet.getHandle()))) { + if (!((boolean) packet.getBooleans().getField(0).get(packet.getHandle()))) { return; } - } - else if(versionService.is1_8() || versionService.is1_9() || versionService.is1_10() || versionService.is1_11()) { + } else if (versionService.is1_8() || versionService.is1_9() || versionService.is1_10() || versionService.is1_11()) { packet.getBytes().getField(0).setAccessible(true); - if(((Byte) packet.getBytes().getField(0).get(packet.getHandle())).intValue() > 1) { + if (((Byte) packet.getBytes().getField(0).get(packet.getHandle())).intValue() > 1) { return; } - } - else { + } else { packet.getChatTypes().getField(0).setAccessible(true); - if(packet.getChatTypes().getField(0).get(packet.getHandle()) == packet.getChatTypes().getField(0).getType().getEnumConstants()[2]) { + if (packet.getChatTypes().getField(0).get(packet.getHandle()) == packet.getChatTypes().getField(0).getType().getEnumConstants()[2]) { return; } } - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); } - + String message = formatter.toPlainText(chat.getHandle(), chat.getHandleType()); String coloredMessage = formatter.toColoredText(chat.getHandle(), chat.getHandleType()); - if(message == null) { + if (message == null) { return; } int hash = message.hashCode(); diff --git a/src/main/java/venture/Aust1n46/chat/initiators/listeners/PreProcessCommandListener.java b/src/main/java/venture/Aust1n46/chat/initiators/listeners/PreProcessCommandListener.java index b7349d1..a6faecd 100644 --- a/src/main/java/venture/Aust1n46/chat/initiators/listeners/PreProcessCommandListener.java +++ b/src/main/java/venture/Aust1n46/chat/initiators/listeners/PreProcessCommandListener.java @@ -36,8 +36,6 @@ import venture.Aust1n46.chat.service.VentureChatPlayerApiService; import venture.Aust1n46.chat.utilities.FormatUtils; import venture.Aust1n46.chat.xcut.VersionService; -//This class listens for commands (Any chat that begins with a /) to use in the command spy and -//in the custom commands such as aliases. @Singleton public class PreProcessCommandListener implements CommandExecutor, Listener { @Inject @@ -184,23 +182,6 @@ public class PreProcessCommandListener implements CommandExecutor, Listener { pluginMessageController.synchronize(mcp, true); } mcp.setQuickChannel(channel); - /* - * String format = ""; if(plugin.getConfig().getConfigurationSection("channels." - * + channel.getName()).getString("format").equalsIgnoreCase("Default")) { - * format = - * FormatTags.ChatFormat(ChatColor.valueOf(channel.getColor().toUpperCase()) + - * "[" + channel.getName() + "] {prefix}{name}" + - * ChatColor.valueOf(channel.getColor().toUpperCase()) + ":" + - * ChatColor.valueOf(channel.getChatColor().toUpperCase()), mcp.getPlayer(), - * plugin, cc, channel, plugin.getConfig().getBoolean("jsonFormat")); } else { - * format = - * FormatTags.ChatFormat(plugin.getConfig().getConfigurationSection("channels." - * + channel.getName()).getString("format"), mcp.getPlayer(), plugin, cc, - * channel, plugin.getConfig().getBoolean("jsonFormat")); - * if(plugin.getConfig().getBoolean("formatcleaner", false)) { format = - * format.replace("[]", " "); format = format.replace(" ", - * " ").replace(" ", " ").replace(" ", " "); } } - */ mcp.setQuickChat(true); mcp.getPlayer().chat(message); event.setCancelled(true); diff --git a/src/main/java/venture/Aust1n46/chat/initiators/listeners/SignListener.java b/src/main/java/venture/Aust1n46/chat/initiators/listeners/SignListener.java index dfcef96..f103a66 100644 --- a/src/main/java/venture/Aust1n46/chat/initiators/listeners/SignListener.java +++ b/src/main/java/venture/Aust1n46/chat/initiators/listeners/SignListener.java @@ -12,25 +12,24 @@ import venture.Aust1n46.chat.model.VentureChatPlayer; import venture.Aust1n46.chat.service.VentureChatPlayerApiService; import venture.Aust1n46.chat.utilities.FormatUtils; -//This class listens for text being added to signs, and it formats them to allow colors and formatting. @Singleton public class SignListener implements Listener { @Inject private VentureChatPlayerApiService playerApiService; - + @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.HIGH) public void onSignChange(SignChangeEvent event) { VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(event.getPlayer()); - for(int a = 0; a < event.getLines().length; a++) { + for (int a = 0; a < event.getLines().length; a++) { String line = event.getLine(a); - if(mcp.getPlayer().hasPermission("venturechat.color.legacy")) { + if (mcp.getPlayer().hasPermission("venturechat.color.legacy")) { line = FormatUtils.FormatStringLegacyColor(line); } - if(mcp.getPlayer().hasPermission("venturechat.color")) { + if (mcp.getPlayer().hasPermission("venturechat.color")) { line = FormatUtils.FormatStringColor(line); } - if(mcp.getPlayer().hasPermission("venturechat.format")) { + if (mcp.getPlayer().hasPermission("venturechat.format")) { line = FormatUtils.FormatString(line); } event.setLine(a, line); diff --git a/src/main/java/venture/Aust1n46/chat/service/VentureChatDatabaseService.java b/src/main/java/venture/Aust1n46/chat/service/VentureChatDatabaseService.java index 92a5d4b..9789f83 100644 --- a/src/main/java/venture/Aust1n46/chat/service/VentureChatDatabaseService.java +++ b/src/main/java/venture/Aust1n46/chat/service/VentureChatDatabaseService.java @@ -38,9 +38,6 @@ public class VentureChatDatabaseService { String password = mysqlConfig.getString("password"); final HikariConfig config = new HikariConfig(); - // config.setDriverClassName(org.postgresql.Driver.class.getName()); - // final String jdbcUrl = String.format("jdbc:postgresql://%s:%d/%s", hostname, - // port, database); final String jdbcUrl = String.format("jdbc:mysql://%s:%d/%s?autoReconnect=true&useSSL=false", host, port, database); config.setJdbcUrl(jdbcUrl); config.setUsername(user);