mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-27 03:28:30 +01:00
Prevent massive amount of mails being send.
Added new config: mails-per-minute, default 1000
This commit is contained in:
parent
98d657ec4b
commit
0097f961b4
@ -179,4 +179,6 @@ public interface ISettings extends IConf
|
||||
double getMaxFlySpeed();
|
||||
|
||||
double getMaxWalkSpeed();
|
||||
|
||||
public int getMailsPerMinute();
|
||||
}
|
||||
|
@ -439,6 +439,7 @@ public class Settings implements ISettings
|
||||
chatRadius = _getChatRadius();
|
||||
commandCosts = _getCommandCosts();
|
||||
warnOnBuildDisallow = _warnOnBuildDisallow();
|
||||
mailsPerMinute = _getMailsPerMinute();
|
||||
}
|
||||
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
||||
|
||||
@ -936,4 +937,15 @@ public class Settings implements ISettings
|
||||
double maxSpeed = config.getDouble("max-walk-speed", 0.8);
|
||||
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
|
||||
}
|
||||
|
||||
private int mailsPerMinute;
|
||||
|
||||
private int _getMailsPerMinute() {
|
||||
return config.getInt("mails-per-minute", 1000);
|
||||
}
|
||||
@Override
|
||||
public int getMailsPerMinute()
|
||||
{
|
||||
return mailsPerMinute;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class Commandmail extends EssentialsCommand
|
||||
{
|
||||
private static int mailsPerMinute = 0;
|
||||
private static long timestamp = 0;
|
||||
|
||||
public Commandmail()
|
||||
{
|
||||
super("mail");
|
||||
@ -58,8 +61,22 @@ public class Commandmail extends EssentialsCommand
|
||||
}
|
||||
if (!u.isIgnoredPlayer(user))
|
||||
{
|
||||
final String mail = Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
|
||||
u.addMail(user.getName() + ": " + mail);
|
||||
final String mail = user.getName() + ": " + Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
|
||||
if (mail.length() > 1000)
|
||||
{
|
||||
throw new Exception("Mail message too long. Try to keep it below 1000");
|
||||
}
|
||||
if (Math.abs(System.currentTimeMillis() - timestamp) > 60000)
|
||||
{
|
||||
timestamp = System.currentTimeMillis();
|
||||
mailsPerMinute = 0;
|
||||
}
|
||||
mailsPerMinute++;
|
||||
if (mailsPerMinute > ess.getSettings().getMailsPerMinute())
|
||||
{
|
||||
throw new Exception("Too many mails have been send within the last minute. Maximum: " + ess.getSettings().getMailsPerMinute());
|
||||
}
|
||||
u.addMail(mail);
|
||||
}
|
||||
user.sendMessage(_("mailSent"));
|
||||
return;
|
||||
|
@ -315,6 +315,9 @@ login-attack-delay: 5
|
||||
#Set the max fly speed, values range from 0.1 to 1.0
|
||||
max-fly-speed: 0.8
|
||||
|
||||
#Set the maximum amount of mails that can be send within a minute.
|
||||
mails-per-minute: 1000
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | EssentialsHome | #
|
||||
|
Loading…
Reference in New Issue
Block a user