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;
}
Aggregations