Merge branch 'main' into party
This commit is contained in:
commit
0932bf8d51
|
|
@ -203,7 +203,7 @@ public final class Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO prefixes need hovers, this hasn't been setup yet!
|
// TODO prefixes need hovers, this hasn't been setup yet!
|
||||||
public static String CHATFORMAT = "<white><light_purple><prefixall> <gray><sender>: <white><message>";
|
public static String CHATFORMAT = "<white><light_purple><prefixall> <gray><hover:show_text:Click to message <sendername>><click:suggest_command:/msg <sendername> ><sender></hover>: <white><message>";
|
||||||
private static void Chat() {
|
private static void Chat() {
|
||||||
CHATFORMAT = getString("chat.format", CHATFORMAT);
|
CHATFORMAT = getString("chat.format", CHATFORMAT);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ public class Utility {
|
||||||
public static HashMap<String, String> colors;
|
public static HashMap<String, String> colors;
|
||||||
static { // this might be in minimessage already?
|
static { // this might be in minimessage already?
|
||||||
colors = new HashMap<>();
|
colors = new HashMap<>();
|
||||||
colors.put("&0", "<black>"); // and confirm these are correct
|
colors.put("&0", "<black>");
|
||||||
colors.put("&1", "<dark_blue>"); // could also add some default hex colors here?
|
colors.put("&1", "<dark_blue>");
|
||||||
colors.put("&2", "<dark_green>");
|
colors.put("&2", "<dark_green>");
|
||||||
colors.put("&3", "<dark_aqua>");
|
colors.put("&3", "<dark_aqua>");
|
||||||
colors.put("&4", "<dark_red>");
|
colors.put("&4", "<dark_red>");
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ChatHandler {
|
public class ChatHandler {
|
||||||
|
|
@ -158,15 +159,16 @@ public class ChatHandler {
|
||||||
if (channel.isProxy()) {
|
if (channel.isProxy()) {
|
||||||
sendChatChannelMessage(player, channel.getChannelName(), "chatchannel", component);
|
sendChatChannelMessage(player, channel.getChannelName(), "chatchannel", component);
|
||||||
} else {
|
} else {
|
||||||
sendChatChannelMessage(channel, component);
|
sendChatChannelMessage(channel, player.getUniqueId(), component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendChatChannelMessage(Channel chatChannel, Component component) {
|
private void sendChatChannelMessage(Channel chatChannel, UUID uuid, Component component) {
|
||||||
if (!chatChannel.getServers().contains(Bukkit.getServerName())) return;
|
if (!chatChannel.getServers().contains(Bukkit.getServerName())) return;
|
||||||
|
|
||||||
Bukkit.getServer().getOnlinePlayers().stream()
|
Bukkit.getServer().getOnlinePlayers().stream()
|
||||||
.filter(p -> p.hasPermission(chatChannel.getPermission()))
|
.filter(p -> p.hasPermission(chatChannel.getPermission()))
|
||||||
|
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers().contains(uuid))
|
||||||
.forEach(p -> p.sendMessage(component));
|
.forEach(p -> p.sendMessage(component));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -191,6 +193,7 @@ public class ChatHandler {
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
out.writeUTF(channel);
|
out.writeUTF(channel);
|
||||||
out.writeUTF(chatChannelName);
|
out.writeUTF(chatChannelName);
|
||||||
|
out.writeUTF(player.getUniqueId().toString());
|
||||||
out.writeUTF(GsonComponentSerializer.gson().serialize(component));
|
out.writeUTF(GsonComponentSerializer.gson().serialize(component));
|
||||||
player.sendPluginMessage(plugin, Config.MESSAGECHANNEL, out.toByteArray());
|
player.sendPluginMessage(plugin, Config.MESSAGECHANNEL, out.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ public class ChatListener implements Listener, ChatRenderer {
|
||||||
|
|
||||||
List<Template> templates = new ArrayList<>(List.of(
|
List<Template> templates = new ArrayList<>(List.of(
|
||||||
Template.of("sender", user.getDisplayName()),
|
Template.of("sender", user.getDisplayName()),
|
||||||
|
Template.of("sendername", player.getName()),
|
||||||
Template.of("prefix", user.getPrefix()),
|
Template.of("prefix", user.getPrefix()),
|
||||||
Template.of("prefixall", user.getPrefixAll()),
|
Template.of("prefixall", user.getPrefixAll()),
|
||||||
Template.of("staffprefix", user.getStaffPrefix()),
|
Template.of("staffprefix", user.getStaffPrefix()),
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,11 @@ public class PluginMessage implements PluginMessageListener {
|
||||||
|
|
||||||
private void chatChannel(ByteArrayDataInput in) {
|
private void chatChannel(ByteArrayDataInput in) {
|
||||||
Channel chatChannel = null;
|
Channel chatChannel = null;
|
||||||
|
UUID uuid = null;
|
||||||
Component component = null;
|
Component component = null;
|
||||||
try {
|
try {
|
||||||
chatChannel = Channel.getChatChannel(in.readUTF());
|
chatChannel = Channel.getChatChannel(in.readUTF());
|
||||||
|
uuid = UUID.fromString(in.readUTF());
|
||||||
component = GsonComponentSerializer.gson().deserialize(in.readUTF());
|
component = GsonComponentSerializer.gson().deserialize(in.readUTF());
|
||||||
} catch (Exception e) { //Idk the exception for reading too far into in.readUTF()
|
} catch (Exception e) { //Idk the exception for reading too far into in.readUTF()
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
@ -102,12 +104,14 @@ public class PluginMessage implements PluginMessageListener {
|
||||||
|
|
||||||
final Channel finalChatChannel = chatChannel;
|
final Channel finalChatChannel = chatChannel;
|
||||||
final Component finalComponent = component;
|
final Component finalComponent = component;
|
||||||
|
final UUID finalUuid = uuid;
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Bukkit.getOnlinePlayers().stream()
|
Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(p -> p.hasPermission(finalChatChannel.getPermission()))
|
.filter(p -> p.hasPermission(finalChatChannel.getPermission()))
|
||||||
|
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers().contains(finalUuid))
|
||||||
.forEach(p -> p.sendMessage(finalComponent));
|
.forEach(p -> p.sendMessage(finalComponent));
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user