Add reason support for muting.

This commit is contained in:
Aust1n46 2021-04-04 18:03:29 -05:00
parent 113e04aa19
commit 704905d439
13 changed files with 436 additions and 214 deletions

View File

@ -17,7 +17,9 @@ ChannelNoPermissionView: '&cYou do not have permission to look at this channel.'
ChannelNoSpeakPermissions: '&cYou do not have permission to speak in this channel.'
ChannelPlayerListHeader: '&6Players in Channel: {channel_color}{channel_name}'
ChannelMuted: '&cYou are muted in this channel: {channel_color}{channel_name}'
ChannelMutedReason: '&cYou are muted in this channel: {channel_color}{channel_name} &4Reason:&c {reason}'
ChannelMutedTimed: '&cYou are muted in this channel: {channel_color}{channel_name}&c for {time}'
ChannelMutedTimedReason: '&cYou are muted in this channel: {channel_color}{channel_name}&c for {time} &4Reason:&c {reason}'
CommandInvalidArguments: '&cInvalid command: {command} {args}'
CommandInvalidArgumentsIgnore: '&cInvalid command: /ignore [player] or /ignore list'
CommandMustBeRunByPlayer: '&cThis command must be run by a player.'
@ -54,11 +56,15 @@ MustListenOneChannel: '&cYou need to be listening on at least one channel, setti
MutePlayerAllPlayer: '&cYou have just been muted in all channels.'
MutePlayerAllSender: '&cMuted player &6{player} &cin all channels.'
MutePlayerPlayer: '&cYou have just been muted in: {channel_color}{channel_name}'
MutePlayerPlayerReason: '&cYou have just been muted in: {channel_color}{channel_name} &4Reason:&c {reason}'
MutePlayerPlayerTime: '&cYou have just been muted in: {channel_color}{channel_name} &cfor {time}'
MutePlayerPlayerTimeReason: '&cYou have just been muted in: {channel_color}{channel_name} &cfor {time} &4Reason:&c {reason}'
MutePlayerSpam: '&cYou have been muted for spamming in: {channel_color}{channel_name}'
MutePlayerSpamTime: '&cYou have been muted for spamming in: {channel_color}{channel_name} &cfor {time}'
MutePlayerSender: '&cMuted player &6{player} &cin: {channel_color}{channel_name}'
MutePlayerSenderReason: '&cMuted player &6{player} &cin: {channel_color}{channel_name} &4Reason:&c {reason}'
MutePlayerSenderTime: '&cMuted player &6{player} &cin: {channel_color}{channel_name} &cfor {time}'
MutePlayerSenderTimeReason: '&cMuted player &6{player} &cin: {channel_color}{channel_name} &cfor {time} &4Reason:&c {reason}'
NoPlayerToReplyTo: '&cYou do not have anyone to reply to.'
NotificationsOff: '&aYou are no longer receiving notifications.'
NotificationsOn: '&aYou are now receiving notifications.'

View File

