Zachari / NameCorrector

Update to PocketMine-MP plugin to support PocketMine-MP API version 3.0.0.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NameCorrector - UPDATED FOR USE WITH API 3.0.0-ALPHA7

Let the whole world join, whatever names they use

NameCorrector is a plugin that makes sure people with any usernames in their MCPE settings can join. But NameCorrector would change their names to do so.

PocketMine uses a rule inherited from "Minecraft Server" by Mojang to force player names be a text of 3 to 16 characters of ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_. Yet, some players are not aware of it. This plugin helps forces them to be aware of that without kicking them. It simply changes their names.

By default configuration, this plugin will:

  • Replace all accent characters (they are disallowed) and other Latin-alphabet-based/alike characters into their original/similar Latin character.
  • Replace other invalid characters and multibyte characters (given that the multibyte extension exists on your server).
  • Truncate usernames longer than 16 characters into 16 characters long.
  • Add padding underscores behind the username until it is 3 characters long.

You can modify these settings in config.yml. Read the comments inside config.yml generated by the plugin for more details. Remember to let your app open config.yml with UTF-8 (instead of other encoding like ANSI)!

The development build of the plugin can be downloaded from GitHub.

You can also view the config.yml default file on GitHub (although it may not be of the version you are using).

Please report bugs to this plugin's issue tracker.

Public API

This plugin provides a public API function:

public string \NameCorrector\NameCorrector::correctName(string name);

Example:

/** @var \pocketmine\Server $server the PocketMine Server instance, often retrieved using $this->getServer() in plugin main classes */
/** @var string $old the uncorrected name */
$nameCorrector = $server->getPluginManager()->getPlugin("NameCorrector");
if($nameCorrector instanceof \NameCorrector\NameCorrector and $nameCorrector->isEnabled()){
    $new = $nameCorrector->correctName($old);
    // TODO handle success: the corrected version of $old is now stored in $new
}else{
    // TODO handle error: NameCorrector is not enabled
}

About

Update to PocketMine-MP plugin to support PocketMine-MP API version 3.0.0.


Languages

Language:PHP 100.0%