@Test public void testBroadcast() throws Exception { TestObjects.initBukkitOnlinePlayers(); int sendPacketCalls = 0; int playerCount = Bukkit.getOnlinePlayers().size(); ActionBarSender.broadcast(new Message("")); sendPacketCalls += playerCount; verifyStatic(times(sendPacketCalls)); Utils.sendPacket(any(Player.class), Matchers.anyObject()); ActionBarSender actionBarSender = new ActionBarSender(); actionBarSender.doBroadcast(""); sendPacketCalls += playerCount; verifyStatic(times(sendPacketCalls)); Utils.sendPacket(any(Player.class), Matchers.anyObject()); actionBarSender.doBroadcast("", 34); sendPacketCalls += playerCount; verifyStatic(times(sendPacketCalls)); Utils.sendPacket(any(Player.class), Matchers.anyObject()); }
@BeforeClass public static void prepareTestData() throws NoSuchFieldException, IllegalAccessException { Bukkit.setServer(new TestBukkitServer()); TestObjects.initNMSReflection(); }