Search in sources :

Example 1 with DisguiseType

use of me.libraryaddict.disguise.disguisetypes.DisguiseType in project MagicPlugin by elBukkit.

the class LibsDisguiseManager method disguise.

public boolean disguise(Entity entity, ConfigurationSection configuration) {
    if (configuration == null) {
        DisguiseAPI.undisguiseToAll(entity);
        return true;
    }
    String disguiseName = configuration.getString("type");
    if (disguiseName == null || disguiseName.isEmpty()) {
        return false;
    }
    try {
        DisguiseType disguiseType = DisguiseType.valueOf(disguiseName.toUpperCase());
        Disguise disguise = null;
        switch(disguiseType) {
            case PLAYER:
                PlayerDisguise playerDisguise = new PlayerDisguise(configuration.getString("name"));
                String skin = configuration.getString("skin");
                if (skin != null) {
                    playerDisguise.setSkin(skin);
                }
                disguise = playerDisguise;
                break;
            case FALLING_BLOCK:
            case DROPPED_ITEM:
                Material material = Material.valueOf(configuration.getString("material").toUpperCase());
                int id = DeprecatedUtils.getId(material);
                MiscDisguise itemDisguise = new MiscDisguise(disguiseType, id, configuration.getInt("data"));
                disguise = itemDisguise;
                break;
            case SPLASH_POTION:
            case PAINTING:
                MiscDisguise paintingDisguise = new MiscDisguise(disguiseType, configuration.getInt("data"));
                disguise = paintingDisguise;
                break;
            case ARROW:
            case TIPPED_ARROW:
            case SPECTRAL_ARROW:
            case FIREBALL:
            case SMALL_FIREBALL:
            case DRAGON_FIREBALL:
            case WITHER_SKULL:
            case FISHING_HOOK:
                MiscDisguise miscDisguise = new MiscDisguise(disguiseType);
                disguise = miscDisguise;
                break;
            default:
                boolean isBaby = configuration.getBoolean("baby", false);
                disguise = new MobDisguise(disguiseType, !isBaby);
        }
        DisguiseAPI.disguiseEntity(entity, disguise);
    } catch (Exception ex) {
        owningPlugin.getLogger().log(Level.WARNING, "Error creating disguise", ex);
        return false;
    }
    return true;
}
Also used : Disguise(me.libraryaddict.disguise.disguisetypes.Disguise) MobDisguise(me.libraryaddict.disguise.disguisetypes.MobDisguise) MiscDisguise(me.libraryaddict.disguise.disguisetypes.MiscDisguise) PlayerDisguise(me.libraryaddict.disguise.disguisetypes.PlayerDisguise) MiscDisguise(me.libraryaddict.disguise.disguisetypes.MiscDisguise) DisguiseType(me.libraryaddict.disguise.disguisetypes.DisguiseType) Material(org.bukkit.Material) MobDisguise(me.libraryaddict.disguise.disguisetypes.MobDisguise) PlayerDisguise(me.libraryaddict.disguise.disguisetypes.PlayerDisguise)

Aggregations

Disguise (me.libraryaddict.disguise.disguisetypes.Disguise)1 DisguiseType (me.libraryaddict.disguise.disguisetypes.DisguiseType)1 MiscDisguise (me.libraryaddict.disguise.disguisetypes.MiscDisguise)1 MobDisguise (me.libraryaddict.disguise.disguisetypes.MobDisguise)1 PlayerDisguise (me.libraryaddict.disguise.disguisetypes.PlayerDisguise)1 Material (org.bukkit.Material)1