use of com.laytonsmith.abstraction.MCConsoleCommandSender in project CommandHelper by EngineHub.
the class PlayerManangementTest method testPlayerFromConsole.
@Test
public void testPlayerFromConsole() throws Exception {
MCConsoleCommandSender fakeConsole = mock(MCConsoleCommandSender.class);
when(fakeConsole.getName()).thenReturn("CONSOLE");
assertEquals("~console", SRun("player()", fakeConsole));
}
use of com.laytonsmith.abstraction.MCConsoleCommandSender in project CommandHelper by EngineHub.
the class StaticTest method GetFakeConsoleCommandSender.
public static MCConsoleCommandSender GetFakeConsoleCommandSender() {
MCConsoleCommandSender c = mock(MCConsoleCommandSender.class);
when(c.getName()).thenReturn("CONSOLE");
MCServer s = GetFakeServer();
when(c.getServer()).thenReturn(s);
return c;
}
use of com.laytonsmith.abstraction.MCConsoleCommandSender in project CommandHelper by EngineHub.
the class PlayerManangementTest method testPlayer2.
@Test(timeout = 10000)
public void testPlayer2() throws Exception {
String script = "player()";
MCConsoleCommandSender c = GetFakeConsoleCommandSender();
assertEquals("~console", SRun(script, c));
}
use of com.laytonsmith.abstraction.MCConsoleCommandSender in project CommandHelper by EngineHub.
the class Static method SendMessage.
/**
* This function sends a message to the player. If the player is not online, a CRE is thrown.
*
* @param m
* @param msg
*/
public static void SendMessage(final MCCommandSender m, String msg, final Target t) {
if (m != null && !(m instanceof MCConsoleCommandSender)) {
if (m instanceof MCPlayer) {
MCPlayer p = (MCPlayer) m;
if (!p.isOnline()) {
throw new CREPlayerOfflineException("The player " + p.getName() + " is not online", t);
}
}
m.sendMessage(msg);
} else {
msg = Static.MCToANSIColors(msg);
if (msg.contains("\033")) {
// We have terminal colors, we need to reset them at the end
msg += TermColors.reset();
}
StreamUtils.GetSystemOut().println(msg);
}
}
Aggregations