use of net.minecraft.server.v1_15_R1.DataWatcher.Item in project solinia3-core by mixxit.
the class ItemStackUtils method IsDisplayItem.
public static boolean IsDisplayItem(ItemStack itemStack) {
// Also check nbttag
if (itemStack == null)
return false;
boolean isDisplayItem = itemStack.getItemMeta().getDisplayName().startsWith("Display Item: ");
if (isDisplayItem)
return isDisplayItem;
// Classic method
net.minecraft.server.v1_15_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound compound = (nmsStack.hasTag()) ? nmsStack.getTag() : new NBTTagCompound();
String isMerchant = compound.getString("merchant");
return Boolean.parseBoolean(isMerchant);
}
use of net.minecraft.server.v1_15_R1.DataWatcher.Item 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.DataWatcher.Item in project solinia3-core by mixxit.
the class ItemStackAdapter method generateSpellLoreText.
private static List<String> generateSpellLoreText(ISoliniaItem soliniaItem) {
List<String> loreTxt = new ArrayList<String>();
ISoliniaSpell spell;
try {
spell = StateManager.getInstance().getConfigurationManager().getSpell(soliniaItem.getAbilityid());
if (spell.getEffectid1() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid1()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid1()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue1() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid1()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue1() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid1()).name() + ChatColor.RESET);
}
if (spell.getEffectid2() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid2()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid2()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue2() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid2()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue2() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid2()).name() + ChatColor.RESET);
}
if (spell.getEffectid3() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid3()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid3()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue3() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid3()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue3() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid3()).name() + ChatColor.RESET);
}
if (spell.getEffectid4() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid4()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid4()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue4() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid4()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue4() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid4()).name() + ChatColor.RESET);
}
if (spell.getEffectid5() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid5()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid5()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue5() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid5()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue5() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid5()).name() + ChatColor.RESET);
}
if (spell.getEffectid6() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid6()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid6()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue6() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid6()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue6() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid6()).name() + ChatColor.RESET);
}
if (spell.getEffectid7() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid7()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid7()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue7() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid7()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue7() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid7()).name() + ChatColor.RESET);
}
if (spell.getEffectid8() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid8()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid8()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue8() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid8()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue8() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid8()).name() + ChatColor.RESET);
}
if (spell.getEffectid9() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid9()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid9()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue9() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid9()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue9() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid9()).name() + ChatColor.RESET);
}
if (spell.getEffectid10() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid10()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid10()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue10() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid10()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue10() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid10()).name() + ChatColor.RESET);
}
if (spell.getEffectid11() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid11()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid11()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue11() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid11()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue11() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid11()).name() + ChatColor.RESET);
}
if (spell.getEffectid12() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid12()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid12()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue12() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid12()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue12() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid12()).name() + ChatColor.RESET);
}
if (!spell.isBardSong()) {
if (spell.getComponents1() > 0) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(spell.getComponents1());
if (item != null && item.isReagent()) {
loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + item.getDisplayname() + " x " + spell.getComponentCounts1() + ChatColor.RESET);
} else {
loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + "ERROR-ALERT-ADMIN-SPELL" + spell.getId() + "-ID" + spell.getComponents1());
}
}
if (spell.getComponents2() > 0) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(spell.getComponents2());
if (item != null && item.isReagent()) {
loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + item.getDisplayname() + " x " + spell.getComponentCounts2() + ChatColor.RESET);
} else {
loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + "ERROR-ALERT-ADMIN-SPELL" + spell.getId() + "-ID" + spell.getComponents2());
}
}
if (spell.getComponents3() > 0) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(spell.getComponents3());
if (item != null && item.isReagent()) {
loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + item.getDisplayname() + " x " + spell.getComponentCounts3() + ChatColor.RESET);
} else {
loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + "ERROR-ALERT-ADMIN-SPELL" + spell.getId() + "-ID" + spell.getComponents3());
}
}
if (spell.getComponents4() > 0) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(spell.getComponents4());
if (item != null && item.isReagent()) {
loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + item.getDisplayname() + " x " + spell.getComponentCounts4() + ChatColor.RESET);
} else {
loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + "ERROR-ALERT-ADMIN-SPELL" + spell.getId() + "-ID" + spell.getComponents4());
}
}
}
loreTxt.add(ChatColor.WHITE + "Mana/Power: " + ChatColor.YELLOW + spell.getMana() + ChatColor.RESET);
loreTxt.add(ChatColor.WHITE + "Spell Skill: " + ChatColor.YELLOW + SkillUtils.getSkillType(spell.getSkill()).name().toUpperCase() + ChatColor.RESET);
loreTxt.add(ChatColor.WHITE + "Range: " + ChatColor.YELLOW + spell.getRange() + ChatColor.RESET);
loreTxt.add(ChatColor.WHITE + "Casting Time: " + ChatColor.YELLOW + (spell.getCastTime() / 1000) + " seconds" + ChatColor.RESET);
if (spell.isAASpell()) {
loreTxt.add(ChatColor.WHITE + "This spell is an AA spell" + ChatColor.RESET);
}
if (spell.isBuffSpell() && spell.getBuffduration() > 0) {
loreTxt.add(ChatColor.WHITE + "Buff Duration: " + ChatColor.YELLOW + (spell.getBuffduration() * 6) + " seconds" + ChatColor.RESET);
}
loreTxt.add(ChatColor.WHITE + "Target Type: " + ChatColor.YELLOW + SpellUtils.getSpellTargetType(spell.getTargettype()).name() + ChatColor.RESET);
List<String> classInfo = generateClassesText(spell);
if (classInfo.size() > 0)
loreTxt.addAll(classInfo);
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return loreTxt;
}
use of net.minecraft.server.v1_15_R1.DataWatcher.Item in project CokesAddon by Cokes86.
the class v1_15_R1 method injectPlayer.
public void injectPlayer(Player player) {
CraftPlayer player1 = (CraftPlayer) player;
if (!player.isValid())
return;
if (channelHandlers.containsKey(player.getUniqueId())) {
final Pair<CraftPlayer, ChannelOutboundHandlerAdapter> pair = channelHandlers.get(player.getUniqueId());
if (!pair.getLeft().isValid()) {
try {
pair.getLeft().getHandle().playerConnection.networkManager.channel.pipeline().remove(pair.getRight());
} catch (NoSuchElementException ignored) {
}
} else
return;
}
final ChannelOutboundHandlerAdapter handler = new ChannelOutboundHandlerAdapter() {
@Override
public void write(ChannelHandlerContext ctx, Object packet, ChannelPromise promise) throws Exception {
if (packet instanceof PacketPlayOutEntityEquipment) {
if ((int) ReflectionUtil.FieldUtil.getValue(packet, "a") == getPlayer().getEntityId()) {
ReflectionUtil.FieldUtil.setValue(packet, "c", ItemStack.a);
}
} else if (packet instanceof PacketPlayOutEntityMetadata) {
if ((int) ReflectionUtil.FieldUtil.getValue(packet, "a") == getPlayer().getEntityId()) {
List<Item<?>> items = ReflectionUtil.FieldUtil.getValue(packet, "b");
if (items.size() != 0) {
Item<?> item = items.get(0);
if (BYTE_DATA_WATCHER_OBJECT.equals(item.a())) {
Item<Byte> byteItem = (Item<Byte>) item;
byteItem.a((byte) (byteItem.b() | 1 << 5));
((CraftPlayer) getPlayer()).getHandle().setInvisible(true);
}
}
}
}
super.write(ctx, packet, promise);
}
};
channelHandlers.put(player.getUniqueId(), Pair.of(player1, handler));
player1.getHandle().playerConnection.networkManager.channel.pipeline().addBefore("packet_handler", hashCode() + ":" + player.getName(), handler);
}
use of net.minecraft.server.v1_15_R1.DataWatcher.Item in project CokesAddon by Cokes86.
the class v1_12_R1 method injectPlayer.
public void injectPlayer(Player player) {
CraftPlayer player1 = (CraftPlayer) player;
if (!player.isValid())
return;
if (channelHandlers.containsKey(player.getUniqueId())) {
final Pair<CraftPlayer, ChannelOutboundHandlerAdapter> pair = channelHandlers.get(player.getUniqueId());
if (!pair.getLeft().isValid()) {
try {
pair.getLeft().getHandle().playerConnection.networkManager.channel.pipeline().remove(pair.getRight());
} catch (NoSuchElementException ignored) {
}
} else
return;
}
final ChannelOutboundHandlerAdapter handler = new ChannelOutboundHandlerAdapter() {
@Override
public void write(ChannelHandlerContext ctx, Object packet, ChannelPromise promise) throws Exception {
if (packet instanceof PacketPlayOutEntityEquipment) {
if ((int) ReflectionUtil.FieldUtil.getValue(packet, "a") == getPlayer().getEntityId()) {
ReflectionUtil.FieldUtil.setValue(packet, "c", ItemStack.a);
}
} else if (packet instanceof PacketPlayOutEntityMetadata) {
if ((int) ReflectionUtil.FieldUtil.getValue(packet, "a") == getPlayer().getEntityId()) {
List<Item<?>> items = ReflectionUtil.FieldUtil.getValue(packet, "b");
if (items.size() != 0) {
Item<?> item = items.get(0);
if (BYTE_DATA_WATCHER_OBJECT.equals(item.a())) {
Item<Byte> byteItem = (Item<Byte>) item;
byteItem.a((byte) (byteItem.b() | 1 << 5));
((CraftPlayer) getPlayer()).getHandle().setInvisible(true);
}
}
}
}
super.write(ctx, packet, promise);
}
};
channelHandlers.put(player.getUniqueId(), Pair.of(player1, handler));
player1.getHandle().playerConnection.networkManager.channel.pipeline().addBefore("packet_handler", hashCode() + ":" + player.getName(), handler);
}
Aggregations