Fix #904 (Ljacqu, pls fix me :P)

This commit is contained in:
Gabriele C 2016-10-01 23:09:39 +02:00
parent 06d61db7f0
commit 62b8af6a37
4 changed files with 13 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package fr.xephi.authme;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.permission.AdminPermission;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.settings.Settings;
@ -66,8 +67,11 @@ public class AntiBot {
public void activateAntiBot() {
antiBotStatus = AntiBotStatus.ACTIVE;
for (String s : messages.retrieve(MessageKey.ANTIBOT_AUTO_ENABLED_MESSAGE)) {
bukkitService.broadcastMessage(s);
for(Player player : bukkitService.getOnlinePlayers()) {
if(!permissionsManager.hasPermission(player, AdminPermission.ANTIBOT_MESSAGES)) {
continue;
}
messages.send(player, MessageKey.ANTIBOT_AUTO_ENABLED_MESSAGE);
}
final int duration = settings.getProperty(ProtectionSettings.ANTIBOT_DURATION);

View File

@ -100,6 +100,11 @@ public enum AdminPermission implements PermissionNode {
*/
RELOAD("authme.admin.reload", DefaultPermission.OP_ONLY),
/**
* Administrator command to reload the plugin configuration.
*/
ANTIBOT_MESSAGES("authme.admin.antibotmessages", DefaultPermission.OP_ONLY),
/**
* Permission to see the other accounts of the players that log in.
*/

View File

@ -3,6 +3,7 @@ package fr.xephi.authme.util;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.permission.PermissionNode;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.PluginSettings;
import org.bukkit.BanEntry;

View File

@ -127,7 +127,7 @@ public class AntiBotTest {
// then
assertThat(antiBot.getAntiBotStatus(), equalTo(AntiBot.AntiBotStatus.ACTIVE));
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(bukkitService, times(2)).broadcastMessage(captor.capture());
verify(messages, times(2)).send(captor.capture());
assertThat(captor.getAllValues(), contains("Test line #1", "Test line #2"));
long expectedTicks = duration * TICKS_PER_MINUTE;
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(expectedTicks));