mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 02:19:05 +00:00
Lombok event.
This commit is contained in:
parent
a0c2501c3e
commit
862c673cd8
@ -6,34 +6,37 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import lombok.Getter;
|
||||
import venture.Aust1n46.chat.model.ChatChannel;
|
||||
import venture.Aust1n46.chat.model.VentureChatPlayer;
|
||||
|
||||
/**
|
||||
* Event called when a message has been sent to a channel.
|
||||
* This event can not be cancelled.
|
||||
* Event called when a message has been sent to a channel. This event can not be
|
||||
* cancelled.
|
||||
*
|
||||
* @author Aust1n46
|
||||
*/
|
||||
@Getter
|
||||
public class VentureChatEvent extends Event {
|
||||
private static final boolean ASYNC = true;
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final VentureChatPlayer mcp;
|
||||
private final VentureChatPlayer ventureChatPlayer;
|
||||
private final String username;
|
||||
private final String playerPrimaryGroup;
|
||||
private final ChatChannel channel;
|
||||
private final Set<Player> recipients;
|
||||
private final int recipientCount; //For not counting vanished players
|
||||
private final int recipientCount; // For not counting vanished players
|
||||
private final String format;
|
||||
private final String chat;
|
||||
private final String globalJSON;
|
||||
private final int hash;
|
||||
private final boolean bungee;
|
||||
|
||||
public VentureChatEvent(VentureChatPlayer mcp, String username, String playerPrimaryGroup, ChatChannel channel, Set<Player> recipients, int recipientCount, String format, String chat, String globalJSON, int hash, boolean bungee) {
|
||||
public VentureChatEvent(final VentureChatPlayer ventureChatPlayer, final String username, final String playerPrimaryGroup, final ChatChannel channel,
|
||||
final Set<Player> recipients, final int recipientCount, final String format, final String chat, final String globalJSON, final int hash, final boolean bungee) {
|
||||
super(ASYNC);
|
||||
this.mcp = mcp;
|
||||
this.ventureChatPlayer = ventureChatPlayer;
|
||||
this.username = username;
|
||||
this.playerPrimaryGroup = playerPrimaryGroup;
|
||||
this.channel = channel;
|
||||
@ -46,61 +49,16 @@ public class VentureChatEvent extends Event {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public VentureChatPlayer getMineverseChatPlayer() {
|
||||
return this.mcp;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getPlayerPrimaryGroup() {
|
||||
return this.playerPrimaryGroup;
|
||||
}
|
||||
|
||||
public ChatChannel getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
public Set<Player> getRecipients() {
|
||||
return this.recipients;
|
||||
}
|
||||
|
||||
//Could be lower than the total number of recipients because vanished players are not counted
|
||||
public int getRecipientCount() {
|
||||
return this.recipientCount;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return this.format;
|
||||
}
|
||||
|
||||
public String getChat() {
|
||||
return this.chat;
|
||||
}
|
||||
|
||||
public String getConsoleChat() {
|
||||
return this.format + this.chat;
|
||||
}
|
||||
|
||||
public String getGlobalJSON() {
|
||||
return this.globalJSON;
|
||||
}
|
||||
|
||||
public int getHash() {
|
||||
return this.hash;
|
||||
}
|
||||
|
||||
public boolean isBungee() {
|
||||
return this.bungee;
|
||||
return format + chat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
@ -511,7 +511,7 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
|
||||
public void handleVentureChatEvent(VentureChatEvent event) {
|
||||
VentureChatPlayer mcp = event.getMineverseChatPlayer();
|
||||
VentureChatPlayer ventureChatPlayer = event.getVentureChatPlayer();
|
||||
ChatChannel channel = event.getChannel();
|
||||
Set<Player> recipients = event.getRecipients();
|
||||
int recipientCount = event.getRecipientCount();
|
||||
@ -523,21 +523,21 @@ public class ChatListener implements Listener {
|
||||
boolean bungee = event.isBungee();
|
||||
|
||||
if (essentialsDiscordHook && channel.isDefaultchannel()) {
|
||||
Bukkit.getServicesManager().load(DiscordService.class).sendChatMessage(mcp.getPlayer(), chat);
|
||||
Bukkit.getServicesManager().load(DiscordService.class).sendChatMessage(ventureChatPlayer.getPlayer(), chat);
|
||||
}
|
||||
|
||||
if(!bungee) {
|
||||
if(databaseService.isEnabled()) {
|
||||
databaseService.writeVentureChat(mcp.getUuid().toString(), mcp.getName(), "Local", channel.getName(), chat.replace("'", "''"), "Chat");
|
||||
databaseService.writeVentureChat(ventureChatPlayer.getUuid().toString(), ventureChatPlayer.getName(), "Local", channel.getName(), chat.replace("'", "''"), "Chat");
|
||||
}
|
||||
|
||||
if(recipientCount == 1) {
|
||||
if(!plugin.getConfig().getString("emptychannelalert", "&6No one is listening to you.").equals("")) {
|
||||
mcp.getPlayer().sendMessage(FormatUtils.FormatStringAll(plugin.getConfig().getString("emptychannelalert", "&6No one is listening to you.")));
|
||||
ventureChatPlayer.getPlayer().sendMessage(FormatUtils.FormatStringAll(plugin.getConfig().getString("emptychannelalert", "&6No one is listening to you.")));
|
||||
}
|
||||
}
|
||||
for(Player p : recipients) {
|
||||
String json = formatService.formatModerationGUI(globalJSON, p, mcp.getName(), channel.getName(), hash);
|
||||
String json = formatService.formatModerationGUI(globalJSON, p, ventureChatPlayer.getName(), channel.getName(), hash);
|
||||
PacketContainer packet = formatService.createPacketPlayOutChat(json);
|
||||
formatService.sendPacketPlayOutChat(p, packet);
|
||||
}
|
||||
@ -550,9 +550,9 @@ public class ChatListener implements Listener {
|
||||
try {
|
||||
out.writeUTF("Chat");
|
||||
out.writeUTF(channel.getName());
|
||||
out.writeUTF(mcp.getName());
|
||||
out.writeUTF(mcp.getUuid().toString());
|
||||
out.writeBoolean(mcp.isBungeeToggle());
|
||||
out.writeUTF(ventureChatPlayer.getName());
|
||||
out.writeUTF(ventureChatPlayer.getUuid().toString());
|
||||
out.writeBoolean(ventureChatPlayer.isBungeeToggle());
|
||||
out.writeInt(hash);
|
||||
out.writeUTF(format);
|
||||
out.writeUTF(chat);
|
||||
@ -563,8 +563,8 @@ public class ChatListener implements Listener {
|
||||
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
||||
System.out.println(out.size() + " bytes size with json");
|
||||
}
|
||||
out.writeUTF(plugin.getVaultPermission().getPrimaryGroup(mcp.getPlayer())); // look into not sending this
|
||||
final String displayName = mcp.getPlayer().getDisplayName();
|
||||
out.writeUTF(plugin.getVaultPermission().getPrimaryGroup(ventureChatPlayer.getPlayer())); // look into not sending this
|
||||
final String displayName = ventureChatPlayer.getPlayer().getDisplayName();
|
||||
out.writeUTF(displayName);
|
||||
pluginMessageController.sendPluginMessage(byteOutStream);
|
||||
out.close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user