mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-22 18:09:06 +00:00
Model refactoring
This commit is contained in:
parent
254c261528
commit
d7e2ed8b9c
@ -6,15 +6,14 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@ -26,9 +25,9 @@ import venture.Aust1n46.chat.model.ChatChannel;
|
||||
import venture.Aust1n46.chat.model.MuteContainer;
|
||||
import venture.Aust1n46.chat.model.VentureChatPlayer;
|
||||
import venture.Aust1n46.chat.service.ConfigService;
|
||||
import venture.Aust1n46.chat.service.VentureChatDatabaseService;
|
||||
import venture.Aust1n46.chat.service.FormatService;
|
||||
import venture.Aust1n46.chat.service.PlayerApiService;
|
||||
import venture.Aust1n46.chat.service.VentureChatDatabaseService;
|
||||
import venture.Aust1n46.chat.utilities.FormatUtils;
|
||||
|
||||
@Singleton
|
||||
@ -105,14 +104,14 @@ public class PluginMessageController {
|
||||
int channelCount = 0;
|
||||
for (String c : mcp.getListening()) {
|
||||
ChatChannel channel = configService.getChannel(c);
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
channelCount++;
|
||||
}
|
||||
}
|
||||
out.write(channelCount);
|
||||
for (String c : mcp.getListening()) {
|
||||
ChatChannel channel = configService.getChannel(c);
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
out.writeUTF(channel.getName());
|
||||
}
|
||||
}
|
||||
@ -120,7 +119,7 @@ public class PluginMessageController {
|
||||
int muteCount = 0;
|
||||
for (MuteContainer mute : mcp.getMutes().values()) {
|
||||
ChatChannel channel = configService.getChannel(mute.getChannel());
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
muteCount++;
|
||||
}
|
||||
}
|
||||
@ -128,7 +127,7 @@ public class PluginMessageController {
|
||||
out.write(muteCount);
|
||||
for (MuteContainer mute : mcp.getMutes().values()) {
|
||||
ChatChannel channel = configService.getChannel(mute.getChannel());
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
out.writeUTF(channel.getName());
|
||||
out.writeLong(mute.getDuration());
|
||||
out.writeUTF(mute.getReason());
|
||||
@ -167,69 +166,41 @@ public class PluginMessageController {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(stream);
|
||||
if (subchannel.equals("Chat")) {
|
||||
String server = msgin.readUTF();
|
||||
String chatchannel = msgin.readUTF();
|
||||
String senderName = msgin.readUTF();
|
||||
UUID senderUUID = UUID.fromString(msgin.readUTF());
|
||||
int hash = msgin.readInt();
|
||||
String format = msgin.readUTF();
|
||||
String chat = msgin.readUTF();
|
||||
String consoleChat = format + chat;
|
||||
String globalJSON = msgin.readUTF();
|
||||
String primaryGroup = msgin.readUTF();
|
||||
|
||||
if (!configService.isChannel(chatchannel)) {
|
||||
final String server = msgin.readUTF();
|
||||
final String chatChannelName = msgin.readUTF();
|
||||
final String senderName = msgin.readUTF();
|
||||
final UUID senderUUID = UUID.fromString(msgin.readUTF());
|
||||
final int hash = msgin.readInt();
|
||||
final String format = msgin.readUTF();
|
||||
final String chat = msgin.readUTF();
|
||||
final String consoleChat = format + chat;
|
||||
final String globalJSON = msgin.readUTF();
|
||||
final String primaryGroup = msgin.readUTF();
|
||||
final ChatChannel chatChannel = configService.getChannel(chatChannelName);
|
||||
if (chatChannel == null || !chatChannel.isBungeeEnabled()) {
|
||||
return;
|
||||
}
|
||||
ChatChannel chatChannelObject = configService.getChannel(chatchannel);
|
||||
|
||||
if (!chatChannelObject.getBungee()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<Player> recipients = new HashSet<Player>();
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if (configService.isListening(p, chatChannelObject.getName())) {
|
||||
recipients.add(p.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
final Set<Player> recipients = playerApiService.getOnlineMineverseChatPlayers()
|
||||
.stream()
|
||||
.filter(vcp -> configService.isListening(vcp, chatChannelName))
|
||||
.filter(vcp -> vcp.isBungeeToggle() || playerApiService.getOnlineMineverseChatPlayer(senderName) == null)
|
||||
.filter(vcp -> !configService.isIgnoreChatEnabled() || !vcp.getIgnores().contains(senderUUID))
|
||||
.map(VentureChatPlayer::getPlayer)
|
||||
.collect(Collectors.toSet());
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Create VentureChatEvent
|
||||
VentureChatEvent ventureChatEvent = new VentureChatEvent(null, senderName, primaryGroup, chatChannelObject, recipients, recipients.size(), format, chat,
|
||||
final VentureChatEvent ventureChatEvent = new VentureChatEvent(null, senderName, primaryGroup, chatChannel, recipients, recipients.size(), format, chat,
|
||||
globalJSON, hash, false);
|
||||
// Fire event and wait for other plugin listeners to act on it
|
||||
// This event cannot be modified or cancelled
|
||||
plugin.getServer().getPluginManager().callEvent(ventureChatEvent);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getServer().getConsoleSender().sendMessage(consoleChat);
|
||||
|
||||
if (databaseService.isEnabled()) {
|
||||
databaseService.writeVentureChat(senderUUID.toString(), senderName, server, chatchannel, chat.replace("'", "''"), "Chat");
|
||||
}
|
||||
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if (configService.isListening(p, chatChannelObject.getName())) {
|
||||
if (!p.isBungeeToggle() && playerApiService.getOnlineMineverseChatPlayer(senderName) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String json = formatService.formatModerationGUI(globalJSON, p.getPlayer(), senderName, chatchannel, hash);
|
||||
PacketContainer packet = formatService.createPacketPlayOutChat(json);
|
||||
|
||||
if (plugin.getConfig().getBoolean("ignorechat", false)) {
|
||||
if (!p.getIgnores().contains(senderUUID)) {
|
||||
// System.out.println("Chat sent");
|
||||
formatService.sendPacketPlayOutChat(p.getPlayer(), packet);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
formatService.sendPacketPlayOutChat(p.getPlayer(), packet);
|
||||
}
|
||||
databaseService.writeVentureChat(senderUUID.toString(), senderName, server, chatChannelName, chat.replace("'", "''"), "Chat");
|
||||
}
|
||||
formatService.createAndSendChatMessage(globalJSON, chatChannelName, hash, recipients, senderName);
|
||||
plugin.getServer().getConsoleSender().sendMessage(consoleChat);
|
||||
}
|
||||
if (subchannel.equals("DiscordSRV")) {
|
||||
String chatChannel = msgin.readUTF();
|
||||
@ -238,20 +209,10 @@ public class PluginMessageController {
|
||||
return;
|
||||
}
|
||||
ChatChannel chatChannelObj = configService.getChannel(chatChannel);
|
||||
if (!chatChannelObj.getBungee()) {
|
||||
if (!chatChannelObj.isBungeeEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String json = formatService.convertPlainTextToJson(message, true);
|
||||
int hash = (message.replaceAll("([<5B>]([a-z0-9]))", "")).hashCode();
|
||||
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if (configService.isListening(p, chatChannelObj.getName())) {
|
||||
String finalJSON = formatService.formatModerationGUI(json, p.getPlayer(), "Discord", chatChannelObj.getName(), hash);
|
||||
PacketContainer packet = formatService.createPacketPlayOutChat(finalJSON);
|
||||
formatService.sendPacketPlayOutChat(p.getPlayer(), packet);
|
||||
}
|
||||
}
|
||||
formatService.createAndSendExternalChatMessage(message, chatChannelObj.getName(), "Discord");
|
||||
}
|
||||
if (subchannel.equals("PlayerNames")) {
|
||||
playerApiService.clearNetworkPlayerNames();
|
||||
@ -323,7 +284,7 @@ public class PluginMessageController {
|
||||
for (Object ch : p.getListening().toArray()) {
|
||||
String c = ch.toString();
|
||||
ChatChannel cha = configService.getChannel(c);
|
||||
if (cha.getBungee()) {
|
||||
if (cha.isBungeeEnabled()) {
|
||||
p.getListening().remove(c);
|
||||
}
|
||||
}
|
||||
@ -332,12 +293,12 @@ public class PluginMessageController {
|
||||
String ch = msgin.readUTF();
|
||||
if (configService.isChannel(ch)) {
|
||||
ChatChannel cha = configService.getChannel(ch);
|
||||
if (!cha.hasPermission() || p.getPlayer().hasPermission(cha.getPermission())) {
|
||||
if (!cha.isPermissionRequired() || p.getPlayer().hasPermission(cha.getPermission())) {
|
||||
p.getListening().add(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
p.getMutes().values().removeIf(mute -> configService.getChannel(mute.getChannel()).getBungee());
|
||||
p.getMutes().values().removeIf(mute -> configService.getChannel(mute.getChannel()).isBungeeEnabled());
|
||||
int sizeB = msgin.read();
|
||||
// System.out.println(sizeB + " mute size");
|
||||
for (int b = 0; b < sizeB; b++) {
|
||||
@ -366,9 +327,9 @@ public class PluginMessageController {
|
||||
if (!p.isHasPlayed()) {
|
||||
boolean isThereABungeeChannel = false;
|
||||
for (ChatChannel ch : configService.getAutojoinList()) {
|
||||
if ((!ch.hasPermission() || p.getPlayer().hasPermission(ch.getPermission())) && !configService.isListening(p, ch.getName())) {
|
||||
if ((!ch.isPermissionRequired() || p.getPlayer().hasPermission(ch.getPermission())) && !configService.isListening(p, ch.getName())) {
|
||||
p.getListening().add(ch.getName());
|
||||
if (ch.getBungee()) {
|
||||
if (ch.isBungeeEnabled()) {
|
||||
isThereABungeeChannel = true;
|
||||
}
|
||||
}
|
||||
|
@ -87,8 +87,8 @@ public class ProxyController {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c You probably have an issue with your player data saving and/or your login data sync!");
|
||||
return;
|
||||
}
|
||||
smcp.clearMessagePackets();
|
||||
smcp.clearMessageData();
|
||||
smcp.setMessagePackets(0);
|
||||
smcp.getMessageData().clear();
|
||||
out.writeUTF("Chwho");
|
||||
out.writeUTF("Get");
|
||||
out.writeUTF(server);
|
||||
@ -110,10 +110,10 @@ public class ProxyController {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c You probably have an issue with your player data saving and/or your login data sync!");
|
||||
return;
|
||||
}
|
||||
smcp.incrementMessagePackets();
|
||||
smcp.setMessagePackets(smcp.getMessagePackets() + 1);
|
||||
int players = in.readInt();
|
||||
for(int a = 0; a < players; a++) {
|
||||
smcp.addData(in.readUTF());
|
||||
smcp.getMessageData().add(in.readUTF());
|
||||
}
|
||||
AtomicInteger servers = new AtomicInteger(0);
|
||||
source.getServers().forEach(send -> {
|
||||
@ -122,7 +122,7 @@ public class ProxyController {
|
||||
}
|
||||
});
|
||||
if(smcp.getMessagePackets() >= servers.get()) {
|
||||
smcp.clearMessagePackets();
|
||||
smcp.setMessagePackets(0);
|
||||
out.writeUTF("Chwho");
|
||||
out.writeUTF("Receive");
|
||||
out.writeUTF(sender);
|
||||
@ -131,7 +131,7 @@ public class ProxyController {
|
||||
for(String s : smcp.getMessageData()) {
|
||||
out.writeUTF(s);
|
||||
}
|
||||
smcp.clearMessageData();
|
||||
smcp.getMessageData().clear();
|
||||
source.sendPluginMessage(server, outstream.toByteArray());
|
||||
}
|
||||
}
|
||||
@ -158,7 +158,7 @@ public class ProxyController {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c You probably have an issue with your player data saving and/or your login data sync!");
|
||||
return;
|
||||
}
|
||||
smcp.clearMessagePackets();
|
||||
smcp.setMessagePackets(0);
|
||||
out.writeUTF("Ignore");
|
||||
out.writeUTF("Send");
|
||||
out.writeUTF(server);
|
||||
@ -180,7 +180,7 @@ public class ProxyController {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c You probably have an issue with your player data saving and/or your login data sync!");
|
||||
return;
|
||||
}
|
||||
smcp.incrementMessagePackets();
|
||||
smcp.setMessagePackets(smcp.getMessagePackets() + 1);
|
||||
AtomicInteger servers = new AtomicInteger(0);
|
||||
source.getServers().forEach(send -> {
|
||||
if(!send.isEmpty()) {
|
||||
@ -188,7 +188,7 @@ public class ProxyController {
|
||||
}
|
||||
});
|
||||
if(smcp.getMessagePackets() >= servers.get()) {
|
||||
smcp.clearMessagePackets();
|
||||
smcp.setMessagePackets(0);
|
||||
out.writeUTF("Ignore");
|
||||
out.writeUTF("Offline");
|
||||
out.writeUTF(player);
|
||||
@ -398,7 +398,7 @@ public class ProxyController {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c You probably have an issue with your player data saving and/or your login data sync!");
|
||||
return;
|
||||
}
|
||||
smcp.clearMessagePackets();
|
||||
smcp.setMessagePackets(0);
|
||||
out.writeUTF("Message");
|
||||
out.writeUTF("Send");
|
||||
out.writeUTF(server);
|
||||
@ -425,7 +425,7 @@ public class ProxyController {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c You probably have an issue with your player data saving and/or your login data sync!");
|
||||
return;
|
||||
}
|
||||
smcp.incrementMessagePackets();
|
||||
smcp.setMessagePackets(smcp.getMessagePackets() + 1);
|
||||
AtomicInteger servers = new AtomicInteger(0);
|
||||
source.getServers().forEach(send -> {
|
||||
if(!send.isEmpty()) {
|
||||
@ -433,7 +433,7 @@ public class ProxyController {
|
||||
}
|
||||
});
|
||||
if(smcp.getMessagePackets() >= servers.get()) {
|
||||
smcp.clearMessagePackets();
|
||||
smcp.setMessagePackets(0);
|
||||
out.writeUTF("Message");
|
||||
out.writeUTF("Offline");
|
||||
out.writeUTF(player);
|
||||
@ -507,7 +507,7 @@ public class ProxyController {
|
||||
UUID uuid = UUID.fromString(in.readUTF());
|
||||
SynchronizedVentureChatPlayer smcp = playerApiService.getSynchronizedMineverseChatPlayer(uuid);
|
||||
if(smcp == null) {
|
||||
smcp = new SynchronizedVentureChatPlayer(uuid);
|
||||
smcp = SynchronizedVentureChatPlayer.builder().uuid(uuid).build();
|
||||
playerApiService.addSynchronizedMineverseChatPlayerToMap(smcp);
|
||||
}
|
||||
out.writeUTF("Sync");
|
||||
@ -521,7 +521,7 @@ public class ProxyController {
|
||||
int muteCount = smcp.getMutes().size();
|
||||
//System.out.println(muteCount);
|
||||
out.write(muteCount);
|
||||
for(MuteContainer muteContainer : smcp.getMutes()) {
|
||||
for(MuteContainer muteContainer : smcp.getMutes().values()) {
|
||||
out.writeUTF(muteContainer.getChannel());
|
||||
out.writeLong(muteContainer.getDuration());
|
||||
out.writeUTF(muteContainer.getReason());
|
||||
@ -529,7 +529,7 @@ public class ProxyController {
|
||||
//System.out.println(smcp.isSpy() + " spy value");
|
||||
//System.out.println(out.size() + " size before");
|
||||
out.writeBoolean(smcp.isSpy());
|
||||
out.writeBoolean(smcp.getMessageToggle());
|
||||
out.writeBoolean(smcp.isMessageToggleEnabled());
|
||||
//System.out.println(out.size() + " size after");
|
||||
int ignoreCount = smcp.getIgnores().size();
|
||||
//System.out.println(ignoreCount + " ignore size");
|
||||
@ -545,16 +545,16 @@ public class ProxyController {
|
||||
UUID uuid = UUID.fromString(in.readUTF());
|
||||
SynchronizedVentureChatPlayer smcp = playerApiService.getSynchronizedMineverseChatPlayer(uuid);
|
||||
if(smcp == null) {
|
||||
smcp = new SynchronizedVentureChatPlayer(uuid);
|
||||
smcp = SynchronizedVentureChatPlayer.builder().uuid(uuid).build();
|
||||
playerApiService.addSynchronizedMineverseChatPlayerToMap(smcp);
|
||||
}
|
||||
smcp.getListening().clear();
|
||||
smcp.clearMutes();
|
||||
smcp.getMutes().clear();
|
||||
smcp.getIgnores().clear();
|
||||
int sizeL = in.read();
|
||||
//System.out.println(sizeL + " listening");
|
||||
for(int a = 0; a < sizeL; a++) {
|
||||
smcp.addListening(in.readUTF());
|
||||
smcp.getListening().add(in.readUTF());
|
||||
}
|
||||
int sizeM = in.read();
|
||||
for(int b = 0; b < sizeM; b++) {
|
||||
@ -562,16 +562,16 @@ public class ProxyController {
|
||||
long muteTime = in.readLong();
|
||||
String muteReason = in.readUTF();
|
||||
//System.out.println(mute);
|
||||
smcp.addMute(mute, muteTime, muteReason);
|
||||
smcp.getMutes().put(mute, new MuteContainer(mute, muteTime, muteReason));
|
||||
}
|
||||
int sizeI = in.read();
|
||||
for(int c = 0; c < sizeI; c++) {
|
||||
String ignore = in.readUTF();
|
||||
//System.out.println(mute);
|
||||
smcp.addIgnore(playerApiService.getSynchronizedMineverseChatPlayer(UUID.fromString(ignore)));
|
||||
smcp.getIgnores().add(UUID.fromString(ignore));
|
||||
}
|
||||
smcp.setSpy(in.readBoolean());
|
||||
smcp.setMessageToggle(in.readBoolean());
|
||||
smcp.setMessageToggleEnabled(in.readBoolean());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,168 +29,168 @@ import venture.Aust1n46.chat.service.ProxyUuidService;
|
||||
*/
|
||||
public class ProxyFlatFileController {
|
||||
@Inject
|
||||
private ProxyUuidService uuidService;
|
||||
private ProxyUuidService uuidService;
|
||||
@Inject
|
||||
private ProxyPlayerApiService playerApiService;
|
||||
|
||||
public void loadLegacyBungeePlayerData(File dataFolder, VentureChatProxySource source) {
|
||||
File sync = new File(dataFolder, "BungeePlayers.yml");
|
||||
if (!sync.exists()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Detected Legacy Player Data!");
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Converting to new structure and deleting old BungeePlayers.yml file!");
|
||||
Configuration playerData = ConfigurationProvider.getProvider(YamlConfiguration.class).load(sync);
|
||||
for (String uuidString : playerData.getKeys()) {
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
if (uuidService.shouldSkipOfflineUUIDProxy(uuid, source)) {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Skipping Offline UUID: " + uuid);
|
||||
continue;
|
||||
}
|
||||
Set<String> listening = new HashSet<String>();
|
||||
StringTokenizer l = new StringTokenizer(playerData.getString(uuidString + ".channels"), ",");
|
||||
while (l.hasMoreTokens()) {
|
||||
String channel = l.nextToken();
|
||||
listening.add(channel);
|
||||
}
|
||||
HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>();
|
||||
StringTokenizer m = new StringTokenizer(playerData.getString(uuidString + ".mutes"), ",");
|
||||
while (m.hasMoreTokens()) {
|
||||
String[] parts = m.nextToken().split(":");
|
||||
String channelName = parts[0];
|
||||
mutes.put(channelName, new MuteContainer(channelName, Long.parseLong(parts[1]), ""));
|
||||
}
|
||||
HashSet<UUID> ignores = new HashSet<UUID>();
|
||||
StringTokenizer n = new StringTokenizer(playerData.getString(uuidString + ".ignores"), ",");
|
||||
while (n.hasMoreTokens()) {
|
||||
String ignore = n.nextToken();
|
||||
ignores.add(UUID.fromString(ignore));
|
||||
}
|
||||
boolean spy = playerData.getBoolean(uuidString + ".spy");
|
||||
boolean messageToggle = playerData.getBoolean(uuidString + ".messagetoggle");
|
||||
playerApiService.addSynchronizedMineverseChatPlayerToMap(new SynchronizedVentureChatPlayer(uuid, listening, mutes, ignores, spy, messageToggle));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
playerApiService.clearProxyPlayerMap();
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Error Loading Legacy Player Data!");
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Deleted BungeePlayers.yml file!");
|
||||
} finally {
|
||||
sync.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadProxyPlayerData(File dataFolder, VentureChatProxySource source) {
|
||||
try {
|
||||
File playerDataDirectory = dataFolder;
|
||||
if (!playerDataDirectory.exists()) {
|
||||
playerDataDirectory.mkdirs();
|
||||
}
|
||||
Files.walk(Paths.get(dataFolder.getAbsolutePath()))
|
||||
.filter(Files::isRegularFile)
|
||||
.forEach((path) -> readProxyPlayerDataFile(path, source));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void loadLegacyBungeePlayerData(File dataFolder, VentureChatProxySource source) {
|
||||
File sync = new File(dataFolder, "BungeePlayers.yml");
|
||||
if (!sync.exists()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Detected Legacy Player Data!");
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Converting to new structure and deleting old BungeePlayers.yml file!");
|
||||
Configuration playerData = ConfigurationProvider.getProvider(YamlConfiguration.class).load(sync);
|
||||
for (String uuidString : playerData.getKeys()) {
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
if (uuidService.shouldSkipOfflineUUIDProxy(uuid, source)) {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Skipping Offline UUID: " + uuid);
|
||||
continue;
|
||||
}
|
||||
Set<String> listening = new HashSet<String>();
|
||||
StringTokenizer l = new StringTokenizer(playerData.getString(uuidString + ".channels"), ",");
|
||||
while (l.hasMoreTokens()) {
|
||||
String channel = l.nextToken();
|
||||
listening.add(channel);
|
||||
}
|
||||
HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>();
|
||||
StringTokenizer m = new StringTokenizer(playerData.getString(uuidString + ".mutes"), ",");
|
||||
while (m.hasMoreTokens()) {
|
||||
String[] parts = m.nextToken().split(":");
|
||||
String channelName = parts[0];
|
||||
mutes.put(channelName, new MuteContainer(channelName, Long.parseLong(parts[1]), ""));
|
||||
}
|
||||
HashSet<UUID> ignores = new HashSet<UUID>();
|
||||
StringTokenizer n = new StringTokenizer(playerData.getString(uuidString + ".ignores"), ",");
|
||||
while (n.hasMoreTokens()) {
|
||||
String ignore = n.nextToken();
|
||||
ignores.add(UUID.fromString(ignore));
|
||||
}
|
||||
boolean spy = playerData.getBoolean(uuidString + ".spy");
|
||||
boolean messageToggle = playerData.getBoolean(uuidString + ".messagetoggle");
|
||||
playerApiService.addSynchronizedMineverseChatPlayerToMap(
|
||||
SynchronizedVentureChatPlayer.builder().uuid(uuid).listening(listening).mutes(mutes).ignores(ignores).spy(spy).messageToggleEnabled(messageToggle).build());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
playerApiService.clearProxyPlayerMap();
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Error Loading Legacy Player Data!");
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Deleted BungeePlayers.yml file!");
|
||||
} finally {
|
||||
sync.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private void readProxyPlayerDataFile(Path path, VentureChatProxySource source) {
|
||||
SynchronizedVentureChatPlayer smcp;
|
||||
File proxyPlayerDataFile = path.toFile();
|
||||
if (!proxyPlayerDataFile.exists()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Configuration proxyPlayerDataFileConfiguration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(proxyPlayerDataFile);
|
||||
String uuidString = proxyPlayerDataFile.getName().replace(".yml", "");
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
if (uuidService.shouldSkipOfflineUUIDProxy(uuid, source)) {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Skipping Offline UUID: " + uuid);
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - File will be skipped and deleted.");
|
||||
proxyPlayerDataFile.delete();
|
||||
return;
|
||||
}
|
||||
Set<String> listening = new HashSet<String>();
|
||||
StringTokenizer l = new StringTokenizer(proxyPlayerDataFileConfiguration.getString("channels"), ",");
|
||||
while (l.hasMoreTokens()) {
|
||||
String channel = l.nextToken();
|
||||
listening.add(channel);
|
||||
}
|
||||
HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>();
|
||||
Configuration muteSection = proxyPlayerDataFileConfiguration.getSection("mutes");
|
||||
for (String channelName : muteSection.getKeys()) {
|
||||
Configuration channelSection = muteSection.getSection(channelName);
|
||||
mutes.put(channelName, new MuteContainer(channelName, channelSection.getLong("time"), channelSection.getString("reason")));
|
||||
}
|
||||
HashSet<UUID> ignores = new HashSet<UUID>();
|
||||
StringTokenizer n = new StringTokenizer(proxyPlayerDataFileConfiguration.getString("ignores"), ",");
|
||||
while (n.hasMoreTokens()) {
|
||||
String ignore = n.nextToken();
|
||||
ignores.add(UUID.fromString(ignore));
|
||||
}
|
||||
boolean spy = proxyPlayerDataFileConfiguration.getBoolean("spy");
|
||||
boolean messageToggle = proxyPlayerDataFileConfiguration.getBoolean("messagetoggle");
|
||||
smcp = new SynchronizedVentureChatPlayer(uuid, listening, mutes, ignores, spy, messageToggle);
|
||||
} catch (Exception e) {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Error Loading Data File: " + proxyPlayerDataFile.getName());
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - File will be skipped and deleted.");
|
||||
proxyPlayerDataFile.delete();
|
||||
return;
|
||||
}
|
||||
if (smcp != null) {
|
||||
playerApiService.addSynchronizedMineverseChatPlayerToMap(smcp);
|
||||
}
|
||||
}
|
||||
public void loadProxyPlayerData(File dataFolder, VentureChatProxySource source) {
|
||||
try {
|
||||
File playerDataDirectory = dataFolder;
|
||||
if (!playerDataDirectory.exists()) {
|
||||
playerDataDirectory.mkdirs();
|
||||
}
|
||||
Files.walk(Paths.get(dataFolder.getAbsolutePath())).filter(Files::isRegularFile).forEach((path) -> readProxyPlayerDataFile(path, source));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveProxyPlayerData(File dataFolder, VentureChatProxySource source) {
|
||||
try {
|
||||
for (SynchronizedVentureChatPlayer p : playerApiService.getSynchronizedMineverseChatPlayers()) {
|
||||
if (uuidService.shouldSkipOfflineUUIDProxy(p.getUUID(), source)) {
|
||||
return;
|
||||
}
|
||||
File proxyPlayerDataFile = new File(dataFolder.getAbsolutePath(), p.getUUID() + ".yml");
|
||||
if (!proxyPlayerDataFile.exists()) {
|
||||
proxyPlayerDataFile.createNewFile();
|
||||
}
|
||||
Configuration proxyPlayerDataFileConfiguration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(proxyPlayerDataFile);
|
||||
private void readProxyPlayerDataFile(Path path, VentureChatProxySource source) {
|
||||
SynchronizedVentureChatPlayer smcp;
|
||||
File proxyPlayerDataFile = path.toFile();
|
||||
if (!proxyPlayerDataFile.exists()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Configuration proxyPlayerDataFileConfiguration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(proxyPlayerDataFile);
|
||||
String uuidString = proxyPlayerDataFile.getName().replace(".yml", "");
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
if (uuidService.shouldSkipOfflineUUIDProxy(uuid, source)) {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Skipping Offline UUID: " + uuid);
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - File will be skipped and deleted.");
|
||||
proxyPlayerDataFile.delete();
|
||||
return;
|
||||
}
|
||||
Set<String> listening = new HashSet<String>();
|
||||
StringTokenizer l = new StringTokenizer(proxyPlayerDataFileConfiguration.getString("channels"), ",");
|
||||
while (l.hasMoreTokens()) {
|
||||
String channel = l.nextToken();
|
||||
listening.add(channel);
|
||||
}
|
||||
HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>();
|
||||
Configuration muteSection = proxyPlayerDataFileConfiguration.getSection("mutes");
|
||||
for (String channelName : muteSection.getKeys()) {
|
||||
Configuration channelSection = muteSection.getSection(channelName);
|
||||
mutes.put(channelName, new MuteContainer(channelName, channelSection.getLong("time"), channelSection.getString("reason")));
|
||||
}
|
||||
HashSet<UUID> ignores = new HashSet<UUID>();
|
||||
StringTokenizer n = new StringTokenizer(proxyPlayerDataFileConfiguration.getString("ignores"), ",");
|
||||
while (n.hasMoreTokens()) {
|
||||
String ignore = n.nextToken();
|
||||
ignores.add(UUID.fromString(ignore));
|
||||
}
|
||||
boolean spy = proxyPlayerDataFileConfiguration.getBoolean("spy");
|
||||
boolean messageToggle = proxyPlayerDataFileConfiguration.getBoolean("messagetoggle");
|
||||
// smcp = new SynchronizedVentureChatPlayer(uuid, listening, mutes, ignores, spy, messageToggle);
|
||||
smcp = SynchronizedVentureChatPlayer.builder().uuid(uuid).listening(listening).mutes(mutes).ignores(ignores).spy(spy).messageToggleEnabled(messageToggle).build();
|
||||
} catch (Exception e) {
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - Error Loading Data File: " + proxyPlayerDataFile.getName());
|
||||
source.sendConsoleMessage("&8[&eVentureChat&8]&c - File will be skipped and deleted.");
|
||||
proxyPlayerDataFile.delete();
|
||||
return;
|
||||
}
|
||||
if (smcp != null) {
|
||||
playerApiService.addSynchronizedMineverseChatPlayerToMap(smcp);
|
||||
}
|
||||
}
|
||||
|
||||
String listen = "";
|
||||
for (String s : p.getListening())
|
||||
listen += s + ",";
|
||||
String ignore = "";
|
||||
for (UUID s : p.getIgnores())
|
||||
ignore += s.toString() + ",";
|
||||
if (listen.length() > 0)
|
||||
listen = listen.substring(0, listen.length() - 1);
|
||||
if (ignore.length() > 0)
|
||||
ignore = ignore.substring(0, ignore.length() - 1);
|
||||
proxyPlayerDataFileConfiguration.set("channels", listen);
|
||||
Configuration muteSection = createSection(proxyPlayerDataFileConfiguration, "mutes");
|
||||
for (MuteContainer mute : p.getMutes()) {
|
||||
Configuration channelSection = createSection(muteSection, mute.getChannel());
|
||||
channelSection.set("time", mute.getDuration());
|
||||
channelSection.set("reason", mute.getReason());
|
||||
}
|
||||
proxyPlayerDataFileConfiguration.set("ignores", ignore);
|
||||
proxyPlayerDataFileConfiguration.set("spy", p.isSpy());
|
||||
proxyPlayerDataFileConfiguration.set("messagetoggle", p.getMessageToggle());
|
||||
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(proxyPlayerDataFileConfiguration, proxyPlayerDataFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void saveProxyPlayerData(File dataFolder, VentureChatProxySource source) {
|
||||
try {
|
||||
for (SynchronizedVentureChatPlayer p : playerApiService.getSynchronizedMineverseChatPlayers()) {
|
||||
if (uuidService.shouldSkipOfflineUUIDProxy(p.getUuid(), source)) {
|
||||
return;
|
||||
}
|
||||
File proxyPlayerDataFile = new File(dataFolder.getAbsolutePath(), p.getUuid() + ".yml");
|
||||
if (!proxyPlayerDataFile.exists()) {
|
||||
proxyPlayerDataFile.createNewFile();
|
||||
}
|
||||
Configuration proxyPlayerDataFileConfiguration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(proxyPlayerDataFile);
|
||||
|
||||
/**
|
||||
* Create a new {@link Configuration} section.
|
||||
*
|
||||
* @param configurationSection
|
||||
* @param sectionKey
|
||||
* @return Configuration
|
||||
*/
|
||||
private Configuration createSection(Configuration configurationSection, String sectionKey) {
|
||||
configurationSection.set(sectionKey, null);
|
||||
return configurationSection.getSection(sectionKey);
|
||||
}
|
||||
String listen = "";
|
||||
for (String s : p.getListening())
|
||||
listen += s + ",";
|
||||
String ignore = "";
|
||||
for (UUID s : p.getIgnores())
|
||||
ignore += s.toString() + ",";
|
||||
if (listen.length() > 0)
|
||||
listen = listen.substring(0, listen.length() - 1);
|
||||
if (ignore.length() > 0)
|
||||
ignore = ignore.substring(0, ignore.length() - 1);
|
||||
proxyPlayerDataFileConfiguration.set("channels", listen);
|
||||
Configuration muteSection = createSection(proxyPlayerDataFileConfiguration, "mutes");
|
||||
for (MuteContainer mute : p.getMutes().values()) {
|
||||
Configuration channelSection = createSection(muteSection, mute.getChannel());
|
||||
channelSection.set("time", mute.getDuration());
|
||||
channelSection.set("reason", mute.getReason());
|
||||
}
|
||||
proxyPlayerDataFileConfiguration.set("ignores", ignore);
|
||||
proxyPlayerDataFileConfiguration.set("spy", p.isSpy());
|
||||
proxyPlayerDataFileConfiguration.set("messagetoggle", p.isMessageToggleEnabled());
|
||||
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(proxyPlayerDataFileConfiguration, proxyPlayerDataFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Configuration} section.
|
||||
*
|
||||
* @param configurationSection
|
||||
* @param sectionKey
|
||||
* @return Configuration
|
||||
*/
|
||||
private Configuration createSection(Configuration configurationSection, String sectionKey) {
|
||||
configurationSection.set(sectionKey, null);
|
||||
return configurationSection.getSection(sectionKey);
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class SpigotFlatFileController {
|
||||
UUID party = playerData.getConfigurationSection("players." + uuidString).getString("party").length() > 0
|
||||
? UUID.fromString(playerData.getConfigurationSection("players." + uuidString).getString("party"))
|
||||
: null;
|
||||
boolean filter = playerData.getConfigurationSection("players." + uuidString).getBoolean("filter");
|
||||
boolean filterEnabled = playerData.getConfigurationSection("players." + uuidString).getBoolean("filter");
|
||||
boolean notifications = playerData.getConfigurationSection("players." + uuidString).getBoolean("notifications");
|
||||
String jsonFormat = "Default";
|
||||
boolean spy = playerData.getConfigurationSection("players." + uuidString).getBoolean("spy", false);
|
||||
@ -124,7 +124,7 @@ public class SpigotFlatFileController {
|
||||
.blockedCommands(blockedCommands)
|
||||
.host(host)
|
||||
.party(party)
|
||||
.filter(filter)
|
||||
.filterEnabled(filterEnabled)
|
||||
.notifications(notifications)
|
||||
.jsonFormat(jsonFormat)
|
||||
.spy(spy)
|
||||
@ -211,7 +211,7 @@ public class SpigotFlatFileController {
|
||||
}
|
||||
boolean host = playerDataFileYamlConfiguration.getBoolean("host");
|
||||
UUID party = playerDataFileYamlConfiguration.getString("party").length() > 0 ? UUID.fromString(playerDataFileYamlConfiguration.getString("party")) : null;
|
||||
boolean filter = playerDataFileYamlConfiguration.getBoolean("filter");
|
||||
boolean filterEnabled = playerDataFileYamlConfiguration.getBoolean("filter");
|
||||
boolean notifications = playerDataFileYamlConfiguration.getBoolean("notifications");
|
||||
String jsonFormat = "Default";
|
||||
boolean spy = playerDataFileYamlConfiguration.getBoolean("spy", false);
|
||||
@ -229,7 +229,7 @@ public class SpigotFlatFileController {
|
||||
.blockedCommands(blockedCommands)
|
||||
.host(host)
|
||||
.party(party)
|
||||
.filter(filter)
|
||||
.filterEnabled(filterEnabled)
|
||||
.notifications(notifications)
|
||||
.jsonFormat(jsonFormat)
|
||||
.spy(spy)
|
||||
@ -292,7 +292,7 @@ public class SpigotFlatFileController {
|
||||
playerDataFileYamlConfiguration.set("blockedcommands", blockedCommands);
|
||||
playerDataFileYamlConfiguration.set("host", mcp.isHost());
|
||||
playerDataFileYamlConfiguration.set("party", mcp.getParty() != null ? mcp.getParty().toString() : "");
|
||||
playerDataFileYamlConfiguration.set("filter", mcp.isFilter());
|
||||
playerDataFileYamlConfiguration.set("filter", mcp.isFilterEnabled());
|
||||
playerDataFileYamlConfiguration.set("notifications", mcp.isNotifications());
|
||||
playerDataFileYamlConfiguration.set("spy", configService.isSpy(mcp));
|
||||
playerDataFileYamlConfiguration.set("commandspy", configService.isCommandSpy(mcp));
|
||||
|
@ -51,7 +51,7 @@ public class Channel extends PlayerCommand {
|
||||
return;
|
||||
ChatChannel channel = event.getChannel();
|
||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(event.getPlayer());
|
||||
if (channel.hasPermission()) {
|
||||
if (channel.isPermissionRequired()) {
|
||||
if (!mcp.getPlayer().hasPermission(channel.getPermission())) {
|
||||
mcp.getListening().remove(channel.getName());
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_PERMISSION.toString());
|
||||
@ -72,7 +72,7 @@ public class Channel extends PlayerCommand {
|
||||
mcp.getListening().add(channel.getName());
|
||||
mcp.setCurrentChannel(channel);
|
||||
mcp.getPlayer().sendMessage(event.getMessage());
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class ChannelAlias extends PlayerCommand {
|
||||
}
|
||||
mcp.getListening().add(channel.getName());
|
||||
mcp.setCurrentChannel(channel);
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
}
|
||||
return;
|
||||
@ -53,7 +53,7 @@ public class ChannelAlias extends PlayerCommand {
|
||||
mcp.setQuickChat(true);
|
||||
mcp.setQuickChannel(channel);
|
||||
mcp.getListening().add(channel.getName());
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
}
|
||||
String msg = "";
|
||||
|
@ -31,7 +31,7 @@ public class Channelinfo extends UniversalCommand {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid channel: " + args[0]);
|
||||
return;
|
||||
}
|
||||
if (chname.hasPermission()) {
|
||||
if (chname.isPermissionRequired()) {
|
||||
if (!sender.hasPermission(chname.getPermission())) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to look at this channel.");
|
||||
return;
|
||||
@ -42,29 +42,29 @@ public class Channelinfo extends UniversalCommand {
|
||||
sender.sendMessage(ChatColor.GOLD + "Color: " + chname.getColor() + chname.getColorRaw());
|
||||
sender.sendMessage(ChatColor.GOLD + "ChatColor: " + (chname.getChatColor().equalsIgnoreCase("None") ? FormatUtils.DEFAULT_COLOR_CODE : chname.getChatColor())
|
||||
+ chname.getChatColorRaw());
|
||||
if (chname.hasPermission()) {
|
||||
if (chname.isPermissionRequired()) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Permission: " + chname.getColor() + chname.getPermission());
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Permission: " + chname.getColor() + "None");
|
||||
}
|
||||
if (chname.hasSpeakPermission()) {
|
||||
if (chname.isSpeakPermissionRequired()) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Speak Permission: " + chname.getColor() + chname.getSpeakPermission());
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Speak Permission: " + chname.getColor() + "None");
|
||||
}
|
||||
sender.sendMessage(ChatColor.GOLD + "Autojoin: " + chname.getColor() + chname.getAutojoin());
|
||||
sender.sendMessage(ChatColor.GOLD + "Default: " + chname.getColor() + chname.hasDistance());
|
||||
if (!chname.hasDistance() || chname.getBungee()) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Autojoin: " + chname.getColor() + chname.isAutoJoinEnabled());
|
||||
sender.sendMessage(ChatColor.GOLD + "Default: " + chname.getColor() + chname.isDefaultChannel());
|
||||
if (chname.getDistance() <= 0 || chname.isBungeeEnabled()) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Distance: " + ChatColor.RED + "N/A");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Distance: " + chname.getColor() + chname.getDistance());
|
||||
}
|
||||
if (!chname.hasCooldown()) {
|
||||
if (chname.getCooldown() <= 0) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Cooldown: " + ChatColor.RED + "N/A");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Cooldown: " + chname.getColor() + chname.getCooldown());
|
||||
}
|
||||
sender.sendMessage(ChatColor.GOLD + "Bungeecord: " + chname.getColor() + chname.getBungee());
|
||||
sender.sendMessage(ChatColor.GOLD + "Bungeecord: " + chname.getColor() + chname.isBungeeEnabled());
|
||||
sender.sendMessage(ChatColor.GOLD + "Format: " + chname.getColor() + chname.getFormat());
|
||||
return;
|
||||
} else {
|
||||
|
@ -81,7 +81,7 @@ public class Chatinfo extends UniversalCommand {
|
||||
} else {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Ranged spy: " + ChatColor.RED + "false");
|
||||
}
|
||||
if (mcp.isFilter()) {
|
||||
if (mcp.isFilterEnabled()) {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Filter: " + ChatColor.GREEN + "true");
|
||||
} else {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Filter: " + ChatColor.RED + "false");
|
||||
@ -141,7 +141,7 @@ public class Chatinfo extends UniversalCommand {
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Ranged spy: " + ChatColor.RED + "false");
|
||||
}
|
||||
if (p.isFilter()) {
|
||||
if (p.isFilterEnabled()) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Filter: " + ChatColor.GREEN + "true");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Filter: " + ChatColor.RED + "false");
|
||||
|
@ -22,7 +22,7 @@ public class Chlist extends UniversalCommand {
|
||||
public void executeCommand(CommandSender sender, String command, String[] args) {
|
||||
sender.sendMessage(LocalizedMessage.CHANNEL_LIST_HEADER.toString());
|
||||
for (ChatChannel chname : configService.getChatChannels()) {
|
||||
if (chname.hasPermission()) {
|
||||
if (chname.isPermissionRequired()) {
|
||||
if (sender.hasPermission(chname.getPermission())) {
|
||||
sender.sendMessage(LocalizedMessage.CHANNEL_LIST_WITH_PERMISSIONS.toString()
|
||||
.replace("{channel_color}", (chname.getColor()).toString())
|
||||
|
@ -47,7 +47,7 @@ public class Chwho extends UniversalCommand {
|
||||
if (args.length > 0) {
|
||||
ChatChannel channel = configService.getChannel(args[0]);
|
||||
if (channel != null) {
|
||||
if (channel.hasPermission()) {
|
||||
if (channel.isPermissionRequired()) {
|
||||
if (!sender.hasPermission(channel.getPermission())) {
|
||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(((Player) sender));
|
||||
mcp.getListening().remove(channel.getName());
|
||||
@ -56,7 +56,7 @@ public class Chwho extends UniversalCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (channel.getBungee() && sender instanceof Player) {
|
||||
if (channel.isBungeeEnabled() && sender instanceof Player) {
|
||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer((Player) sender);
|
||||
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||
@ -82,7 +82,7 @@ public class Chwho extends UniversalCommand {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (channel.hasDistance() && sender instanceof Player) {
|
||||
if (channel.getDistance() > 0 && sender instanceof Player) {
|
||||
if (!this.isPlayerWithinDistance((Player) sender, p.getPlayer(), channel.getDistance())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -22,12 +22,12 @@ public class Filter extends PlayerCommand {
|
||||
public void executeCommand(Player sender, String command, String[] args) {
|
||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer((Player) sender);
|
||||
if (mcp.getPlayer().hasPermission("venturechat.ignorefilter")) {
|
||||
if (!mcp.isFilter()) {
|
||||
mcp.setFilter(true);
|
||||
if (!mcp.isFilterEnabled()) {
|
||||
mcp.setFilterEnabled(true);
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.FILTER_ON.toString());
|
||||
return;
|
||||
}
|
||||
mcp.setFilter(false);
|
||||
mcp.setFilterEnabled(false);
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.FILTER_OFF.toString());
|
||||
return;
|
||||
}
|
||||
|
@ -52,11 +52,11 @@ public class Kickchannel extends UniversalCommand {
|
||||
} else {
|
||||
player.setModified(true);
|
||||
}
|
||||
boolean isThereABungeeChannel = channel.getBungee();
|
||||
boolean isThereABungeeChannel = channel.isBungeeEnabled();
|
||||
if (player.getListening().size() == 0) {
|
||||
player.getListening().add(configService.getDefaultChannel().getName());
|
||||
player.setCurrentChannel(configService.getDefaultChannel());
|
||||
if (configService.getDefaultChannel().getBungee()) {
|
||||
if (configService.getDefaultChannel().isBungeeEnabled()) {
|
||||
isThereABungeeChannel = true;
|
||||
}
|
||||
if (player.isOnline()) {
|
||||
|
@ -42,7 +42,7 @@ public class Kickchannelall extends UniversalCommand {
|
||||
for (String channel : player.getListening()) {
|
||||
if (configService.isChannel(channel)) {
|
||||
ChatChannel chatChannelObj = configService.getChannel(channel);
|
||||
if (chatChannelObj.getBungee()) {
|
||||
if (chatChannelObj.isBungeeEnabled()) {
|
||||
isThereABungeeChannel = true;
|
||||
}
|
||||
}
|
||||
@ -51,7 +51,7 @@ public class Kickchannelall extends UniversalCommand {
|
||||
sender.sendMessage(LocalizedMessage.KICK_CHANNEL_ALL_SENDER.toString().replace("{player}", player.getName()));
|
||||
player.getListening().add(configService.getDefaultChannel().getName());
|
||||
player.setCurrentChannel(configService.getDefaultChannel());
|
||||
if (configService.getDefaultChannel().getBungee()) {
|
||||
if (configService.getDefaultChannel().isBungeeEnabled()) {
|
||||
isThereABungeeChannel = true;
|
||||
}
|
||||
if (isThereABungeeChannel) {
|
||||
|
@ -37,11 +37,11 @@ public class Leave extends PlayerCommand {
|
||||
}
|
||||
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();
|
||||
boolean isThereABungeeChannel = channel.isBungeeEnabled();
|
||||
if (mcp.getListening().size() == 0) {
|
||||
mcp.getListening().add(configService.getDefaultChannel().getName());
|
||||
mcp.setCurrentChannel(configService.getDefaultChannel());
|
||||
if (configService.getDefaultChannel().getBungee()) {
|
||||
if (configService.getDefaultChannel().isBungeeEnabled()) {
|
||||
isThereABungeeChannel = true;
|
||||
}
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.MUST_LISTEN_ONE_CHANNEL.toString());
|
||||
|
@ -34,7 +34,7 @@ public class Listen extends PlayerCommand {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.INVALID_CHANNEL.toString().replace("{args}", args[0]));
|
||||
return;
|
||||
}
|
||||
if (channel.hasPermission()) {
|
||||
if (channel.isPermissionRequired()) {
|
||||
if (!mcp.getPlayer().hasPermission(channel.getPermission())) {
|
||||
mcp.getListening().remove(channel.getName());
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_PERMISSION.toString());
|
||||
@ -44,7 +44,7 @@ public class Listen extends PlayerCommand {
|
||||
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()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
}
|
||||
return;
|
||||
|
@ -31,7 +31,7 @@ public class Me extends UniversalCommand {
|
||||
for (int x = 0; x < args.length; x++)
|
||||
if (args[x].length() > 0)
|
||||
msg += " " + args[x];
|
||||
if (sender instanceof Player && playerApiService.getOnlineMineverseChatPlayer((Player) sender).isFilter()) {
|
||||
if (sender instanceof Player && playerApiService.getOnlineMineverseChatPlayer((Player) sender).isFilterEnabled()) {
|
||||
msg = formatService.filterChat(msg);
|
||||
}
|
||||
if (sender.hasPermission("venturechat.color.legacy")) {
|
||||
|
@ -85,7 +85,7 @@ public class Message extends PlayerCommand {
|
||||
for (int r = 1; r < args.length; r++) {
|
||||
msg += " " + args[r];
|
||||
}
|
||||
if (mcp.isFilter()) {
|
||||
if (mcp.isFilterEnabled()) {
|
||||
msg = formatService.filterChat(msg);
|
||||
}
|
||||
if (mcp.getPlayer().hasPermission("venturechat.color.legacy")) {
|
||||
@ -184,7 +184,7 @@ public class Message extends PlayerCommand {
|
||||
msgBuilder.append(" " + args[r]);
|
||||
}
|
||||
String msg = msgBuilder.toString();
|
||||
if (mcp.isFilter()) {
|
||||
if (mcp.isFilterEnabled()) {
|
||||
msg = formatService.filterChat(msg);
|
||||
}
|
||||
if (mcp.getPlayer().hasPermission("venturechat.color.legacy")) {
|
||||
|
@ -69,7 +69,7 @@ public class Mute extends UniversalCommand {
|
||||
}
|
||||
reason = FormatUtils.FormatStringAll(reasonBuilder.toString().trim());
|
||||
}
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
sendBungeeCordMute(sender, args[1], channel, time, reason);
|
||||
return;
|
||||
}
|
||||
@ -157,7 +157,7 @@ public class Mute extends UniversalCommand {
|
||||
if (args.length == 2) {
|
||||
if (configService.isChannel(args[0])) {
|
||||
ChatChannel chatChannelObj = configService.getChannel(args[0]);
|
||||
if (chatChannelObj.getBungee()) {
|
||||
if (chatChannelObj.isBungeeEnabled()) {
|
||||
StringUtil.copyPartialMatches(args[1], playerApiService.getNetworkPlayerNames(), completions);
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
|
@ -52,7 +52,7 @@ public class Muteall extends UniversalCommand {
|
||||
for (ChatChannel channel : configService.getChatChannels()) {
|
||||
if (channel.isMutable()) {
|
||||
player.getMutes().put(channel.getName(), new MuteContainer(channel.getName(), 0, ""));
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
bungee = true;
|
||||
}
|
||||
}
|
||||
@ -71,7 +71,7 @@ public class Muteall extends UniversalCommand {
|
||||
for (ChatChannel channel : configService.getChatChannels()) {
|
||||
if (channel.isMutable()) {
|
||||
player.getMutes().put(channel.getName(), new MuteContainer(channel.getName(), 0, reason));
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
bungee = true;
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ public class Party extends PlayerCommand {
|
||||
if (args[x].length() > 0)
|
||||
msg += " " + args[x];
|
||||
}
|
||||
if (mcp.isFilter()) {
|
||||
if (mcp.isFilterEnabled()) {
|
||||
msg = formatService.filterChat(msg);
|
||||
}
|
||||
if (mcp.getPlayer().hasPermission("venturechat.color.legacy")) {
|
||||
|
@ -70,7 +70,7 @@ public class Removemessage extends UniversalCommand {
|
||||
sender.sendMessage(LocalizedMessage.INVALID_HASH.toString());
|
||||
return;
|
||||
}
|
||||
if (args.length > 1 && configService.isChannel(args[1]) && configService.getChannel(args[1]).getBungee()) {
|
||||
if (args.length > 1 && configService.isChannel(args[1]) && configService.getChannel(args[1]).isBungeeEnabled()) {
|
||||
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||
try {
|
||||
|
@ -73,7 +73,7 @@ public class Reply extends PlayerCommand {
|
||||
if (args.length > 0) {
|
||||
for (int r = 0; r < args.length; r++)
|
||||
msg += " " + args[r];
|
||||
if (mcp.isFilter()) {
|
||||
if (mcp.isFilterEnabled()) {
|
||||
msg = formatService.filterChat(msg);
|
||||
}
|
||||
if (mcp.getPlayer().hasPermission("venturechat.color.legacy")) {
|
||||
@ -130,7 +130,7 @@ public class Reply extends PlayerCommand {
|
||||
msgBuilder.append(" " + args[r]);
|
||||
}
|
||||
String msg = msgBuilder.toString();
|
||||
if (mcp.isFilter()) {
|
||||
if (mcp.isFilterEnabled()) {
|
||||
msg = formatService.filterChat(msg);
|
||||
}
|
||||
if (mcp.getPlayer().hasPermission("venturechat.color.legacy")) {
|
||||
|
@ -42,7 +42,7 @@ public class Setchannel extends UniversalCommand {
|
||||
sender.sendMessage(LocalizedMessage.INVALID_CHANNEL.toString().replace("{args}", args[1]));
|
||||
return;
|
||||
}
|
||||
if (channel.hasPermission()) {
|
||||
if (channel.isPermissionRequired()) {
|
||||
if (!player.isOnline()) {
|
||||
sender.sendMessage(LocalizedMessage.PLAYER_OFFLINE_NO_PERMISSIONS_CHECK.toString());
|
||||
return;
|
||||
@ -78,7 +78,7 @@ public class Setchannel extends UniversalCommand {
|
||||
else {
|
||||
player.setModified(true);
|
||||
}
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
pluginMessageController.synchronize(player, true);
|
||||
}
|
||||
return;
|
||||
|
@ -39,7 +39,7 @@ public class Setchannelall extends UniversalCommand {
|
||||
}
|
||||
boolean isThereABungeeChannel = false;
|
||||
for (ChatChannel channel : configService.getChatChannels()) {
|
||||
if (channel.hasPermission()) {
|
||||
if (channel.isPermissionRequired()) {
|
||||
if (!player.isOnline()) {
|
||||
sender.sendMessage(LocalizedMessage.PLAYER_OFFLINE_NO_PERMISSIONS_CHECK.toString());
|
||||
return;
|
||||
@ -52,7 +52,7 @@ public class Setchannelall extends UniversalCommand {
|
||||
} else {
|
||||
player.getListening().add(channel.getName());
|
||||
}
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
isThereABungeeChannel = true;
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class Unmute extends UniversalCommand {
|
||||
}
|
||||
if (configService.isChannel(args[0])) {
|
||||
ChatChannel channel = configService.getChannel(args[0]);
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
sendBungeeCordUnmute(sender, args[1], channel);
|
||||
return;
|
||||
}
|
||||
@ -87,7 +87,7 @@ public class Unmute extends UniversalCommand {
|
||||
if (args.length == 2) {
|
||||
if (configService.isChannel(args[0])) {
|
||||
ChatChannel chatChannelObj = configService.getChannel(args[0]);
|
||||
if (chatChannelObj.getBungee()) {
|
||||
if (chatChannelObj.isBungeeEnabled()) {
|
||||
StringUtil.copyPartialMatches(args[1], playerApiService.getNetworkPlayerNames(), completions);
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
|
@ -40,7 +40,7 @@ public class Unmuteall extends UniversalCommand {
|
||||
boolean bungee = false;
|
||||
for (ChatChannel channel : configService.getChatChannels()) {
|
||||
player.getMutes().remove(channel.getName());
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
bungee = true;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
@ -31,9 +30,9 @@ import venture.Aust1n46.chat.model.ChatChannel;
|
||||
import venture.Aust1n46.chat.model.MuteContainer;
|
||||
import venture.Aust1n46.chat.model.VentureChatPlayer;
|
||||
import venture.Aust1n46.chat.service.ConfigService;
|
||||
import venture.Aust1n46.chat.service.VentureChatDatabaseService;
|
||||
import venture.Aust1n46.chat.service.FormatService;
|
||||
import venture.Aust1n46.chat.service.PlayerApiService;
|
||||
import venture.Aust1n46.chat.service.VentureChatDatabaseService;
|
||||
import venture.Aust1n46.chat.utilities.FormatUtils;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -100,7 +99,7 @@ public class ChatListener implements Listener {
|
||||
String echo = "";
|
||||
String send = "";
|
||||
String spy = "";
|
||||
if (ventureChatPlayer.isFilter()) {
|
||||
if (ventureChatPlayer.isFilterEnabled()) {
|
||||
filtered = formatService.filterChat(filtered);
|
||||
}
|
||||
if (ventureChatPlayer.getPlayer().hasPermission("venturechat.color.legacy")) {
|
||||
@ -155,7 +154,7 @@ public class ChatListener implements Listener {
|
||||
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||
if ((p.getParty() != null && p.getParty().toString().equals(ventureChatPlayer.getParty().toString()) || configService.isSpy(p))) {
|
||||
String filtered = chat;
|
||||
if (ventureChatPlayer.isFilter()) {
|
||||
if (ventureChatPlayer.isFilterEnabled()) {
|
||||
filtered = formatService.filterChat(filtered);
|
||||
}
|
||||
if (ventureChatPlayer.getPlayer().hasPermission("venturechat.color.legacy")) {
|
||||
@ -239,7 +238,7 @@ public class ChatListener implements Listener {
|
||||
processPartyChat(mcp, chat);
|
||||
return;
|
||||
}
|
||||
if (eventChannel.hasPermission() && !mcp.getPlayer().hasPermission(eventChannel.getPermission())) {
|
||||
if (eventChannel.isPermissionRequired() && !mcp.getPlayer().hasPermission(eventChannel.getPermission())) {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_PERMISSION.toString());
|
||||
mcp.setQuickChat(false);
|
||||
mcp.getListening().remove(eventChannel.getName());
|
||||
@ -248,7 +247,7 @@ public class ChatListener implements Listener {
|
||||
} else {
|
||||
mcp.getListening().add(eventChannel.getName());
|
||||
}
|
||||
if (eventChannel.hasSpeakPermission() && !mcp.getPlayer().hasPermission(eventChannel.getSpeakPermission())) {
|
||||
if (eventChannel.isSpeakPermissionRequired() && !mcp.getPlayer().hasPermission(eventChannel.getSpeakPermission())) {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_SPEAK_PERMISSIONS.toString());
|
||||
mcp.setQuickChat(false);
|
||||
return;
|
||||
@ -260,7 +259,7 @@ public class ChatListener implements Listener {
|
||||
|
||||
long dateTimeSeconds = System.currentTimeMillis() / FormatUtils.MILLISECONDS_PER_SECOND;
|
||||
int chCooldown = 0;
|
||||
if (eventChannel.hasCooldown()) {
|
||||
if (eventChannel.getCooldown() > 0) {
|
||||
chCooldown = eventChannel.getCooldown();
|
||||
}
|
||||
try {
|
||||
@ -274,7 +273,7 @@ public class ChatListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (eventChannel.hasCooldown()) {
|
||||
if (eventChannel.getCooldown() > 0) {
|
||||
if (!mcp.getPlayer().hasPermission("venturechat.cooldown.bypass")) {
|
||||
mcp.getCooldowns().put(eventChannel, dateTimeSeconds + chCooldown);
|
||||
}
|
||||
@ -306,7 +305,7 @@ public class ChatListener implements Listener {
|
||||
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()));
|
||||
}
|
||||
if (eventChannel.getBungee()) {
|
||||
if (eventChannel.isBungeeEnabled()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
}
|
||||
mcp.getSpam().get(eventChannel).set(0, 0L);
|
||||
@ -333,7 +332,7 @@ public class ChatListener implements Listener {
|
||||
|
||||
format = FormatUtils.FormatStringAll(eventChannel.getFormat());
|
||||
|
||||
if (eventChannel.isFiltered() && mcp.isFilter()) {
|
||||
if (eventChannel.isFiltered() && mcp.isFilterEnabled()) {
|
||||
chat = formatService.filterChat(chat);
|
||||
}
|
||||
PluginManager pluginManager = plugin.getServer().getPluginManager();
|
||||
@ -414,11 +413,8 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
double chDistance = 0D;
|
||||
if (eventChannel.hasDistance()) {
|
||||
chDistance = eventChannel.getDistance();
|
||||
}
|
||||
if (chDistance > (double) 0 && !eventChannel.getBungee() && !configService.isRangedSpy(p)) {
|
||||
double chDistance = Math.max(eventChannel.getDistance(), 0);
|
||||
if (chDistance > (double) 0 && !eventChannel.isBungeeEnabled() && !configService.isRangedSpy(p)) {
|
||||
final Location locreceip = p.getPlayer().getLocation();
|
||||
if (locreceip.getWorld() == mcp.getPlayer().getWorld()) {
|
||||
final Location locsender = mcp.getPlayer().getLocation();
|
||||
@ -470,7 +466,7 @@ public class ChatListener implements Listener {
|
||||
format = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), FormatUtils.FormatStringAll(format)));
|
||||
String message = FormatUtils.stripColor(format + chat); // UTF-8 encoding issues.
|
||||
final VentureChatEvent ventureChatEvent = new VentureChatEvent(mcp, mcp.getName(), plugin.getVaultPermission().getPrimaryGroup(mcp.getPlayer()), eventChannel, recipients,
|
||||
recipientCount, format, chat, globalJSON, message.hashCode(), eventChannel.getBungee());
|
||||
recipientCount, format, chat, globalJSON, message.hashCode(), eventChannel.isBungeeEnabled());
|
||||
plugin.getServer().getPluginManager().callEvent(ventureChatEvent);
|
||||
handleVentureChatEvent(ventureChatEvent);
|
||||
mcp.setQuickChat(false);
|
||||
@ -487,26 +483,19 @@ public class ChatListener implements Listener {
|
||||
String globalJSON = event.getGlobalJSON();
|
||||
int hash = event.getHash();
|
||||
boolean bungee = event.isBungee();
|
||||
|
||||
if (essentialsDiscordHook && channel.isDefaultchannel()) {
|
||||
if (essentialsDiscordHook && channel.isDefaultChannel()) {
|
||||
plugin.getServer().getServicesManager().load(DiscordService.class).sendChatMessage(ventureChatPlayer.getPlayer(), chat);
|
||||
}
|
||||
|
||||
if (!bungee) {
|
||||
if (databaseService.isEnabled()) {
|
||||
databaseService.writeVentureChat(ventureChatPlayer.getUuid().toString(), ventureChatPlayer.getName(), "Local", channel.getName(), chat.replace("'", "''"), "Chat");
|
||||
}
|
||||
|
||||
if (recipientCount == 1) {
|
||||
if (!plugin.getConfig().getString("emptychannelalert", "&6No one is listening to you.").equals("")) {
|
||||
if (!plugin.getConfig().getString("emptychannelalert", "&6No one is listening to you.").isEmpty()) {
|
||||
ventureChatPlayer.getPlayer().sendMessage(FormatUtils.FormatStringAll(plugin.getConfig().getString("emptychannelalert", "&6No one is listening to you.")));
|
||||
}
|
||||
}
|
||||
for (Player p : recipients) {
|
||||
String json = formatService.formatModerationGUI(globalJSON, p, ventureChatPlayer.getName(), channel.getName(), hash);
|
||||
PacketContainer packet = formatService.createPacketPlayOutChat(json);
|
||||
formatService.sendPacketPlayOutChat(p, packet);
|
||||
}
|
||||
formatService.createAndSendChatMessage(globalJSON, channel.getName(), hash, recipients, ventureChatPlayer.getName());
|
||||
plugin.getServer().getConsoleSender().sendMessage(consoleChat);
|
||||
return;
|
||||
} else {
|
||||
|
@ -100,7 +100,7 @@ public class LoginListener implements Listener {
|
||||
}
|
||||
mcp.setJsonFormat(jsonFormat);
|
||||
for (ChatChannel ch : configService.getAutojoinList()) {
|
||||
if (ch.hasPermission()) {
|
||||
if (ch.isPermissionRequired()) {
|
||||
if (mcp.getPlayer().hasPermission(ch.getPermission())) {
|
||||
mcp.getListening().add(ch.getName());
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public class PreProcessCommandListener implements CommandExecutor, Listener {
|
||||
|
||||
if (!configService.areAliasesRegisteredAsCommands()) {
|
||||
for (ChatChannel channel : configService.getChatChannels()) {
|
||||
if (!channel.hasPermission() || mcp.getPlayer().hasPermission(channel.getPermission())) {
|
||||
if (!channel.isPermissionRequired() || mcp.getPlayer().hasPermission(channel.getPermission())) {
|
||||
if (message.equals("/" + channel.getAlias())) {
|
||||
mcp.getPlayer().sendMessage(
|
||||
LocalizedMessage.SET_CHANNEL.toString().replace("{channel_color}", channel.getColor() + "").replace("{channel_name}", channel.getName()));
|
||||
@ -169,7 +169,7 @@ public class PreProcessCommandListener implements CommandExecutor, Listener {
|
||||
}
|
||||
mcp.getListening().add(channel.getName());
|
||||
mcp.setCurrentChannel(channel);
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
@ -178,7 +178,7 @@ public class PreProcessCommandListener implements CommandExecutor, Listener {
|
||||
if (message.toLowerCase().startsWith("/" + channel.getAlias() + " ")) {
|
||||
message = message.substring(channel.getAlias().length() + 1);
|
||||
mcp.getListening().add(channel.getName());
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
}
|
||||
mcp.setQuickChannel(channel);
|
||||
@ -218,7 +218,7 @@ public class PreProcessCommandListener implements CommandExecutor, Listener {
|
||||
mcp.setQuickChat(true);
|
||||
mcp.setQuickChannel(channel);
|
||||
mcp.getListening().add(channel.getName());
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
pluginMessageController.synchronize(mcp, true);
|
||||
}
|
||||
String msg = "";
|
||||
|
@ -52,7 +52,7 @@ public class UnmuteScheduler {
|
||||
iterator.remove();
|
||||
p.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString().replace("{player}", p.getName())
|
||||
.replace("{channel_color}", channel.getColor()).replace("{channel_name}", mute.getChannel()));
|
||||
if (channel.getBungee()) {
|
||||
if (channel.isBungeeEnabled()) {
|
||||
pluginMessageController.synchronize(p, true);
|
||||
}
|
||||
}
|
||||
|
@ -1,335 +1,40 @@
|
||||
package venture.Aust1n46.chat.model;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import venture.Aust1n46.chat.service.FormatService;
|
||||
import venture.Aust1n46.chat.utilities.FormatUtils;
|
||||
|
||||
/**
|
||||
* Chat channel object pojo. Class also contains static initialization methods
|
||||
* for reading chat channels from the config file.
|
||||
*
|
||||
* @author Aust1n46
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
public class ChatChannel {
|
||||
private static final String PERMISSION_PREFIX = "venturechat.";
|
||||
private static final String NO_PERMISSIONS = "venturechat.none";
|
||||
|
||||
public static final String NO_PERMISSIONS = "venturechat.none";
|
||||
|
||||
private String name;
|
||||
private String color;
|
||||
private String colorRaw;
|
||||
private String chatColor;
|
||||
private String chatColorRaw;
|
||||
private String permission;
|
||||
private String speakPermission;
|
||||
private boolean mutable;
|
||||
private String color;
|
||||
private String chatColor;
|
||||
private boolean filtered;
|
||||
private boolean defaultChannel;
|
||||
private boolean autojoin;
|
||||
private String alias;
|
||||
private double distance;
|
||||
private boolean filter;
|
||||
private boolean bungee;
|
||||
private String format;
|
||||
private boolean autoJoinEnabled;
|
||||
private boolean bungeeEnabled;
|
||||
private int cooldown;
|
||||
private String format;
|
||||
private String prefix;
|
||||
|
||||
/**
|
||||
* Parameterized constructor a {@link ChatChannel}.
|
||||
*
|
||||
* @param name
|
||||
* @param color
|
||||
* @param chatColor
|
||||
* @param permission
|
||||
* @param speakPermission
|
||||
* @param mutable
|
||||
* @param filter
|
||||
* @param defaultChannel
|
||||
* @param alias
|
||||
* @param distance
|
||||
* @param autojoin
|
||||
* @param bungee
|
||||
* @param cooldown
|
||||
* @param format
|
||||
*/
|
||||
public ChatChannel(String name, String color, String chatColor, String permission, String speakPermission,
|
||||
boolean mutable, boolean filter, boolean defaultChannel, String alias, double distance, boolean autojoin,
|
||||
boolean bungee, int cooldown, String prefix, String format) {
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
this.chatColor = chatColor;
|
||||
this.permission = PERMISSION_PREFIX + permission;
|
||||
this.speakPermission = PERMISSION_PREFIX + speakPermission;
|
||||
this.mutable = mutable;
|
||||
this.filter = filter;
|
||||
this.defaultChannel = defaultChannel;
|
||||
this.alias = alias;
|
||||
this.distance = distance;
|
||||
this.autojoin = autojoin;
|
||||
this.bungee = bungee;
|
||||
this.cooldown = cooldown;
|
||||
this.format = format;
|
||||
this.prefix = prefix;
|
||||
public boolean isPermissionRequired() {
|
||||
return !NO_PERMISSIONS.equalsIgnoreCase(permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated parameterized constructor a {@link ChatChannel}.
|
||||
*
|
||||
* @param name
|
||||
* @param color
|
||||
* @param chatColor
|
||||
* @param permission
|
||||
* @param speakPermission
|
||||
* @param mutable
|
||||
* @param filter
|
||||
* @param defaultChannel
|
||||
* @param alias
|
||||
* @param distance
|
||||
* @param autojoin
|
||||
* @param bungee
|
||||
* @param cooldown
|
||||
* @param format
|
||||
*/
|
||||
@Deprecated
|
||||
public ChatChannel(String name, String color, String chatColor, String permission, String speakPermission,
|
||||
Boolean mutable, Boolean filter, Boolean defaultChannel, String alias, Double distance, Boolean autojoin,
|
||||
Boolean bungee, int cooldown, String format) {
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
this.chatColor = chatColor;
|
||||
this.permission = PERMISSION_PREFIX + permission;
|
||||
this.speakPermission = PERMISSION_PREFIX + speakPermission;
|
||||
this.mutable = mutable;
|
||||
this.filter = filter;
|
||||
this.defaultChannel = defaultChannel;
|
||||
this.alias = alias;
|
||||
this.distance = distance;
|
||||
this.autojoin = autojoin;
|
||||
this.bungee = bungee;
|
||||
this.cooldown = cooldown;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the format of the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cooldown of the chat channel in seconds.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getCooldown() {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the prefix of the chat channel.
|
||||
* @return String
|
||||
*/
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the chat channel is BungeeCord enabled.
|
||||
*
|
||||
* @return {@link Boolean#TRUE} if the chat channel is BungeeCord enabled,
|
||||
* {@link Boolean#FALSE} otherwise.
|
||||
*/
|
||||
public Boolean getBungee() {
|
||||
return Boolean.valueOf(bungee);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permissions node for the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if autojoin is enabled for the chat channel.
|
||||
*
|
||||
* @return {@link Boolean#TRUE} if autojoin is enabled, {@link Boolean#FALSE}
|
||||
* otherwise.
|
||||
*/
|
||||
public Boolean getAutojoin() {
|
||||
return Boolean.valueOf(autojoin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the chat channel allows muting.
|
||||
*
|
||||
* @return {@link Boolean#TRUE} if muting is allowed, {@link Boolean#FALSE}
|
||||
* otherwise.
|
||||
*/
|
||||
public Boolean isMutable() {
|
||||
return Boolean.valueOf(mutable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatted color of the chat channel.
|
||||
*
|
||||
* @return {@link String}. Returns {@link FormatService#DEFAULT_COLOR_CODE} if the
|
||||
* color is invalid.
|
||||
*/
|
||||
public String getColor() {
|
||||
if (FormatUtils.isValidColor(color)) {
|
||||
return String.valueOf(ChatColor.valueOf(color.toUpperCase()));
|
||||
}
|
||||
if (FormatUtils.isValidHexColor(color)) {
|
||||
return FormatUtils.convertHexColorCodeToBukkitColorCode(color);
|
||||
}
|
||||
return FormatUtils.DEFAULT_COLOR_CODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw color value of the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getColorRaw() {
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatted chat color of the chat channel.
|
||||
*
|
||||
* @return {@link String}. Returns {@link FormatService#DEFAULT_COLOR_CODE} if the chat
|
||||
* color is invalid.
|
||||
*/
|
||||
public String getChatColor() {
|
||||
if (chatColor.equalsIgnoreCase("None")) {
|
||||
return chatColor;
|
||||
}
|
||||
if (FormatUtils.isValidColor(chatColor)) {
|
||||
return String.valueOf(ChatColor.valueOf(chatColor.toUpperCase()));
|
||||
}
|
||||
if (FormatUtils.isValidHexColor(chatColor)) {
|
||||
return FormatUtils.convertHexColorCodeToBukkitColorCode(chatColor);
|
||||
}
|
||||
return FormatUtils.DEFAULT_COLOR_CODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw chat color value of the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getChatColorRaw() {
|
||||
return chatColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the chat channel is the default chat channel.
|
||||
*
|
||||
* @return {@link Boolean#TRUE} if the chat channel is the default chat channel,
|
||||
* {@link Boolean#FALSE} otherwise.
|
||||
*/
|
||||
public Boolean isDefaultchannel() {
|
||||
return Boolean.valueOf(defaultChannel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the alias of the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance of the chat channel in blocks.
|
||||
*
|
||||
* @return {@link Double}
|
||||
*/
|
||||
public Double getDistance() {
|
||||
return Double.valueOf(distance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the chat channel has a distance set.
|
||||
*
|
||||
* @return {@link Boolean#TRUE} if the distance is greater than zero,
|
||||
* {@link Boolean#FALSE} otherwise.
|
||||
*/
|
||||
public Boolean hasDistance() {
|
||||
return Boolean.valueOf(distance > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the chat channel has a cooldown set.
|
||||
*
|
||||
* @return {@link Boolean#TRUE} if the cooldown is greater than zero,
|
||||
* {@link Boolean#FALSE} otherwise.
|
||||
*/
|
||||
public Boolean hasCooldown() {
|
||||
return Boolean.valueOf(cooldown > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the chat channel has a permission set.
|
||||
*
|
||||
* @return {@link Boolean#TRUE} if the permission does not equal
|
||||
* {@link ChatChannel#NO_PERMISSIONS}, {@link Boolean#FALSE} otherwise.
|
||||
*/
|
||||
public Boolean hasPermission() {
|
||||
return Boolean.valueOf(!permission.equalsIgnoreCase(NO_PERMISSIONS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the chat channel has a speak permission set.
|
||||
*
|
||||
* @return true if the speak permission does not equal
|
||||
* {@link ChatChannel#NO_PERMISSIONS}, false otherwise.
|
||||
*/
|
||||
public boolean hasSpeakPermission() {
|
||||
return !speakPermission.equalsIgnoreCase(NO_PERMISSIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the speak permissions node for the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getSpeakPermission() {
|
||||
return speakPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the chat channel has the filter enabled.
|
||||
*
|
||||
* @return {@link Boolean#TRUE} if the chat channel has the filter enabled,
|
||||
* {@link Boolean#FALSE} otherwise.
|
||||
*/
|
||||
public Boolean isFiltered() {
|
||||
return Boolean.valueOf(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the chat channel by name to determine equality.
|
||||
*
|
||||
* @param channel
|
||||
* Object to compare for equality.
|
||||
* @return true if the objects are equal, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object channel) {
|
||||
return channel instanceof ChatChannel && this.name.equals(((ChatChannel) channel).getName());
|
||||
public boolean isSpeakPermissionRequired() {
|
||||
return !NO_PERMISSIONS.equalsIgnoreCase(speakPermission);
|
||||
}
|
||||
}
|
||||
|
@ -1,118 +1,34 @@
|
||||
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.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Builder.Default;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Builder
|
||||
public class SynchronizedVentureChatPlayer {
|
||||
private UUID uuid;
|
||||
private Set<String> listening;
|
||||
private HashMap<String, MuteContainer> mutes;
|
||||
private Set<UUID> ignores;
|
||||
private int messagePackets;
|
||||
private List<String> messageData = new ArrayList<String>();
|
||||
private boolean spy;
|
||||
private boolean messageToggle;
|
||||
|
||||
public SynchronizedVentureChatPlayer(UUID uuid, Set<String> listening, HashMap<String, MuteContainer> mutes, Set<UUID> ignores, boolean spy, boolean messageToggle) {
|
||||
this.uuid = uuid;
|
||||
this.listening = listening;
|
||||
this.mutes = mutes;
|
||||
this.ignores = ignores;
|
||||
this.spy = spy;
|
||||
this.messageToggle = messageToggle;
|
||||
}
|
||||
|
||||
public SynchronizedVentureChatPlayer(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
listening = new HashSet<String>();
|
||||
mutes = new HashMap<String, MuteContainer>();
|
||||
ignores = new HashSet<UUID>();
|
||||
spy = false;
|
||||
messageToggle = true;
|
||||
}
|
||||
|
||||
public List<String> getMessageData() {
|
||||
return this.messageData;
|
||||
}
|
||||
|
||||
public void addData(String s) {
|
||||
this.messageData.add(s);
|
||||
}
|
||||
|
||||
public void clearMessageData() {
|
||||
this.messageData.clear();
|
||||
}
|
||||
|
||||
public int getMessagePackets() {
|
||||
return this.messagePackets;
|
||||
}
|
||||
|
||||
public void incrementMessagePackets() {
|
||||
this.messagePackets++;
|
||||
}
|
||||
|
||||
public void clearMessagePackets() {
|
||||
this.messagePackets = 0;
|
||||
}
|
||||
|
||||
public void addIgnore(SynchronizedVentureChatPlayer smcp) {
|
||||
this.ignores.add(smcp.getUUID());
|
||||
}
|
||||
|
||||
public void removeIgnore(SynchronizedVentureChatPlayer smcp) {
|
||||
this.ignores.remove(smcp.getUUID());
|
||||
}
|
||||
|
||||
public Set<UUID> getIgnores() {
|
||||
return this.ignores;
|
||||
}
|
||||
|
||||
public void addMute(String channel, long time, String reason) {
|
||||
mutes.put(channel, new MuteContainer(channel, time, reason));
|
||||
}
|
||||
|
||||
public void clearMutes() {
|
||||
this.mutes.clear();
|
||||
}
|
||||
|
||||
public Collection<MuteContainer> getMutes() {
|
||||
return this.mutes.values();
|
||||
}
|
||||
|
||||
public void addListening(String channel) {
|
||||
this.listening.add(channel);
|
||||
}
|
||||
|
||||
public void removeListening(String channel) {
|
||||
this.listening.remove(channel);
|
||||
}
|
||||
|
||||
public Set<String> getListening() {
|
||||
return this.listening;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public boolean isSpy() {
|
||||
return this.spy;
|
||||
}
|
||||
|
||||
public void setSpy(boolean spy) {
|
||||
this.spy = spy;
|
||||
}
|
||||
|
||||
public boolean getMessageToggle() {
|
||||
return this.messageToggle;
|
||||
}
|
||||
|
||||
public void setMessageToggle(boolean messageToggle) {
|
||||
this.messageToggle = messageToggle;
|
||||
}
|
||||
}
|
||||
private UUID uuid;
|
||||
@Default
|
||||
private Set<String> listening = new HashSet<>();
|
||||
@Default
|
||||
private HashMap<String, MuteContainer> mutes = new HashMap<>();
|
||||
@Default
|
||||
private Set<UUID> ignores = new HashSet<>();
|
||||
@Default
|
||||
private List<String> messageData = new ArrayList<>();
|
||||
@Default
|
||||
private boolean messageToggleEnabled = true;
|
||||
private boolean spy;
|
||||
private int messagePackets;
|
||||
}
|
||||
|
@ -6,31 +6,31 @@ import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
|
||||
public class TemporaryDataInstance {
|
||||
private final UUID uuid;
|
||||
@Getter
|
||||
private int messagePackets;
|
||||
private final UUID uuid;
|
||||
|
||||
private static final HashMap<UUID, TemporaryDataInstance> temporaryDataInstances = new HashMap<UUID, TemporaryDataInstance>();
|
||||
private static final HashMap<UUID, TemporaryDataInstance> TEMPORARY_DATA_INSTANCES = new HashMap<>();
|
||||
|
||||
private TemporaryDataInstance(UUID uuid) {
|
||||
private TemporaryDataInstance(final UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public static UUID createTemporaryDataInstance() {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
temporaryDataInstances.put(uuid, new TemporaryDataInstance(uuid));
|
||||
final UUID uuid = UUID.randomUUID();
|
||||
TEMPORARY_DATA_INSTANCES.put(uuid, new TemporaryDataInstance(uuid));
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public static TemporaryDataInstance getTemporaryDataInstance(UUID uuid) {
|
||||
return temporaryDataInstances.get(uuid);
|
||||
public static TemporaryDataInstance getTemporaryDataInstance(final UUID uuid) {
|
||||
return TEMPORARY_DATA_INSTANCES.get(uuid);
|
||||
}
|
||||
|
||||
public void incrementMessagePackets() {
|
||||
this.messagePackets++;
|
||||
messagePackets++;
|
||||
}
|
||||
|
||||
public void destroyInstance() {
|
||||
temporaryDataInstances.remove(uuid);
|
||||
TEMPORARY_DATA_INSTANCES.remove(uuid);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class VentureChatPlayer {
|
||||
private boolean editing;
|
||||
private int editHash;
|
||||
@Default
|
||||
private boolean filter = true;
|
||||
private boolean filterEnabled = true;
|
||||
@Default
|
||||
private boolean notifications = true;
|
||||
@Default
|
||||
|
@ -52,7 +52,7 @@ public class VentureChatPlaceholders extends PlaceholderExpansion {
|
||||
case "channel_chatcolor":
|
||||
return currentChannel.getChatColor();
|
||||
case "channel_is_bungee":
|
||||
return currentChannel.getBungee() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
|
||||
return currentChannel.isBungeeEnabled() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
|
||||
case "channel_cooldown":
|
||||
return currentChannel.getCooldown() + "";
|
||||
case "channel_distance":
|
||||
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
@ -25,6 +26,8 @@ import venture.Aust1n46.chat.utilities.FormatUtils;
|
||||
|
||||
@Singleton
|
||||
public class ConfigService {
|
||||
private static final String PERMISSION_PREFIX = "venturechat.";
|
||||
|
||||
@Inject
|
||||
private VentureChat plugin;
|
||||
|
||||
@ -35,31 +38,45 @@ public class ConfigService {
|
||||
private boolean aliasesRegisteredAsCommands;
|
||||
private ChatChannel defaultChatChannel;
|
||||
private String defaultColor;
|
||||
|
||||
|
||||
@Getter
|
||||
private boolean ignoreChatEnabled;
|
||||
@Getter
|
||||
private List<Filter> filters;
|
||||
|
||||
public String getValidColor(final String colorRaw) {
|
||||
if (FormatUtils.isValidColor(colorRaw)) {
|
||||
return String.valueOf(ChatColor.valueOf(colorRaw.toUpperCase()));
|
||||
}
|
||||
if (FormatUtils.isValidHexColor(colorRaw)) {
|
||||
return FormatUtils.convertHexColorCodeToBukkitColorCode(colorRaw);
|
||||
}
|
||||
return FormatUtils.DEFAULT_COLOR_CODE;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void postConstruct() {
|
||||
aliasesRegisteredAsCommands = true;
|
||||
ConfigurationSection cs = plugin.getConfig().getConfigurationSection("channels");
|
||||
for (String key : cs.getKeys(false)) {
|
||||
String color = cs.getString(key + ".color", "white");
|
||||
String chatColor = cs.getString(key + ".chatcolor", "white");
|
||||
String name = key;
|
||||
String permission = cs.getString(key + ".permissions", "None");
|
||||
String speakPermission = cs.getString(key + ".speak_permissions", "None");
|
||||
boolean mutable = cs.getBoolean(key + ".mutable", false);
|
||||
boolean filter = cs.getBoolean(key + ".filter", true);
|
||||
boolean bungee = cs.getBoolean(key + ".bungeecord", false);
|
||||
String format = cs.getString(key + ".format", "Default");
|
||||
boolean defaultChannel = cs.getBoolean(key + ".default", false);
|
||||
String alias = cs.getString(key + ".alias", "None");
|
||||
double distance = cs.getDouble(key + ".distance", (double) 0);
|
||||
int cooldown = cs.getInt(key + ".cooldown", 0);
|
||||
boolean autojoin = cs.getBoolean(key + ".autojoin", false);
|
||||
String prefix = cs.getString(key + ".channel_prefix");
|
||||
ChatChannel chatChannel = new ChatChannel(name, color, chatColor, permission, speakPermission, mutable, filter, defaultChannel, alias, distance, autojoin, bungee,
|
||||
for (final String key : cs.getKeys(false)) {
|
||||
final String colorRaw = cs.getString(key + ".color", "white");
|
||||
final String chatColorRaw = cs.getString(key + ".chatcolor", "white");
|
||||
final String name = key;
|
||||
final String permission = PERMISSION_PREFIX + cs.getString(key + ".permissions", "None");
|
||||
final String speakPermission = PERMISSION_PREFIX + cs.getString(key + ".speak_permissions", "None");
|
||||
final boolean mutable = cs.getBoolean(key + ".mutable", false);
|
||||
final boolean filter = cs.getBoolean(key + ".filter", true);
|
||||
final boolean bungee = cs.getBoolean(key + ".bungeecord", false);
|
||||
final String format = cs.getString(key + ".format", "Default");
|
||||
final boolean defaultChannel = cs.getBoolean(key + ".default", false);
|
||||
final String alias = cs.getString(key + ".alias", "None");
|
||||
final double distance = cs.getDouble(key + ".distance", (double) 0);
|
||||
final int cooldown = cs.getInt(key + ".cooldown", 0);
|
||||
final boolean autojoin = cs.getBoolean(key + ".autojoin", false);
|
||||
final String prefix = cs.getString(key + ".channel_prefix");
|
||||
final String color = getValidColor(colorRaw);
|
||||
final String chatColor = chatColorRaw.equalsIgnoreCase("None") ? "None" : getValidColor(chatColorRaw);
|
||||
final ChatChannel chatChannel = new ChatChannel(name, color, colorRaw, chatColor, chatColorRaw, permission, speakPermission, mutable, filter, defaultChannel, alias, distance, autojoin, bungee,
|
||||
cooldown, prefix, format);
|
||||
chatChannels.put(name.toLowerCase(), chatChannel);
|
||||
chatChannels.put(alias.toLowerCase(), chatChannel);
|
||||
@ -71,7 +88,7 @@ public class ConfigService {
|
||||
// Error handling for missing default channel in the config.
|
||||
if (defaultChatChannel == null) {
|
||||
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&e - &cNo default channel found!"));
|
||||
defaultChatChannel = new ChatChannel("MissingDefault", "red", "red", "None", "None", false, true, true, "md", 0, true, false, 0, "&f[&cMissingDefault&f]",
|
||||
defaultChatChannel = new ChatChannel("MissingDefault", "red", "RED", "red", "RED", ChatChannel.NO_PERMISSIONS, ChatChannel.NO_PERMISSIONS, false, true, true, "md", 0, true, false, 0, "&f[&cMissingDefault&f]",
|
||||
"{venturechat_channel_prefix} {vault_prefix}{player_displayname}&c:");
|
||||
defaultColor = defaultChatChannel.getColor();
|
||||
chatChannels.put("missingdefault", defaultChatChannel);
|
||||
@ -124,6 +141,8 @@ public class ConfigService {
|
||||
.map(x -> x.split(","))
|
||||
.map(x -> new Filter(x[0], x[1]))
|
||||
.toList();
|
||||
|
||||
ignoreChatEnabled = plugin.getConfig().getBoolean("ignorechat", false);
|
||||
}
|
||||
|
||||
public boolean areAliasesRegisteredAsCommands() {
|
||||
@ -164,9 +183,9 @@ public class ConfigService {
|
||||
if (ventureChatPlayer.isOnline()) {
|
||||
if (isChannel(channel)) {
|
||||
ChatChannel chatChannel = getChannel(channel);
|
||||
if (chatChannel.hasPermission()) {
|
||||
if (chatChannel.isPermissionRequired()) {
|
||||
if (!ventureChatPlayer.getPlayer().hasPermission(chatChannel.getPermission())) {
|
||||
if (ventureChatPlayer.getCurrentChannel().equals(chatChannel)) {
|
||||
if (ventureChatPlayer.getCurrentChannel().getName().equals(channel)) {
|
||||
ventureChatPlayer.setCurrentChannel(getDefaultChannel());
|
||||
}
|
||||
ventureChatPlayer.getListening().remove(channel);
|
||||
@ -237,7 +256,7 @@ public class ConfigService {
|
||||
public List<ChatChannel> getAutojoinList() {
|
||||
List<ChatChannel> joinlist = new ArrayList<ChatChannel>();
|
||||
for (ChatChannel c : chatChannels.values()) {
|
||||
if (c.getAutojoin()) {
|
||||
if (c.isAutoJoinEnabled()) {
|
||||
joinlist.add(c);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import static venture.Aust1n46.chat.utilities.FormatUtils.HEX_COLOR_CODE_PREFIX;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
@ -437,7 +438,7 @@ public class FormatService {
|
||||
return s.replace("\\", "\\\\").replace("\"", "\\\"");
|
||||
}
|
||||
|
||||
public String formatModerationGUI(String json, Player player, String sender, String channelName, int hash) {
|
||||
private String formatModerationGUI(String json, Player player, String sender, String channelName, int hash) {
|
||||
if (player.hasPermission("venturechat.gui")) {
|
||||
json = json.substring(0, json.length() - 1);
|
||||
json += "," + convertToJsonColors(FormatUtils.FormatStringAll(plugin.getConfig().getString("guiicon")),
|
||||
@ -502,6 +503,27 @@ public class FormatService {
|
||||
}
|
||||
}
|
||||
|
||||
public void createAndSendChatMessage(final String json, final String channelName, final int hash, final Set<Player> recipients, final String sender) {
|
||||
for (final Player player : recipients) {
|
||||
final String finalJson = formatModerationGUI(json, player, sender, channelName, hash);
|
||||
final PacketContainer packet = createPacketPlayOutChat(finalJson);
|
||||
sendPacketPlayOutChat(player, packet);
|
||||
}
|
||||
}
|
||||
|
||||
public void createAndSendExternalChatMessage(final String message, final String channelName, final String sender) {
|
||||
final String json = convertPlainTextToJson(message, true);
|
||||
final int hash = FormatUtils.stripColor(message).hashCode();
|
||||
playerApiService.getOnlineMineverseChatPlayers()
|
||||
.stream()
|
||||
.filter(vcp -> configService.isListening(vcp, channelName))
|
||||
.forEach(vcp -> {
|
||||
final String finalJSON = formatModerationGUI(json, vcp.getPlayer(), sender, channelName, hash);
|
||||
final PacketContainer packet = createPacketPlayOutChat(finalJSON);
|
||||
sendPacketPlayOutChat(vcp.getPlayer(), packet);
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public String toColoredText(Object o, Class<?> c) {
|
||||
if (versionService.is1_7()) {
|
||||
|
@ -13,7 +13,7 @@ public class ProxyPlayerApiService {
|
||||
private final HashMap<UUID, SynchronizedVentureChatPlayer> proxyPlayerMap = new HashMap<>();
|
||||
|
||||
public void addSynchronizedMineverseChatPlayerToMap(SynchronizedVentureChatPlayer smcp) {
|
||||
proxyPlayerMap.put(smcp.getUUID(), smcp);
|
||||
proxyPlayerMap.put(smcp.getUuid(), smcp);
|
||||
}
|
||||
|
||||
public void clearProxyPlayerMap() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user