mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 10:39:05 +00:00
Updated mute localization and spam mute system
This commit is contained in:
parent
f82af0761c
commit
d64de56e6d
@ -16,7 +16,8 @@ ChannelNoPermission: '&cYou do not have permission for this channel.'
|
|||||||
ChannelNoPermissionView: '&cYou do not have permission to look at this channel.'
|
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}&c{time}'
|
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}'
|
||||||
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,7 +55,8 @@ 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} {units}'
|
||||||
MutePlayerSpam: '&cYou have been muted for spamming in: {channel_color}{channel_name}&c{time}'
|
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}'
|
||||||
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} {units}'
|
||||||
NoPlayerToReplyTo: '&cYou do not have anyone to reply to.'
|
NoPlayerToReplyTo: '&cYou do not have anyone to reply to.'
|
||||||
@ -76,8 +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}.'
|
||||||
UnitsPlural: 'minutes'
|
UnitsMinutePlural: 'minutes'
|
||||||
UnitsSingular: 'minute'
|
UnitsMinuteSingular: 'minute'
|
||||||
|
UnitsSecondPlural: 'seconds'
|
||||||
|
UnitsSecondSingular: 'second'
|
||||||
UnmutePlayerAllPlayer: '&cYou have just been unmuted in all channels.'
|
UnmutePlayerAllPlayer: '&cYou have just been unmuted in all channels.'
|
||||||
UnmutePlayerAllSender: '&cUnmuted player &6{player} &cin all channels.'
|
UnmutePlayerAllSender: '&cUnmuted player &6{player} &cin all channels.'
|
||||||
UnmutePlayerPlayer: '&cYou have just been unmuted in: {channel_color}{channel_name}'
|
UnmutePlayerPlayer: '&cYou have just been unmuted in: {channel_color}{channel_name}'
|
||||||
|
@ -77,9 +77,9 @@ public class Mute extends MineverseCommand {
|
|||||||
int time = Integer.parseInt(args[2]);
|
int time = Integer.parseInt(args[2]);
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
player.addMute(channel.getName(), datetime + (time * MILLISECONDS_PER_MINUTE));
|
player.addMute(channel.getName(), datetime + (time * MILLISECONDS_PER_MINUTE));
|
||||||
String units = LocalizedMessage.UNITS_PLURAL.toString();
|
String units = LocalizedMessage.UNITS_MINUTE_PLURAL.toString();
|
||||||
if (time == 1)
|
if (time == 1)
|
||||||
units = LocalizedMessage.UNITS_SINGULAR.toString();
|
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())
|
||||||
|
@ -35,6 +35,9 @@ 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)
|
||||||
@ -209,27 +212,29 @@ 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())) {
|
||||||
String timedMute = "";
|
|
||||||
if (mcp.getMutes().get(eventChannel.getName()).intValue() > 0) {
|
if (mcp.getMutes().get(eventChannel.getName()).intValue() > 0) {
|
||||||
//Calendar currentDate = Calendar.getInstance();
|
int dateTimeMillis = (int) System.currentTimeMillis();
|
||||||
//SimpleDateFormat formatter = new SimpleDateFormat("dd:HH:mm:ss");
|
String units = LocalizedMessage.UNITS_MINUTE_PLURAL.toString();
|
||||||
//String date = formatter.format(currentDate.getTime());
|
int muteTimeMillis = mcp.getMutes().get(eventChannel.getName()).intValue();
|
||||||
//String[] datearray = date.split(":");
|
int remainingMuteTime = (muteTimeMillis - dateTimeMillis) / MILLISECONDS_PER_MINUTE;
|
||||||
//int datetime = (Integer.parseInt(datearray[0]) * 1440) + (Integer.parseInt(datearray[1]) * 60) + (Integer.parseInt(datearray[2]));
|
if (remainingMuteTime <= 0) {
|
||||||
|
remainingMuteTime = 1;
|
||||||
int time = (int) (System.currentTimeMillis() / 60000);
|
|
||||||
|
|
||||||
String keyword = "minutes";
|
|
||||||
int timemark = mcp.getMutes().get(eventChannel.getName()).intValue();
|
|
||||||
int remaining = timemark - time;
|
|
||||||
if(remaining <= 0) remaining = 1;
|
|
||||||
if(remaining == 1) keyword = "minute";
|
|
||||||
timedMute = " for " + remaining + " more " + keyword;
|
|
||||||
}
|
}
|
||||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_MUTED.toString()
|
if (remainingMuteTime == 1) {
|
||||||
.replace("{channel_color}", eventChannel.getColor() + "")
|
units = LocalizedMessage.UNITS_MINUTE_SINGULAR.toString();
|
||||||
|
}
|
||||||
|
mcp.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED.toString()
|
||||||
|
.replace("{channel_color}", eventChannel.getColor())
|
||||||
.replace("{channel_name}", eventChannel.getName())
|
.replace("{channel_name}", eventChannel.getName())
|
||||||
.replace("{time}", timedMute));
|
.replace("{time}", String.valueOf(remainingMuteTime)).replace("{units}", units));
|
||||||
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
@ -251,21 +256,22 @@ public class ChatListener implements Listener {
|
|||||||
curColor = eventChannel.getChatColor();
|
curColor = eventChannel.getChatColor();
|
||||||
bungee = eventChannel.getBungee();
|
bungee = eventChannel.getBungee();
|
||||||
|
|
||||||
int time = (int) (System.currentTimeMillis() / 1000);
|
int dateTimeSeconds = (int) System.currentTimeMillis() / MILLISECONDS_PER_SECOND;
|
||||||
|
|
||||||
if(eventChannel.hasCooldown()) {
|
if(eventChannel.hasCooldown()) {
|
||||||
chCooldown = eventChannel.getCooldown();
|
chCooldown = eventChannel.getCooldown();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (mcp.hasCooldown(eventChannel)) {
|
if (mcp.hasCooldown(eventChannel)) {
|
||||||
int timemark = mcp.getCooldowns().get(eventChannel).intValue();
|
int cooldownTime = mcp.getCooldowns().get(eventChannel).intValue();
|
||||||
if(time < timemark) {
|
if (dateTimeSeconds < cooldownTime) {
|
||||||
int remaining = timemark - time;
|
int remainingCooldownTime = cooldownTime - dateTimeSeconds;
|
||||||
String keyword = "seconds";
|
String units = LocalizedMessage.UNITS_SECOND_PLURAL.toString();
|
||||||
if(remaining == 1) keyword = "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}", remaining + "")
|
.replace("{cooldown}", String.valueOf(remainingCooldownTime)).replace("{units}", units));
|
||||||
.replace("{units}", keyword));
|
|
||||||
mcp.setQuickChat(false);
|
mcp.setQuickChat(false);
|
||||||
bungee = false;
|
bungee = false;
|
||||||
return;
|
return;
|
||||||
@ -273,55 +279,61 @@ public class ChatListener implements Listener {
|
|||||||
}
|
}
|
||||||
if (eventChannel.hasCooldown()) {
|
if (eventChannel.hasCooldown()) {
|
||||||
if (!mcp.getPlayer().hasPermission("venturechat.cooldown.bypass")) {
|
if (!mcp.getPlayer().hasPermission("venturechat.cooldown.bypass")) {
|
||||||
mcp.addCooldown(eventChannel, time + chCooldown);
|
mcp.addCooldown(eventChannel, dateTimeSeconds + chCooldown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
catch(NumberFormatException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mcp.hasSpam(eventChannel) && plugin.getConfig().getConfigurationSection("antispam").getBoolean("enabled") && !mcp.getPlayer().hasPermission("venturechat.spam.bypass")) {
|
if (mcp.hasSpam(eventChannel) && plugin.getConfig().getConfigurationSection("antispam").getBoolean("enabled")
|
||||||
|
&& !mcp.getPlayer().hasPermission("venturechat.spam.bypass")) {
|
||||||
int spamcount = mcp.getSpam().get(eventChannel).get(0);
|
int spamcount = mcp.getSpam().get(eventChannel).get(0);
|
||||||
int spamtime = mcp.getSpam().get(eventChannel).get(1);
|
int spamtime = mcp.getSpam().get(eventChannel).get(1);
|
||||||
int spamtimeconfig = plugin.getConfig().getConfigurationSection("antispam").getInt("spamnumber");
|
int spamtimeconfig = plugin.getConfig().getConfigurationSection("antispam").getInt("spamnumber");
|
||||||
int mutedfor = plugin.getConfig().getConfigurationSection("antispam").getInt("mutetime", 0);
|
int mutedForTime = plugin.getConfig().getConfigurationSection("antispam").getInt("mutetime", 0);
|
||||||
|
int dateTime = (int) System.currentTimeMillis();
|
||||||
int datetime = time/60;
|
if (dateTimeSeconds < spamtime
|
||||||
if(time < spamtime + plugin.getConfig().getConfigurationSection("antispam").getInt("spamtime")) {
|
+ plugin.getConfig().getConfigurationSection("antispam").getInt("spamtime")) {
|
||||||
if (spamcount + 1 >= spamtimeconfig) {
|
if (spamcount + 1 >= spamtimeconfig) {
|
||||||
mcp.addMute(eventChannel.getName(), datetime + mutedfor);
|
mcp.addMute(eventChannel.getName(), dateTime + (mutedForTime * MILLISECONDS_PER_MINUTE));
|
||||||
String timedmute = "";
|
if (mutedForTime > 0) {
|
||||||
if(mutedfor > 0) {
|
String units = LocalizedMessage.UNITS_MINUTE_PLURAL.toString();
|
||||||
String keyword = "minutes";
|
if (mutedForTime == 1) {
|
||||||
if(mutedfor == 1) keyword = "minute";
|
units = LocalizedMessage.UNITS_MINUTE_SINGULAR.toString();
|
||||||
timedmute = " for " + mutedfor + " " + keyword;
|
|
||||||
}
|
}
|
||||||
mcp.getSpam().get(eventChannel).set(0, 0);
|
mcp.getPlayer()
|
||||||
mcp.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SPAM.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}", timedmute));
|
.replace("{time}", String.valueOf(mutedForTime)).replace("{units}", units));
|
||||||
mcp.setQuickChat(false);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(spamtimeconfig % 2 != 0) spamtimeconfig++;
|
mcp.getPlayer()
|
||||||
|
.sendMessage(LocalizedMessage.MUTE_PLAYER_SPAM.toString()
|
||||||
|
.replace("{channel_color}", eventChannel.getColor())
|
||||||
|
.replace("{channel_name}", eventChannel.getName()));
|
||||||
|
}
|
||||||
|
mcp.getSpam().get(eventChannel).set(0, 0);
|
||||||
|
mcp.setQuickChat(false);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (spamtimeconfig % 2 != 0) {
|
||||||
|
spamtimeconfig++;
|
||||||
|
}
|
||||||
if (spamcount + 1 == spamtimeconfig / 2) {
|
if (spamcount + 1 == spamtimeconfig / 2) {
|
||||||
mcp.getPlayer().sendMessage(LocalizedMessage.SPAM_WARNING.toString());
|
mcp.getPlayer().sendMessage(LocalizedMessage.SPAM_WARNING.toString());
|
||||||
}
|
}
|
||||||
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, 1);
|
||||||
mcp.getSpam().get(eventChannel).set(1, time);
|
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, 1);
|
||||||
mcp.getSpam().get(eventChannel).add(1, time);
|
mcp.getSpam().get(eventChannel).add(1, dateTimeSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(eventChannel.hasDistance()) {
|
if(eventChannel.hasDistance()) {
|
||||||
|
@ -3,7 +3,7 @@ package mineverse.Aust1n46.chat.localization;
|
|||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Messages configurable in Messages.yml
|
* Messages configurable in Messages.yml file.
|
||||||
*/
|
*/
|
||||||
public enum LocalizedMessage {
|
public enum LocalizedMessage {
|
||||||
BLOCK_COMMAND_PLAYER("BlockCommandPlayer"),
|
BLOCK_COMMAND_PLAYER("BlockCommandPlayer"),
|
||||||
@ -24,6 +24,7 @@ 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_TIMED("ChannelMutedTimed"),
|
||||||
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"),
|
||||||
@ -62,6 +63,7 @@ public enum LocalizedMessage {
|
|||||||
MUTE_PLAYER_PLAYER("MutePlayerPlayer"),
|
MUTE_PLAYER_PLAYER("MutePlayerPlayer"),
|
||||||
MUTE_PLAYER_PLAYER_TIME("MutePlayerPlayerTime"),
|
MUTE_PLAYER_PLAYER_TIME("MutePlayerPlayerTime"),
|
||||||
MUTE_PLAYER_SPAM("MutePlayerSpam"),
|
MUTE_PLAYER_SPAM("MutePlayerSpam"),
|
||||||
|
MUTE_PLAYER_SPAM_TIME("MutePlayerSpamTime"),
|
||||||
MUTE_PLAYER_SENDER("MutePlayerSender"),
|
MUTE_PLAYER_SENDER("MutePlayerSender"),
|
||||||
MUTE_PLAYER_SENDER_TIME("MutePlayerSenderTime"),
|
MUTE_PLAYER_SENDER_TIME("MutePlayerSenderTime"),
|
||||||
NO_PLAYER_TO_REPLY_TO("NoPlayerToReplyTo"),
|
NO_PLAYER_TO_REPLY_TO("NoPlayerToReplyTo"),
|
||||||
@ -83,8 +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_PLURAL("UnitsPlural"),
|
UNITS_MINUTE_PLURAL("UnitsMinutePlural"),
|
||||||
UNITS_SINGULAR("UnitsSingular"),
|
UNITS_MINUTE_SINGULAR("UnitsMinuteSingular"),
|
||||||
|
UNITS_SECOND_PLURAL("UnitsSecondPlural"),
|
||||||
|
UNITS_SECOND_SINGULAR("UnitsSecondSingular"),
|
||||||
UNMUTE_PLAYER_ALL_PLAYER("UnmutePlayerAllPlayer"),
|
UNMUTE_PLAYER_ALL_PLAYER("UnmutePlayerAllPlayer"),
|
||||||
UNMUTE_PLAYER_ALL_SENDER("UnmutePlayerAllSender"),
|
UNMUTE_PLAYER_ALL_SENDER("UnmutePlayerAllSender"),
|
||||||
UNMUTE_PLAYER_PLAYER("UnmutePlayerPlayer"),
|
UNMUTE_PLAYER_PLAYER("UnmutePlayerPlayer"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user