use of com.solinia.solinia.Models.SoliniaEntitySpells in project solinia3-core by mixxit.
the class CommandPet method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
// TODO Auto-generated method stub
if (sender instanceof Player) {
try {
Player player = (Player) sender;
LivingEntity pet = StateManager.getInstance().getEntityManager().getPet(player);
if (pet == null) {
player.sendMessage("You don't have a pet");
return true;
}
if (args.length > 0) {
String petcommand = args[0];
if (petcommand.equals("back")) {
Wolf c = (Wolf) pet;
player.setLastDamageCause(null);
player.sendMessage("* As you wish my master");
c.setTarget(null);
}
}
player.sendMessage("Pet Name: " + pet.getName());
player.sendMessage("Pet HP: " + pet.getHealth() + "/" + pet.getMaxHealth());
ISoliniaLivingEntity petLivingEntity = SoliniaLivingEntityAdapter.Adapt(pet);
EntityInsentient entityhandle = (EntityInsentient) ((org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) pet).getHandle();
double dmg = entityhandle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).getValue();
player.sendMessage("Pet DMG: " + dmg);
player.sendMessage("STR: " + petLivingEntity.getStrength() + " STA: " + petLivingEntity.getStamina() + " AGI: " + petLivingEntity.getAgility() + " DEX: " + petLivingEntity.getDexterity() + " INT: " + petLivingEntity.getIntelligence() + " WIS: " + petLivingEntity.getWisdom() + " CHA: " + petLivingEntity.getCharisma());
player.sendMessage("Pet Armour Class Mitigation : " + petLivingEntity.getMitigationAC());
player.sendMessage("Pet Attack Value: " + petLivingEntity.getAttk());
player.sendMessage("Pet Total Rune of: " + petLivingEntity.getRune());
player.sendMessage("Active Effects:");
SoliniaEntitySpells spells = StateManager.getInstance().getEntityManager().getActiveEntitySpells(pet);
for (SoliniaActiveSpell activeSpell : spells.getActiveSpells()) {
ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(activeSpell.getSpellId());
String removetext = "";
ChatColor spellcolor = ChatColor.GREEN;
if (spell.isBeneficial()) {
removetext = "Removable spell";
} else {
removetext = "Unremovable spell";
spellcolor = ChatColor.RED;
}
TextComponent tc = new TextComponent();
tc.setText("- " + spellcolor + spell.getName() + ChatColor.RESET + " " + activeSpell.getTicksLeft() + " ticks left - ");
TextComponent tc2 = new TextComponent();
tc2.setText(removetext);
tc.addExtra(tc2);
sender.spigot().sendMessage(tc);
}
return true;
} catch (CoreStateInitException e) {
}
}
return true;
}
use of com.solinia.solinia.Models.SoliniaEntitySpells in project solinia3-core by mixxit.
the class CommandEffects method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
try {
SoliniaEntitySpells spells = StateManager.getInstance().getEntityManager().getActiveEntitySpells(player);
if (spells == null)
return true;
if (args.length == 0) {
player.sendMessage(ChatColor.GOLD + "Active Spell Effects on you:" + ChatColor.WHITE);
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
if (solplayer.getExperienceBonusExpires() != null) {
System.out.println("Experience Bonus was not null: " + solplayer.getExperienceBonusExpires().toString());
LocalDateTime datetime = LocalDateTime.now();
Timestamp nowtimestamp = Timestamp.valueOf(datetime);
Timestamp expiretimestamp = solplayer.getExperienceBonusExpires();
if (expiretimestamp != null) {
System.out.println("Experience Bonus expire timestamp " + solplayer.getExperienceBonusExpires() + " vs Now: " + nowtimestamp.toString());
if (!nowtimestamp.after(expiretimestamp)) {
System.out.println("Experience bonus was after, displaying in effects");
int secondsleft = (int) Math.floor(Utils.compareTwoTimeStamps(expiretimestamp, nowtimestamp));
TextComponent tc = new TextComponent();
tc.setText("- " + ChatColor.GREEN + "100% Experience Potion" + ChatColor.RESET + " " + secondsleft + " seconds");
sender.spigot().sendMessage(tc);
}
}
} else {
System.out.println("Experience Bonus was null");
}
for (SoliniaActiveSpell activeSpell : spells.getActiveSpells()) {
ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(activeSpell.getSpellId());
String removetext = "";
ChatColor spellcolor = ChatColor.GREEN;
if (spell.isBeneficial()) {
removetext = "/effects remove " + spell.getId();
} else {
removetext = "Unremovable spell";
spellcolor = ChatColor.RED;
}
TextComponent tc = new TextComponent();
tc.setText("- " + spellcolor + spell.getName() + ChatColor.RESET + " " + activeSpell.getTicksLeft() + " ticks left - ");
TextComponent tc2 = new TextComponent();
tc2.setText(removetext);
if (spell.isBeneficial()) {
tc2.setText(ChatColor.GRAY + "Click here to remove" + ChatColor.RESET);
tc2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, removetext));
}
tc.addExtra(tc2);
sender.spigot().sendMessage(tc);
}
} else {
if (args.length < 2)
return true;
int spellid = Integer.parseInt(args[1]);
ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(spellid);
if (spell == null) {
player.sendMessage("That spell does not exist");
return true;
}
StateManager.getInstance().getEntityManager().removeSpellEffectsOfSpellId(plugin, player.getUniqueId(), spell.getId());
if (!spell.isBeneficial()) {
player.sendMessage("Can only remove beneficial spells");
return true;
}
player.sendMessage("Spell Effect removed");
}
} catch (CoreStateInitException e) {
player.sendMessage(e.getMessage());
}
}
return true;
}
use of com.solinia.solinia.Models.SoliniaEntitySpells in project solinia3-core by mixxit.
the class Utils method getActiveSpellEffectsRemainingValue.
public static int getActiveSpellEffectsRemainingValue(LivingEntity livingEntity, SpellEffectType effectType) {
int totalRemaining = 0;
SoliniaEntitySpells effects;
try {
effects = StateManager.getInstance().getEntityManager().getActiveEntitySpells(livingEntity);
for (SoliniaActiveSpell activeSpell : effects.getActiveSpells()) {
for (ActiveSpellEffect effect : activeSpell.getActiveSpellEffects()) {
if (!(effect.getSpellEffectType().equals(effectType)))
continue;
totalRemaining += effect.getRemainingValue();
}
}
} catch (CoreStateInitException e) {
// skip
}
return totalRemaining;
}
use of com.solinia.solinia.Models.SoliniaEntitySpells in project solinia3-core by mixxit.
the class Utils method getActiveSpellEffects.
public static List<ActiveSpellEffect> getActiveSpellEffects(LivingEntity livingEntity, SpellEffectType effectType) {
List<ActiveSpellEffect> returnEffects = new ArrayList<ActiveSpellEffect>();
SoliniaEntitySpells effects;
try {
effects = StateManager.getInstance().getEntityManager().getActiveEntitySpells(livingEntity);
for (SoliniaActiveSpell activeSpell : effects.getActiveSpells()) {
for (ActiveSpellEffect effect : activeSpell.getActiveSpellEffects()) {
if (!(effect.getSpellEffectType().equals(effectType)))
continue;
returnEffects.add(effect);
}
}
} catch (CoreStateInitException e) {
// skip
}
return returnEffects;
}
Aggregations