mirror of
				https://github.com/Aust1n46/VentureChat.git
				synced 2025-10-30 21:52:23 +00:00 
			
		
		
		
	Add reason support for muting.
This commit is contained in:
		
							parent
							
								
									113e04aa19
								
							
						
					
					
						commit
						704905d439
					
				| @ -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.' | ChannelNoSpeakPermissions: '&cYou do not have permission to speak in this channel.' | ||||||
| ChannelPlayerListHeader: '&6Players in Channel: {channel_color}{channel_name}' | ChannelPlayerListHeader: '&6Players in Channel: {channel_color}{channel_name}' | ||||||
| ChannelMuted: '&cYou are muted in this 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}' | 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}' | CommandInvalidArguments: '&cInvalid command: {command} {args}' | ||||||
| CommandInvalidArgumentsIgnore: '&cInvalid command: /ignore [player] or /ignore list' | CommandInvalidArgumentsIgnore: '&cInvalid command: /ignore [player] or /ignore list' | ||||||
| CommandMustBeRunByPlayer: '&cThis command must be run by a player.' | 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.' | MutePlayerAllPlayer: '&cYou have just been muted in all channels.' | ||||||
| MutePlayerAllSender: '&cMuted player &6{player} &cin all channels.' | MutePlayerAllSender: '&cMuted player &6{player} &cin all channels.' | ||||||
| MutePlayerPlayer: '&cYou have just been muted in: {channel_color}{channel_name}' | 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}' | 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}' | 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}' | MutePlayerSpamTime: '&cYou have been muted for spamming in: {channel_color}{channel_name} &cfor {time}' | ||||||
| MutePlayerSender: '&cMuted player &6{player} &cin: {channel_color}{channel_name}' | 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}' | 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.' | NoPlayerToReplyTo: '&cYou do not have anyone to reply to.' | ||||||
| NotificationsOff: '&aYou are no longer receiving notifications.' | NotificationsOff: '&aYou are no longer receiving notifications.' | ||||||
| NotificationsOn: '&aYou are now receiving notifications.' | NotificationsOn: '&aYou are now receiving notifications.' | ||||||
|  | |||||||
| @ -81,6 +81,7 @@ import mineverse.Aust1n46.chat.command.message.Notifications; | |||||||
| import mineverse.Aust1n46.chat.command.message.Reply; | import mineverse.Aust1n46.chat.command.message.Reply; | ||||||
| import mineverse.Aust1n46.chat.command.message.Spy; | import mineverse.Aust1n46.chat.command.message.Spy; | ||||||
| import mineverse.Aust1n46.chat.command.mute.Mute; | 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.Muteall; | ||||||
| import mineverse.Aust1n46.chat.command.mute.Unmute; | import mineverse.Aust1n46.chat.command.mute.Unmute; | ||||||
| import mineverse.Aust1n46.chat.command.mute.Unmuteall; | import mineverse.Aust1n46.chat.command.mute.Unmuteall; | ||||||
| @ -378,12 +379,12 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener { | |||||||
| 			public void run() { | 			public void run() { | ||||||
| 				for (MineverseChatPlayer p : MineverseChatAPI.getOnlineMineverseChatPlayers()) { | 				for (MineverseChatPlayer p : MineverseChatAPI.getOnlineMineverseChatPlayers()) { | ||||||
| 					long currentTimeMillis = System.currentTimeMillis(); | 					long currentTimeMillis = System.currentTimeMillis(); | ||||||
| 					Iterator<String> iterator = p.getMutes().keySet().iterator(); | 					Iterator<MuteContainer> iterator = p.getMutes().iterator(); | ||||||
| 					while (iterator.hasNext()) { | 					while (iterator.hasNext()) { | ||||||
| 						String channelName = iterator.next(); | 						MuteContainer mute = iterator.next(); | ||||||
| 						if(ChatChannel.isChannel(channelName)) { | 						if(ChatChannel.isChannel(mute.getChannel())) { | ||||||
| 							ChatChannel channel = ChatChannel.getChannel(channelName); | 							ChatChannel channel = ChatChannel.getChannel(mute.getChannel()); | ||||||
| 							long timemark = p.getMutes().get(channelName); | 							long timemark = mute.getDuration(); | ||||||
| 							if (timemark == 0) { | 							if (timemark == 0) { | ||||||
| 								continue; | 								continue; | ||||||
| 							} | 							} | ||||||
| @ -394,7 +395,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener { | |||||||
| 								iterator.remove(); | 								iterator.remove(); | ||||||
| 								p.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString() | 								p.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString() | ||||||
| 										.replace("{player}", p.getName()).replace("{channel_color}", channel.getColor()) | 										.replace("{player}", p.getName()).replace("{channel_color}", channel.getColor()) | ||||||
| 										.replace("{channel_name}", channelName)); | 										.replace("{channel_name}", mute.getChannel())); | ||||||
| 								if(channel.getBungee()) { | 								if(channel.getBungee()) { | ||||||
| 									MineverseChat.getInstance().synchronize(p, true); | 									MineverseChat.getInstance().synchronize(p, true); | ||||||
| 								} | 								} | ||||||
| @ -566,19 +567,20 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener { | |||||||
| 				} | 				} | ||||||
| 				// out.writeUTF("Mutes"); | 				// out.writeUTF("Mutes"); | ||||||
| 				int muteCount = 0; | 				int muteCount = 0; | ||||||
| 				for(String c : mcp.getMutes().keySet()) { | 				for(MuteContainer mute : mcp.getMutes()) { | ||||||
| 					ChatChannel channel = ChatChannel.getChannel(c); | 					ChatChannel channel = ChatChannel.getChannel(mute.getChannel()); | ||||||
| 					if(channel.getBungee()) { | 					if(channel.getBungee()) { | ||||||
| 						muteCount++; | 						muteCount++; | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				// System.out.println(muteCount + " mutes"); | 				// System.out.println(muteCount + " mutes"); | ||||||
| 				out.write(muteCount); | 				out.write(muteCount); | ||||||
| 				for(String c : mcp.getMutes().keySet()) { | 				for(MuteContainer mute : mcp.getMutes()) { | ||||||
| 					ChatChannel channel = ChatChannel.getChannel(c); | 					ChatChannel channel = ChatChannel.getChannel(mute.getChannel()); | ||||||
| 					if(channel.getBungee()) { | 					if(channel.getBungee()) { | ||||||
| 						out.writeUTF(channel.getName()); | 						out.writeUTF(channel.getName()); | ||||||
| 						out.writeLong(mcp.getMutes().get(c)); | 						out.writeLong(mute.getDuration()); | ||||||
|  | 						out.writeUTF(mute.getReason()); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				int ignoreCount = 0; | 				int ignoreCount = 0; | ||||||
| @ -816,20 +818,16 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener { | |||||||
| 						} | 						} | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				for(Object o : p.getMutes().keySet().toArray()) { | 				p.getMutes().removeIf(mute -> ChatChannel.getChannel(mute.getChannel()).getBungee()); | ||||||
| 					ChatChannel ch = ChatChannel.getChannel((String) o); |  | ||||||
| 					if(ch.getBungee()) { |  | ||||||
| 						p.removeMute(ch.getName()); |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 				int sizeB = msgin.read(); | 				int sizeB = msgin.read(); | ||||||
| 				// System.out.println(sizeB + " mute size"); | 				// System.out.println(sizeB + " mute size"); | ||||||
| 				for(int b = 0; b < sizeB; b++) { | 				for(int b = 0; b < sizeB; b++) { | ||||||
| 					String ch = msgin.readUTF(); | 					String ch = msgin.readUTF(); | ||||||
| 					long muteTime = msgin.readLong(); | 					long muteTime = msgin.readLong(); | ||||||
|  | 					String muteReason = msgin.readUTF(); | ||||||
| 					// System.out.println(ch); | 					// System.out.println(ch); | ||||||
| 					if(ChatChannel.isChannel(ch)) { | 					if(ChatChannel.isChannel(ch)) { | ||||||
| 						p.addMute(ch, muteTime); | 						p.addMute(ch, muteTime, muteReason); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				// System.out.println(msgin.available() + " available before"); | 				// System.out.println(msgin.available() + " available before"); | ||||||
| @ -849,7 +847,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener { | |||||||
| 				if(!p.hasPlayed()) { | 				if(!p.hasPlayed()) { | ||||||
| 					boolean isThereABungeeChannel = false; | 					boolean isThereABungeeChannel = false; | ||||||
| 					for(ChatChannel ch : ChatChannel.getAutojoinList()) { | 					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());	 | 							p.addListening(ch.getName());	 | ||||||
| 							if(ch.getBungee()) { | 							if(ch.getBungee()) { | ||||||
| 								isThereABungeeChannel = true; | 								isThereABungeeChannel = true; | ||||||
| @ -924,6 +922,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener { | |||||||
| 					String playerToMute = msgin.readUTF(); | 					String playerToMute = msgin.readUTF(); | ||||||
| 					String channelName = msgin.readUTF(); | 					String channelName = msgin.readUTF(); | ||||||
| 					long time = msgin.readLong(); | 					long time = msgin.readLong(); | ||||||
|  | 					String reason = msgin.readUTF(); | ||||||
| 					MineverseChatPlayer playerToMuteMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(playerToMute); | 					MineverseChatPlayer playerToMuteMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(playerToMute); | ||||||
| 					if(playerToMuteMCP == null) { | 					if(playerToMuteMCP == null) { | ||||||
| 						out.writeUTF("Mute"); | 						out.writeUTF("Mute"); | ||||||
| @ -951,20 +950,42 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener { | |||||||
| 					} | 					} | ||||||
| 					if(time > 0) { | 					if(time > 0) { | ||||||
| 						long datetime = System.currentTimeMillis(); | 						long datetime = System.currentTimeMillis(); | ||||||
| 						playerToMuteMCP.addMute(chatChannelObj.getName(), datetime + time); | 						if(reason.isEmpty()) { | ||||||
| 						String timeString = Format.parseTimeStringFromMillis(time); | 							playerToMuteMCP.addMute(chatChannelObj.getName(), datetime + time); | ||||||
| 						playerToMuteMCP.getPlayer() | 							String timeString = Format.parseTimeStringFromMillis(time); | ||||||
| 								.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME.toString() | 							playerToMuteMCP.getPlayer() | ||||||
| 								.replace("{channel_color}", chatChannelObj.getColor()) | 									.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME.toString() | ||||||
| 								.replace("{channel_name}", chatChannelObj.getName()) | 									.replace("{channel_color}", chatChannelObj.getColor()) | ||||||
| 								.replace("{time}", timeString)); | 									.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 { | 					else { | ||||||
| 						playerToMuteMCP.addMute(chatChannelObj.getName(), 0); | 						if(reason.isEmpty()) { | ||||||
| 						playerToMuteMCP.getPlayer() | 							playerToMuteMCP.addMute(chatChannelObj.getName()); | ||||||
| 								.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER.toString() | 							playerToMuteMCP.getPlayer() | ||||||
| 								.replace("{channel_color}", chatChannelObj.getColor()) | 									.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER.toString() | ||||||
| 								.replace("{channel_name}", chatChannelObj.getName()));	 | 									.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); | 					synchronize(playerToMuteMCP, true); | ||||||
| 					out.writeUTF("Mute"); | 					out.writeUTF("Mute"); | ||||||
| @ -974,6 +995,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener { | |||||||
| 					out.writeUTF(playerToMute); | 					out.writeUTF(playerToMute); | ||||||
| 					out.writeUTF(channelName); | 					out.writeUTF(channelName); | ||||||
| 					out.writeLong(time); | 					out.writeLong(time); | ||||||
|  | 					out.writeUTF(reason); | ||||||
| 					sendPluginMessage(stream); | 					sendPluginMessage(stream); | ||||||
| 					return; | 					return; | ||||||
| 				} | 				} | ||||||
| @ -982,43 +1004,86 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener { | |||||||
| 					String playerToMute = msgin.readUTF(); | 					String playerToMute = msgin.readUTF(); | ||||||
| 					String channelName = msgin.readUTF(); | 					String channelName = msgin.readUTF(); | ||||||
| 					long time = msgin.readLong(); | 					long time = msgin.readLong(); | ||||||
|  | 					String reason = msgin.readUTF(); | ||||||
| 					if(!ChatChannel.isChannel(channelName)) { | 					if(!ChatChannel.isChannel(channelName)) { | ||||||
| 						return; | 						return; | ||||||
| 					} | 					} | ||||||
| 					ChatChannel chatChannelObj = ChatChannel.getChannel(channelName); | 					ChatChannel chatChannelObj = ChatChannel.getChannel(channelName); | ||||||
| 					if(time > 0) { | 					if(time > 0) { | ||||||
| 						String timeString = Format.parseTimeStringFromMillis(time); | 						String timeString = Format.parseTimeStringFromMillis(time); | ||||||
| 						if(senderIdentifier.equals("VentureChat:Console")) { | 						if(reason.isEmpty()) { | ||||||
| 							Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString() | 							if(senderIdentifier.equals("VentureChat:Console")) { | ||||||
| 									.replace("{player}", playerToMute) | 								Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString() | ||||||
| 									.replace("{channel_color}", chatChannelObj.getColor()) | 										.replace("{player}", playerToMute) | ||||||
| 									.replace("{channel_name}", chatChannelObj.getName()) | 										.replace("{channel_color}", chatChannelObj.getColor()) | ||||||
| 									.replace("{time}", timeString)); | 										.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 { | 						else { | ||||||
| 							UUID sender = UUID.fromString(senderIdentifier); | 							if(senderIdentifier.equals("VentureChat:Console")) { | ||||||
| 							MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender); | 								Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME_REASON.toString() | ||||||
| 							senderMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString() | 										.replace("{player}", playerToMute) | ||||||
| 									.replace("{player}", playerToMute) | 										.replace("{channel_color}", chatChannelObj.getColor()) | ||||||
| 									.replace("{channel_color}", chatChannelObj.getColor()) | 										.replace("{channel_name}", chatChannelObj.getName()) | ||||||
| 									.replace("{channel_name}", chatChannelObj.getName()) | 										.replace("{time}", timeString) | ||||||
| 									.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 { | 					else { | ||||||
| 						if(senderIdentifier.equals("VentureChat:Console")) { | 						if(reason.isEmpty()) { | ||||||
| 							Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString() | 							if(senderIdentifier.equals("VentureChat:Console")) { | ||||||
| 									.replace("{player}", playerToMute) | 								Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString() | ||||||
| 									.replace("{channel_color}", chatChannelObj.getColor()) | 										.replace("{player}", playerToMute) | ||||||
| 									.replace("{channel_name}", chatChannelObj.getName())); | 										.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 { | 						else { | ||||||
| 							UUID sender = UUID.fromString(senderIdentifier); | 							if(senderIdentifier.equals("VentureChat:Console")) { | ||||||
| 							MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender); | 								Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_REASON.toString() | ||||||
| 							senderMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString() | 										.replace("{player}", playerToMute) | ||||||
| 									.replace("{player}", playerToMute) | 										.replace("{channel_color}", chatChannelObj.getColor()) | ||||||
| 									.replace("{channel_color}", chatChannelObj.getColor()) | 										.replace("{channel_name}", chatChannelObj.getName()) | ||||||
| 									.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; | 					return; | ||||||
| @ -1174,7 +1239,6 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener { | |||||||
| 					MineverseChatPlayer p = MineverseChatAPI.getOnlineMineverseChatPlayer(receiver); | 					MineverseChatPlayer p = MineverseChatAPI.getOnlineMineverseChatPlayer(receiver); | ||||||
| 					UUID sender = UUID.fromString(msgin.readUTF()); | 					UUID sender = UUID.fromString(msgin.readUTF()); | ||||||
| 					String sName = msgin.readUTF(); | 					String sName = msgin.readUTF(); | ||||||
| 					MineverseChatPlayer s = MineverseChatAPI.getMineverseChatPlayer(sender); |  | ||||||
| 					String send = msgin.readUTF(); | 					String send = msgin.readUTF(); | ||||||
| 					String echo = msgin.readUTF(); | 					String echo = msgin.readUTF(); | ||||||
| 					String spy = 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()); | 						player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray()); | ||||||
| 						return; | 						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); | 					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()) { | 						if(VersionHandler.is1_8() || VersionHandler.is1_7_10() || VersionHandler.is1_7_2() || VersionHandler.is1_7_9()) { | ||||||
|  | |||||||
| @ -1,7 +1,9 @@ | |||||||
| package mineverse.Aust1n46.chat.api; | package mineverse.Aust1n46.chat.api; | ||||||
| 
 | 
 | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
|  | import java.util.Collection; | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
|  | import java.util.HashSet; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Set; | import java.util.Set; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
| @ -9,6 +11,7 @@ import java.util.UUID; | |||||||
| import mineverse.Aust1n46.chat.ChatMessage; | import mineverse.Aust1n46.chat.ChatMessage; | ||||||
| import mineverse.Aust1n46.chat.MineverseChat; | import mineverse.Aust1n46.chat.MineverseChat; | ||||||
| import mineverse.Aust1n46.chat.channel.ChatChannel; | import mineverse.Aust1n46.chat.channel.ChatChannel; | ||||||
|  | import mineverse.Aust1n46.chat.command.mute.MuteContainer; | ||||||
| import mineverse.Aust1n46.chat.json.JsonFormat; | import mineverse.Aust1n46.chat.json.JsonFormat; | ||||||
| 
 | 
 | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| @ -22,7 +25,7 @@ public class MineverseChatPlayer { | |||||||
| 	private ChatChannel currentChannel; | 	private ChatChannel currentChannel; | ||||||
| 	private Set<UUID> ignores; | 	private Set<UUID> ignores; | ||||||
| 	private Set<String> listening; | 	private Set<String> listening; | ||||||
| 	private HashMap<String, Long> mutes; | 	private HashMap<String, MuteContainer> mutes; | ||||||
| 	private Set<String> blockedCommands; | 	private Set<String> blockedCommands; | ||||||
| 	private boolean host; | 	private boolean host; | ||||||
| 	private UUID party; | 	private UUID party; | ||||||
| @ -50,7 +53,7 @@ public class MineverseChatPlayer { | |||||||
| 	private boolean messageToggle; | 	private boolean messageToggle; | ||||||
| 	private boolean bungeeToggle; | 	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.uuid = uuid; | ||||||
| 		this.name = name; | 		this.name = name; | ||||||
| 		this.currentChannel = currentChannel; | 		this.currentChannel = currentChannel; | ||||||
| @ -83,6 +86,40 @@ public class MineverseChatPlayer { | |||||||
| 		this.bungeeToggle = bungeeToggle; | 		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() { | 	public boolean getBungeeToggle() { | ||||||
| 		return this.bungeeToggle; | 		return this.bungeeToggle; | ||||||
| 	} | 	} | ||||||
| @ -207,13 +244,29 @@ public class MineverseChatPlayer { | |||||||
| 		this.listening.clear(); | 		this.listening.clear(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public HashMap<String, Long> getMutes() { | 	public Collection<MuteContainer> getMutes() { | ||||||
| 		return this.mutes; | 		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) { | 	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) { | 		if(channel != null && time >= 0) { | ||||||
| 			mutes.put(channel, time); | 			mutes.put(channel, new MuteContainer(channel, time, reason)); | ||||||
| 			return true; | 			return true; | ||||||
| 		} | 		} | ||||||
| 		return false; | 		return false; | ||||||
|  | |||||||
| @ -1,22 +1,26 @@ | |||||||
| package mineverse.Aust1n46.chat.api; | package mineverse.Aust1n46.chat.api; | ||||||
| 
 | 
 | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
|  | import java.util.Collection; | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
|  | import java.util.HashSet; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Set; | import java.util.Set; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
| 
 | 
 | ||||||
|  | import mineverse.Aust1n46.chat.command.mute.MuteContainer; | ||||||
|  | 
 | ||||||
| public class SynchronizedMineverseChatPlayer { | public class SynchronizedMineverseChatPlayer { | ||||||
| 	private UUID uuid; | 	private UUID uuid; | ||||||
| 	private Set<String> listening; | 	private Set<String> listening; | ||||||
| 	private HashMap<String, Long> mutes; | 	private HashMap<String, MuteContainer> mutes; | ||||||
| 	private Set<UUID> ignores; | 	private Set<UUID> ignores; | ||||||
| 	private int messagePackets; | 	private int messagePackets; | ||||||
| 	private List<String> messageData = new ArrayList<String>(); | 	private List<String> messageData = new ArrayList<String>(); | ||||||
| 	private boolean spy; | 	private boolean spy; | ||||||
| 	private boolean messageToggle; | 	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.uuid = uuid; | ||||||
| 		this.listening = listening; | 		this.listening = listening; | ||||||
| 		this.mutes = mutes; | 		this.mutes = mutes; | ||||||
| @ -25,6 +29,15 @@ public class SynchronizedMineverseChatPlayer { | |||||||
| 		this.messageToggle = messageToggle; | 		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() { | 	public List<String> getMessageData() { | ||||||
| 		return this.messageData; | 		return this.messageData; | ||||||
| 	} | 	} | ||||||
| @ -61,16 +74,16 @@ public class SynchronizedMineverseChatPlayer { | |||||||
| 		return this.ignores; | 		return this.ignores; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public void addMute(String channel, long muteTime) { | 	public void addMute(String channel, long time, String reason) { | ||||||
| 		this.mutes.put(channel, muteTime); | 		mutes.put(channel, new MuteContainer(channel, time, reason));		 | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public void removeMute(String channel) { | 	public void clearMutes() { | ||||||
| 		this.mutes.remove(channel); | 		this.mutes.clear(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public HashMap<String, Long> getMutes() { | 	public Collection<MuteContainer> getMutes() { | ||||||
| 		return this.mutes; | 		return this.mutes.values(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public void addListening(String channel) { | 	public void addListening(String channel) { | ||||||
|  | |||||||
| @ -6,16 +6,11 @@ import java.io.DataInputStream; | |||||||
| import java.io.DataOutputStream; | import java.io.DataOutputStream; | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.nio.file.Files; | import java.nio.file.Files; | ||||||
| import java.util.HashMap; |  | ||||||
| import java.util.HashSet; |  | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
| 
 | 
 | ||||||
| import mineverse.Aust1n46.chat.api.MineverseChatAPI; | import mineverse.Aust1n46.chat.api.MineverseChatAPI; | ||||||
| import mineverse.Aust1n46.chat.api.SynchronizedMineverseChatPlayer; | import mineverse.Aust1n46.chat.api.SynchronizedMineverseChatPlayer; | ||||||
| import mineverse.Aust1n46.chat.bungee.command.GlobalMute; | import mineverse.Aust1n46.chat.command.mute.MuteContainer; | ||||||
| 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.database.BungeePlayerData; | import mineverse.Aust1n46.chat.database.BungeePlayerData; | ||||||
| import mineverse.Aust1n46.chat.database.TemporaryDataInstance; | import mineverse.Aust1n46.chat.database.TemporaryDataInstance; | ||||||
| import mineverse.Aust1n46.chat.utilities.UUIDFetcher; | 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().registerChannel(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL); | ||||||
| 		this.getProxy().getPluginManager().registerListener(this, this); | 		this.getProxy().getPluginManager().registerListener(this, this); | ||||||
| 		 |  | ||||||
| 		registerBungeeCordMuteCommands(); |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| @ -70,21 +63,6 @@ public class MineverseChatBungee extends Plugin implements Listener { | |||||||
| 		BungeePlayerData.saveBungeePlayerData(); | 		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() { | 	public static MineverseChatBungee getInstance() { | ||||||
| 		return instance; | 		return instance; | ||||||
| 	} | 	} | ||||||
| @ -316,6 +294,7 @@ public class MineverseChatBungee extends Plugin implements Listener { | |||||||
| 					String playerToMute = in.readUTF(); | 					String playerToMute = in.readUTF(); | ||||||
| 					String channelName = in.readUTF(); | 					String channelName = in.readUTF(); | ||||||
| 					long time = in.readLong(); | 					long time = in.readLong(); | ||||||
|  | 					String reason = in.readUTF(); | ||||||
| 					UUID temporaryDataInstanceUUID = TemporaryDataInstance.createTemporaryDataInstance(); | 					UUID temporaryDataInstanceUUID = TemporaryDataInstance.createTemporaryDataInstance(); | ||||||
| 					out.writeUTF("Mute"); | 					out.writeUTF("Mute"); | ||||||
| 					out.writeUTF("Send"); | 					out.writeUTF("Send"); | ||||||
| @ -325,6 +304,7 @@ public class MineverseChatBungee extends Plugin implements Listener { | |||||||
| 					out.writeUTF(playerToMute); | 					out.writeUTF(playerToMute); | ||||||
| 					out.writeUTF(channelName); | 					out.writeUTF(channelName); | ||||||
| 					out.writeLong(time); | 					out.writeLong(time); | ||||||
|  | 					out.writeUTF(reason); | ||||||
| 					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) { | ||||||
| 							getProxy().getServers().get(send).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, outstream.toByteArray()); | 							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 playerToMute = in.readUTF(); | ||||||
| 					String channelName = in.readUTF(); | 					String channelName = in.readUTF(); | ||||||
| 					long time = in.readLong(); | 					long time = in.readLong(); | ||||||
|  | 					String reason = in.readUTF(); | ||||||
| 					out.writeUTF("Mute"); | 					out.writeUTF("Mute"); | ||||||
| 					out.writeUTF("Valid"); | 					out.writeUTF("Valid"); | ||||||
| 					out.writeUTF(senderIdentifier); | 					out.writeUTF(senderIdentifier); | ||||||
| 					out.writeUTF(playerToMute); | 					out.writeUTF(playerToMute); | ||||||
| 					out.writeUTF(channelName); | 					out.writeUTF(channelName); | ||||||
| 					out.writeLong(time); | 					out.writeLong(time); | ||||||
|  | 					out.writeUTF(reason); | ||||||
| 					if(getProxy().getServers().get(server).getPlayers().size() > 0) { | 					if(getProxy().getServers().get(server).getPlayers().size() > 0) { | ||||||
| 						getProxy().getServers().get(server).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, outstream.toByteArray()); | 						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()); | 					UUID uuid = UUID.fromString(in.readUTF()); | ||||||
| 					SynchronizedMineverseChatPlayer smcp = MineverseChatAPI.getSynchronizedMineverseChatPlayer(uuid); | 					SynchronizedMineverseChatPlayer smcp = MineverseChatAPI.getSynchronizedMineverseChatPlayer(uuid); | ||||||
| 					if(smcp == null) { | 					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); | 						MineverseChatAPI.addSynchronizedMineverseChatPlayerToMap(smcp); | ||||||
| 					} | 					} | ||||||
| 					out.writeUTF("Sync"); | 					out.writeUTF("Sync"); | ||||||
| @ -585,13 +567,13 @@ public class MineverseChatBungee extends Plugin implements Listener { | |||||||
| 					for(String channel : smcp.getListening()) { | 					for(String channel : smcp.getListening()) { | ||||||
| 						out.writeUTF(channel); | 						out.writeUTF(channel); | ||||||
| 					} | 					} | ||||||
| 					int muteCount = smcp.getMutes().keySet().size(); | 					int muteCount = smcp.getMutes().size(); | ||||||
| 					//System.out.println(muteCount); | 					//System.out.println(muteCount); | ||||||
| 					out.write(muteCount); | 					out.write(muteCount); | ||||||
| 					for(String channel : smcp.getMutes().keySet()) { | 					for(MuteContainer muteContainer : smcp.getMutes()) { | ||||||
| 						//System.out.println(channel); | 						out.writeUTF(muteContainer.getChannel()); | ||||||
| 						out.writeUTF(channel); | 						out.writeLong(muteContainer.getDuration()); | ||||||
| 						out.writeLong(smcp.getMutes().get(channel)); | 						out.writeUTF(muteContainer.getReason()); | ||||||
| 					} | 					} | ||||||
| 					//System.out.println(smcp.isSpy() + " spy value"); | 					//System.out.println(smcp.isSpy() + " spy value"); | ||||||
| 					//System.out.println(out.size() + " size before"); | 					//System.out.println(out.size() + " size before"); | ||||||
| @ -611,11 +593,11 @@ public class MineverseChatBungee extends Plugin implements Listener { | |||||||
| 					UUID uuid = UUID.fromString(in.readUTF()); | 					UUID uuid = UUID.fromString(in.readUTF()); | ||||||
| 					SynchronizedMineverseChatPlayer smcp = MineverseChatAPI.getSynchronizedMineverseChatPlayer(uuid); | 					SynchronizedMineverseChatPlayer smcp = MineverseChatAPI.getSynchronizedMineverseChatPlayer(uuid); | ||||||
| 					if(smcp == null) { | 					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); | 						MineverseChatAPI.addSynchronizedMineverseChatPlayerToMap(smcp); | ||||||
| 					}		 | 					}		 | ||||||
| 					smcp.getListening().clear(); | 					smcp.getListening().clear(); | ||||||
| 					smcp.getMutes().clear(); | 					smcp.clearMutes(); | ||||||
| 					smcp.getIgnores().clear(); | 					smcp.getIgnores().clear(); | ||||||
| 					int sizeL = in.read(); | 					int sizeL = in.read(); | ||||||
| 					//System.out.println(sizeL + " listening"); | 					//System.out.println(sizeL + " listening"); | ||||||
| @ -623,12 +605,12 @@ public class MineverseChatBungee extends Plugin implements Listener { | |||||||
| 						smcp.addListening(in.readUTF()); | 						smcp.addListening(in.readUTF()); | ||||||
| 					} | 					} | ||||||
| 					int sizeM = in.read(); | 					int sizeM = in.read(); | ||||||
| 					//System.out.println(size + " mutes"); |  | ||||||
| 					for(int b = 0; b < sizeM; b++) { | 					for(int b = 0; b < sizeM; b++) { | ||||||
| 						String mute = in.readUTF(); | 						String mute = in.readUTF(); | ||||||
| 						long muteTime = in.readLong(); | 						long muteTime = in.readLong(); | ||||||
|  | 						String muteReason = in.readUTF(); | ||||||
| 						//System.out.println(mute); | 						//System.out.println(mute); | ||||||
| 						smcp.addMute(mute, muteTime); | 						smcp.addMute(mute, muteTime, muteReason); | ||||||
| 					} | 					} | ||||||
| 					int sizeI = in.read(); | 					int sizeI = in.read(); | ||||||
| 					for(int c = 0; c < sizeI; c++) { | 					for(int c = 0; c < sizeI; c++) { | ||||||
|  | |||||||
| @ -9,6 +9,7 @@ import mineverse.Aust1n46.chat.api.MineverseChatAPI; | |||||||
| import mineverse.Aust1n46.chat.api.MineverseChatPlayer; | import mineverse.Aust1n46.chat.api.MineverseChatPlayer; | ||||||
| import mineverse.Aust1n46.chat.channel.ChatChannel; | import mineverse.Aust1n46.chat.channel.ChatChannel; | ||||||
| import mineverse.Aust1n46.chat.command.MineverseCommand; | import mineverse.Aust1n46.chat.command.MineverseCommand; | ||||||
|  | import mineverse.Aust1n46.chat.command.mute.MuteContainer; | ||||||
| 
 | 
 | ||||||
| public class Chatinfo extends MineverseCommand { | public class Chatinfo extends MineverseCommand { | ||||||
| 	private MineverseChat plugin = MineverseChat.getInstance();; | 	private MineverseChat plugin = MineverseChat.getInstance();; | ||||||
| @ -36,8 +37,8 @@ public class Chatinfo extends MineverseCommand { | |||||||
| 						ChatChannel channel = ChatChannel.getChannel(c); | 						ChatChannel channel = ChatChannel.getChannel(c); | ||||||
| 						listen += channel.getColor() + channel.getName() + " ";						 | 						listen += channel.getColor() + channel.getName() + " ";						 | ||||||
| 					} | 					} | ||||||
| 					for(String c : mcp.getMutes().keySet()) { | 					for(MuteContainer muteContainer : mcp.getMutes()) { | ||||||
| 						ChatChannel channel = ChatChannel.getChannel(c); | 						ChatChannel channel = ChatChannel.getChannel(muteContainer.getChannel()); | ||||||
| 						mute += channel.getColor() + channel.getName() + " ";						 | 						mute += channel.getColor() + channel.getName() + " ";						 | ||||||
| 					} | 					} | ||||||
| 					for(String bc : mcp.getBlockedCommands()) {						 | 					for(String bc : mcp.getBlockedCommands()) {						 | ||||||
| @ -97,8 +98,8 @@ public class Chatinfo extends MineverseCommand { | |||||||
| 					ChatChannel channel = ChatChannel.getChannel(c); | 					ChatChannel channel = ChatChannel.getChannel(c); | ||||||
| 					listen += channel.getColor() + channel.getName() + " ";						 | 					listen += channel.getColor() + channel.getName() + " ";						 | ||||||
| 				} | 				} | ||||||
| 				for(String c : p.getMutes().keySet()) { | 				for(MuteContainer muteContainer : p.getMutes()) { | ||||||
| 					ChatChannel channel = ChatChannel.getChannel(c); | 					ChatChannel channel = ChatChannel.getChannel(muteContainer.getChannel()); | ||||||
| 					mute += channel.getColor() + channel.getName() + " ";						 | 					mute += channel.getColor() + channel.getName() + " ";						 | ||||||
| 				} | 				} | ||||||
| 				for(String bc : p.getBlockedCommands()) {						 | 				for(String bc : p.getBlockedCommands()) {						 | ||||||
|  | |||||||
| @ -41,25 +41,26 @@ public class Mute extends MineverseCommand { | |||||||
| 				if (channel.isMutable()) { | 				if (channel.isMutable()) { | ||||||
| 					long datetime = System.currentTimeMillis(); | 					long datetime = System.currentTimeMillis(); | ||||||
| 					long time = 0; | 					long time = 0; | ||||||
|  | 					int reasonStartPos = 2; | ||||||
|  | 					String reason = ""; | ||||||
| 					if(args.length > 2) { | 					if(args.length > 2) { | ||||||
| 						try { | 						String timeString = args[2]; | ||||||
| 							time = Format.parseTimeStringToMillis(args[2]); | 						if(Character.isDigit(timeString.charAt(0))) { | ||||||
|  | 							reasonStartPos = 3; | ||||||
|  | 							time = Format.parseTimeStringToMillis(timeString); | ||||||
| 							if (time <= 0) { | 							if (time <= 0) { | ||||||
| 								sender.sendMessage(LocalizedMessage.INVALID_TIME.toString().replace("{args}", args[2])); | 								sender.sendMessage(LocalizedMessage.INVALID_TIME.toString().replace("{args}", timeString)); | ||||||
| 								return; | 								return; | ||||||
| 							} | 							} | ||||||
| 						} | 						} | ||||||
| 						catch (Exception e) { | 						StringBuilder reasonBuilder = new StringBuilder(); | ||||||
| 							sender.sendMessage(LocalizedMessage.INVALID_TIME.toString().replace("{args}", args[2])); | 						for(int a = reasonStartPos; a < args.length; a ++) { | ||||||
| 							return; | 							reasonBuilder.append(args[a]); | ||||||
| 						} | 						} | ||||||
|  | 						reason = reasonBuilder.toString(); | ||||||
| 					} | 					} | ||||||
| 					if(channel.getBungee()) { | 					if(channel.getBungee()) { | ||||||
| 						if(args.length > 2) { | 						sendBungeeCordMute(sender, args[1], channel, time, reason); | ||||||
| 							sendBungeeCordMute(sender, args[1], channel, time); |  | ||||||
| 							return; |  | ||||||
| 						} |  | ||||||
| 						sendBungeeCordMute(sender, args[1], channel, 0); |  | ||||||
| 						return; | 						return; | ||||||
| 					} | 					} | ||||||
| 					MineverseChatPlayer playerToMute = MineverseChatAPI.getMineverseChatPlayer(args[1]); | 					MineverseChatPlayer playerToMute = MineverseChatAPI.getMineverseChatPlayer(args[1]); | ||||||
| @ -73,40 +74,87 @@ public class Mute extends MineverseCommand { | |||||||
| 								.replace("{channel_name}", channel.getName())); | 								.replace("{channel_name}", channel.getName())); | ||||||
| 						return; | 						return; | ||||||
| 					} | 					} | ||||||
| 					if(args.length > 2) { | 					 | ||||||
| 						playerToMute.addMute(channel.getName(), datetime + time); | 					if(time > 0) { | ||||||
| 						String timeString = Format.parseTimeStringFromMillis(time); | 						if(reason.isEmpty()) { | ||||||
| 						sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString() | 							playerToMute.addMute(channel.getName(), datetime + time); | ||||||
| 								.replace("{player}", playerToMute.getName()) | 							String timeString = Format.parseTimeStringFromMillis(time); | ||||||
| 								.replace("{channel_color}", channel.getColor()) | 							sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString() | ||||||
| 								.replace("{channel_name}", channel.getName()) | 									.replace("{player}", playerToMute.getName()) | ||||||
| 								.replace("{time}", timeString)); | 									.replace("{channel_color}", channel.getColor()) | ||||||
| 						if (playerToMute.isOnline()) { | 									.replace("{channel_name}", channel.getName()) | ||||||
| 							playerToMute.getPlayer() | 									.replace("{time}", timeString)); | ||||||
| 									.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME.toString() | 							if (playerToMute.isOnline()) { | ||||||
| 											.replace("{channel_color}", channel.getColor()) | 								playerToMute.getPlayer() | ||||||
| 											.replace("{channel_name}", channel.getName()) | 										.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME.toString() | ||||||
| 											.replace("{time}", timeString)); | 												.replace("{channel_color}", channel.getColor()) | ||||||
|  | 												.replace("{channel_name}", channel.getName()) | ||||||
|  | 												.replace("{time}", timeString)); | ||||||
|  | 							} | ||||||
|  | 							else { | ||||||
|  | 								playerToMute.setModified(true); | ||||||
|  | 							} | ||||||
|  | 							return; | ||||||
| 						} | 						} | ||||||
| 						else { | 						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 { | 					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() | 				sender.sendMessage(LocalizedMessage.CHANNEL_CANNOT_MUTE.toString() | ||||||
| 						.replace("{channel_color}", channel.getColor()) | 						.replace("{channel_color}", channel.getColor()) | ||||||
| @ -149,7 +197,7 @@ public class Mute extends MineverseCommand { | |||||||
| 		return Collections.emptyList(); | 		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(); | 		ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); | ||||||
| 		DataOutputStream out = new DataOutputStream(byteOutStream); | 		DataOutputStream out = new DataOutputStream(byteOutStream); | ||||||
| 		try { | 		try { | ||||||
| @ -164,6 +212,7 @@ public class Mute extends MineverseCommand { | |||||||
| 			out.writeUTF(playerToMute); | 			out.writeUTF(playerToMute); | ||||||
| 			out.writeUTF(channel.getName()); | 			out.writeUTF(channel.getName()); | ||||||
| 			out.writeLong(time); | 			out.writeLong(time); | ||||||
|  | 			out.writeUTF(reason); | ||||||
| 			MineverseChat.sendPluginMessage(byteOutStream); | 			MineverseChat.sendPluginMessage(byteOutStream); | ||||||
| 			out.close(); | 			out.close(); | ||||||
| 		} | 		} | ||||||
|  | |||||||
							
								
								
									
										45
									
								
								src/mineverse/Aust1n46/chat/command/mute/MuteContainer.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								src/mineverse/Aust1n46/chat/command/mute/MuteContainer.java
									
									
									
									
									
										Normal 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; | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -14,6 +14,7 @@ import java.util.UUID; | |||||||
| import mineverse.Aust1n46.chat.api.MineverseChatAPI; | import mineverse.Aust1n46.chat.api.MineverseChatAPI; | ||||||
| import mineverse.Aust1n46.chat.api.SynchronizedMineverseChatPlayer; | import mineverse.Aust1n46.chat.api.SynchronizedMineverseChatPlayer; | ||||||
| import mineverse.Aust1n46.chat.bungee.MineverseChatBungee; | import mineverse.Aust1n46.chat.bungee.MineverseChatBungee; | ||||||
|  | import mineverse.Aust1n46.chat.command.mute.MuteContainer; | ||||||
| import mineverse.Aust1n46.chat.utilities.Format; | import mineverse.Aust1n46.chat.utilities.Format; | ||||||
| import mineverse.Aust1n46.chat.utilities.UUIDFetcher; | import mineverse.Aust1n46.chat.utilities.UUIDFetcher; | ||||||
| import net.md_5.bungee.api.ProxyServer; | import net.md_5.bungee.api.ProxyServer; | ||||||
| @ -52,11 +53,12 @@ public class BungeePlayerData { | |||||||
| 					String channel = l.nextToken(); | 					String channel = l.nextToken(); | ||||||
| 					listening.add(channel); | 					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"), ","); | 				StringTokenizer m = new StringTokenizer(playerData.getString(uuidString + ".mutes"), ","); | ||||||
| 				while(m.hasMoreTokens()) { | 				while(m.hasMoreTokens()) { | ||||||
| 					String[] parts = m.nextToken().split(":"); | 					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>(); | 				HashSet<UUID> ignores = new HashSet<UUID>(); | ||||||
| 				StringTokenizer n = new StringTokenizer(playerData.getString(uuidString + ".ignores"), ","); | 				StringTokenizer n = new StringTokenizer(playerData.getString(uuidString + ".ignores"), ","); | ||||||
| @ -115,11 +117,11 @@ public class BungeePlayerData { | |||||||
| 				String channel = l.nextToken(); | 				String channel = l.nextToken(); | ||||||
| 				listening.add(channel); | 				listening.add(channel); | ||||||
| 			} | 			} | ||||||
| 			HashMap<String, Long> mutes = new HashMap<String, Long>(); | 			HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>(); | ||||||
| 			StringTokenizer m = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("mutes"), ","); | 			Configuration muteSection = bungeePlayerDataFileConfiguration.getSection("mutes"); | ||||||
| 			while(m.hasMoreTokens()) { | 			for(String channelName : muteSection.getKeys()) { | ||||||
| 				String[] parts = m.nextToken().split(":"); | 				Configuration channelSection = muteSection.getSection(channelName); | ||||||
| 				mutes.put(parts[0], Long.parseLong(parts[1])); | 				mutes.put(channelName, new MuteContainer(channelName, channelSection.getLong("time"), channelSection.getString("reason"))); | ||||||
| 			} | 			} | ||||||
| 			HashSet<UUID> ignores = new HashSet<UUID>(); | 			HashSet<UUID> ignores = new HashSet<UUID>(); | ||||||
| 			StringTokenizer n = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("ignores"), ","); | 			StringTokenizer n = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("ignores"), ","); | ||||||
| @ -157,20 +159,20 @@ public class BungeePlayerData { | |||||||
| 				String listen = ""; | 				String listen = ""; | ||||||
| 				for(String s : p.getListening()) | 				for(String s : p.getListening()) | ||||||
| 					listen += s + ","; | 					listen += s + ","; | ||||||
| 				String mute = ""; |  | ||||||
| 				for(String s : p.getMutes().keySet()) |  | ||||||
| 					mute += s + ":0,"; |  | ||||||
| 				String ignore = ""; | 				String ignore = ""; | ||||||
| 				for(UUID s : p.getIgnores())  | 				for(UUID s : p.getIgnores())  | ||||||
| 					ignore += s.toString() + ","; | 					ignore += s.toString() + ","; | ||||||
| 				if(listen.length() > 0) | 				if(listen.length() > 0) | ||||||
| 					listen = listen.substring(0, listen.length() - 1); | 					listen = listen.substring(0, listen.length() - 1); | ||||||
| 				if(mute.length() > 0) |  | ||||||
| 					mute = mute.substring(0, mute.length() - 1); |  | ||||||
| 				if(ignore.length() > 0) | 				if(ignore.length() > 0) | ||||||
| 					ignore = ignore.substring(0, ignore.length() - 1); | 					ignore = ignore.substring(0, ignore.length() - 1); | ||||||
| 				bungeePlayerDataFileConfiguration.set("channels", listen); | 				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("ignores", ignore); | ||||||
| 				bungeePlayerDataFileConfiguration.set("spy", p.isSpy()); | 				bungeePlayerDataFileConfiguration.set("spy", p.isSpy()); | ||||||
| 				bungeePlayerDataFileConfiguration.set("messagetoggle", p.getMessageToggle()); | 				bungeePlayerDataFileConfiguration.set("messagetoggle", p.getMessageToggle()); | ||||||
| @ -182,4 +184,16 @@ public class BungeePlayerData { | |||||||
| 			e.printStackTrace(); | 			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); | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -22,6 +22,7 @@ import mineverse.Aust1n46.chat.MineverseChat; | |||||||
| 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.channel.ChatChannel; | import mineverse.Aust1n46.chat.channel.ChatChannel; | ||||||
|  | import mineverse.Aust1n46.chat.command.mute.MuteContainer; | ||||||
| import mineverse.Aust1n46.chat.utilities.Format; | import mineverse.Aust1n46.chat.utilities.Format; | ||||||
| import mineverse.Aust1n46.chat.utilities.UUIDFetcher; | import mineverse.Aust1n46.chat.utilities.UUIDFetcher; | ||||||
| 
 | 
 | ||||||
| @ -65,7 +66,7 @@ public class PlayerData { | |||||||
| 						listening.add(channel); | 						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"), ","); | 				StringTokenizer m = new StringTokenizer(playerData.getConfigurationSection("players." + uuidString).getString("mutes"), ","); | ||||||
| 				while(m.hasMoreTokens()) { | 				while(m.hasMoreTokens()) { | ||||||
| 					String[] parts = m.nextToken().split(":"); | 					String[] parts = m.nextToken().split(":"); | ||||||
| @ -74,7 +75,8 @@ public class PlayerData { | |||||||
| 							Bukkit.getConsoleSender().sendMessage("[VentureChat] Null Mute Time: " + parts[0] + " " + name); | 							Bukkit.getConsoleSender().sendMessage("[VentureChat] Null Mute Time: " + parts[0] + " " + name); | ||||||
| 							continue; | 							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>(); | 				Set<String> blockedCommands = new HashSet<String>(); | ||||||
| @ -161,22 +163,11 @@ public class PlayerData { | |||||||
| 					listening.add(channel); | 					listening.add(channel); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			HashMap<String, Long> mutes = new HashMap<String, Long>(); | 			HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>(); | ||||||
| //			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])); |  | ||||||
| //				} |  | ||||||
| //			} |  | ||||||
| 			ConfigurationSection muteSection = playerDataFileYamlConfiguration.getConfigurationSection("mutes"); | 			ConfigurationSection muteSection = playerDataFileYamlConfiguration.getConfigurationSection("mutes"); | ||||||
| 			for(String channelName : muteSection.getKeys(false)) { | 			for(String channelName : muteSection.getKeys(false)) { | ||||||
| 				ConfigurationSection channelSection = muteSection.getConfigurationSection(channelName); | 				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>(); | 			Set<String> blockedCommands = new HashSet<String>(); | ||||||
| @ -242,9 +233,10 @@ public class PlayerData { | |||||||
| 			playerDataFileYamlConfiguration.set("listen", listening); | 			playerDataFileYamlConfiguration.set("listen", listening); | ||||||
| 			 | 			 | ||||||
| 			ConfigurationSection muteSection = playerDataFileYamlConfiguration.createSection("mutes"); | 			ConfigurationSection muteSection = playerDataFileYamlConfiguration.createSection("mutes"); | ||||||
| 			for(String channelName : mcp.getMutes().keySet()) { | 			for(MuteContainer mute : mcp.getMutes()) { | ||||||
| 				ConfigurationSection channelSection = muteSection.createSection(channelName); | 				ConfigurationSection channelSection = muteSection.createSection(mute.getChannel()); | ||||||
| 				channelSection.set("time", mcp.getMutes().get(channelName)); | 				channelSection.set("time", mute.getDuration()); | ||||||
|  | 				channelSection.set("reason", mute.getReason()); | ||||||
| 			} | 			} | ||||||
| 			 | 			 | ||||||
| 			playerDataFileYamlConfiguration.set("blockedcommands", blockedCommands); | 			playerDataFileYamlConfiguration.set("blockedcommands", blockedCommands); | ||||||
|  | |||||||
| @ -29,6 +29,7 @@ import mineverse.Aust1n46.chat.api.MineverseChatPlayer; | |||||||
| import mineverse.Aust1n46.chat.api.events.ChannelJoinEvent; | import mineverse.Aust1n46.chat.api.events.ChannelJoinEvent; | ||||||
| import mineverse.Aust1n46.chat.api.events.VentureChatEvent; | import mineverse.Aust1n46.chat.api.events.VentureChatEvent; | ||||||
| import mineverse.Aust1n46.chat.channel.ChatChannel; | import mineverse.Aust1n46.chat.channel.ChatChannel; | ||||||
|  | import mineverse.Aust1n46.chat.command.mute.MuteContainer; | ||||||
| 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; | import mineverse.Aust1n46.chat.versions.VersionHandler; | ||||||
| @ -210,25 +211,45 @@ public class ChatListener implements Listener { | |||||||
| 		Boolean filterthis = true; | 		Boolean filterthis = true; | ||||||
| 		mcp.addListening(eventChannel.getName()); | 		mcp.addListening(eventChannel.getName()); | ||||||
| 		if (mcp.isMuted(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 dateTimeMillis = System.currentTimeMillis(); | ||||||
| 				long muteTimeMillis = mcp.getMutes().get(eventChannel.getName()).longValue(); | 				long muteTimeMillis = muteContainer.getDuration(); | ||||||
| 				long remainingMuteTime = muteTimeMillis - dateTimeMillis; | 				long remainingMuteTime = muteTimeMillis - dateTimeMillis; | ||||||
| 				if (remainingMuteTime < 1000) { | 				if (remainingMuteTime < 1000) { | ||||||
| 					remainingMuteTime = 1000; | 					remainingMuteTime = 1000; | ||||||
| 				} | 				} | ||||||
| 				String timeString = Format.parseTimeStringFromMillis(remainingMuteTime); | 				String timeString = Format.parseTimeStringFromMillis(remainingMuteTime); | ||||||
| 				mcp.getPlayer() | 				if(muteContainer.hasReason()) { | ||||||
| 						.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED.toString() | 					mcp.getPlayer() | ||||||
| 								.replace("{channel_color}", eventChannel.getColor()) | 					.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED_REASON.toString() | ||||||
| 								.replace("{channel_name}", eventChannel.getName()) | 							.replace("{channel_color}", eventChannel.getColor()) | ||||||
| 								.replace("{time}", timeString)); | 							.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 { | 			else { | ||||||
| 				mcp.getPlayer() | 				if(muteContainer.hasReason()) { | ||||||
| 						.sendMessage(LocalizedMessage.CHANNEL_MUTED.toString() | 					mcp.getPlayer() | ||||||
| 								.replace("{channel_color}", eventChannel.getColor()) | 					.sendMessage(LocalizedMessage.CHANNEL_MUTED_REASON.toString() | ||||||
| 								.replace("{channel_name}", eventChannel.getName())); | 							.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); | 			mcp.setQuickChat(false); | ||||||
| 			return; | 			return; | ||||||
|  | |||||||
| @ -1,8 +1,5 @@ | |||||||
| package mineverse.Aust1n46.chat.listeners; | package mineverse.Aust1n46.chat.listeners; | ||||||
| 
 | 
 | ||||||
| import java.util.HashMap; |  | ||||||
| import java.util.HashSet; |  | ||||||
| import java.util.Set; |  | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
| 
 | 
 | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| @ -64,14 +61,7 @@ public class LoginListener implements Listener { | |||||||
| 			Player player = event.getPlayer(); | 			Player player = event.getPlayer(); | ||||||
| 			String name = player.getName(); | 			String name = player.getName(); | ||||||
| 			UUID uuid = player.getUniqueId(); | 			UUID uuid = player.getUniqueId(); | ||||||
| 			ChatChannel current = ChatChannel.getDefaultChannel(); | 			mcp = new MineverseChatPlayer(uuid, name); | ||||||
| 			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); |  | ||||||
| 			MineverseChatAPI.addMineverseChatPlayerToMap(mcp); | 			MineverseChatAPI.addMineverseChatPlayerToMap(mcp); | ||||||
| 			MineverseChatAPI.addNameToMap(mcp); | 			MineverseChatAPI.addNameToMap(mcp); | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -24,7 +24,9 @@ public enum LocalizedMessage { | |||||||
|     CHANNEL_NO_SPEAK_PERMISSIONS("ChannelNoSpeakPermissions"), |     CHANNEL_NO_SPEAK_PERMISSIONS("ChannelNoSpeakPermissions"), | ||||||
|     CHANNEL_PLAYER_LIST_HEADER("ChannelPlayerListHeader"), |     CHANNEL_PLAYER_LIST_HEADER("ChannelPlayerListHeader"), | ||||||
|     CHANNEL_MUTED("ChannelMuted"), |     CHANNEL_MUTED("ChannelMuted"), | ||||||
|  |     CHANNEL_MUTED_REASON("ChannelMutedReason"), | ||||||
|     CHANNEL_MUTED_TIMED("ChannelMutedTimed"), |     CHANNEL_MUTED_TIMED("ChannelMutedTimed"), | ||||||
|  |     CHANNEL_MUTED_TIMED_REASON("ChannelMutedTimedReason"), | ||||||
|     COMMAND_INVALID_ARGUMENTS("CommandInvalidArguments"), |     COMMAND_INVALID_ARGUMENTS("CommandInvalidArguments"), | ||||||
|     COMMAND_INVALID_ARGUMENTS_IGNORE("CommandInvalidArgumentsIgnore"), |     COMMAND_INVALID_ARGUMENTS_IGNORE("CommandInvalidArgumentsIgnore"), | ||||||
|     COMMAND_MUST_BE_RUN_BY_PLAYER("CommandMustBeRunByPlayer"), |     COMMAND_MUST_BE_RUN_BY_PLAYER("CommandMustBeRunByPlayer"), | ||||||
| @ -62,10 +64,14 @@ public enum LocalizedMessage { | |||||||
| 	MUTE_PLAYER_ALL_SENDER("MutePlayerAllSender"), | 	MUTE_PLAYER_ALL_SENDER("MutePlayerAllSender"), | ||||||
| 	MUTE_PLAYER_PLAYER("MutePlayerPlayer"), | 	MUTE_PLAYER_PLAYER("MutePlayerPlayer"), | ||||||
| 	MUTE_PLAYER_PLAYER_TIME("MutePlayerPlayerTime"), | 	MUTE_PLAYER_PLAYER_TIME("MutePlayerPlayerTime"), | ||||||
|  | 	MUTE_PLAYER_PLAYER_TIME_REASON("MutePlayerPlayerTimeReason"), | ||||||
|  | 	MUTE_PLAYER_PLAYER_REASON("MutePlayerPlayerReason"), | ||||||
| 	MUTE_PLAYER_SPAM("MutePlayerSpam"), | 	MUTE_PLAYER_SPAM("MutePlayerSpam"), | ||||||
| 	MUTE_PLAYER_SPAM_TIME("MutePlayerSpamTime"), | 	MUTE_PLAYER_SPAM_TIME("MutePlayerSpamTime"), | ||||||
| 	MUTE_PLAYER_SENDER("MutePlayerSender"), | 	MUTE_PLAYER_SENDER("MutePlayerSender"), | ||||||
|  | 	MUTE_PLAYER_SENDER_REASON("MutePlayerSenderReason"), | ||||||
| 	MUTE_PLAYER_SENDER_TIME("MutePlayerSenderTime"), | 	MUTE_PLAYER_SENDER_TIME("MutePlayerSenderTime"), | ||||||
|  | 	MUTE_PLAYER_SENDER_TIME_REASON("MutePlayerSenderTimeReason"), | ||||||
| 	NO_PLAYER_TO_REPLY_TO("NoPlayerToReplyTo"), | 	NO_PLAYER_TO_REPLY_TO("NoPlayerToReplyTo"), | ||||||
| 	NOTIFICATIONS_OFF("NotificationsOff"), | 	NOTIFICATIONS_OFF("NotificationsOff"), | ||||||
| 	NOTIFICATIONS_ON("NotificationsOn"), | 	NOTIFICATIONS_ON("NotificationsOn"), | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Aust1n46
						Aust1n46