mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-22 18:09:06 +00:00
Simply getter/setters in VentureChatPlayer model
This commit is contained in:
parent
62d8c28c5b
commit
254c261528
@ -118,7 +118,7 @@ public class PluginMessageController {
|
||||
}
|
||||
// out.writeUTF("Mutes");
|
||||
int muteCount = 0;
|
||||
for (MuteContainer mute : mcp.getMutes()) {
|
||||
for (MuteContainer mute : mcp.getMutes().values()) {
|
||||
ChatChannel channel = configService.getChannel(mute.getChannel());
|
||||
if (channel.getBungee()) {
|
||||
muteCount++;
|
||||
@ -126,7 +126,7 @@ public class PluginMessageController {
|
||||
}
|
||||
// System.out.println(muteCount + " mutes");
|
||||
out.write(muteCount);
|
||||
for (MuteContainer mute : mcp.getMutes()) {
|
||||
for (MuteContainer mute : mcp.getMutes().values()) {
|
||||
ChatChannel channel = configService.getChannel(mute.getChannel());
|
||||
if (channel.getBungee()) {
|
||||
out.writeUTF(channel.getName());
|
||||
@ -143,7 +143,7 @@ public class PluginMessageController {
|
||||
for (UUID c : mcp.getIgnores()) {
|
||||
out.writeUTF(c.toString());
|
||||
}
|
||||
out.writeBoolean(mcp.isSpy());
|
||||
out.writeBoolean(configService.isSpy(mcp));
|
||||
out.writeBoolean(mcp.isMessageToggle());
|
||||
}
|
||||
sendPluginMessage(outstream);
|
||||
@ -271,7 +271,7 @@ public class PluginMessageController {
|
||||
for (VentureChatPlayer mcp : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if (configService.isListening(mcp, chatchannel)) {
|
||||
String entry = "&f" + mcp.getName();
|
||||
if (mcp.isMuted(chatchannel)) {
|
||||
if (mcp.getMutes().containsKey(chatchannel)) {
|
||||
entry = "&c" + mcp.getName();
|
||||
}
|
||||
listening.add(entry);
|
||||
@ -324,7 +324,7 @@ public class PluginMessageController {
|
||||
String c = ch.toString();
|
||||
ChatChannel cha = configService.getChannel(c);
|
||||
if (cha.getBungee()) {
|
||||
p.removeListening(c);
|
||||
p.getListening().remove(c);
|
||||
}
|
||||
}
|
||||
int size = msgin.read();
|
||||
@ -333,11 +333,11 @@ public class PluginMessageController {
|
||||
if (configService.isChannel(ch)) {
|
||||
ChatChannel cha = configService.getChannel(ch);
|
||||
if (!cha.hasPermission() || p.getPlayer().hasPermission(cha.getPermission())) {
|
||||
p.addListening(ch);
|
||||
p.getListening().add(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
p.getMutes().removeIf(mute -> configService.getChannel(mute.getChannel()).getBungee());
|
||||
p.getMutes().values().removeIf(mute -> configService.getChannel(mute.getChannel()).getBungee());
|
||||
int sizeB = msgin.read();
|
||||
// System.out.println(sizeB + " mute size");
|
||||
for (int b = 0; b < sizeB; b++) {
|
||||
@ -346,7 +346,7 @@ public class PluginMessageController {
|
||||
String muteReason = msgin.readUTF();
|
||||
// System.out.println(ch);
|
||||
if (configService.isChannel(ch)) {
|
||||
p.addMute(ch, muteTime, muteReason);
|
||||
p.getMutes().put(ch, new MuteContainer(ch, muteTime, muteReason));
|
||||
}
|
||||
}
|
||||
// System.out.println(msgin.available() + " available before");
|
||||
@ -354,20 +354,20 @@ public class PluginMessageController {
|
||||
p.setMessageToggle(msgin.readBoolean());
|
||||
// System.out.println(msgin.available() + " available after");
|
||||
for (Object o : p.getIgnores().toArray()) {
|
||||
p.removeIgnore((UUID) o);
|
||||
p.getIgnores().remove((UUID) o);
|
||||
}
|
||||
int sizeC = msgin.read();
|
||||
// System.out.println(sizeC + " ignore size");
|
||||
for (int c = 0; c < sizeC; c++) {
|
||||
String i = msgin.readUTF();
|
||||
// System.out.println(i);
|
||||
p.addIgnore(UUID.fromString(i));
|
||||
p.getIgnores().add(UUID.fromString(i));
|
||||
}
|
||||
if (!p.isHasPlayed()) {
|
||||
boolean isThereABungeeChannel = false;
|
||||
for (ChatChannel ch : configService.getAutojoinList()) {
|
||||
if ((!ch.hasPermission() || p.getPlayer().hasPermission(ch.getPermission())) && !configService.isListening(p, ch.getName())) {
|
||||
p.addListening(ch.getName());
|
||||
p.getListening().add(ch.getName());
|
||||
if (ch.getBungee()) {
|
||||
isThereABungeeChannel = true;
|
||||
}
|
||||
@ -428,12 +428,12 @@ public class PluginMessageController {
|
||||
|
||||
if (p.getIgnores().contains(receiver)) {
|
||||
p.getPlayer().sendMessage(LocalizedMessage.IGNORE_PLAYER_OFF.toString().replace("{player}", receiverName));
|
||||
p.removeIgnore(receiver);
|
||||
p.getIgnores().remove(receiver);
|
||||
synchronize(p, true);
|
||||
return;
|
||||
}
|
||||
|
||||
p.addIgnore(receiver);
|
||||
p.getIgnores().add(receiver);
|
||||
p.getPlayer().sendMessage(LocalizedMessage.IGNORE_PLAYER_ON.toString().replace("{player}", receiverName));
|
||||
synchronize(p, true);
|
||||
}
|
||||
@ -469,7 +469,7 @@ public class PluginMessageController {
|
||||
return;
|
||||
}
|
||||
ChatChannel chatChannelObj = configService.getChannel(channelName);
|
||||
if (playerToMuteMCP.isMuted(chatChannelObj.getName())) {
|
||||
if (playerToMuteMCP.getMutes().containsKey(chatChannelObj.getName())) {
|
||||
out.writeUTF("Mute");
|
||||
out.writeUTF("AlreadyMuted");
|
||||
out.writeUTF(server);
|
||||
@ -482,23 +482,23 @@ public class PluginMessageController {
|
||||
if (time > 0) {
|
||||
long datetime = System.currentTimeMillis();
|
||||
if (reason.isEmpty()) {
|
||||
playerToMuteMCP.addMute(chatChannelObj.getName(), datetime + time);
|
||||
playerToMuteMCP.getMutes().put(chatChannelObj.getName(), new MuteContainer(chatChannelObj.getName(), datetime + time, ""));
|
||||
String timeString = FormatUtils.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);
|
||||
playerToMuteMCP.getMutes().put(chatChannelObj.getName(), new MuteContainer(chatChannelObj.getName(), datetime + time, reason));
|
||||
String timeString = FormatUtils.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 {
|
||||
if (reason.isEmpty()) {
|
||||
playerToMuteMCP.addMute(chatChannelObj.getName());
|
||||
playerToMuteMCP.getMutes().put(chatChannelObj.getName(), new MuteContainer(chatChannelObj.getName(), 0, ""));
|
||||
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.getMutes().put(chatChannelObj.getName(), new MuteContainer(chatChannelObj.getName(), 0, reason));
|
||||
playerToMuteMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_REASON.toString().replace("{channel_color}", chatChannelObj.getColor())
|
||||
.replace("{channel_name}", chatChannelObj.getName()).replace("{reason}", reason));
|
||||
}
|
||||
@ -632,7 +632,7 @@ public class PluginMessageController {
|
||||
return;
|
||||
}
|
||||
ChatChannel chatChannelObj = configService.getChannel(channelName);
|
||||
if (!playerToUnmuteMCP.isMuted(chatChannelObj.getName())) {
|
||||
if (!playerToUnmuteMCP.getMutes().containsKey(chatChannelObj.getName())) {
|
||||
out.writeUTF("Unmute");
|
||||
out.writeUTF("NotMuted");
|
||||
out.writeUTF(server);
|
||||
@ -642,7 +642,7 @@ public class PluginMessageController {
|
||||
sendPluginMessage(stream);
|
||||
return;
|
||||
}
|
||||
playerToUnmuteMCP.removeMute(chatChannelObj.getName());
|
||||
playerToUnmuteMCP.getMutes().remove(chatChannelObj.getName());
|
||||
playerToUnmuteMCP.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString().replace("{player}", player.getName())
|
||||
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()));
|
||||
synchronize(playerToUnmuteMCP, true);
|
||||
@ -750,7 +750,9 @@ public class PluginMessageController {
|
||||
formatService.playMessageSound(p);
|
||||
}
|
||||
if (playerApiService.getMineverseChatPlayer(sender) == null) {
|
||||
VentureChatPlayer senderMCP = new VentureChatPlayer(sender, sName, configService.getDefaultChannel());
|
||||
// VentureChatPlayer senderMCP = new VentureChatPlayer(sender, sName, configService.getDefaultChannel());
|
||||
VentureChatPlayer senderMCP = VentureChatPlayer.builder().uuid(sender).name(sName).currentChannel(configService.getDefaultChannel()).build();
|
||||
senderMCP.getListening().add(configService.getDefaultChannel().getName());
|
||||
playerApiService.addMineverseChatPlayerToMap(senderMCP);
|
||||
playerApiService.addNameToMap(senderMCP);
|
||||
}
|
||||
@ -793,7 +795,9 @@ public class PluginMessageController {
|
||||
VentureChatPlayer senderMCP = playerApiService.getOnlineMineverseChatPlayer(senderUUID);
|
||||
String echo = msgin.readUTF();
|
||||
if (playerApiService.getMineverseChatPlayer(receiverUUID) == null) {
|
||||
VentureChatPlayer receiverMCP = new VentureChatPlayer(receiverUUID, receiverName, configService.getDefaultChannel());
|
||||
// VentureChatPlayer receiverMCP = new VentureChatPlayer(receiverUUID, receiverName, configService.getDefaultChannel());
|
||||
VentureChatPlayer receiverMCP = VentureChatPlayer.builder().uuid(receiverUUID).name(receiverName).currentChannel(configService.getDefaultChannel()).build();
|
||||
receiverMCP.getListening().add(configService.getDefaultChannel().getName());
|
||||
playerApiService.addMineverseChatPlayerToMap(receiverMCP);
|
||||
playerApiService.addNameToMap(receiverMCP);
|
||||
}
|
||||
@ -806,7 +810,7 @@ public class PluginMessageController {
|
||||
String spy = msgin.readUTF();
|
||||
if (!spy.startsWith("VentureChat:NoSpy")) {
|
||||
for (VentureChatPlayer pl : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if (pl.isSpy() && !pl.getName().equals(senderName) && !pl.getName().equals(receiverName)) {
|
||||
if (configService.isSpy(pl) && !pl.getName().equals(senderName) && !pl.getName().equals(receiverName)) {
|
||||
pl.getPlayer().sendMessage(spy);
|
||||
}
|
||||
}
|
||||
|
@ -114,8 +114,25 @@ public class SpigotFlatFileController {
|
||||
boolean rangedSpy = playerData.getConfigurationSection("players." + uuidString).getBoolean("rangedspy", false);
|
||||
boolean messageToggle = playerData.getConfigurationSection("players." + uuidString).getBoolean("messagetoggle", true);
|
||||
boolean bungeeToggle = playerData.getConfigurationSection("players." + uuidString).getBoolean("bungeetoggle", true);
|
||||
VentureChatPlayer mcp = new VentureChatPlayer(uuid, name, currentChannel, ignores, listening, mutes, blockedCommands, host, party, filter, notifications,
|
||||
jsonFormat, spy, commandSpy, rangedSpy, messageToggle, bungeeToggle);
|
||||
final VentureChatPlayer mcp = VentureChatPlayer.builder()
|
||||
.uuid(uuid)
|
||||
.name(name)
|
||||
.currentChannel(currentChannel)
|
||||
.ignores(ignores)
|
||||
.listening(listening)
|
||||
.mutes(mutes)
|
||||
.blockedCommands(blockedCommands)
|
||||
.host(host)
|
||||
.party(party)
|
||||
.filter(filter)
|
||||
.notifications(notifications)
|
||||
.jsonFormat(jsonFormat)
|
||||
.spy(spy)
|
||||
.commandSpy(commandSpy)
|
||||
.rangedSpy(rangedSpy)
|
||||
.messageToggle(messageToggle)
|
||||
.bungeeToggle(bungeeToggle)
|
||||
.build();
|
||||
mcp.setModified(true);
|
||||
ventureChatApi.addMineverseChatPlayerToMap(mcp);
|
||||
ventureChatApi.addNameToMap(mcp);
|
||||
@ -202,8 +219,25 @@ public class SpigotFlatFileController {
|
||||
boolean rangedSpy = playerDataFileYamlConfiguration.getBoolean("rangedspy", false);
|
||||
boolean messageToggle = playerDataFileYamlConfiguration.getBoolean("messagetoggle", true);
|
||||
boolean bungeeToggle = playerDataFileYamlConfiguration.getBoolean("bungeetoggle", true);
|
||||
mcp = new VentureChatPlayer(uuid, name, currentChannel, ignores, listening, mutes, blockedCommands, host, party, filter, notifications, jsonFormat, spy, commandSpy,
|
||||
rangedSpy, messageToggle, bungeeToggle);
|
||||
mcp = VentureChatPlayer.builder()
|
||||
.uuid(uuid)
|
||||
.name(name)
|
||||
.currentChannel(currentChannel)
|
||||
.ignores(ignores)
|
||||
.listening(listening)
|
||||
.mutes(mutes)
|
||||
.blockedCommands(blockedCommands)
|
||||
.host(host)
|
||||
.party(party)
|
||||
.filter(filter)
|
||||
.notifications(notifications)
|
||||
.jsonFormat(jsonFormat)
|
||||
.spy(spy)
|
||||
.commandSpy(commandSpy)
|
||||
.rangedSpy(rangedSpy)
|
||||
.messageToggle(messageToggle)
|
||||
.bungeeToggle(bungeeToggle)
|
||||
.build();
|
||||
} catch (Exception e) {
|
||||
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Error Loading Data File: " + playerDataFile.getName()));
|
||||
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - File will be skipped and deleted."));
|
||||
@ -249,7 +283,7 @@ public class SpigotFlatFileController {
|
||||
playerDataFileYamlConfiguration.set("listen", listening);
|
||||
|
||||
ConfigurationSection muteSection = playerDataFileYamlConfiguration.createSection("mutes");
|
||||
for (MuteContainer mute : mcp.getMutes()) {
|
||||
for (MuteContainer mute : mcp.getMutes().values()) {
|
||||
ConfigurationSection channelSection = muteSection.createSection(mute.getChannel());
|
||||
channelSection.set("time", mute.getDuration());
|
||||
channelSection.set("reason", mute.getReason());
|
||||
@ -257,12 +291,12 @@ public class SpigotFlatFileController {
|
||||
|
||||
playerDataFileYamlConfiguration.set("blockedcommands", blockedCommands);
|
||||
playerDataFileYamlConfiguration.set("host", mcp.isHost());
|
||||
playerDataFileYamlConfiguration.set("party", mcp.hasParty() ? mcp.getParty().toString() : "");
|
||||
playerDataFileYamlConfiguration.set("party", mcp.getParty() != null ? mcp.getParty().toString() : "");
|
||||
playerDataFileYamlConfiguration.set("filter", mcp.isFilter());
|
||||
playerDataFileYamlConfiguration.set("notifications", mcp.isNotifications());
|
||||
playerDataFileYamlConfiguration.set("spy", mcp.isSpy());
|
||||
playerDataFileYamlConfiguration.set("commandspy", mcp.hasCommandSpy());
|
||||
playerDataFileYamlConfiguration.set("rangedspy", mcp.getRangedSpy());
|
||||
playerDataFileYamlConfiguration.set("spy", configService.isSpy(mcp));
|
||||
playerDataFileYamlConfiguration.set("commandspy", configService.isCommandSpy(mcp));
|
||||
playerDataFileYamlConfiguration.set("rangedspy", configService.isRangedSpy(mcp));
|
||||
playerDataFileYamlConfiguration.set("messagetoggle", mcp.isMessageToggle());
|
||||
playerDataFileYamlConfiguration.set("bungeetoggle", mcp.isBungeeToggle());
|
||||
Calendar currentDate = Calendar.getInstance();
|
||||
|
@ -53,14 +53,14 @@ public class Channel extends PlayerCommand {
|
||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(event.getPlayer());
|
||||
if (channel.hasPermission()) {
|
||||
if (!mcp.getPlayer().hasPermission(channel.getPermission())) {
|
||||
mcp.removeListening(channel.getName());
|
||||
mcp.getListening().remove(channel.getName());
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_PERMISSION.toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (mcp.hasConversation()) {
|
||||
if (mcp.getConversation() != null) {
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if (p.isSpy()) {
|
||||
if (configService.isSpy(p)) {
|
||||
p.getPlayer().sendMessage(LocalizedMessage.EXIT_PRIVATE_CONVERSATION_SPY.toString().replace("{player_sender}", mcp.getName()).replace("{player_receiver}",
|
||||
playerApiService.getMineverseChatPlayer(mcp.getConversation()).getName()));
|
||||
}
|
||||
@ -69,7 +69,7 @@ public class Channel extends PlayerCommand {
|
||||
LocalizedMessage.EXIT_PRIVATE_CONVERSATION.toString().replace("{player_receiver}", playerApiService.getMineverseChatPlayer(mcp.getConversation()).getName()));
|
||||
mcp.setConversation(null);
|
||||
}
|
||||
mcp.addListening(channel.getName());
|
||||
mcp.getListening().add(channel.getName());
|
||||
mcp.setCurrentChannel(channel);
|
||||
mcp.getPlayer().sendMessage(event.getMessage());
|
||||
if (channel.getBungee()) {
|
||||
|
@ -32,9 +32,9 @@ public class ChannelAlias extends PlayerCommand {
|
||||
if (args.length == 0) {
|
||||
mcp.getPlayer()
|
||||
.sendMessage(LocalizedMessage.SET_CHANNEL.toString().replace("{channel_color}", channel.getColor() + "").replace("{channel_name}", channel.getName()));
|
||||
if (mcp.hasConversation()) {
|
||||
if (mcp.getConversation() != null) {
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if (p.isSpy()) {
|
||||
if (configService.isSpy(p)) {
|
||||
p.getPlayer().sendMessage(LocalizedMessage.EXIT_PRIVATE_CONVERSATION_SPY.toString().replace("{player_sender}", mcp.getName())
|
||||
.replace("{player_receiver}", playerApiService.getMineverseChatPlayer(mcp.getConversation()).getName()));
|
||||
}
|
||||
@ -43,7 +43,7 @@ public class ChannelAlias extends PlayerCommand {
|
||||
playerApiService.getMineverseChatPlayer(mcp.getConversation()).getName()));
|
||||
mcp.setConversation(null);
|
||||
}
|
||||
mcp.addListening(channel.getName());
|
||||
mcp.getListening().add(channel.getName());
|
||||
mcp.setCurrentChannel(channel);
|
||||
if (channel.getBungee()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
@ -52,7 +52,7 @@ public class ChannelAlias extends PlayerCommand {
|
||||
} else {
|
||||
mcp.setQuickChat(true);
|
||||
mcp.setQuickChannel(channel);
|
||||
mcp.addListening(channel.getName());
|
||||
mcp.getListening().add(channel.getName());
|
||||
if (channel.getBungee()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class Chatinfo extends UniversalCommand {
|
||||
ChatChannel channel = configService.getChannel(c);
|
||||
listen += channel.getColor() + channel.getName() + " ";
|
||||
}
|
||||
for (MuteContainer muteContainer : mcp.getMutes()) {
|
||||
for (MuteContainer muteContainer : mcp.getMutes().values()) {
|
||||
ChatChannel channel = configService.getChannel(muteContainer.getChannel());
|
||||
mute += channel.getColor() + channel.getName() + " ";
|
||||
}
|
||||
@ -60,22 +60,27 @@ public class Chatinfo extends UniversalCommand {
|
||||
} else {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Blocked Commands: " + ChatColor.RED + "N/A");
|
||||
}
|
||||
if (mcp.hasConversation()) {
|
||||
if (mcp.getConversation() != null) {
|
||||
mcp.getPlayer().sendMessage(
|
||||
ChatColor.GOLD + "Private conversation: " + ChatColor.GREEN + playerApiService.getMineverseChatPlayer(mcp.getConversation()).getName());
|
||||
} else {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Private conversation: " + ChatColor.RED + "N/A");
|
||||
}
|
||||
if (mcp.isSpy()) {
|
||||
if (configService.isSpy(mcp)) {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Spy: " + ChatColor.GREEN + "true");
|
||||
} else {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Spy: " + ChatColor.RED + "false");
|
||||
}
|
||||
if (mcp.hasCommandSpy()) {
|
||||
if (configService.isCommandSpy(mcp)) {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Command spy: " + ChatColor.GREEN + "true");
|
||||
} else {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Command spy: " + ChatColor.RED + "false");
|
||||
}
|
||||
if (configService.isRangedSpy(mcp)) {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Ranged spy: " + ChatColor.GREEN + "true");
|
||||
} else {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Ranged spy: " + ChatColor.RED + "false");
|
||||
}
|
||||
if (mcp.isFilter()) {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Filter: " + ChatColor.GREEN + "true");
|
||||
} else {
|
||||
@ -98,7 +103,7 @@ public class Chatinfo extends UniversalCommand {
|
||||
ChatChannel channel = configService.getChannel(c);
|
||||
listen += channel.getColor() + channel.getName() + " ";
|
||||
}
|
||||
for (MuteContainer muteContainer : p.getMutes()) {
|
||||
for (MuteContainer muteContainer : p.getMutes().values()) {
|
||||
ChatChannel channel = configService.getChannel(muteContainer.getChannel());
|
||||
mute += channel.getColor() + channel.getName() + " ";
|
||||
}
|
||||
@ -116,21 +121,26 @@ public class Chatinfo extends UniversalCommand {
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Blocked Commands: " + ChatColor.RED + "N/A");
|
||||
}
|
||||
if (p.hasConversation()) {
|
||||
if (p.getConversation() != null) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Private conversation: " + ChatColor.GREEN + playerApiService.getMineverseChatPlayer(p.getConversation()).getName());
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Private conversation: " + ChatColor.RED + "N/A");
|
||||
}
|
||||
if (p.isSpy()) {
|
||||
if (configService.isSpy(p)) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Spy: " + ChatColor.GREEN + "true");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Spy: " + ChatColor.RED + "false");
|
||||
}
|
||||
if (p.hasCommandSpy()) {
|
||||
if (configService.isCommandSpy(p)) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Command spy: " + ChatColor.GREEN + "true");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Command spy: " + ChatColor.RED + "false");
|
||||
}
|
||||
if (configService.isRangedSpy(p)) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Ranged spy: " + ChatColor.GREEN + "true");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Ranged spy: " + ChatColor.RED + "false");
|
||||
}
|
||||
if (p.isFilter()) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Filter: " + ChatColor.GREEN + "true");
|
||||
} else {
|
||||
|
@ -53,7 +53,8 @@ public class Chatreload extends UniversalCommand {
|
||||
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - There could be an issue with your player data saving."));
|
||||
String name = p.getName();
|
||||
UUID uuid = p.getUniqueId();
|
||||
mcp = new VentureChatPlayer(uuid, name, configService.getDefaultChannel());
|
||||
mcp = VentureChatPlayer.builder().uuid(uuid).name(name).currentChannel(configService.getDefaultChannel()).build();
|
||||
mcp.getListening().add(configService.getDefaultChannel().getName());
|
||||
}
|
||||
mcp.setOnline(true);
|
||||
mcp.setPlayer(plugin.getServer().getPlayer(mcp.getUuid()));
|
||||
|
@ -50,7 +50,7 @@ public class Chwho extends UniversalCommand {
|
||||
if (channel.hasPermission()) {
|
||||
if (!sender.hasPermission(channel.getPermission())) {
|
||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(((Player) sender));
|
||||
mcp.removeListening(channel.getName());
|
||||
mcp.getListening().remove(channel.getName());
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_PERMISSION_VIEW.toString());
|
||||
return;
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class Chwho extends UniversalCommand {
|
||||
playerlist += "\n";
|
||||
linecount = linecount + LINE_LENGTH;
|
||||
}
|
||||
if (!p.isMuted(channel.getName())) {
|
||||
if (!p.getMutes().containsKey(channel.getName())) {
|
||||
playerlist += ChatColor.WHITE + p.getName();
|
||||
} else {
|
||||
playerlist += ChatColor.RED + p.getName();
|
||||
@ -119,7 +119,7 @@ public class Chwho extends UniversalCommand {
|
||||
playerlist += "\n";
|
||||
linecount = linecount + LINE_LENGTH;
|
||||
}
|
||||
if (!p.isMuted(channel.getName())) {
|
||||
if (!p.getMutes().containsKey(channel.getName())) {
|
||||
playerlist += ChatColor.WHITE + p.getName();
|
||||
} else {
|
||||
playerlist += ChatColor.RED + p.getName();
|
||||
@ -146,7 +146,7 @@ public class Chwho extends UniversalCommand {
|
||||
playerlist += "\n";
|
||||
linecount = linecount + LINE_LENGTH;
|
||||
}
|
||||
if (!p.isMuted(channel.getName())) {
|
||||
if (!p.getMutes().containsKey(channel.getName())) {
|
||||
playerlist += ChatColor.WHITE + p.getName();
|
||||
} else {
|
||||
playerlist += ChatColor.RED + p.getName();
|
||||
@ -167,7 +167,7 @@ public class Chwho extends UniversalCommand {
|
||||
playerlist += "\n";
|
||||
linecount = linecount + LINE_LENGTH;
|
||||
}
|
||||
if (!p.isMuted(channel.getName())) {
|
||||
if (!p.getMutes().containsKey(channel.getName())) {
|
||||
playerlist += ChatColor.WHITE + p.getName();
|
||||
} else {
|
||||
playerlist += ChatColor.RED + p.getName();
|
||||
|
@ -37,9 +37,9 @@ public class Commandblock extends UniversalCommand {
|
||||
for (String cb : (List<String>) plugin.getConfig().getStringList("blockablecommands"))
|
||||
if (args[1].equals("/" + cb))
|
||||
match = true;
|
||||
if (match || player.isBlockedCommand(args[1])) {
|
||||
if (!player.isBlockedCommand(args[1])) {
|
||||
player.addBlockedCommand(args[1]);
|
||||
if (match || player.getBlockedCommands().contains(args[1])) {
|
||||
if (!player.getBlockedCommands().contains(args[1])) {
|
||||
player.getBlockedCommands().add(args[1]);
|
||||
player.getPlayer().sendMessage(LocalizedMessage.BLOCK_COMMAND_PLAYER.toString()
|
||||
.replace("{command}", args[1]));
|
||||
sender.sendMessage(LocalizedMessage.BLOCK_COMMAND_SENDER.toString()
|
||||
@ -47,7 +47,7 @@ public class Commandblock extends UniversalCommand {
|
||||
.replace("{command}", args[1]));
|
||||
return;
|
||||
}
|
||||
player.removeBlockedCommand(args[1]);
|
||||
player.getBlockedCommands().remove(args[1]);
|
||||
player.getPlayer().sendMessage(LocalizedMessage.UNBLOCK_COMMAND_PLAYER.toString()
|
||||
.replace("{command}", args[1]));
|
||||
sender.sendMessage(LocalizedMessage.UNBLOCK_COMMAND_SENDER.toString()
|
||||
|
@ -7,11 +7,14 @@ import com.google.inject.Inject;
|
||||
import venture.Aust1n46.chat.localization.LocalizedMessage;
|
||||
import venture.Aust1n46.chat.model.PlayerCommand;
|
||||
import venture.Aust1n46.chat.model.VentureChatPlayer;
|
||||
import venture.Aust1n46.chat.service.ConfigService;
|
||||
import venture.Aust1n46.chat.service.PlayerApiService;
|
||||
|
||||
public class Commandspy extends PlayerCommand {
|
||||
@Inject
|
||||
private PlayerApiService playerApiService;
|
||||
@Inject
|
||||
private ConfigService configService;
|
||||
|
||||
@Inject
|
||||
public Commandspy(String name) {
|
||||
@ -22,7 +25,7 @@ public class Commandspy extends PlayerCommand {
|
||||
public void executeCommand(Player sender, String command, String[] args) {
|
||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer((Player) sender);
|
||||
if (mcp.getPlayer().hasPermission("venturechat.commandspy")) {
|
||||
if (!mcp.hasCommandSpy()) {
|
||||
if (!configService.isCommandSpy(mcp)) {
|
||||
mcp.setCommandSpy(true);
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.COMMANDSPY_ON.toString());
|
||||
return;
|
||||
|
@ -88,7 +88,7 @@ public class Ignore extends PlayerCommand {
|
||||
}
|
||||
if (mcp.getIgnores().contains(player.getUuid())) {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.IGNORE_PLAYER_OFF.toString().replace("{player}", player.getName()));
|
||||
mcp.removeIgnore(player.getUuid());
|
||||
mcp.getIgnores().remove(player.getUuid());
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
return;
|
||||
}
|
||||
@ -97,7 +97,7 @@ public class Ignore extends PlayerCommand {
|
||||
return;
|
||||
}
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.IGNORE_PLAYER_ON.toString().replace("{player}", player.getName()));
|
||||
mcp.addIgnore(player.getUuid());
|
||||
mcp.getIgnores().add(player.getUuid());
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class Kickchannel extends UniversalCommand {
|
||||
}
|
||||
sender.sendMessage(LocalizedMessage.KICK_CHANNEL.toString().replace("{player}", args[0]).replace("{channel_color}", channel.getColor() + "").replace("{channel_name}",
|
||||
channel.getName()));
|
||||
player.removeListening(channel.getName());
|
||||
player.getListening().remove(channel.getName());
|
||||
if (player.isOnline()) {
|
||||
player.getPlayer()
|
||||
.sendMessage(LocalizedMessage.LEAVE_CHANNEL.toString().replace("{channel_color}", channel.getColor() + "").replace("{channel_name}", channel.getName()));
|
||||
@ -54,7 +54,7 @@ public class Kickchannel extends UniversalCommand {
|
||||
}
|
||||
boolean isThereABungeeChannel = channel.getBungee();
|
||||
if (player.getListening().size() == 0) {
|
||||
player.addListening(configService.getDefaultChannel().getName());
|
||||
player.getListening().add(configService.getDefaultChannel().getName());
|
||||
player.setCurrentChannel(configService.getDefaultChannel());
|
||||
if (configService.getDefaultChannel().getBungee()) {
|
||||
isThereABungeeChannel = true;
|
||||
|
@ -47,9 +47,9 @@ public class Kickchannelall extends UniversalCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
player.clearListening();
|
||||
player.getListening().clear();
|
||||
sender.sendMessage(LocalizedMessage.KICK_CHANNEL_ALL_SENDER.toString().replace("{player}", player.getName()));
|
||||
player.addListening(configService.getDefaultChannel().getName());
|
||||
player.getListening().add(configService.getDefaultChannel().getName());
|
||||
player.setCurrentChannel(configService.getDefaultChannel());
|
||||
if (configService.getDefaultChannel().getBungee()) {
|
||||
isThereABungeeChannel = true;
|
||||
|
@ -35,11 +35,11 @@ public class Leave extends PlayerCommand {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.INVALID_CHANNEL.toString().replace("{args}", args[0]));
|
||||
return;
|
||||
}
|
||||
mcp.removeListening(channel.getName());
|
||||
mcp.getListening().remove(channel.getName());
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.LEAVE_CHANNEL.toString().replace("{channel_color}", channel.getColor() + "").replace("{channel_name}", channel.getName()));
|
||||
boolean isThereABungeeChannel = channel.getBungee();
|
||||
if (mcp.getListening().size() == 0) {
|
||||
mcp.addListening(configService.getDefaultChannel().getName());
|
||||
mcp.getListening().add(configService.getDefaultChannel().getName());
|
||||
mcp.setCurrentChannel(configService.getDefaultChannel());
|
||||
if (configService.getDefaultChannel().getBungee()) {
|
||||
isThereABungeeChannel = true;
|
||||
|
@ -36,12 +36,12 @@ public class Listen extends PlayerCommand {
|
||||
}
|
||||
if (channel.hasPermission()) {
|
||||
if (!mcp.getPlayer().hasPermission(channel.getPermission())) {
|
||||
mcp.removeListening(channel.getName());
|
||||
mcp.getListening().remove(channel.getName());
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_PERMISSION.toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
mcp.addListening(channel.getName());
|
||||
mcp.getListening().add(channel.getName());
|
||||
mcp.getPlayer()
|
||||
.sendMessage(LocalizedMessage.LISTEN_CHANNEL.toString().replace("{channel_color}", channel.getColor() + "").replace("{channel_name}", channel.getName()));
|
||||
if (channel.getBungee()) {
|
||||
|
@ -18,6 +18,7 @@ import venture.Aust1n46.chat.initiators.application.VentureChat;
|
||||
import venture.Aust1n46.chat.localization.LocalizedMessage;
|
||||
import venture.Aust1n46.chat.model.PlayerCommand;
|
||||
import venture.Aust1n46.chat.model.VentureChatPlayer;
|
||||
import venture.Aust1n46.chat.service.ConfigService;
|
||||
import venture.Aust1n46.chat.service.FormatService;
|
||||
import venture.Aust1n46.chat.service.PlayerApiService;
|
||||
import venture.Aust1n46.chat.utilities.FormatUtils;
|
||||
@ -31,6 +32,8 @@ public class Message extends PlayerCommand {
|
||||
private PluginMessageController pluginMessageController;
|
||||
@Inject
|
||||
private PlayerApiService playerApiService;
|
||||
@Inject
|
||||
private ConfigService configService;
|
||||
|
||||
@Inject
|
||||
public Message(String name) {
|
||||
@ -116,7 +119,7 @@ public class Message extends PlayerCommand {
|
||||
if (sp.getName().equals(mcp.getName()) || sp.getName().equals(player.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (sp.isSpy()) {
|
||||
if (configService.isCommandSpy(sp)) {
|
||||
sp.getPlayer().sendMessage(spy);
|
||||
}
|
||||
}
|
||||
@ -125,14 +128,14 @@ public class Message extends PlayerCommand {
|
||||
}
|
||||
if (args.length == 1) {
|
||||
if (args[0].length() > 0) {
|
||||
if (!mcp.hasConversation() || (mcp.hasConversation() && !mcp.getConversation().toString().equals(player.getUuid().toString()))) {
|
||||
if (mcp.getConversation() == null || (!mcp.getConversation().toString().equals(player.getUuid().toString()))) {
|
||||
mcp.setConversation(player.getUuid());
|
||||
if (!mcp.getPlayer().hasPermission("venturechat.spy.override")) {
|
||||
for (VentureChatPlayer sp : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if (sp.getName().equals(mcp.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (sp.isSpy()) {
|
||||
if (configService.isCommandSpy(sp)) {
|
||||
sp.getPlayer().sendMessage(LocalizedMessage.ENTER_PRIVATE_CONVERSATION_SPY.toString().replace("{player_sender}", mcp.getName())
|
||||
.replace("{player_receiver}", player.getName()));
|
||||
}
|
||||
@ -146,7 +149,7 @@ public class Message extends PlayerCommand {
|
||||
if (sp.getName().equals(mcp.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (sp.isSpy()) {
|
||||
if (configService.isCommandSpy(sp)) {
|
||||
sp.getPlayer().sendMessage(LocalizedMessage.EXIT_PRIVATE_CONVERSATION_SPY.toString().replace("{player_sender}", mcp.getName())
|
||||
.replace("{player_receiver}", player.getName()));
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import com.google.inject.Inject;
|
||||
import venture.Aust1n46.chat.controllers.PluginMessageController;
|
||||
import venture.Aust1n46.chat.localization.LocalizedMessage;
|
||||
import venture.Aust1n46.chat.model.ChatChannel;
|
||||
import venture.Aust1n46.chat.model.MuteContainer;
|
||||
import venture.Aust1n46.chat.model.UniversalCommand;
|
||||
import venture.Aust1n46.chat.model.VentureChatPlayer;
|
||||
import venture.Aust1n46.chat.service.ConfigService;
|
||||
@ -77,7 +78,7 @@ public class Mute extends UniversalCommand {
|
||||
sender.sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString().replace("{args}", args[1]));
|
||||
return;
|
||||
}
|
||||
if (playerToMute.isMuted(channel.getName())) {
|
||||
if (playerToMute.getMutes().containsKey(channel.getName())) {
|
||||
sender.sendMessage(LocalizedMessage.PLAYER_ALREADY_MUTED.toString().replace("{player}", playerToMute.getName())
|
||||
.replace("{channel_color}", channel.getColor()).replace("{channel_name}", channel.getName()));
|
||||
return;
|
||||
@ -85,7 +86,7 @@ public class Mute extends UniversalCommand {
|
||||
|
||||
if (time > 0) {
|
||||
if (reason.isEmpty()) {
|
||||
playerToMute.addMute(channel.getName(), datetime + time);
|
||||
playerToMute.getMutes().put(channel.getName(), new MuteContainer(channel.getName(), datetime + time, ""));
|
||||
String timeString = FormatUtils.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));
|
||||
@ -97,7 +98,7 @@ public class Mute extends UniversalCommand {
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
playerToMute.addMute(channel.getName(), datetime + time, reason);
|
||||
playerToMute.getMutes().put(channel.getName(), new MuteContainer(channel.getName(), datetime + time, reason));
|
||||
String timeString = FormatUtils.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)
|
||||
@ -112,7 +113,7 @@ public class Mute extends UniversalCommand {
|
||||
}
|
||||
} else {
|
||||
if (reason.isEmpty()) {
|
||||
playerToMute.addMute(channel.getName());
|
||||
playerToMute.getMutes().put(channel.getName(), new MuteContainer(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()) {
|
||||
@ -123,7 +124,7 @@ public class Mute extends UniversalCommand {
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
playerToMute.addMute(channel.getName(), reason);
|
||||
playerToMute.getMutes().put(channel.getName(), new MuteContainer(channel.getName(), 0, 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()) {
|
||||
@ -161,7 +162,7 @@ public class Mute extends UniversalCommand {
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
StringUtil.copyPartialMatches(args[1], playerApiService.getOnlineMineverseChatPlayers().stream().filter(mcp -> !mcp.isMuted(chatChannelObj.getName()))
|
||||
StringUtil.copyPartialMatches(args[1], playerApiService.getOnlineMineverseChatPlayers().stream().filter(mcp -> !mcp.getMutes().containsKey(chatChannelObj.getName()))
|
||||
.map(VentureChatPlayer::getName).collect(Collectors.toList()), completions);
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
|
@ -7,6 +7,7 @@ import com.google.inject.Inject;
|
||||
import venture.Aust1n46.chat.controllers.PluginMessageController;
|
||||
import venture.Aust1n46.chat.localization.LocalizedMessage;
|
||||
import venture.Aust1n46.chat.model.ChatChannel;
|
||||
import venture.Aust1n46.chat.model.MuteContainer;
|
||||
import venture.Aust1n46.chat.model.UniversalCommand;
|
||||
import venture.Aust1n46.chat.model.VentureChatPlayer;
|
||||
import venture.Aust1n46.chat.service.ConfigService;
|
||||
@ -50,7 +51,7 @@ public class Muteall extends UniversalCommand {
|
||||
boolean bungee = false;
|
||||
for (ChatChannel channel : configService.getChatChannels()) {
|
||||
if (channel.isMutable()) {
|
||||
player.addMute(channel.getName());
|
||||
player.getMutes().put(channel.getName(), new MuteContainer(channel.getName(), 0, ""));
|
||||
if (channel.getBungee()) {
|
||||
bungee = true;
|
||||
}
|
||||
@ -69,7 +70,7 @@ public class Muteall extends UniversalCommand {
|
||||
boolean bungee = false;
|
||||
for (ChatChannel channel : configService.getChatChannels()) {
|
||||
if (channel.isMutable()) {
|
||||
player.addMute(channel.getName(), reason);
|
||||
player.getMutes().put(channel.getName(), new MuteContainer(channel.getName(), 0, reason));
|
||||
if (channel.getBungee()) {
|
||||
bungee = true;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.google.inject.Inject;
|
||||
import venture.Aust1n46.chat.initiators.application.VentureChat;
|
||||
import venture.Aust1n46.chat.model.PlayerCommand;
|
||||
import venture.Aust1n46.chat.model.VentureChatPlayer;
|
||||
import venture.Aust1n46.chat.service.ConfigService;
|
||||
import venture.Aust1n46.chat.service.FormatService;
|
||||
import venture.Aust1n46.chat.service.PlayerApiService;
|
||||
import venture.Aust1n46.chat.utilities.FormatUtils;
|
||||
@ -21,6 +22,8 @@ public class Party extends PlayerCommand {
|
||||
private FormatService formatService;
|
||||
@Inject
|
||||
private PlayerApiService playerApiService;
|
||||
@Inject
|
||||
private ConfigService configService;
|
||||
|
||||
@Inject
|
||||
public Party(String name) {
|
||||
@ -45,7 +48,7 @@ public class Party extends PlayerCommand {
|
||||
mcp.setHost(false);
|
||||
mcp.getPlayer().sendMessage(ChatColor.GREEN + "You are no longer hosting a party.");
|
||||
for (VentureChatPlayer player : playerApiService.getMineverseChatPlayers()) {
|
||||
if (player.hasParty() && player.getParty().equals(mcp.getParty())) {
|
||||
if (player.getParty() != null && player.getParty().equals(mcp.getParty())) {
|
||||
player.setParty(null);
|
||||
if (player.isOnline()) {
|
||||
player.getPlayer().sendMessage(ChatColor.RED + mcp.getName() + " is no longer hosting a party.");
|
||||
@ -71,7 +74,7 @@ public class Party extends PlayerCommand {
|
||||
VentureChatPlayer player = playerApiService.getMineverseChatPlayer(args[1]);
|
||||
if (player != null) {
|
||||
if (player.isHost()) {
|
||||
if (!mcp.hasParty()) {
|
||||
if (mcp.getParty() == null) {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GREEN + "Joined " + player.getName() + "'s party.");
|
||||
mcp.setParty(player.getUuid());
|
||||
player.getPlayer().sendMessage(ChatColor.GREEN + mcp.getName() + " joined your party.");
|
||||
@ -94,12 +97,12 @@ public class Party extends PlayerCommand {
|
||||
mcp.getPlayer().sendMessage(ChatColor.RED + "You do not have permission for this command!");
|
||||
return;
|
||||
}
|
||||
if (mcp.hasParty()) {
|
||||
if (mcp.getParty() != null) {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GREEN + "Leaving " + playerApiService.getMineverseChatPlayer(mcp.getParty()).getName() + "'s party.");
|
||||
mcp.setParty(null);
|
||||
if (mcp.isHost()) {
|
||||
for (VentureChatPlayer player : playerApiService.getMineverseChatPlayers()) {
|
||||
if (player.hasParty() && player.getParty().equals(mcp.getUuid()) && !player.getName().equals(mcp.getName())) {
|
||||
if (player.getParty() != null && player.getParty().equals(mcp.getUuid()) && !player.getName().equals(mcp.getName())) {
|
||||
player.setParty(null);
|
||||
if (player.isOnline()) {
|
||||
player.getPlayer().sendMessage(ChatColor.RED + mcp.getName() + " is no longer hosting a party.");
|
||||
@ -125,7 +128,7 @@ public class Party extends PlayerCommand {
|
||||
VentureChatPlayer player = playerApiService.getMineverseChatPlayer(args[1]);
|
||||
if (player != null) {
|
||||
if (!player.getName().equals(mcp.getName())) {
|
||||
if (player.hasParty() && player.getParty().equals(mcp.getUuid())) {
|
||||
if (player.getParty() != null && player.getParty().equals(mcp.getUuid())) {
|
||||
player.setParty(null);
|
||||
player.getPlayer().sendMessage(ChatColor.RED + "You have been kicked out of " + mcp.getName() + "'s party.");
|
||||
mcp.getPlayer().sendMessage(ChatColor.RED + "You have kicked " + player.getName() + " out of your party.");
|
||||
@ -151,7 +154,7 @@ public class Party extends PlayerCommand {
|
||||
mcp.getPlayer().sendMessage(ChatColor.RED + "You do not have permission for this command!");
|
||||
return;
|
||||
}
|
||||
if (mcp.hasParty() && !mcp.isHost()) {
|
||||
if (mcp.getParty() != null && !mcp.isHost()) {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GREEN + "You are in " + playerApiService.getMineverseChatPlayer(mcp.getParty()).getName() + "'s party.");
|
||||
} else if (mcp.isHost()) {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GREEN + "You are hosting a party.");
|
||||
@ -175,11 +178,11 @@ public class Party extends PlayerCommand {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GREEN + "Toggled party chat off.");
|
||||
break;
|
||||
}
|
||||
if (mcp.hasConversation()) {
|
||||
if (mcp.getConversation() != null) {
|
||||
String tellChat = playerApiService.getMineverseChatPlayer(mcp.getConversation()).getName();
|
||||
mcp.setConversation(null);
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if (p.isSpy()) {
|
||||
if (configService.isSpy(p)) {
|
||||
p.getPlayer().sendMessage(mcp.getName() + " is no longer in a private conversation with " + tellChat + ".");
|
||||
}
|
||||
}
|
||||
@ -241,7 +244,7 @@ public class Party extends PlayerCommand {
|
||||
if (args[0].length() > 0) {
|
||||
if (!args[0].equals("host") && !args[0].equals("join") && !args[0].equals("leave") && !args[0].equals("kick") && !args[0].equals("info") && !args[0].equals("chat")
|
||||
&& !args[0].equals("help") && !args[0].equals("members") && !args[0].equals("ban") && !args[0].equals("unban")) {
|
||||
if (mcp.hasParty()) {
|
||||
if (mcp.getParty() != null) {
|
||||
String msg = "";
|
||||
String partyformat = "";
|
||||
for (int x = 0; x < args.length; x++) {
|
||||
@ -267,7 +270,7 @@ public class Party extends PlayerCommand {
|
||||
.replace("{host}", playerApiService.getMineverseChatPlayer(mcp.getParty()).getName()).replace("{player}", mcp.getName())) + msg;
|
||||
}
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if ((p.getParty().equals(mcp.getParty()) || p.isSpy())) {
|
||||
if ((p.getParty().equals(mcp.getParty()) || configService.isSpy(p))) {
|
||||
p.getPlayer().sendMessage(partyformat);
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,14 @@ import com.google.inject.Inject;
|
||||
import venture.Aust1n46.chat.localization.LocalizedMessage;
|
||||
import venture.Aust1n46.chat.model.PlayerCommand;
|
||||
import venture.Aust1n46.chat.model.VentureChatPlayer;
|
||||
import venture.Aust1n46.chat.service.ConfigService;
|
||||
import venture.Aust1n46.chat.service.PlayerApiService;
|
||||
|
||||
public class RangedSpy extends PlayerCommand {
|
||||
@Inject
|
||||
private PlayerApiService playerApiService;
|
||||
@Inject
|
||||
private ConfigService configService;
|
||||
|
||||
@Inject
|
||||
public RangedSpy(String name) {
|
||||
@ -22,7 +25,7 @@ public class RangedSpy extends PlayerCommand {
|
||||
public void executeCommand(Player player, String command, String[] args) {
|
||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer((Player) player);
|
||||
if (mcp.getPlayer().hasPermission("venturechat.rangedspy")) {
|
||||
if (!mcp.getRangedSpy()) {
|
||||
if (!configService.isRangedSpy(mcp)) {
|
||||
mcp.setRangedSpy(true);
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.RANGED_SPY_ON.toString());
|
||||
return;
|
||||
|
@ -13,6 +13,7 @@ import venture.Aust1n46.chat.initiators.application.VentureChat;
|
||||
import venture.Aust1n46.chat.localization.LocalizedMessage;
|
||||
import venture.Aust1n46.chat.model.PlayerCommand;
|
||||
import venture.Aust1n46.chat.model.VentureChatPlayer;
|
||||
import venture.Aust1n46.chat.service.ConfigService;
|
||||
import venture.Aust1n46.chat.service.FormatService;
|
||||
import venture.Aust1n46.chat.service.PlayerApiService;
|
||||
import venture.Aust1n46.chat.utilities.FormatUtils;
|
||||
@ -26,6 +27,8 @@ public class Reply extends PlayerCommand {
|
||||
private PluginMessageController pluginMessageController;
|
||||
@Inject
|
||||
private PlayerApiService playerApiService;
|
||||
@Inject
|
||||
private ConfigService configService;
|
||||
|
||||
@Inject
|
||||
public Reply(String name) {
|
||||
@ -40,7 +43,7 @@ public class Reply extends PlayerCommand {
|
||||
}
|
||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(sender);
|
||||
if (args.length > 0) {
|
||||
if (mcp.hasReplyPlayer()) {
|
||||
if (mcp.getReplyPlayer() != null) {
|
||||
if (plugin.getConfig().getBoolean("bungeecordmessaging", true)) {
|
||||
sendBungeeCordReply(mcp, args);
|
||||
return;
|
||||
@ -99,7 +102,7 @@ public class Reply extends PlayerCommand {
|
||||
if (p.getName().equals(mcp.getName()) || p.getName().equals(player.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (p.isSpy()) {
|
||||
if (configService.isSpy(p)) {
|
||||
p.getPlayer().sendMessage(spy);
|
||||
}
|
||||
}
|
||||
|
@ -48,19 +48,19 @@ public class Setchannel extends UniversalCommand {
|
||||
return;
|
||||
}
|
||||
if (!player.getPlayer().hasPermission(channel.getPermission())) {
|
||||
player.removeListening(channel.getName());
|
||||
player.getListening().remove(channel.getName());
|
||||
sender.sendMessage(LocalizedMessage.SET_CHANNEL_PLAYER_CHANNEL_NO_PERMISSION.toString().replace("{player}", player.getName())
|
||||
.replace("{channel_color}", channel.getColor() + "").replace("{channel_name}", channel.getName()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.addListening(channel.getName());
|
||||
player.getListening().add(channel.getName());
|
||||
player.setCurrentChannel(channel);
|
||||
sender.sendMessage(LocalizedMessage.SET_CHANNEL_SENDER.toString().replace("{player}", player.getName()).replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
if (player.hasConversation()) {
|
||||
if (player.getConversation() != null) {
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if (p.isSpy()) {
|
||||
if (configService.isSpy(p)) {
|
||||
p.getPlayer().sendMessage(LocalizedMessage.EXIT_PRIVATE_CONVERSATION_SPY.toString().replace("{player_sender}", player.getName())
|
||||
.replace("{player_receiver}", playerApiService.getMineverseChatPlayer(player.getConversation()).getName()));
|
||||
}
|
||||
|
@ -45,12 +45,12 @@ public class Setchannelall extends UniversalCommand {
|
||||
return;
|
||||
}
|
||||
if (!player.getPlayer().hasPermission(channel.getPermission())) {
|
||||
player.removeListening(channel.getName());
|
||||
player.getListening().remove(channel.getName());
|
||||
} else {
|
||||
player.addListening(channel.getName());
|
||||
player.getListening().add(channel.getName());
|
||||
}
|
||||
} else {
|
||||
player.addListening(channel.getName());
|
||||
player.getListening().add(channel.getName());
|
||||
}
|
||||
if (channel.getBungee()) {
|
||||
isThereABungeeChannel = true;
|
||||
|
@ -8,6 +8,7 @@ import venture.Aust1n46.chat.controllers.PluginMessageController;
|
||||
import venture.Aust1n46.chat.localization.LocalizedMessage;
|
||||
import venture.Aust1n46.chat.model.PlayerCommand;
|
||||
import venture.Aust1n46.chat.model.VentureChatPlayer;
|
||||
import venture.Aust1n46.chat.service.ConfigService;
|
||||
import venture.Aust1n46.chat.service.PlayerApiService;
|
||||
|
||||
public class Spy extends PlayerCommand {
|
||||
@ -15,6 +16,8 @@ public class Spy extends PlayerCommand {
|
||||
private PluginMessageController pluginMessageController;
|
||||
@Inject
|
||||
private PlayerApiService playerApiService;
|
||||
@Inject
|
||||
private ConfigService configService;
|
||||
|
||||
@Inject
|
||||
public Spy(String name) {
|
||||
@ -25,7 +28,7 @@ public class Spy extends PlayerCommand {
|
||||
public void executeCommand(Player player, String command, String[] args) {
|
||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(player);
|
||||
if (mcp.getPlayer().hasPermission("venturechat.spy")) {
|
||||
if (!mcp.isSpy()) {
|
||||
if (!configService.isSpy(mcp)) {
|
||||
mcp.setSpy(true);
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.SPY_ON.toString());
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
|
@ -52,12 +52,12 @@ public class Unmute extends UniversalCommand {
|
||||
sender.sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString().replace("{args}", args[1]));
|
||||
return;
|
||||
}
|
||||
if (!player.isMuted(channel.getName())) {
|
||||
if (!player.getMutes().containsKey(channel.getName())) {
|
||||
sender.sendMessage(LocalizedMessage.PLAYER_NOT_MUTED.toString().replace("{player}", player.getName()).replace("{channel_color}", channel.getColor())
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
return;
|
||||
}
|
||||
player.removeMute(channel.getName());
|
||||
player.getMutes().remove(channel.getName());
|
||||
sender.sendMessage(LocalizedMessage.UNMUTE_PLAYER_SENDER.toString().replace("{player}", player.getName()).replace("{channel_color}", channel.getColor())
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
if (player.isOnline()) {
|
||||
@ -92,7 +92,7 @@ public class Unmute extends UniversalCommand {
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
StringUtil.copyPartialMatches(args[1], playerApiService.getOnlineMineverseChatPlayers().stream().filter(mcp -> mcp.isMuted(chatChannelObj.getName()))
|
||||
StringUtil.copyPartialMatches(args[1], playerApiService.getOnlineMineverseChatPlayers().stream().filter(mcp -> mcp.getMutes().containsKey(chatChannelObj.getName()))
|
||||
.map(VentureChatPlayer::getName).collect(Collectors.toList()), completions);
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
|
@ -39,7 +39,7 @@ public class Unmuteall extends UniversalCommand {
|
||||
}
|
||||
boolean bungee = false;
|
||||
for (ChatChannel channel : configService.getChatChannels()) {
|
||||
player.removeMute(channel.getName());
|
||||
player.getMutes().remove(channel.getName());
|
||||
if (channel.getBungee()) {
|
||||
bungee = true;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package venture.Aust1n46.chat.initiators.listeners;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -79,7 +80,7 @@ public class ChatListener implements Listener {
|
||||
if (p.getName().equals(ventureChatPlayer.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (p.isSpy()) {
|
||||
if (configService.isSpy(p)) {
|
||||
p.getPlayer().sendMessage(LocalizedMessage.EXIT_PRIVATE_CONVERSATION_SPY.toString().replace("{player_sender}", ventureChatPlayer.getName())
|
||||
.replace("{player_receiver}", tp.getName()));
|
||||
}
|
||||
@ -129,7 +130,7 @@ public class ChatListener implements Listener {
|
||||
if (p.getName().equals(ventureChatPlayer.getName()) || p.getName().equals(tp.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (p.isSpy()) {
|
||||
if (configService.isSpy(p)) {
|
||||
p.getPlayer().sendMessage(spy);
|
||||
}
|
||||
}
|
||||
@ -149,10 +150,10 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
|
||||
private void processPartyChat(final VentureChatPlayer ventureChatPlayer, final String chat) {
|
||||
if (ventureChatPlayer.hasParty()) {
|
||||
if (ventureChatPlayer.getParty() != null) {
|
||||
String partyformat = "";
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if ((p.hasParty() && p.getParty().toString().equals(ventureChatPlayer.getParty().toString()) || p.isSpy())) {
|
||||
if ((p.getParty() != null && p.getParty().toString().equals(ventureChatPlayer.getParty().toString()) || configService.isSpy(p))) {
|
||||
String filtered = chat;
|
||||
if (ventureChatPlayer.isFilter()) {
|
||||
filtered = formatService.filterChat(filtered);
|
||||
@ -189,7 +190,7 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
|
||||
private void processMute(final VentureChatPlayer ventureChatPlayer, final ChatChannel channel) {
|
||||
MuteContainer muteContainer = ventureChatPlayer.getMute(channel.getName());
|
||||
MuteContainer muteContainer = ventureChatPlayer.getMutes().get(channel.getName());
|
||||
if (muteContainer.getDuration() > 0) {
|
||||
long dateTimeMillis = System.currentTimeMillis();
|
||||
long muteTimeMillis = muteContainer.getDuration();
|
||||
@ -230,7 +231,7 @@ public class ChatListener implements Listener {
|
||||
if (mcp.isQuickChat()) {
|
||||
eventChannel = mcp.getQuickChannel();
|
||||
}
|
||||
if (mcp.hasConversation() && !mcp.isQuickChat()) {
|
||||
if (mcp.getConversation() != null && !mcp.isQuickChat()) {
|
||||
processPrivateMessageConversation(mcp, chat);
|
||||
return;
|
||||
}
|
||||
@ -241,18 +242,18 @@ public class ChatListener implements Listener {
|
||||
if (eventChannel.hasPermission() && !mcp.getPlayer().hasPermission(eventChannel.getPermission())) {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_PERMISSION.toString());
|
||||
mcp.setQuickChat(false);
|
||||
mcp.removeListening(eventChannel.getName());
|
||||
mcp.getListening().remove(eventChannel.getName());
|
||||
mcp.setCurrentChannel(configService.getDefaultChannel());
|
||||
return;
|
||||
} else {
|
||||
mcp.addListening(eventChannel.getName());
|
||||
mcp.getListening().add(eventChannel.getName());
|
||||
}
|
||||
if (eventChannel.hasSpeakPermission() && !mcp.getPlayer().hasPermission(eventChannel.getSpeakPermission())) {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_SPEAK_PERMISSIONS.toString());
|
||||
mcp.setQuickChat(false);
|
||||
return;
|
||||
}
|
||||
if (mcp.isMuted(eventChannel.getName())) {
|
||||
if (mcp.getMutes().containsKey(eventChannel.getName())) {
|
||||
processMute(mcp, eventChannel);
|
||||
return;
|
||||
}
|
||||
@ -263,7 +264,7 @@ public class ChatListener implements Listener {
|
||||
chCooldown = eventChannel.getCooldown();
|
||||
}
|
||||
try {
|
||||
if (mcp.hasCooldown(eventChannel)) {
|
||||
if (mcp.getCooldowns().containsKey(eventChannel)) {
|
||||
long cooldownTime = mcp.getCooldowns().get(eventChannel).longValue();
|
||||
if (dateTimeSeconds < cooldownTime) {
|
||||
long remainingCooldownTime = cooldownTime - dateTimeSeconds;
|
||||
@ -275,14 +276,15 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
if (eventChannel.hasCooldown()) {
|
||||
if (!mcp.getPlayer().hasPermission("venturechat.cooldown.bypass")) {
|
||||
mcp.addCooldown(eventChannel, dateTimeSeconds + chCooldown);
|
||||
mcp.getCooldowns().put(eventChannel, dateTimeSeconds + chCooldown);
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (mcp.hasSpam(eventChannel) && plugin.getConfig().getConfigurationSection("antispam").getBoolean("enabled")
|
||||
// TODO Refactor and clarify this. Refactor how this is initialized and stored as player data
|
||||
if (mcp.getSpam().containsKey(eventChannel) && plugin.getConfig().getConfigurationSection("antispam").getBoolean("enabled")
|
||||
&& !mcp.getPlayer().hasPermission("venturechat.spam.bypass")) {
|
||||
long spamcount = mcp.getSpam().get(eventChannel).get(0);
|
||||
long spamtime = mcp.getSpam().get(eventChannel).get(1);
|
||||
@ -293,14 +295,14 @@ public class ChatListener implements Listener {
|
||||
if (spamcount + 1 >= spamtimeconfig) {
|
||||
long time = FormatUtils.parseTimeStringToMillis(mutedForTime);
|
||||
if (time > 0) {
|
||||
mcp.addMute(eventChannel.getName(), dateTime + time, LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString());
|
||||
mcp.getMutes().put(eventChannel.getName(), new MuteContainer(eventChannel.getName(), dateTime + time, LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString()));
|
||||
String timeString = FormatUtils.parseTimeStringFromMillis(time);
|
||||
mcp.getPlayer()
|
||||
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME_REASON.toString().replace("{channel_color}", eventChannel.getColor())
|
||||
.replace("{channel_name}", eventChannel.getName()).replace("{time}", timeString)
|
||||
.replace("{reason}", LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString()));
|
||||
} else {
|
||||
mcp.addMute(eventChannel.getName(), LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString());
|
||||
mcp.getMutes().put(eventChannel.getName(), new MuteContainer(eventChannel.getName(), 0, LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString()));
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_REASON.toString().replace("{channel_color}", eventChannel.getColor())
|
||||
.replace("{channel_name}", eventChannel.getName()).replace("{reason}", LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString()));
|
||||
}
|
||||
@ -324,7 +326,7 @@ public class ChatListener implements Listener {
|
||||
mcp.getSpam().get(eventChannel).set(1, dateTimeSeconds);
|
||||
}
|
||||
} else {
|
||||
mcp.addSpam(eventChannel);
|
||||
mcp.getSpam().put(eventChannel, new ArrayList<>());
|
||||
mcp.getSpam().get(eventChannel).add(0, 1L);
|
||||
mcp.getSpam().get(eventChannel).add(1, dateTimeSeconds);
|
||||
}
|
||||
@ -416,7 +418,7 @@ public class ChatListener implements Listener {
|
||||
if (eventChannel.hasDistance()) {
|
||||
chDistance = eventChannel.getDistance();
|
||||
}
|
||||
if (chDistance > (double) 0 && !eventChannel.getBungee() && !p.getRangedSpy()) {
|
||||
if (chDistance > (double) 0 && !eventChannel.getBungee() && !configService.isRangedSpy(p)) {
|
||||
final Location locreceip = p.getPlayer().getLocation();
|
||||
if (locreceip.getWorld() == mcp.getPlayer().getWorld()) {
|
||||
final Location locsender = mcp.getPlayer().getLocation();
|
||||
|
@ -53,8 +53,9 @@ public class LoginListener implements Listener {
|
||||
log.warn("onPlayerQuit() Could not find VentureChatPlayer");
|
||||
} else {
|
||||
spigotFlatFileController.savePlayerData(ventureChatPlayer);
|
||||
ventureChatPlayer.clearMessages();
|
||||
ventureChatPlayer.getMessages().clear();
|
||||
ventureChatPlayer.setOnline(false);
|
||||
ventureChatPlayer.setPlayer(null);
|
||||
playerApiService.removeMineverseChatOnlinePlayerToMap(ventureChatPlayer);
|
||||
log.debug("onPlayerQuit() ventureChatPlayer:{} quit", ventureChatPlayer);
|
||||
}
|
||||
@ -75,7 +76,8 @@ public class LoginListener implements Listener {
|
||||
String name = player.getName();
|
||||
if (mcp == null) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
mcp = new VentureChatPlayer(uuid, name, configService.getDefaultChannel());
|
||||
mcp = VentureChatPlayer.builder().uuid(uuid).name(name).currentChannel(configService.getDefaultChannel()).build();
|
||||
mcp.getListening().add(configService.getDefaultChannel().getName());
|
||||
playerApiService.addMineverseChatPlayerToMap(mcp);
|
||||
playerApiService.addNameToMap(mcp);
|
||||
}
|
||||
@ -100,10 +102,10 @@ public class LoginListener implements Listener {
|
||||
for (ChatChannel ch : configService.getAutojoinList()) {
|
||||
if (ch.hasPermission()) {
|
||||
if (mcp.getPlayer().hasPermission(ch.getPermission())) {
|
||||
mcp.addListening(ch.getName());
|
||||
mcp.getListening().add(ch.getName());
|
||||
}
|
||||
} else {
|
||||
mcp.addListening(ch.getName());
|
||||
mcp.getListening().add(ch.getName());
|
||||
}
|
||||
}
|
||||
if (configService.isProxyEnabled()) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package venture.Aust1n46.chat.initiators.listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
@ -74,6 +76,10 @@ public class PacketListenerLegacyChat extends PacketAdapter {
|
||||
return;
|
||||
}
|
||||
int hash = message.hashCode();
|
||||
mcp.addMessage(new ChatMessage(chat, message, coloredMessage, hash));
|
||||
final List<ChatMessage> messages = mcp.getMessages();
|
||||
if (messages.size() >= 100) {
|
||||
messages.remove(0);
|
||||
}
|
||||
messages.add(new ChatMessage(chat, message, coloredMessage, hash));
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class PreProcessCommandListener implements CommandExecutor, Listener {
|
||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(event.getPlayer());
|
||||
if (!mcp.getPlayer().hasPermission("venturechat.commandspy.override")) {
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if (p.hasCommandSpy()) {
|
||||
if (configService.isCommandSpy(p)) {
|
||||
if (wec) {
|
||||
p.getPlayer().sendMessage(FormatUtils.FormatStringAll(cs.getString("format").replace("{player}", mcp.getName()).replace("{command}", event.getMessage())));
|
||||
} else {
|
||||
@ -156,9 +156,9 @@ public class PreProcessCommandListener implements CommandExecutor, Listener {
|
||||
if (message.equals("/" + channel.getAlias())) {
|
||||
mcp.getPlayer().sendMessage(
|
||||
LocalizedMessage.SET_CHANNEL.toString().replace("{channel_color}", channel.getColor() + "").replace("{channel_name}", channel.getName()));
|
||||
if (mcp.hasConversation()) {
|
||||
if (mcp.getConversation() != null) {
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if (p.isSpy()) {
|
||||
if (configService.isSpy(p)) {
|
||||
p.getPlayer().sendMessage(LocalizedMessage.EXIT_PRIVATE_CONVERSATION_SPY.toString().replace("{player_sender}", mcp.getName())
|
||||
.replace("{player_receiver}", playerApiService.getMineverseChatPlayer(mcp.getConversation()).getName()));
|
||||
}
|
||||
@ -167,7 +167,7 @@ public class PreProcessCommandListener implements CommandExecutor, Listener {
|
||||
playerApiService.getMineverseChatPlayer(mcp.getConversation()).getName()));
|
||||
mcp.setConversation(null);
|
||||
}
|
||||
mcp.addListening(channel.getName());
|
||||
mcp.getListening().add(channel.getName());
|
||||
mcp.setCurrentChannel(channel);
|
||||
if (channel.getBungee()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
@ -177,7 +177,7 @@ public class PreProcessCommandListener implements CommandExecutor, Listener {
|
||||
}
|
||||
if (message.toLowerCase().startsWith("/" + channel.getAlias() + " ")) {
|
||||
message = message.substring(channel.getAlias().length() + 1);
|
||||
mcp.addListening(channel.getName());
|
||||
mcp.getListening().add(channel.getName());
|
||||
if (channel.getBungee()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
}
|
||||
@ -217,7 +217,7 @@ public class PreProcessCommandListener implements CommandExecutor, Listener {
|
||||
}
|
||||
mcp.setQuickChat(true);
|
||||
mcp.setQuickChannel(channel);
|
||||
mcp.addListening(channel.getName());
|
||||
mcp.getListening().add(channel.getName());
|
||||
if (channel.getBungee()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class UnmuteScheduler {
|
||||
public void run() {
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
Iterator<MuteContainer> iterator = p.getMutes().iterator();
|
||||
Iterator<MuteContainer> iterator = p.getMutes().values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
MuteContainer mute = iterator.next();
|
||||
if (configService.isChannel(mute.getChannel())) {
|
||||
|
@ -1,20 +1,19 @@
|
||||
package venture.Aust1n46.chat.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Builder.Default;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -26,273 +25,50 @@ import lombok.ToString;
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class VentureChatPlayer {
|
||||
@Setter(value = AccessLevel.NONE)
|
||||
private UUID uuid;
|
||||
private String name;
|
||||
private ChatChannel currentChannel;
|
||||
private Set<UUID> ignores;
|
||||
private Set<String> listening;
|
||||
private HashMap<String, MuteContainer> mutes;
|
||||
private Set<String> blockedCommands;
|
||||
private boolean host;
|
||||
private UUID party;
|
||||
private boolean filter;
|
||||
private boolean notifications;
|
||||
private boolean online;
|
||||
private Player player;
|
||||
private boolean hasPlayed;
|
||||
private UUID conversation;
|
||||
private boolean spy;
|
||||
private boolean commandSpy;
|
||||
private boolean online;
|
||||
private ChatChannel currentChannel;
|
||||
private boolean quickChat;
|
||||
private ChatChannel quickChannel;
|
||||
private UUID conversation;
|
||||
private UUID replyPlayer;
|
||||
private HashMap<ChatChannel, Long> cooldowns;
|
||||
private boolean partyChat;
|
||||
private HashMap<ChatChannel, List<Long>> spam;
|
||||
private boolean hasPlayed;
|
||||
private boolean modified;
|
||||
private List<ChatMessage> messages;
|
||||
private String jsonFormat;
|
||||
private boolean rangedSpy;
|
||||
private boolean spy;
|
||||
private boolean commandSpy;
|
||||
private UUID party;
|
||||
private boolean host;
|
||||
private boolean partyChat;
|
||||
private boolean editing;
|
||||
private int editHash;
|
||||
private boolean rangedSpy;
|
||||
private boolean messageToggle;
|
||||
private boolean bungeeToggle;
|
||||
|
||||
public VentureChatPlayer(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 jsonFormat, boolean spy, boolean commandSpy, boolean rangedSpy,
|
||||
boolean messageToggle, boolean bungeeToggle) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.currentChannel = currentChannel;
|
||||
this.ignores = ignores;
|
||||
this.listening = listening;
|
||||
this.mutes = mutes;
|
||||
this.blockedCommands = blockedCommands;
|
||||
this.host = host;
|
||||
this.party = party;
|
||||
this.filter = filter;
|
||||
this.notifications = notifications;
|
||||
this.spy = spy;
|
||||
this.rangedSpy = rangedSpy;
|
||||
this.commandSpy = commandSpy;
|
||||
this.messages = new ArrayList<ChatMessage>();
|
||||
this.jsonFormat = jsonFormat;
|
||||
this.cooldowns = new HashMap<ChatChannel, Long>();
|
||||
this.spam = new HashMap<ChatChannel, List<Long>>();
|
||||
this.messageToggle = messageToggle;
|
||||
this.bungeeToggle = bungeeToggle;
|
||||
}
|
||||
|
||||
public VentureChatPlayer(UUID uuid, String name, ChatChannel currentChannel) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.currentChannel = currentChannel;
|
||||
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.filter = true;
|
||||
this.notifications = true;
|
||||
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 getRangedSpy() {
|
||||
if (isOnline()) {
|
||||
if (!getPlayer().hasPermission("venturechat.rangedspy")) {
|
||||
setRangedSpy(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this.rangedSpy;
|
||||
}
|
||||
|
||||
public boolean setCurrentChannel(ChatChannel channel) {
|
||||
if (channel != null) {
|
||||
this.currentChannel = channel;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addIgnore(UUID ignore) {
|
||||
this.ignores.add(ignore);
|
||||
}
|
||||
|
||||
public void removeIgnore(UUID ignore) {
|
||||
this.ignores.remove(ignore);
|
||||
}
|
||||
|
||||
public boolean isListening(String channel) {
|
||||
return listening.contains(channel);
|
||||
}
|
||||
|
||||
public boolean addListening(String channel) {
|
||||
if (channel != null) {
|
||||
this.listening.add(channel);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeListening(String channel) {
|
||||
if (channel != null) {
|
||||
this.listening.remove(channel);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void clearListening() {
|
||||
this.listening.clear();
|
||||
}
|
||||
|
||||
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, new MuteContainer(channel, time, reason));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeMute(String channel) {
|
||||
if (channel != null) {
|
||||
mutes.remove(channel);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isMuted(String channel) {
|
||||
return channel != null ? this.mutes.containsKey(channel) : false;
|
||||
}
|
||||
|
||||
public void addBlockedCommand(String command) {
|
||||
this.blockedCommands.add(command);
|
||||
}
|
||||
|
||||
public void removeBlockedCommand(String command) {
|
||||
this.blockedCommands.remove(command);
|
||||
}
|
||||
|
||||
public boolean isBlockedCommand(String command) {
|
||||
return this.blockedCommands.contains(command);
|
||||
}
|
||||
|
||||
public boolean hasParty() {
|
||||
return this.party != null;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.online ? this.player : null;
|
||||
}
|
||||
|
||||
public boolean hasConversation() {
|
||||
return this.conversation != null;
|
||||
}
|
||||
|
||||
public boolean isSpy() {
|
||||
if (this.isOnline()) {
|
||||
if (!this.getPlayer().hasPermission("venturechat.spy")) {
|
||||
this.setSpy(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this.spy;
|
||||
}
|
||||
|
||||
public boolean hasCommandSpy() {
|
||||
if (this.isOnline()) {
|
||||
if (!this.getPlayer().hasPermission("venturechat.commandspy")) {
|
||||
this.setCommandSpy(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this.commandSpy;
|
||||
}
|
||||
|
||||
public boolean setQuickChannel(ChatChannel channel) {
|
||||
if (channel != null) {
|
||||
this.quickChannel = channel;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasReplyPlayer() {
|
||||
return this.replyPlayer != null;
|
||||
}
|
||||
|
||||
public boolean addCooldown(ChatChannel channel, long time) {
|
||||
if (channel != null && time > 0) {
|
||||
cooldowns.put(channel, time);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeCooldown(ChatChannel channel) {
|
||||
if (channel != null) {
|
||||
cooldowns.remove(channel);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasCooldown(ChatChannel channel) {
|
||||
return channel != null && this.cooldowns != null ? this.cooldowns.containsKey(channel) : false;
|
||||
}
|
||||
|
||||
public boolean hasSpam(ChatChannel channel) {
|
||||
return channel != null && this.spam != null ? this.spam.containsKey(channel) : false;
|
||||
}
|
||||
|
||||
public boolean addSpam(ChatChannel channel) {
|
||||
if (channel != null) {
|
||||
spam.put(channel, new ArrayList<Long>());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addMessage(ChatMessage message) {
|
||||
if (this.messages.size() >= 100) {
|
||||
this.messages.remove(0);
|
||||
}
|
||||
this.messages.add(message);
|
||||
}
|
||||
|
||||
public void clearMessages() {
|
||||
this.messages.clear();
|
||||
}
|
||||
@Default
|
||||
private boolean filter = true;
|
||||
@Default
|
||||
private boolean notifications = true;
|
||||
@Default
|
||||
private boolean messageToggle = true;
|
||||
@Default
|
||||
private boolean bungeeToggle = true;
|
||||
@Default
|
||||
private String jsonFormat = "Default";
|
||||
@Default
|
||||
private Set<String> listening = new HashSet<>();
|
||||
@Default
|
||||
private Map<String, MuteContainer> mutes = new HashMap<>();
|
||||
@Default
|
||||
private Set<UUID> ignores = new HashSet<>();
|
||||
@Default
|
||||
private Map<ChatChannel, Long> cooldowns = new HashMap<>();
|
||||
@Default
|
||||
private Map<ChatChannel, List<Long>> spam = new HashMap<>();
|
||||
@Default
|
||||
private Set<String> blockedCommands = new HashSet<>();
|
||||
@Default
|
||||
private List<ChatMessage> messages = new ArrayList<>();
|
||||
}
|
||||
|
@ -159,6 +159,7 @@ public class ConfigService {
|
||||
return getChannel(channelName) != null;
|
||||
}
|
||||
|
||||
// TODO Investigate if all of this logic should be here
|
||||
public boolean isListening(VentureChatPlayer ventureChatPlayer, String channel) {
|
||||
if (ventureChatPlayer.isOnline()) {
|
||||
if (isChannel(channel)) {
|
||||
@ -168,13 +169,46 @@ public class ConfigService {
|
||||
if (ventureChatPlayer.getCurrentChannel().equals(chatChannel)) {
|
||||
ventureChatPlayer.setCurrentChannel(getDefaultChannel());
|
||||
}
|
||||
ventureChatPlayer.removeListening(channel);
|
||||
ventureChatPlayer.getListening().remove(channel);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ventureChatPlayer.isListening(channel);
|
||||
return ventureChatPlayer.getListening().contains(channel);
|
||||
}
|
||||
|
||||
// TODO Investigate if all of this logic should be here
|
||||
public boolean isRangedSpy(final VentureChatPlayer ventureChatPlayer) {
|
||||
if (ventureChatPlayer.isOnline()) {
|
||||
if (!ventureChatPlayer.getPlayer().hasPermission("venturechat.rangedspy")) {
|
||||
ventureChatPlayer.setRangedSpy(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ventureChatPlayer.isRangedSpy();
|
||||
}
|
||||
|
||||
// TODO Investigate if all of this logic should be here
|
||||
public boolean isSpy(final VentureChatPlayer ventureChatPlayer) {
|
||||
if (ventureChatPlayer.isOnline()) {
|
||||
if (!ventureChatPlayer.getPlayer().hasPermission("venturechat.spy")) {
|
||||
ventureChatPlayer.setSpy(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ventureChatPlayer.isSpy();
|
||||
}
|
||||
|
||||
// TODO Investigate if all of this logic should be here
|
||||
public boolean isCommandSpy(final VentureChatPlayer ventureChatPlayer) {
|
||||
if (ventureChatPlayer.isOnline()) {
|
||||
if (!ventureChatPlayer.getPlayer().hasPermission("venturechat.commandspy")) {
|
||||
ventureChatPlayer.setCommandSpy(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ventureChatPlayer.isCommandSpy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user