Search in sources :

Example 1 with PlayerDisguise

use of me.libraryaddict.disguise.disguisetypes.PlayerDisguise in project solinia3-core by mixxit.

the class SoliniaActiveSpell method applyIllusion.

private void applyIllusion(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
    DisguisePackage disguise = Utils.getDisguiseTypeFromDisguiseId(spellEffect.getBase());
    if (disguise.getDisguisetype() == null || disguise.getDisguisetype() == null || disguise.getDisguisetype().equals(DisguiseType.UNKNOWN)) {
        System.out.println("Could not find illusion: " + spellEffect.getBase());
        return;
    }
    if (DisguiseAPI.isDisguised(getLivingEntity())) {
        Disguise dis = DisguiseAPI.getDisguise(getLivingEntity());
        if (dis instanceof PlayerDisguise) {
            if (disguise.getDisguisedata() != null && !disguise.getDisguisedata().equals("")) {
                if (((PlayerDisguise) dis).getSkin().equals(disguise.getDisguisedata()))
                    return;
            // If we get here we can let the player change their skin as it doesnt match
            // their existing player skin name
            } else {
                return;
            }
        } else {
            if (dis.getType().equals(disguise.getDisguisetype()))
                return;
        }
    }
    if (disguise.getDisguisetype().equals(DisguiseType.PLAYER)) {
        String disguisename = disguise.getDisguisedata();
        if (disguisename == null || disguisename.equals(""))
            disguisename = "RomanPraetor";
        PlayerDisguise playerdisguise = new PlayerDisguise(getLivingEntity().getName(), disguisename);
        DisguiseAPI.disguiseEntity(getLivingEntity(), playerdisguise);
    } else {
        MobDisguise mob = new MobDisguise(disguise.getDisguisetype());
        DisguiseAPI.disguiseEntity(getLivingEntity(), mob);
    }
}
Also used : MobDisguise(me.libraryaddict.disguise.disguisetypes.MobDisguise) Disguise(me.libraryaddict.disguise.disguisetypes.Disguise) PlayerDisguise(me.libraryaddict.disguise.disguisetypes.PlayerDisguise) MobDisguise(me.libraryaddict.disguise.disguisetypes.MobDisguise) PlayerDisguise(me.libraryaddict.disguise.disguisetypes.PlayerDisguise)

Example 2 with PlayerDisguise

use of me.libraryaddict.disguise.disguisetypes.PlayerDisguise 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)2 MobDisguise (me.libraryaddict.disguise.disguisetypes.MobDisguise)2 PlayerDisguise (me.libraryaddict.disguise.disguisetypes.PlayerDisguise)2 DisguiseType (me.libraryaddict.disguise.disguisetypes.DisguiseType)1 MiscDisguise (me.libraryaddict.disguise.disguisetypes.MiscDisguise)1 Material (org.bukkit.Material)1