#1442 Don't send bungee messages if the plugin is disabled

+ fix unit test on windows env
This commit is contained in:
Gabriele C 2017-12-05 00:30:08 +01:00
parent 058ac22462
commit 8fd402add3
2 changed files with 10 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package fr.xephi.authme.service.bungeecord;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.settings.Settings;
@ -11,6 +12,7 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.Messenger;
import javax.inject.Inject;
import java.io.Console;
public class BungeeSender implements SettingsDependent {
@ -76,6 +78,10 @@ public class BungeeSender implements SettingsDependent {
*/
public void sendAuthMeBungeecordMessage(String type, String playerName) {
if (isEnabled) {
if(!plugin.isEnabled()) {
ConsoleLogger.debug("Tried to send a " + type + " bungeecord message but the plugin was disabled!");
return;
}
sendBungeecordMessage("AuthMe", type, playerName.toLowerCase());
}
}

View File

@ -15,6 +15,8 @@ import java.util.Arrays;
import java.util.Collections;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.containsStringIgnoringCase;
import static org.hamcrest.Matchers.equalToIgnoringCase;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@ -55,7 +57,7 @@ public class RecentPlayersCommandTest {
// then
verify(sender).sendMessage(argThat(containsString("Recently logged in players")));
verify(sender).sendMessage("- Hannah (08:09 AM, 11 Nov with IP 11.11.11.11)");
verify(sender).sendMessage("- MATT (11:15 PM, 09 Nov with IP 22.11.22.33)");
verify(sender).sendMessage(argThat(equalToIgnoringCase("- Hannah (08:09 AM, 11 Nov with IP 11.11.11.11)")));
verify(sender).sendMessage(argThat(equalToIgnoringCase("- MATT (11:15 PM, 09 Nov with IP 22.11.22.33)")));
}
}