From 0097f961b43ecf735513085f1cadaa760e473e73 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sun, 7 Oct 2012 22:46:15 +0200 Subject: Prevent massive amount of mails being send. Added new config: mails-per-minute, default 1000 --- .../src/com/earth2me/essentials/ISettings.java | 2 ++ .../src/com/earth2me/essentials/Settings.java | 12 ++++++++++++ .../earth2me/essentials/commands/Commandmail.java | 21 +++++++++++++++++++-- Essentials/src/config.yml | 3 +++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index d8c421fde..eac342d9e 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -179,4 +179,6 @@ public interface ISettings extends IConf double getMaxFlySpeed(); double getMaxWalkSpeed(); + + public int getMailsPerMinute(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index f05474196..c0cac8dcf 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -439,6 +439,7 @@ public class Settings implements ISettings chatRadius = _getChatRadius(); commandCosts = _getCommandCosts(); warnOnBuildDisallow = _warnOnBuildDisallow(); + mailsPerMinute = _getMailsPerMinute(); } private List itemSpawnBl = new ArrayList(); @@ -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; + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java index 60306c272..e2c95afab 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java @@ -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; diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 9fa0f8c4c..1eedc95dd 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -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 | # -- cgit v1.2.3 From 140a9100b785d1b328060d8bd486843d52c7c40c Mon Sep 17 00:00:00 2001 From: snowleo Date: Sun, 7 Oct 2012 23:00:09 +0200 Subject: Update AntiBuild for NB7.2 --- EssentialsAntiBuild/nbproject/build-impl.xml | 453 +++++++++++++++++++--- EssentialsAntiBuild/nbproject/genfiles.properties | 4 +- 2 files changed, 402 insertions(+), 55 deletions(-) diff --git a/EssentialsAntiBuild/nbproject/build-impl.xml b/EssentialsAntiBuild/nbproject/build-impl.xml index fd7175255..94e589ef7 100644 --- a/EssentialsAntiBuild/nbproject/build-impl.xml +++ b/EssentialsAntiBuild/nbproject/build-impl.xml @@ -12,9 +12,9 @@ is divided into following sections: - execution - debugging - javadoc - - junit compilation - - junit execution - - junit debugging + - test compilation + - test execution + - test debugging - applet - cleanup @@ -181,6 +181,7 @@ is divided into following sections: + @@ -225,6 +226,27 @@ is divided into following sections: + + + + + + + + + + + + + + + + + + + + + @@ -357,11 +379,52 @@ is divided into following sections: - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -370,32 +433,270 @@ is divided into following sections: - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -427,10 +728,13 @@ is divided into following sections: - + Must set JVM to use for profiling in profiler.info.jvm Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + @@ -488,6 +792,7 @@ is divided into following sections: + @@ -504,6 +809,7 @@ is divided into following sections: + @@ -511,6 +817,7 @@ is divided into following sections: + @@ -537,6 +844,9 @@ is divided into following sections: + + + @@ -582,7 +892,7 @@ is divided into following sections: - + - + + + This target only works when run from inside the NetBeans IDE. @@ -813,8 +1127,9 @@ is divided into following sections: - + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. @@ -822,12 +1137,8 @@ is divided into following sections: - - + + This target only works when run from inside the NetBeans IDE. @@ -839,12 +1150,8 @@ is divided into following sections: - - + + This target only works when run from inside the NetBeans IDE. @@ -866,6 +1173,42 @@ is divided into following sections: + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + @@ -952,14 +1295,14 @@ is divided into following sections: - + Some tests failed; see details above. @@ -972,39 +1315,40 @@ is divided into following sections: Must select some files in the IDE or set test.includes - + Some tests failed; see details above. + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + - + Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + @@ -1076,9 +1420,12 @@ is divided into following sections: - - - + + + + + + diff --git a/EssentialsAntiBuild/nbproject/genfiles.properties b/EssentialsAntiBuild/nbproject/genfiles.properties index 61188645c..ed84f2f67 100644 --- a/EssentialsAntiBuild/nbproject/genfiles.properties +++ b/EssentialsAntiBuild/nbproject/genfiles.properties @@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.3.45 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=ddb4519c -nbproject/build-impl.xml.script.CRC32=cfb9443d -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.3.46 +nbproject/build-impl.xml.script.CRC32=00e1454b +nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46 -- cgit v1.2.3