@ -81,6 +81,7 @@ import mineverse.Aust1n46.chat.command.message.Notifications;
import mineverse.Aust1n46.chat.command.message.Reply;
import mineverse.Aust1n46.chat.command.message.Spy;
import mineverse.Aust1n46.chat.command.mute.Mute;
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
import mineverse.Aust1n46.chat.command.mute.Muteall;
import mineverse.Aust1n46.chat.command.mute.Unmute;
import mineverse.Aust1n46.chat.command.mute.Unmuteall;
@ -378,12 +379,12 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
public void run() {
for (MineverseChatPlayer p : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
long currentTimeMillis = System.currentTimeMillis();
Iterator<String> iterator = p.getMutes().keySet().iterator();
Iterator<MuteContainer> iterator = p.getMutes().iterator();
while (iterator.hasNext()) {
String channelName = iterator.next();
if(ChatChannel.isChannel(channelName)) {
ChatChannel channel = ChatChannel.getChannel(channelName);
long timemark = p.getMutes().get(channelName);
MuteContainer mute = iterator.next();
if(ChatChannel.isChannel(mute.getChannel())) {
ChatChannel channel = ChatChannel.getChannel(mute.getChannel());
long timemark = mute.getDuration();
if (timemark == 0) {
continue;
}
@ -394,7 +395,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
iterator.remove();
p.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString()
.replace("{player}", p.getName()).replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channelName));
.replace("{channel_name}", mute.getChannel()));
if(channel.getBungee()) {
MineverseChat.getInstance().synchronize(p, true);
}
@ -566,19 +567,20 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
}
// out.writeUTF("Mutes");
int muteCount = 0;
for(String c : mcp.getMutes().keySet()) {
ChatChannel channel = ChatChannel.getChannel(c);
for(MuteContainer mute : mcp.getMutes()) {
ChatChannel channel = ChatChannel.getChannel(mute.getChannel());
if(channel.getBungee()) {
muteCount++;
}
}
// System.out.println(muteCount + " mutes");
out.write(muteCount);
for(String c : mcp.getMutes().keySet()) {
ChatChannel channel = ChatChannel.getChannel(c);
for(MuteContainer mute : mcp.getMutes()) {
ChatChannel channel = ChatChannel.getChannel(mute.getChannel());
if(channel.getBungee()) {
out.writeUTF(channel.getName());
out.writeLong(mcp.getMutes().get(c));
out.writeLong(mute.getDuration());
out.writeUTF(mute.getReason());
}
}
int ignoreCount = 0;
@ -816,20 +818,16 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
}
}
}
for(Object o : p.getMutes().keySet().toArray()) {
ChatChannel ch = ChatChannel.getChannel((String) o);
if(ch.getBungee()) {
p.removeMute(ch.getName());
}
}
p.getMutes().removeIf(mute -> ChatChannel.getChannel(mute.getChannel()).getBungee());
int sizeB = msgin.read();
// System.out.println(sizeB + " mute size");
for(int b = 0; b < sizeB; b++) {
String ch = msgin.readUTF();
long muteTime = msgin.readLong();
String muteReason = msgin.readUTF();
// System.out.println(ch);
if(ChatChannel.isChannel(ch)) {
p.addMute(ch, muteTime);
p.addMute(ch, muteTime, muteReason);
}
}
// System.out.println(msgin.available() + " available before");
@ -849,7 +847,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
if(!p.hasPlayed()) {
boolean isThereABungeeChannel = false;
for(ChatChannel ch : ChatChannel.getAutojoinList()) {
if(!ch.hasPermission() || p.getPlayer().hasPermission(ch.getPermission())) {
if((!ch.hasPermission() || p.getPlayer().hasPermission(ch.getPermission())) && !p.isListening(ch.getName())) {
p.addListening(ch.getName());
if(ch.getBungee()) {
isThereABungeeChannel = true;
@ -924,6 +922,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
String playerToMute = msgin.readUTF();
String channelName = msgin.readUTF();
long time = msgin.readLong();
String reason = msgin.readUTF();
MineverseChatPlayer playerToMuteMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(playerToMute);
if(playerToMuteMCP == null) {
out.writeUTF("Mute");
@ -951,20 +950,42 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
}
if(time > 0) {
long datetime = System.currentTimeMillis();
playerToMuteMCP.addMute(chatChannelObj.getName(), datetime + time);
String timeString = Format.parseTimeStringFromMillis(time);
playerToMuteMCP.getPlayer()
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME.toString()
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName())
.replace("{time}", timeString));
if(reason.isEmpty()) {
playerToMuteMCP.addMute(chatChannelObj.getName(), datetime + time);
String timeString = Format.parseTimeStringFromMillis(time);
playerToMuteMCP.getPlayer()
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME.toString()
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName())
.replace("{time}", timeString));
}
else {
playerToMuteMCP.addMute(chatChannelObj.getName(), datetime + time, reason);
String timeString = Format.parseTimeStringFromMillis(time);
playerToMuteMCP.getPlayer()
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME_REASON.toString()
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName())
.replace("{time}", timeString)
.replace("{reason}", reason));
}
}
else {
playerToMuteMCP.addMute(chatChannelObj.getName(), 0);
playerToMuteMCP.getPlayer()
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER.toString()
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName()));
if(reason.isEmpty()) {
playerToMuteMCP.addMute(chatChannelObj.getName());
playerToMuteMCP.getPlayer()
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER.toString()
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName()));
}
else {
playerToMuteMCP.addMute(chatChannelObj.getName(), reason);
playerToMuteMCP.getPlayer()
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_REASON.toString()
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName())
.replace("{reason}", reason));
}
}
synchronize(playerToMuteMCP, true);
out.writeUTF("Mute");
@ -974,6 +995,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
out.writeUTF(playerToMute);
out.writeUTF(channelName);
out.writeLong(time);
out.writeUTF(reason);
sendPluginMessage(stream);
return;
}
@ -982,43 +1004,86 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
String playerToMute = msgin.readUTF();
String channelName = msgin.readUTF();
long time = msgin.readLong();
String reason = msgin.readUTF();
if(!ChatChannel.isChannel(channelName)) {
return;
}
ChatChannel chatChannelObj = ChatChannel.getChannel(channelName);
if(time > 0) {
String timeString = Format.parseTimeStringFromMillis(time);
if(senderIdentifier.equals("VentureChat:Console")) {
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
.replace("{player}", playerToMute)
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName())
.replace("{time}", timeString));
if(reason.isEmpty()) {
if(senderIdentifier.equals("VentureChat:Console")) {
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
.replace("{player}", playerToMute)
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName())
.replace("{time}", timeString));
}
else {
UUID sender = UUID.fromString(senderIdentifier);
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
senderMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
.replace("{player}", playerToMute)
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName())
.replace("{time}", timeString));
}
}
else {
UUID sender = UUID.fromString(senderIdentifier);
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
senderMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
.replace("{player}", playerToMute)
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName())
.replace("{time}", timeString));
if(senderIdentifier.equals("VentureChat:Console")) {
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME_REASON.toString()
.replace("{player}", playerToMute)
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName())
.replace("{time}", timeString)
.replace("{reason}", reason));
}
else {
UUID sender = UUID.fromString(senderIdentifier);
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
senderMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME_REASON.toString()
.replace("{player}", playerToMute)
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName())
.replace("{time}", timeString)
.replace("{reason}", reason));
}
}
}
else {
if(senderIdentifier.equals("VentureChat:Console")) {
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString()
.replace("{player}", playerToMute)
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName()));
if(reason.isEmpty()) {
if(senderIdentifier.equals("VentureChat:Console")) {
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString()
.replace("{player}", playerToMute)
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName()));
}
else {
UUID sender = UUID.fromString(senderIdentifier);
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
senderMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString()
.replace("{player}", playerToMute)
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName()));
}
}
else {
UUID sender = UUID.fromString(senderIdentifier);
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
senderMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString()
.replace("{player}", playerToMute)
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName()));
if(senderIdentifier.equals("VentureChat:Console")) {
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_REASON.toString()
.replace("{player}", playerToMute)
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName())
.replace("{reason}", reason));
}
else {
UUID sender = UUID.fromString(senderIdentifier);
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
senderMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_REASON.toString()
.replace("{player}", playerToMute)
.replace("{channel_color}", chatChannelObj.getColor())
.replace("{channel_name}", chatChannelObj.getName())
.replace("{reason}", reason));
}
}
}
return;
@ -1174,7 +1239,6 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
MineverseChatPlayer p = MineverseChatAPI.getOnlineMineverseChatPlayer(receiver);
UUID sender = UUID.fromString(msgin.readUTF());
String sName = msgin.readUTF();
MineverseChatPlayer s = MineverseChatAPI.getMineverseChatPlayer(sender);
String send = msgin.readUTF();
String echo = msgin.readUTF();
String spy = msgin.readUTF();
@ -1206,20 +1270,6 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
return;
}
else {
UUID uuid = sender;
String name = sName;
ChatChannel current = ChatChannel.getDefaultChannel();
Set<UUID> ignores = new HashSet<UUID>();
Set<String> listening = new HashSet<String>();
listening.add(current.getName());
HashMap<String, Long> mutes = new HashMap<String, Long>();
Set<String> blockedCommands = new HashSet<String>();
String jsonFormat = "Default";
s = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, false, null, true, true, name, jsonFormat, false, false, false, true, true);
MineverseChatAPI.addMineverseChatPlayerToMap(s);
MineverseChatAPI.addNameToMap(s);
}
p.getPlayer().sendMessage(Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(p.getPlayer(), send.replaceAll("receiver_", ""))) + msg);
if(p.hasNotifications()) {
if(VersionHandler.is1_8() || VersionHandler.is1_7_10() || VersionHandler.is1_7_2() || VersionHandler.is1_7_9()) {

View File

@ -1,7 +1,9 @@
package mineverse.Aust1n46.chat.api;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
@ -9,6 +11,7 @@ import java.util.UUID;
import mineverse.Aust1n46.chat.ChatMessage;
import mineverse.Aust1n46.chat.MineverseChat;
import mineverse.Aust1n46.chat.channel.ChatChannel;
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
import mineverse.Aust1n46.chat.json.JsonFormat;
import org.bukkit.Bukkit;
@ -22,7 +25,7 @@ public class MineverseChatPlayer {
private ChatChannel currentChannel;
private Set<UUID> ignores;
private Set<String> listening;
private HashMap<String, Long> mutes;
private HashMap<String, MuteContainer> mutes;
private Set<String> blockedCommands;
private boolean host;
private UUID party;
@ -50,7 +53,7 @@ public class MineverseChatPlayer {
private boolean messageToggle;
private boolean bungeeToggle;
public MineverseChatPlayer(UUID uuid, String name, ChatChannel currentChannel, Set<UUID> ignores, Set<String> listening, HashMap<String, Long> mutes, Set<String> blockedCommands, boolean host, UUID party, boolean filter, boolean notifications, String nickname, String jsonFormat, boolean spy, boolean commandSpy, boolean rangedSpy, boolean messageToggle, boolean bungeeToggle) {
public MineverseChatPlayer(UUID uuid, String name, ChatChannel currentChannel, Set<UUID> ignores, Set<String> listening, HashMap<String, MuteContainer> mutes, Set<String> blockedCommands, boolean host, UUID party, boolean filter, boolean notifications, String nickname, String jsonFormat, boolean spy, boolean commandSpy, boolean rangedSpy, boolean messageToggle, boolean bungeeToggle) {
this.uuid = uuid;
this.name = name;
this.currentChannel = currentChannel;
@ -83,6 +86,40 @@ public class MineverseChatPlayer {
this.bungeeToggle = bungeeToggle;
}
public MineverseChatPlayer(UUID uuid, String name) {
this.uuid = uuid;
this.name = name;
this.currentChannel = ChatChannel.getDefaultChannel();
this.ignores = new HashSet<UUID>();
this.listening = new HashSet<String>();
listening.add(currentChannel.getName());
this.mutes = new HashMap<String, MuteContainer>();
this.blockedCommands = new HashSet<String>();
this.host = false;
this.party = null;
this.filter = true;
this.notifications = true;
this.nickname = name;
this.online = false;
this.player = null;
this.hasPlayed = false;
this.conversation = null;
this.spy = false;
this.rangedSpy = false;
this.commandSpy = false;
this.quickChat = false;
this.quickChannel = null;
this.replyPlayer = null;
this.partyChat = false;
this.modified = false;
this.messages = new ArrayList<ChatMessage>();
this.jsonFormat = "Default";
this.cooldowns = new HashMap<ChatChannel, Long>();
this.spam = new HashMap<ChatChannel, List<Long>>();
this.messageToggle = true;
this.bungeeToggle = true;
}
public boolean getBungeeToggle() {
return this.bungeeToggle;
}
@ -207,13 +244,29 @@ public class MineverseChatPlayer {
this.listening.clear();
}
public HashMap<String, Long> getMutes() {
return this.mutes;
public Collection<MuteContainer> getMutes() {
return this.mutes.values();
}
public MuteContainer getMute(String channel) {
return mutes.get(channel);
}
public boolean addMute(String channel) {
return addMute(channel, 0, "");
}
public boolean addMute(String channel, long time) {
return addMute(channel, time, "");
}
public boolean addMute(String channel, String reason) {
return addMute(channel, 0, reason);
}
public boolean addMute(String channel, long time, String reason) {
if(channel != null && time >= 0) {
mutes.put(channel, time);
mutes.put(channel, new MuteContainer(channel, time, reason));
return true;
}
return false;

View File

@ -1,22 +1,26 @@
package mineverse.Aust1n46.chat.api;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
public class SynchronizedMineverseChatPlayer {
private UUID uuid;
private Set<String> listening;
private HashMap<String, Long> mutes;
private HashMap<String, MuteContainer> mutes;
private Set<UUID> ignores;
private int messagePackets;
private List<String> messageData = new ArrayList<String>();
private boolean spy;
private boolean messageToggle;
public SynchronizedMineverseChatPlayer(UUID uuid, Set<String> listening, HashMap<String, Long> mutes, Set<UUID> ignores, boolean spy, boolean messageToggle) {
public SynchronizedMineverseChatPlayer(UUID uuid, Set<String> listening, HashMap<String, MuteContainer> mutes, Set<UUID> ignores, boolean spy, boolean messageToggle) {
this.uuid = uuid;
this.listening = listening;
this.mutes = mutes;
@ -25,6 +29,15 @@ public class SynchronizedMineverseChatPlayer {
this.messageToggle = messageToggle;
}
public SynchronizedMineverseChatPlayer(UUID uuid) {
this.uuid = uuid;
listening = new HashSet<String>();
mutes = new HashMap<String, MuteContainer>();
ignores = new HashSet<UUID>();
spy = false;
messageToggle = true;
}
public List<String> getMessageData() {
return this.messageData;
}
@ -61,16 +74,16 @@ public class SynchronizedMineverseChatPlayer {
return this.ignores;
}
public void addMute(String channel, long muteTime) {
this.mutes.put(channel, muteTime);
public void addMute(String channel, long time, String reason) {
mutes.put(channel, new MuteContainer(channel, time, reason));
}
public void removeMute(String channel) {
this.mutes.remove(channel);
public void clearMutes() {
this.mutes.clear();
}
public HashMap<String, Long> getMutes() {
return this.mutes;
public Collection<MuteContainer> getMutes() {
return this.mutes.values();
}
public void addListening(String channel) {

View File

@ -6,16 +6,11 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
import mineverse.Aust1n46.chat.api.SynchronizedMineverseChatPlayer;
import mineverse.Aust1n46.chat.bungee.command.GlobalMute;
import mineverse.Aust1n46.chat.bungee.command.GlobalMuteAll;
import mineverse.Aust1n46.chat.bungee.command.GlobalUnmute;
import mineverse.Aust1n46.chat.bungee.command.GlobalUnmuteAll;
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
import mineverse.Aust1n46.chat.database.BungeePlayerData;
import mineverse.Aust1n46.chat.database.TemporaryDataInstance;
import mineverse.Aust1n46.chat.utilities.UUIDFetcher;
@ -61,8 +56,6 @@ public class MineverseChatBungee extends Plugin implements Listener {
this.getProxy().registerChannel(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL);
this.getProxy().getPluginManager().registerListener(this, this);
registerBungeeCordMuteCommands();
}
@Override
@ -70,21 +63,6 @@ public class MineverseChatBungee extends Plugin implements Listener {
BungeePlayerData.saveBungeePlayerData();
}
/**
* Old BungeeCord mute commands that pretty much no one even knows about let alone uses...
* Slated for removal when the mute system is reworked.
*/
private void registerBungeeCordMuteCommands() {
getProxy().getPluginManager().registerCommand(this, new GlobalMute(this, "globalmute"));
getProxy().getPluginManager().registerCommand(this, new GlobalMute(this, "gmute"));
getProxy().getPluginManager().registerCommand(this, new GlobalMuteAll(this, "globalmuteall"));
getProxy().getPluginManager().registerCommand(this, new GlobalMuteAll(this, "gmuteall"));
getProxy().getPluginManager().registerCommand(this, new GlobalUnmute(this, "globalunmute"));
getProxy().getPluginManager().registerCommand(this, new GlobalUnmute(this, "gunmute"));
getProxy().getPluginManager().registerCommand(this, new GlobalUnmuteAll(this, "globalunmuteall"));
getProxy().getPluginManager().registerCommand(this, new GlobalUnmuteAll(this, "gunmuteall"));
}
public static MineverseChatBungee getInstance() {
return instance;
}
@ -316,6 +294,7 @@ public class MineverseChatBungee extends Plugin implements Listener {
String playerToMute = in.readUTF();
String channelName = in.readUTF();
long time = in.readLong();
String reason = in.readUTF();
UUID temporaryDataInstanceUUID = TemporaryDataInstance.createTemporaryDataInstance();
out.writeUTF("Mute");
out.writeUTF("Send");
@ -325,6 +304,7 @@ public class MineverseChatBungee extends Plugin implements Listener {
out.writeUTF(playerToMute);
out.writeUTF(channelName);
out.writeLong(time);
out.writeUTF(reason);
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());
@ -337,12 +317,14 @@ public class MineverseChatBungee extends Plugin implements Listener {
String playerToMute = in.readUTF();
String channelName = in.readUTF();
long time = in.readLong();
String reason = in.readUTF();
out.writeUTF("Mute");
out.writeUTF("Valid");
out.writeUTF(senderIdentifier);
out.writeUTF(playerToMute);
out.writeUTF(channelName);
out.writeLong(time);
out.writeUTF(reason);
if(getProxy().getServers().get(server).getPlayers().size() > 0) {
getProxy().getServers().get(server).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, outstream.toByteArray());
}
@ -574,7 +556,7 @@ public class MineverseChatBungee extends Plugin implements Listener {
UUID uuid = UUID.fromString(in.readUTF());
SynchronizedMineverseChatPlayer smcp = MineverseChatAPI.getSynchronizedMineverseChatPlayer(uuid);
if(smcp == null) {
smcp = new SynchronizedMineverseChatPlayer(uuid, new HashSet<String>(), new HashMap<String, Long>(), new HashSet<UUID>(), false, true);
smcp = new SynchronizedMineverseChatPlayer(uuid);
MineverseChatAPI.addSynchronizedMineverseChatPlayerToMap(smcp);
}
out.writeUTF("Sync");
@ -585,13 +567,13 @@ public class MineverseChatBungee extends Plugin implements Listener {
for(String channel : smcp.getListening()) {
out.writeUTF(channel);
}
int muteCount = smcp.getMutes().keySet().size();
int muteCount = smcp.getMutes().size();
//System.out.println(muteCount);
out.write(muteCount);
for(String channel : smcp.getMutes().keySet()) {
//System.out.println(channel);
out.writeUTF(channel);
out.writeLong(smcp.getMutes().get(channel));
for(MuteContainer muteContainer : smcp.getMutes()) {
out.writeUTF(muteContainer.getChannel());
out.writeLong(muteContainer.getDuration());
out.writeUTF(muteContainer.getReason());
}
//System.out.println(smcp.isSpy() + " spy value");
//System.out.println(out.size() + " size before");
@ -611,11 +593,11 @@ public class MineverseChatBungee extends Plugin implements Listener {
UUID uuid = UUID.fromString(in.readUTF());
SynchronizedMineverseChatPlayer smcp = MineverseChatAPI.getSynchronizedMineverseChatPlayer(uuid);
if(smcp == null) {
smcp = new SynchronizedMineverseChatPlayer(uuid, new HashSet<String>(), new HashMap<String, Long>(), new HashSet<UUID>(), false, true);
smcp = new SynchronizedMineverseChatPlayer(uuid);
MineverseChatAPI.addSynchronizedMineverseChatPlayerToMap(smcp);
}
smcp.getListening().clear();
smcp.getMutes().clear();
smcp.clearMutes();
smcp.getIgnores().clear();
int sizeL = in.read();
//System.out.println(sizeL + " listening");
@ -623,12 +605,12 @@ public class MineverseChatBungee extends Plugin implements Listener {
smcp.addListening(in.readUTF());
}
int sizeM = in.read();
//System.out.println(size + " mutes");
for(int b = 0; b < sizeM; b++) {
String mute = in.readUTF();
long muteTime = in.readLong();
String muteReason = in.readUTF();
//System.out.println(mute);
smcp.addMute(mute, muteTime);
smcp.addMute(mute, muteTime, muteReason);
}
int sizeI = in.read();
for(int c = 0; c < sizeI; c++) {

View File

@ -9,6 +9,7 @@ import mineverse.Aust1n46.chat.api.MineverseChatAPI;
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
import mineverse.Aust1n46.chat.channel.ChatChannel;
import mineverse.Aust1n46.chat.command.MineverseCommand;
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
public class Chatinfo extends MineverseCommand {
private MineverseChat plugin = MineverseChat.getInstance();;
@ -36,8 +37,8 @@ public class Chatinfo extends MineverseCommand {
ChatChannel channel = ChatChannel.getChannel(c);
listen += channel.getColor() + channel.getName() + " ";
}
for(String c : mcp.getMutes().keySet()) {
ChatChannel channel = ChatChannel.getChannel(c);
for(MuteContainer muteContainer : mcp.getMutes()) {
ChatChannel channel = ChatChannel.getChannel(muteContainer.getChannel());
mute += channel.getColor() + channel.getName() + " ";
}
for(String bc : mcp.getBlockedCommands()) {
@ -97,8 +98,8 @@ public class Chatinfo extends MineverseCommand {
ChatChannel channel = ChatChannel.getChannel(c);
listen += channel.getColor() + channel.getName() + " ";
}
for(String c : p.getMutes().keySet()) {
ChatChannel channel = ChatChannel.getChannel(c);
for(MuteContainer muteContainer : p.getMutes()) {
ChatChannel channel = ChatChannel.getChannel(muteContainer.getChannel());
mute += channel.getColor() + channel.getName() + " ";
}
for(String bc : p.getBlockedCommands()) {

View File

@ -41,25 +41,26 @@ public class Mute extends MineverseCommand {
if (channel.isMutable()) {
long datetime = System.currentTimeMillis();
long time = 0;
int reasonStartPos = 2;
String reason = "";
if(args.length > 2) {
try {
time = Format.parseTimeStringToMillis(args[2]);
String timeString = args[2];
if(Character.isDigit(timeString.charAt(0))) {
reasonStartPos = 3;
time = Format.parseTimeStringToMillis(timeString);
if (time <= 0) {
sender.sendMessage(LocalizedMessage.INVALID_TIME.toString().replace("{args}", args[2]));
sender.sendMessage(LocalizedMessage.INVALID_TIME.toString().replace("{args}", timeString));
return;
}
}
catch (Exception e) {
sender.sendMessage(LocalizedMessage.INVALID_TIME.toString().replace("{args}", args[2]));
return;
StringBuilder reasonBuilder = new StringBuilder();
for(int a = reasonStartPos; a < args.length; a ++) {
reasonBuilder.append(args[a]);
}
reason = reasonBuilder.toString();
}
if(channel.getBungee()) {
if(args.length > 2) {
sendBungeeCordMute(sender, args[1], channel, time);
return;
}
sendBungeeCordMute(sender, args[1], channel, 0);
sendBungeeCordMute(sender, args[1], channel, time, reason);
return;
}
MineverseChatPlayer playerToMute = MineverseChatAPI.getMineverseChatPlayer(args[1]);
@ -73,40 +74,87 @@ public class Mute extends MineverseCommand {
.replace("{channel_name}", channel.getName()));
return;
}
if(args.length > 2) {
playerToMute.addMute(channel.getName(), datetime + time);
String timeString = Format.parseTimeStringFromMillis(time);
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
.replace("{player}", playerToMute.getName())
.replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName())
.replace("{time}", timeString));
if (playerToMute.isOnline()) {
playerToMute.getPlayer()
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME.toString()
.replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName())
.replace("{time}", timeString));
if(time > 0) {
if(reason.isEmpty()) {
playerToMute.addMute(channel.getName(), datetime + time);
String timeString = Format.parseTimeStringFromMillis(time);
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
.replace("{player}", playerToMute.getName())
.replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName())
.replace("{time}", timeString));
if (playerToMute.isOnline()) {
playerToMute.getPlayer()
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME.toString()
.replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName())
.replace("{time}", timeString));
}
else {
playerToMute.setModified(true);
}
return;
}
else {
playerToMute.setModified(true);
playerToMute.addMute(channel.getName(), datetime + time, reason);
String timeString = Format.parseTimeStringFromMillis(time);
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME_REASON.toString()
.replace("{player}", playerToMute.getName())
.replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName())
.replace("{time}", timeString)
.replace("{reason}", reason));
if (playerToMute.isOnline()) {
playerToMute.getPlayer()
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME_REASON.toString()
.replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName())
.replace("{time}", timeString)
.replace("{reason}", reason));
}
else {
playerToMute.setModified(true);
}
return;
}
return;
}
playerToMute.addMute(channel.getName(), 0);
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString()
.replace("{player}", playerToMute.getName()).replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName()));
if (playerToMute.isOnline()) {
playerToMute.getPlayer()
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER.toString()
.replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName()));
}
else {
playerToMute.setModified(true);
if(reason.isEmpty()) {
playerToMute.addMute(channel.getName());
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString()
.replace("{player}", playerToMute.getName()).replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName()));
if (playerToMute.isOnline()) {
playerToMute.getPlayer()
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER.toString()
.replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName()));
}
else {
playerToMute.setModified(true);
}
return;
}
else {
playerToMute.addMute(channel.getName(), reason);
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_REASON.toString()
.replace("{player}", playerToMute.getName()).replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName())
.replace("{reason}", reason));
if (playerToMute.isOnline()) {
playerToMute.getPlayer()
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_REASON.toString()
.replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName())
.replace("{reason}", reason));
}
else {
playerToMute.setModified(true);
}
return;
}
}
return;
}
sender.sendMessage(LocalizedMessage.CHANNEL_CANNOT_MUTE.toString()
.replace("{channel_color}", channel.getColor())
@ -149,7 +197,7 @@ public class Mute extends MineverseCommand {
return Collections.emptyList();
}
private void sendBungeeCordMute(CommandSender sender, String playerToMute, ChatChannel channel, long time) {
private void sendBungeeCordMute(CommandSender sender, String playerToMute, ChatChannel channel, long time, String reason) {
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(byteOutStream);
try {
@ -164,6 +212,7 @@ public class Mute extends MineverseCommand {
out.writeUTF(playerToMute);
out.writeUTF(channel.getName());
out.writeLong(time);
out.writeUTF(reason);
MineverseChat.sendPluginMessage(byteOutStream);
out.close();
}

View File

@ -0,0 +1,45 @@
package mineverse.Aust1n46.chat.command.mute;
public class MuteContainer {
private String channel;
private String reason;
private long duration;
public MuteContainer(String channel) {
this(channel, 0, "");
}
public MuteContainer(String channel, long duration) {
this(channel, duration, "");
}
public MuteContainer(String channel, String reason) {
this(channel, 0, reason);
}
public MuteContainer(String channel, long duration, String reason) {
this.channel = channel;
this.reason = reason;
this.duration = duration;
}
public String getChannel() {
return channel;
}
public boolean hasReason() {
return !reason.equals("");
}
public String getReason() {
return reason;
}
public boolean hasDuration() {
return duration > 0;
}
public long getDuration() {
return duration;
}
}

View File

@ -14,6 +14,7 @@ import java.util.UUID;
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
import mineverse.Aust1n46.chat.api.SynchronizedMineverseChatPlayer;
import mineverse.Aust1n46.chat.bungee.MineverseChatBungee;
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
import mineverse.Aust1n46.chat.utilities.Format;
import mineverse.Aust1n46.chat.utilities.UUIDFetcher;
import net.md_5.bungee.api.ProxyServer;
@ -52,11 +53,12 @@ public class BungeePlayerData {
String channel = l.nextToken();
listening.add(channel);
}
HashMap<String, Long> mutes = new HashMap<String, Long>();
HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>();
StringTokenizer m = new StringTokenizer(playerData.getString(uuidString + ".mutes"), ",");
while(m.hasMoreTokens()) {
String[] parts = m.nextToken().split(":");
mutes.put(parts[0], Long.parseLong(parts[1]));
String channelName = parts[0];
mutes.put(channelName, new MuteContainer(channelName, Long.parseLong(parts[1])));
}
HashSet<UUID> ignores = new HashSet<UUID>();
StringTokenizer n = new StringTokenizer(playerData.getString(uuidString + ".ignores"), ",");
@ -115,11 +117,11 @@ public class BungeePlayerData {
String channel = l.nextToken();
listening.add(channel);
}
HashMap<String, Long> mutes = new HashMap<String, Long>();
StringTokenizer m = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("mutes"), ",");
while(m.hasMoreTokens()) {
String[] parts = m.nextToken().split(":");
mutes.put(parts[0], Long.parseLong(parts[1]));
HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>();
Configuration muteSection = bungeePlayerDataFileConfiguration.getSection("mutes");
for(String channelName : muteSection.getKeys()) {
Configuration channelSection = muteSection.getSection(channelName);
mutes.put(channelName, new MuteContainer(channelName, channelSection.getLong("time"), channelSection.getString("reason")));
}
HashSet<UUID> ignores = new HashSet<UUID>();
StringTokenizer n = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("ignores"), ",");
@ -157,20 +159,20 @@ public class BungeePlayerData {
String listen = "";
for(String s : p.getListening())
listen += s + ",";
String mute = "";
for(String s : p.getMutes().keySet())
mute += s + ":0,";
String ignore = "";
for(UUID s : p.getIgnores())
ignore += s.toString() + ",";
if(listen.length() > 0)
listen = listen.substring(0, listen.length() - 1);
if(mute.length() > 0)
mute = mute.substring(0, mute.length() - 1);
if(ignore.length() > 0)
ignore = ignore.substring(0, ignore.length() - 1);
bungeePlayerDataFileConfiguration.set("channels", listen);
bungeePlayerDataFileConfiguration.set("mutes", mute);
Configuration muteSection = createSection(bungeePlayerDataFileConfiguration, "mutes");
for(MuteContainer mute : p.getMutes()) {
Configuration channelSection = createSection(muteSection, mute.getChannel());
channelSection.set("time", mute.getDuration());
channelSection.set("reason", mute.getReason());
}
bungeePlayerDataFileConfiguration.set("ignores", ignore);
bungeePlayerDataFileConfiguration.set("spy", p.isSpy());
bungeePlayerDataFileConfiguration.set("messagetoggle", p.getMessageToggle());
@ -182,4 +184,16 @@ public class BungeePlayerData {
e.printStackTrace();
}
}
/**
* Create a new {@link Configuration} section.
*
* @param configurationSection
* @param sectionKey
* @return Configuration
*/
private static Configuration createSection(Configuration configurationSection, String sectionKey) {
configurationSection.set(sectionKey, null);
return configurationSection.getSection(sectionKey);
}
}

View File

@ -22,6 +22,7 @@ import mineverse.Aust1n46.chat.MineverseChat;
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
import mineverse.Aust1n46.chat.channel.ChatChannel;
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
import mineverse.Aust1n46.chat.utilities.Format;
import mineverse.Aust1n46.chat.utilities.UUIDFetcher;
@ -65,7 +66,7 @@ public class PlayerData {
listening.add(channel);
}
}
HashMap<String, Long> mutes = new HashMap<String, Long>();
HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>();
StringTokenizer m = new StringTokenizer(playerData.getConfigurationSection("players." + uuidString).getString("mutes"), ",");
while(m.hasMoreTokens()) {
String[] parts = m.nextToken().split(":");
@ -74,7 +75,8 @@ public class PlayerData {
Bukkit.getConsoleSender().sendMessage("[VentureChat] Null Mute Time: " + parts[0] + " " + name);
continue;
}
mutes.put(ChatChannel.getChannel(parts[0]).getName(), Long.parseLong(parts[1]));
String channelName = parts[0];
mutes.put(channelName, new MuteContainer(channelName, Long.parseLong(parts[1])));
}
}
Set<String> blockedCommands = new HashSet<String>();
@ -161,22 +163,11 @@ public class PlayerData {
listening.add(channel);
}
}
HashMap<String, Long> mutes = new HashMap<String, Long>();
// StringTokenizer m = new StringTokenizer(playerDataFileYamlConfiguration.getString("mutes"), ",");
// while(m.hasMoreTokens()) {
// String[] parts = m.nextToken().split(":");
// if(ChatChannel.isChannel(parts[0])) {
// if(parts[1].equals("null")) {
// Bukkit.getConsoleSender().sendMessage("[VentureChat] Null Mute Time: " + parts[0] + " " + name);
// continue;
// }
// mutes.put(ChatChannel.getChannel(parts[0]).getName(), Long.parseLong(parts[1]));
// }
// }
HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>();
ConfigurationSection muteSection = playerDataFileYamlConfiguration.getConfigurationSection("mutes");
for(String channelName : muteSection.getKeys(false)) {
ConfigurationSection channelSection = muteSection.getConfigurationSection(channelName);
mutes.put(channelName, channelSection.getLong("time"));
mutes.put(channelName, new MuteContainer(channelName, channelSection.getLong("time"), channelSection.getString("reason")));
}
Set<String> blockedCommands = new HashSet<String>();
@ -242,9 +233,10 @@ public class PlayerData {
playerDataFileYamlConfiguration.set("listen", listening);
ConfigurationSection muteSection = playerDataFileYamlConfiguration.createSection("mutes");
for(String channelName : mcp.getMutes().keySet()) {
ConfigurationSection channelSection = muteSection.createSection(channelName);
channelSection.set("time", mcp.getMutes().get(channelName));
for(MuteContainer mute : mcp.getMutes()) {
ConfigurationSection channelSection = muteSection.createSection(mute.getChannel());
channelSection.set("time", mute.getDuration());
channelSection.set("reason", mute.getReason());
}
playerDataFileYamlConfiguration.set("blockedcommands", blockedCommands);

View File

@ -29,6 +29,7 @@ import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
import mineverse.Aust1n46.chat.api.events.ChannelJoinEvent;
import mineverse.Aust1n46.chat.api.events.VentureChatEvent;
import mineverse.Aust1n46.chat.channel.ChatChannel;
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
import mineverse.Aust1n46.chat.utilities.Format;
import mineverse.Aust1n46.chat.versions.VersionHandler;
@ -210,25 +211,45 @@ public class ChatListener implements Listener {
Boolean filterthis = true;
mcp.addListening(eventChannel.getName());
if (mcp.isMuted(eventChannel.getName())) {
if (mcp.getMutes().get(eventChannel.getName()).longValue() > 0) {
MuteContainer muteContainer = mcp.getMute(eventChannel.getName());
if (muteContainer.hasDuration()) {
long dateTimeMillis = System.currentTimeMillis();
long muteTimeMillis = mcp.getMutes().get(eventChannel.getName()).longValue();
long muteTimeMillis = muteContainer.getDuration();
long remainingMuteTime = muteTimeMillis - dateTimeMillis;
if (remainingMuteTime < 1000) {
remainingMuteTime = 1000;
}
String timeString = Format.parseTimeStringFromMillis(remainingMuteTime);
mcp.getPlayer()
.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED.toString()
.replace("{channel_color}", eventChannel.getColor())
.replace("{channel_name}", eventChannel.getName())
.replace("{time}", timeString));
if(muteContainer.hasReason()) {
mcp.getPlayer()
.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED_REASON.toString()
.replace("{channel_color}", eventChannel.getColor())
.replace("{channel_name}", eventChannel.getName())
.replace("{time}", timeString)
.replace("{reason}", muteContainer.getReason()));
}
else {
mcp.getPlayer()
.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED.toString()
.replace("{channel_color}", eventChannel.getColor())
.replace("{channel_name}", eventChannel.getName())
.replace("{time}", timeString));
}
}
else {
mcp.getPlayer()
.sendMessage(LocalizedMessage.CHANNEL_MUTED.toString()
.replace("{channel_color}", eventChannel.getColor())
.replace("{channel_name}", eventChannel.getName()));
if(muteContainer.hasReason()) {
mcp.getPlayer()
.sendMessage(LocalizedMessage.CHANNEL_MUTED_REASON.toString()
.replace("{channel_color}", eventChannel.getColor())
.replace("{channel_name}", eventChannel.getName())
.replace("{reason}", muteContainer.getReason()));
}
else {
mcp.getPlayer()
.sendMessage(LocalizedMessage.CHANNEL_MUTED.toString()
.replace("{channel_color}", eventChannel.getColor())
.replace("{channel_name}", eventChannel.getName()));
}
}
mcp.setQuickChat(false);
return;

View File

@ -1,8 +1,5 @@
package mineverse.Aust1n46.chat.listeners;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
@ -64,14 +61,7 @@ public class LoginListener implements Listener {
Player player = event.getPlayer();
String name = player.getName();
UUID uuid = player.getUniqueId();
ChatChannel current = ChatChannel.getDefaultChannel();
Set<UUID> ignores = new HashSet<UUID>();
Set<String> listening = new HashSet<String>();
listening.add(current.getName());
HashMap<String, Long> mutes = new HashMap<String, Long>();
Set<String> blockedCommands = new HashSet<String>();
String jsonFormat = "Default";
mcp = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, false, null, true, true, name, jsonFormat, false, false, false, true, true);
mcp = new MineverseChatPlayer(uuid, name);
MineverseChatAPI.addMineverseChatPlayerToMap(mcp);
MineverseChatAPI.addNameToMap(mcp);
}

View File

@ -24,7 +24,9 @@ public enum LocalizedMessage {
CHANNEL_NO_SPEAK_PERMISSIONS("ChannelNoSpeakPermissions"),
CHANNEL_PLAYER_LIST_HEADER("ChannelPlayerListHeader"),
CHANNEL_MUTED("ChannelMuted"),
CHANNEL_MUTED_REASON("ChannelMutedReason"),
CHANNEL_MUTED_TIMED("ChannelMutedTimed"),
CHANNEL_MUTED_TIMED_REASON("ChannelMutedTimedReason"),
COMMAND_INVALID_ARGUMENTS("CommandInvalidArguments"),
COMMAND_INVALID_ARGUMENTS_IGNORE("CommandInvalidArgumentsIgnore"),
COMMAND_MUST_BE_RUN_BY_PLAYER("CommandMustBeRunByPlayer"),
@ -62,10 +64,14 @@ public enum LocalizedMessage {
MUTE_PLAYER_ALL_SENDER("MutePlayerAllSender"),
MUTE_PLAYER_PLAYER("MutePlayerPlayer"),
MUTE_PLAYER_PLAYER_TIME("MutePlayerPlayerTime"),
MUTE_PLAYER_PLAYER_TIME_REASON("MutePlayerPlayerTimeReason"),
MUTE_PLAYER_PLAYER_REASON("MutePlayerPlayerReason"),
MUTE_PLAYER_SPAM("MutePlayerSpam"),
MUTE_PLAYER_SPAM_TIME("MutePlayerSpamTime"),
MUTE_PLAYER_SENDER("MutePlayerSender"),
MUTE_PLAYER_SENDER_REASON("MutePlayerSenderReason"),
MUTE_PLAYER_SENDER_TIME("MutePlayerSenderTime"),
MUTE_PLAYER_SENDER_TIME_REASON("MutePlayerSenderTimeReason"),
NO_PLAYER_TO_REPLY_TO("NoPlayerToReplyTo"),
NOTIFICATIONS_OFF("NotificationsOff"),
NOTIFICATIONS_ON("NotificationsOn"),