mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 10:39:05 +00:00
Added DiscordSRV Bungee route
This commit is contained in:
parent
6d438f9372
commit
b730be11f5
@ -41,6 +41,7 @@ import mineverse.Aust1n46.chat.listeners.SignListener;
|
|||||||
import mineverse.Aust1n46.chat.alias.AliasInfo;
|
import mineverse.Aust1n46.chat.alias.AliasInfo;
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||||
|
import mineverse.Aust1n46.chat.api.events.VentureChatEvent;
|
||||||
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
||||||
//import mineverse.Aust1n46.chat.command.CCommand;
|
//import mineverse.Aust1n46.chat.command.CCommand;
|
||||||
import mineverse.Aust1n46.chat.command.MineverseCommand;
|
import mineverse.Aust1n46.chat.command.MineverseCommand;
|
||||||
@ -662,13 +663,32 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendDiscordSRVPluginMessage(String chatChannel, String message) {
|
||||||
|
if(onlinePlayers.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player host = onlinePlayers.iterator().next().getPlayer();
|
||||||
|
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||||
|
try {
|
||||||
|
out.writeUTF("DiscordSRV");
|
||||||
|
out.writeUTF(chatChannel);
|
||||||
|
out.writeUTF(message);
|
||||||
|
host.sendPluginMessage(plugin, MineverseChat.PLUGIN_MESSAGING_CHANNEL, byteOutStream.toByteArray());
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
public void onPluginMessageReceived(String channel, Player player, byte[] inputStream) {
|
||||||
if(!channel.equals(MineverseChat.PLUGIN_MESSAGING_CHANNEL)) {
|
if(!channel.equals(MineverseChat.PLUGIN_MESSAGING_CHANNEL)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DataInputStream msgin = new DataInputStream(new ByteArrayInputStream(message));
|
DataInputStream msgin = new DataInputStream(new ByteArrayInputStream(inputStream));
|
||||||
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
||||||
System.out.println(msgin.available() + " size on receiving end");
|
System.out.println(msgin.available() + " size on receiving end");
|
||||||
}
|
}
|
||||||
@ -680,46 +700,65 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
String senderName = msgin.readUTF();
|
String senderName = msgin.readUTF();
|
||||||
UUID senderUUID = UUID.fromString(msgin.readUTF());
|
UUID senderUUID = UUID.fromString(msgin.readUTF());
|
||||||
int hash = msgin.readInt();
|
int hash = msgin.readInt();
|
||||||
String consoleChat = msgin.readUTF();
|
String format = msgin.readUTF();
|
||||||
boolean hasJSON = msgin.readBoolean();
|
String chat = msgin.readUTF();
|
||||||
String globalJSON = "";
|
String consoleChat = format + chat;
|
||||||
if(hasJSON) {
|
String globalJSON = msgin.readUTF();
|
||||||
globalJSON = msgin.readUTF();
|
|
||||||
|
if(!ChatChannel.isChannel(chatchannel)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if(ChatChannel.isChannel(chatchannel) && ChatChannel.getChannel(chatchannel).getBungee()) {
|
ChatChannel chatChannelObject = ChatChannel.getChannel(chatchannel);
|
||||||
Bukkit.getConsoleSender().sendMessage(consoleChat);
|
|
||||||
for(MineverseChatPlayer p : MineverseChat.onlinePlayers) {
|
|
||||||
if(p.isListening(ChatChannel.getChannel(chatchannel).getName())) {
|
|
||||||
if(!p.getBungeeToggle() && MineverseChatAPI.getOnlineMineverseChatPlayer(senderName) == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
PacketContainer packet = null;
|
if(!chatChannelObject.getBungee()) {
|
||||||
if(hasJSON) {
|
return;
|
||||||
String json = Format.formatModerationGUI(globalJSON, p.getPlayer(), senderName, chatchannel, hash);
|
}
|
||||||
WrappedChatComponent chatComponent = WrappedChatComponent.fromJson(json);
|
|
||||||
packet = Format.createPacketPlayOutChat(chatComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(plugin.getConfig().getBoolean("ignorechat", false)) {
|
Set<Player> recipients = new HashSet<Player>();
|
||||||
if(!p.getIgnores().contains(senderUUID)) {
|
for(MineverseChatPlayer p : MineverseChat.onlinePlayers) {
|
||||||
// System.out.println("Chat sent");
|
if(p.isListening(chatChannelObject.getName())) {
|
||||||
if(hasJSON) {
|
recipients.add(p.getPlayer());
|
||||||
Format.sendPacketPlayOutChat(p.getPlayer(), packet);
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
p.getPlayer().sendMessage(consoleChat);
|
Bukkit.getServer().getScheduler().runTaskAsynchronously(this, new Runnable() {
|
||||||
}
|
@Override
|
||||||
}
|
public void run() {
|
||||||
continue;
|
//Create VentureChatEvent
|
||||||
}
|
VentureChatEvent ventureChatEvent = new VentureChatEvent(onlinePlayers.iterator().next(), chatChannelObject, recipients, format, chat, globalJSON, hash, false);
|
||||||
if(hasJSON) {
|
//Fire event and wait for other plugin listeners to act on it
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Bukkit.getConsoleSender().sendMessage(consoleChat);
|
||||||
|
for(MineverseChatPlayer p : MineverseChat.onlinePlayers) {
|
||||||
|
if(p.isListening(chatChannelObject.getName())) {
|
||||||
|
if(!p.getBungeeToggle() && MineverseChatAPI.getOnlineMineverseChatPlayer(senderName) == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String json = Format.formatModerationGUI(globalJSON, p.getPlayer(), senderName, chatchannel, hash);
|
||||||
|
WrappedChatComponent chatComponent = WrappedChatComponent.fromJson(json);
|
||||||
|
PacketContainer packet = Format.createPacketPlayOutChat(chatComponent);
|
||||||
|
|
||||||
|
if(plugin.getConfig().getBoolean("ignorechat", false)) {
|
||||||
|
if(!p.getIgnores().contains(senderUUID)) {
|
||||||
|
// System.out.println("Chat sent");
|
||||||
Format.sendPacketPlayOutChat(p.getPlayer(), packet);
|
Format.sendPacketPlayOutChat(p.getPlayer(), packet);
|
||||||
}
|
}
|
||||||
else {
|
continue;
|
||||||
p.getPlayer().sendMessage(consoleChat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Format.sendPacketPlayOutChat(p.getPlayer(), packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(subchannel.equals("DiscordSRV")) {
|
||||||
|
String chatchannel = msgin.readUTF();
|
||||||
|
String message = msgin.readUTF();
|
||||||
|
if(ChatChannel.isChannel(chatchannel) && ChatChannel.getChannel(chatchannel).getBungee()) {
|
||||||
|
for(MineverseChatPlayer p : MineverseChat.onlinePlayers) {
|
||||||
|
p.getPlayer().sendMessage(Format.FormatStringAll(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,22 +157,17 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
String senderUUID = in.readUTF();
|
String senderUUID = in.readUTF();
|
||||||
boolean bungeeToggle = in.readBoolean();
|
boolean bungeeToggle = in.readBoolean();
|
||||||
int hash = in.readInt();
|
int hash = in.readInt();
|
||||||
String consoleChat = in.readUTF();
|
String format = in.readUTF();
|
||||||
boolean hasJSON = in.readBoolean();
|
String chat = in.readUTF();
|
||||||
String json = "";
|
String json = in.readUTF();
|
||||||
if(hasJSON) {
|
|
||||||
json = in.readUTF();
|
|
||||||
}
|
|
||||||
out.writeUTF("Chat");
|
out.writeUTF("Chat");
|
||||||
out.writeUTF(chatchannel);
|
out.writeUTF(chatchannel);
|
||||||
out.writeUTF(senderName);
|
out.writeUTF(senderName);
|
||||||
out.writeUTF(senderUUID);
|
out.writeUTF(senderUUID);
|
||||||
out.writeInt(hash);
|
out.writeInt(hash);
|
||||||
out.writeUTF(consoleChat);
|
out.writeUTF(format);
|
||||||
out.writeBoolean(hasJSON);
|
out.writeUTF(chat);
|
||||||
if(hasJSON) {
|
out.writeUTF(json);
|
||||||
out.writeUTF(json);
|
|
||||||
}
|
|
||||||
for(String send : getProxy().getServers().keySet()) {
|
for(String send : getProxy().getServers().keySet()) {
|
||||||
if(getProxy().getServers().get(send).getPlayers().size() > 0) {
|
if(getProxy().getServers().get(send).getPlayers().size() > 0) {
|
||||||
if(!bungeeToggle && !getProxy().getServers().get(send).getName().equalsIgnoreCase(ser.getInfo().getName())) {
|
if(!bungeeToggle && !getProxy().getServers().get(send).getName().equalsIgnoreCase(ser.getInfo().getName())) {
|
||||||
@ -182,6 +177,18 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(subchannel.equals("DiscordSRV")) {
|
||||||
|
String chatchannel = in.readUTF();
|
||||||
|
String message = in.readUTF();
|
||||||
|
out.writeUTF("DiscordSRV");
|
||||||
|
out.writeUTF(chatchannel);
|
||||||
|
out.writeUTF(message);
|
||||||
|
for(String send : getProxy().getServers().keySet()) {
|
||||||
|
if(getProxy().getServers().get(send).getPlayers().size() > 0) {
|
||||||
|
getProxy().getServers().get(send).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, outstream.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if(subchannel.equals("Chwho")) {
|
if(subchannel.equals("Chwho")) {
|
||||||
String identifier = in.readUTF();
|
String identifier = in.readUTF();
|
||||||
if(identifier.equals("Get")) {
|
if(identifier.equals("Get")) {
|
||||||
|
@ -467,6 +467,7 @@ public class ChatListener implements Listener {
|
|||||||
MineverseChatPlayer mcp = event.getMineverseChatPlayer();
|
MineverseChatPlayer mcp = event.getMineverseChatPlayer();
|
||||||
ChatChannel channel = event.getChannel();
|
ChatChannel channel = event.getChannel();
|
||||||
Set<Player> recipients = event.getRecipients();
|
Set<Player> recipients = event.getRecipients();
|
||||||
|
String format = event.getFormat();
|
||||||
String chat = event.getChat();
|
String chat = event.getChat();
|
||||||
String consoleChat = event.getConsoleChat();
|
String consoleChat = event.getConsoleChat();
|
||||||
String globalJSON = event.getGlobalJSON();
|
String globalJSON = event.getGlobalJSON();
|
||||||
@ -512,17 +513,16 @@ public class ChatListener implements Listener {
|
|||||||
out.writeUTF(mcp.getUUID().toString());
|
out.writeUTF(mcp.getUUID().toString());
|
||||||
out.writeBoolean(mcp.getBungeeToggle());
|
out.writeBoolean(mcp.getBungeeToggle());
|
||||||
out.writeInt(hash);
|
out.writeInt(hash);
|
||||||
out.writeUTF(consoleChat);
|
out.writeUTF(format);
|
||||||
|
out.writeUTF(chat);
|
||||||
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
||||||
System.out.println(out.size() + " size bytes without json");
|
System.out.println(out.size() + " size bytes without json");
|
||||||
}
|
}
|
||||||
out.writeBoolean(true);
|
|
||||||
out.writeUTF(globalJSON);
|
out.writeUTF(globalJSON);
|
||||||
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
||||||
System.out.println(out.size() + " bytes size with json");
|
System.out.println(out.size() + " bytes size with json");
|
||||||
}
|
}
|
||||||
mcp.getPlayer().sendPluginMessage(plugin, MineverseChat.PLUGIN_MESSAGING_CHANNEL, byteOutStream.toByteArray());
|
mcp.getPlayer().sendPluginMessage(plugin, MineverseChat.PLUGIN_MESSAGING_CHANNEL, byteOutStream.toByteArray());
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user