use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class CommandClaim method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
try {
if (args.length < 1) {
sender.sendMessage(ChatColor.GRAY + "Insufficient arguments (list,claim)");
return true;
}
switch(args[0]) {
case "list":
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
sender.sendMessage("Current Claims: " + solplayer.getAccountClaims().size());
for (SoliniaAccountClaim claim : solplayer.getAccountClaims()) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(claim.getItemid());
if (item == null)
continue;
TextComponent tc = new TextComponent();
tc.setText(ChatColor.LIGHT_PURPLE + item.getDisplayname() + " /claim claim " + claim.getId());
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ComponentBuilder(item.asJsonString()).create()));
sender.spigot().sendMessage(tc);
}
return true;
case "give":
if (!sender.isOp())
return false;
if (args.length < 3) {
sender.sendMessage("That is not a claim id - /claim give mcaccountname itemid");
return true;
}
String mcaccountname = args[1];
int itemId = Integer.parseInt(args[2].toUpperCase());
SoliniaAccountClaim newclaim = new SoliniaAccountClaim();
newclaim.setId(StateManager.getInstance().getConfigurationManager().getNextAccountClaimId());
newclaim.setMcname(mcaccountname);
newclaim.setItemid(itemId);
newclaim.setClaimed(false);
StateManager.getInstance().getConfigurationManager().addAccountClaim(newclaim);
sender.sendMessage("Account claim added!");
return true;
case "claim":
if (!(sender instanceof Player))
return false;
Player claimPlayer = (Player) sender;
ISoliniaPlayer solClaimPlayer = SoliniaPlayerAdapter.Adapt(claimPlayer);
sender.sendMessage("Current Claims: " + solClaimPlayer.getAccountClaims().size());
if (args.length < 2) {
sender.sendMessage("That is not a claim id - /claim claim claimid (see /claim list)");
return true;
}
int seekClaimId = Integer.parseInt(args[1].toUpperCase());
System.out.println("Looking up claims for player name: " + claimPlayer.getName() + " for claim ID: " + seekClaimId);
SoliniaAccountClaim claim = StateManager.getInstance().getConfigurationManager().getAccountClaim(claimPlayer.getName().toUpperCase(), seekClaimId);
if (claim == null) {
sender.sendMessage("That is not a valid claim - /claim claim claimid (see /claim list)");
return true;
}
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(claim.getItemid());
if (item == null) {
sender.sendMessage("That is not a valid claim item - /claim claim claimid (see /claim list)");
return true;
}
claimPlayer.getWorld().dropItemNaturally(claimPlayer.getLocation(), item.asItemStack());
sender.sendMessage("Claim item dropped at your feet - ID: " + claim.getId());
StateManager.getInstance().getConfigurationManager().removeClaim(claim.getId());
return true;
default:
sender.sendMessage(ChatColor.GRAY + "Invalid arguments (list,claim)");
return true;
}
} catch (CoreStateInitException e) {
}
return true;
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class SoliniaLivingEntity method Attack.
@Override
public boolean Attack(ISoliniaLivingEntity defender, EntityDamageEvent event, boolean arrowHit, Solinia3CorePlugin plugin) {
int baseDamage = (int) event.getDamage(DamageModifier.BASE);
try {
if (defender.isPlayer() && isPlayer()) {
ISoliniaPlayer defenderPlayer = SoliniaPlayerAdapter.Adapt((Player) defender.getBukkitLivingEntity());
ISoliniaPlayer attackerPlayer = SoliniaPlayerAdapter.Adapt((Player) this.getBukkitLivingEntity());
if (defenderPlayer.getGroup() != null && attackerPlayer.getGroup() != null) {
if (defenderPlayer.getGroup().getId().equals(attackerPlayer.getGroup().getId())) {
Utils.CancelEvent(event);
;
return false;
}
}
}
} catch (CoreStateInitException e) {
// ignore
}
if (isPlayer()) {
Player player = (Player) this.getBukkitLivingEntity();
if (player.isSneaking()) {
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
if (solplayer.getClassObj() != null) {
if (solplayer.getClassObj().isSneakFromCrouch()) {
player.sendMessage("You cannot concentrate on combat while meditating or sneaking");
Utils.CancelEvent(event);
;
return false;
}
}
} catch (CoreStateInitException e) {
// do nothing
}
}
}
if (usingValidWeapon() == false) {
Utils.CancelEvent(event);
;
return false;
} else {
if (Utils.IsSoliniaItem(getBukkitLivingEntity().getEquipment().getItemInMainHand())) {
try {
ISoliniaItem soliniaitem = StateManager.getInstance().getConfigurationManager().getItem(getBukkitLivingEntity().getEquipment().getItemInMainHand());
// TODO move this
if (soliniaitem.getBaneUndead() > 0 && defender.isUndead())
baseDamage += soliniaitem.getBaneUndead();
} catch (CoreStateInitException e) {
Utils.CancelEvent(event);
;
return false;
}
}
}
if (baseDamage < 1)
baseDamage = 1;
if (defender == null) {
Utils.CancelEvent(event);
;
return false;
}
if (defender.getBukkitLivingEntity().isDead() || this.getBukkitLivingEntity().isDead() || this.getBukkitLivingEntity().getHealth() < 0) {
Utils.CancelEvent(event);
;
return false;
}
if (isInulvnerable()) {
Utils.CancelEvent(event);
;
return false;
}
if (isFeigned()) {
Utils.CancelEvent(event);
;
return false;
}
ItemStack weapon = this.getBukkitLivingEntity().getEquipment().getItemInHand();
DamageHitInfo my_hit = new DamageHitInfo();
my_hit.skill = Utils.getSkillForMaterial(weapon.getType().toString()).getSkillname();
if (arrowHit) {
my_hit.skill = "ARCHERY";
}
// Now figure out damage
my_hit.damage_done = 1;
my_hit.min_damage = 0;
int mylevel = getLevel();
int hate = 0;
my_hit.base_damage = baseDamage;
// amount of hate is based on the damage done
if (hate == 0 && my_hit.base_damage > 1)
hate = my_hit.base_damage;
if (my_hit.base_damage > 0) {
my_hit.base_damage = getDamageCaps(my_hit.base_damage);
tryIncreaseSkill(my_hit.skill, 1);
tryIncreaseSkill("OFFENSE", 1);
int ucDamageBonus = 0;
if (getClassObj() != null && getClassObj().isWarriorClass() && getLevel() >= 28) {
ucDamageBonus = getWeaponDamageBonus(weapon);
my_hit.min_damage = ucDamageBonus;
hate += ucDamageBonus;
}
// TODO Sinister Strikes
int hit_chance_bonus = 0;
// we need this a few times
my_hit.offense = getOffense(my_hit.skill);
my_hit.tohit = getTotalToHit(my_hit.skill, hit_chance_bonus);
doAttack(plugin, defender, my_hit);
}
defender.addToHateList(getBukkitLivingEntity().getUniqueId(), hate);
if (getBukkitLivingEntity().isDead()) {
Utils.CancelEvent(event);
;
return false;
}
if (my_hit.damage_done > 0) {
triggerDefensiveProcs(defender, my_hit.damage_done, arrowHit);
try {
event.setDamage(DamageModifier.ABSORPTION, 0);
} catch (UnsupportedOperationException e) {
}
try {
event.setDamage(DamageModifier.ARMOR, 0);
} catch (UnsupportedOperationException e) {
}
try {
event.setDamage(DamageModifier.BASE, my_hit.damage_done);
} catch (UnsupportedOperationException e) {
}
try {
event.setDamage(DamageModifier.BLOCKING, 0);
} catch (UnsupportedOperationException e) {
}
try {
event.setDamage(DamageModifier.HARD_HAT, 0);
} catch (UnsupportedOperationException e) {
}
try {
event.setDamage(DamageModifier.MAGIC, 0);
} catch (UnsupportedOperationException e) {
}
try {
event.setDamage(DamageModifier.RESISTANCE, 0);
} catch (UnsupportedOperationException e) {
}
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
if (getBukkitLivingEntity() instanceof Player) {
String name = defender.getBukkitLivingEntity().getName();
if (defender.getBukkitLivingEntity().getCustomName() != null)
name = defender.getBukkitLivingEntity().getCustomName();
if (defender.isPlayer())
System.out.println("Detected player " + getBukkitLivingEntity().getName() + " vs player " + defender.getName());
((Player) getBukkitLivingEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("You hit " + name + " for " + df.format(event.getDamage()) + " " + df.format(defender.getBukkitLivingEntity().getHealth() - event.getDamage()) + "/" + df.format(defender.getBukkitLivingEntity().getMaxHealth()) + " " + my_hit.skill + " damage"));
if (defender.isNPC()) {
ISoliniaNPC npc;
try {
npc = StateManager.getInstance().getConfigurationManager().getNPC(defender.getNpcid());
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// Only players get this
if (getDoubleAttackCheck()) {
if (getBukkitLivingEntity() instanceof Player) {
((Player) getBukkitLivingEntity()).sendMessage(ChatColor.GRAY + "* You double attack!");
tryIncreaseSkill("DOUBLEATTACK", 1);
}
defender.damage(plugin, my_hit.damage_done, this.getBukkitLivingEntity());
}
try {
if (Utils.IsSoliniaItem(getBukkitLivingEntity().getEquipment().getItemInMainHand())) {
try {
ISoliniaItem soliniaitem = SoliniaItemAdapter.Adapt(getBukkitLivingEntity().getEquipment().getItemInMainHand());
if (soliniaitem != null) {
// Check if item has any proc effects
if (soliniaitem.getWeaponabilityid() > 0 && event.getCause().equals(DamageCause.ENTITY_ATTACK)) {
ISoliniaSpell procSpell = StateManager.getInstance().getConfigurationManager().getSpell(soliniaitem.getWeaponabilityid());
if (procSpell != null) {
// Chance to proc
int procChance = getProcChancePct();
int roll = Utils.RandomBetween(0, 100);
if (roll < procChance) {
// TODO - For now apply self and group to attacker, else attach to target
switch(Utils.getSpellTargetType(procSpell.getTargettype())) {
case Self:
procSpell.tryApplyOnEntity(plugin, this.getBukkitLivingEntity(), this.getBukkitLivingEntity());
break;
case Group:
procSpell.tryApplyOnEntity(plugin, this.getBukkitLivingEntity(), this.getBukkitLivingEntity());
break;
default:
procSpell.tryApplyOnEntity(plugin, this.getBukkitLivingEntity(), defender.getBukkitLivingEntity());
}
}
}
}
}
} catch (SoliniaItemException e) {
// skip
}
}
// Check if attacker has any WeaponProc effects
SoliniaEntitySpells effects = StateManager.getInstance().getEntityManager().getActiveEntitySpells(this.getBukkitLivingEntity());
if (effects != null) {
for (SoliniaActiveSpell activeSpell : effects.getActiveSpells()) {
ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(activeSpell.getSpellId());
if (spell == null)
continue;
if (!spell.isWeaponProc())
continue;
for (ActiveSpellEffect spelleffect : activeSpell.getActiveSpellEffects()) {
if (spelleffect.getSpellEffectType().equals(SpellEffectType.WeaponProc)) {
if (spelleffect.getBase() < 0)
continue;
ISoliniaSpell procSpell = StateManager.getInstance().getConfigurationManager().getSpell(spelleffect.getBase());
if (spell == null)
continue;
// Chance to proc
int procChance = getProcChancePct();
int roll = Utils.RandomBetween(0, 100);
if (roll < procChance) {
boolean itemUseSuccess = procSpell.tryApplyOnEntity(plugin, this.getBukkitLivingEntity(), defender.getBukkitLivingEntity());
if (procSpell.getActSpellCost(this) > 0)
if (itemUseSuccess) {
if (getBukkitLivingEntity() instanceof Player) {
SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity()).reducePlayerMana(procSpell.getActSpellCost(this));
}
}
}
}
}
}
}
} catch (CoreStateInitException e) {
}
}
if (defender.getBukkitLivingEntity() instanceof Player) {
((Player) defender.getBukkitLivingEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("You were hit by " + getBukkitLivingEntity().getCustomName() + " for " + df.format(event.getDamage()) + " " + my_hit.skill + " damage"));
}
if (event.getDamage() > getBukkitLivingEntity().getHealth() && hasDeathSave() > 0) {
Utils.CancelEvent(event);
removeDeathSaves(plugin);
getBukkitLivingEntity().sendMessage("* Your death save boon has saved you from death!");
return false;
}
defender.damageHook(event.getDamage(), getBukkitLivingEntity());
return true;
} else {
Utils.CancelEvent(event);
return false;
}
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getAgility.
@Override
public int getAgility() {
if (getNpcid() < 1 && !isPlayer())
return 1;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc == null)
return 1;
int stat = npc.getLevel() * 5;
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "AGILITY");
if (stat > getMaxStat("AGILITY"))
stat = getMaxStat("AGILITY");
return stat;
}
if (isPlayer()) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
if (solplayer == null)
return 1;
int stat = 1;
if (solplayer.getRace() != null)
stat += solplayer.getRace().getAgility();
stat += solplayer.getTotalItemStat("AGILITY");
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "AGILITY");
stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "AGILITY");
if (stat > getMaxStat("AGILITY"))
stat = getMaxStat("AGILITY");
return stat;
}
} catch (CoreStateInitException e) {
return 1;
}
return 1;
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getDexterity.
@Override
public int getDexterity() {
if (getNpcid() < 1 && !isPlayer())
return 1;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc == null)
return 1;
int stat = npc.getLevel() * 5;
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "DEXTERITY");
if (stat > getMaxStat("DEXTERITY"))
stat = getMaxStat("DEXTERITY");
return stat;
}
if (isPlayer()) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
if (solplayer == null)
return 1;
int stat = 1;
if (solplayer.getRace() != null)
stat += solplayer.getRace().getDexterity();
stat += solplayer.getTotalItemStat("DEXTERITY");
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "DEXTERITY");
stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "DEXTERITY");
if (stat > getMaxStat("DEXTERITY"))
stat = getMaxStat("DEXTERITY");
return stat;
}
} catch (CoreStateInitException e) {
return 1;
}
return 1;
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getDodgeCheck.
@Override
public boolean getDodgeCheck() {
if (getNpcid() < 1 && !isPlayer())
return false;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc == null)
return false;
boolean result = npc.getDodgeCheck();
return result;
}
if (isPlayer()) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
if (solplayer == null)
return false;
boolean result = solplayer.getDodgeCheck();
return solplayer.getDodgeCheck();
}
} catch (CoreStateInitException e) {
return false;
}
return false;
}
Aggregations