mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 10:39:05 +00:00
Merge branch 'Mute-Update'
Conflicts: src/bungee.yml src/plugin.yml
This commit is contained in:
commit
7d91f560b7
@ -1,4 +1,4 @@
|
|||||||
Version: 2.20.0
|
Version: 2.22.4
|
||||||
BlockCommandPlayer: '&cYou have been blocked from entering command {command}.'
|
BlockCommandPlayer: '&cYou have been blocked from entering command {command}.'
|
||||||
BlockCommandSender: '&cBlocked player &6{player} &cfrom entering command {command}.'
|
BlockCommandSender: '&cBlocked player &6{player} &cfrom entering command {command}.'
|
||||||
BlockedCommand: '&cYou are blocked from entering this command: {command}'
|
BlockedCommand: '&cYou are blocked from entering this command: {command}'
|
||||||
@ -8,7 +8,7 @@ BungeeToggleOn: '&6You are now receiving BungeeCord chat.'
|
|||||||
ClearChatSender: '&aCleared the server chat.'
|
ClearChatSender: '&aCleared the server chat.'
|
||||||
ClearChatServer: '&aYour chat has been cleared.'
|
ClearChatServer: '&aYour chat has been cleared.'
|
||||||
ChannelCannotMute: '&cYou cannot mute players in this channel: {channel_color}{channel_name}'
|
ChannelCannotMute: '&cYou cannot mute players in this channel: {channel_color}{channel_name}'
|
||||||
ChannelCooldown: '&c{cooldown} {units} of cooldown remaining.'
|
ChannelCooldown: '&c{cooldown} of cooldown remaining.'
|
||||||
ChannelList: '{channel_color}{channel_name} : {channel_alias}'
|
ChannelList: '{channel_color}{channel_name} : {channel_alias}'
|
||||||
ChannelListHeader: '&6Channel List : Alias'
|
ChannelListHeader: '&6Channel List : Alias'
|
||||||
ChannelListWithPermissions: '{channel_color}{channel_name} : {channel_alias} - Permission Required'
|
ChannelListWithPermissions: '{channel_color}{channel_name} : {channel_alias} - Permission Required'
|
||||||
@ -17,7 +17,9 @@ ChannelNoPermissionView: '&cYou do not have permission to look at this channel.'
|
|||||||
ChannelNoSpeakPermissions: '&cYou do not have permission to speak in this channel.'
|
ChannelNoSpeakPermissions: '&cYou do not have permission to speak in this channel.'
|
||||||
ChannelPlayerListHeader: '&6Players in Channel: {channel_color}{channel_name}'
|
ChannelPlayerListHeader: '&6Players in Channel: {channel_color}{channel_name}'
|
||||||
ChannelMuted: '&cYou are muted in this channel: {channel_color}{channel_name}'
|
ChannelMuted: '&cYou are muted in this channel: {channel_color}{channel_name}'
|
||||||
ChannelMutedTimed: '&cYou are muted in this channel: {channel_color}{channel_name}&c for {time} more {units}'
|
ChannelMutedReason: '&cYou are muted in this channel: {channel_color}{channel_name} &4Reason:&c {reason}'
|
||||||
|
ChannelMutedTimed: '&cYou are muted in this channel: {channel_color}{channel_name}&c for {time}'
|
||||||
|
ChannelMutedTimedReason: '&cYou are muted in this channel: {channel_color}{channel_name}&c for {time} &4Reason:&c {reason}'
|
||||||
CommandInvalidArguments: '&cInvalid command: {command} {args}'
|
CommandInvalidArguments: '&cInvalid command: {command} {args}'
|
||||||
CommandInvalidArgumentsIgnore: '&cInvalid command: /ignore [player] or /ignore list'
|
CommandInvalidArgumentsIgnore: '&cInvalid command: /ignore [player] or /ignore list'
|
||||||
CommandMustBeRunByPlayer: '&cThis command must be run by a player.'
|
CommandMustBeRunByPlayer: '&cThis command must be run by a player.'
|
||||||
@ -52,13 +54,17 @@ MessageToggleOff: '&6You are now blocking messages.'
|
|||||||
MessageToggleOn: '&6You are now receiving messages.'
|
MessageToggleOn: '&6You are now receiving messages.'
|
||||||
MustListenOneChannel: '&cYou need to be listening on at least one channel, setting you into the default channel.'
|
MustListenOneChannel: '&cYou need to be listening on at least one channel, setting you into the default channel.'
|
||||||
MutePlayerAllPlayer: '&cYou have just been muted in all channels.'
|
MutePlayerAllPlayer: '&cYou have just been muted in all channels.'
|
||||||
|
MutePlayerAllPlayerReason: '&cYou have just been muted in all channels. &4Reason:&c {reason}'
|
||||||
MutePlayerAllSender: '&cMuted player &6{player} &cin all channels.'
|
MutePlayerAllSender: '&cMuted player &6{player} &cin all channels.'
|
||||||
|
MutePlayerAllSenderReason: '&cMuted player &6{player} &cin all channels. &4Reason:&c {reason}'
|
||||||
MutePlayerPlayer: '&cYou have just been muted in: {channel_color}{channel_name}'
|
MutePlayerPlayer: '&cYou have just been muted in: {channel_color}{channel_name}'
|
||||||
MutePlayerPlayerTime: '&cYou have just been muted in: {channel_color}{channel_name} &cfor {time} {units}'
|
MutePlayerPlayerReason: '&cYou have just been muted in: {channel_color}{channel_name} &4Reason:&c {reason}'
|
||||||
MutePlayerSpam: '&cYou have been muted for spamming in: {channel_color}{channel_name}'
|
MutePlayerPlayerTime: '&cYou have just been muted in: {channel_color}{channel_name} &cfor {time}'
|
||||||
MutePlayerSpamTime: '&cYou have been muted for spamming in: {channel_color}{channel_name} &cfor {time} {units}'
|
MutePlayerPlayerTimeReason: '&cYou have just been muted in: {channel_color}{channel_name} &cfor {time} &4Reason:&c {reason}'
|
||||||
MutePlayerSender: '&cMuted player &6{player} &cin: {channel_color}{channel_name}'
|
MutePlayerSender: '&cMuted player &6{player} &cin: {channel_color}{channel_name}'
|
||||||
MutePlayerSenderTime: '&cMuted player &6{player} &cin: {channel_color}{channel_name} &cfor {time} {units}'
|
MutePlayerSenderReason: '&cMuted player &6{player} &cin: {channel_color}{channel_name} &4Reason:&c {reason}'
|
||||||
|
MutePlayerSenderTime: '&cMuted player &6{player} &cin: {channel_color}{channel_name} &cfor {time}'
|
||||||
|
MutePlayerSenderTimeReason: '&cMuted player &6{player} &cin: {channel_color}{channel_name} &cfor {time} &4Reason:&c {reason}'
|
||||||
NoPlayerToReplyTo: '&cYou do not have anyone to reply to.'
|
NoPlayerToReplyTo: '&cYou do not have anyone to reply to.'
|
||||||
NotificationsOff: '&aYou are no longer receiving notifications.'
|
NotificationsOff: '&aYou are no longer receiving notifications.'
|
||||||
NotificationsOn: '&aYou are now receiving notifications.'
|
NotificationsOn: '&aYou are now receiving notifications.'
|
||||||
@ -73,11 +79,16 @@ SetChannelAllPlayer: '&cYou have been set into all channels.'
|
|||||||
SetChannelAllSender: '&6Set player &c{player} &6into all channels.'
|
SetChannelAllSender: '&6Set player &c{player} &6into all channels.'
|
||||||
SetChannelPlayerChannelNoPermission: '&cThis player does not have permission for channel: {channel_color}{channel_name}'
|
SetChannelPlayerChannelNoPermission: '&cThis player does not have permission for channel: {channel_color}{channel_name}'
|
||||||
SetChannelSender: '&6Set player &c{player} &6into channel: {channel_color}{channel_name}'
|
SetChannelSender: '&6Set player &c{player} &6into channel: {channel_color}{channel_name}'
|
||||||
|
SpamMuteReasonText: 'Spamming'
|
||||||
SpamWarning: '&cSlow down your chat! You''re halfway to being muted for spam!'
|
SpamWarning: '&cSlow down your chat! You''re halfway to being muted for spam!'
|
||||||
SpyOff: '&6You are no longer spying.'
|
SpyOff: '&6You are no longer spying.'
|
||||||
SpyOn: '&6You are now spying.'
|
SpyOn: '&6You are now spying.'
|
||||||
UnblockCommandPlayer: '&cYou have been unblocked from entering command {command}.'
|
UnblockCommandPlayer: '&cYou have been unblocked from entering command {command}.'
|
||||||
UnblockCommandSender: '&cUnblocked player &6{player} &cfrom entering command {command}.'
|
UnblockCommandSender: '&cUnblocked player &6{player} &cfrom entering command {command}.'
|
||||||
|
UnitsDayPlural: 'days'
|
||||||
|
UnitsDaySingular: 'day'
|
||||||
|
UnitsHourPlural: 'hours'
|
||||||
|
UnitsHourSingular: 'hour'
|
||||||
UnitsMinutePlural: 'minutes'
|
UnitsMinutePlural: 'minutes'
|
||||||
UnitsMinuteSingular: 'minute'
|
UnitsMinuteSingular: 'minute'
|
||||||
UnitsSecondPlural: 'seconds'
|
UnitsSecondPlural: 'seconds'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
name: VentureChat
|
name: VentureChat
|
||||||
main: mineverse.Aust1n46.chat.bungee.MineverseChatBungee
|
main: mineverse.Aust1n46.chat.bungee.MineverseChatBungee
|
||||||
version: 2.22.3
|
version: 2.22.4
|
||||||
author: Aust1n46
|
author: Aust1n46
|
@ -55,14 +55,17 @@ commandspy:
|
|||||||
antispam:
|
antispam:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
# number of messages to be spam
|
# Number of messages to be spam
|
||||||
spamnumber: 5
|
spamnumber: 5
|
||||||
|
|
||||||
# amount of time in seconds for it to be spam
|
# Amount of time in seconds for it to be spam
|
||||||
spamtime: 10
|
spamtime: 10
|
||||||
|
|
||||||
# amount of time in minutes for the mute to last, use 0 for untimed mute
|
# Amount of time for the mute to last
|
||||||
mutetime: 10
|
# Acceptable units are: d,h,m,s
|
||||||
|
# Units can be combined, for example: 1d8h30m15s
|
||||||
|
# Use 0 for untimed mute
|
||||||
|
mutetime: 10m
|
||||||
|
|
||||||
# Logging chat and commands to a mysql database
|
# Logging chat and commands to a mysql database
|
||||||
mysql:
|
mysql:
|
||||||
@ -105,6 +108,9 @@ unmuteinterval: 60
|
|||||||
# Enables or disabled BungeeCord messaging
|
# Enables or disabled BungeeCord messaging
|
||||||
bungeecordmessaging: false
|
bungeecordmessaging: false
|
||||||
|
|
||||||
|
# Sound for message notification
|
||||||
|
message_sound: ENTITY_PLAYER_LEVELUP
|
||||||
|
|
||||||
# This will allow vanished players to be exempt from being sent private messages, and will act as if they aren't online
|
# This will allow vanished players to be exempt from being sent private messages, and will act as if they aren't online
|
||||||
vanishsupport: true
|
vanishsupport: true
|
||||||
|
|
||||||
@ -179,16 +185,16 @@ venturegui:
|
|||||||
mute:
|
mute:
|
||||||
icon: 'REDSTONE_BLOCK'
|
icon: 'REDSTONE_BLOCK'
|
||||||
durability: 0
|
durability: 0
|
||||||
text: '&cMute {player_name}'
|
text: '&cMute {player_name} &410m'
|
||||||
permission: 'mute'
|
permission: 'mute'
|
||||||
command: '/mute {player_name} {channel} 10'
|
command: '/mute {channel} {player_name} 10m'
|
||||||
slot: 1
|
slot: 1
|
||||||
unmute:
|
unmute:
|
||||||
icon: 'DIAMOND_BLOCK'
|
icon: 'DIAMOND_BLOCK'
|
||||||
durability: 0
|
durability: 0
|
||||||
text: '&bUnmute {player_name}'
|
text: '&bUnmute {player_name}'
|
||||||
permission: 'mute'
|
permission: 'mute'
|
||||||
command: '/unmute {player_name} {channel}'
|
command: '/unmute {channel} {player_name} '
|
||||||
slot: 2
|
slot: 2
|
||||||
removemessage:
|
removemessage:
|
||||||
icon: 'DIAMOND_AXE'
|
icon: 'DIAMOND_AXE'
|
||||||
|
@ -55,14 +55,17 @@ commandspy:
|
|||||||
antispam:
|
antispam:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
# number of messages to be spam
|
# Number of messages to be spam
|
||||||
spamnumber: 5
|
spamnumber: 5
|
||||||
|
|
||||||
# amount of time in seconds for it to be spam
|
# Amount of time in seconds for it to be spam
|
||||||
spamtime: 10
|
spamtime: 10
|
||||||
|
|
||||||
# amount of time in minutes for the mute to last, use 0 for untimed mute
|
# Amount of time for the mute to last
|
||||||
mutetime: 10
|
# Acceptable units are: d,h,m,s
|
||||||
|
# Units can be combined, for example: 1d8h30m15s
|
||||||
|
# Use 0 for untimed mute
|
||||||
|
mutetime: 10m
|
||||||
|
|
||||||
# Logging chat and commands to a mysql database
|
# Logging chat and commands to a mysql database
|
||||||
mysql:
|
mysql:
|
||||||
@ -105,6 +108,9 @@ unmuteinterval: 60
|
|||||||
# Enables or disabled BungeeCord messaging
|
# Enables or disabled BungeeCord messaging
|
||||||
bungeecordmessaging: false
|
bungeecordmessaging: false
|
||||||
|
|
||||||
|
# Sound for message notification
|
||||||
|
message_sound: ENTITY_PLAYER_LEVELUP
|
||||||
|
|
||||||
# This will allow vanished players to be exempt from being sent private messages, and will act as if they aren't online
|
# This will allow vanished players to be exempt from being sent private messages, and will act as if they aren't online
|
||||||
vanishsupport: true
|
vanishsupport: true
|
||||||
|
|
||||||
@ -179,16 +185,16 @@ venturegui:
|
|||||||
mute:
|
mute:
|
||||||
icon: 'REDSTONE_BLOCK'
|
icon: 'REDSTONE_BLOCK'
|
||||||
durability: 0
|
durability: 0
|
||||||
text: '&cMute {player_name}'
|
text: '&cMute {player_name} &410m'
|
||||||
permission: 'mute'
|
permission: 'mute'
|
||||||
command: '/mute {player_name} {channel} 10'
|
command: '/mute {channel} {player_name} 10m'
|
||||||
slot: 1
|
slot: 1
|
||||||
unmute:
|
unmute:
|
||||||
icon: 'DIAMOND_BLOCK'
|
icon: 'DIAMOND_BLOCK'
|
||||||
durability: 0
|
durability: 0
|
||||||
text: '&bUnmute {player_name}'
|
text: '&bUnmute {player_name}'
|
||||||
permission: 'mute'
|
permission: 'mute'
|
||||||
command: '/unmute {player_name} {channel}'
|
command: '/unmute {channel} {player_name} '
|
||||||
slot: 2
|
slot: 2
|
||||||
removemessage:
|
removemessage:
|
||||||
icon: 'DIAMOND_AXE'
|
icon: 'DIAMOND_AXE'
|
@ -1,7 +1,3 @@
|
|||||||
/*
|
|
||||||
* VentureChat plugin for Minecraft servers running Bukkit or Spigot software.
|
|
||||||
* @author Aust1n46
|
|
||||||
*/
|
|
||||||
package mineverse.Aust1n46.chat;
|
package mineverse.Aust1n46.chat;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@ -12,9 +8,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -81,11 +75,11 @@ import mineverse.Aust1n46.chat.command.message.Notifications;
|
|||||||
import mineverse.Aust1n46.chat.command.message.Reply;
|
import mineverse.Aust1n46.chat.command.message.Reply;
|
||||||
import mineverse.Aust1n46.chat.command.message.Spy;
|
import mineverse.Aust1n46.chat.command.message.Spy;
|
||||||
import mineverse.Aust1n46.chat.command.mute.Mute;
|
import mineverse.Aust1n46.chat.command.mute.Mute;
|
||||||
|
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
|
||||||
import mineverse.Aust1n46.chat.command.mute.Muteall;
|
import mineverse.Aust1n46.chat.command.mute.Muteall;
|
||||||
import mineverse.Aust1n46.chat.command.mute.Unmute;
|
import mineverse.Aust1n46.chat.command.mute.Unmute;
|
||||||
import mineverse.Aust1n46.chat.command.mute.Unmuteall;
|
import mineverse.Aust1n46.chat.command.mute.Unmuteall;
|
||||||
import mineverse.Aust1n46.chat.database.Database;
|
import mineverse.Aust1n46.chat.database.Database;
|
||||||
import mineverse.Aust1n46.chat.database.MySQL;
|
|
||||||
import mineverse.Aust1n46.chat.database.PlayerData;
|
import mineverse.Aust1n46.chat.database.PlayerData;
|
||||||
import mineverse.Aust1n46.chat.gui.GuiSlotInfo;
|
import mineverse.Aust1n46.chat.gui.GuiSlotInfo;
|
||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
@ -97,15 +91,12 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.command.SimpleCommandMap;
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
import org.bukkit.Sound;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
@ -113,6 +104,10 @@ import com.comphenix.protocol.utility.MinecraftReflection;
|
|||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VentureChat Minecraft plugin for servers running Spigot or Paper software.
|
||||||
|
* @author Aust1n46
|
||||||
|
*/
|
||||||
public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
||||||
// Listeners --------------------------------
|
// Listeners --------------------------------
|
||||||
private ChatListener chatListener;
|
private ChatListener chatListener;
|
||||||
@ -135,9 +130,6 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
private MineverseCommandExecutor commandExecutor;
|
private MineverseCommandExecutor commandExecutor;
|
||||||
private Map<String, MineverseCommand> commands = new HashMap<String, MineverseCommand>();
|
private Map<String, MineverseCommand> commands = new HashMap<String, MineverseCommand>();
|
||||||
|
|
||||||
// Database ------------------------------------
|
|
||||||
public Database db = null;
|
|
||||||
|
|
||||||
// Misc --------------------------------
|
// Misc --------------------------------
|
||||||
public static AliasInfo aaInfo;
|
public static AliasInfo aaInfo;
|
||||||
public static JsonFormatInfo jfInfo;
|
public static JsonFormatInfo jfInfo;
|
||||||
@ -195,7 +187,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Config found! Loading file."));
|
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Config found! Loading file."));
|
||||||
}
|
}
|
||||||
|
|
||||||
saveResource("defaultconfig.yml", true);
|
saveResource("example_config_always_up_to_date!.yml", true);
|
||||||
}
|
}
|
||||||
catch(Exception ex) {
|
catch(Exception ex) {
|
||||||
log.severe(String.format("[" + String.format("VentureChat") + "]" + " - Could not load configuration!\n " + ex, getDescription().getName()));
|
log.severe(String.format("[" + String.format("VentureChat") + "]" + " - Could not load configuration!\n " + ex, getDescription().getName()));
|
||||||
@ -249,16 +241,9 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
MineverseChatAPI.addNameToMap(mcp);
|
MineverseChatAPI.addNameToMap(mcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileConfiguration config = getConfig();
|
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
|
||||||
ConfigurationSection mysqlConfig = config.getConfigurationSection("mysql");
|
Database.initializeMySQL();
|
||||||
if (this.getConfig().getConfigurationSection("mysql").getBoolean("enabled")) {
|
});
|
||||||
String host = mysqlConfig.getString("host");
|
|
||||||
int port = mysqlConfig.getInt("port");
|
|
||||||
String database = mysqlConfig.getString("database");
|
|
||||||
String user = mysqlConfig.getString("user");
|
|
||||||
String password = mysqlConfig.getString("password");
|
|
||||||
db = new MySQL(host, port, database, user, password);
|
|
||||||
}
|
|
||||||
|
|
||||||
commands.put("broadcast", new Broadcast("broadcast"));
|
commands.put("broadcast", new Broadcast("broadcast"));
|
||||||
commands.put("channel", new Channel("channel"));
|
commands.put("channel", new Channel("channel"));
|
||||||
@ -391,25 +376,27 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (MineverseChatPlayer p : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
for (MineverseChatPlayer p : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
||||||
int time = Format.currentTimeMillis();
|
long currentTimeMillis = System.currentTimeMillis();
|
||||||
Iterator<String> iterator = p.getMutes().keySet().iterator();
|
Iterator<MuteContainer> iterator = p.getMutes().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
ChatChannel channel = ChatChannel.getChannel(iterator.next());
|
MuteContainer mute = iterator.next();
|
||||||
int timemark = p.getMutes().get(channel.getName());
|
if(ChatChannel.isChannel(mute.getChannel())) {
|
||||||
if (timemark == 0) {
|
ChatChannel channel = ChatChannel.getChannel(mute.getChannel());
|
||||||
continue;
|
long timemark = mute.getDuration();
|
||||||
}
|
if (timemark == 0) {
|
||||||
if (getConfig().getString("loglevel", "info").equals("debug")) {
|
continue;
|
||||||
System.out.println(time + " " + timemark);
|
}
|
||||||
}
|
if (getConfig().getString("loglevel", "info").equals("debug")) {
|
||||||
if (time >= timemark) {
|
System.out.println(currentTimeMillis + " " + timemark);
|
||||||
iterator.remove();
|
}
|
||||||
if (p.isOnline()) {
|
if (currentTimeMillis >= timemark) {
|
||||||
|
iterator.remove();
|
||||||
p.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString()
|
p.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString()
|
||||||
.replace("{player}", p.getName()).replace("{channel_color}", channel.getColor())
|
.replace("{player}", p.getName()).replace("{channel_color}", channel.getColor())
|
||||||
.replace("{channel_name}", channel.getName()));
|
.replace("{channel_name}", mute.getChannel()));
|
||||||
} else {
|
if(channel.getBungee()) {
|
||||||
p.setModified(true);
|
MineverseChat.getInstance().synchronize(p, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -419,7 +406,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
.sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Updating Player Mutes"));
|
.sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Updating Player Mutes"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0L, 1200L); // one minute interval
|
}, 0L, 60L); // three second interval
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -548,6 +535,15 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
// 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(this, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(mcp.hasPlayed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
synchronize(mcp, false);
|
||||||
|
}
|
||||||
|
}, 20L); // one second delay before running again
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
out.writeUTF("Update");
|
out.writeUTF("Update");
|
||||||
@ -569,18 +565,20 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
// out.writeUTF("Mutes");
|
// out.writeUTF("Mutes");
|
||||||
int muteCount = 0;
|
int muteCount = 0;
|
||||||
for(String c : mcp.getMutes().keySet()) {
|
for(MuteContainer mute : mcp.getMutes()) {
|
||||||
ChatChannel channel = ChatChannel.getChannel(c);
|
ChatChannel channel = ChatChannel.getChannel(mute.getChannel());
|
||||||
if(channel.getBungee()) {
|
if(channel.getBungee()) {
|
||||||
muteCount++;
|
muteCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// System.out.println(muteCount + " mutes");
|
// System.out.println(muteCount + " mutes");
|
||||||
out.write(muteCount);
|
out.write(muteCount);
|
||||||
for(String c : mcp.getMutes().keySet()) {
|
for(MuteContainer mute : mcp.getMutes()) {
|
||||||
ChatChannel channel = ChatChannel.getChannel(c);
|
ChatChannel channel = ChatChannel.getChannel(mute.getChannel());
|
||||||
if(channel.getBungee()) {
|
if(channel.getBungee()) {
|
||||||
out.writeUTF(channel.getName());
|
out.writeUTF(channel.getName());
|
||||||
|
out.writeLong(mute.getDuration());
|
||||||
|
out.writeUTF(mute.getReason());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int ignoreCount = 0;
|
int ignoreCount = 0;
|
||||||
@ -607,6 +605,10 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendPluginMessage(ByteArrayOutputStream byteOutStream) {
|
||||||
|
MineverseChatAPI.getOnlineMineverseChatPlayers().iterator().next().getPlayer().sendPluginMessage(MineverseChat.getInstance(), MineverseChat.PLUGIN_MESSAGING_CHANNEL, byteOutStream.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendDiscordSRVPluginMessage(String chatChannel, String message) {
|
public static void sendDiscordSRVPluginMessage(String chatChannel, String message) {
|
||||||
if(MineverseChatAPI.getOnlineMineverseChatPlayers().size() == 0) {
|
if(MineverseChatAPI.getOnlineMineverseChatPlayers().size() == 0) {
|
||||||
return;
|
return;
|
||||||
@ -680,11 +682,8 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
|
|
||||||
Bukkit.getConsoleSender().sendMessage(consoleChat);
|
Bukkit.getConsoleSender().sendMessage(consoleChat);
|
||||||
|
|
||||||
if(db != null) {
|
if(Database.isEnabled()) {
|
||||||
Calendar currentDate = Calendar.getInstance();
|
Database.writeVentureChat(senderUUID.toString(), senderName, server, chatchannel, chat.replace("'", "''"), "Chat");
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
String date = formatter.format(currentDate.getTime());
|
|
||||||
db.writeVentureChat(date, senderUUID.toString(), senderName, server, chatchannel, chat.replace("'", "''"), "Chat");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(MineverseChatPlayer p : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
for(MineverseChatPlayer p : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
||||||
@ -794,6 +793,9 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
String uuid = msgin.readUTF();
|
String uuid = msgin.readUTF();
|
||||||
MineverseChatPlayer p = MineverseChatAPI.getMineverseChatPlayer(UUID.fromString(uuid));
|
MineverseChatPlayer p = MineverseChatAPI.getMineverseChatPlayer(UUID.fromString(uuid));
|
||||||
|
if(p.hasPlayed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for(Object ch : p.getListening().toArray()) {
|
for(Object ch : p.getListening().toArray()) {
|
||||||
String c = ch.toString();
|
String c = ch.toString();
|
||||||
ChatChannel cha = ChatChannel.getChannel(c);
|
ChatChannel cha = ChatChannel.getChannel(c);
|
||||||
@ -811,19 +813,16 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(Object o : p.getMutes().keySet().toArray()) {
|
p.getMutes().removeIf(mute -> ChatChannel.getChannel(mute.getChannel()).getBungee());
|
||||||
ChatChannel ch = ChatChannel.getChannel((String) o);
|
|
||||||
if(ch.getBungee()) {
|
|
||||||
p.removeMute(ch.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int sizeB = msgin.read();
|
int sizeB = msgin.read();
|
||||||
// System.out.println(sizeB + " mute size");
|
// System.out.println(sizeB + " mute size");
|
||||||
for(int b = 0; b < sizeB; b++) {
|
for(int b = 0; b < sizeB; b++) {
|
||||||
String ch = msgin.readUTF();
|
String ch = msgin.readUTF();
|
||||||
|
long muteTime = msgin.readLong();
|
||||||
|
String muteReason = msgin.readUTF();
|
||||||
// System.out.println(ch);
|
// System.out.println(ch);
|
||||||
if(ChatChannel.isChannel(ch)) {
|
if(ChatChannel.isChannel(ch)) {
|
||||||
p.addMute(ch, 0);
|
p.addMute(ch, muteTime, muteReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// System.out.println(msgin.available() + " available before");
|
// System.out.println(msgin.available() + " available before");
|
||||||
@ -843,7 +842,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
if(!p.hasPlayed()) {
|
if(!p.hasPlayed()) {
|
||||||
boolean isThereABungeeChannel = false;
|
boolean isThereABungeeChannel = false;
|
||||||
for(ChatChannel ch : ChatChannel.getAutojoinList()) {
|
for(ChatChannel ch : ChatChannel.getAutojoinList()) {
|
||||||
if(!ch.hasPermission() || p.getPlayer().hasPermission(ch.getPermission())) {
|
if((!ch.hasPermission() || p.getPlayer().hasPermission(ch.getPermission())) && !p.isListening(ch.getName())) {
|
||||||
p.addListening(ch.getName());
|
p.addListening(ch.getName());
|
||||||
if(ch.getBungee()) {
|
if(ch.getBungee()) {
|
||||||
isThereABungeeChannel = true;
|
isThereABungeeChannel = true;
|
||||||
@ -909,6 +908,324 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
this.synchronize(p, true);
|
this.synchronize(p, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(subchannel.equals("Mute")) {
|
||||||
|
String identifier = msgin.readUTF();
|
||||||
|
if(identifier.equals("Send")) {
|
||||||
|
String server = msgin.readUTF();
|
||||||
|
String senderIdentifier = msgin.readUTF();
|
||||||
|
String temporaryDataInstanceUUIDString = msgin.readUTF();
|
||||||
|
String playerToMute = msgin.readUTF();
|
||||||
|
String channelName = msgin.readUTF();
|
||||||
|
long time = msgin.readLong();
|
||||||
|
String reason = msgin.readUTF();
|
||||||
|
MineverseChatPlayer playerToMuteMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(playerToMute);
|
||||||
|
if(playerToMuteMCP == null) {
|
||||||
|
out.writeUTF("Mute");
|
||||||
|
out.writeUTF("Offline");
|
||||||
|
out.writeUTF(server);
|
||||||
|
out.writeUTF(temporaryDataInstanceUUIDString);
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(playerToMute);
|
||||||
|
sendPluginMessage(stream);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!ChatChannel.isChannel(channelName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ChatChannel chatChannelObj = ChatChannel.getChannel(channelName);
|
||||||
|
if (playerToMuteMCP.isMuted(chatChannelObj.getName())) {
|
||||||
|
out.writeUTF("Mute");
|
||||||
|
out.writeUTF("AlreadyMuted");
|
||||||
|
out.writeUTF(server);
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(playerToMute);
|
||||||
|
out.writeUTF(channelName);
|
||||||
|
sendPluginMessage(stream);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(time > 0) {
|
||||||
|
long datetime = System.currentTimeMillis();
|
||||||
|
if(reason.isEmpty()) {
|
||||||
|
playerToMuteMCP.addMute(chatChannelObj.getName(), datetime + time);
|
||||||
|
String timeString = Format.parseTimeStringFromMillis(time);
|
||||||
|
playerToMuteMCP.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME.toString()
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName())
|
||||||
|
.replace("{time}", timeString));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
playerToMuteMCP.addMute(chatChannelObj.getName(), datetime + time, reason);
|
||||||
|
String timeString = Format.parseTimeStringFromMillis(time);
|
||||||
|
playerToMuteMCP.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME_REASON.toString()
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName())
|
||||||
|
.replace("{time}", timeString)
|
||||||
|
.replace("{reason}", reason));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(reason.isEmpty()) {
|
||||||
|
playerToMuteMCP.addMute(chatChannelObj.getName());
|
||||||
|
playerToMuteMCP.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER.toString()
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
playerToMuteMCP.addMute(chatChannelObj.getName(), reason);
|
||||||
|
playerToMuteMCP.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_REASON.toString()
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName())
|
||||||
|
.replace("{reason}", reason));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
synchronize(playerToMuteMCP, true);
|
||||||
|
out.writeUTF("Mute");
|
||||||
|
out.writeUTF("Valid");
|
||||||
|
out.writeUTF(server);
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(playerToMute);
|
||||||
|
out.writeUTF(channelName);
|
||||||
|
out.writeLong(time);
|
||||||
|
out.writeUTF(reason);
|
||||||
|
sendPluginMessage(stream);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(identifier.equals("Valid")) {
|
||||||
|
String senderIdentifier = msgin.readUTF();
|
||||||
|
String playerToMute = msgin.readUTF();
|
||||||
|
String channelName = msgin.readUTF();
|
||||||
|
long time = msgin.readLong();
|
||||||
|
String reason = msgin.readUTF();
|
||||||
|
if(!ChatChannel.isChannel(channelName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ChatChannel chatChannelObj = ChatChannel.getChannel(channelName);
|
||||||
|
if(time > 0) {
|
||||||
|
String timeString = Format.parseTimeStringFromMillis(time);
|
||||||
|
if(reason.isEmpty()) {
|
||||||
|
if(senderIdentifier.equals("VentureChat:Console")) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
|
||||||
|
.replace("{player}", playerToMute)
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName())
|
||||||
|
.replace("{time}", timeString));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
|
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
|
||||||
|
senderMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
|
||||||
|
.replace("{player}", playerToMute)
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName())
|
||||||
|
.replace("{time}", timeString));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(senderIdentifier.equals("VentureChat:Console")) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME_REASON.toString()
|
||||||
|
.replace("{player}", playerToMute)
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName())
|
||||||
|
.replace("{time}", timeString)
|
||||||
|
.replace("{reason}", reason));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
|
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
|
||||||
|
senderMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME_REASON.toString()
|
||||||
|
.replace("{player}", playerToMute)
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName())
|
||||||
|
.replace("{time}", timeString)
|
||||||
|
.replace("{reason}", reason));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(reason.isEmpty()) {
|
||||||
|
if(senderIdentifier.equals("VentureChat:Console")) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString()
|
||||||
|
.replace("{player}", playerToMute)
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
|
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
|
||||||
|
senderMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString()
|
||||||
|
.replace("{player}", playerToMute)
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(senderIdentifier.equals("VentureChat:Console")) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_REASON.toString()
|
||||||
|
.replace("{player}", playerToMute)
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName())
|
||||||
|
.replace("{reason}", reason));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
|
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
|
||||||
|
senderMCP.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_REASON.toString()
|
||||||
|
.replace("{player}", playerToMute)
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName())
|
||||||
|
.replace("{reason}", reason));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(identifier.equals("Offline")) {
|
||||||
|
String senderIdentifier = msgin.readUTF();
|
||||||
|
String playerToMute = msgin.readUTF();
|
||||||
|
if(senderIdentifier.equals("VentureChat:Console")) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString()
|
||||||
|
.replace("{args}", playerToMute));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
|
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
|
||||||
|
senderMCP.getPlayer().sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString()
|
||||||
|
.replace("{args}", playerToMute));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(identifier.equals("AlreadyMuted")) {
|
||||||
|
String senderIdentifier = msgin.readUTF();
|
||||||
|
String playerToMute = msgin.readUTF();
|
||||||
|
String channelName = msgin.readUTF();
|
||||||
|
if(!ChatChannel.isChannel(channelName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ChatChannel chatChannelObj = ChatChannel.getChannel(channelName);
|
||||||
|
if(senderIdentifier.equals("VentureChat:Console")) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.PLAYER_ALREADY_MUTED.toString()
|
||||||
|
.replace("{player}", playerToMute).replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
|
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
|
||||||
|
senderMCP.getPlayer().sendMessage(LocalizedMessage.PLAYER_ALREADY_MUTED.toString()
|
||||||
|
.replace("{player}", playerToMute).replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(subchannel.equals("Unmute")) {
|
||||||
|
String identifier = msgin.readUTF();
|
||||||
|
if(identifier.equals("Send")) {
|
||||||
|
String server = msgin.readUTF();
|
||||||
|
String senderIdentifier = msgin.readUTF();
|
||||||
|
String temporaryDataInstanceUUIDString = msgin.readUTF();
|
||||||
|
String playerToUnmute = msgin.readUTF();
|
||||||
|
String channelName = msgin.readUTF();
|
||||||
|
MineverseChatPlayer playerToUnmuteMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(playerToUnmute);
|
||||||
|
if(playerToUnmuteMCP == null) {
|
||||||
|
out.writeUTF("Unmute");
|
||||||
|
out.writeUTF("Offline");
|
||||||
|
out.writeUTF(server);
|
||||||
|
out.writeUTF(temporaryDataInstanceUUIDString);
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(playerToUnmute);
|
||||||
|
sendPluginMessage(stream);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!ChatChannel.isChannel(channelName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ChatChannel chatChannelObj = ChatChannel.getChannel(channelName);
|
||||||
|
if (!playerToUnmuteMCP.isMuted(chatChannelObj.getName())) {
|
||||||
|
out.writeUTF("Unmute");
|
||||||
|
out.writeUTF("NotMuted");
|
||||||
|
out.writeUTF(server);
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(playerToUnmute);
|
||||||
|
out.writeUTF(channelName);
|
||||||
|
sendPluginMessage(stream);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
playerToUnmuteMCP.removeMute(chatChannelObj.getName());
|
||||||
|
playerToUnmuteMCP.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString()
|
||||||
|
.replace("{player}", player.getName()).replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName()));
|
||||||
|
synchronize(playerToUnmuteMCP, true);
|
||||||
|
out.writeUTF("Unmute");
|
||||||
|
out.writeUTF("Valid");
|
||||||
|
out.writeUTF(server);
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(playerToUnmute);
|
||||||
|
out.writeUTF(channelName);
|
||||||
|
sendPluginMessage(stream);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(identifier.equals("Valid")) {
|
||||||
|
String senderIdentifier = msgin.readUTF();
|
||||||
|
String playerToUnmute = msgin.readUTF();
|
||||||
|
String channelName = msgin.readUTF();
|
||||||
|
if(!ChatChannel.isChannel(channelName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ChatChannel chatChannelObj = ChatChannel.getChannel(channelName);
|
||||||
|
if(senderIdentifier.equals("VentureChat:Console")) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.UNMUTE_PLAYER_SENDER.toString()
|
||||||
|
.replace("{player}", playerToUnmute)
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
|
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
|
||||||
|
senderMCP.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_SENDER.toString()
|
||||||
|
.replace("{player}", playerToUnmute)
|
||||||
|
.replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName()));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(identifier.equals("Offline")) {
|
||||||
|
String senderIdentifier = msgin.readUTF();
|
||||||
|
String playerToUnmute = msgin.readUTF();
|
||||||
|
if(senderIdentifier.equals("VentureChat:Console")) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString()
|
||||||
|
.replace("{args}", playerToUnmute));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
|
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
|
||||||
|
senderMCP.getPlayer().sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString()
|
||||||
|
.replace("{args}", playerToUnmute));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(identifier.equals("NotMuted")) {
|
||||||
|
String senderIdentifier = msgin.readUTF();
|
||||||
|
String playerToUnmute = msgin.readUTF();
|
||||||
|
String channelName = msgin.readUTF();
|
||||||
|
if(!ChatChannel.isChannel(channelName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ChatChannel chatChannelObj = ChatChannel.getChannel(channelName);
|
||||||
|
if(senderIdentifier.equals("VentureChat:Console")) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(LocalizedMessage.PLAYER_NOT_MUTED.toString()
|
||||||
|
.replace("{player}", playerToUnmute).replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UUID sender = UUID.fromString(senderIdentifier);
|
||||||
|
MineverseChatPlayer senderMCP = MineverseChatAPI.getOnlineMineverseChatPlayer(sender);
|
||||||
|
senderMCP.getPlayer().sendMessage(LocalizedMessage.PLAYER_NOT_MUTED.toString()
|
||||||
|
.replace("{player}", playerToUnmute).replace("{channel_color}", chatChannelObj.getColor())
|
||||||
|
.replace("{channel_name}", chatChannelObj.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(subchannel.equals("Message")) {
|
if(subchannel.equals("Message")) {
|
||||||
String identifier = msgin.readUTF();
|
String identifier = msgin.readUTF();
|
||||||
if(identifier.equals("Send")) {
|
if(identifier.equals("Send")) {
|
||||||
@ -917,12 +1234,11 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
MineverseChatPlayer p = MineverseChatAPI.getOnlineMineverseChatPlayer(receiver);
|
MineverseChatPlayer p = MineverseChatAPI.getOnlineMineverseChatPlayer(receiver);
|
||||||
UUID sender = UUID.fromString(msgin.readUTF());
|
UUID sender = UUID.fromString(msgin.readUTF());
|
||||||
String sName = msgin.readUTF();
|
String sName = msgin.readUTF();
|
||||||
MineverseChatPlayer s = MineverseChatAPI.getMineverseChatPlayer(sender);
|
|
||||||
String send = msgin.readUTF();
|
String send = msgin.readUTF();
|
||||||
String echo = msgin.readUTF();
|
String echo = msgin.readUTF();
|
||||||
String spy = msgin.readUTF();
|
String spy = msgin.readUTF();
|
||||||
String msg = msgin.readUTF();
|
String msg = msgin.readUTF();
|
||||||
if(!this.getConfig().getBoolean("bungeecordmessaging", true) || p == null || !p.isOnline()) {
|
if(!this.getConfig().getBoolean("bungeecordmessaging", true) || p == null) {
|
||||||
out.writeUTF("Message");
|
out.writeUTF("Message");
|
||||||
out.writeUTF("Offline");
|
out.writeUTF("Offline");
|
||||||
out.writeUTF(server);
|
out.writeUTF(server);
|
||||||
@ -949,28 +1265,9 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
UUID uuid = sender;
|
|
||||||
String name = sName;
|
|
||||||
ChatChannel current = ChatChannel.getDefaultChannel();
|
|
||||||
Set<UUID> ignores = new HashSet<UUID>();
|
|
||||||
Set<String> listening = new HashSet<String>();
|
|
||||||
listening.add(current.getName());
|
|
||||||
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
|
||||||
Set<String> blockedCommands = new HashSet<String>();
|
|
||||||
String jsonFormat = "Default";
|
|
||||||
s = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, false, null, true, true, name, jsonFormat, false, false, false, true, true);
|
|
||||||
MineverseChatAPI.addMineverseChatPlayerToMap(s);
|
|
||||||
MineverseChatAPI.addNameToMap(s);
|
|
||||||
}
|
|
||||||
p.getPlayer().sendMessage(Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(p.getPlayer(), send.replaceAll("receiver_", ""))) + msg);
|
p.getPlayer().sendMessage(Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(p.getPlayer(), send.replaceAll("receiver_", ""))) + msg);
|
||||||
if(p.hasNotifications()) {
|
if(p.hasNotifications()) {
|
||||||
if(VersionHandler.is1_8() || VersionHandler.is1_7_10() || VersionHandler.is1_7_2() || VersionHandler.is1_7_9()) {
|
Format.playMessageSound(p);
|
||||||
p.getPlayer().playSound(p.getPlayer().getLocation(), Sound.valueOf("LEVEL_UP"), 1, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
p.getPlayer().playSound(p.getPlayer().getLocation(), Sound.valueOf("ENTITY_PLAYER_LEVELUP"), 1, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p.setReplyPlayer(sender);
|
p.setReplyPlayer(sender);
|
||||||
out.writeUTF("Message");
|
out.writeUTF("Message");
|
||||||
@ -1021,319 +1318,14 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
String receiverName = msgin.readUTF();
|
String receiverName = msgin.readUTF();
|
||||||
String senderName = msgin.readUTF();
|
String senderName = msgin.readUTF();
|
||||||
String spy = msgin.readUTF();
|
String spy = msgin.readUTF();
|
||||||
for(MineverseChatPlayer pl : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
if(!spy.startsWith("VentureChat:NoSpy")) {
|
||||||
if(pl.isSpy() && !pl.getName().equals(senderName) && !pl.getName().equals(receiverName)) {
|
for(MineverseChatPlayer pl : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
||||||
pl.getPlayer().sendMessage(spy);
|
if(pl.isSpy() && !pl.getName().equals(senderName) && !pl.getName().equals(receiverName)) {
|
||||||
}
|
pl.getPlayer().sendMessage(spy);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(subchannel.equals("Mute")) {
|
|
||||||
String sendplayer = msgin.readUTF();
|
|
||||||
String mutePlayer = msgin.readUTF();
|
|
||||||
String chatchannel = msgin.readUTF();
|
|
||||||
String server = msgin.readUTF();
|
|
||||||
String time = msgin.readUTF();
|
|
||||||
int numtime = 0;
|
|
||||||
MineverseChatPlayer p = MineverseChatAPI.getMineverseChatPlayer(mutePlayer);
|
|
||||||
ChatChannel cc = ChatChannel.getChannel(chatchannel);
|
|
||||||
if(cc == null) {
|
|
||||||
try {
|
|
||||||
out.writeUTF("Mute");
|
|
||||||
out.writeUTF("Channel");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(chatchannel);
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(p == null) {
|
|
||||||
try {
|
|
||||||
out.writeUTF("Mute");
|
|
||||||
out.writeUTF("Player");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(mutePlayer);
|
|
||||||
out.writeUTF(server);
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(!cc.isMutable()) {
|
|
||||||
try {
|
|
||||||
out.writeUTF("Mute");
|
|
||||||
out.writeUTF("Mutable");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(cc.getName());
|
|
||||||
out.writeUTF(cc.getColor());
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(p.isMuted(cc.getName())) {
|
|
||||||
try {
|
|
||||||
out.writeUTF("Mute");
|
|
||||||
out.writeUTF("Already");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(mutePlayer);
|
|
||||||
out.writeUTF(cc.getName());
|
|
||||||
out.writeUTF(cc.getColor());
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(!time.equals("None\n")) {
|
|
||||||
try {
|
|
||||||
numtime = Integer.parseInt(time);
|
|
||||||
if(numtime > 0) {
|
|
||||||
Calendar currentDate = Calendar.getInstance();
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd:HH:mm:ss");
|
|
||||||
String date = formatter.format(currentDate.getTime());
|
|
||||||
String[] datearray = date.split(":");
|
|
||||||
int datetime = (Integer.parseInt(datearray[0]) * 1440) + (Integer.parseInt(datearray[1]) * 60) + (Integer.parseInt(datearray[2]));
|
|
||||||
p.addMute(cc.getName(), datetime + numtime);
|
|
||||||
String keyword = "minutes";
|
|
||||||
if(numtime == 1) keyword = "minute";
|
|
||||||
if(p.isOnline()) p.getPlayer().sendMessage(ChatColor.RED + "You have just been muted in: " + ChatColor.valueOf(cc.getColor().toUpperCase()) + cc.getName() + ChatColor.RED + " for " + time + " " + keyword);
|
|
||||||
else p.setModified(true);
|
|
||||||
if(cc.getBungee()) {
|
|
||||||
MineverseChat.getInstance().synchronize(p, true);
|
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
out.writeUTF("Mute");
|
|
||||||
out.writeUTF("Valid");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(mutePlayer);
|
|
||||||
out.writeUTF(cc.getName());
|
|
||||||
out.writeUTF(cc.getColor());
|
|
||||||
out.writeUTF(time);
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
out.writeUTF("Mute");
|
|
||||||
out.writeUTF("Time");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(time);
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
try {
|
|
||||||
out.writeUTF("Mute");
|
|
||||||
out.writeUTF("Time");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(time);
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.addMute(cc.getName(), 0);
|
|
||||||
if(p.isOnline()) p.getPlayer().sendMessage(ChatColor.RED + "You have just been muted in: " + ChatColor.valueOf(cc.getColor().toUpperCase()) + cc.getName());
|
|
||||||
else p.setModified(true);
|
|
||||||
if(cc.getBungee()) {
|
|
||||||
MineverseChat.getInstance().synchronize(p, true);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
out.writeUTF("Mute");
|
|
||||||
out.writeUTF("Valid");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(mutePlayer);
|
|
||||||
out.writeUTF(cc.getName());
|
|
||||||
out.writeUTF(cc.getColor());
|
|
||||||
out.writeUTF(time);
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(subchannel.equals("Muteall")) {
|
|
||||||
String sendplayer = msgin.readUTF();
|
|
||||||
String muteplayer = msgin.readUTF();
|
|
||||||
String server = msgin.readUTF();
|
|
||||||
Player mp = Bukkit.getPlayer(muteplayer);
|
|
||||||
MineverseChatPlayer p = MineverseChatAPI.getMineverseChatPlayer(mp);
|
|
||||||
if(mp == null) {
|
|
||||||
try {
|
|
||||||
out.writeUTF("Muteall");
|
|
||||||
out.writeUTF("Player");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(muteplayer);
|
|
||||||
out.writeUTF(server);
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
boolean bungee = false;
|
|
||||||
for(ChatChannel c : ChatChannel.getChannels()) {
|
|
||||||
if(c.isMutable()) {
|
|
||||||
p.addMute(c.getName(), 0);
|
|
||||||
if(c.getBungee()) {
|
|
||||||
bungee = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(bungee) {
|
|
||||||
MineverseChat.getInstance().synchronize(p, true);
|
|
||||||
}
|
|
||||||
if(p.isOnline()) {
|
|
||||||
p.getPlayer().sendMessage(ChatColor.RED + "You have just been muted in all channels.");
|
|
||||||
}
|
|
||||||
else p.setModified(true);
|
|
||||||
try {
|
|
||||||
out.writeUTF("Muteall");
|
|
||||||
out.writeUTF("Valid");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(muteplayer);
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(subchannel.equals("Unmuteall")) {
|
|
||||||
String sendplayer = msgin.readUTF();
|
|
||||||
String muteplayer = msgin.readUTF();
|
|
||||||
String server = msgin.readUTF();
|
|
||||||
Player mp = Bukkit.getPlayer(muteplayer);
|
|
||||||
MineverseChatPlayer p = MineverseChatAPI.getMineverseChatPlayer(mp);
|
|
||||||
if(mp == null) {
|
|
||||||
try {
|
|
||||||
out.writeUTF("Unmuteall");
|
|
||||||
out.writeUTF("Player");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(muteplayer);
|
|
||||||
out.writeUTF(server);
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
boolean bungee = false;
|
|
||||||
for(ChatChannel c : ChatChannel.getChannels()) {
|
|
||||||
p.removeMute(c.getName());
|
|
||||||
if(c.getBungee()) {
|
|
||||||
bungee = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(bungee) {
|
|
||||||
MineverseChat.getInstance().synchronize(p, true);
|
|
||||||
}
|
|
||||||
if(p.isOnline()) {
|
|
||||||
p.getPlayer().sendMessage(ChatColor.RED + "You have just been unmuted in all channels.");
|
|
||||||
}
|
|
||||||
else p.setModified(true);
|
|
||||||
try {
|
|
||||||
out.writeUTF("Unmuteall");
|
|
||||||
out.writeUTF("Valid");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(muteplayer);
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(subchannel.equals("Unmute")) {
|
|
||||||
String sendplayer = msgin.readUTF();
|
|
||||||
String mutePlayer = msgin.readUTF();
|
|
||||||
String chatchannel = msgin.readUTF();
|
|
||||||
String server = msgin.readUTF();
|
|
||||||
MineverseChatPlayer p = MineverseChatAPI.getMineverseChatPlayer(mutePlayer);
|
|
||||||
ChatChannel cc = ChatChannel.getChannel(chatchannel);
|
|
||||||
if(cc == null) {
|
|
||||||
try {
|
|
||||||
out.writeUTF("Unmute");
|
|
||||||
out.writeUTF("Channel");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(chatchannel);
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(p == null) {
|
|
||||||
try {
|
|
||||||
out.writeUTF("Unmute");
|
|
||||||
out.writeUTF("Player");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(mutePlayer);
|
|
||||||
out.writeUTF(server);
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(!p.isMuted(cc.getName())) {
|
|
||||||
try {
|
|
||||||
out.writeUTF("Unmute");
|
|
||||||
out.writeUTF("Already");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(mutePlayer);
|
|
||||||
out.writeUTF(cc.getName());
|
|
||||||
out.writeUTF(cc.getColor());
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
p.removeMute(cc.getName());
|
|
||||||
if(p.isOnline()) p.getPlayer().sendMessage(ChatColor.RED + "You have just been unmuted in: " + ChatColor.valueOf(cc.getColor().toUpperCase()) + cc.getName());
|
|
||||||
else p.setModified(true);
|
|
||||||
if(cc.getBungee()) {
|
|
||||||
MineverseChat.getInstance().synchronize(p, true);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
out.writeUTF("Unmute");
|
|
||||||
out.writeUTF("Valid");
|
|
||||||
out.writeUTF(sendplayer);
|
|
||||||
out.writeUTF(mutePlayer);
|
|
||||||
out.writeUTF(cc.getName());
|
|
||||||
out.writeUTF(cc.getColor());
|
|
||||||
player.sendPluginMessage(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package mineverse.Aust1n46.chat.api;
|
package mineverse.Aust1n46.chat.api;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -9,6 +11,7 @@ import java.util.UUID;
|
|||||||
import mineverse.Aust1n46.chat.ChatMessage;
|
import mineverse.Aust1n46.chat.ChatMessage;
|
||||||
import mineverse.Aust1n46.chat.MineverseChat;
|
import mineverse.Aust1n46.chat.MineverseChat;
|
||||||
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
||||||
|
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
|
||||||
import mineverse.Aust1n46.chat.json.JsonFormat;
|
import mineverse.Aust1n46.chat.json.JsonFormat;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -22,7 +25,7 @@ public class MineverseChatPlayer {
|
|||||||
private ChatChannel currentChannel;
|
private ChatChannel currentChannel;
|
||||||
private Set<UUID> ignores;
|
private Set<UUID> ignores;
|
||||||
private Set<String> listening;
|
private Set<String> listening;
|
||||||
private HashMap<String, Integer> mutes;
|
private HashMap<String, MuteContainer> mutes;
|
||||||
private Set<String> blockedCommands;
|
private Set<String> blockedCommands;
|
||||||
private boolean host;
|
private boolean host;
|
||||||
private UUID party;
|
private UUID party;
|
||||||
@ -38,9 +41,9 @@ public class MineverseChatPlayer {
|
|||||||
private boolean quickChat;
|
private boolean quickChat;
|
||||||
private ChatChannel quickChannel;
|
private ChatChannel quickChannel;
|
||||||
private UUID replyPlayer;
|
private UUID replyPlayer;
|
||||||
private HashMap<ChatChannel, Integer> cooldowns;
|
private HashMap<ChatChannel, Long> cooldowns;
|
||||||
private boolean partyChat;
|
private boolean partyChat;
|
||||||
private HashMap<ChatChannel, List<Integer>> spam;
|
private HashMap<ChatChannel, List<Long>> spam;
|
||||||
private boolean modified;
|
private boolean modified;
|
||||||
private List<ChatMessage> messages;
|
private List<ChatMessage> messages;
|
||||||
private String jsonFormat;
|
private String jsonFormat;
|
||||||
@ -50,14 +53,7 @@ public class MineverseChatPlayer {
|
|||||||
private boolean messageToggle;
|
private boolean messageToggle;
|
||||||
private boolean bungeeToggle;
|
private boolean bungeeToggle;
|
||||||
|
|
||||||
//buttons variable no longer used
|
public MineverseChatPlayer(UUID uuid, String name, ChatChannel currentChannel, Set<UUID> ignores, Set<String> listening, HashMap<String, MuteContainer> mutes, Set<String> blockedCommands, boolean host, UUID party, boolean filter, boolean notifications, String nickname, String jsonFormat, boolean spy, boolean commandSpy, boolean rangedSpy, boolean messageToggle, boolean bungeeToggle) {
|
||||||
//mail variable no longer used
|
|
||||||
@Deprecated
|
|
||||||
public MineverseChatPlayer(UUID uuid, String name, ChatChannel currentChannel, Set<UUID> ignores, Set<String> listening, HashMap<String, Integer> mutes, Set<String> blockedCommands, List<String> mail, boolean host, UUID party, boolean filter, boolean notifications, String nickname, String jsonFormat, boolean spy, boolean commandSpy, boolean rangedSpy, boolean buttons, boolean messageToggle, boolean bungeeToggle) {
|
|
||||||
this(uuid, name, currentChannel, ignores, listening, mutes, blockedCommands, host, party, filter, notifications, nickname, jsonFormat, spy, commandSpy, rangedSpy, messageToggle, bungeeToggle);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MineverseChatPlayer(UUID uuid, String name, ChatChannel currentChannel, Set<UUID> ignores, Set<String> listening, HashMap<String, Integer> mutes, Set<String> blockedCommands, boolean host, UUID party, boolean filter, boolean notifications, String nickname, String jsonFormat, boolean spy, boolean commandSpy, boolean rangedSpy, boolean messageToggle, boolean bungeeToggle) {
|
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.currentChannel = currentChannel;
|
this.currentChannel = currentChannel;
|
||||||
@ -84,12 +80,46 @@ public class MineverseChatPlayer {
|
|||||||
this.modified = 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, Integer>();
|
this.cooldowns = new HashMap<ChatChannel, Long>();
|
||||||
this.spam = new HashMap<ChatChannel, List<Integer>>();
|
this.spam = new HashMap<ChatChannel, List<Long>>();
|
||||||
this.messageToggle = messageToggle;
|
this.messageToggle = messageToggle;
|
||||||
this.bungeeToggle = bungeeToggle;
|
this.bungeeToggle = bungeeToggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MineverseChatPlayer(UUID uuid, String name) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.name = name;
|
||||||
|
this.currentChannel = ChatChannel.getDefaultChannel();
|
||||||
|
this.ignores = new HashSet<UUID>();
|
||||||
|
this.listening = new HashSet<String>();
|
||||||
|
listening.add(currentChannel.getName());
|
||||||
|
this.mutes = new HashMap<String, MuteContainer>();
|
||||||
|
this.blockedCommands = new HashSet<String>();
|
||||||
|
this.host = false;
|
||||||
|
this.party = null;
|
||||||
|
this.filter = true;
|
||||||
|
this.notifications = true;
|
||||||
|
this.nickname = name;
|
||||||
|
this.online = false;
|
||||||
|
this.player = null;
|
||||||
|
this.hasPlayed = false;
|
||||||
|
this.conversation = null;
|
||||||
|
this.spy = false;
|
||||||
|
this.rangedSpy = false;
|
||||||
|
this.commandSpy = false;
|
||||||
|
this.quickChat = false;
|
||||||
|
this.quickChannel = null;
|
||||||
|
this.replyPlayer = null;
|
||||||
|
this.partyChat = false;
|
||||||
|
this.modified = false;
|
||||||
|
this.messages = new ArrayList<ChatMessage>();
|
||||||
|
this.jsonFormat = "Default";
|
||||||
|
this.cooldowns = new HashMap<ChatChannel, Long>();
|
||||||
|
this.spam = new HashMap<ChatChannel, List<Long>>();
|
||||||
|
this.messageToggle = true;
|
||||||
|
this.bungeeToggle = true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getBungeeToggle() {
|
public boolean getBungeeToggle() {
|
||||||
return this.bungeeToggle;
|
return this.bungeeToggle;
|
||||||
}
|
}
|
||||||
@ -214,13 +244,29 @@ public class MineverseChatPlayer {
|
|||||||
this.listening.clear();
|
this.listening.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Integer> getMutes() {
|
public Collection<MuteContainer> getMutes() {
|
||||||
return this.mutes;
|
return this.mutes.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addMute(String channel, int time) {
|
public MuteContainer getMute(String channel) {
|
||||||
|
return mutes.get(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addMute(String channel) {
|
||||||
|
return addMute(channel, 0, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addMute(String channel, long time) {
|
||||||
|
return addMute(channel, time, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addMute(String channel, String reason) {
|
||||||
|
return addMute(channel, 0, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addMute(String channel, long time, String reason) {
|
||||||
if(channel != null && time >= 0) {
|
if(channel != null && time >= 0) {
|
||||||
mutes.put(channel, time);
|
mutes.put(channel, new MuteContainer(channel, time, reason));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -412,11 +458,11 @@ public class MineverseChatPlayer {
|
|||||||
this.partyChat = partyChat;
|
this.partyChat = partyChat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<ChatChannel, Integer> getCooldowns() {
|
public HashMap<ChatChannel, Long> getCooldowns() {
|
||||||
return this.cooldowns;
|
return this.cooldowns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addCooldown(ChatChannel channel, int time) {
|
public boolean addCooldown(ChatChannel channel, long time) {
|
||||||
if(channel != null && time > 0) {
|
if(channel != null && time > 0) {
|
||||||
cooldowns.put(channel, time);
|
cooldowns.put(channel, time);
|
||||||
return true;
|
return true;
|
||||||
@ -436,7 +482,7 @@ public class MineverseChatPlayer {
|
|||||||
return channel != null && this.cooldowns != null ? this.cooldowns.containsKey(channel) : false;
|
return channel != null && this.cooldowns != null ? this.cooldowns.containsKey(channel) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<ChatChannel, List<Integer>> getSpam() {
|
public HashMap<ChatChannel, List<Long>> getSpam() {
|
||||||
return this.spam;
|
return this.spam;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +492,7 @@ public class MineverseChatPlayer {
|
|||||||
|
|
||||||
public boolean addSpam(ChatChannel channel) {
|
public boolean addSpam(ChatChannel channel) {
|
||||||
if(channel != null) {
|
if(channel != null) {
|
||||||
spam.put(channel, new ArrayList<Integer>());
|
spam.put(channel, new ArrayList<Long>());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,22 +1,26 @@
|
|||||||
package mineverse.Aust1n46.chat.api;
|
package mineverse.Aust1n46.chat.api;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
|
||||||
|
|
||||||
public class SynchronizedMineverseChatPlayer {
|
public class SynchronizedMineverseChatPlayer {
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
private Set<String> listening;
|
private Set<String> listening;
|
||||||
private HashMap<String, Integer> mutes;
|
private HashMap<String, MuteContainer> mutes;
|
||||||
private Set<UUID> ignores;
|
private Set<UUID> ignores;
|
||||||
private int messagePackets;
|
private int messagePackets;
|
||||||
private List<String> messageData = new ArrayList<String>();
|
private List<String> messageData = new ArrayList<String>();
|
||||||
private boolean spy;
|
private boolean spy;
|
||||||
private boolean messageToggle;
|
private boolean messageToggle;
|
||||||
|
|
||||||
public SynchronizedMineverseChatPlayer(UUID uuid, Set<String> listening, HashMap<String, Integer> mutes, Set<UUID> ignores, boolean spy, boolean messageToggle) {
|
public SynchronizedMineverseChatPlayer(UUID uuid, Set<String> listening, HashMap<String, MuteContainer> mutes, Set<UUID> ignores, boolean spy, boolean messageToggle) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.listening = listening;
|
this.listening = listening;
|
||||||
this.mutes = mutes;
|
this.mutes = mutes;
|
||||||
@ -25,6 +29,15 @@ public class SynchronizedMineverseChatPlayer {
|
|||||||
this.messageToggle = messageToggle;
|
this.messageToggle = messageToggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SynchronizedMineverseChatPlayer(UUID uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
listening = new HashSet<String>();
|
||||||
|
mutes = new HashMap<String, MuteContainer>();
|
||||||
|
ignores = new HashSet<UUID>();
|
||||||
|
spy = false;
|
||||||
|
messageToggle = true;
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getMessageData() {
|
public List<String> getMessageData() {
|
||||||
return this.messageData;
|
return this.messageData;
|
||||||
}
|
}
|
||||||
@ -61,16 +74,16 @@ public class SynchronizedMineverseChatPlayer {
|
|||||||
return this.ignores;
|
return this.ignores;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMute(String channel) {
|
public void addMute(String channel, long time, String reason) {
|
||||||
this.mutes.put(channel, 0);
|
mutes.put(channel, new MuteContainer(channel, time, reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMute(String channel) {
|
public void clearMutes() {
|
||||||
this.mutes.remove(channel);
|
this.mutes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Integer> getMutes() {
|
public Collection<MuteContainer> getMutes() {
|
||||||
return this.mutes;
|
return this.mutes.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListening(String channel) {
|
public void addListening(String channel) {
|
||||||
|
@ -6,20 +6,14 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
import mineverse.Aust1n46.chat.api.SynchronizedMineverseChatPlayer;
|
import mineverse.Aust1n46.chat.api.SynchronizedMineverseChatPlayer;
|
||||||
import mineverse.Aust1n46.chat.bungee.command.GlobalMute;
|
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
|
||||||
import mineverse.Aust1n46.chat.bungee.command.GlobalMuteAll;
|
|
||||||
import mineverse.Aust1n46.chat.bungee.command.GlobalUnmute;
|
|
||||||
import mineverse.Aust1n46.chat.bungee.command.GlobalUnmuteAll;
|
|
||||||
import mineverse.Aust1n46.chat.database.BungeePlayerData;
|
import mineverse.Aust1n46.chat.database.BungeePlayerData;
|
||||||
|
import mineverse.Aust1n46.chat.database.TemporaryDataInstance;
|
||||||
import mineverse.Aust1n46.chat.utilities.UUIDFetcher;
|
import mineverse.Aust1n46.chat.utilities.UUIDFetcher;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.connection.Server;
|
import net.md_5.bungee.api.connection.Server;
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
@ -62,8 +56,6 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
|
|
||||||
this.getProxy().registerChannel(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL);
|
this.getProxy().registerChannel(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL);
|
||||||
this.getProxy().getPluginManager().registerListener(this, this);
|
this.getProxy().getPluginManager().registerListener(this, this);
|
||||||
|
|
||||||
registerBungeeCordMuteCommands();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,21 +63,6 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
BungeePlayerData.saveBungeePlayerData();
|
BungeePlayerData.saveBungeePlayerData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Old BungeeCord mute commands that pretty much no one even knows about let alone uses...
|
|
||||||
* Slated for removal when the mute system is reworked.
|
|
||||||
*/
|
|
||||||
private void registerBungeeCordMuteCommands() {
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalMute(this, "globalmute"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalMute(this, "gmute"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalMuteAll(this, "globalmuteall"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalMuteAll(this, "gmuteall"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalUnmute(this, "globalunmute"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalUnmute(this, "gunmute"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalUnmuteAll(this, "globalunmuteall"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalUnmuteAll(this, "gunmuteall"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MineverseChatBungee getInstance() {
|
public static MineverseChatBungee getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
@ -309,6 +286,162 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(subchannel.equals("Mute")) {
|
||||||
|
String identifier = in.readUTF();
|
||||||
|
if(identifier.equals("Send")) {
|
||||||
|
String server = ser.getInfo().getName();
|
||||||
|
String senderIdentifier = in.readUTF();
|
||||||
|
String playerToMute = in.readUTF();
|
||||||
|
String channelName = in.readUTF();
|
||||||
|
long time = in.readLong();
|
||||||
|
String reason = in.readUTF();
|
||||||
|
UUID temporaryDataInstanceUUID = TemporaryDataInstance.createTemporaryDataInstance();
|
||||||
|
out.writeUTF("Mute");
|
||||||
|
out.writeUTF("Send");
|
||||||
|
out.writeUTF(server);
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(temporaryDataInstanceUUID.toString());
|
||||||
|
out.writeUTF(playerToMute);
|
||||||
|
out.writeUTF(channelName);
|
||||||
|
out.writeLong(time);
|
||||||
|
out.writeUTF(reason);
|
||||||
|
for(String send : getProxy().getServers().keySet()) {
|
||||||
|
if(getProxy().getServers().get(send).getPlayers().size() > 0) {
|
||||||
|
getProxy().getServers().get(send).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, outstream.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(identifier.equals("Valid")) {
|
||||||
|
String server = in.readUTF();
|
||||||
|
String senderIdentifier = in.readUTF();
|
||||||
|
String playerToMute = in.readUTF();
|
||||||
|
String channelName = in.readUTF();
|
||||||
|
long time = in.readLong();
|
||||||
|
String reason = in.readUTF();
|
||||||
|
out.writeUTF("Mute");
|
||||||
|
out.writeUTF("Valid");
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(playerToMute);
|
||||||
|
out.writeUTF(channelName);
|
||||||
|
out.writeLong(time);
|
||||||
|
out.writeUTF(reason);
|
||||||
|
if(getProxy().getServers().get(server).getPlayers().size() > 0) {
|
||||||
|
getProxy().getServers().get(server).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, outstream.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(identifier.equals("Offline")) {
|
||||||
|
String server = in.readUTF();
|
||||||
|
UUID temporaryDataInstanceUUID = UUID.fromString(in.readUTF());
|
||||||
|
String senderIdentifier = in.readUTF();
|
||||||
|
String playerToMute = in.readUTF();
|
||||||
|
TemporaryDataInstance temporaryDataInstance = TemporaryDataInstance.getTemporaryDataInstance(temporaryDataInstanceUUID);
|
||||||
|
temporaryDataInstance.incrementMessagePackets();
|
||||||
|
int servers = 0;
|
||||||
|
for(String send : getProxy().getServers().keySet()) {
|
||||||
|
if(getProxy().getServers().get(send).getPlayers().size() > 0) {
|
||||||
|
servers ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(temporaryDataInstance.getMessagePackets() >= servers) {
|
||||||
|
temporaryDataInstance.destroyInstance();
|
||||||
|
out.writeUTF("Mute");
|
||||||
|
out.writeUTF("Offline");
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(playerToMute);
|
||||||
|
if(getProxy().getServers().get(server).getPlayers().size() > 0) {
|
||||||
|
getProxy().getServers().get(server).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, outstream.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(identifier.equals("AlreadyMuted")) {
|
||||||
|
String server = in.readUTF();
|
||||||
|
String senderIdentifier = in.readUTF();
|
||||||
|
String playerToMute = in.readUTF();
|
||||||
|
String channelName = in.readUTF();
|
||||||
|
out.writeUTF("Mute");
|
||||||
|
out.writeUTF("AlreadyMuted");
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(playerToMute);
|
||||||
|
out.writeUTF(channelName);
|
||||||
|
if(getProxy().getServers().get(server).getPlayers().size() > 0) {
|
||||||
|
getProxy().getServers().get(server).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, outstream.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(subchannel.equals("Unmute")) {
|
||||||
|
String identifier = in.readUTF();
|
||||||
|
if(identifier.equals("Send")) {
|
||||||
|
String server = ser.getInfo().getName();
|
||||||
|
String senderIdentifier = in.readUTF();
|
||||||
|
String playerToUnmute = in.readUTF();
|
||||||
|
String channelName = in.readUTF();
|
||||||
|
UUID temporaryDataInstanceUUID = TemporaryDataInstance.createTemporaryDataInstance();
|
||||||
|
out.writeUTF("Unmute");
|
||||||
|
out.writeUTF("Send");
|
||||||
|
out.writeUTF(server);
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(temporaryDataInstanceUUID.toString());
|
||||||
|
out.writeUTF(playerToUnmute);
|
||||||
|
out.writeUTF(channelName);
|
||||||
|
for(String send : getProxy().getServers().keySet()) {
|
||||||
|
if(getProxy().getServers().get(send).getPlayers().size() > 0) {
|
||||||
|
getProxy().getServers().get(send).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, outstream.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(identifier.equals("Valid")) {
|
||||||
|
String server = in.readUTF();
|
||||||
|
String senderIdentifier = in.readUTF();
|
||||||
|
String playerToUnmute = in.readUTF();
|
||||||
|
String channelName = in.readUTF();
|
||||||
|
out.writeUTF("Unmute");
|
||||||
|
out.writeUTF("Valid");
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(playerToUnmute);
|
||||||
|
out.writeUTF(channelName);
|
||||||
|
if(getProxy().getServers().get(server).getPlayers().size() > 0) {
|
||||||
|
getProxy().getServers().get(server).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, outstream.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(identifier.equals("Offline")) {
|
||||||
|
String server = in.readUTF();
|
||||||
|
UUID temporaryDataInstanceUUID = UUID.fromString(in.readUTF());
|
||||||
|
String senderIdentifier = in.readUTF();
|
||||||
|
String playerToUnmute = in.readUTF();
|
||||||
|
TemporaryDataInstance temporaryDataInstance = TemporaryDataInstance.getTemporaryDataInstance(temporaryDataInstanceUUID);
|
||||||
|
temporaryDataInstance.incrementMessagePackets();
|
||||||
|
int servers = 0;
|
||||||
|
for(String send : getProxy().getServers().keySet()) {
|
||||||
|
if(getProxy().getServers().get(send).getPlayers().size() > 0) {
|
||||||
|
servers ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(temporaryDataInstance.getMessagePackets() >= servers) {
|
||||||
|
temporaryDataInstance.destroyInstance();
|
||||||
|
out.writeUTF("Unmute");
|
||||||
|
out.writeUTF("Offline");
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(playerToUnmute);
|
||||||
|
if(getProxy().getServers().get(server).getPlayers().size() > 0) {
|
||||||
|
getProxy().getServers().get(server).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, outstream.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(identifier.equals("NotMuted")) {
|
||||||
|
String server = in.readUTF();
|
||||||
|
String senderIdentifier = in.readUTF();
|
||||||
|
String playerToUnmute = in.readUTF();
|
||||||
|
String channelName = in.readUTF();
|
||||||
|
out.writeUTF("Unmute");
|
||||||
|
out.writeUTF("NotMuted");
|
||||||
|
out.writeUTF(senderIdentifier);
|
||||||
|
out.writeUTF(playerToUnmute);
|
||||||
|
out.writeUTF(channelName);
|
||||||
|
if(getProxy().getServers().get(server).getPlayers().size() > 0) {
|
||||||
|
getProxy().getServers().get(server).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, outstream.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if(subchannel.equals("Message")) {
|
if(subchannel.equals("Message")) {
|
||||||
String identifier = in.readUTF();
|
String identifier = in.readUTF();
|
||||||
if(identifier.equals("Send")) {
|
if(identifier.equals("Send")) {
|
||||||
@ -423,7 +556,7 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
UUID uuid = UUID.fromString(in.readUTF());
|
UUID uuid = UUID.fromString(in.readUTF());
|
||||||
SynchronizedMineverseChatPlayer smcp = MineverseChatAPI.getSynchronizedMineverseChatPlayer(uuid);
|
SynchronizedMineverseChatPlayer smcp = MineverseChatAPI.getSynchronizedMineverseChatPlayer(uuid);
|
||||||
if(smcp == null) {
|
if(smcp == null) {
|
||||||
smcp = new SynchronizedMineverseChatPlayer(uuid, new HashSet<String>(), new HashMap<String, Integer>(), new HashSet<UUID>(), false, true);
|
smcp = new SynchronizedMineverseChatPlayer(uuid);
|
||||||
MineverseChatAPI.addSynchronizedMineverseChatPlayerToMap(smcp);
|
MineverseChatAPI.addSynchronizedMineverseChatPlayerToMap(smcp);
|
||||||
}
|
}
|
||||||
out.writeUTF("Sync");
|
out.writeUTF("Sync");
|
||||||
@ -434,12 +567,13 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
for(String channel : smcp.getListening()) {
|
for(String channel : smcp.getListening()) {
|
||||||
out.writeUTF(channel);
|
out.writeUTF(channel);
|
||||||
}
|
}
|
||||||
int muteCount = smcp.getMutes().keySet().size();
|
int muteCount = smcp.getMutes().size();
|
||||||
//System.out.println(muteCount);
|
//System.out.println(muteCount);
|
||||||
out.write(muteCount);
|
out.write(muteCount);
|
||||||
for(String channel : smcp.getMutes().keySet()) {
|
for(MuteContainer muteContainer : smcp.getMutes()) {
|
||||||
//System.out.println(channel);
|
out.writeUTF(muteContainer.getChannel());
|
||||||
out.writeUTF(channel);
|
out.writeLong(muteContainer.getDuration());
|
||||||
|
out.writeUTF(muteContainer.getReason());
|
||||||
}
|
}
|
||||||
//System.out.println(smcp.isSpy() + " spy value");
|
//System.out.println(smcp.isSpy() + " spy value");
|
||||||
//System.out.println(out.size() + " size before");
|
//System.out.println(out.size() + " size before");
|
||||||
@ -459,11 +593,11 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
UUID uuid = UUID.fromString(in.readUTF());
|
UUID uuid = UUID.fromString(in.readUTF());
|
||||||
SynchronizedMineverseChatPlayer smcp = MineverseChatAPI.getSynchronizedMineverseChatPlayer(uuid);
|
SynchronizedMineverseChatPlayer smcp = MineverseChatAPI.getSynchronizedMineverseChatPlayer(uuid);
|
||||||
if(smcp == null) {
|
if(smcp == null) {
|
||||||
smcp = new SynchronizedMineverseChatPlayer(uuid, new HashSet<String>(), new HashMap<String, Integer>(), new HashSet<UUID>(), false, true);
|
smcp = new SynchronizedMineverseChatPlayer(uuid);
|
||||||
MineverseChatAPI.addSynchronizedMineverseChatPlayerToMap(smcp);
|
MineverseChatAPI.addSynchronizedMineverseChatPlayerToMap(smcp);
|
||||||
}
|
}
|
||||||
smcp.getListening().clear();
|
smcp.getListening().clear();
|
||||||
smcp.getMutes().clear();
|
smcp.clearMutes();
|
||||||
smcp.getIgnores().clear();
|
smcp.getIgnores().clear();
|
||||||
int sizeL = in.read();
|
int sizeL = in.read();
|
||||||
//System.out.println(sizeL + " listening");
|
//System.out.println(sizeL + " listening");
|
||||||
@ -471,11 +605,12 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
smcp.addListening(in.readUTF());
|
smcp.addListening(in.readUTF());
|
||||||
}
|
}
|
||||||
int sizeM = in.read();
|
int sizeM = in.read();
|
||||||
//System.out.println(size + " mutes");
|
|
||||||
for(int b = 0; b < sizeM; b++) {
|
for(int b = 0; b < sizeM; b++) {
|
||||||
String mute = in.readUTF();
|
String mute = in.readUTF();
|
||||||
|
long muteTime = in.readLong();
|
||||||
|
String muteReason = in.readUTF();
|
||||||
//System.out.println(mute);
|
//System.out.println(mute);
|
||||||
smcp.addMute(mute);
|
smcp.addMute(mute, muteTime, muteReason);
|
||||||
}
|
}
|
||||||
int sizeI = in.read();
|
int sizeI = in.read();
|
||||||
for(int c = 0; c < sizeI; c++) {
|
for(int c = 0; c < sizeI; c++) {
|
||||||
@ -487,124 +622,6 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
smcp.setMessageToggle(in.readBoolean());
|
smcp.setMessageToggle(in.readBoolean());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(subchannel.equals("Mute")) {
|
|
||||||
String identifier = in.readUTF();
|
|
||||||
if(identifier.equals("Channel")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String channel = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.RED + "Invalid channel: " + channel));
|
|
||||||
}
|
|
||||||
if(identifier.equals("Player")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String muteplayer = in.readUTF();
|
|
||||||
String server = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.RED + "Player: " + ChatColor.GOLD + muteplayer + ChatColor.RED + " is not connected to server: " + server));
|
|
||||||
}
|
|
||||||
if(identifier.equals("Mutable")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String channel = in.readUTF();
|
|
||||||
String color = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.RED + "You cannot mute players in this channel: " + ChatColor.valueOf(color.toUpperCase()) + channel));
|
|
||||||
}
|
|
||||||
if(identifier.equals("Already")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String muteplayer = in.readUTF();
|
|
||||||
String channel = in.readUTF();
|
|
||||||
String color = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.GOLD + muteplayer + ChatColor.RED + " is already muted in channel: " + ChatColor.valueOf(color.toUpperCase()) + channel));
|
|
||||||
}
|
|
||||||
if(identifier.equals("Time")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String muteplayer = in.readUTF();
|
|
||||||
String channel = in.readUTF();
|
|
||||||
String color = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.RED + "Muted player " + ChatColor.GOLD + muteplayer + ChatColor.RED + " in: " + ChatColor.valueOf(color.toUpperCase()) + channel));
|
|
||||||
}
|
|
||||||
if(identifier.equals("Valid")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String muteplayer = in.readUTF();
|
|
||||||
String channel = in.readUTF();
|
|
||||||
String color = in.readUTF();
|
|
||||||
String time = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
String timedmute = "";
|
|
||||||
if(!time.equals("None\n")) {
|
|
||||||
String keyword = "minutes";
|
|
||||||
if(time.equals("1")) keyword = "minute";
|
|
||||||
timedmute = ChatColor.RED + " for " + time + " " + keyword;
|
|
||||||
}
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.RED + "Muted player " + ChatColor.GOLD + muteplayer + ChatColor.RED + " in: " + ChatColor.valueOf(color.toUpperCase()) + channel + timedmute));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(subchannel.equals("Muteall")) {
|
|
||||||
String identifier = in.readUTF();
|
|
||||||
if(identifier.equals("Player")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String muteplayer = in.readUTF();
|
|
||||||
String server = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.RED + "Player: " + ChatColor.GOLD + muteplayer + ChatColor.RED + " is not connected to server: " + server));
|
|
||||||
}
|
|
||||||
if(identifier.equals("Valid")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String muteplayer = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.RED + "Muted player " + ChatColor.GOLD + muteplayer + ChatColor.RED + " in all channels."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(subchannel.equals("Unmuteall")) {
|
|
||||||
String identifier = in.readUTF();
|
|
||||||
if(identifier.equals("Player")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String muteplayer = in.readUTF();
|
|
||||||
String server = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.RED + "Player: " + ChatColor.GOLD + muteplayer + ChatColor.RED + " is not connected to server: " + server));
|
|
||||||
}
|
|
||||||
if(identifier.equals("Valid")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String muteplayer = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.RED + "Unmuted player " + ChatColor.GOLD + muteplayer + ChatColor.RED + " in all channels."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(subchannel.equals("Unmute")) {
|
|
||||||
String identifier = in.readUTF();
|
|
||||||
if(identifier.equals("Channel")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String channel = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.RED + "Invalid channel: " + channel));
|
|
||||||
}
|
|
||||||
if(identifier.equals("Player")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String muteplayer = in.readUTF();
|
|
||||||
String server = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.RED + "Player: " + ChatColor.GOLD + muteplayer + ChatColor.RED + " is not connected to server: " + server));
|
|
||||||
}
|
|
||||||
if(identifier.equals("Already")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String muteplayer = in.readUTF();
|
|
||||||
String channel = in.readUTF();
|
|
||||||
String color = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.GOLD + muteplayer + ChatColor.RED + " is not muted in channel: " + ChatColor.valueOf(color.toUpperCase()) + channel));
|
|
||||||
}
|
|
||||||
if(identifier.equals("Valid")) {
|
|
||||||
String player = in.readUTF();
|
|
||||||
String muteplayer = in.readUTF();
|
|
||||||
String channel = in.readUTF();
|
|
||||||
String color = in.readUTF();
|
|
||||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
|
||||||
p.sendMessage(new TextComponent(ChatColor.RED + "Unmuted player " + ChatColor.GOLD + muteplayer + ChatColor.RED + " in: " + ChatColor.valueOf(color.toUpperCase()) + channel));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
/GlobalMute.class
|
|
||||||
/GlobalMuteAll.class
|
|
||||||
/GlobalUnmute.class
|
|
||||||
/GlobalUnmuteAll.class
|
|
@ -1,70 +0,0 @@
|
|||||||
package mineverse.Aust1n46.chat.bungee.command;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
|
|
||||||
import mineverse.Aust1n46.chat.bungee.MineverseChatBungee;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
|
||||||
|
|
||||||
public class GlobalMute extends Command {
|
|
||||||
private MineverseChatBungee plugin;
|
|
||||||
private String alias;
|
|
||||||
|
|
||||||
public GlobalMute(MineverseChatBungee plugin, String alias) {
|
|
||||||
super(alias);
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.alias = alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(CommandSender commandSender, String[] args) {
|
|
||||||
if(!(commandSender instanceof ProxiedPlayer)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(commandSender.hasPermission("venturechat.mute")) {
|
|
||||||
if(args.length < 3) {
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Invalid command: /" + alias + " [server] [player] [channel] {time}"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ProxiedPlayer player = plugin.getProxy().getPlayer(args[1]);
|
|
||||||
if(player != null) {
|
|
||||||
if(plugin.getProxy().getServers().containsKey(args[0])) {
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream out = new DataOutputStream(stream);
|
|
||||||
try {
|
|
||||||
out.writeUTF("Mute");
|
|
||||||
out.writeUTF(commandSender.getName());
|
|
||||||
out.writeUTF(args[1]);
|
|
||||||
out.writeUTF(args[2]);
|
|
||||||
out.writeUTF(args[0]);
|
|
||||||
String time = "None\n";
|
|
||||||
if(args.length > 3) {
|
|
||||||
time = args[3];
|
|
||||||
}
|
|
||||||
out.writeUTF(time);
|
|
||||||
if(plugin.getProxy().getServers().get(args[0]).getPlayers().size() > 0) {
|
|
||||||
plugin.getProxy().getServers().get(args[0]).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Player: " + ChatColor.GOLD + args[1] + ChatColor.RED + " is not connected to server: " + args[0]));
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Invalid server: " + args[0]));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Player: " + ChatColor.GOLD + args[1] + ChatColor.RED + " is not online."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "You do not have permission for this command."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
package mineverse.Aust1n46.chat.bungee.command;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import mineverse.Aust1n46.chat.bungee.MineverseChatBungee;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
|
||||||
|
|
||||||
public class GlobalMuteAll extends Command {
|
|
||||||
private MineverseChatBungee plugin;
|
|
||||||
private String alias;
|
|
||||||
|
|
||||||
public GlobalMuteAll(MineverseChatBungee plugin, String alias) {
|
|
||||||
super(alias);
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.alias = alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(CommandSender commandSender, String[] args) {
|
|
||||||
if(!(commandSender instanceof ProxiedPlayer)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(commandSender.hasPermission("venturechat.mute")) {
|
|
||||||
if(args.length < 2) {
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Invalid command: /" + alias + " [server] [player]"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ProxiedPlayer player = plugin.getProxy().getPlayer(args[1]);
|
|
||||||
if(player != null) {
|
|
||||||
if(plugin.getProxy().getServers().containsKey(args[0])) {
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream out = new DataOutputStream(stream);
|
|
||||||
try {
|
|
||||||
out.writeUTF("Muteall");
|
|
||||||
out.writeUTF(commandSender.getName());
|
|
||||||
out.writeUTF(args[1]);
|
|
||||||
out.writeUTF(args[0]);
|
|
||||||
if(plugin.getProxy().getServers().get(args[0]).getPlayers().size() > 0) {
|
|
||||||
plugin.getProxy().getServers().get(args[0]).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Player: " + ChatColor.GOLD + args[1] + ChatColor.RED + " is not connected to server: " + args[0]));
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Invalid server: " + args[0]));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Player: " + ChatColor.GOLD + args[1] + ChatColor.RED + " is not online."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "You do not have permission for this command."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
package mineverse.Aust1n46.chat.bungee.command;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
|
|
||||||
import mineverse.Aust1n46.chat.bungee.MineverseChatBungee;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
|
||||||
|
|
||||||
public class GlobalUnmute extends Command {
|
|
||||||
private MineverseChatBungee plugin;
|
|
||||||
private String alias;
|
|
||||||
|
|
||||||
public GlobalUnmute(MineverseChatBungee plugin, String alias) {
|
|
||||||
super(alias);
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.alias = alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(CommandSender commandSender, String[] args) {
|
|
||||||
if(!(commandSender instanceof ProxiedPlayer)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(commandSender.hasPermission("venturechat.mute")) {
|
|
||||||
if(args.length < 3) {
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Invalid command: /" + alias + " [server] [player] [channel]"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ProxiedPlayer player = plugin.getProxy().getPlayer(args[1]);
|
|
||||||
if(player != null) {
|
|
||||||
if(plugin.getProxy().getServers().containsKey(args[0])) {
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream out = new DataOutputStream(stream);
|
|
||||||
try {
|
|
||||||
out.writeUTF("Unmute");
|
|
||||||
out.writeUTF(commandSender.getName());
|
|
||||||
out.writeUTF(args[1]);
|
|
||||||
out.writeUTF(args[2]);
|
|
||||||
out.writeUTF(args[0]);
|
|
||||||
if(plugin.getProxy().getServers().get(args[0]).getPlayers().size() > 0) {
|
|
||||||
plugin.getProxy().getServers().get(args[0]).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Player: " + ChatColor.GOLD + args[1] + ChatColor.RED + " is not connected to server: " + args[0]));
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Invalid server: " + args[0]));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Player: " + ChatColor.GOLD + args[1] + ChatColor.RED + " is not online."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "You do not have permission for this command."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
package mineverse.Aust1n46.chat.bungee.command;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import mineverse.Aust1n46.chat.bungee.MineverseChatBungee;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
|
||||||
|
|
||||||
public class GlobalUnmuteAll extends Command {
|
|
||||||
private MineverseChatBungee plugin;
|
|
||||||
private String alias;
|
|
||||||
|
|
||||||
public GlobalUnmuteAll(MineverseChatBungee plugin, String alias) {
|
|
||||||
super(alias);
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.alias = alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(CommandSender commandSender, String[] args) {
|
|
||||||
if(!(commandSender instanceof ProxiedPlayer)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(commandSender.hasPermission("venturechat.mute")) {
|
|
||||||
if(args.length < 2) {
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Invalid command: /" + alias + " [server] [player]"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ProxiedPlayer player = plugin.getProxy().getPlayer(args[1]);
|
|
||||||
if(player != null) {
|
|
||||||
if(plugin.getProxy().getServers().containsKey(args[0])) {
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream out = new DataOutputStream(stream);
|
|
||||||
try {
|
|
||||||
out.writeUTF("Unmuteall");
|
|
||||||
out.writeUTF(commandSender.getName());
|
|
||||||
out.writeUTF(args[1]);
|
|
||||||
out.writeUTF(args[0]);
|
|
||||||
if(plugin.getProxy().getServers().get(args[0]).getPlayers().size() > 0) {
|
|
||||||
plugin.getProxy().getServers().get(args[0]).sendData(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL, stream.toByteArray());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Player: " + ChatColor.GOLD + args[1] + ChatColor.RED + " is not connected to server: " + args[0]));
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Invalid server: " + args[0]));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "Player: " + ChatColor.GOLD + args[1] + ChatColor.RED + " is not online."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commandSender.sendMessage(new TextComponent(ChatColor.RED + "You do not have permission for this command."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,8 +21,10 @@ public class ChatChannel {
|
|||||||
|
|
||||||
private static MineverseChat plugin = MineverseChat.getInstance();
|
private static MineverseChat plugin = MineverseChat.getInstance();
|
||||||
private static ChatChannel defaultChatChannel;
|
private static ChatChannel defaultChatChannel;
|
||||||
|
@Deprecated
|
||||||
private static ChatChannel[] channels;
|
private static ChatChannel[] channels;
|
||||||
private static String defaultColor;
|
private static String defaultColor;
|
||||||
|
private static List<ChatChannel> chatChannels = new ArrayList<ChatChannel>();
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String permission;
|
private String permission;
|
||||||
@ -65,6 +67,7 @@ public class ChatChannel {
|
|||||||
ChatChannel chatChannel = new ChatChannel(name, color, chatColor, permission, speakPermission, mutable,
|
ChatChannel chatChannel = new ChatChannel(name, color, chatColor, permission, speakPermission, mutable,
|
||||||
filter, defaultChannel, alias, distance, autojoin, bungee, cooldown, format);
|
filter, defaultChannel, alias, distance, autojoin, bungee, cooldown, format);
|
||||||
channels[counter++] = chatChannel;
|
channels[counter++] = chatChannel;
|
||||||
|
chatChannels.add(chatChannel);
|
||||||
if (defaultChannel) {
|
if (defaultChannel) {
|
||||||
defaultChatChannel = chatChannel;
|
defaultChatChannel = chatChannel;
|
||||||
defaultColor = color;
|
defaultColor = color;
|
||||||
@ -77,10 +80,20 @@ public class ChatChannel {
|
|||||||
*
|
*
|
||||||
* @return {@link ChatChannel}[]
|
* @return {@link ChatChannel}[]
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static ChatChannel[] getChannels() {
|
public static ChatChannel[] getChannels() {
|
||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of chat channels.
|
||||||
|
*
|
||||||
|
* @return {@link List}<{@link ChatChannel}>
|
||||||
|
*/
|
||||||
|
public static List<ChatChannel> getChatChannels() {
|
||||||
|
return chatChannels;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a chat channel by name.
|
* Get a chat channel by name.
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package mineverse.Aust1n46.chat.command;
|
package mineverse.Aust1n46.chat.command;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
//This class is the parent class of all of the plugins commands. The execute method runs the command.
|
//This class is the parent class of all of the plugins commands. The execute method runs the command.
|
||||||
@ -14,6 +17,10 @@ public abstract class MineverseCommand {
|
|||||||
|
|
||||||
public abstract void execute(CommandSender sender, String command, String[] args);
|
public abstract void execute(CommandSender sender, String command, String[] args);
|
||||||
|
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package mineverse.Aust1n46.chat.command;
|
package mineverse.Aust1n46.chat.command;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
|
|
||||||
//This class is a standard command executor that is used to run the MineverseCommand's.
|
//This class is a standard command executor that is used to run the MineverseCommand's.
|
||||||
public class MineverseCommandExecutor implements CommandExecutor {
|
public class MineverseCommandExecutor implements TabExecutor {
|
||||||
private Map<String, MineverseCommand> commands;
|
private Map<String, MineverseCommand> commands;
|
||||||
|
|
||||||
public MineverseCommandExecutor(Map<String, MineverseCommand> commands) {
|
public MineverseCommandExecutor(Map<String, MineverseCommand> commands) {
|
||||||
@ -16,12 +17,12 @@ public class MineverseCommandExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] parameters) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] parameters) {
|
||||||
for(String com : commands.keySet()) {
|
commands.get(command.getName()).execute(sender, command.getName(), parameters);
|
||||||
if(command.getName().equalsIgnoreCase(com)) {
|
return true;
|
||||||
commands.get(com).execute(sender, command.getName(), parameters);
|
}
|
||||||
return true;
|
|
||||||
}
|
@Override
|
||||||
}
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
return false;
|
return commands.get(command.getName()).onTabComplete(sender, command, label, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ public class Broadcast extends MineverseCommand {
|
|||||||
public void execute(CommandSender sender, String command, String[] args) {
|
public void execute(CommandSender sender, String command, String[] args) {
|
||||||
ConfigurationSection bs = plugin.getConfig().getConfigurationSection("broadcast");
|
ConfigurationSection bs = plugin.getConfig().getConfigurationSection("broadcast");
|
||||||
String broadcastColor = bs.getString("color", "white");
|
String broadcastColor = bs.getString("color", "white");
|
||||||
String broadcastPermissions = bs.getString("permissions", "");
|
String broadcastPermissions = bs.getString("permissions", "None");
|
||||||
String broadcastDisplayTag = Format.FormatStringAll(bs.getString("displaytag", "[Broadcast]"));
|
String broadcastDisplayTag = Format.FormatStringAll(bs.getString("displaytag", "[Broadcast]"));
|
||||||
if(broadcastPermissions.equalsIgnoreCase("None") || sender.hasPermission(broadcastPermissions)) {
|
if(broadcastPermissions.equalsIgnoreCase("None") || sender.hasPermission(broadcastPermissions)) {
|
||||||
if(args.length > 0) {
|
if(args.length > 0) {
|
||||||
@ -29,7 +29,7 @@ public class Broadcast extends MineverseCommand {
|
|||||||
if(args[x].length() > 0) bc += args[x] + " ";
|
if(args[x].length() > 0) bc += args[x] + " ";
|
||||||
}
|
}
|
||||||
bc = Format.FormatStringAll(bc);
|
bc = Format.FormatStringAll(bc);
|
||||||
plugin.getServer().broadcastMessage(broadcastDisplayTag + ChatColor.valueOf(broadcastColor.toUpperCase()) + " " + bc);
|
Format.broadcastToServer(broadcastDisplayTag + ChatColor.valueOf(broadcastColor.toUpperCase()) + " " + bc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -9,6 +9,7 @@ import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
|||||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||||
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
||||||
import mineverse.Aust1n46.chat.command.MineverseCommand;
|
import mineverse.Aust1n46.chat.command.MineverseCommand;
|
||||||
|
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
|
||||||
|
|
||||||
public class Chatinfo extends MineverseCommand {
|
public class Chatinfo extends MineverseCommand {
|
||||||
private MineverseChat plugin = MineverseChat.getInstance();;
|
private MineverseChat plugin = MineverseChat.getInstance();;
|
||||||
@ -36,8 +37,8 @@ public class Chatinfo extends MineverseCommand {
|
|||||||
ChatChannel channel = ChatChannel.getChannel(c);
|
ChatChannel channel = ChatChannel.getChannel(c);
|
||||||
listen += channel.getColor() + channel.getName() + " ";
|
listen += channel.getColor() + channel.getName() + " ";
|
||||||
}
|
}
|
||||||
for(String c : mcp.getMutes().keySet()) {
|
for(MuteContainer muteContainer : mcp.getMutes()) {
|
||||||
ChatChannel channel = ChatChannel.getChannel(c);
|
ChatChannel channel = ChatChannel.getChannel(muteContainer.getChannel());
|
||||||
mute += channel.getColor() + channel.getName() + " ";
|
mute += channel.getColor() + channel.getName() + " ";
|
||||||
}
|
}
|
||||||
for(String bc : mcp.getBlockedCommands()) {
|
for(String bc : mcp.getBlockedCommands()) {
|
||||||
@ -97,8 +98,8 @@ public class Chatinfo extends MineverseCommand {
|
|||||||
ChatChannel channel = ChatChannel.getChannel(c);
|
ChatChannel channel = ChatChannel.getChannel(c);
|
||||||
listen += channel.getColor() + channel.getName() + " ";
|
listen += channel.getColor() + channel.getName() + " ";
|
||||||
}
|
}
|
||||||
for(String c : p.getMutes().keySet()) {
|
for(MuteContainer muteContainer : p.getMutes()) {
|
||||||
ChatChannel channel = ChatChannel.getChannel(c);
|
ChatChannel channel = ChatChannel.getChannel(muteContainer.getChannel());
|
||||||
mute += channel.getColor() + channel.getName() + " ";
|
mute += channel.getColor() + channel.getName() + " ";
|
||||||
}
|
}
|
||||||
for(String bc : p.getBlockedCommands()) {
|
for(String bc : p.getBlockedCommands()) {
|
||||||
|
@ -15,7 +15,7 @@ public class Chlist extends MineverseCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String command, String[] args) {
|
public void execute(CommandSender sender, String command, String[] args) {
|
||||||
sender.sendMessage(LocalizedMessage.CHANNEL_LIST_HEADER.toString());
|
sender.sendMessage(LocalizedMessage.CHANNEL_LIST_HEADER.toString());
|
||||||
for(ChatChannel chname : ChatChannel.getChannels()) {
|
for(ChatChannel chname : ChatChannel.getChatChannels()) {
|
||||||
if(chname.hasPermission()) {
|
if(chname.hasPermission()) {
|
||||||
if(sender.hasPermission(chname.getPermission())) {
|
if(sender.hasPermission(chname.getPermission())) {
|
||||||
sender.sendMessage(LocalizedMessage.CHANNEL_LIST_WITH_PERMISSIONS.toString()
|
sender.sendMessage(LocalizedMessage.CHANNEL_LIST_WITH_PERMISSIONS.toString()
|
||||||
|
@ -29,7 +29,7 @@ public class Setchannelall extends MineverseCommand {
|
|||||||
.replace("{args}", args[0]));
|
.replace("{args}", args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(ChatChannel channel : ChatChannel.getChannels()) {
|
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||||
if(channel.hasPermission()) {
|
if(channel.hasPermission()) {
|
||||||
if(!player.isOnline()) {
|
if(!player.isOnline()) {
|
||||||
sender.sendMessage(LocalizedMessage.PLAYER_OFFLINE_NO_PERMISSIONS_CHECK.toString());
|
sender.sendMessage(LocalizedMessage.PLAYER_OFFLINE_NO_PERMISSIONS_CHECK.toString());
|
||||||
|
@ -6,7 +6,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabExecutor;
|
import org.bukkit.command.TabExecutor;
|
||||||
@ -19,7 +18,6 @@ import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
|||||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||||
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
|
||||||
|
|
||||||
public class MessageCommandExecutor implements TabExecutor {
|
public class MessageCommandExecutor implements TabExecutor {
|
||||||
private MineverseChat plugin = MineverseChat.getInstance();
|
private MineverseChat plugin = MineverseChat.getInstance();
|
||||||
@ -101,12 +99,7 @@ public class MessageCommandExecutor implements TabExecutor {
|
|||||||
player.getPlayer().sendMessage(send);
|
player.getPlayer().sendMessage(send);
|
||||||
mcp.getPlayer().sendMessage(echo);
|
mcp.getPlayer().sendMessage(echo);
|
||||||
if(player.hasNotifications()) {
|
if(player.hasNotifications()) {
|
||||||
if(VersionHandler.is1_8() || VersionHandler.is1_7_10() || VersionHandler.is1_7_2() || VersionHandler.is1_7_9()) {
|
Format.playMessageSound(player);
|
||||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.valueOf("LEVEL_UP"), 1, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.valueOf("ENTITY_PLAYER_LEVELUP"), 1, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(!mcp.getPlayer().hasPermission("venturechat.spy.override")) {
|
if(!mcp.getPlayer().hasPermission("venturechat.spy.override")) {
|
||||||
for(MineverseChatPlayer sp : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
for(MineverseChatPlayer sp : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
||||||
@ -181,13 +174,11 @@ public class MessageCommandExecutor implements TabExecutor {
|
|||||||
}
|
}
|
||||||
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||||
DataOutputStream out = new DataOutputStream(byteOutStream);
|
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||||
String msg = "";
|
StringBuilder msgBuilder = new StringBuilder();
|
||||||
String send = "";
|
|
||||||
String echo = "";
|
|
||||||
String spy = "";
|
|
||||||
for(int r = 1; r < args.length; r++) {
|
for(int r = 1; r < args.length; r++) {
|
||||||
msg += " " + args[r];
|
msgBuilder.append(" " + args[r]);
|
||||||
}
|
}
|
||||||
|
String msg = msgBuilder.toString();
|
||||||
if(mcp.hasFilter()) {
|
if(mcp.hasFilter()) {
|
||||||
msg = Format.FilterChat(msg);
|
msg = Format.FilterChat(msg);
|
||||||
}
|
}
|
||||||
@ -201,9 +192,12 @@ public class MessageCommandExecutor implements TabExecutor {
|
|||||||
msg = Format.FormatString(msg);
|
msg = Format.FormatString(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
send = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("tellformatfrom").replaceAll("sender_", "")));
|
String send = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("tellformatfrom").replaceAll("sender_", "")));
|
||||||
echo = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("tellformatto").replaceAll("sender_", "")));
|
String echo = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("tellformatto").replaceAll("sender_", "")));
|
||||||
spy = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("tellformatspy").replaceAll("sender_", "")));
|
String spy = "VentureChat:NoSpy";
|
||||||
|
if(!mcp.getPlayer().hasPermission("venturechat.spy.override")) {
|
||||||
|
spy = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("tellformatspy").replaceAll("sender_", "")));
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
out.writeUTF("Message");
|
out.writeUTF("Message");
|
||||||
out.writeUTF("Send");
|
out.writeUTF("Send");
|
||||||
|
@ -3,7 +3,6 @@ package mineverse.Aust1n46.chat.command.message;
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -14,7 +13,6 @@ import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
|||||||
import mineverse.Aust1n46.chat.command.MineverseCommand;
|
import mineverse.Aust1n46.chat.command.MineverseCommand;
|
||||||
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
|
||||||
|
|
||||||
public class Reply extends MineverseCommand {
|
public class Reply extends MineverseCommand {
|
||||||
private MineverseChat plugin = MineverseChat.getInstance();
|
private MineverseChat plugin = MineverseChat.getInstance();
|
||||||
@ -97,12 +95,7 @@ public class Reply extends MineverseCommand {
|
|||||||
player.getPlayer().sendMessage(send);
|
player.getPlayer().sendMessage(send);
|
||||||
mcp.getPlayer().sendMessage(echo);
|
mcp.getPlayer().sendMessage(echo);
|
||||||
if(player.hasNotifications()) {
|
if(player.hasNotifications()) {
|
||||||
if(VersionHandler.is1_8() || VersionHandler.is1_7_10() || VersionHandler.is1_7_2() || VersionHandler.is1_7_9()) {
|
Format.playMessageSound(player);
|
||||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.valueOf("LEVEL_UP"), 1, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.valueOf("ENTITY_PLAYER_LEVELUP"), 1, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
player.setReplyPlayer(mcp.getUUID());
|
player.setReplyPlayer(mcp.getUUID());
|
||||||
return;
|
return;
|
||||||
@ -119,13 +112,11 @@ public class Reply extends MineverseCommand {
|
|||||||
private void sendBungeeCordReply(MineverseChatPlayer mcp, String[] args) {
|
private void sendBungeeCordReply(MineverseChatPlayer mcp, String[] args) {
|
||||||
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||||
DataOutputStream out = new DataOutputStream(byteOutStream);
|
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||||
String msg = "";
|
StringBuilder msgBuilder = new StringBuilder();
|
||||||
String send = "";
|
|
||||||
String echo = "";
|
|
||||||
String spy = "";
|
|
||||||
for(int r = 0; r < args.length; r++) {
|
for(int r = 0; r < args.length; r++) {
|
||||||
msg += " " + args[r];
|
msgBuilder.append(" " + args[r]);
|
||||||
}
|
}
|
||||||
|
String msg = msgBuilder.toString();
|
||||||
if(mcp.hasFilter()) {
|
if(mcp.hasFilter()) {
|
||||||
msg = Format.FilterChat(msg);
|
msg = Format.FilterChat(msg);
|
||||||
}
|
}
|
||||||
@ -139,9 +130,12 @@ public class Reply extends MineverseCommand {
|
|||||||
msg = Format.FormatString(msg);
|
msg = Format.FormatString(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
send = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("replyformatfrom").replaceAll("sender_", "")));
|
String send = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("replyformatfrom").replaceAll("sender_", "")));
|
||||||
echo = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("replyformatto").replaceAll("sender_", "")));
|
String echo = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("replyformatto").replaceAll("sender_", "")));
|
||||||
spy = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("replyformatspy").replaceAll("sender_", "")));
|
String spy = "VentureChat:NoSpy";
|
||||||
|
if(!mcp.getPlayer().hasPermission("venturechat.spy.override")) {
|
||||||
|
spy = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), plugin.getConfig().getString("replyformatspy").replaceAll("sender_", "")));
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
out.writeUTF("Message");
|
out.writeUTF("Message");
|
||||||
out.writeUTF("Send");
|
out.writeUTF("Send");
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
package mineverse.Aust1n46.chat.command.mute;
|
package mineverse.Aust1n46.chat.command.mute;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import mineverse.Aust1n46.chat.MineverseChat;
|
import mineverse.Aust1n46.chat.MineverseChat;
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
@ -11,7 +22,7 @@ import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
|||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
|
|
||||||
public class Mute extends MineverseCommand {
|
public class Mute extends MineverseCommand {
|
||||||
private static final int MILLISECONDS_PER_MINUTE = 60000;
|
private static final List<String> COMMON_MUTE_TIMES = Collections.unmodifiableList(Arrays.asList(new String[]{"12h", "15m", "1d", "1h", "1m", "30s"}));
|
||||||
|
|
||||||
public Mute(String name) {
|
public Mute(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
@ -22,96 +33,191 @@ public class Mute extends MineverseCommand {
|
|||||||
if (sender.hasPermission("venturechat.mute")) {
|
if (sender.hasPermission("venturechat.mute")) {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage(LocalizedMessage.COMMAND_INVALID_ARGUMENTS.toString().replace("{command}", "/mute")
|
sender.sendMessage(LocalizedMessage.COMMAND_INVALID_ARGUMENTS.toString().replace("{command}", "/mute")
|
||||||
.replace("{args}", "[player] [channel] {time}"));
|
.replace("{args}", "[channel] [player] {time} {reason}"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MineverseChatPlayer player = MineverseChatAPI.getMineverseChatPlayer(args[0]);
|
if (ChatChannel.isChannel(args[0])) {
|
||||||
if (player == null || (!player.isOnline() && !sender.hasPermission("venturechat.mute.offline"))) {
|
ChatChannel channel = ChatChannel.getChannel(args[0]);
|
||||||
sender.sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString().replace("{args}", args[0]));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
if (ChatChannel.isChannel(args[1])) {
|
|
||||||
ChatChannel channel = ChatChannel.getChannel(args[1]);
|
|
||||||
if (player.isMuted(channel.getName())) {
|
|
||||||
sender.sendMessage(LocalizedMessage.PLAYER_ALREADY_MUTED.toString()
|
|
||||||
.replace("{player}", player.getName()).replace("{channel_color}", channel.getColor())
|
|
||||||
.replace("{channel_name}", channel.getName()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (channel.isMutable()) {
|
|
||||||
player.addMute(channel.getName(), 0);
|
|
||||||
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString()
|
|
||||||
.replace("{player}", player.getName()).replace("{channel_color}", channel.getColor())
|
|
||||||
.replace("{channel_name}", channel.getName()));
|
|
||||||
if (player.isOnline())
|
|
||||||
player.getPlayer()
|
|
||||||
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER.toString()
|
|
||||||
.replace("{channel_color}", channel.getColor())
|
|
||||||
.replace("{channel_name}", channel.getName()));
|
|
||||||
else
|
|
||||||
player.setModified(true);
|
|
||||||
if (channel.getBungee()) {
|
|
||||||
MineverseChat.getInstance().synchronize(player, true);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sender.sendMessage(LocalizedMessage.CHANNEL_CANNOT_MUTE.toString()
|
|
||||||
.replace("{channel_color}", channel.getColor())
|
|
||||||
.replace("{channel_name}", channel.getName()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sender.sendMessage(LocalizedMessage.INVALID_CHANNEL.toString().replace("{args}", args[1]));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ChatChannel.isChannel(args[1])) {
|
|
||||||
ChatChannel channel = ChatChannel.getChannel(args[1]);
|
|
||||||
if (player.isMuted(channel.getName())) {
|
|
||||||
sender.sendMessage(LocalizedMessage.PLAYER_ALREADY_MUTED.toString()
|
|
||||||
.replace("{player}", player.getName()).replace("{channel_color}", channel.getColor())
|
|
||||||
.replace("{channel_name}", channel.getName()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (channel.isMutable()) {
|
if (channel.isMutable()) {
|
||||||
try {
|
long datetime = System.currentTimeMillis();
|
||||||
int datetime = Format.currentTimeMillis();
|
long time = 0;
|
||||||
int time = Integer.parseInt(args[2]);
|
int reasonStartPos = 2;
|
||||||
if (time > 0) {
|
String reason = "";
|
||||||
player.addMute(channel.getName(), datetime + (time * MILLISECONDS_PER_MINUTE));
|
if(args.length > 2) {
|
||||||
String units = LocalizedMessage.UNITS_MINUTE_PLURAL.toString();
|
String timeString = args[2];
|
||||||
if (time == 1)
|
if(Character.isDigit(timeString.charAt(0))) {
|
||||||
units = LocalizedMessage.UNITS_MINUTE_SINGULAR.toString();
|
reasonStartPos = 3;
|
||||||
|
time = Format.parseTimeStringToMillis(timeString);
|
||||||
|
if (time <= 0) {
|
||||||
|
sender.sendMessage(LocalizedMessage.INVALID_TIME.toString().replace("{args}", timeString));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuilder reasonBuilder = new StringBuilder();
|
||||||
|
for(int a = reasonStartPos; a < args.length; a ++) {
|
||||||
|
reasonBuilder.append(args[a]);
|
||||||
|
}
|
||||||
|
reason = reasonBuilder.toString();
|
||||||
|
}
|
||||||
|
if(channel.getBungee()) {
|
||||||
|
sendBungeeCordMute(sender, args[1], channel, time, reason);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MineverseChatPlayer playerToMute = MineverseChatAPI.getMineverseChatPlayer(args[1]);
|
||||||
|
if (playerToMute == null || (!playerToMute.isOnline() && !sender.hasPermission("venturechat.mute.offline"))) {
|
||||||
|
sender.sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString().replace("{args}", args[1]));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (playerToMute.isMuted(channel.getName())) {
|
||||||
|
sender.sendMessage(LocalizedMessage.PLAYER_ALREADY_MUTED.toString()
|
||||||
|
.replace("{player}", playerToMute.getName()).replace("{channel_color}", channel.getColor())
|
||||||
|
.replace("{channel_name}", channel.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(time > 0) {
|
||||||
|
if(reason.isEmpty()) {
|
||||||
|
playerToMute.addMute(channel.getName(), datetime + time);
|
||||||
|
String timeString = Format.parseTimeStringFromMillis(time);
|
||||||
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
|
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
|
||||||
.replace("{player}", player.getName())
|
.replace("{player}", playerToMute.getName())
|
||||||
.replace("{channel_color}", channel.getColor())
|
.replace("{channel_color}", channel.getColor())
|
||||||
.replace("{channel_name}", channel.getName()).replace("{time}", time + "")
|
.replace("{channel_name}", channel.getName())
|
||||||
.replace("{units}", units));
|
.replace("{time}", timeString));
|
||||||
if (player.isOnline())
|
if (playerToMute.isOnline()) {
|
||||||
player.getPlayer()
|
playerToMute.getPlayer()
|
||||||
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME.toString()
|
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME.toString()
|
||||||
.replace("{channel_color}", channel.getColor())
|
.replace("{channel_color}", channel.getColor())
|
||||||
.replace("{channel_name}", channel.getName())
|
.replace("{channel_name}", channel.getName())
|
||||||
.replace("{time}", time + "").replace("{units}", units));
|
.replace("{time}", timeString));
|
||||||
else
|
}
|
||||||
player.setModified(true);
|
else {
|
||||||
if (channel.getBungee()) {
|
playerToMute.setModified(true);
|
||||||
MineverseChat.getInstance().synchronize(player, true);
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
playerToMute.addMute(channel.getName(), datetime + time, reason);
|
||||||
|
String timeString = Format.parseTimeStringFromMillis(time);
|
||||||
|
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME_REASON.toString()
|
||||||
|
.replace("{player}", playerToMute.getName())
|
||||||
|
.replace("{channel_color}", channel.getColor())
|
||||||
|
.replace("{channel_name}", channel.getName())
|
||||||
|
.replace("{time}", timeString)
|
||||||
|
.replace("{reason}", reason));
|
||||||
|
if (playerToMute.isOnline()) {
|
||||||
|
playerToMute.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME_REASON.toString()
|
||||||
|
.replace("{channel_color}", channel.getColor())
|
||||||
|
.replace("{channel_name}", channel.getName())
|
||||||
|
.replace("{time}", timeString)
|
||||||
|
.replace("{reason}", reason));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
playerToMute.setModified(true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(reason.isEmpty()) {
|
||||||
|
playerToMute.addMute(channel.getName());
|
||||||
|
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString()
|
||||||
|
.replace("{player}", playerToMute.getName()).replace("{channel_color}", channel.getColor())
|
||||||
|
.replace("{channel_name}", channel.getName()));
|
||||||
|
if (playerToMute.isOnline()) {
|
||||||
|
playerToMute.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER.toString()
|
||||||
|
.replace("{channel_color}", channel.getColor())
|
||||||
|
.replace("{channel_name}", channel.getName()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
playerToMute.setModified(true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
playerToMute.addMute(channel.getName(), reason);
|
||||||
|
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_REASON.toString()
|
||||||
|
.replace("{player}", playerToMute.getName()).replace("{channel_color}", channel.getColor())
|
||||||
|
.replace("{channel_name}", channel.getName())
|
||||||
|
.replace("{reason}", reason));
|
||||||
|
if (playerToMute.isOnline()) {
|
||||||
|
playerToMute.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_REASON.toString()
|
||||||
|
.replace("{channel_color}", channel.getColor())
|
||||||
|
.replace("{channel_name}", channel.getName())
|
||||||
|
.replace("{reason}", reason));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
playerToMute.setModified(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(LocalizedMessage.INVALID_TIME.toString().replace("{args}", args[2]));
|
|
||||||
} catch (Exception e) {
|
|
||||||
sender.sendMessage(LocalizedMessage.INVALID_TIME.toString().replace("{args}", args[2]));
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
sender.sendMessage(LocalizedMessage.CHANNEL_CANNOT_MUTE.toString()
|
sender.sendMessage(LocalizedMessage.CHANNEL_CANNOT_MUTE.toString()
|
||||||
.replace("{channel_color}", channel.getColor()).replace("{channel_name}", channel.getName()));
|
.replace("{channel_color}", channel.getColor())
|
||||||
|
.replace("{channel_name}", channel.getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(LocalizedMessage.INVALID_CHANNEL.toString().replace("{args}", args[1]));
|
sender.sendMessage(LocalizedMessage.INVALID_CHANNEL.toString().replace("{args}", args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(LocalizedMessage.COMMAND_NO_PERMISSION.toString());
|
sender.sendMessage(LocalizedMessage.COMMAND_NO_PERMISSION.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
List<String> completions = new ArrayList<>();
|
||||||
|
if(args.length == 1) {
|
||||||
|
StringUtil.copyPartialMatches(args[0], ChatChannel.getChatChannels().stream().map(ChatChannel::getName).collect(Collectors.toList()), completions);
|
||||||
|
Collections.sort(completions);
|
||||||
|
return completions;
|
||||||
|
}
|
||||||
|
if(args.length == 2) {
|
||||||
|
if(ChatChannel.isChannel(args[0])) {
|
||||||
|
ChatChannel chatChannelObj = ChatChannel.getChannel(args[0]);
|
||||||
|
if(chatChannelObj.getBungee()) {
|
||||||
|
StringUtil.copyPartialMatches(args[1], MineverseChat.networkPlayerNames, completions);
|
||||||
|
Collections.sort(completions);
|
||||||
|
return completions;
|
||||||
|
}
|
||||||
|
StringUtil.copyPartialMatches(args[1], MineverseChatAPI.getOnlineMineverseChatPlayers().stream().filter(mcp -> !mcp.isMuted(chatChannelObj.getName())).map(MineverseChatPlayer::getName).collect(Collectors.toList()), completions);
|
||||||
|
Collections.sort(completions);
|
||||||
|
return completions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(args.length == 3) {
|
||||||
|
StringUtil.copyPartialMatches(args[2], COMMON_MUTE_TIMES, completions);
|
||||||
|
Collections.sort(completions);
|
||||||
|
return completions;
|
||||||
|
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendBungeeCordMute(CommandSender sender, String playerToMute, ChatChannel channel, long time, String reason) {
|
||||||
|
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||||
|
try {
|
||||||
|
out.writeUTF("Mute");
|
||||||
|
out.writeUTF("Send");
|
||||||
|
if(sender instanceof Player) {
|
||||||
|
out.writeUTF(((Player) sender).getUniqueId().toString());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out.writeUTF("VentureChat:Console");
|
||||||
|
}
|
||||||
|
out.writeUTF(playerToMute);
|
||||||
|
out.writeUTF(channel.getName());
|
||||||
|
out.writeLong(time);
|
||||||
|
out.writeUTF(reason);
|
||||||
|
MineverseChat.sendPluginMessage(byteOutStream);
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
45
src/mineverse/Aust1n46/chat/command/mute/MuteContainer.java
Normal file
45
src/mineverse/Aust1n46/chat/command/mute/MuteContainer.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package mineverse.Aust1n46.chat.command.mute;
|
||||||
|
|
||||||
|
public class MuteContainer {
|
||||||
|
private String channel;
|
||||||
|
private String reason;
|
||||||
|
private long duration;
|
||||||
|
|
||||||
|
public MuteContainer(String channel) {
|
||||||
|
this(channel, 0, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public MuteContainer(String channel, long duration) {
|
||||||
|
this(channel, duration, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public MuteContainer(String channel, String reason) {
|
||||||
|
this(channel, 0, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MuteContainer(String channel, long duration, String reason) {
|
||||||
|
this.channel = channel;
|
||||||
|
this.reason = reason;
|
||||||
|
this.duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasReason() {
|
||||||
|
return !reason.equals("");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasDuration() {
|
||||||
|
return duration > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getDuration() {
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
}
|
@ -21,7 +21,7 @@ public class Muteall extends MineverseCommand {
|
|||||||
if(args.length < 1) {
|
if(args.length < 1) {
|
||||||
sender.sendMessage(LocalizedMessage.COMMAND_INVALID_ARGUMENTS.toString()
|
sender.sendMessage(LocalizedMessage.COMMAND_INVALID_ARGUMENTS.toString()
|
||||||
.replace("{command}", "/muteall")
|
.replace("{command}", "/muteall")
|
||||||
.replace("{args}", "[player]"));
|
.replace("{args}", "[player] {reason}"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MineverseChatPlayer player = MineverseChatAPI.getMineverseChatPlayer(args[0]);
|
MineverseChatPlayer player = MineverseChatAPI.getMineverseChatPlayer(args[0]);
|
||||||
@ -30,26 +30,60 @@ public class Muteall extends MineverseCommand {
|
|||||||
.replace("{args}", args[0]));
|
.replace("{args}", args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean bungee = false;
|
String reason = "";
|
||||||
for(ChatChannel channel : ChatChannel.getChannels()) {
|
if(args.length > 1) {
|
||||||
if(channel.isMutable()) {
|
StringBuilder reasonBuilder = new StringBuilder();
|
||||||
player.addMute(channel.getName(), 0);
|
for(int a = 1; a < args.length; a ++) {
|
||||||
if(channel.getBungee()) {
|
reasonBuilder.append(args[a]);
|
||||||
bungee = true;
|
}
|
||||||
|
reason = reasonBuilder.toString();
|
||||||
|
}
|
||||||
|
if(reason.isEmpty()) {
|
||||||
|
boolean bungee = false;
|
||||||
|
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||||
|
if(channel.isMutable()) {
|
||||||
|
player.addMute(channel.getName());
|
||||||
|
if(channel.getBungee()) {
|
||||||
|
bungee = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(bungee) {
|
||||||
|
MineverseChat.getInstance().synchronize(player, true);
|
||||||
|
}
|
||||||
|
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_ALL_SENDER.toString()
|
||||||
|
.replace("{player}", player.getName()));
|
||||||
|
if(player.isOnline()) {
|
||||||
|
player.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_ALL_PLAYER.toString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
player.setModified(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if(bungee) {
|
else {
|
||||||
MineverseChat.getInstance().synchronize(player, true);
|
boolean bungee = false;
|
||||||
|
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||||
|
if(channel.isMutable()) {
|
||||||
|
player.addMute(channel.getName(), reason);
|
||||||
|
if(channel.getBungee()) {
|
||||||
|
bungee = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(bungee) {
|
||||||
|
MineverseChat.getInstance().synchronize(player, true);
|
||||||
|
}
|
||||||
|
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_ALL_SENDER_REASON.toString()
|
||||||
|
.replace("{player}", player.getName())
|
||||||
|
.replace("{reason}", reason));
|
||||||
|
if(player.isOnline()) {
|
||||||
|
player.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_ALL_PLAYER_REASON.toString()
|
||||||
|
.replace("{reason}", reason));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
player.setModified(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_ALL_SENDER.toString()
|
|
||||||
.replace("{player}", player.getName()));
|
|
||||||
if(player.isOnline()) {
|
|
||||||
player.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_ALL_PLAYER.toString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
player.setModified(true);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocalizedMessage.COMMAND_NO_PERMISSION.toString());
|
sender.sendMessage(LocalizedMessage.COMMAND_NO_PERMISSION.toString());
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
package mineverse.Aust1n46.chat.command.mute;
|
package mineverse.Aust1n46.chat.command.mute;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import mineverse.Aust1n46.chat.MineverseChat;
|
import mineverse.Aust1n46.chat.MineverseChat;
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
@ -20,44 +30,91 @@ public class Unmute extends MineverseCommand {
|
|||||||
if (sender.hasPermission("venturechat.mute")) {
|
if (sender.hasPermission("venturechat.mute")) {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage(LocalizedMessage.COMMAND_INVALID_ARGUMENTS.toString().replace("{command}", "/unmute")
|
sender.sendMessage(LocalizedMessage.COMMAND_INVALID_ARGUMENTS.toString().replace("{command}", "/unmute")
|
||||||
.replace("{args}", "[player] [channel]"));
|
.replace("{args}", "[channel] [player]"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MineverseChatPlayer player = MineverseChatAPI.getMineverseChatPlayer(args[0]);
|
if (ChatChannel.isChannel(args[0])) {
|
||||||
if (player == null || (!player.isOnline() && !sender.hasPermission("venturechat.mute.offline"))) {
|
ChatChannel channel = ChatChannel.getChannel(args[0]);
|
||||||
sender.sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString().replace("{args}", args[0]));
|
if(channel.getBungee()) {
|
||||||
return;
|
sendBungeeCordUnmute(sender, args[1], channel);
|
||||||
}
|
|
||||||
for (ChatChannel channel : ChatChannel.getChannels()) {
|
|
||||||
if (channel.getName().equalsIgnoreCase(args[1]) || channel.getAlias().equalsIgnoreCase(args[1])) {
|
|
||||||
if (!player.isMuted(channel.getName())) {
|
|
||||||
sender.sendMessage(LocalizedMessage.PLAYER_NOT_MUTED.toString()
|
|
||||||
.replace("{player}", player.getName()).replace("{channel_color}", channel.getColor())
|
|
||||||
.replace("{channel_name}", channel.getName()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.removeMute(channel.getName());
|
|
||||||
sender.sendMessage(LocalizedMessage.UNMUTE_PLAYER_SENDER.toString()
|
|
||||||
.replace("{player}", player.getName()).replace("{channel_color}", channel.getColor())
|
|
||||||
.replace("{channel_name}", channel.getName()));
|
|
||||||
if (player.isOnline()) {
|
|
||||||
player.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString()
|
|
||||||
.replace("{player}", player.getName()).replace("{channel_color}", channel.getColor())
|
|
||||||
.replace("{channel_name}", channel.getName()));
|
|
||||||
} else {
|
|
||||||
player.setModified(true);
|
|
||||||
}
|
|
||||||
if (channel.getBungee()) {
|
|
||||||
MineverseChat.getInstance().synchronize(player, true);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
MineverseChatPlayer player = MineverseChatAPI.getMineverseChatPlayer(args[1]);
|
||||||
|
if (player == null || (!player.isOnline() && !sender.hasPermission("venturechat.mute.offline"))) {
|
||||||
|
sender.sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString().replace("{args}", args[1]));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!player.isMuted(channel.getName())) {
|
||||||
|
sender.sendMessage(LocalizedMessage.PLAYER_NOT_MUTED.toString()
|
||||||
|
.replace("{player}", player.getName()).replace("{channel_color}", channel.getColor())
|
||||||
|
.replace("{channel_name}", channel.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.removeMute(channel.getName());
|
||||||
|
sender.sendMessage(LocalizedMessage.UNMUTE_PLAYER_SENDER.toString()
|
||||||
|
.replace("{player}", player.getName()).replace("{channel_color}", channel.getColor())
|
||||||
|
.replace("{channel_name}", channel.getName()));
|
||||||
|
if (player.isOnline()) {
|
||||||
|
player.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString()
|
||||||
|
.replace("{player}", player.getName()).replace("{channel_color}", channel.getColor())
|
||||||
|
.replace("{channel_name}", channel.getName()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.setModified(true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(LocalizedMessage.INVALID_CHANNEL.toString().replace("{args}", args[1]));
|
sender.sendMessage(LocalizedMessage.INVALID_CHANNEL.toString().replace("{args}", args[0]));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(LocalizedMessage.COMMAND_NO_PERMISSION.toString());
|
sender.sendMessage(LocalizedMessage.COMMAND_NO_PERMISSION.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
List<String> completions = new ArrayList<>();
|
||||||
|
if(args.length == 1) {
|
||||||
|
StringUtil.copyPartialMatches(args[0], ChatChannel.getChatChannels().stream().map(ChatChannel::getName).collect(Collectors.toList()), completions);
|
||||||
|
Collections.sort(completions);
|
||||||
|
return completions;
|
||||||
|
}
|
||||||
|
if(args.length == 2) {
|
||||||
|
if(ChatChannel.isChannel(args[0])) {
|
||||||
|
ChatChannel chatChannelObj = ChatChannel.getChannel(args[0]);
|
||||||
|
if(chatChannelObj.getBungee()) {
|
||||||
|
StringUtil.copyPartialMatches(args[1], MineverseChat.networkPlayerNames, completions);
|
||||||
|
Collections.sort(completions);
|
||||||
|
return completions;
|
||||||
|
}
|
||||||
|
StringUtil.copyPartialMatches(args[1], MineverseChatAPI.getOnlineMineverseChatPlayers().stream().filter(mcp -> mcp.isMuted(chatChannelObj.getName())).map(MineverseChatPlayer::getName).collect(Collectors.toList()), completions);
|
||||||
|
Collections.sort(completions);
|
||||||
|
return completions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendBungeeCordUnmute(CommandSender sender, String playerToUnmute, ChatChannel channel) {
|
||||||
|
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||||
|
try {
|
||||||
|
out.writeUTF("Unmute");
|
||||||
|
out.writeUTF("Send");
|
||||||
|
if(sender instanceof Player) {
|
||||||
|
out.writeUTF(((Player) sender).getUniqueId().toString());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out.writeUTF("VentureChat:Console");
|
||||||
|
}
|
||||||
|
out.writeUTF(playerToUnmute);
|
||||||
|
out.writeUTF(channel.getName());
|
||||||
|
MineverseChat.sendPluginMessage(byteOutStream);
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -31,7 +31,7 @@ public class Unmuteall extends MineverseCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean bungee = false;
|
boolean bungee = false;
|
||||||
for(ChatChannel channel : ChatChannel.getChannels()) {
|
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||||
player.removeMute(channel.getName());
|
player.removeMute(channel.getName());
|
||||||
if(channel.getBungee()) {
|
if(channel.getBungee()) {
|
||||||
bungee = true;
|
bungee = true;
|
||||||
|
@ -14,6 +14,7 @@ import java.util.UUID;
|
|||||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
import mineverse.Aust1n46.chat.api.SynchronizedMineverseChatPlayer;
|
import mineverse.Aust1n46.chat.api.SynchronizedMineverseChatPlayer;
|
||||||
import mineverse.Aust1n46.chat.bungee.MineverseChatBungee;
|
import mineverse.Aust1n46.chat.bungee.MineverseChatBungee;
|
||||||
|
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
|
||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
import mineverse.Aust1n46.chat.utilities.UUIDFetcher;
|
import mineverse.Aust1n46.chat.utilities.UUIDFetcher;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -52,11 +53,12 @@ public class BungeePlayerData {
|
|||||||
String channel = l.nextToken();
|
String channel = l.nextToken();
|
||||||
listening.add(channel);
|
listening.add(channel);
|
||||||
}
|
}
|
||||||
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>();
|
||||||
StringTokenizer m = new StringTokenizer(playerData.getString(uuidString + ".mutes"), ",");
|
StringTokenizer m = new StringTokenizer(playerData.getString(uuidString + ".mutes"), ",");
|
||||||
while(m.hasMoreTokens()) {
|
while(m.hasMoreTokens()) {
|
||||||
String[] parts = m.nextToken().split(":");
|
String[] parts = m.nextToken().split(":");
|
||||||
mutes.put(parts[0], Integer.parseInt(parts[1]));
|
String channelName = parts[0];
|
||||||
|
mutes.put(channelName, new MuteContainer(channelName, Long.parseLong(parts[1])));
|
||||||
}
|
}
|
||||||
HashSet<UUID> ignores = new HashSet<UUID>();
|
HashSet<UUID> ignores = new HashSet<UUID>();
|
||||||
StringTokenizer n = new StringTokenizer(playerData.getString(uuidString + ".ignores"), ",");
|
StringTokenizer n = new StringTokenizer(playerData.getString(uuidString + ".ignores"), ",");
|
||||||
@ -115,11 +117,11 @@ public class BungeePlayerData {
|
|||||||
String channel = l.nextToken();
|
String channel = l.nextToken();
|
||||||
listening.add(channel);
|
listening.add(channel);
|
||||||
}
|
}
|
||||||
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>();
|
||||||
StringTokenizer m = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("mutes"), ",");
|
Configuration muteSection = bungeePlayerDataFileConfiguration.getSection("mutes");
|
||||||
while(m.hasMoreTokens()) {
|
for(String channelName : muteSection.getKeys()) {
|
||||||
String[] parts = m.nextToken().split(":");
|
Configuration channelSection = muteSection.getSection(channelName);
|
||||||
mutes.put(parts[0], Integer.parseInt(parts[1]));
|
mutes.put(channelName, new MuteContainer(channelName, channelSection.getLong("time"), channelSection.getString("reason")));
|
||||||
}
|
}
|
||||||
HashSet<UUID> ignores = new HashSet<UUID>();
|
HashSet<UUID> ignores = new HashSet<UUID>();
|
||||||
StringTokenizer n = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("ignores"), ",");
|
StringTokenizer n = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("ignores"), ",");
|
||||||
@ -157,20 +159,20 @@ public class BungeePlayerData {
|
|||||||
String listen = "";
|
String listen = "";
|
||||||
for(String s : p.getListening())
|
for(String s : p.getListening())
|
||||||
listen += s + ",";
|
listen += s + ",";
|
||||||
String mute = "";
|
|
||||||
for(String s : p.getMutes().keySet())
|
|
||||||
mute += s + ":0,";
|
|
||||||
String ignore = "";
|
String ignore = "";
|
||||||
for(UUID s : p.getIgnores())
|
for(UUID s : p.getIgnores())
|
||||||
ignore += s.toString() + ",";
|
ignore += s.toString() + ",";
|
||||||
if(listen.length() > 0)
|
if(listen.length() > 0)
|
||||||
listen = listen.substring(0, listen.length() - 1);
|
listen = listen.substring(0, listen.length() - 1);
|
||||||
if(mute.length() > 0)
|
|
||||||
mute = mute.substring(0, mute.length() - 1);
|
|
||||||
if(ignore.length() > 0)
|
if(ignore.length() > 0)
|
||||||
ignore = ignore.substring(0, ignore.length() - 1);
|
ignore = ignore.substring(0, ignore.length() - 1);
|
||||||
bungeePlayerDataFileConfiguration.set("channels", listen);
|
bungeePlayerDataFileConfiguration.set("channels", listen);
|
||||||
bungeePlayerDataFileConfiguration.set("mutes", mute);
|
Configuration muteSection = createSection(bungeePlayerDataFileConfiguration, "mutes");
|
||||||
|
for(MuteContainer mute : p.getMutes()) {
|
||||||
|
Configuration channelSection = createSection(muteSection, mute.getChannel());
|
||||||
|
channelSection.set("time", mute.getDuration());
|
||||||
|
channelSection.set("reason", mute.getReason());
|
||||||
|
}
|
||||||
bungeePlayerDataFileConfiguration.set("ignores", ignore);
|
bungeePlayerDataFileConfiguration.set("ignores", ignore);
|
||||||
bungeePlayerDataFileConfiguration.set("spy", p.isSpy());
|
bungeePlayerDataFileConfiguration.set("spy", p.isSpy());
|
||||||
bungeePlayerDataFileConfiguration.set("messagetoggle", p.getMessageToggle());
|
bungeePlayerDataFileConfiguration.set("messagetoggle", p.getMessageToggle());
|
||||||
@ -182,4 +184,16 @@ public class BungeePlayerData {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new {@link Configuration} section.
|
||||||
|
*
|
||||||
|
* @param configurationSection
|
||||||
|
* @param sectionKey
|
||||||
|
* @return Configuration
|
||||||
|
*/
|
||||||
|
private static Configuration createSection(Configuration configurationSection, String sectionKey) {
|
||||||
|
configurationSection.set(sectionKey, null);
|
||||||
|
return configurationSection.getSection(sectionKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,27 +3,76 @@ package mineverse.Aust1n46.chat.database;
|
|||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
|
||||||
import mineverse.Aust1n46.chat.MineverseChat;
|
import mineverse.Aust1n46.chat.MineverseChat;
|
||||||
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
|
|
||||||
//Parent class for both the MySQL and SQLite database classes.
|
/**
|
||||||
public abstract class Database {
|
* Initializes and handles writing to the chat logging database.
|
||||||
|
*/
|
||||||
|
public class Database {
|
||||||
|
private static HikariDataSource dataSource = null;
|
||||||
|
|
||||||
protected HikariDataSource dataSource = null;
|
public static void initializeMySQL() {
|
||||||
|
try {
|
||||||
|
ConfigurationSection mysqlConfig = MineverseChat.getInstance().getConfig().getConfigurationSection("mysql");
|
||||||
|
if (mysqlConfig.getBoolean("enabled", false)) {
|
||||||
|
String host = mysqlConfig.getString("host");
|
||||||
|
int port = mysqlConfig.getInt("port");
|
||||||
|
String database = mysqlConfig.getString("database");
|
||||||
|
String user = mysqlConfig.getString("user");
|
||||||
|
String password = mysqlConfig.getString("password");
|
||||||
|
|
||||||
public void writeVentureChat(String time, String uuid, String name, String server, String channel, String text, String type) {
|
final HikariConfig config = new HikariConfig();
|
||||||
|
// config.setDriverClassName(org.postgresql.Driver.class.getName());
|
||||||
|
// final String jdbcUrl = String.format("jdbc:postgresql://%s:%d/%s", hostname,
|
||||||
|
// port, database);
|
||||||
|
final String jdbcUrl = String.format("jdbc:mysql://%s:%d/%s?autoReconnect=true&useSSL=false", host,
|
||||||
|
port, database);
|
||||||
|
config.setJdbcUrl(jdbcUrl);
|
||||||
|
config.setUsername(user);
|
||||||
|
config.setPassword(password);
|
||||||
|
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||||
|
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||||
|
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||||
|
dataSource = new HikariDataSource(config);
|
||||||
|
final String SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS VentureChat "
|
||||||
|
+ "(ID SERIAL PRIMARY KEY, ChatTime TEXT, UUID TEXT, Name TEXT, "
|
||||||
|
+ "Server TEXT, Channel TEXT, Text TEXT, Type TEXT)";
|
||||||
|
final Connection conn = dataSource.getConnection();
|
||||||
|
final PreparedStatement statement = conn.prepareStatement(SQL_CREATE_TABLE);
|
||||||
|
statement.executeUpdate();
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(
|
||||||
|
Format.FormatStringAll("&8[&eVentureChat&8]&c - Database could not be loaded. Is it running?"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEnabled() {
|
||||||
|
return dataSource != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeVentureChat(String uuid, String name, String server, String channel, String text,
|
||||||
|
String type) {
|
||||||
MineverseChat plugin = MineverseChat.getInstance();
|
MineverseChat plugin = MineverseChat.getInstance();
|
||||||
|
Calendar currentDate = Calendar.getInstance();
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
String date = formatter.format(currentDate.getTime());
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
try(final Connection conn = dataSource.getConnection();
|
try (final Connection conn = dataSource.getConnection();
|
||||||
final PreparedStatement statement = conn.prepareStatement(
|
final PreparedStatement statement = conn.prepareStatement(
|
||||||
"INSERT INTO VentureChat " +
|
"INSERT INTO VentureChat " + "(ChatTime, UUID, Name, Server, Channel, Text, Type) "
|
||||||
"(ChatTime, UUID, Name, Server, Channel, Text, Type) " +
|
+ "VALUES (?, ?, ?, ?, ?, ?, ?)")) {
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?)")) {
|
statement.setString(1, date);
|
||||||
statement.setString(1, time);
|
|
||||||
statement.setString(2, uuid);
|
statement.setString(2, uuid);
|
||||||
statement.setString(3, name);
|
statement.setString(3, name);
|
||||||
statement.setString(4, server);
|
statement.setString(4, server);
|
||||||
@ -31,9 +80,8 @@ public abstract class Database {
|
|||||||
statement.setString(6, text);
|
statement.setString(6, text);
|
||||||
statement.setString(7, type);
|
statement.setString(7, type);
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
}
|
} catch (SQLException error) {
|
||||||
catch(SQLException e) {
|
error.printStackTrace();
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
package mineverse.Aust1n46.chat.database;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
|
||||||
|
|
||||||
//This class initializes the plugin's connection to the MySQL database if it's enabled.
|
|
||||||
public class MySQL extends Database {
|
|
||||||
|
|
||||||
public MySQL(String hostname, int port, String database, String user, String password) {
|
|
||||||
final HikariConfig config = new HikariConfig();
|
|
||||||
//config.setDriverClassName(org.postgresql.Driver.class.getName());
|
|
||||||
//final String jdbcUrl = String.format("jdbc:postgresql://%s:%d/%s", hostname, port, database);
|
|
||||||
final String jdbcUrl = String.format("jdbc:mysql://%s:%d/%s", hostname, port, database);
|
|
||||||
config.setJdbcUrl(jdbcUrl);
|
|
||||||
config.setUsername(user);
|
|
||||||
config.setPassword(password);
|
|
||||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
|
||||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
|
||||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
|
||||||
dataSource = new HikariDataSource(config);
|
|
||||||
final String SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS VentureChat " +
|
|
||||||
"(ID SERIAL PRIMARY KEY, ChatTime TEXT, UUID TEXT, Name TEXT, " +
|
|
||||||
"Server TEXT, Channel TEXT, Text TEXT, Type TEXT)";
|
|
||||||
try (final Connection conn = dataSource.getConnection();
|
|
||||||
final PreparedStatement statement = conn.prepareStatement(SQL_CREATE_TABLE)) {
|
|
||||||
statement.executeUpdate();
|
|
||||||
}
|
|
||||||
catch (SQLException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,6 +14,7 @@ import java.util.StringTokenizer;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
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;
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ import mineverse.Aust1n46.chat.MineverseChat;
|
|||||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||||
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
||||||
|
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
|
||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
import mineverse.Aust1n46.chat.utilities.UUIDFetcher;
|
import mineverse.Aust1n46.chat.utilities.UUIDFetcher;
|
||||||
|
|
||||||
@ -64,7 +66,7 @@ public class PlayerData {
|
|||||||
listening.add(channel);
|
listening.add(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>();
|
||||||
StringTokenizer m = new StringTokenizer(playerData.getConfigurationSection("players." + uuidString).getString("mutes"), ",");
|
StringTokenizer m = new StringTokenizer(playerData.getConfigurationSection("players." + uuidString).getString("mutes"), ",");
|
||||||
while(m.hasMoreTokens()) {
|
while(m.hasMoreTokens()) {
|
||||||
String[] parts = m.nextToken().split(":");
|
String[] parts = m.nextToken().split(":");
|
||||||
@ -73,7 +75,8 @@ public class PlayerData {
|
|||||||
Bukkit.getConsoleSender().sendMessage("[VentureChat] Null Mute Time: " + parts[0] + " " + name);
|
Bukkit.getConsoleSender().sendMessage("[VentureChat] Null Mute Time: " + parts[0] + " " + name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mutes.put(ChatChannel.getChannel(parts[0]).getName(), Integer.parseInt(parts[1]));
|
String channelName = parts[0];
|
||||||
|
mutes.put(channelName, new MuteContainer(channelName, Long.parseLong(parts[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<String> blockedCommands = new HashSet<String>();
|
Set<String> blockedCommands = new HashSet<String>();
|
||||||
@ -160,18 +163,13 @@ public class PlayerData {
|
|||||||
listening.add(channel);
|
listening.add(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
HashMap<String, MuteContainer> mutes = new HashMap<String, MuteContainer>();
|
||||||
StringTokenizer m = new StringTokenizer(playerDataFileYamlConfiguration.getString("mutes"), ",");
|
ConfigurationSection muteSection = playerDataFileYamlConfiguration.getConfigurationSection("mutes");
|
||||||
while(m.hasMoreTokens()) {
|
for(String channelName : muteSection.getKeys(false)) {
|
||||||
String[] parts = m.nextToken().split(":");
|
ConfigurationSection channelSection = muteSection.getConfigurationSection(channelName);
|
||||||
if(ChatChannel.isChannel(parts[0])) {
|
mutes.put(channelName, new MuteContainer(channelName, channelSection.getLong("time"), channelSection.getString("reason")));
|
||||||
if(parts[1].equals("null")) {
|
|
||||||
Bukkit.getConsoleSender().sendMessage("[VentureChat] Null Mute Time: " + parts[0] + " " + name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
mutes.put(ChatChannel.getChannel(parts[0]).getName(), Integer.parseInt(parts[1]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> blockedCommands = new HashSet<String>();
|
Set<String> blockedCommands = new HashSet<String>();
|
||||||
StringTokenizer b = new StringTokenizer(playerDataFileYamlConfiguration.getString("blockedcommands"), ",");
|
StringTokenizer b = new StringTokenizer(playerDataFileYamlConfiguration.getString("blockedcommands"), ",");
|
||||||
while(b.hasMoreTokens()) {
|
while(b.hasMoreTokens()) {
|
||||||
@ -225,11 +223,6 @@ public class PlayerData {
|
|||||||
ChatChannel c = ChatChannel.getChannel(channel);
|
ChatChannel c = ChatChannel.getChannel(channel);
|
||||||
listening += c.getName() + ",";
|
listening += c.getName() + ",";
|
||||||
}
|
}
|
||||||
String mutes = "";
|
|
||||||
for(String channel : mcp.getMutes().keySet()) {
|
|
||||||
ChatChannel c = ChatChannel.getChannel(channel);
|
|
||||||
mutes += c.getName() + ":" + mcp.getMutes().get(c.getName()) + ",";
|
|
||||||
}
|
|
||||||
String blockedCommands = "";
|
String blockedCommands = "";
|
||||||
for(String s : mcp.getBlockedCommands()) {
|
for(String s : mcp.getBlockedCommands()) {
|
||||||
blockedCommands += s + ",";
|
blockedCommands += s + ",";
|
||||||
@ -238,13 +231,14 @@ public class PlayerData {
|
|||||||
listening = listening.substring(0, listening.length() - 1);
|
listening = listening.substring(0, listening.length() - 1);
|
||||||
}
|
}
|
||||||
playerDataFileYamlConfiguration.set("listen", listening);
|
playerDataFileYamlConfiguration.set("listen", listening);
|
||||||
if(mutes.length() > 0) {
|
|
||||||
mutes = mutes.substring(0, mutes.length() - 1);
|
ConfigurationSection muteSection = playerDataFileYamlConfiguration.createSection("mutes");
|
||||||
}
|
for(MuteContainer mute : mcp.getMutes()) {
|
||||||
playerDataFileYamlConfiguration.set("mutes", mutes);
|
ConfigurationSection channelSection = muteSection.createSection(mute.getChannel());
|
||||||
if(blockedCommands.length() > 0) {
|
channelSection.set("time", mute.getDuration());
|
||||||
blockedCommands = blockedCommands.substring(0, blockedCommands.length() - 1);
|
channelSection.set("reason", mute.getReason());
|
||||||
}
|
}
|
||||||
|
|
||||||
playerDataFileYamlConfiguration.set("blockedcommands", blockedCommands);
|
playerDataFileYamlConfiguration.set("blockedcommands", blockedCommands);
|
||||||
playerDataFileYamlConfiguration.set("host", mcp.isHost());
|
playerDataFileYamlConfiguration.set("host", mcp.isHost());
|
||||||
playerDataFileYamlConfiguration.set("party", mcp.hasParty() ? mcp.getParty().toString() : "");
|
playerDataFileYamlConfiguration.set("party", mcp.hasParty() ? mcp.getParty().toString() : "");
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
package mineverse.Aust1n46.chat.database;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
|
||||||
|
|
||||||
import mineverse.Aust1n46.chat.MineverseChat;
|
|
||||||
|
|
||||||
//This class initializes the connection to a SQLite database, which has no implementations currently in the plugin.
|
|
||||||
public class SQLite extends Database {
|
|
||||||
|
|
||||||
public SQLite(String dbLocation) {
|
|
||||||
File dataFolder = MineverseChat.getInstance().getDataFolder();
|
|
||||||
if (!dataFolder.exists()) dataFolder.mkdirs();
|
|
||||||
File databaseFile = new File(dataFolder, dbLocation);
|
|
||||||
try {
|
|
||||||
if (!databaseFile.exists()) databaseFile.createNewFile();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
HikariConfig config = new HikariConfig();
|
|
||||||
final String jdbcUrl = String.format("jdbc:sqlite:%s", databaseFile);
|
|
||||||
config.setJdbcUrl(jdbcUrl);
|
|
||||||
dataSource = new HikariDataSource(config);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,37 @@
|
|||||||
|
package mineverse.Aust1n46.chat.database;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class TemporaryDataInstance {
|
||||||
|
private int messagePackets;
|
||||||
|
private UUID uuid;
|
||||||
|
|
||||||
|
private static HashMap<UUID, TemporaryDataInstance> temporaryDataInstances = new HashMap<UUID, TemporaryDataInstance>();
|
||||||
|
|
||||||
|
private TemporaryDataInstance(UUID uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UUID createTemporaryDataInstance() {
|
||||||
|
UUID uuid = UUID.randomUUID();
|
||||||
|
temporaryDataInstances.put(uuid, new TemporaryDataInstance(uuid));
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TemporaryDataInstance getTemporaryDataInstance(UUID uuid) {
|
||||||
|
return temporaryDataInstances.get(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMessagePackets() {
|
||||||
|
return this.messagePackets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementMessagePackets() {
|
||||||
|
this.messagePackets++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroyInstance() {
|
||||||
|
temporaryDataInstances.remove(uuid);
|
||||||
|
}
|
||||||
|
}
|
@ -2,14 +2,11 @@ package mineverse.Aust1n46.chat.listeners;
|
|||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -29,15 +26,13 @@ import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
|||||||
import mineverse.Aust1n46.chat.api.events.ChannelJoinEvent;
|
import mineverse.Aust1n46.chat.api.events.ChannelJoinEvent;
|
||||||
import mineverse.Aust1n46.chat.api.events.VentureChatEvent;
|
import mineverse.Aust1n46.chat.api.events.VentureChatEvent;
|
||||||
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
||||||
|
import mineverse.Aust1n46.chat.command.mute.MuteContainer;
|
||||||
|
import mineverse.Aust1n46.chat.database.Database;
|
||||||
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
|
||||||
|
|
||||||
//This class listens to chat through the chat event and handles the bulk of the chat channels and formatting.
|
//This class listens to chat through the chat event and handles the bulk of the chat channels and formatting.
|
||||||
public class ChatListener implements Listener {
|
public class ChatListener implements Listener {
|
||||||
private static final int MILLISECONDS_PER_MINUTE = 60000;
|
|
||||||
private static final int MILLISECONDS_PER_SECOND = 1000;
|
|
||||||
|
|
||||||
private MineverseChat plugin = MineverseChat.getInstance();
|
private MineverseChat plugin = MineverseChat.getInstance();
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
@ -147,20 +142,12 @@ public class ChatListener implements Listener {
|
|||||||
tp.getPlayer().sendMessage(send);
|
tp.getPlayer().sendMessage(send);
|
||||||
mcp.getPlayer().sendMessage(echo);
|
mcp.getPlayer().sendMessage(echo);
|
||||||
if(tp.hasNotifications()) {
|
if(tp.hasNotifications()) {
|
||||||
if(VersionHandler.is1_8()) {
|
Format.playMessageSound(tp);
|
||||||
tp.getPlayer().playSound(tp.getPlayer().getLocation(), Sound.valueOf("LEVEL_UP"), 1, 0);
|
|
||||||
}
|
|
||||||
if(VersionHandler.is1_9()) {
|
|
||||||
tp.getPlayer().playSound(tp.getPlayer().getLocation(), Sound.valueOf("ENTITY_PLAYER_LEVELUP"), 1, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mcp.setReplyPlayer(tp.getUUID());
|
mcp.setReplyPlayer(tp.getUUID());
|
||||||
tp.setReplyPlayer(mcp.getUUID());
|
tp.setReplyPlayer(mcp.getUUID());
|
||||||
if(plugin.db != null) {
|
if(Database.isEnabled()) {
|
||||||
Calendar currentDate = Calendar.getInstance();
|
Database.writeVentureChat(mcp.getUUID().toString(), mcp.getName(), "Local", "Messaging_Component", chat.replace("'", "''"), "Chat");
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
String date = formatter.format(currentDate.getTime());
|
|
||||||
plugin.db.writeVentureChat(date, mcp.getUUID().toString(), mcp.getName(), "Local", "Messaging_Component", chat.replace("'", "''"), "Chat");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -195,11 +182,8 @@ public class ChatListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Bukkit.getConsoleSender().sendMessage(partyformat);
|
Bukkit.getConsoleSender().sendMessage(partyformat);
|
||||||
if(plugin.db != null) {
|
if(Database.isEnabled()) {
|
||||||
Calendar currentDate = Calendar.getInstance();
|
Database.writeVentureChat(mcp.getUUID().toString(), mcp.getName(), "Local", "Party_Component", chat.replace("'", "''"), "Chat");
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
String date = formatter.format(currentDate.getTime());
|
|
||||||
plugin.db.writeVentureChat(date, mcp.getUUID().toString(), mcp.getName(), "Local", "Party_Component", chat.replace("'", "''"), "Chat");
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -213,34 +197,50 @@ public class ChatListener implements Listener {
|
|||||||
Boolean filterthis = true;
|
Boolean filterthis = true;
|
||||||
mcp.addListening(eventChannel.getName());
|
mcp.addListening(eventChannel.getName());
|
||||||
if (mcp.isMuted(eventChannel.getName())) {
|
if (mcp.isMuted(eventChannel.getName())) {
|
||||||
if (mcp.getMutes().get(eventChannel.getName()).intValue() > 0) {
|
MuteContainer muteContainer = mcp.getMute(eventChannel.getName());
|
||||||
int dateTimeMillis = Format.currentTimeMillis();
|
if (muteContainer.hasDuration()) {
|
||||||
String units = LocalizedMessage.UNITS_MINUTE_PLURAL.toString();
|
long dateTimeMillis = System.currentTimeMillis();
|
||||||
int muteTimeMillis = mcp.getMutes().get(eventChannel.getName()).intValue();
|
long muteTimeMillis = muteContainer.getDuration();
|
||||||
int remainingMuteTime = (muteTimeMillis - dateTimeMillis) / MILLISECONDS_PER_MINUTE;
|
long remainingMuteTime = muteTimeMillis - dateTimeMillis;
|
||||||
if (remainingMuteTime <= 0) {
|
if (remainingMuteTime < 1000) {
|
||||||
remainingMuteTime = 1;
|
remainingMuteTime = 1000;
|
||||||
}
|
}
|
||||||
if (remainingMuteTime == 1) {
|
String timeString = Format.parseTimeStringFromMillis(remainingMuteTime);
|
||||||
units = LocalizedMessage.UNITS_MINUTE_SINGULAR.toString();
|
if(muteContainer.hasReason()) {
|
||||||
|
mcp.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED_REASON.toString()
|
||||||
|
.replace("{channel_color}", eventChannel.getColor())
|
||||||
|
.replace("{channel_name}", eventChannel.getName())
|
||||||
|
.replace("{time}", timeString)
|
||||||
|
.replace("{reason}", muteContainer.getReason()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mcp.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED.toString()
|
||||||
|
.replace("{channel_color}", eventChannel.getColor())
|
||||||
|
.replace("{channel_name}", eventChannel.getName())
|
||||||
|
.replace("{time}", timeString));
|
||||||
}
|
}
|
||||||
mcp.getPlayer()
|
|
||||||
.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED.toString()
|
|
||||||
.replace("{channel_color}", eventChannel.getColor())
|
|
||||||
.replace("{channel_name}", eventChannel.getName())
|
|
||||||
.replace("{time}", String.valueOf(remainingMuteTime)).replace("{units}", units));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mcp.getPlayer()
|
if(muteContainer.hasReason()) {
|
||||||
.sendMessage(LocalizedMessage.CHANNEL_MUTED.toString()
|
mcp.getPlayer()
|
||||||
.replace("{channel_color}", eventChannel.getColor())
|
.sendMessage(LocalizedMessage.CHANNEL_MUTED_REASON.toString()
|
||||||
.replace("{channel_name}", eventChannel.getName()));
|
.replace("{channel_color}", eventChannel.getColor())
|
||||||
|
.replace("{channel_name}", eventChannel.getName())
|
||||||
|
.replace("{reason}", muteContainer.getReason()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mcp.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.CHANNEL_MUTED.toString()
|
||||||
|
.replace("{channel_color}", eventChannel.getColor())
|
||||||
|
.replace("{channel_name}", eventChannel.getName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mcp.setQuickChat(false);
|
mcp.setQuickChat(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Double chDistance = (double) 0;
|
Double chDistance = (double) 0;
|
||||||
int chCooldown = 0;
|
|
||||||
String curColor = "";
|
String curColor = "";
|
||||||
if(eventChannel.hasPermission() && !mcp.getPlayer().hasPermission(eventChannel.getPermission())) {
|
if(eventChannel.hasPermission() && !mcp.getPlayer().hasPermission(eventChannel.getPermission())) {
|
||||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_PERMISSION.toString());
|
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_PERMISSION.toString());
|
||||||
@ -257,22 +257,20 @@ public class ChatListener implements Listener {
|
|||||||
curColor = eventChannel.getChatColor();
|
curColor = eventChannel.getChatColor();
|
||||||
bungee = eventChannel.getBungee();
|
bungee = eventChannel.getBungee();
|
||||||
|
|
||||||
int dateTimeSeconds = Format.currentTimeMillis() / MILLISECONDS_PER_SECOND;
|
long dateTimeSeconds = System.currentTimeMillis() / Format.MILLISECONDS_PER_SECOND;
|
||||||
|
|
||||||
|
int chCooldown = 0;
|
||||||
if(eventChannel.hasCooldown()) {
|
if(eventChannel.hasCooldown()) {
|
||||||
chCooldown = eventChannel.getCooldown();
|
chCooldown = eventChannel.getCooldown();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (mcp.hasCooldown(eventChannel)) {
|
if (mcp.hasCooldown(eventChannel)) {
|
||||||
int cooldownTime = mcp.getCooldowns().get(eventChannel).intValue();
|
long cooldownTime = mcp.getCooldowns().get(eventChannel).longValue();
|
||||||
if (dateTimeSeconds < cooldownTime) {
|
if (dateTimeSeconds < cooldownTime) {
|
||||||
int remainingCooldownTime = cooldownTime - dateTimeSeconds;
|
long remainingCooldownTime = cooldownTime - dateTimeSeconds;
|
||||||
String units = LocalizedMessage.UNITS_SECOND_PLURAL.toString();
|
String cooldownString = Format.parseTimeStringFromMillis(remainingCooldownTime * Format.MILLISECONDS_PER_SECOND);
|
||||||
if (remainingCooldownTime == 1) {
|
|
||||||
units = LocalizedMessage.UNITS_SECOND_SINGULAR.toString();
|
|
||||||
}
|
|
||||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_COOLDOWN.toString()
|
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_COOLDOWN.toString()
|
||||||
.replace("{cooldown}", String.valueOf(remainingCooldownTime)).replace("{units}", units));
|
.replace("{cooldown}", cooldownString));
|
||||||
mcp.setQuickChat(false);
|
mcp.setQuickChat(false);
|
||||||
bungee = false;
|
bungee = false;
|
||||||
return;
|
return;
|
||||||
@ -289,34 +287,37 @@ public class ChatListener implements Listener {
|
|||||||
|
|
||||||
if (mcp.hasSpam(eventChannel) && plugin.getConfig().getConfigurationSection("antispam").getBoolean("enabled")
|
if (mcp.hasSpam(eventChannel) && plugin.getConfig().getConfigurationSection("antispam").getBoolean("enabled")
|
||||||
&& !mcp.getPlayer().hasPermission("venturechat.spam.bypass")) {
|
&& !mcp.getPlayer().hasPermission("venturechat.spam.bypass")) {
|
||||||
int spamcount = mcp.getSpam().get(eventChannel).get(0);
|
long spamcount = mcp.getSpam().get(eventChannel).get(0);
|
||||||
int spamtime = mcp.getSpam().get(eventChannel).get(1);
|
long spamtime = mcp.getSpam().get(eventChannel).get(1);
|
||||||
int spamtimeconfig = plugin.getConfig().getConfigurationSection("antispam").getInt("spamnumber");
|
long spamtimeconfig = plugin.getConfig().getConfigurationSection("antispam").getLong("spamnumber");
|
||||||
int mutedForTime = plugin.getConfig().getConfigurationSection("antispam").getInt("mutetime", 0);
|
String mutedForTime = plugin.getConfig().getConfigurationSection("antispam").getString("mutetime", "0");
|
||||||
int dateTime = Format.currentTimeMillis();
|
long dateTime = System.currentTimeMillis();
|
||||||
if (dateTimeSeconds < spamtime
|
if (dateTimeSeconds < spamtime
|
||||||
+ plugin.getConfig().getConfigurationSection("antispam").getInt("spamtime")) {
|
+ plugin.getConfig().getConfigurationSection("antispam").getLong("spamtime")) {
|
||||||
if (spamcount + 1 >= spamtimeconfig) {
|
if (spamcount + 1 >= spamtimeconfig) {
|
||||||
if (mutedForTime > 0) {
|
long time = Format.parseTimeStringToMillis(mutedForTime);
|
||||||
mcp.addMute(eventChannel.getName(), dateTime + (mutedForTime * MILLISECONDS_PER_MINUTE));
|
if (time > 0) {
|
||||||
String units = LocalizedMessage.UNITS_MINUTE_PLURAL.toString();
|
mcp.addMute(eventChannel.getName(), dateTime + time, LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString());
|
||||||
if (mutedForTime == 1) {
|
String timeString = Format.parseTimeStringFromMillis(time);
|
||||||
units = LocalizedMessage.UNITS_MINUTE_SINGULAR.toString();
|
|
||||||
}
|
|
||||||
mcp.getPlayer()
|
mcp.getPlayer()
|
||||||
.sendMessage(LocalizedMessage.MUTE_PLAYER_SPAM_TIME.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("{channel_name}", eventChannel.getName())
|
||||||
.replace("{time}", String.valueOf(mutedForTime)).replace("{units}", units));
|
.replace("{time}", timeString)
|
||||||
|
.replace("{reason}", LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mcp.addMute(eventChannel.getName(), 0);
|
mcp.addMute(eventChannel.getName(), LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString());
|
||||||
mcp.getPlayer()
|
mcp.getPlayer()
|
||||||
.sendMessage(LocalizedMessage.MUTE_PLAYER_SPAM.toString()
|
.sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_REASON.toString()
|
||||||
.replace("{channel_color}", eventChannel.getColor())
|
.replace("{channel_color}", eventChannel.getColor())
|
||||||
.replace("{channel_name}", eventChannel.getName()));
|
.replace("{channel_name}", eventChannel.getName())
|
||||||
|
.replace("{reason}", LocalizedMessage.SPAM_MUTE_REASON_TEXT.toString()));
|
||||||
}
|
}
|
||||||
mcp.getSpam().get(eventChannel).set(0, 0);
|
if(eventChannel.getBungee()) {
|
||||||
|
plugin.synchronize(mcp, true);
|
||||||
|
}
|
||||||
|
mcp.getSpam().get(eventChannel).set(0, 0L);
|
||||||
mcp.setQuickChat(false);
|
mcp.setQuickChat(false);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -329,12 +330,12 @@ public class ChatListener implements Listener {
|
|||||||
mcp.getSpam().get(eventChannel).set(0, spamcount + 1);
|
mcp.getSpam().get(eventChannel).set(0, spamcount + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mcp.getSpam().get(eventChannel).set(0, 1);
|
mcp.getSpam().get(eventChannel).set(0, 1L);
|
||||||
mcp.getSpam().get(eventChannel).set(1, dateTimeSeconds);
|
mcp.getSpam().get(eventChannel).set(1, dateTimeSeconds);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mcp.addSpam(eventChannel);
|
mcp.addSpam(eventChannel);
|
||||||
mcp.getSpam().get(eventChannel).add(0, 1);
|
mcp.getSpam().get(eventChannel).add(0, 1L);
|
||||||
mcp.getSpam().get(eventChannel).add(1, dateTimeSeconds);
|
mcp.getSpam().get(eventChannel).add(1, dateTimeSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,11 +512,8 @@ public class ChatListener implements Listener {
|
|||||||
boolean bungee = event.isBungee();
|
boolean bungee = event.isBungee();
|
||||||
|
|
||||||
if(!bungee) {
|
if(!bungee) {
|
||||||
if(plugin.db != null) {
|
if(Database.isEnabled()) {
|
||||||
Calendar currentDate = Calendar.getInstance();
|
Database.writeVentureChat(mcp.getUUID().toString(), mcp.getName(), "Local", channel.getName(), chat.replace("'", "''"), "Chat");
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
String date = formatter.format(currentDate.getTime());
|
|
||||||
plugin.db.writeVentureChat(date, mcp.getUUID().toString(), mcp.getName(), "Local", channel.getName(), chat.replace("'", "''"), "Chat");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(recipientCount == 1) {
|
if(recipientCount == 1) {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package mineverse.Aust1n46.chat.listeners;
|
package mineverse.Aust1n46.chat.listeners;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
import mineverse.Aust1n46.chat.MineverseChat;
|
import mineverse.Aust1n46.chat.MineverseChat;
|
||||||
import mineverse.Aust1n46.chat.alias.Alias;
|
import mineverse.Aust1n46.chat.alias.Alias;
|
||||||
@ -10,6 +8,7 @@ import mineverse.Aust1n46.chat.alias.AliasInfo;
|
|||||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||||
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
||||||
|
import mineverse.Aust1n46.chat.database.Database;
|
||||||
import mineverse.Aust1n46.chat.gui.GuiSlot;
|
import mineverse.Aust1n46.chat.gui.GuiSlot;
|
||||||
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
@ -48,18 +47,20 @@ public class CommandListener implements CommandExecutor, Listener {
|
|||||||
ConfigurationSection cs = plugin.getConfig().getConfigurationSection("commandspy");
|
ConfigurationSection cs = plugin.getConfig().getConfigurationSection("commandspy");
|
||||||
Boolean wec = cs.getBoolean("worldeditcommands", true);
|
Boolean wec = cs.getBoolean("worldeditcommands", true);
|
||||||
MineverseChatPlayer mcp = MineverseChatAPI.getOnlineMineverseChatPlayer(event.getPlayer());
|
MineverseChatPlayer mcp = MineverseChatAPI.getOnlineMineverseChatPlayer(event.getPlayer());
|
||||||
for(MineverseChatPlayer p : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
if(!mcp.getPlayer().hasPermission("venturechat.commandspy.override")) {
|
||||||
if(p.hasCommandSpy()) {
|
for(MineverseChatPlayer p : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
||||||
if(wec) {
|
if(p.hasCommandSpy()) {
|
||||||
p.getPlayer().sendMessage(Format.FormatStringAll(cs.getString("format").replace("{player}", mcp.getName()).replace("{command}", event.getMessage())));
|
if(wec) {
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(!(event.getMessage().toLowerCase().startsWith("//"))) {
|
|
||||||
p.getPlayer().sendMessage(Format.FormatStringAll(cs.getString("format").replace("{player}", mcp.getName()).replace("{command}", event.getMessage())));
|
p.getPlayer().sendMessage(Format.FormatStringAll(cs.getString("format").replace("{player}", mcp.getName()).replace("{command}", event.getMessage())));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!(event.getMessage().toLowerCase().startsWith("//"))) {
|
if(!(event.getMessage().toLowerCase().startsWith("//"))) {
|
||||||
p.getPlayer().sendMessage(ChatColor.GOLD + mcp.getName() + ": " + event.getMessage());
|
p.getPlayer().sendMessage(Format.FormatStringAll(cs.getString("format").replace("{player}", mcp.getName()).replace("{command}", event.getMessage())));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(!(event.getMessage().toLowerCase().startsWith("//"))) {
|
||||||
|
p.getPlayer().sendMessage(ChatColor.GOLD + mcp.getName() + ": " + event.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,30 +76,9 @@ public class CommandListener implements CommandExecutor, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
/*
|
|
||||||
* boolean cus = false; if((message.startsWith("/pl") ||
|
|
||||||
* message.startsWith("/plugins")) &&
|
|
||||||
* plugin.getConfig().getBoolean("modifypluginlist", true)) {
|
|
||||||
* if(message.contains(" ")) { if(message.split(" ")[0].equals("/pl") ||
|
|
||||||
* message.split(" ")[0].equals("/plugins")) { cus = true; } }
|
|
||||||
* if(message.equals("/pl") || message.equals("/plugins")) { cus = true;
|
|
||||||
* } if(cus && mcp.getPlayer().hasPermission("bukkit.command.plugins"))
|
|
||||||
* { String pluginlist = ""; for(Plugin p :
|
|
||||||
* Bukkit.getPluginManager().getPlugins()) { pluginlist +=
|
|
||||||
* ChatColor.GREEN + p.getName().replace("VentureChat",
|
|
||||||
* plugin.getConfig().getString("pluginname", "VentureChat")) +
|
|
||||||
* ChatColor.WHITE + ", "; } if(pluginlist.length() > 2) { pluginlist =
|
|
||||||
* pluginlist.substring(0, pluginlist.length() - 2); }
|
|
||||||
* mcp.getPlayer().sendMessage("Plugins (" +
|
|
||||||
* Bukkit.getPluginManager().getPlugins().length + "): " + pluginlist);
|
|
||||||
* event.setCancelled(true); return; } }
|
|
||||||
*/
|
|
||||||
|
|
||||||
if(plugin.db != null) {
|
if(Database.isEnabled()) {
|
||||||
Calendar currentDate = Calendar.getInstance();
|
Database.writeVentureChat(mcp.getUUID().toString(), mcp.getName(), "Local", "Command_Component", event.getMessage().replace("'", "''"), "Command");
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
String date = formatter.format(currentDate.getTime());
|
|
||||||
plugin.db.writeVentureChat(date, mcp.getUUID().toString(), mcp.getName(), "Local", "Command_Component", event.getMessage().replace("'", "''"), "Command");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Alias a : aa.getAliases()) {
|
for(Alias a : aa.getAliases()) {
|
||||||
@ -145,7 +125,7 @@ public class CommandListener implements CommandExecutor, Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
if(s.startsWith("Broadcast:")) {
|
if(s.startsWith("Broadcast:")) {
|
||||||
plugin.getServer().broadcastMessage(s.substring(11).replace("$", send));
|
Format.broadcastToServer(s.substring(11).replace("$", send));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,7 +133,7 @@ public class CommandListener implements CommandExecutor, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!plugin.quickchat) {
|
if(!plugin.quickchat) {
|
||||||
for(ChatChannel channel : ChatChannel.getChannels()) {
|
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||||
if(!channel.hasPermission() || mcp.getPlayer().hasPermission(channel.getPermission())) {
|
if(!channel.hasPermission() || mcp.getPlayer().hasPermission(channel.getPermission())) {
|
||||||
if(message.equals("/" + channel.getAlias())) {
|
if(message.equals("/" + channel.getAlias())) {
|
||||||
mcp.getPlayer().sendMessage(LocalizedMessage.SET_CHANNEL.toString()
|
mcp.getPlayer().sendMessage(LocalizedMessage.SET_CHANNEL.toString()
|
||||||
@ -209,11 +189,8 @@ public class CommandListener implements CommandExecutor, Listener {
|
|||||||
//old 1.8 command map
|
//old 1.8 command map
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onServerCommand(ServerCommandEvent event) {
|
public void onServerCommand(ServerCommandEvent event) {
|
||||||
if (plugin.db != null) {
|
if (Database.isEnabled()) {
|
||||||
Calendar currentDate = Calendar.getInstance();
|
Database.writeVentureChat("N/A", "Console", "Local", "Command_Component", event.getCommand().replace("'", "''") , "Command");
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
String date = formatter.format(currentDate.getTime());
|
|
||||||
plugin.db.writeVentureChat(date, "N/A", "Console", "Local", "Command_Component", event.getCommand().replace("'", "''") , "Command");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +204,7 @@ public class CommandListener implements CommandExecutor, Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
MineverseChatPlayer mcp = MineverseChatAPI.getOnlineMineverseChatPlayer((Player) sender);
|
MineverseChatPlayer mcp = MineverseChatAPI.getOnlineMineverseChatPlayer((Player) sender);
|
||||||
for(ChatChannel channel : ChatChannel.getChannels()) {
|
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||||
if(command.getName().toLowerCase().equals(channel.getAlias())) {
|
if(command.getName().toLowerCase().equals(channel.getAlias())) {
|
||||||
if(args.length == 0) {
|
if(args.length == 0) {
|
||||||
mcp.getPlayer().sendMessage(ChatColor.RED + "Invalid command: /" + channel.getAlias() + " message");
|
mcp.getPlayer().sendMessage(ChatColor.RED + "Invalid command: /" + channel.getAlias() + " message");
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package mineverse.Aust1n46.chat.listeners;
|
package mineverse.Aust1n46.chat.listeners;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -12,6 +9,7 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.spigotmc.SpigotConfig;
|
||||||
|
|
||||||
import mineverse.Aust1n46.chat.MineverseChat;
|
import mineverse.Aust1n46.chat.MineverseChat;
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
@ -25,7 +23,6 @@ import mineverse.Aust1n46.chat.utilities.UUIDFetcher;
|
|||||||
//and it's data.
|
//and it's data.
|
||||||
public class LoginListener implements Listener {
|
public class LoginListener implements Listener {
|
||||||
private MineverseChat plugin = MineverseChat.getInstance();
|
private MineverseChat plugin = MineverseChat.getInstance();
|
||||||
private boolean firstPlayerHasJoined = false;
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerQuit(PlayerQuitEvent plog) {
|
public void onPlayerQuit(PlayerQuitEvent plog) {
|
||||||
@ -46,6 +43,18 @@ public class LoginListener implements Listener {
|
|||||||
MineverseChatAPI.removeMineverseChatOnlinePlayerToMap(mcp);
|
MineverseChatAPI.removeMineverseChatOnlinePlayerToMap(mcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleNameChange(MineverseChatPlayer mcp, Player eventPlayerInstance) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Detected Name Change. Old Name:&c " + mcp.getName() + " &eNew Name:&c " + eventPlayerInstance.getName()));
|
||||||
|
MineverseChatAPI.removeNameFromMap(mcp.getName());
|
||||||
|
//reset nickname if nickname equals old username
|
||||||
|
if(mcp.getName().equals(eventPlayerInstance.getDisplayName())) {
|
||||||
|
eventPlayerInstance.setDisplayName(eventPlayerInstance.getName());
|
||||||
|
mcp.setNickname(eventPlayerInstance.getName());
|
||||||
|
}
|
||||||
|
mcp.setName(eventPlayerInstance.getName());
|
||||||
|
MineverseChatAPI.addNameToMap(mcp);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) throws Exception {
|
public void onPlayerJoin(PlayerJoinEvent event) throws Exception {
|
||||||
MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer(event.getPlayer());
|
MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer(event.getPlayer());
|
||||||
@ -53,24 +62,14 @@ public class LoginListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
ChatChannel current = ChatChannel.getDefaultChannel();
|
mcp = new MineverseChatPlayer(uuid, name);
|
||||||
Set<UUID> ignores = new HashSet<UUID>();
|
|
||||||
Set<String> listening = new HashSet<String>();
|
|
||||||
listening.add(current.getName());
|
|
||||||
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
|
||||||
Set<String> blockedCommands = new HashSet<String>();
|
|
||||||
String jsonFormat = "Default";
|
|
||||||
mcp = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, false, null, true, true, name, jsonFormat, false, false, false, true, true);
|
|
||||||
MineverseChatAPI.addMineverseChatPlayerToMap(mcp);
|
MineverseChatAPI.addMineverseChatPlayerToMap(mcp);
|
||||||
MineverseChatAPI.addNameToMap(mcp);
|
MineverseChatAPI.addNameToMap(mcp);
|
||||||
}
|
}
|
||||||
UUIDFetcher.checkOfflineUUIDWarning(mcp.getUUID());
|
UUIDFetcher.checkOfflineUUIDWarning(mcp.getUUID());
|
||||||
//check for name change
|
//check for name change
|
||||||
if(!mcp.getName().equals(event.getPlayer().getName())) {
|
if(!mcp.getName().equals(event.getPlayer().getName())) {
|
||||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Detected Name Change. Old Name:&c " + mcp.getName() + " &eNew Name:&c " + event.getPlayer().getName()));
|
handleNameChange(mcp, event.getPlayer());
|
||||||
MineverseChatAPI.removeNameFromMap(mcp.getName());
|
|
||||||
mcp.setName(event.getPlayer().getName());
|
|
||||||
MineverseChatAPI.addNameToMap(mcp);
|
|
||||||
}
|
}
|
||||||
if(!event.getPlayer().getDisplayName().equals(mcp.getName())) {
|
if(!event.getPlayer().getDisplayName().equals(mcp.getName())) {
|
||||||
mcp.setNickname(event.getPlayer().getDisplayName());
|
mcp.setNickname(event.getPlayer().getDisplayName());
|
||||||
@ -97,19 +96,15 @@ public class LoginListener implements Listener {
|
|||||||
mcp.addListening(ch.getName());
|
mcp.addListening(ch.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(SpigotConfig.bungee) {
|
||||||
long delayInTicks = 20L;
|
long delayInTicks = 20L;
|
||||||
// Add extra delay to allow the sync to run properly
|
final MineverseChatPlayer sync = mcp;
|
||||||
if(!firstPlayerHasJoined) {
|
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||||
delayInTicks = 100L;
|
public void run() {
|
||||||
firstPlayerHasJoined = true;
|
plugin.synchronize(sync, false);
|
||||||
|
}
|
||||||
|
}, delayInTicks);
|
||||||
}
|
}
|
||||||
final MineverseChatPlayer sync = mcp;
|
|
||||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
plugin.synchronize(sync, false);
|
|
||||||
}
|
|
||||||
}, delayInTicks);
|
|
||||||
if(!plugin.getConfig().getConfigurationSection("login").getString("message", "Default").equalsIgnoreCase("Default")) {
|
if(!plugin.getConfig().getConfigurationSection("login").getString("message", "Default").equalsIgnoreCase("Default")) {
|
||||||
event.setJoinMessage(Format.FormatStringAll(plugin.getConfig().getConfigurationSection("login").getString("message", "Default").replace("{player}", event.getPlayer().getName())));
|
event.setJoinMessage(Format.FormatStringAll(plugin.getConfig().getConfigurationSection("login").getString("message", "Default").replace("{player}", event.getPlayer().getName())));
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public class Localization {
|
|||||||
private static MineverseChat plugin = MineverseChat.getInstance();
|
private static MineverseChat plugin = MineverseChat.getInstance();
|
||||||
private static FileConfiguration localization;
|
private static FileConfiguration localization;
|
||||||
|
|
||||||
private static final String VERSION = "2.20.0";
|
private static final String VERSION = "2.22.4";
|
||||||
|
|
||||||
public static void initialize() {
|
public static void initialize() {
|
||||||
File localizationFile = new File(plugin.getDataFolder().getAbsolutePath(), "Messages.yml");
|
File localizationFile = new File(plugin.getDataFolder().getAbsolutePath(), "Messages.yml");
|
||||||
|
@ -24,7 +24,9 @@ public enum LocalizedMessage {
|
|||||||
CHANNEL_NO_SPEAK_PERMISSIONS("ChannelNoSpeakPermissions"),
|
CHANNEL_NO_SPEAK_PERMISSIONS("ChannelNoSpeakPermissions"),
|
||||||
CHANNEL_PLAYER_LIST_HEADER("ChannelPlayerListHeader"),
|
CHANNEL_PLAYER_LIST_HEADER("ChannelPlayerListHeader"),
|
||||||
CHANNEL_MUTED("ChannelMuted"),
|
CHANNEL_MUTED("ChannelMuted"),
|
||||||
|
CHANNEL_MUTED_REASON("ChannelMutedReason"),
|
||||||
CHANNEL_MUTED_TIMED("ChannelMutedTimed"),
|
CHANNEL_MUTED_TIMED("ChannelMutedTimed"),
|
||||||
|
CHANNEL_MUTED_TIMED_REASON("ChannelMutedTimedReason"),
|
||||||
COMMAND_INVALID_ARGUMENTS("CommandInvalidArguments"),
|
COMMAND_INVALID_ARGUMENTS("CommandInvalidArguments"),
|
||||||
COMMAND_INVALID_ARGUMENTS_IGNORE("CommandInvalidArgumentsIgnore"),
|
COMMAND_INVALID_ARGUMENTS_IGNORE("CommandInvalidArgumentsIgnore"),
|
||||||
COMMAND_MUST_BE_RUN_BY_PLAYER("CommandMustBeRunByPlayer"),
|
COMMAND_MUST_BE_RUN_BY_PLAYER("CommandMustBeRunByPlayer"),
|
||||||
@ -59,13 +61,19 @@ public enum LocalizedMessage {
|
|||||||
MESSAGE_TOGGLE_ON("MessageToggleOn"),
|
MESSAGE_TOGGLE_ON("MessageToggleOn"),
|
||||||
MUST_LISTEN_ONE_CHANNEL("MustListenOneChannel"),
|
MUST_LISTEN_ONE_CHANNEL("MustListenOneChannel"),
|
||||||
MUTE_PLAYER_ALL_PLAYER("MutePlayerAllPlayer"),
|
MUTE_PLAYER_ALL_PLAYER("MutePlayerAllPlayer"),
|
||||||
|
MUTE_PLAYER_ALL_PLAYER_REASON("MutePlayerAllPlayerReason"),
|
||||||
MUTE_PLAYER_ALL_SENDER("MutePlayerAllSender"),
|
MUTE_PLAYER_ALL_SENDER("MutePlayerAllSender"),
|
||||||
|
MUTE_PLAYER_ALL_SENDER_REASON("MutePlayerAllSenderReason"),
|
||||||
MUTE_PLAYER_PLAYER("MutePlayerPlayer"),
|
MUTE_PLAYER_PLAYER("MutePlayerPlayer"),
|
||||||
MUTE_PLAYER_PLAYER_TIME("MutePlayerPlayerTime"),
|
MUTE_PLAYER_PLAYER_TIME("MutePlayerPlayerTime"),
|
||||||
|
MUTE_PLAYER_PLAYER_TIME_REASON("MutePlayerPlayerTimeReason"),
|
||||||
|
MUTE_PLAYER_PLAYER_REASON("MutePlayerPlayerReason"),
|
||||||
MUTE_PLAYER_SPAM("MutePlayerSpam"),
|
MUTE_PLAYER_SPAM("MutePlayerSpam"),
|
||||||
MUTE_PLAYER_SPAM_TIME("MutePlayerSpamTime"),
|
MUTE_PLAYER_SPAM_TIME("MutePlayerSpamTime"),
|
||||||
MUTE_PLAYER_SENDER("MutePlayerSender"),
|
MUTE_PLAYER_SENDER("MutePlayerSender"),
|
||||||
|
MUTE_PLAYER_SENDER_REASON("MutePlayerSenderReason"),
|
||||||
MUTE_PLAYER_SENDER_TIME("MutePlayerSenderTime"),
|
MUTE_PLAYER_SENDER_TIME("MutePlayerSenderTime"),
|
||||||
|
MUTE_PLAYER_SENDER_TIME_REASON("MutePlayerSenderTimeReason"),
|
||||||
NO_PLAYER_TO_REPLY_TO("NoPlayerToReplyTo"),
|
NO_PLAYER_TO_REPLY_TO("NoPlayerToReplyTo"),
|
||||||
NOTIFICATIONS_OFF("NotificationsOff"),
|
NOTIFICATIONS_OFF("NotificationsOff"),
|
||||||
NOTIFICATIONS_ON("NotificationsOn"),
|
NOTIFICATIONS_ON("NotificationsOn"),
|
||||||
@ -80,11 +88,16 @@ public enum LocalizedMessage {
|
|||||||
SET_CHANNEL_ALL_SENDER("SetChannelAllSender"),
|
SET_CHANNEL_ALL_SENDER("SetChannelAllSender"),
|
||||||
SET_CHANNEL_PLAYER_CHANNEL_NO_PERMISSION("SetChannelPlayerChannelNoPermission"),
|
SET_CHANNEL_PLAYER_CHANNEL_NO_PERMISSION("SetChannelPlayerChannelNoPermission"),
|
||||||
SET_CHANNEL_SENDER("SetChannelSender"),
|
SET_CHANNEL_SENDER("SetChannelSender"),
|
||||||
|
SPAM_MUTE_REASON_TEXT("SpamMuteReasonText"),
|
||||||
SPAM_WARNING("SpamWarning"),
|
SPAM_WARNING("SpamWarning"),
|
||||||
SPY_OFF("SpyOff"),
|
SPY_OFF("SpyOff"),
|
||||||
SPY_ON("SpyOn"),
|
SPY_ON("SpyOn"),
|
||||||
UNBLOCK_COMMAND_PLAYER("UnblockCommandPlayer"),
|
UNBLOCK_COMMAND_PLAYER("UnblockCommandPlayer"),
|
||||||
UNBLOCK_COMMAND_SENDER("UnblockCommandSender"),
|
UNBLOCK_COMMAND_SENDER("UnblockCommandSender"),
|
||||||
|
UNITS_DAY_PLURAL("UnitsDayPlural"),
|
||||||
|
UNITS_DAY_SINGULAR("UnitsDaySingular"),
|
||||||
|
UNITS_HOUR_PLURAL("UnitsHourPlural"),
|
||||||
|
UNITS_HOUR_SINGULAR("UnitsHourSingular"),
|
||||||
UNITS_MINUTE_PLURAL("UnitsMinutePlural"),
|
UNITS_MINUTE_PLURAL("UnitsMinutePlural"),
|
||||||
UNITS_MINUTE_SINGULAR("UnitsMinuteSingular"),
|
UNITS_MINUTE_SINGULAR("UnitsMinuteSingular"),
|
||||||
UNITS_SECOND_PLURAL("UnitsSecondPlural"),
|
UNITS_SECOND_PLURAL("UnitsSecondPlural"),
|
||||||
|
@ -3,13 +3,16 @@ package mineverse.Aust1n46.chat.utilities;
|
|||||||
import static mineverse.Aust1n46.chat.MineverseChat.getInstance;
|
import static mineverse.Aust1n46.chat.MineverseChat.getInstance;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
@ -19,8 +22,10 @@ import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import mineverse.Aust1n46.chat.MineverseChat;
|
import mineverse.Aust1n46.chat.MineverseChat;
|
||||||
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||||
import mineverse.Aust1n46.chat.json.JsonFormat;
|
import mineverse.Aust1n46.chat.json.JsonFormat;
|
||||||
|
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
||||||
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,6 +44,14 @@ public class Format {
|
|||||||
private static final Pattern LEGACY_CHAT_COLOR_PATTERN = Pattern.compile(
|
private static final Pattern LEGACY_CHAT_COLOR_PATTERN = Pattern.compile(
|
||||||
"(?<!(&x(&[a-fA-F0-9]){5}))(?<!(&x(&[a-fA-F0-9]){4}))(?<!(&x(&[a-fA-F0-9]){3}))(?<!(&x(&[a-fA-F0-9]){2}))(?<!(&x(&[a-fA-F0-9]){1}))(?<!(&x))(&)([0-9a-fA-F])");
|
"(?<!(&x(&[a-fA-F0-9]){5}))(?<!(&x(&[a-fA-F0-9]){4}))(?<!(&x(&[a-fA-F0-9]){3}))(?<!(&x(&[a-fA-F0-9]){2}))(?<!(&x(&[a-fA-F0-9]){1}))(?<!(&x))(&)([0-9a-fA-F])");
|
||||||
|
|
||||||
|
public static final long MILLISECONDS_PER_DAY = 86400000;
|
||||||
|
public static final long MILLISECONDS_PER_HOUR = 3600000;
|
||||||
|
public static final long MILLISECONDS_PER_MINUTE = 60000;
|
||||||
|
public static final long MILLISECONDS_PER_SECOND = 1000;
|
||||||
|
|
||||||
|
public static final String DEFAULT_MESSAGE_SOUND = "ENTITY_PLAYER_LEVELUP";
|
||||||
|
public static final String DEFAULT_LEGACY_MESSAGE_SOUND = "LEVEL_UP";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a message to Minecraft JSON formatting while applying the
|
* Converts a message to Minecraft JSON formatting while applying the
|
||||||
* {@link JsonFormat} from the config.
|
* {@link JsonFormat} from the config.
|
||||||
@ -705,7 +718,163 @@ public class Format {
|
|||||||
return getInstance().getConfig().getBoolean("underlineurls", true);
|
return getInstance().getConfig().getBoolean("underlineurls", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int currentTimeMillis() {
|
public static String parseTimeStringFromMillis(long millis) {
|
||||||
return (int) (System.currentTimeMillis() % Integer.MAX_VALUE);
|
String timeString = "";
|
||||||
|
if(millis >= Format.MILLISECONDS_PER_DAY) {
|
||||||
|
long numberOfDays = millis / Format.MILLISECONDS_PER_DAY;
|
||||||
|
millis -= Format.MILLISECONDS_PER_DAY * numberOfDays;
|
||||||
|
|
||||||
|
String units = LocalizedMessage.UNITS_DAY_PLURAL.toString();
|
||||||
|
if (numberOfDays == 1) {
|
||||||
|
units = LocalizedMessage.UNITS_DAY_SINGULAR.toString();
|
||||||
|
}
|
||||||
|
timeString += numberOfDays + " " + units + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(millis >= Format.MILLISECONDS_PER_HOUR) {
|
||||||
|
long numberOfHours = millis / Format.MILLISECONDS_PER_HOUR;
|
||||||
|
millis -= Format.MILLISECONDS_PER_HOUR * numberOfHours;
|
||||||
|
|
||||||
|
String units = LocalizedMessage.UNITS_HOUR_PLURAL.toString();
|
||||||
|
if (numberOfHours == 1) {
|
||||||
|
units = LocalizedMessage.UNITS_HOUR_SINGULAR.toString();
|
||||||
|
}
|
||||||
|
timeString += numberOfHours + " " + units + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(millis >= Format.MILLISECONDS_PER_MINUTE) {
|
||||||
|
long numberOfMinutes = millis / Format.MILLISECONDS_PER_MINUTE;
|
||||||
|
millis -= Format.MILLISECONDS_PER_MINUTE * numberOfMinutes;
|
||||||
|
|
||||||
|
String units = LocalizedMessage.UNITS_MINUTE_PLURAL.toString();
|
||||||
|
if (numberOfMinutes == 1) {
|
||||||
|
units = LocalizedMessage.UNITS_MINUTE_SINGULAR.toString();
|
||||||
|
}
|
||||||
|
timeString += numberOfMinutes + " " + units + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(millis >= Format.MILLISECONDS_PER_SECOND) {
|
||||||
|
long numberOfSeconds = millis / Format.MILLISECONDS_PER_SECOND;
|
||||||
|
millis -= Format.MILLISECONDS_PER_SECOND * numberOfSeconds;
|
||||||
|
|
||||||
|
String units = LocalizedMessage.UNITS_SECOND_PLURAL.toString();
|
||||||
|
if (numberOfSeconds == 1) {
|
||||||
|
units = LocalizedMessage.UNITS_SECOND_SINGULAR.toString();
|
||||||
|
}
|
||||||
|
timeString += numberOfSeconds + " " + units;
|
||||||
|
}
|
||||||
|
return timeString.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long parseTimeStringToMillis(String timeInput) {
|
||||||
|
long millis = 0L;
|
||||||
|
timeInput = timeInput.toLowerCase();
|
||||||
|
char validChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'd', 'h', 'm', 's' };
|
||||||
|
if(containsInvalidChars(validChars, timeInput)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
long countDayTokens = timeInput.chars().filter(ch -> ch == 'd').count();
|
||||||
|
long countHourTokens = timeInput.chars().filter(ch -> ch == 'h').count();
|
||||||
|
long countMinuteTokens = timeInput.chars().filter(ch -> ch == 'm').count();
|
||||||
|
long countSecondTokens = timeInput.chars().filter(ch -> ch == 's').count();
|
||||||
|
if(countDayTokens > 1 || countHourTokens > 1 || countMinuteTokens > 1 || countSecondTokens > 1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int indexOfSecondToken = timeInput.indexOf("s");
|
||||||
|
int indexOfMinuteToken = timeInput.indexOf("m");
|
||||||
|
int indexOfHourToken = timeInput.indexOf("h");
|
||||||
|
int indexOfDayToken = timeInput.indexOf("d");
|
||||||
|
if(indexOfDayToken != -1) {
|
||||||
|
if((indexOfHourToken != -1 && indexOfHourToken < indexOfDayToken) || (indexOfMinuteToken != -1 && indexOfMinuteToken < indexOfDayToken) || (indexOfSecondToken != -1 && indexOfSecondToken < indexOfDayToken)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(indexOfHourToken != -1) {
|
||||||
|
if((indexOfMinuteToken != -1 && indexOfMinuteToken < indexOfHourToken) || (indexOfSecondToken != -1 && indexOfSecondToken < indexOfHourToken)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(indexOfMinuteToken != -1) {
|
||||||
|
if((indexOfSecondToken != -1 && indexOfSecondToken < indexOfMinuteToken)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(indexOfDayToken != -1) {
|
||||||
|
int numberOfDays = Integer.parseInt(timeInput.substring(0, indexOfDayToken));
|
||||||
|
timeInput = timeInput.substring(indexOfDayToken + 1);
|
||||||
|
millis += MILLISECONDS_PER_DAY * numberOfDays;
|
||||||
|
}
|
||||||
|
if(timeInput.length() > 0) {
|
||||||
|
indexOfHourToken = timeInput.indexOf("h");
|
||||||
|
if(indexOfHourToken != -1) {
|
||||||
|
int numberOfHours = Integer.parseInt(timeInput.substring(0, indexOfHourToken));
|
||||||
|
timeInput = timeInput.substring(indexOfHourToken + 1);
|
||||||
|
millis += MILLISECONDS_PER_HOUR * numberOfHours;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(timeInput.length() > 0) {
|
||||||
|
indexOfMinuteToken = timeInput.indexOf("m");
|
||||||
|
if(indexOfMinuteToken != -1) {
|
||||||
|
int numberOfMinutes = Integer.parseInt(timeInput.substring(0, indexOfMinuteToken));
|
||||||
|
timeInput = timeInput.substring(indexOfMinuteToken + 1);
|
||||||
|
millis += MILLISECONDS_PER_MINUTE * numberOfMinutes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(timeInput.length() > 0) {
|
||||||
|
indexOfSecondToken = timeInput.indexOf("s");
|
||||||
|
if(indexOfSecondToken != -1) {
|
||||||
|
int numberOfSeconds = Integer.parseInt(timeInput.substring(0, indexOfSecondToken));
|
||||||
|
timeInput = timeInput.substring(indexOfSecondToken + 1);
|
||||||
|
millis += MILLISECONDS_PER_SECOND * numberOfSeconds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return millis;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean containsInvalidChars(char[] validChars, String validate) {
|
||||||
|
for(char c : validate.toCharArray()) {
|
||||||
|
boolean isValidChar = false;
|
||||||
|
for(char v : validChars) {
|
||||||
|
if(c == v) {
|
||||||
|
isValidChar = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!isValidChar) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void broadcastToServer(String message) {
|
||||||
|
for(MineverseChatPlayer mcp : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
|
||||||
|
mcp.getPlayer().sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void playMessageSound(MineverseChatPlayer mcp) {
|
||||||
|
Player player = mcp.getPlayer();
|
||||||
|
Sound messageSound = getSound(getInstance().getConfig().getString("message_sound", DEFAULT_MESSAGE_SOUND));
|
||||||
|
player.playSound(player.getLocation(), messageSound, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Sound getSound(String soundName) {
|
||||||
|
if(Arrays.asList(Sound.values()).stream().map(Sound::toString).collect(Collectors.toList()).contains(soundName)) {
|
||||||
|
return Sound.valueOf(soundName);
|
||||||
|
}
|
||||||
|
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&c - Message sound invalid!"));
|
||||||
|
return getDefaultMessageSound();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Sound getDefaultMessageSound() {
|
||||||
|
if(VersionHandler.is1_8() || VersionHandler.is1_7_10() || VersionHandler.is1_7_2() || VersionHandler.is1_7_9()) {
|
||||||
|
return Sound.valueOf(DEFAULT_LEGACY_MESSAGE_SOUND);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Sound.valueOf(DEFAULT_MESSAGE_SOUND);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: VentureChat
|
name: VentureChat
|
||||||
version: 2.22.3
|
version: 2.22.4
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
main: mineverse.Aust1n46.chat.MineverseChat
|
main: mineverse.Aust1n46.chat.MineverseChat
|
||||||
depend: [Vault, ProtocolLib, PlaceholderAPI]
|
depend: [Vault, ProtocolLib, PlaceholderAPI]
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
package mineverse.Aust1n46.chat.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
|
import mineverse.Aust1n46.chat.MineverseChat;
|
||||||
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
|
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||||
|
import mineverse.Aust1n46.chat.listeners.LoginListener;;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link LoginListener}.
|
||||||
|
*/
|
||||||
|
@RunWith(PowerMockRunner.class)
|
||||||
|
@PrepareForTest({ MineverseChat.class, MineverseChatAPI.class, Bukkit.class})
|
||||||
|
public class LoginListenerTest {
|
||||||
|
private MineverseChat mockPlugin;
|
||||||
|
private Player mockPlayer;
|
||||||
|
private MineverseChatPlayer mockMCP;
|
||||||
|
private ConsoleCommandSender mockConsoleSender;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mockPlugin = Mockito.mock(MineverseChat.class);
|
||||||
|
mockPlayer = Mockito.mock(Player.class);
|
||||||
|
mockMCP = Mockito.mock(MineverseChatPlayer.class);
|
||||||
|
mockConsoleSender = Mockito.mock(ConsoleCommandSender.class);
|
||||||
|
|
||||||
|
PowerMockito.mockStatic(MineverseChat.class);
|
||||||
|
PowerMockito.when(MineverseChat.getInstance()).thenReturn(mockPlugin);
|
||||||
|
|
||||||
|
PowerMockito.mockStatic(MineverseChatAPI.class);
|
||||||
|
PowerMockito.when(MineverseChatAPI.getMineverseChatPlayer(Mockito.any(Player.class))).thenReturn(mockMCP);
|
||||||
|
|
||||||
|
PowerMockito.mockStatic(Bukkit.class);
|
||||||
|
PowerMockito.when(Bukkit.getConsoleSender()).thenReturn(mockConsoleSender);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
mockPlugin = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoginWithNameChange() throws Exception {
|
||||||
|
Mockito.when(mockPlayer.getName()).thenReturn("NewName");
|
||||||
|
Mockito.when(mockMCP.getName()).thenReturn("OldName");
|
||||||
|
Mockito.when(mockPlayer.getDisplayName()).thenReturn("OldName");
|
||||||
|
LoginListener testLoginListener = new LoginListener();
|
||||||
|
testLoginListener.handleNameChange(mockMCP, mockPlayer);
|
||||||
|
Mockito.verify(mockMCP, Mockito.times(1)).setNickname("NewName");
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user