Хостинг серверов Minecraft playvds.com
  1. Вы находитесь в русском сообществе Bukkit. Мы - администраторы серверов Minecraft, разрабатываем собственные плагины и переводим на русский язык плагины наших собратьев из других стран.
    Скрыть объявление

ID пакетов в Bungee

Тема в разделе "Разработка плагинов для новичков", создана пользователем MrTrojan, 23 июн 2016.

  1. Автор темы
    MrTrojan

    MrTrojan Активный участник Пользователь

    Баллы:
    98
    Skype:
    mrtrojan.ru
    Имя в Minecraft:
    MrTrojan
    Здравствуйте, использую библиотеку BungeePackets, для кое-каких целей, и столкнулся с проблемой, чтобы слушать пакеты, нужно их зарегистрировать, а аргументы брать я так не понял откуда.

     
  2. Хостинг MineCraft
    <
  3. fall.us

    fall.us Активный участник Пользователь

    Баллы:
    76
    Имя в Minecraft:
    fallus
    BungeePackets adds in one simple event to manage packets. PacketEvent. The packet event is used to manage all incoming and outgoing packets. With ever incoming and outgoing packet there is a player assigned with it somewhere in the pipe. Using this system we can differentiate whether a server is sending a packet to Bungee, or a player is, vice-versa.

    In the example below, we are listening for an incoming packet coming from the client to the BungeeCord. We can check who is sending/receiving packets by checking if they are an instance of a commection. To check if the sender is a palyer, check if the sender is an instanceof a ProxiedPlayer. To check if the sender is Bungee, check if the sender is an instance of a BungeeConnection. To check if the sender is a server, check if the sender is an instanceof a ServerConnection.
    Код:
    @EventHandler
    public void onPacket(PacketEvent event) {
        if(event.getSender() instanceof ProxiedPlayer && event.getReciever() instanceof BungeeConnection) {
            if(event.getPacket() instanceof InFlying) {
                InFlying packet = (InFlying) event.getPacket();
            }
        }
    }
    [DOUBLEPOST=1466690886,1466690768][/DOUBLEPOST]Если нужно слушать собственный пакет, то его собсна нужно создать. Айди придумать самому.
     
  4. Автор темы
    MrTrojan

    MrTrojan Активный участник Пользователь

    Баллы:
    98
    Skype:
    mrtrojan.ru
    Имя в Minecraft:
    MrTrojan
    Тогда какие аргументы (первое и третье) задавать?
     
  5. fall.us

    fall.us Активный участник Пользователь

    Баллы:
    76
    Имя в Minecraft:
    fallus
    Полагаю Protocol.DirectionData.TO_SERVER - направление(куда отсылается пакет): TO_SERVER или TO_CLIENT.
    Третье - сам класс.
    public class MyPacket extends Packet{}
    Вроде все ясно написано)
     
    Последнее редактирование: 23 июн 2016

Поделиться этой страницей