Chameleon 1.1

An API for modifying tags and skins

  1. Nogtail
    So, what is it?
    Chameleon is an API which allows developers to customise players tags and skins and provides utility methods for refreshing players and loading skins. It is mainly event based like TagAPI which will reduce or eliminate conflicts even when many plugins need to change a players skin and/or tag. Unlike TagAPI this plugin won't break for most updates and allows changing of skins without changing tags.

    I'm a server owner
    Great! If you have a plugin which requires Chameleon for modifying tags and/or skins then simply place the latest version in your plugins directory then restart/reload your server. Chameleon requires ProtocolLib so you will also need to grab the latest version from here.

    I'm a plugin developer

    Why use Chameleon?
    Chameleon eliminates conflicts between plugins which both require access to change a players skin and/or tag. Because it is event based the highest priority listener always has the final say in who gets what tag/skin which allows developers to override less important plugins.

    How do I use it?
    Chameleon is based around the AsyncPlayerTagEvent which is fired when a player receives a tag or skin. The event will fire for every viewer of the player when their tag is changed which allows you to set different tags and skins for each viewer. This is an asynchronous event so you will have to make sure you use thread safe objects and be careful when using the Bukkit API.

    To get the viewer of this tag and skin change call the getViewer() method of the event. To get the player whose skin or tag is being changed then you can call the getTarget() method.
    Code (Text):
    @EventHandler
    public void onPlayerTag(AsyncPlayerTagEvent event) {
        Player target = event.getTarget();
        Player viewer = event.getViewer();
    }

    To set the tag of the player use the setTag(String) method, to set the skin of the player you can use the setTextures(String) method. If you need to get the tag or skin from the event you can call the
    getTag() or getTextures() methods respectively.
    Code (Text):
    @EventHandler
    public void onPlayerTag(AsyncPlayerTagEvent event) {
        event.setTag("Notch");
        event.setTextures("Notch");
    }
    The event is fired automatically when players join, vanish etc. but if you want to manually force an event to be fired for a player there are some utility methods you can use. To use these methods you will need an instance of Chameleon which can be obtained by calling Chameleon.getInstance(). To refresh viewers of a player you can call the updateViewers(Player) method. To update the target call the update(Player) method on the instance of Chameleon, this will cause a few packets to be sent to update their skin which will cause a brief flash of the loading screen so it is best not to use this during PvP situations. Usually when changing a players skin both methods will be called.
    Code (Text):
    public void update(Player player) {
        Chameleon chameleon = Chameleon.getInstance();
        chameleon.updateViewers(player);
        chameleon.update(player);
    }
    Why can't I just include this within my plugin?
    The purpose of this plugin is to provide an easy to use API while eliminating conflicts that arise when multiple plugins try to set a players skin or tag, it also means a skin cache is located in a single location which avoids duplication of data. Including this in your plugin would break the entire purpose of this plugin.

    Show me the source
    The source is on Github and can be found here.

    Any examples?
    I have written an example plugin here.
    SIndybad likes this.

Recent Updates

  1. Fix Incorrect Dimension on Skin Reload

Recent Reviews

  1. chekaarHqZ
    chekaarHqZ
    3/5,
    Version: 1.0
    Nice :)
    1. Nogtail
      Author's Response
      Bit of a late reply, but why 3 stars if it is "Nice"?