mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 10:39:05 +00:00
Added configurable message sound.
Added spy override to /reply command.
This commit is contained in:
parent
0c0e4da5f0
commit
40a7d70270
@ -108,6 +108,9 @@ unmuteinterval: 60
|
|||||||
# Enables or disabled BungeeCord messaging
|
# Enables or disabled BungeeCord messaging
|
||||||
bungeecordmessaging: false
|
bungeecordmessaging: false
|
||||||
|
|
||||||
|
# Sound for message notification
|
||||||
|
message_sound: ENTITY_PLAYER_LEVELUP
|
||||||
|
|
||||||
# This will allow vanished players to be exempt from being sent private messages, and will act as if they aren't online
|
# This will allow vanished players to be exempt from being sent private messages, and will act as if they aren't online
|
||||||
vanishsupport: true
|
vanishsupport: true
|
||||||
|
|
||||||
|
@ -108,6 +108,9 @@ unmuteinterval: 60
|
|||||||
# Enables or disabled BungeeCord messaging
|
# Enables or disabled BungeeCord messaging
|
||||||
bungeecordmessaging: false
|
bungeecordmessaging: false
|
||||||
|
|
||||||
|
# Sound for message notification
|
||||||
|
message_sound: ENTITY_PLAYER_LEVELUP
|
||||||
|
|
||||||
# This will allow vanished players to be exempt from being sent private messages, and will act as if they aren't online
|
# This will allow vanished players to be exempt from being sent private messages, and will act as if they aren't online
|
||||||
vanishsupport: true
|
vanishsupport: true
|
||||||
|
|
||||||
|
@ -97,7 +97,6 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
import org.bukkit.Sound;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
@ -1254,12 +1253,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
p.getPlayer().sendMessage(Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(p.getPlayer(), send.replaceAll("receiver_", ""))) + msg);
|
p.getPlayer().sendMessage(Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(p.getPlayer(), send.replaceAll("receiver_", ""))) + msg);
|
||||||
if(p.hasNotifications()) {
|
if(p.hasNotifications()) {
|
||||||
if(VersionHandler.is1_8() || VersionHandler.is1_7_10() || VersionHandler.is1_7_2() || VersionHandler.is1_7_9()) {
|
Format.playMessageSound(p);
|
||||||
p.getPlayer().playSound(p.getPlayer().getLocation(), Sound.valueOf("LEVEL_UP"), 1, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
p.getPlayer().playSound(p.getPlayer().getLocation(), Sound.valueOf("ENTITY_PLAYER_LEVELUP"), 1, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p.setReplyPlayer(sender);
|
p.setReplyPlayer(sender);
|
||||||
out.writeUTF("Message");
|
out.writeUTF("Message");
|
||||||
|
@ -6,7 +6,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabExecutor;
|
import org.bukkit.command.TabExecutor;
|
||||||
@ -19,7 +18,6 @@ import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
|||||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||||
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
|
||||||
|
|
||||||
public class MessageCommandExecutor implements TabExecutor {
|
public class MessageCommandExecutor implements TabExecutor {
|
||||||
private MineverseChat plugin = MineverseChat.getInstance();
|
private MineverseChat plugin = MineverseChat.getInstance();
|
||||||
@ -101,12 +99,7 @@ public class MessageCommandExecutor implements TabExecutor {
|
|||||||
player.getPlayer().sendMessage(send);
|
player.getPlayer().sendMessage(send);
|
||||||
mcp.getPlayer().sendMessage(echo);
|
mcp.getPlayer().sendMessage(echo);
|
||||||
if(player.hasNotifications()) {
|
if(player.hasNotifications()) {
|
||||||
if(VersionHandler.is1_8() || VersionHandler.is1_7_10() || VersionHandler.is1_7_2() || VersionHandler.is1_7_9()) {
|
Format.playMessageSound(player);
|
||||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.valueOf("LEVEL_UP"), 1, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.valueOf("ENTITY_PLAYER_LEVELUP"), 1, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(!mcp.getPlayer().hasPermission("venturechat.spy.override")) {
|
if(!mcp.getPlayer().hasPermission("venturechat.spy.override")) {
|
||||||
for(MineverseChatPlayer sp : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
for(MineverseChatPlayer sp : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
||||||
|
@ -3,7 +3,6 @@ package mineverse.Aust1n46.chat.command.message;
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -14,7 +13,6 @@ import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
|||||||
import mineverse.Aust1n46.chat.command.MineverseCommand;
|
import mineverse.Aust1n46.chat.command.MineverseCommand;
|
||||||
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
|
||||||
|
|
||||||
public class Reply extends MineverseCommand {
|
public class Reply extends MineverseCommand {
|
||||||
private MineverseChat plugin = MineverseChat.getInstance();
|
private MineverseChat plugin = MineverseChat.getInstance();
|
||||||
@ -97,12 +95,7 @@ public class Reply extends MineverseCommand {
|
|||||||
player.getPlayer().sendMessage(send);
|
player.getPlayer().sendMessage(send);
|
||||||
mcp.getPlayer().sendMessage(echo);
|
mcp.getPlayer().sendMessage(echo);
|
||||||
if(player.hasNotifications()) {
|
if(player.hasNotifications()) {
|
||||||
if(VersionHandler.is1_8() || VersionHandler.is1_7_10() || VersionHandler.is1_7_2() || VersionHandler.is1_7_9()) {
|
Format.playMessageSound(player);
|
||||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.valueOf("LEVEL_UP"), 1, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.valueOf("ENTITY_PLAYER_LEVELUP"), 1, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
player.setReplyPlayer(mcp.getUUID());
|
player.setReplyPlayer(mcp.getUUID());
|
||||||
return;
|
return;
|
||||||
@ -119,13 +112,11 @@ public class Reply extends MineverseCommand {
|
|||||||
private void sendBungeeCordReply(MineverseChatPlayer mcp, String[] args) {
|
private void sendBungeeCordReply(MineverseChatPlayer mcp, String[] args) {
|
||||||
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||||
DataOutputStream out = new DataOutputStream(byteOutStream);
|
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||||
String msg = "";
|
StringBuilder msgBuilder = new StringBuilder();
|
||||||
String send = "";
|
|
||||||
String echo = "";
|
|
||||||
String spy = "";
|
|
||||||
for(int r = 0; r < args.length; r++) {
|
for(int r = 0; r < args.length; r++) {
|
||||||
msg += " " + args[r];
|
msgBuilder.append(" " + args[r]);
|
||||||
}
|
}
|
||||||
|
String msg = msgBuilder.toString();
|
||||||
if(mcp.hasFilter()) {
|
if(mcp.hasFilter()) {
|
||||||
msg = Format.FilterChat(msg);
|
msg = Format.FilterChat(msg);
|
||||||
}
|
}
|
||||||
@ -139,9 +130,12 @@ public class Reply extends MineverseCommand {
|
|||||||
msg = Format.FormatString(msg);
|
msg = Format.FormatString(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
send = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("replyformatfrom").replaceAll("sender_", "")));
|
String send = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("replyformatfrom").replaceAll("sender_", "")));
|
||||||
echo = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("replyformatto").replaceAll("sender_", "")));
|
String echo = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("replyformatto").replaceAll("sender_", "")));
|
||||||
|
String spy = "VentureChat:NoSpy";
|
||||||
|
if(!mcp.getPlayer().hasPermission("venturechat.spy.override")) {
|
||||||
spy = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("replyformatspy").replaceAll("sender_", "")));
|
spy = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("replyformatspy").replaceAll("sender_", "")));
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
out.writeUTF("Message");
|
out.writeUTF("Message");
|
||||||
out.writeUTF("Send");
|
out.writeUTF("Send");
|
||||||
|
@ -7,7 +7,6 @@ import java.util.Set;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -31,7 +30,6 @@ import mineverse.Aust1n46.chat.command.mute.MuteContainer;
|
|||||||
import mineverse.Aust1n46.chat.database.Database;
|
import mineverse.Aust1n46.chat.database.Database;
|
||||||
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
|
||||||
|
|
||||||
//This class listens to chat through the chat event and handles the bulk of the chat channels and formatting.
|
//This class listens to chat through the chat event and handles the bulk of the chat channels and formatting.
|
||||||
public class ChatListener implements Listener {
|
public class ChatListener implements Listener {
|
||||||
@ -144,12 +142,7 @@ public class ChatListener implements Listener {
|
|||||||
tp.getPlayer().sendMessage(send);
|
tp.getPlayer().sendMessage(send);
|
||||||
mcp.getPlayer().sendMessage(echo);
|
mcp.getPlayer().sendMessage(echo);
|
||||||
if(tp.hasNotifications()) {
|
if(tp.hasNotifications()) {
|
||||||
if(VersionHandler.is1_8()) {
|
Format.playMessageSound(tp);
|
||||||
tp.getPlayer().playSound(tp.getPlayer().getLocation(), Sound.valueOf("LEVEL_UP"), 1, 0);
|
|
||||||
}
|
|
||||||
if(VersionHandler.is1_9()) {
|
|
||||||
tp.getPlayer().playSound(tp.getPlayer().getLocation(), Sound.valueOf("ENTITY_PLAYER_LEVELUP"), 1, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mcp.setReplyPlayer(tp.getUUID());
|
mcp.setReplyPlayer(tp.getUUID());
|
||||||
tp.setReplyPlayer(mcp.getUUID());
|
tp.setReplyPlayer(mcp.getUUID());
|
||||||
|
@ -3,13 +3,16 @@ package mineverse.Aust1n46.chat.utilities;
|
|||||||
import static mineverse.Aust1n46.chat.MineverseChat.getInstance;
|
import static mineverse.Aust1n46.chat.MineverseChat.getInstance;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
@ -46,6 +49,9 @@ public class Format {
|
|||||||
public static final long MILLISECONDS_PER_MINUTE = 60000;
|
public static final long MILLISECONDS_PER_MINUTE = 60000;
|
||||||
public static final long MILLISECONDS_PER_SECOND = 1000;
|
public static final long MILLISECONDS_PER_SECOND = 1000;
|
||||||
|
|
||||||
|
public static final String DEFAULT_MESSAGE_SOUND = "ENTITY_PLAYER_LEVELUP";
|
||||||
|
public static final String DEFAULT_LEGACY_MESSAGE_SOUND = "LEVEL_UP";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a message to Minecraft JSON formatting while applying the
|
* Converts a message to Minecraft JSON formatting while applying the
|
||||||
* {@link JsonFormat} from the config.
|
* {@link JsonFormat} from the config.
|
||||||
@ -843,4 +849,27 @@ public class Format {
|
|||||||
mcp.getPlayer().sendMessage(message);
|
mcp.getPlayer().sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void playMessageSound(MineverseChatPlayer mcp) {
|
||||||
|
Player player = mcp.getPlayer();
|
||||||
|
Sound messageSound = getSound(getInstance().getConfig().getString("message_sound", DEFAULT_MESSAGE_SOUND));
|
||||||
|
player.playSound(player.getLocation(), messageSound, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Sound getSound(String soundName) {
|
||||||
|
if(Arrays.asList(Sound.values()).stream().map(Sound::toString).collect(Collectors.toList()).contains(soundName)) {
|
||||||
|
return Sound.valueOf(soundName);
|
||||||
|
}
|
||||||
|
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&c - Message sound invalid!"));
|
||||||
|
return getDefaultMessageSound();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Sound getDefaultMessageSound() {
|
||||||
|
if(VersionHandler.is1_8() || VersionHandler.is1_7_10() || VersionHandler.is1_7_2() || VersionHandler.is1_7_9()) {
|
||||||
|
return Sound.valueOf(DEFAULT_LEGACY_MESSAGE_SOUND);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Sound.valueOf(DEFAULT_MESSAGE_SOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user