Skip to content

ModernDisguise is a free lightweight open-source high quality library to help you add a disguise/nick system in your minecraft plugin

License

Notifications You must be signed in to change notification settings

iiAhmedYT/ModernDisguise

Repository files navigation

💬 Description

ModernDisguise is a free lightweight open-source high quality library to help you add a disguise system to your minecraft plugin

Here's the SpigotMC Forum

😎 Features

You can change the player's:

  • Name (Server side)
  • Skin (Server side)
  • EntityType (up to 82 entities) (Client side & other players only can see it)

✅ Supported versions

  • 1.8.8 (1_8_R3)
  • 1.9.4 (1_9_R2)
  • 1.10.x (1_10_R1)
  • 1.11.x (1_11_R1)
  • 1.12.x (1_12_R1)
  • 1.13.x (1_13_R1, 1_13_R2)
  • 1.14.x (1_14_R1)
  • 1.15.x (1_15_R1)
  • 1.16.x (1_16_R1, 1_16_R2, 1_16_R3)
  • 1.17.x (1_17_R1)
  • 1.18.x (1_18_R1, 1_18_R2)
  • 1.19.x (1_19_R1, 1_19_R2, 1_19_R3)
  • 1.20.x (1_20_R1, 1_20_R2, 1_20_R3, 1_20_R4)

⚠️ WARNING

On versions that support Mojang Chat-Reports this library disables that feature in order for disguised players to chat. You can disable it by using DisguiseProvider#allowOverrideChat(false)

Example:

public class ExampleClass {

    private final DisguiseProvider provider = DisguiseManager.getProvider();

    public ExampleClass() {
        DisguiseManager.setPlugin(ExamplePlugin.getInstance());
        provider.allowOverrideChat(false);
    }

}

➕ Add to your project

Maven

Add this repo to your repositories:

<repository>
    <id>gravemc-repo</id>
    <url>https://repo.gravemc.net/releases/</url>
</repository>

and then add this dependancy:

<dependency>
    <groupId>dev.iiahmed</groupId>
    <artifactId>ModernDisguise</artifactId>
    <version>2.8</version>
    <scope>compile</scope>
</dependency>

and you can relocate them as well, here's an example maven-shade-plugin config:

<configuration>
    <filters>
        <filter>
            <artifact>*:*</artifact>
            <excludes>
                <exclude>META-INF/</exclude>
            </excludes>
        </filter>
    </filters>
    <relocations>
        <relocation>
            <pattern>dev.iiahmed.disguise</pattern>
            <shadedPattern>your.own.package.disguise</shadedPattern>
        </relocation>
    </relocations>
</configuration>

Gradle

Add this repo to your repositories block:

repositories {
    maven {
        name = "gravemc-repo"
        url = "https://repo.gravemc.net/releases/"
    }
}

and now add dependency:

dependencies {
    implementation 'dev.iiahmed:ModernDisguise:2.8'
}

🧑‍💻 Usage

Here's an example usage of the API (easiest):

import dev.iiahmed.disguise.*;

public class ExampleClass implements Listener {

    private final DisguiseProvider provider = DisguiseManager.getProvider();

    public ExampleClass() {
        DisguiseManager.setPlugin(ExamplePlugin.getInstance());
        // this is optional (it registers a PlaceholderAPI expansion for you)
        // placeholders are: %nick_name%, %nick_realname%, %nick_is_nicked% (%nick_is_disguised%)
        DisguiseManager.registerExpansion();
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        Disguise disguise = Disguise.builder()
                .setName("BillBobbyBob")
                // you could as well use Disguise.Builder#setSkin(textures, signature)
                // or even Disguise.Builder#setSkin(uuid, skinAPI)
                // it's recommended to run this async since #setSkin from an online API will block the mainthread
                .setSkin("example-name", SkinAPI.MOJANG) // You don't have to specify an API (mojang is default)
                // this will change the player into a zombie for others only
                .setEntityType(EntityType.ZOMBIE)
                .build();
        provider.disguise(player, disguise);
    }

}

Here's an advanced way of using it:

import dev.iiahmed.disguise.*;

public class ExampleClass implements Listener {

    private final DisguiseProvider provider = DisguiseManager.getProvider();

    public ExampleClass() {
        DisguiseManager.setPlugin(ExamplePlugin.getInstance());
        // this is optional (it registers a PlaceholderAPI expansion for you)
        // placeholders are: %nick_name%, %nick_realname%, %nick_is_nicked% (%nick_is_disguised%)
        DisguiseManager.registerExpansion();
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        Disguise disguise = Disguise.builder()
                .setName("BillBobbyBob")
                // you could as well use Disguise.Builder#setSkin(textures, signature)
                // or even Disguise.Builder#setSkin(uuid, skinAPI)
                // it's recommended to run this async since #setSkin from an online API will block the mainthread
                .setSkin("example-name", SkinAPI.MOJANG) // You don't have to specify an API (mojang is default)
                // this will change the player into a zombie for others only
                .setEntityType(EntityType.ZOMBIE)
                .build();
        DisguiseResponse response = provider.disguise(player, disguise);
        // there are 8 responses other than DisguiseResponse#SUCCESS
        switch (response) {
            case SUCCESS -> player.sendMessage("Disguise is successful.");
            case FAIL_NAME_ALREADY_ONLINE -> player.sendMessage("There's already an online player with that name.");
            default -> player.sendMessage("Disguise is unsuccessful with the reason " + response.toString());
        }
    }

}

There's way more to it but I'd rather you figure it out on your own by checking the DisguiseProvider class :)

🏗️ Building

1- Building Spigot Versions

All these versions have to be built using Spigot's BuildTools

  • 1.8.8
  • 1.9.4
  • 1.10.2
  • 1.11.2
  • 1.12.2
  • 1.13, 1.13.2
  • 1.14.4
  • 1.15.2
  • 1.16.1, 1.16.3, 1.16.5

Versions from now-on should be built with the --remapped flag

  • 1.17.1
  • 1.18.1, 1.18.2
  • 1.19.2, 1.19.3, 1.19.4
  • 1.20.1, 1.20.2, 1.20.4, 1.20.5
2- Cloning

You can either clone the repository using the famous git clone command or use your IDE's clone feature

Congratulations! Now you can build ModernDisguise with the command mvn clean install

🪪 License

This project is licensed under the GPL-3.0 License

☀️ Credits

Shoutout to those people for helping me test this project and helping me find every single bug

Thanks to all the github contributors

Thanks JetBrains for providing me an Open-Source development tools License ❤️

About

ModernDisguise is a free lightweight open-source high quality library to help you add a disguise/nick system in your minecraft plugin

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages