mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 10:39:05 +00:00
Replace static access to Bukkit
This commit is contained in:
parent
cc791c2dae
commit
d5822b8840
@ -11,7 +11,6 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -90,7 +89,7 @@ public class PluginMessageController {
|
|||||||
// System.out.println(mcp.getPlayer().getServer().getServerName());
|
// System.out.println(mcp.getPlayer().getServer().getServerName());
|
||||||
// out.writeUTF(mcp.getPlayer().getServer().getServerName());
|
// out.writeUTF(mcp.getPlayer().getServer().getServerName());
|
||||||
out.writeUTF(mcp.getUuid().toString());
|
out.writeUTF(mcp.getUuid().toString());
|
||||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!mcp.isOnline() || mcp.isHasPlayed()) {
|
if (!mcp.isOnline() || mcp.isHasPlayed()) {
|
||||||
@ -195,18 +194,18 @@ public class PluginMessageController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Create VentureChatEvent
|
// Create VentureChatEvent
|
||||||
VentureChatEvent ventureChatEvent = new VentureChatEvent(null, senderName, primaryGroup, chatChannelObject, recipients, recipients.size(), format, chat,
|
VentureChatEvent ventureChatEvent = new VentureChatEvent(null, senderName, primaryGroup, chatChannelObject, recipients, recipients.size(), format, chat,
|
||||||
globalJSON, hash, false);
|
globalJSON, hash, false);
|
||||||
// Fire event and wait for other plugin listeners to act on it
|
// Fire event and wait for other plugin listeners to act on it
|
||||||
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
|
plugin.getServer().getPluginManager().callEvent(ventureChatEvent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Bukkit.getConsoleSender().sendMessage(consoleChat);
|
plugin.getServer().getConsoleSender().sendMessage(consoleChat);
|
||||||
|
|
||||||
if (databaseService.isEnabled()) {
|
if (databaseService.isEnabled()) {
|
||||||
databaseService.writeVentureChat(senderUUID.toString(), senderName, server, chatchannel, chat.replace("'", "''"), "Chat");
|
databaseService.writeVentureChat(senderUUID.toString(), senderName, server, chatchannel, chat.replace("'", "''"), "Chat");
|
||||||
@ -314,7 +313,7 @@ public class PluginMessageController {
|
|||||||
}
|
}
|
||||||
if (subchannel.equals("Sync")) {
|
if (subchannel.equals("Sync")) {
|
||||||
if (plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
if (plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&e - Received update..."));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&e - Received update..."));
|
||||||
}
|
}
|
||||||
String uuid = msgin.readUTF();
|
String uuid = msgin.readUTF();
|
||||||
VentureChatPlayer p = playerApiService.getOnlineMineverseChatPlayer(UUID.fromString(uuid));
|
VentureChatPlayer p = playerApiService.getOnlineMineverseChatPlayer(UUID.fromString(uuid));
|
||||||
@ -515,7 +514,7 @@ public class PluginMessageController {
|
|||||||
String timeString = FormatUtils.parseTimeStringFromMillis(time);
|
String timeString = FormatUtils.parseTimeStringFromMillis(time);
|
||||||
if (reason.isEmpty()) {
|
if (reason.isEmpty()) {
|
||||||
if (senderIdentifier.equals("VentureChat:Console")) {
|
if (senderIdentifier.equals("VentureChat:Console")) {
|
||||||
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString().replace("{player}", playerToMute)
|
plugin.getServer().getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString().replace("{player}", playerToMute)
|
||||||
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()).replace("{time}", timeString));
|
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()).replace("{time}", timeString));
|
||||||
} else {
|
} else {
|
||||||
UUID sender = UUID.fromString(senderIdentifier);
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
@ -525,7 +524,7 @@ public class PluginMessageController {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (senderIdentifier.equals("VentureChat:Console")) {
|
if (senderIdentifier.equals("VentureChat:Console")) {
|
||||||
Bukkit.getConsoleSender()
|
plugin.getServer().getConsoleSender()
|
||||||
.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME_REASON.toString().replace("{player}", playerToMute)
|
.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME_REASON.toString().replace("{player}", playerToMute)
|
||||||
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName())
|
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName())
|
||||||
.replace("{time}", timeString).replace("{reason}", reason));
|
.replace("{time}", timeString).replace("{reason}", reason));
|
||||||
@ -541,7 +540,7 @@ public class PluginMessageController {
|
|||||||
} else {
|
} else {
|
||||||
if (reason.isEmpty()) {
|
if (reason.isEmpty()) {
|
||||||
if (senderIdentifier.equals("VentureChat:Console")) {
|
if (senderIdentifier.equals("VentureChat:Console")) {
|
||||||
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString().replace("{player}", playerToMute)
|
plugin.getServer().getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString().replace("{player}", playerToMute)
|
||||||
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()));
|
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()));
|
||||||
} else {
|
} else {
|
||||||
UUID sender = UUID.fromString(senderIdentifier);
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
@ -551,7 +550,7 @@ public class PluginMessageController {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (senderIdentifier.equals("VentureChat:Console")) {
|
if (senderIdentifier.equals("VentureChat:Console")) {
|
||||||
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_REASON.toString().replace("{player}", playerToMute)
|
plugin.getServer().getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_REASON.toString().replace("{player}", playerToMute)
|
||||||
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()).replace("{reason}", reason));
|
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()).replace("{reason}", reason));
|
||||||
} else {
|
} else {
|
||||||
UUID sender = UUID.fromString(senderIdentifier);
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
@ -567,7 +566,7 @@ public class PluginMessageController {
|
|||||||
String senderIdentifier = msgin.readUTF();
|
String senderIdentifier = msgin.readUTF();
|
||||||
String playerToMute = msgin.readUTF();
|
String playerToMute = msgin.readUTF();
|
||||||
if (senderIdentifier.equals("VentureChat:Console")) {
|
if (senderIdentifier.equals("VentureChat:Console")) {
|
||||||
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString().replace("{args}", playerToMute));
|
plugin.getServer().getConsoleSender().sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString().replace("{args}", playerToMute));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UUID sender = UUID.fromString(senderIdentifier);
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
@ -584,7 +583,7 @@ public class PluginMessageController {
|
|||||||
}
|
}
|
||||||
ChatChannel chatChannelObj = configService.getChannel(channelName);
|
ChatChannel chatChannelObj = configService.getChannel(channelName);
|
||||||
if (senderIdentifier.equals("VentureChat:Console")) {
|
if (senderIdentifier.equals("VentureChat:Console")) {
|
||||||
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.PLAYER_ALREADY_MUTED.toString().replace("{player}", playerToMute)
|
plugin.getServer().getConsoleSender().sendMessage(LocalizedMessage.PLAYER_ALREADY_MUTED.toString().replace("{player}", playerToMute)
|
||||||
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()));
|
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -650,7 +649,7 @@ public class PluginMessageController {
|
|||||||
}
|
}
|
||||||
ChatChannel chatChannelObj = configService.getChannel(channelName);
|
ChatChannel chatChannelObj = configService.getChannel(channelName);
|
||||||
if (senderIdentifier.equals("VentureChat:Console")) {
|
if (senderIdentifier.equals("VentureChat:Console")) {
|
||||||
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.UNMUTE_PLAYER_SENDER.toString().replace("{player}", playerToUnmute)
|
plugin.getServer().getConsoleSender().sendMessage(LocalizedMessage.UNMUTE_PLAYER_SENDER.toString().replace("{player}", playerToUnmute)
|
||||||
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()));
|
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()));
|
||||||
} else {
|
} else {
|
||||||
UUID sender = UUID.fromString(senderIdentifier);
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
@ -664,7 +663,7 @@ public class PluginMessageController {
|
|||||||
String senderIdentifier = msgin.readUTF();
|
String senderIdentifier = msgin.readUTF();
|
||||||
String playerToUnmute = msgin.readUTF();
|
String playerToUnmute = msgin.readUTF();
|
||||||
if (senderIdentifier.equals("VentureChat:Console")) {
|
if (senderIdentifier.equals("VentureChat:Console")) {
|
||||||
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString().replace("{args}", playerToUnmute));
|
plugin.getServer().getConsoleSender().sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString().replace("{args}", playerToUnmute));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UUID sender = UUID.fromString(senderIdentifier);
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
@ -681,7 +680,7 @@ public class PluginMessageController {
|
|||||||
}
|
}
|
||||||
ChatChannel chatChannelObj = configService.getChannel(channelName);
|
ChatChannel chatChannelObj = configService.getChannel(channelName);
|
||||||
if (senderIdentifier.equals("VentureChat:Console")) {
|
if (senderIdentifier.equals("VentureChat:Console")) {
|
||||||
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.PLAYER_NOT_MUTED.toString().replace("{player}", playerToUnmute)
|
plugin.getServer().getConsoleSender().sendMessage(LocalizedMessage.PLAYER_NOT_MUTED.toString().replace("{player}", playerToUnmute)
|
||||||
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()));
|
.replace("{channel_color}", chatChannelObj.getColor()).replace("{channel_name}", chatChannelObj.getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import java.util.Set;
|
|||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -59,13 +58,14 @@ public class VentureChatSpigotFlatFileController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Detected Legacy Player Data!"));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Detected Legacy Player Data!"));
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Converting to new structure and deleting old Players.yml file!"));
|
plugin.getServer().getConsoleSender()
|
||||||
|
.sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Converting to new structure and deleting old Players.yml file!"));
|
||||||
FileConfiguration playerData = YamlConfiguration.loadConfiguration(legacyPlayerDataFile);
|
FileConfiguration playerData = YamlConfiguration.loadConfiguration(legacyPlayerDataFile);
|
||||||
for (String uuidString : playerData.getConfigurationSection("players").getKeys(false)) {
|
for (String uuidString : playerData.getConfigurationSection("players").getKeys(false)) {
|
||||||
UUID uuid = UUID.fromString(uuidString);
|
UUID uuid = UUID.fromString(uuidString);
|
||||||
if (uuidService.shouldSkipOfflineUUID(uuid)) {
|
if (uuidService.shouldSkipOfflineUUID(uuid)) {
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Skipping Offline UUID: " + uuid));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Skipping Offline UUID: " + uuid));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String name = playerData.getConfigurationSection("players." + uuid).getString("name");
|
String name = playerData.getConfigurationSection("players." + uuid).getString("name");
|
||||||
@ -90,7 +90,7 @@ public class VentureChatSpigotFlatFileController {
|
|||||||
String[] parts = m.nextToken().split(":");
|
String[] parts = m.nextToken().split(":");
|
||||||
if (configService.isChannel(parts[0])) {
|
if (configService.isChannel(parts[0])) {
|
||||||
if (parts[1].equals("null")) {
|
if (parts[1].equals("null")) {
|
||||||
Bukkit.getConsoleSender().sendMessage("[VentureChat] Null Mute Time: " + parts[0] + " " + name);
|
plugin.getServer().getConsoleSender().sendMessage("[VentureChat] Null Mute Time: " + parts[0] + " " + name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String channelName = parts[0];
|
String channelName = parts[0];
|
||||||
@ -103,7 +103,9 @@ public class VentureChatSpigotFlatFileController {
|
|||||||
blockedCommands.add(b.nextToken());
|
blockedCommands.add(b.nextToken());
|
||||||
}
|
}
|
||||||
boolean host = playerData.getConfigurationSection("players." + uuidString).getBoolean("host");
|
boolean host = playerData.getConfigurationSection("players." + uuidString).getBoolean("host");
|
||||||
UUID party = playerData.getConfigurationSection("players." + uuidString).getString("party").length() > 0 ? UUID.fromString(playerData.getConfigurationSection("players." + uuidString).getString("party")) : null;
|
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 filter = playerData.getConfigurationSection("players." + uuidString).getBoolean("filter");
|
||||||
boolean notifications = playerData.getConfigurationSection("players." + uuidString).getBoolean("notifications");
|
boolean notifications = playerData.getConfigurationSection("players." + uuidString).getBoolean("notifications");
|
||||||
String jsonFormat = "Default";
|
String jsonFormat = "Default";
|
||||||
@ -112,7 +114,8 @@ public class VentureChatSpigotFlatFileController {
|
|||||||
boolean rangedSpy = playerData.getConfigurationSection("players." + uuidString).getBoolean("rangedspy", false);
|
boolean rangedSpy = playerData.getConfigurationSection("players." + uuidString).getBoolean("rangedspy", false);
|
||||||
boolean messageToggle = playerData.getConfigurationSection("players." + uuidString).getBoolean("messagetoggle", true);
|
boolean messageToggle = playerData.getConfigurationSection("players." + uuidString).getBoolean("messagetoggle", true);
|
||||||
boolean bungeeToggle = playerData.getConfigurationSection("players." + uuidString).getBoolean("bungeetoggle", 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);
|
VentureChatPlayer mcp = new VentureChatPlayer(uuid, name, currentChannel, ignores, listening, mutes, blockedCommands, host, party, filter, notifications,
|
||||||
|
jsonFormat, spy, commandSpy, rangedSpy, messageToggle, bungeeToggle);
|
||||||
mcp.setModified(true);
|
mcp.setModified(true);
|
||||||
ventureChatApi.addMineverseChatPlayerToMap(mcp);
|
ventureChatApi.addMineverseChatPlayerToMap(mcp);
|
||||||
ventureChatApi.addNameToMap(mcp);
|
ventureChatApi.addNameToMap(mcp);
|
||||||
@ -120,8 +123,8 @@ public class VentureChatSpigotFlatFileController {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ventureChatApi.clearMineverseChatPlayerMap();
|
ventureChatApi.clearMineverseChatPlayerMap();
|
||||||
ventureChatApi.clearNameMap();
|
ventureChatApi.clearNameMap();
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Error Loading Legacy Player Data!"));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Error Loading Legacy Player Data!"));
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Deleted Players.yml file!"));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Deleted Players.yml file!"));
|
||||||
} finally {
|
} finally {
|
||||||
legacyPlayerDataFile.delete();
|
legacyPlayerDataFile.delete();
|
||||||
}
|
}
|
||||||
@ -133,16 +136,15 @@ public class VentureChatSpigotFlatFileController {
|
|||||||
if (!playerDataDirectory.exists()) {
|
if (!playerDataDirectory.exists()) {
|
||||||
playerDataDirectory.mkdirs();
|
playerDataDirectory.mkdirs();
|
||||||
}
|
}
|
||||||
Files.walk(Paths.get(playerDataDirectoryPath))
|
Files.walk(Paths.get(playerDataDirectoryPath)).filter(Files::isRegularFile).forEach((path) -> readPlayerDataFile(path));
|
||||||
.filter(Files::isRegularFile)
|
|
||||||
.forEach((path) -> readPlayerDataFile(path));
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the player data file for a specific player. Corrupt/invalid data files are skipped and deleted.
|
* Loads the player data file for a specific player. Corrupt/invalid data files
|
||||||
|
* are skipped and deleted.
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
*/
|
*/
|
||||||
@ -157,8 +159,8 @@ public class VentureChatSpigotFlatFileController {
|
|||||||
String uuidString = playerDataFile.getName().replace(".yml", "");
|
String uuidString = playerDataFile.getName().replace(".yml", "");
|
||||||
UUID uuid = UUID.fromString(uuidString);
|
UUID uuid = UUID.fromString(uuidString);
|
||||||
if (uuidService.shouldSkipOfflineUUID(uuid)) {
|
if (uuidService.shouldSkipOfflineUUID(uuid)) {
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Skipping Offline UUID: " + uuid));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Skipping Offline UUID: " + uuid));
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - File will be skipped and deleted."));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - File will be skipped and deleted."));
|
||||||
playerDataFile.delete();
|
playerDataFile.delete();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -200,10 +202,11 @@ public class VentureChatSpigotFlatFileController {
|
|||||||
boolean rangedSpy = playerDataFileYamlConfiguration.getBoolean("rangedspy", false);
|
boolean rangedSpy = playerDataFileYamlConfiguration.getBoolean("rangedspy", false);
|
||||||
boolean messageToggle = playerDataFileYamlConfiguration.getBoolean("messagetoggle", true);
|
boolean messageToggle = playerDataFileYamlConfiguration.getBoolean("messagetoggle", true);
|
||||||
boolean bungeeToggle = playerDataFileYamlConfiguration.getBoolean("bungeetoggle", 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 = new VentureChatPlayer(uuid, name, currentChannel, ignores, listening, mutes, blockedCommands, host, party, filter, notifications, jsonFormat, spy, commandSpy,
|
||||||
|
rangedSpy, messageToggle, bungeeToggle);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Error Loading Data File: " + playerDataFile.getName()));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Error Loading Data File: " + playerDataFile.getName()));
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - File will be skipped and deleted."));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - File will be skipped and deleted."));
|
||||||
playerDataFile.delete();
|
playerDataFile.delete();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package venture.Aust1n46.chat.initators.commands;
|
package venture.Aust1n46.chat.initators.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@ -40,7 +39,7 @@ public class Channel extends PlayerCommand {
|
|||||||
ChatChannel channel = configService.getChannel(args[0]);
|
ChatChannel channel = configService.getChannel(args[0]);
|
||||||
ChannelJoinEvent channelJoinEvent = new ChannelJoinEvent(mcp.getPlayer(), channel,
|
ChannelJoinEvent channelJoinEvent = new ChannelJoinEvent(mcp.getPlayer(), channel,
|
||||||
LocalizedMessage.SET_CHANNEL.toString().replace("{channel_color}", channel.getColor() + "").replace("{channel_name}", channel.getName()));
|
LocalizedMessage.SET_CHANNEL.toString().replace("{channel_color}", channel.getColor() + "").replace("{channel_name}", channel.getName()));
|
||||||
Bukkit.getServer().getPluginManager().callEvent(channelJoinEvent);
|
plugin.getServer().getPluginManager().callEvent(channelJoinEvent);
|
||||||
handleChannelJoinEvent(channelJoinEvent);
|
handleChannelJoinEvent(channelJoinEvent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package venture.Aust1n46.chat.initators.commands;
|
package venture.Aust1n46.chat.initators.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -29,7 +28,7 @@ public class Chatinfo extends UniversalCommand {
|
|||||||
if (sender.hasPermission("venturechat.chatinfo")) {
|
if (sender.hasPermission("venturechat.chatinfo")) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "This command must be run by a player; use /ci [name]");
|
plugin.getServer().getConsoleSender().sendMessage(ChatColor.RED + "This command must be run by a player; use /ci [name]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer((Player) sender);
|
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer((Player) sender);
|
||||||
|
@ -2,7 +2,6 @@ package venture.Aust1n46.chat.initators.commands;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -49,9 +48,9 @@ public class Chatreload extends UniversalCommand {
|
|||||||
for (Player p : plugin.getServer().getOnlinePlayers()) {
|
for (Player p : plugin.getServer().getOnlinePlayers()) {
|
||||||
VentureChatPlayer mcp = playerApiService.getMineverseChatPlayer(p);
|
VentureChatPlayer mcp = playerApiService.getMineverseChatPlayer(p);
|
||||||
if (mcp == null) {
|
if (mcp == null) {
|
||||||
Bukkit.getConsoleSender()
|
plugin.getServer().getConsoleSender()
|
||||||
.sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Could not find player data post reload for currently online player: " + p.getName()));
|
.sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Could not find player data post reload for currently online player: " + p.getName()));
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - There could be an issue with your player data saving."));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - There could be an issue with your player data saving."));
|
||||||
String name = p.getName();
|
String name = p.getName();
|
||||||
UUID uuid = p.getUniqueId();
|
UUID uuid = p.getUniqueId();
|
||||||
mcp = new VentureChatPlayer(uuid, name, configService.getDefaultChannel());
|
mcp = new VentureChatPlayer(uuid, name, configService.getDefaultChannel());
|
||||||
@ -72,7 +71,7 @@ public class Chatreload extends UniversalCommand {
|
|||||||
playerApiService.addNameToMap(mcp);
|
playerApiService.addNameToMap(mcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&e - Config reloaded"));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&e - Config reloaded"));
|
||||||
for (VentureChatPlayer player : playerApiService.getOnlineMineverseChatPlayers()) {
|
for (VentureChatPlayer player : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||||
if (player.getPlayer().hasPermission("venturechat.reload")) {
|
if (player.getPlayer().hasPermission("venturechat.reload")) {
|
||||||
player.getPlayer().sendMessage(LocalizedMessage.CONFIG_RELOADED.toString());
|
player.getPlayer().sendMessage(LocalizedMessage.CONFIG_RELOADED.toString());
|
||||||
|
@ -72,11 +72,6 @@ public class Party extends PlayerCommand {
|
|||||||
if (player != null) {
|
if (player != null) {
|
||||||
if (player.isHost()) {
|
if (player.isHost()) {
|
||||||
if (!mcp.hasParty()) {
|
if (!mcp.hasParty()) {
|
||||||
/*
|
|
||||||
* if(plugin.getMetadata(player, "MineverseChat.party.ban." + tp.getName(),
|
|
||||||
* plugin)) { player.sendMessage(ChatColor.RED + "You are banned from " +
|
|
||||||
* tp.getName() + "'s party."); break; }
|
|
||||||
*/
|
|
||||||
mcp.getPlayer().sendMessage(ChatColor.GREEN + "Joined " + player.getName() + "'s party.");
|
mcp.getPlayer().sendMessage(ChatColor.GREEN + "Joined " + player.getName() + "'s party.");
|
||||||
mcp.setParty(player.getUuid());
|
mcp.setParty(player.getUuid());
|
||||||
player.getPlayer().sendMessage(ChatColor.GREEN + mcp.getName() + " joined your party.");
|
player.getPlayer().sendMessage(ChatColor.GREEN + mcp.getName() + " joined your party.");
|
||||||
@ -151,37 +146,6 @@ public class Party extends PlayerCommand {
|
|||||||
mcp.getPlayer().sendMessage(ChatColor.RED + "You are not hosting a party.");
|
mcp.getPlayer().sendMessage(ChatColor.RED + "You are not hosting a party.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* case "ban": { if(mcp.isHost()) { if(args.length > 1) { Player tp =
|
|
||||||
* Bukkit.getPlayer(args[1]); if(tp != null) {
|
|
||||||
* if(!tp.getName().equals(player.getName())) {
|
|
||||||
* tp.setMetadata("MineverseChat.party.ban." + player.getUniqueId().toString(),
|
|
||||||
* new FixedMetadataValue(plugin, true)); if(plugin.getMetadataString(tp,
|
|
||||||
* "MineverseChat.party", plugin).equals(plugin.getMetadataString(player,
|
|
||||||
* "MineverseChat.party", plugin))) { tp.setMetadata("MineverseChat.party", new
|
|
||||||
* FixedMetadataValue(plugin, "")); } tp.sendMessage(ChatColor.RED +
|
|
||||||
* "You have been banned from " + player.getName() + "'s party.");
|
|
||||||
* player.sendMessage(ChatColor.RED + "You have banned " + tp.getName() +
|
|
||||||
* " from your party."); break; } player.sendMessage(ChatColor.RED +
|
|
||||||
* "You cannot ban yourself."); break; } player.sendMessage(ChatColor.RED +
|
|
||||||
* "Player: " + ChatColor.GOLD + args[1] + ChatColor.RED + " is not online.");
|
|
||||||
* break; } player.sendMessage(ChatColor.RED +
|
|
||||||
* "Invalid command: /party ban [playername]"); break; }
|
|
||||||
* player.sendMessage(ChatColor.RED + "You are not hosting a party."); break; }
|
|
||||||
* case "unban": { if(plugin.getMetadata(player, "MineverseChat.party.host",
|
|
||||||
* plugin)) { if(args.length > 1) { Player tp = Bukkit.getPlayer(args[1]); if(tp
|
|
||||||
* != null) { if(!tp.getName().equals(player.getName())) {
|
|
||||||
* tp.setMetadata("MineverseChat.party.ban." + player.getUniqueId(), new
|
|
||||||
* FixedMetadataValue(plugin, false)); tp.sendMessage(ChatColor.RED +
|
|
||||||
* "You have been unbanned from " + player.getName() + "'s party.");
|
|
||||||
* player.sendMessage(ChatColor.RED + "You have unbanned " + tp.getName() +
|
|
||||||
* " from your party."); break; } player.sendMessage(ChatColor.RED +
|
|
||||||
* "You cannot unban yourself."); break; } player.sendMessage(ChatColor.RED +
|
|
||||||
* "Player: " + ChatColor.GOLD + args[1] + ChatColor.RED + " is not online.");
|
|
||||||
* break; } player.sendMessage(ChatColor.RED +
|
|
||||||
* "Invalid command: /party unban [playername]"); break; }
|
|
||||||
* player.sendMessage(ChatColor.RED + "You are not hosting a party."); break; }
|
|
||||||
*/
|
|
||||||
case "info": {
|
case "info": {
|
||||||
if (!mcp.getPlayer().hasPermission("venturechat.party.info")) {
|
if (!mcp.getPlayer().hasPermission("venturechat.party.info")) {
|
||||||
mcp.getPlayer().sendMessage(ChatColor.RED + "You do not have permission for this command!");
|
mcp.getPlayer().sendMessage(ChatColor.RED + "You do not have permission for this command!");
|
||||||
|
@ -3,7 +3,6 @@ package venture.Aust1n46.chat.initators.commands;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -79,7 +78,7 @@ public class VentureChatGui extends PlayerCommand {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void openInventory(VentureChatPlayer mcp, VentureChatPlayer target, ChatChannel channel, int hash) {
|
private void openInventory(VentureChatPlayer mcp, VentureChatPlayer target, ChatChannel channel, int hash) {
|
||||||
Inventory inv = Bukkit.createInventory(null, this.getSlots(), "VentureChat: " + target.getName() + " GUI");
|
Inventory inv = plugin.getServer().createInventory(null, this.getSlots(), "VentureChat: " + target.getName() + " GUI");
|
||||||
ItemStack close = null;
|
ItemStack close = null;
|
||||||
ItemStack skull = null;
|
ItemStack skull = null;
|
||||||
if (versionService.is1_7()) {
|
if (versionService.is1_7()) {
|
||||||
@ -136,7 +135,7 @@ public class VentureChatGui extends PlayerCommand {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void openInventoryDiscord(VentureChatPlayer mcp, ChatChannel channel, int hash) {
|
private void openInventoryDiscord(VentureChatPlayer mcp, ChatChannel channel, int hash) {
|
||||||
Inventory inv = Bukkit.createInventory(null, this.getSlots(), "VentureChat: Discord_Message GUI");
|
Inventory inv = plugin.getServer().createInventory(null, this.getSlots(), "VentureChat: Discord_Message GUI");
|
||||||
ItemStack close = null;
|
ItemStack close = null;
|
||||||
ItemStack skull = null;
|
ItemStack skull = null;
|
||||||
if (versionService.is1_7()) {
|
if (versionService.is1_7()) {
|
||||||
|
@ -4,7 +4,6 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -40,7 +39,7 @@ import venture.Aust1n46.chat.utilities.FormatUtils;
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ChatListener implements Listener {
|
public class ChatListener implements Listener {
|
||||||
private final boolean essentialsDiscordHook = Bukkit.getPluginManager().isPluginEnabled("EssentialsDiscord");
|
private boolean essentialsDiscordHook;
|
||||||
@Inject
|
@Inject
|
||||||
private VentureChat plugin;
|
private VentureChat plugin;
|
||||||
@Inject
|
@Inject
|
||||||
@ -54,11 +53,17 @@ public class ChatListener implements Listener {
|
|||||||
@Inject
|
@Inject
|
||||||
private ConfigService configService;
|
private ConfigService configService;
|
||||||
|
|
||||||
// this event isn't always asynchronous even though the event's name starts with "Async"
|
@Inject
|
||||||
|
public void postConstruct() {
|
||||||
|
essentialsDiscordHook = plugin.getServer().getPluginManager().isPluginEnabled("EssentialsDiscord");
|
||||||
|
}
|
||||||
|
|
||||||
|
// this event isn't always asynchronous even though the event's name starts with
|
||||||
|
// "Async"
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event) {
|
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
handleTrueAsyncPlayerChatEvent(event);
|
handleTrueAsyncPlayerChatEvent(event);
|
||||||
@ -66,151 +71,126 @@ public class ChatListener implements Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleTrueAsyncPlayerChatEvent(AsyncPlayerChatEvent event) {
|
private void processPrivateMessageConversation(final VentureChatPlayer ventureChatPlayer, final String chat) {
|
||||||
boolean bungee = false;
|
VentureChatPlayer tp = playerApiService.getMineverseChatPlayer(ventureChatPlayer.getConversation());
|
||||||
String chat = event.getMessage();
|
if (!tp.isOnline()) {
|
||||||
String format;
|
ventureChatPlayer.getPlayer().sendMessage(ChatColor.RED + tp.getName() + " is not available.");
|
||||||
Set<Player> recipients = event.getRecipients();
|
if (!ventureChatPlayer.getPlayer().hasPermission("venturechat.spy.override")) {
|
||||||
int recipientCount = recipients.size(); // Don't count vanished players
|
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||||
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(event.getPlayer());
|
if (p.getName().equals(ventureChatPlayer.getName())) {
|
||||||
ChatChannel eventChannel = mcp.getCurrentChannel();
|
|
||||||
|
|
||||||
if(mcp.isEditing()) {
|
|
||||||
mcp.getPlayer().sendMessage(FormatUtils.FormatStringAll(chat));
|
|
||||||
mcp.setEditing(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mcp.isQuickChat()) {
|
|
||||||
eventChannel = mcp.getQuickChannel();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mcp.hasConversation() && !mcp.isQuickChat()) {
|
|
||||||
VentureChatPlayer tp = playerApiService.getMineverseChatPlayer(mcp.getConversation());
|
|
||||||
if(!tp.isOnline()) {
|
|
||||||
mcp.getPlayer().sendMessage(ChatColor.RED + tp.getName() + " is not available.");
|
|
||||||
if(!mcp.getPlayer().hasPermission("venturechat.spy.override")) {
|
|
||||||
for(VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
|
||||||
if(p.getName().equals(mcp.getName())) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(p.isSpy()) {
|
if (p.isSpy()) {
|
||||||
p.getPlayer().sendMessage(LocalizedMessage.EXIT_PRIVATE_CONVERSATION_SPY.toString()
|
p.getPlayer().sendMessage(LocalizedMessage.EXIT_PRIVATE_CONVERSATION_SPY.toString().replace("{player_sender}", ventureChatPlayer.getName())
|
||||||
.replace("{player_sender}", mcp.getName())
|
|
||||||
.replace("{player_receiver}", tp.getName()));
|
.replace("{player_receiver}", tp.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mcp.setConversation(null);
|
ventureChatPlayer.setConversation(null);
|
||||||
}
|
} else {
|
||||||
else {
|
if (tp.getIgnores().contains(ventureChatPlayer.getUuid())) {
|
||||||
if(tp.getIgnores().contains(mcp.getUuid())) {
|
ventureChatPlayer.getPlayer().sendMessage(LocalizedMessage.IGNORING_MESSAGE.toString().replace("{player}", tp.getName()));
|
||||||
mcp.getPlayer().sendMessage(LocalizedMessage.IGNORING_MESSAGE.toString()
|
|
||||||
.replace("{player}", tp.getName()));
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!tp.isMessageToggle()) {
|
if (!tp.isMessageToggle()) {
|
||||||
mcp.getPlayer().sendMessage(LocalizedMessage.BLOCKING_MESSAGE.toString()
|
ventureChatPlayer.getPlayer().sendMessage(LocalizedMessage.BLOCKING_MESSAGE.toString().replace("{player}", tp.getName()));
|
||||||
.replace("{player}", tp.getName()));
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String filtered = chat;
|
String filtered = chat;
|
||||||
String echo = "";
|
String echo = "";
|
||||||
String send = "";
|
String send = "";
|
||||||
String spy = "";
|
String spy = "";
|
||||||
if(mcp.isFilter()) {
|
if (ventureChatPlayer.isFilter()) {
|
||||||
filtered = formatService.FilterChat(filtered);
|
filtered = formatService.FilterChat(filtered);
|
||||||
}
|
}
|
||||||
if(mcp.getPlayer().hasPermission("venturechat.color.legacy")) {
|
if (ventureChatPlayer.getPlayer().hasPermission("venturechat.color.legacy")) {
|
||||||
filtered = FormatUtils.FormatStringLegacyColor(filtered);
|
filtered = FormatUtils.FormatStringLegacyColor(filtered);
|
||||||
}
|
}
|
||||||
if(mcp.getPlayer().hasPermission("venturechat.color")) {
|
if (ventureChatPlayer.getPlayer().hasPermission("venturechat.color")) {
|
||||||
filtered = FormatUtils.FormatStringColor(filtered);
|
filtered = FormatUtils.FormatStringColor(filtered);
|
||||||
}
|
}
|
||||||
if(mcp.getPlayer().hasPermission("venturechat.format")) {
|
if (ventureChatPlayer.getPlayer().hasPermission("venturechat.format")) {
|
||||||
filtered = FormatUtils.FormatString(filtered);
|
filtered = FormatUtils.FormatString(filtered);
|
||||||
}
|
}
|
||||||
filtered = " " + filtered;
|
filtered = " " + filtered;
|
||||||
|
|
||||||
send = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("tellformatfrom").replaceAll("sender_", "")));
|
send = FormatUtils.FormatStringAll(
|
||||||
echo = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("tellformatto").replaceAll("sender_", "")));
|
PlaceholderAPI.setBracketPlaceholders(ventureChatPlayer.getPlayer(), plugin.getConfig().getString("tellformatfrom").replaceAll("sender_", "")));
|
||||||
spy = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("tellformatspy").replaceAll("sender_", "")));
|
echo = FormatUtils
|
||||||
|
.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(ventureChatPlayer.getPlayer(), plugin.getConfig().getString("tellformatto").replaceAll("sender_", "")));
|
||||||
|
spy = FormatUtils
|
||||||
|
.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(ventureChatPlayer.getPlayer(), plugin.getConfig().getString("tellformatspy").replaceAll("sender_", "")));
|
||||||
|
|
||||||
send = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(tp.getPlayer(), send.replaceAll("receiver_", ""))) + filtered;
|
send = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(tp.getPlayer(), send.replaceAll("receiver_", ""))) + filtered;
|
||||||
echo = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(tp.getPlayer(), echo.replaceAll("receiver_", ""))) + filtered;
|
echo = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(tp.getPlayer(), echo.replaceAll("receiver_", ""))) + filtered;
|
||||||
spy = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(tp.getPlayer(), spy.replaceAll("receiver_", ""))) + filtered;
|
spy = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(tp.getPlayer(), spy.replaceAll("receiver_", ""))) + filtered;
|
||||||
|
|
||||||
if(!mcp.getPlayer().hasPermission("venturechat.spy.override")) {
|
if (!ventureChatPlayer.getPlayer().hasPermission("venturechat.spy.override")) {
|
||||||
for(VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||||
if(p.getName().equals(mcp.getName()) || p.getName().equals(tp.getName())) {
|
if (p.getName().equals(ventureChatPlayer.getName()) || p.getName().equals(tp.getName())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(p.isSpy()) {
|
if (p.isSpy()) {
|
||||||
p.getPlayer().sendMessage(spy);
|
p.getPlayer().sendMessage(spy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tp.getPlayer().sendMessage(send);
|
tp.getPlayer().sendMessage(send);
|
||||||
mcp.getPlayer().sendMessage(echo);
|
ventureChatPlayer.getPlayer().sendMessage(echo);
|
||||||
if(tp.isNotifications()) {
|
if (tp.isNotifications()) {
|
||||||
formatService.playMessageSound(tp);
|
formatService.playMessageSound(tp);
|
||||||
}
|
}
|
||||||
mcp.setReplyPlayer(tp.getUuid());
|
ventureChatPlayer.setReplyPlayer(tp.getUuid());
|
||||||
tp.setReplyPlayer(mcp.getUuid());
|
tp.setReplyPlayer(ventureChatPlayer.getUuid());
|
||||||
if(databaseService.isEnabled()) {
|
if (databaseService.isEnabled()) {
|
||||||
databaseService.writeVentureChat(mcp.getUuid().toString(), mcp.getName(), "Local", "Messaging_Component", chat.replace("'", "''"), "Chat");
|
databaseService.writeVentureChat(ventureChatPlayer.getUuid().toString(), ventureChatPlayer.getName(), "Local", "Messaging_Component", chat.replace("'", "''"),
|
||||||
|
"Chat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mcp.isPartyChat() && !mcp.isQuickChat()) {
|
private void processPartyChat(final VentureChatPlayer ventureChatPlayer, final String chat) {
|
||||||
if(mcp.hasParty()) {
|
if (ventureChatPlayer.hasParty()) {
|
||||||
String partyformat = "";
|
String partyformat = "";
|
||||||
for(VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||||
if((p.hasParty() && p.getParty().toString().equals(mcp.getParty().toString()) || p.isSpy())) {
|
if ((p.hasParty() && p.getParty().toString().equals(ventureChatPlayer.getParty().toString()) || p.isSpy())) {
|
||||||
String filtered = chat;
|
String filtered = chat;
|
||||||
if(mcp.isFilter()) {
|
if (ventureChatPlayer.isFilter()) {
|
||||||
filtered = formatService.FilterChat(filtered);
|
filtered = formatService.FilterChat(filtered);
|
||||||
}
|
}
|
||||||
if(mcp.getPlayer().hasPermission("venturechat.color.legacy")) {
|
if (ventureChatPlayer.getPlayer().hasPermission("venturechat.color.legacy")) {
|
||||||
filtered = FormatUtils.FormatStringLegacyColor(filtered);
|
filtered = FormatUtils.FormatStringLegacyColor(filtered);
|
||||||
}
|
}
|
||||||
if(mcp.getPlayer().hasPermission("venturechat.color")) {
|
if (ventureChatPlayer.getPlayer().hasPermission("venturechat.color")) {
|
||||||
filtered = FormatUtils.FormatStringColor(filtered);
|
filtered = FormatUtils.FormatStringColor(filtered);
|
||||||
}
|
}
|
||||||
if(mcp.getPlayer().hasPermission("venturechat.format")) {
|
if (ventureChatPlayer.getPlayer().hasPermission("venturechat.format")) {
|
||||||
filtered = FormatUtils.FormatString(filtered);
|
filtered = FormatUtils.FormatString(filtered);
|
||||||
}
|
}
|
||||||
filtered = " " + filtered;
|
filtered = " " + filtered;
|
||||||
if(plugin.getConfig().getString("partyformat").equalsIgnoreCase("Default")) {
|
if (plugin.getConfig().getString("partyformat").equalsIgnoreCase("Default")) {
|
||||||
partyformat = ChatColor.GREEN + "[" + playerApiService.getMineverseChatPlayer(mcp.getParty()).getName() + "'s Party] " + mcp.getName() + ":" + filtered;
|
partyformat = ChatColor.GREEN + "[" + playerApiService.getMineverseChatPlayer(ventureChatPlayer.getParty()).getName() + "'s Party] "
|
||||||
}
|
+ ventureChatPlayer.getName() + ":" + filtered;
|
||||||
else {
|
} else {
|
||||||
partyformat = FormatUtils.FormatStringAll(plugin.getConfig().getString("partyformat").replace("{host}", playerApiService.getMineverseChatPlayer(mcp.getParty()).getName()).replace("{player}", mcp.getName())) + filtered;
|
partyformat = FormatUtils.FormatStringAll(
|
||||||
|
plugin.getConfig().getString("partyformat").replace("{host}", playerApiService.getMineverseChatPlayer(ventureChatPlayer.getParty()).getName())
|
||||||
|
.replace("{player}", ventureChatPlayer.getName()))
|
||||||
|
+ filtered;
|
||||||
}
|
}
|
||||||
p.getPlayer().sendMessage(partyformat);
|
p.getPlayer().sendMessage(partyformat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Bukkit.getConsoleSender().sendMessage(partyformat);
|
plugin.getServer().getConsoleSender().sendMessage(partyformat);
|
||||||
if(databaseService.isEnabled()) {
|
if (databaseService.isEnabled()) {
|
||||||
databaseService.writeVentureChat(mcp.getUuid().toString(), mcp.getName(), "Local", "Party_Component", chat.replace("'", "''"), "Chat");
|
databaseService.writeVentureChat(ventureChatPlayer.getUuid().toString(), ventureChatPlayer.getName(), "Local", "Party_Component", chat.replace("'", "''"), "Chat");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mcp.getPlayer().sendMessage(ChatColor.RED + "You are not in a party.");
|
ventureChatPlayer.getPlayer().sendMessage(ChatColor.RED + "You are not in a party.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Location locreceip;
|
private void processMute(final VentureChatPlayer ventureChatPlayer, final ChatChannel channel) {
|
||||||
Location locsender = mcp.getPlayer().getLocation();
|
MuteContainer muteContainer = ventureChatPlayer.getMute(channel.getName());
|
||||||
Location diff;
|
|
||||||
Boolean filterthis = true;
|
|
||||||
mcp.addListening(eventChannel.getName());
|
|
||||||
if (mcp.isMuted(eventChannel.getName())) {
|
|
||||||
MuteContainer muteContainer = mcp.getMute(eventChannel.getName());
|
|
||||||
if (muteContainer.hasDuration()) {
|
if (muteContainer.hasDuration()) {
|
||||||
long dateTimeMillis = System.currentTimeMillis();
|
long dateTimeMillis = System.currentTimeMillis();
|
||||||
long muteTimeMillis = muteContainer.getDuration();
|
long muteTimeMillis = muteContainer.getDuration();
|
||||||
@ -219,61 +199,68 @@ public class ChatListener implements Listener {
|
|||||||
remainingMuteTime = 1000;
|
remainingMuteTime = 1000;
|
||||||
}
|
}
|
||||||
String timeString = FormatUtils.parseTimeStringFromMillis(remainingMuteTime);
|
String timeString = FormatUtils.parseTimeStringFromMillis(remainingMuteTime);
|
||||||
if(muteContainer.hasReason()) {
|
if (muteContainer.hasReason()) {
|
||||||
mcp.getPlayer()
|
ventureChatPlayer.getPlayer().sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED_REASON.toString().replace("{channel_color}", channel.getColor())
|
||||||
.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED_REASON.toString()
|
.replace("{channel_name}", channel.getName()).replace("{time}", timeString).replace("{reason}", muteContainer.getReason()));
|
||||||
.replace("{channel_color}", eventChannel.getColor())
|
} else {
|
||||||
.replace("{channel_name}", eventChannel.getName())
|
ventureChatPlayer.getPlayer().sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED.toString().replace("{channel_color}", channel.getColor())
|
||||||
.replace("{time}", timeString)
|
.replace("{channel_name}", channel.getName()).replace("{time}", timeString));
|
||||||
.replace("{reason}", muteContainer.getReason()));
|
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
mcp.getPlayer()
|
if (muteContainer.hasReason()) {
|
||||||
.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED.toString()
|
ventureChatPlayer.getPlayer().sendMessage(LocalizedMessage.CHANNEL_MUTED_REASON.toString().replace("{channel_color}", channel.getColor())
|
||||||
.replace("{channel_color}", eventChannel.getColor())
|
.replace("{channel_name}", channel.getName()).replace("{reason}", muteContainer.getReason()));
|
||||||
.replace("{channel_name}", eventChannel.getName())
|
} else {
|
||||||
.replace("{time}", timeString));
|
ventureChatPlayer.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.CHANNEL_MUTED.toString().replace("{channel_color}", channel.getColor()).replace("{channel_name}", channel.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
ventureChatPlayer.setQuickChat(false);
|
||||||
if(muteContainer.hasReason()) {
|
|
||||||
mcp.getPlayer()
|
|
||||||
.sendMessage(LocalizedMessage.CHANNEL_MUTED_REASON.toString()
|
|
||||||
.replace("{channel_color}", eventChannel.getColor())
|
|
||||||
.replace("{channel_name}", eventChannel.getName())
|
|
||||||
.replace("{reason}", muteContainer.getReason()));
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
mcp.getPlayer()
|
private void handleTrueAsyncPlayerChatEvent(final AsyncPlayerChatEvent event) {
|
||||||
.sendMessage(LocalizedMessage.CHANNEL_MUTED.toString()
|
String chat = event.getMessage();
|
||||||
.replace("{channel_color}", eventChannel.getColor())
|
String format;
|
||||||
.replace("{channel_name}", eventChannel.getName()));
|
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(event.getPlayer());
|
||||||
}
|
ChatChannel eventChannel = mcp.getCurrentChannel();
|
||||||
}
|
if (mcp.isEditing()) {
|
||||||
mcp.setQuickChat(false);
|
mcp.getPlayer().sendMessage(FormatUtils.FormatStringAll(chat));
|
||||||
|
mcp.setEditing(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Double chDistance = (double) 0;
|
if (mcp.isQuickChat()) {
|
||||||
String curColor = "";
|
eventChannel = mcp.getQuickChannel();
|
||||||
if(eventChannel.hasPermission() && !mcp.getPlayer().hasPermission(eventChannel.getPermission())) {
|
}
|
||||||
|
if (mcp.hasConversation() && !mcp.isQuickChat()) {
|
||||||
|
processPrivateMessageConversation(mcp, chat);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mcp.isPartyChat() && !mcp.isQuickChat()) {
|
||||||
|
processPartyChat(mcp, chat);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (eventChannel.hasPermission() && !mcp.getPlayer().hasPermission(eventChannel.getPermission())) {
|
||||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_PERMISSION.toString());
|
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_PERMISSION.toString());
|
||||||
mcp.setQuickChat(false);
|
mcp.setQuickChat(false);
|
||||||
mcp.removeListening(eventChannel.getName());
|
mcp.removeListening(eventChannel.getName());
|
||||||
mcp.setCurrentChannel(configService.getDefaultChannel());
|
mcp.setCurrentChannel(configService.getDefaultChannel());
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
mcp.addListening(eventChannel.getName());
|
||||||
}
|
}
|
||||||
if(eventChannel.hasSpeakPermission() && !mcp.getPlayer().hasPermission(eventChannel.getSpeakPermission())) {
|
if (eventChannel.hasSpeakPermission() && !mcp.getPlayer().hasPermission(eventChannel.getSpeakPermission())) {
|
||||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_SPEAK_PERMISSIONS.toString());
|
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_SPEAK_PERMISSIONS.toString());
|
||||||
mcp.setQuickChat(false);
|
mcp.setQuickChat(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
curColor = eventChannel.getChatColor();
|
if (mcp.isMuted(eventChannel.getName())) {
|
||||||
bungee = eventChannel.getBungee();
|
processMute(mcp, eventChannel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
long dateTimeSeconds = System.currentTimeMillis() / FormatUtils.MILLISECONDS_PER_SECOND;
|
long dateTimeSeconds = System.currentTimeMillis() / FormatUtils.MILLISECONDS_PER_SECOND;
|
||||||
|
|
||||||
int chCooldown = 0;
|
int chCooldown = 0;
|
||||||
if(eventChannel.hasCooldown()) {
|
if (eventChannel.hasCooldown()) {
|
||||||
chCooldown = eventChannel.getCooldown();
|
chCooldown = eventChannel.getCooldown();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -282,10 +269,8 @@ public class ChatListener implements Listener {
|
|||||||
if (dateTimeSeconds < cooldownTime) {
|
if (dateTimeSeconds < cooldownTime) {
|
||||||
long remainingCooldownTime = cooldownTime - dateTimeSeconds;
|
long remainingCooldownTime = cooldownTime - dateTimeSeconds;
|
||||||
String cooldownString = FormatUtils.parseTimeStringFromMillis(remainingCooldownTime * FormatUtils.MILLISECONDS_PER_SECOND);
|
String cooldownString = FormatUtils.parseTimeStringFromMillis(remainingCooldownTime * FormatUtils.MILLISECONDS_PER_SECOND);
|
||||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_COOLDOWN.toString()
|
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_COOLDOWN.toString().replace("{cooldown}", cooldownString));
|
||||||
.replace("{cooldown}", cooldownString));
|
|
||||||
mcp.setQuickChat(false);
|
mcp.setQuickChat(false);
|
||||||
bungee = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -305,29 +290,22 @@ public class ChatListener implements Listener {
|
|||||||
long spamtimeconfig = plugin.getConfig().getConfigurationSection("antispam").getLong("spamnumber");
|
long spamtimeconfig = plugin.getConfig().getConfigurationSection("antispam").getLong("spamnumber");
|
||||||
String mutedForTime = plugin.getConfig().getConfigurationSection("antispam").getString("mutetime", "0");
|
String mutedForTime = plugin.getConfig().getConfigurationSection("antispam").getString("mutetime", "0");
|
||||||
long dateTime = System.currentTimeMillis();
|
long dateTime = System.currentTimeMillis();
|
||||||
if (dateTimeSeconds < spamtime
|
if (dateTimeSeconds < spamtime + plugin.getConfig().getConfigurationSection("antispam").getLong("spamtime")) {
|
||||||
+ plugin.getConfig().getConfigurationSection("antispam").getLong("spamtime")) {
|
|
||||||
if (spamcount + 1 >= spamtimeconfig) {
|
if (spamcount + 1 >= spamtimeconfig) {
|
||||||
long time = FormatUtils.parseTimeStringToMillis(mutedForTime);
|
long time = FormatUtils.parseTimeStringToMillis(mutedForTime);
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
mcp.addMute(eventChannel.getName(), dateTime + time, LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString());
|
mcp.addMute(eventChannel.getName(), dateTime + time, LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString());
|
||||||
String timeString = FormatUtils.parseTimeStringFromMillis(time);
|
String timeString = FormatUtils.parseTimeStringFromMillis(time);
|
||||||
mcp.getPlayer()
|
mcp.getPlayer()
|
||||||
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME_REASON.toString()
|
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME_REASON.toString().replace("{channel_color}", eventChannel.getColor())
|
||||||
.replace("{channel_color}", eventChannel.getColor())
|
.replace("{channel_name}", eventChannel.getName()).replace("{time}", timeString)
|
||||||
.replace("{channel_name}", eventChannel.getName())
|
|
||||||
.replace("{time}", timeString)
|
|
||||||
.replace("{reason}", LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString()));
|
.replace("{reason}", LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString()));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
mcp.addMute(eventChannel.getName(), LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString());
|
mcp.addMute(eventChannel.getName(), LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString());
|
||||||
mcp.getPlayer()
|
mcp.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_REASON.toString().replace("{channel_color}", eventChannel.getColor())
|
||||||
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_REASON.toString()
|
.replace("{channel_name}", eventChannel.getName()).replace("{reason}", LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString()));
|
||||||
.replace("{channel_color}", eventChannel.getColor())
|
|
||||||
.replace("{channel_name}", eventChannel.getName())
|
|
||||||
.replace("{reason}", LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString()));
|
|
||||||
}
|
}
|
||||||
if(eventChannel.getBungee()) {
|
if (eventChannel.getBungee()) {
|
||||||
pluginMessageController.synchronize(mcp, true);
|
pluginMessageController.synchronize(mcp, true);
|
||||||
}
|
}
|
||||||
mcp.getSpam().get(eventChannel).set(0, 0L);
|
mcp.getSpam().get(eventChannel).set(0, 0L);
|
||||||
@ -352,146 +330,138 @@ public class ChatListener implements Listener {
|
|||||||
mcp.getSpam().get(eventChannel).add(1, dateTimeSeconds);
|
mcp.getSpam().get(eventChannel).add(1, dateTimeSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(eventChannel.hasDistance()) {
|
|
||||||
chDistance = eventChannel.getDistance();
|
|
||||||
}
|
|
||||||
|
|
||||||
format = FormatUtils.FormatStringAll(eventChannel.getFormat());
|
format = FormatUtils.FormatStringAll(eventChannel.getFormat());
|
||||||
|
|
||||||
filterthis = eventChannel.isFiltered();
|
if (eventChannel.isFiltered() && mcp.isFilter()) {
|
||||||
if(filterthis) {
|
|
||||||
if(mcp.isFilter()) {
|
|
||||||
chat = formatService.FilterChat(chat);
|
chat = formatService.FilterChat(chat);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
PluginManager pluginManager = plugin.getServer().getPluginManager();
|
PluginManager pluginManager = plugin.getServer().getPluginManager();
|
||||||
for(VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
Set<Player> recipients = event.getRecipients();
|
||||||
if(p.getPlayer() != mcp.getPlayer()) {
|
int recipientCount = recipients.size(); // Don't count vanished players
|
||||||
if(!configService.isListening(p, eventChannel.getName())) {
|
for (VentureChatPlayer p : playerApiService.getOnlineMineverseChatPlayers()) {
|
||||||
|
if (p.getPlayer() != mcp.getPlayer()) {
|
||||||
|
if (!configService.isListening(p, eventChannel.getName())) {
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(plugin.getConfig().getBoolean("ignorechat", false) && p.getIgnores().contains(mcp.getUuid())) {
|
if (plugin.getConfig().getBoolean("ignorechat", false) && p.getIgnores().contains(mcp.getUuid())) {
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(plugin.getConfig().getBoolean("enable_towny_channel") && pluginManager.isPluginEnabled("Towny")) {
|
if (plugin.getConfig().getBoolean("enable_towny_channel") && pluginManager.isPluginEnabled("Towny")) {
|
||||||
try {
|
try {
|
||||||
TownyUniverse towny = TownyUniverse.getInstance();
|
TownyUniverse towny = TownyUniverse.getInstance();
|
||||||
if(eventChannel.getName().equalsIgnoreCase("Town")) {
|
if (eventChannel.getName().equalsIgnoreCase("Town")) {
|
||||||
Resident r = towny.getResident(p.getName());
|
Resident r = towny.getResident(p.getName());
|
||||||
Resident pp = towny.getResident(mcp.getName());
|
Resident pp = towny.getResident(mcp.getName());
|
||||||
if(!pp.hasTown()) {
|
if (!pp.hasTown()) {
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
continue;
|
continue;
|
||||||
}
|
} else if (!r.hasTown()) {
|
||||||
else if(!r.hasTown()) {
|
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
continue;
|
continue;
|
||||||
}
|
} else if (!(r.getTown().getName().equals(pp.getTown().getName()))) {
|
||||||
else if(!(r.getTown().getName().equals(pp.getTown().getName()))) {
|
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(eventChannel.getName().equalsIgnoreCase("Nation")) {
|
if (eventChannel.getName().equalsIgnoreCase("Nation")) {
|
||||||
Resident r = towny.getResident(p.getName());
|
Resident r = towny.getResident(p.getName());
|
||||||
Resident pp = towny.getResident(mcp.getName());
|
Resident pp = towny.getResident(mcp.getName());
|
||||||
if(!pp.hasNation()) {
|
if (!pp.hasNation()) {
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
continue;
|
continue;
|
||||||
}
|
} else if (!r.hasNation()) {
|
||||||
else if(!r.hasNation()) {
|
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
continue;
|
continue;
|
||||||
}
|
} else if (!(r.getTown().getNation().getName().equals(pp.getTown().getNation().getName()))) {
|
||||||
else if(!(r.getTown().getNation().getName().equals(pp.getTown().getNation().getName()))) {
|
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch(Exception ex) {
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(plugin.getConfig().getBoolean("enable_factions_channel") && pluginManager.isPluginEnabled("Factions")) {
|
if (plugin.getConfig().getBoolean("enable_factions_channel") && pluginManager.isPluginEnabled("Factions")) {
|
||||||
try {
|
try {
|
||||||
if(eventChannel.getName().equalsIgnoreCase("Faction")) {
|
if (eventChannel.getName().equalsIgnoreCase("Faction")) {
|
||||||
MPlayer mplayer = MPlayer.get(mcp.getPlayer());
|
MPlayer mplayer = MPlayer.get(mcp.getPlayer());
|
||||||
MPlayer mplayerp = MPlayer.get(p.getPlayer());
|
MPlayer mplayerp = MPlayer.get(p.getPlayer());
|
||||||
if(!mplayer.hasFaction()) {
|
if (!mplayer.hasFaction()) {
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
}
|
} else if (!mplayerp.hasFaction()) {
|
||||||
else if(!mplayerp.hasFaction()) {
|
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
}
|
} else if (!(mplayer.getFactionName().equals(mplayerp.getFactionName()))) {
|
||||||
else if(!(mplayer.getFactionName().equals(mplayerp.getFactionName()))) {
|
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch(Exception ex) {
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chDistance > (double) 0 && !bungee && !p.getRangedSpy()) {
|
double chDistance = 0D;
|
||||||
locreceip = p.getPlayer().getLocation();
|
if (eventChannel.hasDistance()) {
|
||||||
if(locreceip.getWorld() == mcp.getPlayer().getWorld()) {
|
chDistance = eventChannel.getDistance();
|
||||||
diff = locreceip.subtract(locsender);
|
}
|
||||||
if(Math.abs(diff.getX()) > chDistance || Math.abs(diff.getZ()) > chDistance || Math.abs(diff.getY()) > chDistance) {
|
if (chDistance > (double) 0 && !eventChannel.getBungee() && !p.getRangedSpy()) {
|
||||||
|
final Location locreceip = p.getPlayer().getLocation();
|
||||||
|
if (locreceip.getWorld() == mcp.getPlayer().getWorld()) {
|
||||||
|
final Location locsender = mcp.getPlayer().getLocation();
|
||||||
|
final Location diff = locreceip.subtract(locsender);
|
||||||
|
if (Math.abs(diff.getX()) > chDistance || Math.abs(diff.getZ()) > chDistance || Math.abs(diff.getY()) > chDistance) {
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(!mcp.getPlayer().canSee(p.getPlayer())) {
|
if (!mcp.getPlayer().canSee(p.getPlayer())) {
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
recipients.remove(p.getPlayer());
|
recipients.remove(p.getPlayer());
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!mcp.getPlayer().canSee(p.getPlayer())) {
|
if (!mcp.getPlayer().canSee(p.getPlayer())) {
|
||||||
recipientCount--;
|
recipientCount--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mcp.getPlayer().hasPermission("venturechat.color.legacy")) {
|
if (mcp.getPlayer().hasPermission("venturechat.color.legacy")) {
|
||||||
chat = FormatUtils.FormatStringLegacyColor(chat);
|
chat = FormatUtils.FormatStringLegacyColor(chat);
|
||||||
}
|
}
|
||||||
if(mcp.getPlayer().hasPermission("venturechat.color")) {
|
if (mcp.getPlayer().hasPermission("venturechat.color")) {
|
||||||
chat = FormatUtils.FormatStringColor(chat);
|
chat = FormatUtils.FormatStringColor(chat);
|
||||||
}
|
}
|
||||||
if(mcp.getPlayer().hasPermission("venturechat.format")) {
|
if (mcp.getPlayer().hasPermission("venturechat.format")) {
|
||||||
chat = FormatUtils.FormatString(chat);
|
chat = FormatUtils.FormatString(chat);
|
||||||
}
|
}
|
||||||
if(!mcp.isQuickChat()) {
|
if (!mcp.isQuickChat()) {
|
||||||
chat = " " + chat;
|
chat = " " + chat;
|
||||||
}
|
}
|
||||||
if(curColor.equalsIgnoreCase("None")) {
|
final String curColor = eventChannel.getChatColor();
|
||||||
// Format the placeholders and their color codes to determine the last color code to use for the chat message color
|
if (curColor.equalsIgnoreCase("None")) {
|
||||||
|
// Format the placeholders and their color codes to determine the last color
|
||||||
|
// code to use for the chat message color
|
||||||
chat = formatService.getLastCode(FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), format))) + chat;
|
chat = formatService.getLastCode(FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), format))) + chat;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
chat = curColor + chat;
|
chat = curColor + chat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,11 +470,12 @@ public class ChatListener implements Listener {
|
|||||||
String message = FormatUtils.stripColor(format + chat); // UTF-8 encoding issues.
|
String message = FormatUtils.stripColor(format + chat); // UTF-8 encoding issues.
|
||||||
int hash = message.hashCode();
|
int hash = message.hashCode();
|
||||||
|
|
||||||
//Create VentureChatEvent
|
// Create VentureChatEvent
|
||||||
VentureChatEvent ventureChatEvent = new VentureChatEvent(mcp, mcp.getName(), plugin.getVaultPermission().getPrimaryGroup(mcp.getPlayer()), eventChannel, recipients, recipientCount, format, chat, globalJSON, hash, bungee);
|
VentureChatEvent ventureChatEvent = new VentureChatEvent(mcp, mcp.getName(), plugin.getVaultPermission().getPrimaryGroup(mcp.getPlayer()), eventChannel, recipients,
|
||||||
//Fire event and wait for other plugin listeners to act on it
|
recipientCount, format, chat, globalJSON, hash, eventChannel.getBungee());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
|
// Fire event and wait for other plugin listeners to act on it
|
||||||
//Call method to send the processed chat
|
plugin.getServer().getPluginManager().callEvent(ventureChatEvent);
|
||||||
|
// Call method to send the processed chat
|
||||||
handleVentureChatEvent(ventureChatEvent);
|
handleVentureChatEvent(ventureChatEvent);
|
||||||
// Reset quick chat flag
|
// Reset quick chat flag
|
||||||
mcp.setQuickChat(false);
|
mcp.setQuickChat(false);
|
||||||
@ -523,28 +494,27 @@ public class ChatListener implements Listener {
|
|||||||
boolean bungee = event.isBungee();
|
boolean bungee = event.isBungee();
|
||||||
|
|
||||||
if (essentialsDiscordHook && channel.isDefaultchannel()) {
|
if (essentialsDiscordHook && channel.isDefaultchannel()) {
|
||||||
Bukkit.getServicesManager().load(DiscordService.class).sendChatMessage(ventureChatPlayer.getPlayer(), chat);
|
plugin.getServer().getServicesManager().load(DiscordService.class).sendChatMessage(ventureChatPlayer.getPlayer(), chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!bungee) {
|
if (!bungee) {
|
||||||
if(databaseService.isEnabled()) {
|
if (databaseService.isEnabled()) {
|
||||||
databaseService.writeVentureChat(ventureChatPlayer.getUuid().toString(), ventureChatPlayer.getName(), "Local", channel.getName(), chat.replace("'", "''"), "Chat");
|
databaseService.writeVentureChat(ventureChatPlayer.getUuid().toString(), ventureChatPlayer.getName(), "Local", channel.getName(), chat.replace("'", "''"), "Chat");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(recipientCount == 1) {
|
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.").equals("")) {
|
||||||
ventureChatPlayer.getPlayer().sendMessage(FormatUtils.FormatStringAll(plugin.getConfig().getString("emptychannelalert", "&6No one is listening to you.")));
|
ventureChatPlayer.getPlayer().sendMessage(FormatUtils.FormatStringAll(plugin.getConfig().getString("emptychannelalert", "&6No one is listening to you.")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(Player p : recipients) {
|
for (Player p : recipients) {
|
||||||
String json = formatService.formatModerationGUI(globalJSON, p, ventureChatPlayer.getName(), channel.getName(), hash);
|
String json = formatService.formatModerationGUI(globalJSON, p, ventureChatPlayer.getName(), channel.getName(), hash);
|
||||||
PacketContainer packet = formatService.createPacketPlayOutChat(json);
|
PacketContainer packet = formatService.createPacketPlayOutChat(json);
|
||||||
formatService.sendPacketPlayOutChat(p, packet);
|
formatService.sendPacketPlayOutChat(p, packet);
|
||||||
}
|
}
|
||||||
Bukkit.getConsoleSender().sendMessage(consoleChat);
|
plugin.getServer().getConsoleSender().sendMessage(consoleChat);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||||
DataOutputStream out = new DataOutputStream(byteOutStream);
|
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||||
try {
|
try {
|
||||||
@ -556,11 +526,11 @@ public class ChatListener implements Listener {
|
|||||||
out.writeInt(hash);
|
out.writeInt(hash);
|
||||||
out.writeUTF(format);
|
out.writeUTF(format);
|
||||||
out.writeUTF(chat);
|
out.writeUTF(chat);
|
||||||
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
if (plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
||||||
System.out.println(out.size() + " size bytes without json");
|
System.out.println(out.size() + " size bytes without json");
|
||||||
}
|
}
|
||||||
out.writeUTF(globalJSON);
|
out.writeUTF(globalJSON);
|
||||||
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
if (plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
||||||
System.out.println(out.size() + " bytes size with json");
|
System.out.println(out.size() + " bytes size with json");
|
||||||
}
|
}
|
||||||
out.writeUTF(plugin.getVaultPermission().getPrimaryGroup(ventureChatPlayer.getPlayer())); // look into not sending this
|
out.writeUTF(plugin.getVaultPermission().getPrimaryGroup(ventureChatPlayer.getPlayer())); // look into not sending this
|
||||||
@ -568,8 +538,7 @@ public class ChatListener implements Listener {
|
|||||||
out.writeUTF(displayName);
|
out.writeUTF(displayName);
|
||||||
pluginMessageController.sendPluginMessage(byteOutStream);
|
pluginMessageController.sendPluginMessage(byteOutStream);
|
||||||
out.close();
|
out.close();
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -2,7 +2,6 @@ package venture.Aust1n46.chat.initiators.listeners;
|
|||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -59,7 +58,8 @@ public class PreProcessCommandListener implements CommandExecutor, Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) throws FileNotFoundException {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) throws FileNotFoundException {
|
||||||
if (event.getPlayer() == null) {
|
if (event.getPlayer() == null) {
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Event.getPlayer() returned null in PlayerCommandPreprocessEvent"));
|
plugin.getServer().getConsoleSender()
|
||||||
|
.sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Event.getPlayer() returned null in PlayerCommandPreprocessEvent"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ConfigurationSection cs = plugin.getConfig().getConfigurationSection("commandspy");
|
ConfigurationSection cs = plugin.getConfig().getConfigurationSection("commandspy");
|
||||||
|
@ -67,18 +67,9 @@ public class VentureChatPlayer {
|
|||||||
this.party = party;
|
this.party = party;
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.notifications = notifications;
|
this.notifications = notifications;
|
||||||
this.online = false;
|
|
||||||
this.player = null;
|
|
||||||
this.hasPlayed = false;
|
|
||||||
this.conversation = null;
|
|
||||||
this.spy = spy;
|
this.spy = spy;
|
||||||
this.rangedSpy = rangedSpy;
|
this.rangedSpy = rangedSpy;
|
||||||
this.commandSpy = commandSpy;
|
this.commandSpy = commandSpy;
|
||||||
this.quickChat = false;
|
|
||||||
this.quickChannel = null;
|
|
||||||
this.replyPlayer = null;
|
|
||||||
this.partyChat = false;
|
|
||||||
this.modified = false;
|
|
||||||
this.messages = new ArrayList<ChatMessage>();
|
this.messages = new ArrayList<ChatMessage>();
|
||||||
this.jsonFormat = jsonFormat;
|
this.jsonFormat = jsonFormat;
|
||||||
this.cooldowns = new HashMap<ChatChannel, Long>();
|
this.cooldowns = new HashMap<ChatChannel, Long>();
|
||||||
@ -96,22 +87,8 @@ public class VentureChatPlayer {
|
|||||||
listening.add(currentChannel.getName());
|
listening.add(currentChannel.getName());
|
||||||
this.mutes = new HashMap<String, MuteContainer>();
|
this.mutes = new HashMap<String, MuteContainer>();
|
||||||
this.blockedCommands = new HashSet<String>();
|
this.blockedCommands = new HashSet<String>();
|
||||||
this.host = false;
|
|
||||||
this.party = null;
|
|
||||||
this.filter = true;
|
this.filter = true;
|
||||||
this.notifications = true;
|
this.notifications = true;
|
||||||
this.online = false;
|
|
||||||
this.player = null;
|
|
||||||
this.hasPlayed = false;
|
|
||||||
this.conversation = null;
|
|
||||||
this.spy = false;
|
|
||||||
this.rangedSpy = false;
|
|
||||||
this.commandSpy = false;
|
|
||||||
this.quickChat = false;
|
|
||||||
this.quickChannel = null;
|
|
||||||
this.replyPlayer = null;
|
|
||||||
this.partyChat = false;
|
|
||||||
this.modified = false;
|
|
||||||
this.messages = new ArrayList<ChatMessage>();
|
this.messages = new ArrayList<ChatMessage>();
|
||||||
this.jsonFormat = "Default";
|
this.jsonFormat = "Default";
|
||||||
this.cooldowns = new HashMap<ChatChannel, Long>();
|
this.cooldowns = new HashMap<ChatChannel, Long>();
|
||||||
|
@ -6,7 +6,6 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@ -65,7 +64,7 @@ public class ConfigService {
|
|||||||
}
|
}
|
||||||
// Error handling for missing default channel in the config.
|
// Error handling for missing default channel in the config.
|
||||||
if (defaultChatChannel == null) {
|
if (defaultChatChannel == null) {
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&e - &cNo default channel found!"));
|
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", "None", "None", false, true, true, "md", 0, true, false, 0, "&f[&cMissingDefault&f]",
|
||||||
"{venturechat_channel_prefix} {vault_prefix}{player_displayname}&c:");
|
"{venturechat_channel_prefix} {vault_prefix}{player_displayname}&c:");
|
||||||
defaultColor = defaultChatChannel.getColor();
|
defaultColor = defaultChatChannel.getColor();
|
||||||
|
@ -2,8 +2,6 @@ package venture.Aust1n46.chat.service;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
@ -21,16 +19,17 @@ public class UUIDService {
|
|||||||
|
|
||||||
public void checkOfflineUUIDWarning(UUID uuid) {
|
public void checkOfflineUUIDWarning(UUID uuid) {
|
||||||
if (shouldSkipOfflineUUID(uuid)) {
|
if (shouldSkipOfflineUUID(uuid)) {
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Detected Offline UUID!"));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Detected Offline UUID!"));
|
||||||
Bukkit.getConsoleSender()
|
plugin.getServer().getConsoleSender()
|
||||||
.sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - If you are using BungeeCord, make sure you have properly setup IP Forwarding."));
|
.sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - If you are using BungeeCord, make sure you have properly setup IP Forwarding."));
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - https://www.spigotmc.org/wiki/bungeecord-ip-forwarding/"));
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - https://www.spigotmc.org/wiki/bungeecord-ip-forwarding/"));
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - You can access this wiki page from the log file or just Google it."));
|
plugin.getServer().getConsoleSender()
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils
|
.sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - You can access this wiki page from the log file or just Google it."));
|
||||||
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils
|
||||||
.FormatStringAll("&8[&eVentureChat&8]&c - If you're running a \"cracked\" server, player data might not be stored properly, and thus, you are on your own."));
|
.FormatStringAll("&8[&eVentureChat&8]&c - If you're running a \"cracked\" server, player data might not be stored properly, and thus, you are on your own."));
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils
|
||||||
.FormatStringAll("&8[&eVentureChat&8]&c - If you run your server in offline mode, you will probably lose your player data when switching to online mode!"));
|
.FormatStringAll("&8[&eVentureChat&8]&c - If you run your server in offline mode, you will probably lose your player data when switching to online mode!"));
|
||||||
Bukkit.getConsoleSender().sendMessage(FormatUtils
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils
|
||||||
.FormatStringAll("&8[&eVentureChat&8]&c - No player data will be saved in offline mode unless you set the \"cracked\" server acknowledgement in the config!"));
|
.FormatStringAll("&8[&eVentureChat&8]&c - No player data will be saved in offline mode unless you set the \"cracked\" server acknowledgement in the config!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import java.sql.SQLException;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@ -42,8 +41,7 @@ public class VentureChatDatabaseService {
|
|||||||
// config.setDriverClassName(org.postgresql.Driver.class.getName());
|
// config.setDriverClassName(org.postgresql.Driver.class.getName());
|
||||||
// final String jdbcUrl = String.format("jdbc:postgresql://%s:%d/%s", hostname,
|
// final String jdbcUrl = String.format("jdbc:postgresql://%s:%d/%s", hostname,
|
||||||
// port, database);
|
// port, database);
|
||||||
final String jdbcUrl = String.format("jdbc:mysql://%s:%d/%s?autoReconnect=true&useSSL=false", host,
|
final String jdbcUrl = String.format("jdbc:mysql://%s:%d/%s?autoReconnect=true&useSSL=false", host, port, database);
|
||||||
port, database);
|
|
||||||
config.setJdbcUrl(jdbcUrl);
|
config.setJdbcUrl(jdbcUrl);
|
||||||
config.setUsername(user);
|
config.setUsername(user);
|
||||||
config.setPassword(password);
|
config.setPassword(password);
|
||||||
@ -51,16 +49,14 @@ public class VentureChatDatabaseService {
|
|||||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||||
dataSource = new HikariDataSource(config);
|
dataSource = new HikariDataSource(config);
|
||||||
final String SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS VentureChat "
|
final String SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS VentureChat " + "(ID SERIAL PRIMARY KEY, ChatTime TEXT, UUID TEXT, Name TEXT, "
|
||||||
+ "(ID SERIAL PRIMARY KEY, ChatTime TEXT, UUID TEXT, Name TEXT, "
|
|
||||||
+ "Server TEXT, Channel TEXT, Text TEXT, Type TEXT)";
|
+ "Server TEXT, Channel TEXT, Text TEXT, Type TEXT)";
|
||||||
final Connection conn = dataSource.getConnection();
|
final Connection conn = dataSource.getConnection();
|
||||||
final PreparedStatement statement = conn.prepareStatement(SQL_CREATE_TABLE);
|
final PreparedStatement statement = conn.prepareStatement(SQL_CREATE_TABLE);
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
Bukkit.getConsoleSender().sendMessage(
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Database could not be loaded. Is it running?"));
|
||||||
FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Database could not be loaded. Is it running?"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,16 +64,14 @@ public class VentureChatDatabaseService {
|
|||||||
return dataSource != null;
|
return dataSource != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeVentureChat(String uuid, String name, String server, String channel, String text,
|
public void writeVentureChat(String uuid, String name, String server, String channel, String text, String type) {
|
||||||
String type) {
|
|
||||||
Calendar currentDate = Calendar.getInstance();
|
Calendar currentDate = Calendar.getInstance();
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
String date = formatter.format(currentDate.getTime());
|
String date = formatter.format(currentDate.getTime());
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
try (final Connection conn = dataSource.getConnection();
|
try (final Connection conn = dataSource.getConnection();
|
||||||
final PreparedStatement statement = conn.prepareStatement(
|
final PreparedStatement statement = conn
|
||||||
"INSERT INTO VentureChat " + "(ChatTime, UUID, Name, Server, Channel, Text, Type) "
|
.prepareStatement("INSERT INTO VentureChat " + "(ChatTime, UUID, Name, Server, Channel, Text, Type) " + "VALUES (?, ?, ?, ?, ?, ?, ?)")) {
|
||||||
+ "VALUES (?, ?, ?, ?, ?, ?, ?)")) {
|
|
||||||
statement.setString(1, date);
|
statement.setString(1, date);
|
||||||
statement.setString(2, uuid);
|
statement.setString(2, uuid);
|
||||||
statement.setString(3, name);
|
statement.setString(3, name);
|
||||||
|
@ -14,7 +14,6 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -109,8 +108,7 @@ public class VentureChatFormatService {
|
|||||||
indexStart = matcher.start();
|
indexStart = matcher.start();
|
||||||
indexEnd = matcher.end();
|
indexEnd = matcher.end();
|
||||||
placeholder = remaining.substring(indexStart, indexEnd);
|
placeholder = remaining.substring(indexStart, indexEnd);
|
||||||
formattedPlaceholder = FormatUtils
|
formattedPlaceholder = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), placeholder));
|
||||||
.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), placeholder));
|
|
||||||
temp += convertToJsonColors(lastCode + remaining.substring(0, indexStart)) + ",";
|
temp += convertToJsonColors(lastCode + remaining.substring(0, indexStart)) + ",";
|
||||||
lastCode = getLastCode(lastCode + remaining.substring(0, indexStart));
|
lastCode = getLastCode(lastCode + remaining.substring(0, indexStart));
|
||||||
String action = "";
|
String action = "";
|
||||||
@ -119,22 +117,17 @@ public class VentureChatFormatService {
|
|||||||
for (JsonAttribute jsonAttribute : format.getJsonAttributes()) {
|
for (JsonAttribute jsonAttribute : format.getJsonAttributes()) {
|
||||||
if (placeholder.contains(jsonAttribute.getName().replace("{", "").replace("}", ""))) {
|
if (placeholder.contains(jsonAttribute.getName().replace("{", "").replace("}", ""))) {
|
||||||
action = jsonAttribute.getClickAction();
|
action = jsonAttribute.getClickAction();
|
||||||
text = FormatUtils.FormatStringAll(
|
text = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), jsonAttribute.getClickText()));
|
||||||
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), jsonAttribute.getClickText()));
|
|
||||||
for (String st : jsonAttribute.getHoverText()) {
|
for (String st : jsonAttribute.getHoverText()) {
|
||||||
hover += FormatUtils.FormatStringAll(st) + "\n";
|
hover += FormatUtils.FormatStringAll(st) + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hover.isEmpty()) {
|
if (!hover.isEmpty()) {
|
||||||
hover = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(),
|
hover = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), hover.substring(0, hover.length() - 1)));
|
||||||
hover.substring(0, hover.length() - 1)));
|
|
||||||
}
|
}
|
||||||
temp += convertToJsonColors(lastCode + formattedPlaceholder,
|
temp += convertToJsonColors(lastCode + formattedPlaceholder, ",\"clickEvent\":{\"action\":\"" + action + "\",\"value\":\"" + text
|
||||||
",\"clickEvent\":{\"action\":\"" + action + "\",\"value\":\"" + text
|
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(hover) + "]}}") + ",";
|
||||||
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
|
|
||||||
+ convertToJsonColors(hover) + "]}}")
|
|
||||||
+ ",";
|
|
||||||
lastCode = getLastCode(lastCode + formattedPlaceholder);
|
lastCode = getLastCode(lastCode + formattedPlaceholder);
|
||||||
remaining = remaining.substring(indexEnd);
|
remaining = remaining.substring(indexEnd);
|
||||||
} else {
|
} else {
|
||||||
@ -159,9 +152,8 @@ public class VentureChatFormatService {
|
|||||||
String link = "";
|
String link = "";
|
||||||
String lastCode = DEFAULT_COLOR_CODE;
|
String lastCode = DEFAULT_COLOR_CODE;
|
||||||
do {
|
do {
|
||||||
Pattern pattern = Pattern.compile(
|
Pattern pattern = Pattern.compile("([a-zA-Z0-9" + BUKKIT_COLOR_CODE_PREFIX + "\\-:/]+\\.[a-zA-Z/0-9" + BUKKIT_COLOR_CODE_PREFIX + "\\-:_#]+(\\.[a-zA-Z/0-9."
|
||||||
"([a-zA-Z0-9" + BUKKIT_COLOR_CODE_PREFIX + "\\-:/]+\\.[a-zA-Z/0-9" + BUKKIT_COLOR_CODE_PREFIX
|
+ BUKKIT_COLOR_CODE_PREFIX + "\\-:;,#\\?\\+=_]+)?)");
|
||||||
+ "\\-:_#]+(\\.[a-zA-Z/0-9." + BUKKIT_COLOR_CODE_PREFIX + "\\-:;,#\\?\\+=_]+)?)");
|
|
||||||
Matcher matcher = pattern.matcher(remaining);
|
Matcher matcher = pattern.matcher(remaining);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
indexLink = matcher.start();
|
indexLink = matcher.start();
|
||||||
@ -173,11 +165,9 @@ public class VentureChatFormatService {
|
|||||||
if (ChatColor.stripColor(link).contains("https://"))
|
if (ChatColor.stripColor(link).contains("https://"))
|
||||||
https = "s";
|
https = "s";
|
||||||
temp += convertToJsonColors(lastCode + link,
|
temp += convertToJsonColors(lastCode + link,
|
||||||
",\"underlined\":\"" + underlineURLs()
|
",\"underlined\":\"" + underlineURLs() + "\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http" + https + "://"
|
||||||
+ "\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http" + https + "://"
|
|
||||||
+ ChatColor.stripColor(link.replace("http://", "").replace("https://", ""))
|
+ ChatColor.stripColor(link.replace("http://", "").replace("https://", ""))
|
||||||
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
|
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(lastCode + link) + "]}}")
|
||||||
+ convertToJsonColors(lastCode + link) + "]}}")
|
|
||||||
+ ",";
|
+ ",";
|
||||||
lastCode = getLastCode(lastCode + link);
|
lastCode = getLastCode(lastCode + link);
|
||||||
remaining = remaining.substring(indexLinkEnd);
|
remaining = remaining.substring(indexLinkEnd);
|
||||||
@ -196,25 +186,18 @@ public class VentureChatFormatService {
|
|||||||
if (String.valueOf(ch[a + 1]).matches("[lkomnLKOMN]") && ch[a] == BUKKIT_COLOR_CODE_PREFIX_CHAR) {
|
if (String.valueOf(ch[a + 1]).matches("[lkomnLKOMN]") && ch[a] == BUKKIT_COLOR_CODE_PREFIX_CHAR) {
|
||||||
ts += String.valueOf(ch[a]) + ch[a + 1];
|
ts += String.valueOf(ch[a]) + ch[a + 1];
|
||||||
a++;
|
a++;
|
||||||
} else if (String.valueOf(ch[a + 1]).matches("[0123456789abcdefrABCDEFR]")
|
} else if (String.valueOf(ch[a + 1]).matches("[0123456789abcdefrABCDEFR]") && ch[a] == BUKKIT_COLOR_CODE_PREFIX_CHAR) {
|
||||||
&& ch[a] == BUKKIT_COLOR_CODE_PREFIX_CHAR) {
|
|
||||||
ts = String.valueOf(ch[a]) + ch[a + 1];
|
ts = String.valueOf(ch[a]) + ch[a + 1];
|
||||||
a++;
|
a++;
|
||||||
} else if (ch[a + 1] == 'x' && ch[a] == BUKKIT_COLOR_CODE_PREFIX_CHAR) {
|
} else if (ch[a + 1] == 'x' && ch[a] == BUKKIT_COLOR_CODE_PREFIX_CHAR) {
|
||||||
if (ch.length > a + 13) {
|
if (ch.length > a + 13) {
|
||||||
if (String.valueOf(ch[a + 3]).matches("[0123456789abcdefABCDEF]")
|
if (String.valueOf(ch[a + 3]).matches("[0123456789abcdefABCDEF]") && String.valueOf(ch[a + 5]).matches("[0123456789abcdefABCDEF]")
|
||||||
&& String.valueOf(ch[a + 5]).matches("[0123456789abcdefABCDEF]")
|
&& String.valueOf(ch[a + 7]).matches("[0123456789abcdefABCDEF]") && String.valueOf(ch[a + 9]).matches("[0123456789abcdefABCDEF]")
|
||||||
&& String.valueOf(ch[a + 7]).matches("[0123456789abcdefABCDEF]")
|
&& String.valueOf(ch[a + 11]).matches("[0123456789abcdefABCDEF]") && String.valueOf(ch[a + 13]).matches("[0123456789abcdefABCDEF]")
|
||||||
&& String.valueOf(ch[a + 9]).matches("[0123456789abcdefABCDEF]")
|
&& ch[a + 2] == BUKKIT_COLOR_CODE_PREFIX_CHAR && ch[a + 4] == BUKKIT_COLOR_CODE_PREFIX_CHAR && ch[a + 6] == BUKKIT_COLOR_CODE_PREFIX_CHAR
|
||||||
&& String.valueOf(ch[a + 11]).matches("[0123456789abcdefABCDEF]")
|
&& ch[a + 8] == BUKKIT_COLOR_CODE_PREFIX_CHAR && ch[a + 10] == BUKKIT_COLOR_CODE_PREFIX_CHAR && ch[a + 12] == BUKKIT_COLOR_CODE_PREFIX_CHAR) {
|
||||||
&& String.valueOf(ch[a + 13]).matches("[0123456789abcdefABCDEF]")
|
ts = String.valueOf(ch[a]) + ch[a + 1] + ch[a + 2] + ch[a + 3] + ch[a + 4] + ch[a + 5] + ch[a + 6] + ch[a + 7] + ch[a + 8] + ch[a + 9] + ch[a + 10]
|
||||||
&& ch[a + 2] == BUKKIT_COLOR_CODE_PREFIX_CHAR && ch[a + 4] == BUKKIT_COLOR_CODE_PREFIX_CHAR
|
+ ch[a + 11] + ch[a + 12] + ch[a + 13];
|
||||||
&& ch[a + 6] == BUKKIT_COLOR_CODE_PREFIX_CHAR && ch[a + 8] == BUKKIT_COLOR_CODE_PREFIX_CHAR
|
|
||||||
&& ch[a + 10] == BUKKIT_COLOR_CODE_PREFIX_CHAR
|
|
||||||
&& ch[a + 12] == BUKKIT_COLOR_CODE_PREFIX_CHAR) {
|
|
||||||
ts = String.valueOf(ch[a]) + ch[a + 1] + ch[a + 2] + ch[a + 3] + ch[a + 4] + ch[a + 5]
|
|
||||||
+ ch[a + 6] + ch[a + 7] + ch[a + 8] + ch[a + 9] + ch[a + 10] + ch[a + 11] + ch[a + 12]
|
|
||||||
+ ch[a + 13];
|
|
||||||
a += 13;
|
a += 13;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,9 +249,7 @@ public class VentureChatFormatService {
|
|||||||
color = remaining.substring(1, indexColor + LEGACY_COLOR_CODE_LENGTH);
|
color = remaining.substring(1, indexColor + LEGACY_COLOR_CODE_LENGTH);
|
||||||
if (color.equals(BUKKIT_HEX_COLOR_CODE_PREFIX)) {
|
if (color.equals(BUKKIT_HEX_COLOR_CODE_PREFIX)) {
|
||||||
if (remaining.length() >= HEX_COLOR_CODE_LENGTH) {
|
if (remaining.length() >= HEX_COLOR_CODE_LENGTH) {
|
||||||
color = HEX_COLOR_CODE_PREFIX
|
color = HEX_COLOR_CODE_PREFIX + remaining.substring(LEGACY_COLOR_CODE_LENGTH, indexColor + HEX_COLOR_CODE_LENGTH).replace(BUKKIT_COLOR_CODE_PREFIX, "");
|
||||||
+ remaining.substring(LEGACY_COLOR_CODE_LENGTH, indexColor + HEX_COLOR_CODE_LENGTH)
|
|
||||||
.replace(BUKKIT_COLOR_CODE_PREFIX, "");
|
|
||||||
colorLength = HEX_COLOR_CODE_LENGTH;
|
colorLength = HEX_COLOR_CODE_LENGTH;
|
||||||
bold = false;
|
bold = false;
|
||||||
obfuscated = false;
|
obfuscated = false;
|
||||||
@ -341,8 +322,7 @@ public class VentureChatFormatService {
|
|||||||
if (indexNextColor == -1) {
|
if (indexNextColor == -1) {
|
||||||
indexNextColor = remaining.length();
|
indexNextColor = remaining.length();
|
||||||
}
|
}
|
||||||
temp += "{\"text\":\"" + remaining.substring(0, indexNextColor) + "\",\"color\":\""
|
temp += "{\"text\":\"" + remaining.substring(0, indexNextColor) + "\",\"color\":\"" + hexidecimalToJsonColorRGB(color) + "\"" + modifier + extensions + "},";
|
||||||
+ hexidecimalToJsonColorRGB(color) + "\"" + modifier + extensions + "},";
|
|
||||||
remaining = remaining.substring(indexNextColor);
|
remaining = remaining.substring(indexNextColor);
|
||||||
} while (remaining.length() > 1 && indexColor != -1);
|
} while (remaining.length() > 1 && indexColor != -1);
|
||||||
if (temp.length() > 1)
|
if (temp.length() > 1)
|
||||||
@ -418,11 +398,9 @@ public class VentureChatFormatService {
|
|||||||
if (player.hasPermission("venturechat.gui")) {
|
if (player.hasPermission("venturechat.gui")) {
|
||||||
json = json.substring(0, json.length() - 1);
|
json = json.substring(0, json.length() - 1);
|
||||||
json += "," + convertToJsonColors(FormatUtils.FormatStringAll(plugin.getConfig().getString("guiicon")),
|
json += "," + convertToJsonColors(FormatUtils.FormatStringAll(plugin.getConfig().getString("guiicon")),
|
||||||
",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/vchatgui " + sender + " " + channelName
|
",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/vchatgui " + sender + " " + channelName + " " + hash
|
||||||
+ " " + hash
|
|
||||||
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
|
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
|
||||||
+ convertToJsonColors(FormatUtils.FormatStringAll(plugin.getConfig().getString("guitext")))
|
+ convertToJsonColors(FormatUtils.FormatStringAll(plugin.getConfig().getString("guitext"))) + "]}}")
|
||||||
+ "]}}")
|
|
||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
return json;
|
return json;
|
||||||
@ -463,10 +441,8 @@ public class VentureChatFormatService {
|
|||||||
splitComponents(finalList, o, c);
|
splitComponents(finalList, o, c);
|
||||||
for (Object component : finalList) {
|
for (Object component : finalList) {
|
||||||
try {
|
try {
|
||||||
if (versionService.is1_8() || versionService.is1_9() || versionService.is1_10()
|
if (versionService.is1_8() || versionService.is1_9() || versionService.is1_10() || versionService.is1_11() || versionService.is1_12() || versionService.is1_13()
|
||||||
|| versionService.is1_11() || versionService.is1_12() || versionService.is1_13()
|
|| versionService.is1_14() || versionService.is1_15() || versionService.is1_16() || versionService.is1_17()) {
|
||||||
|| versionService.is1_14() || versionService.is1_15() || versionService.is1_16()
|
|
||||||
|| versionService.is1_17()) {
|
|
||||||
String text = (String) component.getClass().getMethod("getText").invoke(component);
|
String text = (String) component.getClass().getMethod("getText").invoke(component);
|
||||||
Object chatModifier = component.getClass().getMethod("getChatModifier").invoke(component);
|
Object chatModifier = component.getClass().getMethod("getChatModifier").invoke(component);
|
||||||
Object color = chatModifier.getClass().getMethod("getColor").invoke(chatModifier);
|
Object color = chatModifier.getClass().getMethod("getColor").invoke(chatModifier);
|
||||||
@ -475,13 +451,10 @@ public class VentureChatFormatService {
|
|||||||
colorString = color.getClass().getMethod("b").invoke(color).toString();
|
colorString = color.getClass().getMethod("b").invoke(color).toString();
|
||||||
}
|
}
|
||||||
boolean bold = (boolean) chatModifier.getClass().getMethod("isBold").invoke(chatModifier);
|
boolean bold = (boolean) chatModifier.getClass().getMethod("isBold").invoke(chatModifier);
|
||||||
boolean strikethrough = (boolean) chatModifier.getClass().getMethod("isStrikethrough")
|
boolean strikethrough = (boolean) chatModifier.getClass().getMethod("isStrikethrough").invoke(chatModifier);
|
||||||
.invoke(chatModifier);
|
|
||||||
boolean italic = (boolean) chatModifier.getClass().getMethod("isItalic").invoke(chatModifier);
|
boolean italic = (boolean) chatModifier.getClass().getMethod("isItalic").invoke(chatModifier);
|
||||||
boolean underlined = (boolean) chatModifier.getClass().getMethod("isUnderlined")
|
boolean underlined = (boolean) chatModifier.getClass().getMethod("isUnderlined").invoke(chatModifier);
|
||||||
.invoke(chatModifier);
|
boolean obfuscated = (boolean) chatModifier.getClass().getMethod("isRandom").invoke(chatModifier);
|
||||||
boolean obfuscated = (boolean) chatModifier.getClass().getMethod("isRandom")
|
|
||||||
.invoke(chatModifier);
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("text", text);
|
jsonObject.put("text", text);
|
||||||
jsonObject.put("color", colorString);
|
jsonObject.put("color", colorString);
|
||||||
@ -537,10 +510,8 @@ public class VentureChatFormatService {
|
|||||||
for (Object component : finalList) {
|
for (Object component : finalList) {
|
||||||
if (versionService.is1_7()) {
|
if (versionService.is1_7()) {
|
||||||
stringbuilder.append((String) component.getClass().getMethod("e").invoke(component));
|
stringbuilder.append((String) component.getClass().getMethod("e").invoke(component));
|
||||||
} else if (versionService.is1_8() || versionService.is1_9() || versionService.is1_10()
|
} else if (versionService.is1_8() || versionService.is1_9() || versionService.is1_10() || versionService.is1_11() || versionService.is1_12()
|
||||||
|| versionService.is1_11() || versionService.is1_12() || versionService.is1_13()
|
|| versionService.is1_13() || versionService.is1_14() || versionService.is1_15() || versionService.is1_16() || versionService.is1_17()) {
|
||||||
|| versionService.is1_14() || versionService.is1_15() || versionService.is1_16()
|
|
||||||
|| versionService.is1_17()) {
|
|
||||||
stringbuilder.append((String) component.getClass().getMethod("getText").invoke(component));
|
stringbuilder.append((String) component.getClass().getMethod("getText").invoke(component));
|
||||||
} else {
|
} else {
|
||||||
stringbuilder.append((String) component.getClass().getMethod("getString").invoke(component));
|
stringbuilder.append((String) component.getClass().getMethod("getString").invoke(component));
|
||||||
@ -553,9 +524,8 @@ public class VentureChatFormatService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void splitComponents(List<Object> finalList, Object o, Class<?> c) throws Exception {
|
private void splitComponents(List<Object> finalList, Object o, Class<?> c) throws Exception {
|
||||||
if (versionService.is1_7() || versionService.is1_8() || versionService.is1_9() || versionService.is1_10()
|
if (versionService.is1_7() || versionService.is1_8() || versionService.is1_9() || versionService.is1_10() || versionService.is1_11() || versionService.is1_12()
|
||||||
|| versionService.is1_11() || versionService.is1_12() || versionService.is1_13()
|
|| versionService.is1_13() || (versionService.is1_14() && !versionService.is1_14_4())) {
|
||||||
|| (versionService.is1_14() && !versionService.is1_14_4())) {
|
|
||||||
ArrayList<?> list = (ArrayList<?>) c.getMethod("a").invoke(o, new Object[0]);
|
ArrayList<?> list = (ArrayList<?>) c.getMethod("a").invoke(o, new Object[0]);
|
||||||
for (Object component : list) {
|
for (Object component : list) {
|
||||||
ArrayList<?> innerList = (ArrayList<?>) c.getMethod("a").invoke(component, new Object[0]);
|
ArrayList<?> innerList = (ArrayList<?>) c.getMethod("a").invoke(component, new Object[0]);
|
||||||
@ -565,8 +535,7 @@ public class VentureChatFormatService {
|
|||||||
finalList.add(component);
|
finalList.add(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (versionService.is1_14_4() || versionService.is1_15() || versionService.is1_16()
|
} else if (versionService.is1_14_4() || versionService.is1_15() || versionService.is1_16() || versionService.is1_17()) {
|
||||||
|| versionService.is1_17()) {
|
|
||||||
ArrayList<?> list = (ArrayList<?>) c.getMethod("getSiblings").invoke(o, new Object[0]);
|
ArrayList<?> list = (ArrayList<?>) c.getMethod("getSiblings").invoke(o, new Object[0]);
|
||||||
for (Object component : list) {
|
for (Object component : list) {
|
||||||
ArrayList<?> innerList = (ArrayList<?>) c.getMethod("getSiblings").invoke(component, new Object[0]);
|
ArrayList<?> innerList = (ArrayList<?>) c.getMethod("getSiblings").invoke(component, new Object[0]);
|
||||||
@ -629,12 +598,10 @@ public class VentureChatFormatService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Sound getSound(String soundName) {
|
private Sound getSound(String soundName) {
|
||||||
if (Arrays.asList(Sound.values()).stream().map(Sound::toString).collect(Collectors.toList())
|
if (Arrays.asList(Sound.values()).stream().map(Sound::toString).collect(Collectors.toList()).contains(soundName)) {
|
||||||
.contains(soundName)) {
|
|
||||||
return Sound.valueOf(soundName);
|
return Sound.valueOf(soundName);
|
||||||
}
|
}
|
||||||
Bukkit.getConsoleSender()
|
plugin.getServer().getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Message sound invalid!"));
|
||||||
.sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Message sound invalid!"));
|
|
||||||
return getDefaultMessageSound();
|
return getDefaultMessageSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user