From 8fd402add340475bb7dc987274a86df9a53b0ddf Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Tue, 5 Dec 2017 00:30:08 +0100 Subject: [PATCH] #1442 Don't send bungee messages if the plugin is disabled + fix unit test on windows env --- .../fr/xephi/authme/service/bungeecord/BungeeSender.java | 6 ++++++ .../command/executable/authme/RecentPlayersCommandTest.java | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java index 4394651be..0b5e6ca64 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java @@ -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()); } } diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/RecentPlayersCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/RecentPlayersCommandTest.java index eac5f8fb9..d73219984 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/RecentPlayersCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/RecentPlayersCommandTest.java @@ -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)"))); } }