use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class Utils method getTotalAAEffectMaxHp.
public static double getTotalAAEffectMaxHp(LivingEntity bukkitLivingEntity) {
if (!(bukkitLivingEntity instanceof Player))
return 0;
try {
ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) bukkitLivingEntity);
int total = 0;
int effectIdLookup = 0;
effectIdLookup = Utils.getEffectIdFromEffectType(SpellEffectType.MaxHPChange);
if (effectIdLookup > 0) {
for (SoliniaAARankEffect effect : player.getRanksEffectsOfEffectType(effectIdLookup)) {
total += effect.getBase1();
}
}
effectIdLookup = Utils.getEffectIdFromEffectType(SpellEffectType.TotalHP);
if (effectIdLookup > 0) {
for (SoliniaAARankEffect effect : player.getRanksEffectsOfEffectType(effectIdLookup)) {
total += effect.getBase1();
}
}
return total;
} catch (CoreStateInitException e) {
return 0;
}
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class Utils method getTotalAAEffectEffectType.
public static int getTotalAAEffectEffectType(LivingEntity bukkitLivingEntity, SpellEffectType effectType) {
if (!(bukkitLivingEntity instanceof Player))
return 0;
try {
ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) bukkitLivingEntity);
int total = 0;
for (SoliniaAARankEffect effect : player.getRanksEffectsOfEffectType(Utils.getEffectIdFromEffectType(effectType))) {
total += effect.getBase1();
}
return total;
} catch (CoreStateInitException e) {
return 0;
}
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class CommandCraft method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
ItemStack primaryItem = player.getInventory().getItemInMainHand();
if (primaryItem.getType().equals(Material.AIR)) {
player.sendMessage(ChatColor.GRAY + "Empty item in primary hand. You must hold the item you want to use in your crafting recipe");
return false;
}
ItemStack secondaryItem = player.getInventory().getItemInOffHand();
if (secondaryItem.getType().equals(Material.AIR)) {
player.sendMessage(ChatColor.GRAY + "Empty item in offhand. You must hold the item you want to use in your crafting recipe");
return false;
}
if (primaryItem.getAmount() > 1) {
player.sendMessage(ChatColor.GRAY + "Stack size in primary hand is too high (max 1)");
return false;
}
if (secondaryItem.getAmount() > 1) {
player.sendMessage(ChatColor.GRAY + "Stack size in secondary hand is too high (max 1)");
return false;
}
if (!Utils.IsSoliniaItem(primaryItem)) {
player.sendMessage("You can only create a new item from solinia items, not minecraft items");
return true;
}
if (!Utils.IsSoliniaItem(secondaryItem)) {
player.sendMessage("You can only create a new item from solinia items, not minecraft items");
return true;
}
try {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(player);
ISoliniaItem primarysolItem = SoliniaItemAdapter.Adapt(primaryItem);
ISoliniaItem secondarysolItem = SoliniaItemAdapter.Adapt(secondaryItem);
List<SoliniaCraft> craft = StateManager.getInstance().getConfigurationManager().getCrafts(primarysolItem.getId(), secondarysolItem.getId());
if (craft.size() < 1) {
player.sendMessage("You do not seem to know how to make anything with these items");
return true;
}
int createCount = 0;
for (SoliniaCraft craftEntry : craft) {
if (craftEntry.getClassId() > 0) {
if (solPlayer.getClassObj() == null) {
player.sendMessage("You do not seem to know how to make anything with these items");
continue;
}
if (solPlayer.getClassObj().getId() != craftEntry.getClassId()) {
player.sendMessage("You do not seem to know how to make anything with these items");
continue;
}
}
if (craftEntry.getSkilltype() != SkillType.None) {
if (craftEntry.getMinSkill() > 0) {
SoliniaPlayerSkill skill = solPlayer.getSkill(craftEntry.getSkilltype().name().toUpperCase());
if (skill == null) {
player.sendMessage("You do not seem to know how to make anything with these items");
continue;
}
if (skill.getValue() < craftEntry.getMinSkill()) {
player.sendMessage("You do not seem to know how to make anything with these items");
continue;
}
}
}
ISoliniaItem outputItem = StateManager.getInstance().getConfigurationManager().getItem(craftEntry.getOutputItem());
if (outputItem != null) {
player.getWorld().dropItemNaturally(player.getLocation(), outputItem.asItemStack());
player.sendMessage("You fashion the items together to make something new!");
createCount++;
if (craftEntry.getSkilltype() != SkillType.None) {
solPlayer.tryIncreaseSkill(craftEntry.getSkilltype().name().toUpperCase(), 1);
}
}
}
if (createCount > 0) {
player.getInventory().setItemInMainHand(null);
player.getInventory().setItemInOffHand(null);
player.updateInventory();
}
} catch (CoreStateInitException e) {
} catch (SoliniaItemException e) {
player.sendMessage("Item no longer exists");
}
return true;
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class Solinia3CoreEntityListener method onEntityTargetEvent.
// Needs to occur before anything else
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityTargetEvent(EntityTargetEvent event) {
if (event.isCancelled())
return;
if (!(event.getEntity() instanceof Creature))
return;
try {
Timestamp mzExpiry = StateManager.getInstance().getEntityManager().getMezzed((LivingEntity) event.getEntity());
if (mzExpiry != null) {
if (event.getEntity() instanceof Player) {
event.getEntity().sendMessage("* You are mezzed!");
}
Utils.CancelEvent(event);
;
return;
}
} catch (CoreStateInitException e) {
}
try {
// Me
ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) event.getEntity());
if (solEntity.isUndead() && !(event.getEntity() instanceof Player) && event.getTarget() instanceof LivingEntity) {
if (StateManager.getInstance().getEntityManager().hasEntityEffectType((LivingEntity) event.getTarget(), SpellEffectType.InvisVsUndead) || StateManager.getInstance().getEntityManager().hasEntityEffectType((LivingEntity) event.getTarget(), SpellEffectType.InvisVsUndead2)) {
((Creature) event.getEntity()).setTarget(null);
Utils.CancelEvent(event);
;
return;
}
}
if (!solEntity.isUndead() && !(event.getEntity() instanceof Player) && !solEntity.isAnimal() && event.getTarget() instanceof LivingEntity) {
if (StateManager.getInstance().getEntityManager().hasEntityEffectType((LivingEntity) event.getTarget(), SpellEffectType.Invisibility) || StateManager.getInstance().getEntityManager().hasEntityEffectType((LivingEntity) event.getTarget(), SpellEffectType.Invisibility2)) {
((Creature) event.getEntity()).setTarget(null);
Utils.CancelEvent(event);
;
return;
}
}
if (solEntity.isAnimal() && !(event.getEntity() instanceof Player) && event.getTarget() instanceof LivingEntity) {
if (StateManager.getInstance().getEntityManager().hasEntityEffectType((LivingEntity) event.getTarget(), SpellEffectType.InvisVsAnimals) || StateManager.getInstance().getEntityManager().hasEntityEffectType((LivingEntity) event.getTarget(), SpellEffectType.ImprovedInvisAnimals)) {
((Creature) event.getEntity()).setTarget(null);
Utils.CancelEvent(event);
;
return;
}
}
// rogue sneak
if (event.getTarget() instanceof Player && !(event.getEntity() instanceof Player)) {
Player targetPlayer = (Player) event.getTarget();
if (targetPlayer.isSneaking()) {
ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) event.getTarget());
if (player.getClassObj() != null) {
if (player.getClassObj().isSneakFromCrouch()) {
Utils.CancelEvent(event);
;
return;
}
}
}
}
if (event.getEntity() != null && event.getTarget() != null) {
if (!(event.getEntity() instanceof Player)) {
if (event.getEntity() instanceof LivingEntity) {
ISoliniaLivingEntity livingEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) event.getEntity());
}
// Mez cancel target
Timestamp mezExpiry = StateManager.getInstance().getEntityManager().getMezzed((LivingEntity) event.getTarget());
if (mezExpiry != null) {
((Creature) event.getEntity()).setTarget(null);
event.getEntity().sendMessage("The target is mezzed, you cannot hit it");
Utils.CancelEvent(event);
;
return;
}
}
}
} catch (CoreStateInitException e) {
return;
}
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class CommandWho method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
for (Player currentplayer : Bukkit.getServer().getOnlinePlayers()) {
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(currentplayer);
int lvl = (int) Math.floor(solplayer.getLevel());
String racename = "UNKNOWN";
String classname = "UNKNOWN";
if (solplayer.getRace() != null)
racename = solplayer.getRace().getName();
if (solplayer.getClassObj() != null)
classname = solplayer.getClassObj().getName();
player.sendMessage("[" + currentplayer.getName() + "]" + ChatColor.YELLOW + solplayer.getFullName().toUpperCase() + ChatColor.RESET + " [" + currentplayer.getWorld().getName() + "] - LVL " + ChatColor.AQUA + lvl + ChatColor.RESET + " " + racename + " " + ChatColor.AQUA + classname + ChatColor.RESET);
} catch (CoreStateInitException e) {
}
}
}
if ((sender instanceof ConsoleCommandSender || sender instanceof DiscordDefaultChannelCommandSender || sender instanceof DiscordAdminChannelCommandSender)) {
CommandSender player = (CommandSender) sender;
for (Player currentplayer : Bukkit.getServer().getOnlinePlayers()) {
ISoliniaPlayer solplayer;
try {
solplayer = SoliniaPlayerAdapter.Adapt(currentplayer);
int lvl = (int) Math.floor(solplayer.getLevel());
String racename = "UNKNOWN";
String classname = "UNKNOWN";
if (solplayer.getRace() != null)
racename = solplayer.getRace().getName();
if (solplayer.getClassObj() != null)
classname = solplayer.getClassObj().getName();
player.sendMessage("[" + currentplayer.getName() + "]" + ChatColor.YELLOW + solplayer.getFullName().toUpperCase() + ChatColor.RESET + " [" + currentplayer.getWorld().getName() + "] - LVL " + ChatColor.AQUA + lvl + ChatColor.RESET + " " + racename + " " + ChatColor.AQUA + classname + ChatColor.RESET);
} catch (CoreStateInitException e) {
}
}
}
return true;
}
Aggregations