Search in sources :

Example 1 with Message

use of at.pcgamingfreaks.Bungee.Message.Message in project Bukkit_Bungee_PluginLib by GeorgH93.

the class ActionBarSenderTest method testBroadcast.

@Test
public void testBroadcast() throws NoSuchFieldException, IllegalAccessException {
    TestObjects.initProxyServer();
    int sendCalls = 0;
    int playerCount = TestObjects.getPlayers().size();
    ActionBarSender actionBarSender = new ActionBarSender();
    actionBarSender.doBroadcast("");
    sendCalls += playerCount;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    actionBarSender.doBroadcast("", 1);
    sendCalls += playerCount;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    ActionBarSender.broadcast(new Message(""));
    sendCalls += playerCount;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
}
Also used : Message(at.pcgamingfreaks.Bungee.Message.Message) Chat(net.md_5.bungee.protocol.packet.Chat) Test(org.junit.Test)

Example 2 with Message

use of at.pcgamingfreaks.Bungee.Message.Message in project Bukkit_Bungee_PluginLib by GeorgH93.

the class ActionBarSenderTest method testSend.

@Test
public void testSend() {
    List<ProxiedPlayer> players = new ArrayList<>();
    players.add(TestObjects.getPlayer());
    players.add(TestObjects.getPlayer());
    int sendCalls = 0;
    int playerCount = players.size();
    ActionBarSender actionBarSender = new ActionBarSender();
    actionBarSender.doSend(TestObjects.getPlayer(), "");
    verify(TestObjects.getPlayer().unsafe(), times(++sendCalls)).sendPacket(any(Chat.class));
    actionBarSender.doSend(TestObjects.getPlayer(), "", 1);
    verify(TestObjects.getPlayer().unsafe(), times(++sendCalls)).sendPacket(any(Chat.class));
    ActionBarSender.send(TestObjects.getPlayer(), new Message(""));
    verify(TestObjects.getPlayer().unsafe(), times(++sendCalls)).sendPacket(any(Chat.class));
    actionBarSender.doSend(players, "");
    sendCalls += playerCount;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    actionBarSender.doSend(players, "", 1);
    sendCalls += playerCount;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    ActionBarSender.send(players, new Message(""));
    sendCalls += playerCount;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) Message(at.pcgamingfreaks.Bungee.Message.Message) ArrayList(java.util.ArrayList) Chat(net.md_5.bungee.protocol.packet.Chat) Test(org.junit.Test)

Example 3 with Message

use of at.pcgamingfreaks.Bungee.Message.Message in project Bukkit_Bungee_PluginLib by GeorgH93.

the class BossBarSenderTest method testSend.

@Test
public void testSend() {
    List<ProxiedPlayer> players = new ArrayList<>();
    players.add(TestObjects.getPlayer());
    players.add(TestObjects.getPlayer());
    int sendCalls = 0;
    BossBarSender bossBarSender = new BossBarSender();
    bossBarSender.doSend(TestObjects.getPlayer(), "");
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    bossBarSender.doSend(TestObjects.getPlayer(), "", 1);
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    BossBarSender.send(TestObjects.getPlayer(), new Message(""));
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    bossBarSender.doSend(players, "");
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    bossBarSender.doSend(players, "", 1);
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) Message(at.pcgamingfreaks.Bungee.Message.Message) ArrayList(java.util.ArrayList) Chat(net.md_5.bungee.protocol.packet.Chat) Test(org.junit.Test)

Example 4 with Message

use of at.pcgamingfreaks.Bungee.Message.Message in project Bukkit_Bungee_PluginLib by GeorgH93.

the class TitleSenderTest method testSend.

@Test
public void testSend() {
    List<ProxiedPlayer> players = new ArrayList<>();
    players.add(TestObjects.getPlayer());
    players.add(TestObjects.getPlayer());
    int sendCalls = 0;
    int playerCount = players.size();
    TitleSender titleSender = new TitleSender();
    titleSender.doSend(TestObjects.getPlayer(), "");
    sendCalls += 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    titleSender.doSend(TestObjects.getPlayer(), "", 1);
    sendCalls += 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    titleSender.doSend(TestObjects.getPlayer(), "", new TitleMetadata());
    sendCalls += 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    TitleSender.send(TestObjects.getPlayer(), new Message(""));
    sendCalls += 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    TitleSender.send(TestObjects.getPlayer(), new Message(""), new TitleMetadata(10, 10, 20));
    sendCalls += 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    titleSender.doSend(players, "");
    sendCalls += playerCount * 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    titleSender.doSend(players, "", 1);
    sendCalls += playerCount * 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    titleSender.doSend(players, "", new TitleMetadata());
    sendCalls += playerCount * 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    TitleSender.send(players, new Message(""));
    sendCalls += playerCount * 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    TitleSender.send(players, new Message(""), new TitleMetadata(true));
    sendCalls += playerCount * 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) Message(at.pcgamingfreaks.Bungee.Message.Message) ArrayList(java.util.ArrayList) Chat(net.md_5.bungee.protocol.packet.Chat) Test(org.junit.Test)

Example 5 with Message

use of at.pcgamingfreaks.Bungee.Message.Message in project Bukkit_Bungee_PluginLib by GeorgH93.

the class TitleSenderTest method testBroadcast.

@Test
public void testBroadcast() throws NoSuchFieldException, IllegalAccessException {
    TestObjects.initProxyServer();
    int sendCalls = 0;
    int playerCount = TestObjects.getPlayers().size();
    TitleSender titleSender = new TitleSender();
    titleSender.doBroadcast("");
    sendCalls += playerCount * 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    titleSender.doBroadcast("", 1);
    sendCalls += playerCount * 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    titleSender.doBroadcast("", new TitleMetadata());
    sendCalls += playerCount * 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    TitleSender.broadcast(new Message(""));
    sendCalls += playerCount * 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    TitleSender.broadcast(new Message(""), TitleMetadata.fromJson("[{\"fadeIn\": 10, \"fadeOut\": 20, \"stay\": 30, \"subtitle\": false}]"));
    sendCalls += playerCount * 2;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
}
Also used : Message(at.pcgamingfreaks.Bungee.Message.Message) Chat(net.md_5.bungee.protocol.packet.Chat) Test(org.junit.Test)

Aggregations

Message (at.pcgamingfreaks.Bungee.Message.Message)9 Test (org.junit.Test)9 Chat (net.md_5.bungee.protocol.packet.Chat)8 ArrayList (java.util.ArrayList)4 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)4