mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 10:39:05 +00:00
Overhauled mute system.
Improved timed muting. Added new arg parser for mute duration. Fixed cooldown overflow issue. Fixed timed mutes not expiring properly issue. Updated data file format to properly use yml formatting. Properly sync timed mutes over BungeeCord.
This commit is contained in:
parent
87b49cec2b
commit
241fe7a319
@ -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,7 @@ 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}'
|
ChannelMutedTimed: '&cYou are muted in this channel: {channel_color}{channel_name}&c for {time}'
|
||||||
CommandInvalidArguments: '&cInvalid command: {command} {args}'
|
CommandInvalidArguments: '&cInvalid command: {command} {args}'
|
||||||
CommandInvalidArgumentsIgnore: '&cInvalid command: /ignore [player] or /ignore list'
|
CommandInvalidArgumentsIgnore: '&cInvalid command: /ignore [player] or /ignore list'
|
||||||
CommandMustBeRunByPlayer: '&cThis command must be run by a player.'
|
CommandMustBeRunByPlayer: '&cThis command must be run by a player.'
|
||||||
@ -54,11 +54,11 @@ MustListenOneChannel: '&cYou need to be listening on at least one channel, setti
|
|||||||
MutePlayerAllPlayer: '&cYou have just been muted in all channels.'
|
MutePlayerAllPlayer: '&cYou have just been muted in all channels.'
|
||||||
MutePlayerAllSender: '&cMuted player &6{player} &cin all channels.'
|
MutePlayerAllSender: '&cMuted player &6{player} &cin all channels.'
|
||||||
MutePlayerPlayer: '&cYou have just been muted in: {channel_color}{channel_name}'
|
MutePlayerPlayer: '&cYou have just been muted in: {channel_color}{channel_name}'
|
||||||
MutePlayerPlayerTime: '&cYou have just been muted in: {channel_color}{channel_name} &cfor {time} {units}'
|
MutePlayerPlayerTime: '&cYou have just been muted in: {channel_color}{channel_name} &cfor {time}'
|
||||||
MutePlayerSpam: '&cYou have been muted for spamming in: {channel_color}{channel_name}'
|
MutePlayerSpam: '&cYou have been muted for spamming in: {channel_color}{channel_name}'
|
||||||
MutePlayerSpamTime: '&cYou have been muted for spamming in: {channel_color}{channel_name} &cfor {time} {units}'
|
MutePlayerSpamTime: '&cYou have been muted for spamming in: {channel_color}{channel_name} &cfor {time}'
|
||||||
MutePlayerSender: '&cMuted player &6{player} &cin: {channel_color}{channel_name}'
|
MutePlayerSender: '&cMuted player &6{player} &cin: {channel_color}{channel_name}'
|
||||||
MutePlayerSenderTime: '&cMuted player &6{player} &cin: {channel_color}{channel_name} &cfor {time} {units}'
|
MutePlayerSenderTime: '&cMuted player &6{player} &cin: {channel_color}{channel_name} &cfor {time}'
|
||||||
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.'
|
||||||
@ -78,6 +78,10 @@ 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'
|
||||||
|
@ -377,25 +377,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<String> iterator = p.getMutes().keySet().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
ChatChannel channel = ChatChannel.getChannel(iterator.next());
|
String channelName = iterator.next();
|
||||||
int timemark = p.getMutes().get(channel.getName());
|
if(ChatChannel.isChannel(channelName)) {
|
||||||
|
ChatChannel channel = ChatChannel.getChannel(channelName);
|
||||||
|
long timemark = p.getMutes().get(channelName);
|
||||||
if (timemark == 0) {
|
if (timemark == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (getConfig().getString("loglevel", "info").equals("debug")) {
|
if (getConfig().getString("loglevel", "info").equals("debug")) {
|
||||||
System.out.println(time + " " + timemark);
|
System.out.println(currentTimeMillis + " " + timemark);
|
||||||
}
|
}
|
||||||
if (time >= timemark) {
|
if (currentTimeMillis >= timemark) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
if (p.isOnline()) {
|
|
||||||
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}", channelName));
|
||||||
} else {
|
if(channel.getBungee()) {
|
||||||
p.setModified(true);
|
MineverseChat.getInstance().synchronize(p, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,7 +407,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
|
||||||
@ -567,6 +569,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
ChatChannel channel = ChatChannel.getChannel(c);
|
ChatChannel channel = ChatChannel.getChannel(c);
|
||||||
if(channel.getBungee()) {
|
if(channel.getBungee()) {
|
||||||
out.writeUTF(channel.getName());
|
out.writeUTF(channel.getName());
|
||||||
|
out.writeLong(mcp.getMutes().get(c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int ignoreCount = 0;
|
int ignoreCount = 0;
|
||||||
@ -807,9 +810,10 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
// 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();
|
||||||
// System.out.println(ch);
|
// System.out.println(ch);
|
||||||
if(ChatChannel.isChannel(ch)) {
|
if(ChatChannel.isChannel(ch)) {
|
||||||
p.addMute(ch, 0);
|
p.addMute(ch, muteTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// System.out.println(msgin.available() + " available before");
|
// System.out.println(msgin.available() + " available before");
|
||||||
@ -942,7 +946,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
Set<UUID> ignores = new HashSet<UUID>();
|
Set<UUID> ignores = new HashSet<UUID>();
|
||||||
Set<String> listening = new HashSet<String>();
|
Set<String> listening = new HashSet<String>();
|
||||||
listening.add(current.getName());
|
listening.add(current.getName());
|
||||||
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
HashMap<String, Long> mutes = new HashMap<String, Long>();
|
||||||
Set<String> blockedCommands = new HashSet<String>();
|
Set<String> blockedCommands = new HashSet<String>();
|
||||||
String jsonFormat = "Default";
|
String jsonFormat = "Default";
|
||||||
s = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, false, null, true, true, name, jsonFormat, false, false, false, true, true);
|
s = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, false, null, true, true, name, jsonFormat, false, false, false, true, true);
|
||||||
|
@ -22,7 +22,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, Long> mutes;
|
||||||
private Set<String> blockedCommands;
|
private Set<String> blockedCommands;
|
||||||
private boolean host;
|
private boolean host;
|
||||||
private UUID party;
|
private UUID party;
|
||||||
@ -38,9 +38,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 +50,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, Long> mutes, Set<String> blockedCommands, boolean host, UUID party, boolean filter, boolean notifications, String nickname, String jsonFormat, boolean spy, boolean commandSpy, boolean rangedSpy, boolean messageToggle, boolean bungeeToggle) {
|
||||||
//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,8 +77,8 @@ 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;
|
||||||
}
|
}
|
||||||
@ -214,11 +207,11 @@ public class MineverseChatPlayer {
|
|||||||
this.listening.clear();
|
this.listening.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Integer> getMutes() {
|
public HashMap<String, Long> getMutes() {
|
||||||
return this.mutes;
|
return this.mutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addMute(String channel, int time) {
|
public boolean addMute(String channel, long time) {
|
||||||
if(channel != null && time >= 0) {
|
if(channel != null && time >= 0) {
|
||||||
mutes.put(channel, time);
|
mutes.put(channel, time);
|
||||||
return true;
|
return true;
|
||||||
@ -412,11 +405,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 +429,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 +439,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;
|
||||||
|
@ -9,14 +9,14 @@ import java.util.UUID;
|
|||||||
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, Long> 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, Long> 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;
|
||||||
@ -61,15 +61,15 @@ public class SynchronizedMineverseChatPlayer {
|
|||||||
return this.ignores;
|
return this.ignores;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMute(String channel) {
|
public void addMute(String channel, long muteTime) {
|
||||||
this.mutes.put(channel, 0);
|
this.mutes.put(channel, muteTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMute(String channel) {
|
public void removeMute(String channel) {
|
||||||
this.mutes.remove(channel);
|
this.mutes.remove(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Integer> getMutes() {
|
public HashMap<String, Long> getMutes() {
|
||||||
return this.mutes;
|
return this.mutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,7 +423,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, new HashSet<String>(), new HashMap<String, Long>(), new HashSet<UUID>(), false, true);
|
||||||
MineverseChatAPI.addSynchronizedMineverseChatPlayerToMap(smcp);
|
MineverseChatAPI.addSynchronizedMineverseChatPlayerToMap(smcp);
|
||||||
}
|
}
|
||||||
out.writeUTF("Sync");
|
out.writeUTF("Sync");
|
||||||
@ -440,6 +440,7 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
for(String channel : smcp.getMutes().keySet()) {
|
for(String channel : smcp.getMutes().keySet()) {
|
||||||
//System.out.println(channel);
|
//System.out.println(channel);
|
||||||
out.writeUTF(channel);
|
out.writeUTF(channel);
|
||||||
|
out.writeLong(smcp.getMutes().get(channel));
|
||||||
}
|
}
|
||||||
//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,7 +460,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, new HashSet<String>(), new HashMap<String, Long>(), new HashSet<UUID>(), false, true);
|
||||||
MineverseChatAPI.addSynchronizedMineverseChatPlayerToMap(smcp);
|
MineverseChatAPI.addSynchronizedMineverseChatPlayerToMap(smcp);
|
||||||
}
|
}
|
||||||
smcp.getListening().clear();
|
smcp.getListening().clear();
|
||||||
@ -474,8 +475,9 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
//System.out.println(size + " mutes");
|
//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();
|
||||||
//System.out.println(mute);
|
//System.out.println(mute);
|
||||||
smcp.addMute(mute);
|
smcp.addMute(mute, muteTime);
|
||||||
}
|
}
|
||||||
int sizeI = in.read();
|
int sizeI = in.read();
|
||||||
for(int c = 0; c < sizeI; c++) {
|
for(int c = 0; c < sizeI; c++) {
|
||||||
|
@ -11,7 +11,6 @@ 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;
|
|
||||||
|
|
||||||
public Mute(String name) {
|
public Mute(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
@ -74,24 +73,22 @@ public class Mute extends MineverseCommand {
|
|||||||
}
|
}
|
||||||
if (channel.isMutable()) {
|
if (channel.isMutable()) {
|
||||||
try {
|
try {
|
||||||
int datetime = Format.currentTimeMillis();
|
long datetime = System.currentTimeMillis();
|
||||||
int time = Integer.parseInt(args[2]);
|
long time = Format.parseTimeStringToMillis(args[2]);
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
player.addMute(channel.getName(), datetime + (time * MILLISECONDS_PER_MINUTE));
|
player.addMute(channel.getName(), datetime + time);
|
||||||
String units = LocalizedMessage.UNITS_MINUTE_PLURAL.toString();
|
String timeString = Format.parseTimeStringFromMillis(time);
|
||||||
if (time == 1)
|
|
||||||
units = LocalizedMessage.UNITS_MINUTE_SINGULAR.toString();
|
|
||||||
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
|
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
|
||||||
.replace("{player}", player.getName())
|
.replace("{player}", player.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 (player.isOnline())
|
||||||
player.getPlayer()
|
player.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
|
else
|
||||||
player.setModified(true);
|
player.setModified(true);
|
||||||
if (channel.getBungee()) {
|
if (channel.getBungee()) {
|
||||||
|
@ -52,11 +52,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, Long> mutes = new HashMap<String, Long>();
|
||||||
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]));
|
mutes.put(parts[0], 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 +115,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, Long> mutes = new HashMap<String, Long>();
|
||||||
StringTokenizer m = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("mutes"), ",");
|
StringTokenizer m = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("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]));
|
mutes.put(parts[0], Long.parseLong(parts[1]));
|
||||||
}
|
}
|
||||||
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"), ",");
|
||||||
|
@ -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;
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ public class PlayerData {
|
|||||||
listening.add(channel);
|
listening.add(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
HashMap<String, Long> mutes = new HashMap<String, Long>();
|
||||||
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 +74,7 @@ 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]));
|
mutes.put(ChatChannel.getChannel(parts[0]).getName(), Long.parseLong(parts[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<String> blockedCommands = new HashSet<String>();
|
Set<String> blockedCommands = new HashSet<String>();
|
||||||
@ -160,18 +161,24 @@ public class PlayerData {
|
|||||||
listening.add(channel);
|
listening.add(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
HashMap<String, Long> mutes = new HashMap<String, Long>();
|
||||||
StringTokenizer m = new StringTokenizer(playerDataFileYamlConfiguration.getString("mutes"), ",");
|
// StringTokenizer m = new StringTokenizer(playerDataFileYamlConfiguration.getString("mutes"), ",");
|
||||||
while(m.hasMoreTokens()) {
|
// while(m.hasMoreTokens()) {
|
||||||
String[] parts = m.nextToken().split(":");
|
// String[] parts = m.nextToken().split(":");
|
||||||
if(ChatChannel.isChannel(parts[0])) {
|
// if(ChatChannel.isChannel(parts[0])) {
|
||||||
if(parts[1].equals("null")) {
|
// if(parts[1].equals("null")) {
|
||||||
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]));
|
// mutes.put(ChatChannel.getChannel(parts[0]).getName(), Long.parseLong(parts[1]));
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
ConfigurationSection muteSection = playerDataFileYamlConfiguration.getConfigurationSection("mutes");
|
||||||
|
for(String channelName : muteSection.getKeys(false)) {
|
||||||
|
ConfigurationSection channelSection = muteSection.getConfigurationSection(channelName);
|
||||||
|
mutes.put(channelName, channelSection.getLong("time"));
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +232,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 +240,13 @@ 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(String channelName : mcp.getMutes().keySet()) {
|
||||||
playerDataFileYamlConfiguration.set("mutes", mutes);
|
ConfigurationSection channelSection = muteSection.createSection(channelName);
|
||||||
if(blockedCommands.length() > 0) {
|
channelSection.set("time", mcp.getMutes().get(channelName));
|
||||||
blockedCommands = blockedCommands.substring(0, blockedCommands.length() - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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() : "");
|
||||||
|
@ -35,9 +35,6 @@ 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)
|
||||||
@ -213,22 +210,19 @@ 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) {
|
if (mcp.getMutes().get(eventChannel.getName()).longValue() > 0) {
|
||||||
int dateTimeMillis = Format.currentTimeMillis();
|
long dateTimeMillis = System.currentTimeMillis();
|
||||||
String units = LocalizedMessage.UNITS_MINUTE_PLURAL.toString();
|
long muteTimeMillis = mcp.getMutes().get(eventChannel.getName()).longValue();
|
||||||
int muteTimeMillis = mcp.getMutes().get(eventChannel.getName()).intValue();
|
long remainingMuteTime = muteTimeMillis - dateTimeMillis;
|
||||||
int remainingMuteTime = (muteTimeMillis - dateTimeMillis) / MILLISECONDS_PER_MINUTE;
|
if (remainingMuteTime < 1000) {
|
||||||
if (remainingMuteTime <= 0) {
|
remainingMuteTime = 1000;
|
||||||
remainingMuteTime = 1;
|
|
||||||
}
|
|
||||||
if (remainingMuteTime == 1) {
|
|
||||||
units = LocalizedMessage.UNITS_MINUTE_SINGULAR.toString();
|
|
||||||
}
|
}
|
||||||
|
String timeString = Format.parseTimeStringFromMillis(remainingMuteTime);
|
||||||
mcp.getPlayer()
|
mcp.getPlayer()
|
||||||
.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED.toString()
|
.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED.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(remainingMuteTime)).replace("{units}", units));
|
.replace("{time}", timeString));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mcp.getPlayer()
|
mcp.getPlayer()
|
||||||
@ -240,7 +234,6 @@ public class ChatListener implements Listener {
|
|||||||
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 +250,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,25 +280,23 @@ 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);
|
||||||
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_SPAM_TIME.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));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mcp.addMute(eventChannel.getName(), 0);
|
mcp.addMute(eventChannel.getName(), 0);
|
||||||
@ -316,7 +305,7 @@ public class ChatListener implements Listener {
|
|||||||
.replace("{channel_color}", eventChannel.getColor())
|
.replace("{channel_color}", eventChannel.getColor())
|
||||||
.replace("{channel_name}", eventChannel.getName()));
|
.replace("{channel_name}", eventChannel.getName()));
|
||||||
}
|
}
|
||||||
mcp.getSpam().get(eventChannel).set(0, 0);
|
mcp.getSpam().get(eventChannel).set(0, 0L);
|
||||||
mcp.setQuickChat(false);
|
mcp.setQuickChat(false);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -329,12 +318,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class LoginListener implements Listener {
|
|||||||
Set<UUID> ignores = new HashSet<UUID>();
|
Set<UUID> ignores = new HashSet<UUID>();
|
||||||
Set<String> listening = new HashSet<String>();
|
Set<String> listening = new HashSet<String>();
|
||||||
listening.add(current.getName());
|
listening.add(current.getName());
|
||||||
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
HashMap<String, Long> mutes = new HashMap<String, Long>();
|
||||||
Set<String> blockedCommands = new HashSet<String>();
|
Set<String> blockedCommands = new HashSet<String>();
|
||||||
String jsonFormat = "Default";
|
String jsonFormat = "Default";
|
||||||
mcp = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, false, null, true, true, name, jsonFormat, false, false, false, true, true);
|
mcp = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, false, null, true, true, name, jsonFormat, false, false, false, true, true);
|
||||||
|
@ -85,6 +85,10 @@ public enum LocalizedMessage {
|
|||||||
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"),
|
||||||
|
@ -21,6 +21,7 @@ import me.clip.placeholderapi.PlaceholderAPI;
|
|||||||
import mineverse.Aust1n46.chat.MineverseChat;
|
import mineverse.Aust1n46.chat.MineverseChat;
|
||||||
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 +40,11 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
@ -700,7 +706,134 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user