From 976149743ac3cb19b649b19a5c3ed95ab9e5f94f Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Tue, 14 Jan 2014 18:28:02 -0600 Subject: [PATCH] Change some way we let people know of hte language system. Also added a console command sender to the test setup, just in case we want to use it later on down the road. --- .../java/com/graywolf336/jail/JailIO.java | 12 +++------ .../jail/util/TestInstanceCreator.java | 25 ++++++++++++++++--- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/graywolf336/jail/JailIO.java b/src/main/java/com/graywolf336/jail/JailIO.java index 3a9674d..b32cafb 100644 --- a/src/main/java/com/graywolf336/jail/JailIO.java +++ b/src/main/java/com/graywolf336/jail/JailIO.java @@ -52,18 +52,14 @@ public class JailIO { lang = YamlConfiguration.loadConfiguration(langFile); pl.getLogger().info("Loaded the language: " + language); }else { - pl.getLogger().severe("The language file can not be a folder, please"); - pl.getLogger().info("double check your setup. Because of that, we"); - pl.getLogger().info("are reverting back to English as the language."); + pl.getLogger().severe("The language file can not be a folder."); + pl.getLogger().severe("As a result, we are reverting back to English as the language."); lang = YamlConfiguration.loadConfiguration(pl.getResource("en.yml")); save = true; } }else { - pl.getLogger().info("Loading the default language of: en"); - pl.getLogger().info("If you wish to change this,"); - pl.getLogger().info("please rename 'en.yml' to whatever"); - pl.getLogger().info("you wish and set the config value"); - pl.getLogger().info("to the name of the file."); + pl.getLogger().warning("Loading the default language of: en"); + pl.getLogger().warning("If you wish to change this, please rename 'en.yml' to whatever you wish and set the config value to the name of the file."); lang = YamlConfiguration.loadConfiguration(pl.getResource("en.yml")); save = true; } diff --git a/src/test/java/test/java/com/graywolf336/jail/util/TestInstanceCreator.java b/src/test/java/test/java/com/graywolf336/jail/util/TestInstanceCreator.java index 1c93094..8f196fb 100644 --- a/src/test/java/test/java/com/graywolf336/jail/util/TestInstanceCreator.java +++ b/src/test/java/test/java/com/graywolf336/jail/util/TestInstanceCreator.java @@ -14,6 +14,7 @@ import org.bukkit.Server; import org.bukkit.World; import org.bukkit.WorldCreator; import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemFactory; import org.bukkit.entity.Player; import org.bukkit.permissions.Permission; @@ -23,13 +24,10 @@ import org.bukkit.plugin.PluginLogger; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; - import org.junit.Assert; - import org.mockito.Matchers; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; - import org.powermock.api.mockito.PowerMockito; import org.powermock.core.MockGateway; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -45,6 +43,7 @@ public class TestInstanceCreator { private Server mockServer; private Player mockPlayer; private CommandSender mockSender, mockPlayerSender; + private ConsoleCommandSender consoleSender; public static final File serverDirectory = new File("bin" + File.separator + "test" + File.separator + "server"); public static final File worldsDirectory = new File("bin" + File.separator + "test" + File.separator + "server"); @@ -188,6 +187,26 @@ public class TestInstanceCreator { serverField.setAccessible(true); serverField.set(main, mockServer); + // Init our command sender + final Logger consoleSenderLogger = Logger.getLogger("ConsoleCommandSender"); + consoleSenderLogger.setParent(Util.logger); + consoleSender = mock(ConsoleCommandSender.class); + doAnswer(new Answer() { + public Void answer(InvocationOnMock invocation) throws Throwable { + consoleSenderLogger.info(ChatColor.stripColor((String) invocation.getArguments()[0])); + return null; + } + }).when(consoleSender).sendMessage(anyString()); + when(consoleSender.getServer()).thenReturn(mockServer); + when(consoleSender.getName()).thenReturn("MockCommandSender"); + when(consoleSender.isPermissionSet(anyString())).thenReturn(true); + when(consoleSender.isPermissionSet(Matchers.isA(Permission.class))).thenReturn(true); + when(consoleSender.hasPermission(anyString())).thenReturn(true); + when(consoleSender.hasPermission(Matchers.isA(Permission.class))).thenReturn(true); + when(consoleSender.addAttachment(main)).thenReturn(null); + when(consoleSender.isOp()).thenReturn(true); + when(mockServer.getConsoleSender()).thenReturn(consoleSender); + // Init our command sender final Logger commandSenderLogger = Logger.getLogger("CommandSender"); commandSenderLogger.setParent(Util.logger);