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

ItsRazum

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

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

Если не знаете, как помочь, не отвечайте
 
Хорошо, не буду отвечать :D
 
http://rubukkit.org/threads/kak-sdelat-soobschenie-v-chate-klikabelnym.139862/
Писал, что пробовал все? а как же гуглить????? Вниз пролистай, там решение есть. Короче ClickEvent - это то, что происходит после клика, Hover, если не ошибаюсь, при наведении. Для менюшки создаешь команду, эту команду при ClickEvent выполняешь. Как это сделать в той теме все написано
 
Ну, что то вроде. Бумага апи.
Код:
    @EventHandler
    public void onChat(AsyncChatEvent event) {
        Component message = event.message();
        message.clickEvent(ClickEvent.suggestCommand(command));
    }
 
Ну, что то вроде. Бумага апи.
Код:
    @EventHandler
    public void onChat(AsyncChatEvent event) {
        Component message = event.message();
        message.clickEvent(ClickEvent.suggestCommand(command));
    }
Вот так можно отправить уже кликабельное сообщение.
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]
 
Вот так можно отправить уже кликабельное сообщение.
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]
TextComponent же надо отсылать через player.spigot().sendMessage(msg);
 
Пишем самописный плагин для чата. В этом деле новички, Поэтому столкнулись с проблемой. Нужно сделать в чате кликабельное сообщение, чтобы на него можно было нажать, и при нажатии плагин вызывает обычную менюшку. Мы что только не перепробовали, у нас ничего не получилось, пишем сюда от отчаяния.

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

Если не знаете, как помочь, не отвечайте
Для решения этой проблемы, вам необходимо установить плагин 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
 
Для решения этой проблемы, вам необходимо установить плагин 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
Ты целый год ответ искал :D?
 
Назад
Верх