1. Вы находитесь в сообществе Rubukkit. Мы - администраторы серверов Minecraft, разрабатываем собственные плагины и переводим на различные языки плагины наших коллег из других стран.
    Скрыть объявление
Скрыть объявление
В преддверии глобального обновления, мы проводим исследования, которые помогут нам сделать опыт пользования форумом ещё удобнее. Помогите нам, примите участие!

Помогите Как сделать кликабельный ник в чате?

Тема в разделе "Разработка плагинов для новичков", создана пользователем ItsRazum, 5 ноя 2021.

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

    ItsRazum Активный участник

    Баллы:
    61
    Пишем самописный плагин для чата. В этом деле новички, Поэтому столкнулись с проблемой. Нужно сделать в чате кликабельное сообщение, чтобы на него можно было нажать, и при нажатии плагин вызывает обычную менюшку. Мы что только не перепробовали, у нас ничего не получилось, пишем сюда от отчаяния.

    Итак, главное условие: сделать каждое сообщение игрока кликабельным, при клике открывается меню.

    Если не знаете, как помочь, не отвечайте
     
  2. NuaN

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

    Баллы:
    96
    Имя в Minecraft:
    NuaN
    Хорошо, не буду отвечать :D
     
  3. TATA82

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

    Баллы:
    76
    Имя в Minecraft:
    TATA82
    Chatty
     
  4. Genius_Lyrics

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

    Баллы:
    76
    Skype:
    discord
    http://rubukkit.org/threads/kak-sdelat-soobschenie-v-chate-klikabelnym.139862/
    Писал, что пробовал все? а как же гуглить????? Вниз пролистай, там решение есть. Короче ClickEvent - это то, что происходит после клика, Hover, если не ошибаюсь, при наведении. Для менюшки создаешь команду, эту команду при ClickEvent выполняешь. Как это сделать в той теме все написано
     
  5. alexandrage

    alexandrage Старожил Пользователь

    Баллы:
    173
    Ну, что то вроде. Бумага апи.
    Код:
        @EventHandler
        public void onChat(AsyncChatEvent event) {
            Component message = event.message();
            message.clickEvent(ClickEvent.suggestCommand(command));
        }
     
  6. Автор темы
    ItsRazum

    ItsRazum Активный участник

    Баллы:
    61
    Позволь спросить: каким боком в чатти есть такая тема? Мы как раз с чатти и слезли и начали писать свой плагин
     
  7. Bezobrazie

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

    Баллы:
    46
    Имя в Minecraft:
    MySoulIsCry
    Вот так можно отправить уже кликабельное сообщение.
    PHP:
                                   TextComponent tc = new TextComponent("message");
                                    
    tc.setClickEvent(new ClickEvent(Action""));
                                    
    player.sendMessage(tc);
    Так можно сделать только ник кликабельный. В примере выше будет кликабельным все сообщение.
    PHP:
                                    TextComponent playerNameClick = new TextComponent("PlayerName");
                                    
    playerNameClick.setClickEvent(new ClickEvent(Action""));
                                    
    TextComponent msg = new TextComponent(playerNameClick "message");
                                    
    player.sendMessage(msg);
    [
    php]
     
  8. OJIEKCAHDP

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

    Баллы:
    76
    Имя в Minecraft:
    OJIEKCAHDP
    TextComponent же надо отсылать через player.spigot().sendMessage(msg);
     
  9. Bezobrazie

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

    Баллы:
    46
    Имя в Minecraft:
    MySoulIsCry
    Ну я использовал бумагу, тут можно и так, на спиготе только так как указал ты.
     
  10. As1de

    As1de Активный участник

    Баллы:
    61
    Для решения этой проблемы, вам необходимо установить плагин Chatty, скачайте его и после установки на сервер, заходите в папку плагина, ищете Config.yml, меняете в нем раздел # * JSON, удаляя текст до # NOTIFICATIONSи просто вставляете данный текст, вот кстати он:
    # * JSON
    #
    # Chat formatting with additional interactive features.
    #
    # 1.7.10 and newer.
    json:
    enable: true
    # Command or text that executes (by player) when you click on the player's name.
    #
    # *** You can use EITHER "command" OR "suggest" OR "link".
    #
    # Supports PlaceholderAPI.
    # You can use "{player}" variable here.
    command: /msg {player}
    # Command or text that suggests when you click on the player's name.
    #
    # *** You can use EITHER "command" OR "suggest" OR "link".
    #
    # Supports PlaceholderAPI.
    # You can use "{player}" variable here.
    suggest: '/msg {player} '
    # URL that opens when when you click on the player's name.
    #
    # You must use "http://" or "https://" prefix, else you will crash Minecraft client :D
    #
    # *** You can use EITHER "command" OR "suggest" OR "link".
    #
    # Supports PlaceholderAPI.
    # You can use "{player}" variable here.
    link:
    # Hover tooltip for the player's name.
    # Supports PlaceholderAPI.
    #
    # You can use "{player}" variable here.
    tooltip:
    - '&aНажмите для личного сообщения игроку &6{player}'
    # Mentions.
    # "@NickName" will notify player that he's mentioned.
    # Also it will replaced to a clickable JSON-part.
    #
    # Requires permission: chatty.mentions
    mentions:
    enable: true
    # Display format of mention.
    format: '&e&l@{player}'
    # Plays sound to player, that was mentioned.
    # Remove the line if not needed.
    sound: CLICK
    # Allows to mention vanished players
    # Default: true
    allow-vanished: false
    # Command or text that executes (by player) when you click on the mention.
    #
    # *** You can use EITHER "command" OR "suggest" OR "link".
    #
    # Supports PlaceholderAPI.
    # You can use "{player}" variable here.
    command: /home
    # Command or text that suggests when you click on the mention.
    #
    # *** You can use EITHER "command" OR "suggest" OR "link".
    #
    # Supports PlaceholderAPI.
    # You can use "{player}" variable here.
    suggest: '/msg {player} '
    # URL that opens when when you click on the mention.
    #
    # You must use "http://" or "https://" prefix, else you will crash Minecraft client :D
    #
    # *** You can use EITHER "command" OR "suggest" OR "link".
    #
    # Supports PlaceholderAPI.
    # You can use "{player}" variable here.
    link: 'https://example.com/players?name={player}'
    # Hover tooltip for the mention.
    # Supports PlaceholderAPI.
    #
    # You can use "{player}" variable here.
    tooltip:
    - '&fClick here to message &e{player}'
    # Swears hovers.
    #
    # Available properties:
    # tooltip, suggest
    #
    # Permission: chatty.swears.see
    swears:
    enable: true
    tooltip:
    - '&o{word}'
    - ''
    - '&eClick here to add word to whitelist.'
    suggest: /swears add {word}
    # Replacements for chat formats.
    #
    # You can replace some plain text with clickable parts
    # to make chat more interactive.
    #
    # Available properties:
    # text, tooltip, command, suggest, link.
    replacements:
    'Admin':
    # Original text.
    original: '&cAdmin'
    # New text.
    #
    # Supports PlaceholderAPI.
    # You can use "{player}" variable here.
    #
    # Remove this line, if you need original text.
    text: '&cAdmin'
    # Hover tooltip for the text.
    #
    # Supports PlaceholderAPI.
    #
    # You can use "{player}" variable here.
    tooltip:
    - '&cThis is admin.'
    - '&4&lBe afraid of him!'
    - ''
    - '&eClick here to see the server rules.'
    # *** You should use "command" OR "suggest-command" OR "link" and cannot combine.
    # Command that executes when you click on the text.
    #
    # Supports PlaceholderAPI.
    #
    # You can use "{player}" variable here.
    command: /rules
     
  11. alexandrage

    alexandrage Старожил Пользователь

    Баллы:
    173
    Ты целый год ответ искал :D?
     

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