Development icon indicating copy to clipboard operation
Development copied to clipboard

PlaceholderAPI Nickname

Open stonegray opened this issue 5 years ago • 1 comments

Is your feature request related to a problem? Please describe. There is no way to integrate MultiChat's nicknames with other plugins (such as tablists).

In Essentials, there is an expansion which provides %essentials_nickname%.

MultiChat does not appear to have this, which makes it a difficult replacement for servers which rely on this functionality.

Describe the solution you'd like

The ability to run a command on change, or set the Essentials nickname with /multichat:nickname would be ideal, as this would allow both for use of a placeholder and allow for other essentials-specific features, such as sending /tpa requests by nickname instead of name.

Alternately, implementing a PlaceholderAPI expansion, eg. %multichat_nickname% would work.

Describe alternatives you've considered I currently use a command substitution that runs both the Essentials nickname and the MultiChat nickname. This works, but is difficult to setup nickname rules as they have to be configured in two places.

PlaceholderAPI does have a poorly documented {player} substitution in the MySQL query expansion, which might be a workaround at the expense of a high number of sql queries.

Additional context

Essentials PlaceholderAPI reference:https://api.extendedclip.com/expansions/essentials/

stonegray avatar Jun 23 '20 10:06 stonegray

Realized I forgot to document the workaround I'm using, so here it is. The following will let you use %mysql_nick% to obtain the player's MultiChat nickname from SQL.

This command will return the nickname if it's available. If not, it will return the player's username.

A word of warning: because this is not implemented in MultiChat, you will hit your DB server every time you expand the placeholder, which can occur many times per second depending on how you use it. If you're on shared hosting your host might not appreciate hundreds of requests per second, and even if you're not, you could take a significant performance hit or risk preventing other plugins from accessing your DB by using this improperly.

To install this, run /papi ecloud download mysql and reload the plugin.

Edit your ./plugins/PlaceholderAPI/expansions/MySQL/config.yml file to include the following:

Query:
  nick:
    query: SELECT IFNULL(MAX(f_nick), (SELECT f_name FROM name_data WHERE id = '{uuid}'))
      FROM nick_data WHERE id = '{uuid}'
Settings:
  Default:
    host: example.org
    port: 1234
    database: foo
    username: bar
    password: baz
  Debug: false

SQL Query:

SELECT
   Ifnull(Max(f_nick), 
   (
      SELECT
         f_name 
      FROM
         name_data 
      WHERE
         id = '{uuid}'
   )
) 
FROM
   nick_data 
WHERE
   id = '{uuid}'

stonegray avatar Jan 30 '21 03:01 stonegray