use of net.minecraft.server.v1_15_R1.Entity in project solinia3-core by mixxit.
the class EntityUtils method teleportSafely.
public static void teleportSafely(Entity targetEntity, Location targetLoc) {
if (targetEntity == null)
return;
if (targetLoc == null)
return;
final UUID entityUuid = targetEntity.getUniqueId();
final Location loc = targetLoc.clone();
Bukkit.getScheduler().runTask(StateManager.getInstance().getPlugin(), new Runnable() {
@Override
public void run() {
if (StateManager.getInstance().isStopping())
return;
Entity entity = Bukkit.getEntity(entityUuid);
if (entity == null)
return;
// if over 3 chunks, remove any pets
if (entity.getLocation().distance(loc) > 48) {
if (EntityUtils.HasPet(entityUuid)) {
EntityUtils.KillAllPets(entityUuid);
entity.sendMessage(ChatColor.GRAY + "* Your pets have been removed due to teleportation" + ChatColor.RESET);
}
}
if (entity instanceof Player) {
Essentials ess = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
if (ess != null) {
User user = ess.getUser((Player) entity);
if (user == null)
entity.teleport(loc);
else
try {
user.getTeleport().now(loc, false, TeleportCause.PLUGIN);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
entity.teleport(loc);
}
} else {
entity.teleport(loc);
}
} else {
entity.teleport(loc);
}
}
});
}
use of net.minecraft.server.v1_15_R1.Entity in project solinia3-core by mixxit.
the class SpecialEffectUtils method playLightningStrike.
public static void playLightningStrike(Entity entity) {
try {
Location loc = entity.getLocation();
net.minecraft.server.v1_15_R1.WorldServer world = ((CraftWorld) loc.getWorld()).getHandle();
EntityLightning lightning = new EntityLightning(world, loc.getX(), loc.getY(), loc.getZ(), true, true);
world.strikeLightning(lightning);
new CraftLightningStrike(world.getServer(), lightning);
return;
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.minecraft.server.v1_15_R1.Entity 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.getUniqueId());
if (pet == null) {
player.sendMessage("You don't have a pet");
return true;
}
if (pet instanceof Sittable) {
Sittable sittable = (Sittable) pet;
if (sittable.isSitting()) {
player.sendMessage("You cannot control a pet which is sitting");
return true;
}
}
ISoliniaLivingEntity petLivingEntity = SoliniaLivingEntityAdapter.Adapt(pet);
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(player);
if (petLivingEntity == null || solPlayer == null)
return false;
if (args.length > 0) {
String petcommand = args[0];
if (petcommand.equals("leave")) {
if (petLivingEntity != null) {
petLivingEntity.clearHateList();
if (petLivingEntity.IsCorePet()) {
solPlayer.killAllPets();
} else {
StateManager.getInstance().getEntityManager().removePet(player.getUniqueId(), !petLivingEntity.isCharmed());
petLivingEntity.clearHateList();
}
player.setLastDamageCause(null);
}
}
if (petcommand.equals("back")) {
if (petLivingEntity != null) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(petLivingEntity.getNpcid());
if (npc != null)
if (npc.isPetControllable() == false) {
player.sendMessage("This pet is not controllable");
return true;
}
player.setLastDamageCause(null);
petLivingEntity.clearHateList();
ChatUtils.SendHint(player, HINT.PET_BACKINGOFFTGT, "", false);
EntityUtils.teleportSafely(pet, player.getLocation());
}
}
if (petcommand.equals("attack")) {
if (solPlayer.getEntityTarget() == null) {
ChatUtils.SendHint(player, HINT.NEED_TARGET, "", false);
}
LivingEntity targetentity = solPlayer.getEntityTarget();
if (targetentity != null && !targetentity.getUniqueId().equals(player.getUniqueId())) {
if (petLivingEntity != null) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(petLivingEntity.getNpcid());
if (npc != null)
if (npc.isPetControllable() == false) {
player.sendMessage("This pet is not controllable");
return true;
}
}
EntityUtils.teleportSafely(pet, player.getLocation());
petLivingEntity.setAttackTarget(null);
// Mez cancel target
Timestamp mezExpiry = StateManager.getInstance().getEntityManager().getMezzed(targetentity);
if (mezExpiry != null) {
petLivingEntity.setAttackTarget(null);
player.sendMessage("You cannot send your pet to attack a mezzed target");
return false;
}
if (pet.getUniqueId().equals(targetentity.getUniqueId())) {
petLivingEntity.setAttackTarget(null);
player.sendMessage("You cannot send your pet to attack itself");
return false;
}
if (petLivingEntity.getOwnerEntity().getUniqueId().equals(targetentity.getUniqueId())) {
petLivingEntity.setAttackTarget(null);
player.sendMessage("You cannot send your pet to attack you!");
return false;
}
ISoliniaPlayer tmpPlayer = SoliniaPlayerAdapter.Adapt(player);
if (tmpPlayer != null && tmpPlayer.isInGroup(targetentity)) {
petLivingEntity.setAttackTarget(null);
player.sendMessage("You cannot send your pet to attack your group!");
return false;
}
if (!pet.getUniqueId().equals(targetentity.getUniqueId())) {
petLivingEntity.setAttackTarget(targetentity);
player.sendMessage("You send your pet to attack!");
return true;
}
ChatUtils.SendHint(player, HINT.PET_ATTACKINGTGT, targetentity.getCustomName(), false);
}
return true;
}
if (petcommand.equals("equip")) {
if (petLivingEntity != null) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(petLivingEntity.getNpcid());
if (npc != null)
if (npc.isPetControllable() == false) {
player.sendMessage("This pet is not controllable/equippable");
return true;
}
}
PetEquip(player, pet);
}
if (petcommand.equals("hatelist")) {
player.sendMessage("Hate List: ");
if (petLivingEntity != null) {
petLivingEntity.sendHateList(player);
}
}
}
player.sendMessage("Pet Name: " + pet.getName() + " Pet Level: " + petLivingEntity.getMentorLevel());
player.sendMessage("Pet HP: " + pet.getHealth() + "/" + pet.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
EntityInsentient entityhandle = (EntityInsentient) ((org.bukkit.craftbukkit.v1_15_R1.entity.CraftLivingEntity) pet).getHandle();
double dmg = entityhandle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).getValue();
player.sendMessage("Pet DMG: " + dmg + " (Hand to Hand)");
Entity target = ((Creature) pet).getTarget();
if (target == null) {
player.sendMessage("Pet Target: None");
} else {
player.sendMessage("Pet Target: " + target.getCustomName() + "/" + target.getName());
}
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 (AC): " + petLivingEntity.getMitigationAC());
player.sendMessage("Pet Attack Value: " + petLivingEntity.getTotalAtk());
player.sendMessage("Pet Attack Speed: " + ChatColor.GOLD + petLivingEntity.getHaste() + "%" + ChatColor.RESET);
player.sendMessage("Pet MainWeapon Attack Rate (Seconds): " + ChatColor.GOLD + petLivingEntity.getAutoAttackTimerFrequencySeconds() + ChatColor.RESET);
player.sendMessage("Pet Total Rune of: " + petLivingEntity.getRune());
player.sendMessage("Skills:");
if (petLivingEntity.getClassObj() != null) {
if (petLivingEntity.getClassObj().getDodgelevel() > 0)
if (petLivingEntity.getMentorLevel() >= petLivingEntity.getClassObj().getDodgelevel())
player.sendMessage(ChatColor.GRAY + "Dodge Skill: " + petLivingEntity.getSkill(SkillType.Dodge));
if (petLivingEntity.getClassObj().getRipostelevel() > 0)
if (petLivingEntity.getMentorLevel() >= petLivingEntity.getClassObj().getRipostelevel())
player.sendMessage(ChatColor.GRAY + "Riposte Skill: " + petLivingEntity.getSkill(SkillType.Riposte));
if (petLivingEntity.getClassObj().getDoubleattacklevel() > 0)
if (petLivingEntity.getMentorLevel() >= petLivingEntity.getClassObj().getDoubleattacklevel())
player.sendMessage(ChatColor.GRAY + "Double Attack Skill: " + petLivingEntity.getSkill(SkillType.DoubleAttack));
if (petLivingEntity.getClassObj().getSafefalllevel() > 0)
if (petLivingEntity.getMentorLevel() >= petLivingEntity.getClassObj().getSafefalllevel())
player.sendMessage(ChatColor.GRAY + "Safefall Skill: " + petLivingEntity.getSkill(SkillType.SafeFall));
if (petLivingEntity.getClassObj().getDualwieldlevel() > 0)
if (petLivingEntity.getMentorLevel() >= petLivingEntity.getClassObj().getDualwieldlevel())
player.sendMessage(ChatColor.GRAY + "Dual Wield: " + petLivingEntity.getSkill(SkillType.DualWield));
}
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);
}
player.sendMessage("Pet subcommands: /pet back | /pet equip | /pet attack | /pet leave");
return true;
} catch (CoreStateInitException e) {
}
}
return true;
}
use of net.minecraft.server.v1_15_R1.Entity in project solinia3-core by mixxit.
the class SoliniaSpell method isValidEffectForEntity.
public static Tuple<Boolean, String> isValidEffectForEntity(LivingEntity target, LivingEntity source, ISoliniaSpell soliniaSpell) throws CoreStateInitException {
try {
if (source == null) {
System.out.println("Source was null for isValidEffectForEntity: " + soliniaSpell.getName() + " on target: " + target.getCustomName());
return new Tuple<Boolean, String>(false, "Source was null for spell");
}
if (target == null) {
System.out.println("Target was null for isValidEffectForEntity: " + soliniaSpell.getName() + " from source: " + source.getCustomName());
return new Tuple<Boolean, String>(false, "Target was null for spell");
}
if (source.isDead() || target.isDead())
return new Tuple<Boolean, String>(false, "Source or target is dead");
ISoliniaLivingEntity solTarget = SoliniaLivingEntityAdapter.Adapt(target);
if (solTarget != null) {
switch(SpellUtils.getSpellTargetType(soliniaSpell.getTargettype())) {
case SummonedAE:
if (!solTarget.isUndead()) {
return new Tuple<Boolean, String>(false, "Only affects undead");
}
break;
case UndeadAE:
if (!solTarget.isUndead()) {
return new Tuple<Boolean, String>(false, "Only affects undead");
}
break;
case Undead:
if (!solTarget.isUndead()) {
source.sendMessage("This spell is only effective on Undead");
return new Tuple<Boolean, String>(false, "Only affects undead");
}
break;
case Summoned:
if (!solTarget.isCurrentlyNPCPet() && !solTarget.isCharmed()) {
source.sendMessage("This spell is only effective on Summoned");
return new Tuple<Boolean, String>(false, "Only affects summoned");
}
break;
case Animal:
if (!solTarget.isAnimal()) {
source.sendMessage("This spell is only effective on Animals");
return new Tuple<Boolean, String>(false, "Only affects animals");
}
break;
case Plant:
if (!solTarget.isPlant()) {
source.sendMessage("This spell is only effective on Plants");
return new Tuple<Boolean, String>(false, "Only affects plants");
}
break;
default:
break;
}
}
ISoliniaLivingEntity solSource = SoliniaLivingEntityAdapter.Adapt(source);
if (solTarget.isNPC()) {
if (source instanceof Player || solSource.isCurrentlyNPCPet()) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(solTarget.getNpcid());
if (npc != null) {
if (npc.isBoss() || npc.isRaidboss())
if (!soliniaSpell.isBossApplyable()) {
source.sendMessage(ChatColor.RED + "This NPC is immune to runspeed, gravity and mezmersization changes");
return new Tuple<Boolean, String>(false, "Immune to runspeed/gravity/mez");
}
if (npc.isRaidheroic())
if (!soliniaSpell.isRaidApplyable()) {
source.sendMessage(ChatColor.RED + "This NPC is immune to runspeed, gravity and mezmersization changes");
return new Tuple<Boolean, String>(false, "Immune to runspeed/gravity/mez");
}
}
}
}
if (!solSource.isNPC() && solTarget.isImmuneToSpell(soliniaSpell)) {
source.sendMessage(ChatColor.RED + "Your target cannot be affected (with this spell) [Spell has maxlevel or effect already]");
return new Tuple<Boolean, String>(false, "Target is (currently) immune to spell - Spell maxlevel limit,haseffect etc..");
}
// Always allow self only spells if the target and source is the self
if (source.getUniqueId().equals(target.getUniqueId()) && SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.Self)) {
// just be sure to check the item its giving if its an item spell
for (SpellEffect effect : soliniaSpell.getBaseSpellEffects()) {
if (effect.getSpellEffectType().equals(SpellEffectType.SummonHorse)) {
if (source instanceof Player) {
if (source.getUniqueId().equals(target.getUniqueId())) {
if (StateManager.getInstance().getPlayerManager().getPlayerLastChangeChar(source.getUniqueId()) != null) {
source.sendMessage("You can only summon a mount once per server session. Please wait for the next 4 hourly restart");
return new Tuple<Boolean, String>(false, "Cannot summon mount this soon");
}
} else {
return new Tuple<Boolean, String>(false, "Source was not target");
}
} else {
return new Tuple<Boolean, String>(false, "Source wasnt player");
}
}
if (effect.getSpellEffectType().equals(SpellEffectType.SummonItem)) {
int itemId = effect.getBase();
try {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemId);
if (item == null) {
return new Tuple<Boolean, String>(false, "Item was null");
}
if (!item.isTemporary() && !soliniaSpell.isIgnoreSummonItemTemporaryCheck()) {
return new Tuple<Boolean, String>(false, "Item wasnt temporary");
}
if (!(target instanceof LivingEntity)) {
return new Tuple<Boolean, String>(false, "Targert wasnt living");
}
} catch (CoreStateInitException e) {
return new Tuple<Boolean, String>(false, "Plugin wasnt initialised");
}
}
}
// "), returning as valid, always");
return new Tuple<Boolean, String>(true, "Self only spell");
}
if (!source.getUniqueId().equals(target.getUniqueId()))
if (!solSource.isPlayer()) {
if (!solSource.checkLosFN(solTarget, true))
return new Tuple<Boolean, String>(false, "Target not in line of sight of source");
} else {
// we dont care about directional for players
if (!solSource.checkLosFN(solTarget, false))
return new Tuple<Boolean, String>(false, "Target not in line of sight of source");
}
// Try not to kill potentially friendly player tameables with hostile spells
if (solTarget.isCurrentlyNPCPet() && target instanceof Creature && !soliniaSpell.isBeneficial()) {
if (soliniaSpell.isCharmSpell() && source.getUniqueId().equals(solTarget.getOwnerEntity().getUniqueId())) {
// Our owner wants to renew his charm
return new Tuple<Boolean, String>(true, "Charm spell and source is target");
} else {
Creature cr = (Creature) target;
if (cr.getTarget() == null)
return new Tuple<Boolean, String>(false, "Target is null");
if (!cr.getTarget().getUniqueId().equals(source.getUniqueId()))
return new Tuple<Boolean, String>(false, "Target is not the source");
}
}
for (SpellEffect effect : soliniaSpell.getBaseSpellEffects()) {
// and the spell is a detrimental
if (source instanceof Player && target instanceof Player && soliniaSpell.isDetrimental()) {
ISoliniaPlayer solsourceplayer = SoliniaPlayerAdapter.Adapt((Player) source);
if (solsourceplayer.getGroup() != null) {
if (solsourceplayer.getGroup().getUnmodifiableGroupMembersForBuffs(true, false).contains(target.getUniqueId())) {
return new Tuple<Boolean, String>(false, "Detrimental against group member");
}
}
}
// Return false if the target is in the same faction as the npc and not self
if (!(source instanceof Player) && !(target instanceof Player) && soliniaSpell.isDetrimental() && !source.getUniqueId().equals(target.getUniqueId())) {
if (source instanceof LivingEntity && target instanceof LivingEntity) {
ISoliniaLivingEntity solsourceEntity = SoliniaLivingEntityAdapter.Adapt(source);
ISoliniaLivingEntity soltargetEntity = SoliniaLivingEntityAdapter.Adapt(target);
if (solsourceEntity.isNPC() && soltargetEntity.isNPC()) {
ISoliniaNPC sourceNpc = StateManager.getInstance().getConfigurationManager().getNPC(solsourceEntity.getNpcid());
ISoliniaNPC targetNpc = StateManager.getInstance().getConfigurationManager().getNPC(soltargetEntity.getNpcid());
if (sourceNpc.getFactionid() > 0 && targetNpc.getFactionid() > 0) {
if (sourceNpc.getFactionid() == targetNpc.getFactionid())
return new Tuple<Boolean, String>(false, "Faction is same");
}
}
}
}
if (effect.getSpellEffectType().equals(SpellEffectType.Revive)) {
if (!(target instanceof Player)) {
return new Tuple<Boolean, String>(false, "Target is not player");
}
if (!(source instanceof Player))
return new Tuple<Boolean, String>(false, "Source is not player");
Player sourcePlayer = (Player) source;
if (!sourcePlayer.getInventory().getItemInOffHand().getType().equals(Material.NAME_TAG)) {
sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (MC): " + sourcePlayer.getInventory().getItemInOffHand().getType().name());
return new Tuple<Boolean, String>(false, "Not holding item in offhand");
}
ItemStack item = sourcePlayer.getInventory().getItemInOffHand();
if (item.getEnchantmentLevel(Enchantment.DURABILITY) != 1) {
sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (EC)");
return new Tuple<Boolean, String>(false, "Not holding item in offhand");
}
if (!item.getItemMeta().getDisplayName().equals("Signaculum")) {
sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (NC)");
return new Tuple<Boolean, String>(false, "Not holding item in offhand");
}
if (item.getItemMeta().getLore().size() < 5) {
sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (LC)");
return new Tuple<Boolean, String>(false, "Not holding item in offhand");
}
String sigdataholder = item.getItemMeta().getLore().get(3);
String[] sigdata = sigdataholder.split("\\|");
if (sigdata.length != 2) {
sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (SD)");
return new Tuple<Boolean, String>(false, "Not holding item in offhand");
}
String str_experience = sigdata[0];
String str_stimetsamp = sigdata[1];
int experience = Integer.parseInt(str_experience);
Timestamp timestamp = Timestamp.valueOf(str_stimetsamp);
LocalDateTime datetime = LocalDateTime.now();
Timestamp currenttimestamp = Timestamp.valueOf(datetime);
long maxminutes = 60 * 7;
if ((currenttimestamp.getTime() - timestamp.getTime()) >= maxminutes * 60 * 1000) {
sourcePlayer.sendMessage("This Signaculum has lost its binding to the soul");
return new Tuple<Boolean, String>(false, "Expired signaculum");
}
String characterId = item.getItemMeta().getLore().get(4);
try {
ISoliniaPlayer soliniaPlayer = StateManager.getInstance().getConfigurationManager().getCharacterById(Integer.parseInt(characterId));
if (soliniaPlayer == null) {
sourcePlayer.sendMessage("You cannot resurrect that player as this character no longer exists");
return new Tuple<Boolean, String>(false, "Character no longer exists");
}
Player targetplayer = Bukkit.getPlayer(soliniaPlayer.getOwnerUUID());
if (targetplayer == null || !targetplayer.isOnline()) {
sourcePlayer.sendMessage("You cannot resurrect that player as they are offline");
return new Tuple<Boolean, String>(false, "Offline player");
}
} catch (NumberFormatException e) {
sourcePlayer.sendMessage("This signaculum has been corrupted by the void");
return new Tuple<Boolean, String>(false, "Character identifier is corrupted");
}
}
// Validate spelleffecttype rules
if (effect.getSpellEffectType().equals(SpellEffectType.CurrentHP) || effect.getSpellEffectType().equals(SpellEffectType.CurrentHPOnce)) {
// Ignore this rule if the spell is self
if (!SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.Self) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AECaster) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AEClientV1)) {
// If the effect is negative standard nuke and on self, cancel out
if (effect.getBase() < 0 && target.equals(source))
return new Tuple<Boolean, String>(false, "Target was self");
}
// cancel
if (source instanceof Player) {
if (!(target instanceof Player)) {
ISoliniaLivingEntity soltargetentity = SoliniaLivingEntityAdapter.Adapt(target);
if (!soltargetentity.isCurrentlyNPCPet()) {
if (effect.getBase() > 0)
return new Tuple<Boolean, String>(false, "Target wasnt a pet npc");
}
}
}
}
if (effect.getSpellEffectType().equals(SpellEffectType.Illusion) || effect.getSpellEffectType().equals(SpellEffectType.IllusionaryTarget) || effect.getSpellEffectType().equals(SpellEffectType.IllusionCopy) || effect.getSpellEffectType().equals(SpellEffectType.IllusionOther) || effect.getSpellEffectType().equals(SpellEffectType.IllusionPersistence)) {
// if target has spell effect of above already then we cant apply another
for (SoliniaActiveSpell activeSpell : StateManager.getInstance().getEntityManager().getActiveEntitySpells(target).getActiveSpells()) {
if (activeSpell.getSpell().getSpellEffectTypes().contains(SpellEffectType.Illusion))
return new Tuple<Boolean, String>(false, "Contained illusion");
if (activeSpell.getSpell().getSpellEffectTypes().contains(SpellEffectType.IllusionaryTarget))
return new Tuple<Boolean, String>(false, "Contained illusion target");
if (activeSpell.getSpell().getSpellEffectTypes().contains(SpellEffectType.IllusionCopy))
return new Tuple<Boolean, String>(false, "Contained illusion copy");
if (activeSpell.getSpell().getSpellEffectTypes().contains(SpellEffectType.IllusionOther))
return new Tuple<Boolean, String>(false, "Contained illusion other");
if (activeSpell.getSpell().getSpellEffectTypes().contains(SpellEffectType.IllusionPersistence))
return new Tuple<Boolean, String>(false, "Contained illusion persistence");
}
}
if (effect.getSpellEffectType().equals(SpellEffectType.SummonItem)) {
System.out.println("Validating SummonItem for source: " + source.getCustomName());
int itemId = effect.getBase();
try {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemId);
System.out.println("Validating SummonItem for source: " + source.getCustomName());
if (item == null) {
System.out.println("Validating SummonItem said item was null");
return new Tuple<Boolean, String>(false, "Item didnt exist");
}
if (!item.isTemporary()) {
System.out.println("Validating SummonItem said item was not temporary");
return new Tuple<Boolean, String>(false, "Item was not temporary");
}
if (!(target instanceof LivingEntity)) {
System.out.println("Validating SummonItem said target was not a living entity");
return new Tuple<Boolean, String>(false, "Target not living");
}
} catch (CoreStateInitException e) {
return new Tuple<Boolean, String>(false, "Plugin not initialised");
}
}
if (!SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.Self) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AECaster) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AEClientV1))
if (effect.getSpellEffectType().equals(SpellEffectType.ResistAll) || effect.getSpellEffectType().equals(SpellEffectType.ResistCold) || effect.getSpellEffectType().equals(SpellEffectType.ResistFire) || effect.getSpellEffectType().equals(SpellEffectType.ResistMagic) || effect.getSpellEffectType().equals(SpellEffectType.ResistPoison) || effect.getSpellEffectType().equals(SpellEffectType.ResistDisease) || effect.getSpellEffectType().equals(SpellEffectType.ResistCorruption)) {
// If the effect is negative standard resist debuffer and on self, cancel out
if (effect.getBase() < 0 && target.equals(source))
return new Tuple<Boolean, String>(false, "Target of spell is source");
}
if (!SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.Self) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AECaster) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AEClientV1))
if (effect.getSpellEffectType().equals(SpellEffectType.Mez)) {
// If the effect is a mez, cancel out
if (target.equals(source))
return new Tuple<Boolean, String>(false, "Target of spell is source");
}
if (effect.getSpellEffectType().equals(SpellEffectType.Charm)) {
if (target instanceof Player)
return new Tuple<Boolean, String>(false, "Target of spell is player");
}
if (!SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.Self) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AECaster) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AEClientV1))
if (effect.getSpellEffectType().equals(SpellEffectType.Charm)) {
// If the effect is a charm, cancel out
if (target.equals(source))
return new Tuple<Boolean, String>(false, "Target of spell is source");
}
if (!SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.Self) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AECaster) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AEClientV1))
if (effect.getSpellEffectType().equals(SpellEffectType.Stun)) {
// If the effect is a stun, cancel out
if (target.equals(source))
return new Tuple<Boolean, String>(false, "Target of spell is source");
}
if (!SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.Self) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AECaster) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AEClientV1))
if (effect.getSpellEffectType().equals(SpellEffectType.Root)) {
// If the effect is a root, cancel out
if (target.equals(source))
return new Tuple<Boolean, String>(false, "Target of spell is source");
}
if (!SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.Self) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AECaster) && !SpellUtils.getSpellTargetType(soliniaSpell.getTargettype()).equals(SpellTargetType.AEClientV1))
if (effect.getSpellEffectType().equals(SpellEffectType.Blind)) {
// If the effect is a blindness, cancel out
if (target.equals(source))
return new Tuple<Boolean, String>(false, "Target of spell is source");
}
if (effect.getSpellEffectType().equals(SpellEffectType.DamageShield) && !(target instanceof Player) && !SoliniaLivingEntityAdapter.Adapt(target).isCurrentlyNPCPet()) {
// If the effect is a mez, cancel out
if (target.equals(source))
return new Tuple<Boolean, String>(false, "Target of spell is source");
}
if (effect.getSpellEffectType().equals(SpellEffectType.NecPet) || effect.getSpellEffectType().equals(SpellEffectType.SummonPet) || effect.getSpellEffectType().equals(SpellEffectType.Teleport) || effect.getSpellEffectType().equals(SpellEffectType.Teleport2) || effect.getSpellEffectType().equals(SpellEffectType.Translocate) || effect.getSpellEffectType().equals(SpellEffectType.TranslocatetoAnchor)) {
// If the effect is teleport and the target is not a player then fail
if (!(target instanceof Player))
return new Tuple<Boolean, String>(false, "Target of spell not a player");
if (!(source instanceof Player))
return new Tuple<Boolean, String>(false, "Source of spell not a player");
// fail
if (effect.getSpellEffectType().equals(SpellEffectType.Teleport) || effect.getSpellEffectType().equals(SpellEffectType.Teleport2) || effect.getSpellEffectType().equals(SpellEffectType.Translocate) || effect.getSpellEffectType().equals(SpellEffectType.TranslocatetoAnchor)) {
// if target is not the player casting
if (!target.getUniqueId().equals(source.getUniqueId())) {
ISoliniaPlayer solplayertarget = SoliniaPlayerAdapter.Adapt((Player) target);
if (solplayertarget == null)
return new Tuple<Boolean, String>(false, "Target not found");
if (solplayertarget.getGroup() == null)
return new Tuple<Boolean, String>(false, "Group not found");
if (!(solplayertarget.getGroup().getUnmodifiableGroupMembersForBuffs(false, false).contains(source.getUniqueId())))
return new Tuple<Boolean, String>(false, "Group member not found");
}
}
if (effect.getSpellEffectType().equals(SpellEffectType.SummonPet) || effect.getSpellEffectType().equals(SpellEffectType.NecPet)) {
try {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getPetNPCByName(soliniaSpell.getTeleportZone());
if (npc == null) {
return new Tuple<Boolean, String>(false, "NPC not found for pet");
}
if (npc.isCorePet() == false) {
System.out.print("NPC " + soliniaSpell.getTeleportZone() + " is not defined as a pet");
return new Tuple<Boolean, String>(false, "Pet is not defined on spell");
}
} catch (CoreStateInitException e) {
return new Tuple<Boolean, String>(false, "Plugin not initialised");
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
return new Tuple<Boolean, String>(false, "Exception: " + e.getStackTrace() + " " + e.getMessage());
}
return new Tuple<Boolean, String>(true, "");
}
use of net.minecraft.server.v1_15_R1.Entity in project solinia3-core by mixxit.
the class EntityManager method resetReverseAggro.
@Override
public void resetReverseAggro(UUID uniqueId) {
if (reverseHateList.get(uniqueId) != null) {
Entity entity = Bukkit.getEntity(uniqueId);
if (entity == null)
return;
if (reverseHateList.get(uniqueId).size() == 0) {
return;
}
// clear reverse hate list in advance
for (Entry<UUID, Tuple<Integer, Boolean>> entitesReverseHateList : reverseHateList.get(uniqueId).entrySet()) {
if (hateList.get(entitesReverseHateList.getKey()) == null) {
continue;
}
if (hateList.get(entitesReverseHateList.getKey()).get(uniqueId) != null) {
hateList.get(entitesReverseHateList.getKey()).remove(uniqueId);
Entity bukkitEntity = Bukkit.getEntity(entitesReverseHateList.getKey());
if (bukkitEntity != null && bukkitEntity instanceof LivingEntity) {
try {
ISoliniaLivingEntity solLivingEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) bukkitEntity);
if (solLivingEntity != null && solLivingEntity.getAttackTarget().getUniqueId().equals(uniqueId)) {
if (solLivingEntity.isInHateList(uniqueId))
solLivingEntity.removeFromHateList(uniqueId);
solLivingEntity.checkHateTargets();
}
} catch (CoreStateInitException e) {
}
}
}
}
}
reverseHateList.put(uniqueId, new ConcurrentHashMap<UUID, Tuple<Integer, Boolean>>());
}
Aggregations