use of me.libraryaddict.disguise.disguisetypes.MobDisguise in project solinia3-core by mixxit.
the class EntityManager method SpawnPet.
@Override
public LivingEntity SpawnPet(Plugin plugin, Player owner, ISoliniaSpell spell) {
try {
LivingEntity pet = StateManager.getInstance().getEntityManager().getPet(owner);
if (pet != null) {
StateManager.getInstance().getEntityManager().killPet(owner);
}
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getPetNPCByName(spell.getTeleportZone());
if (npc == null)
return null;
if (npc.isPet() == false)
return null;
Wolf entity = (Wolf) owner.getWorld().spawnEntity(owner.getLocation(), EntityType.WOLF);
entity.setMetadata("npcid", new FixedMetadataValue(plugin, "NPCID_" + npc.getId()));
StateManager.getInstance().getEntityManager().setPet(owner, entity);
entity.setAdult();
entity.setTamed(true);
entity.setOwner(owner);
entity.setBreed(false);
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(owner);
entity.setCustomName(solplayer.getForename() + "'s Pet");
entity.setCustomNameVisible(true);
entity.setCanPickupItems(false);
ISoliniaLivingEntity solentity = SoliniaLivingEntityAdapter.Adapt(entity);
solentity.configurePetGoals();
entity.setMaxHealth(solentity.getMaxHP());
entity.setHealth(solentity.getMaxHP());
net.minecraft.server.v1_12_R1.EntityInsentient entityhandle = (net.minecraft.server.v1_12_R1.EntityInsentient) ((org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) entity).getHandle();
entityhandle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue((double) solentity.getMaxDamage());
owner.sendMessage("New Pet spawned with HP: " + entity.getMaxHealth() + " and " + solentity.getMaxDamage() + " dmg");
MobDisguise mob = new MobDisguise(DisguiseType.WOLF);
switch(npc.getMctype().toUpperCase()) {
case "WOLF":
mob = new MobDisguise(DisguiseType.WOLF);
break;
case "SQUID":
mob = new MobDisguise(DisguiseType.SQUID);
break;
case "PARROT":
mob = new MobDisguise(DisguiseType.PARROT);
break;
case "SKELETON":
mob = new MobDisguise(DisguiseType.SKELETON);
break;
case "BLAZE":
mob = new MobDisguise(DisguiseType.BLAZE);
break;
case "IRON_GOLEM":
mob = new MobDisguise(DisguiseType.IRON_GOLEM);
break;
case "GUARDIAN":
mob = new MobDisguise(DisguiseType.GUARDIAN);
break;
default:
mob = new MobDisguise(DisguiseType.WOLF);
break;
}
DisguiseAPI.disguiseEntity(entity, mob);
solentity.configurePetGoals();
return entity;
} catch (CoreStateInitException e) {
return null;
}
}
use of me.libraryaddict.disguise.disguisetypes.MobDisguise 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);
}
}
use of me.libraryaddict.disguise.disguisetypes.MobDisguise 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