Skip to content
This repository was archived by the owner on May 22, 2023. It is now read-only.
Merged

1.98 #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions editor/js/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,8 @@ function TargetArea()
this.data.push(new ListValue("Through Wall", "wall", ['True', 'False'], 'False')
.setTooltip('Whether or not to allow targets to be on the other side of a wall')
);
this.data.push(new ListValue("Include Caster", "caster", [ 'True', 'False' ], 'False')
.setTooltip('Whether or not to include the caster in the target list')
this.data.push(new ListValue("Include Caster", "caster", [ 'True', 'False', 'In area' ], 'False')
.setTooltip('Whether to include the caster in the target list. "True" will always include them, "False" will never, and "In area" will only if they are within the targeted area')
);
this.data.push(new AttributeValue("Max Targets", "max", 99, 0)
.setTooltip('The max amount of targets to apply children to')
Expand Down Expand Up @@ -1804,10 +1804,13 @@ function MechanicDamage()
.setTooltip('The amount of damage to deal')
);
this.data.push(new ListValue('True Damage', 'true', [ 'True', 'False' ], 'False')
.setTooltip('Whether or not to deal true damage. True damage ignores armor and all plugin checks.')
.setTooltip('Whether or not to deal true damage. True damage ignores armor and all plugin checks, and doesn not have a damage animation nor knockback')
);
this.data.push(new StringValue('Classifier', 'classifier', 'default')
.setTooltip('[PREMIUM ONLY] The type of damage to deal. Can act as elemental damage or fake physical damage')
.setTooltip('The type of damage to deal. Can act as elemental damage or fake physical damage')
);
this.data.push(new ListValue('Apply Knockback', 'knockback', [ 'True', 'False' ], 'True')
.setTooltip('Whether or not the damage will inflict knockback. Ignored if it is True Damage')
);
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.sucy.skill</groupId>
<artifactId>SkillAPI</artifactId>
<version>s1.97</version>
<version>s1.98</version>
<packaging>jar</packaging>

<name>SkillAPI</name>
Expand Down
53 changes: 41 additions & 12 deletions src/main/java/com/sucy/skill/api/skills/Skill.java
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ public ItemStack getIndicator(PlayerSkill skillData, boolean brief)
Object nextValue = getAttr(player, attr, Math.min(skillData.getLevel() + 1, maxLevel));
if (attr.equals("level") || attr.equals("cost"))
{
nextValue = (int) Math.floor(NumberParser.parseDouble(nextValue.toString()));
nextValue = (int) Math.floor(NumberParser.parseDouble(nextValue.toString().replace(',','.')));
currValue = nextValue;
}

Expand Down Expand Up @@ -749,26 +749,54 @@ public void damage(LivingEntity target, double damage, LivingEntity source) {
* @param classification type of damage to deal
*/
public void damage(LivingEntity target, double damage, LivingEntity source, String classification) {
if (target instanceof TempEntity) return;
damage(target, damage, source, classification);
}

/**
* Applies skill damage to the target, launching the skill damage event
*
* @param target target to receive the damage
* @param damage amount of damage to deal
* @param source source of the damage (skill caster)
* @param classification type of damage to deal
* @param knockback whether the damage should apply knockback
*/
public void damage(LivingEntity target, double damage, LivingEntity source, String classification, boolean knockback) {
if (target instanceof TempEntity) { return; }

SkillDamageEvent event = new SkillDamageEvent(this, source, target, damage, classification);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled())
{
if (source instanceof Player)
{
if (!event.isCancelled()) {
if (source instanceof Player) {
Player player = (Player) source;
if (PluginChecker.isNoCheatActive()) NoCheatHook.exempt(player);
skillDamage = true;
target.setNoDamageTicks(0);
target.damage(event.getDamage(), source);
if (knockback) { target.damage(event.getDamage(), source); }
else { target.damage(event.getDamage()); }
skillDamage = false;
if (PluginChecker.isNoCheatActive()) NoCheatHook.unexempt(player);
}
else
{
} else {
skillDamage = true;
VersionManager.damage(target, source, event.getDamage());
//Modified code from com.rit.sucy.version.VersionManager.damage() (MCCore)
{
// Allow damage to occur
int ticks = target.getNoDamageTicks();
target.setNoDamageTicks(0);

if (VersionManager.isVersionAtMost(VersionManager.V1_5_2)) {
// 1.5.2 and earlier used integer values
if (knockback) { target.damage((int) damage, source); }
else { target.damage((int) damage); }
} else {
// 1.6.2 and beyond use double values
if (knockback) { target.damage(damage, source); }
else { target.damage(damage); }
}

// Reset damage timer to before the damage was applied
target.setNoDamageTicks(ticks);
}
skillDamage = false;
}
}
Expand All @@ -788,8 +816,9 @@ public void trueDamage(LivingEntity target, double damage, LivingEntity source)

TrueDamageEvent event = new TrueDamageEvent(this, source, target, damage);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getDamage() != 0)
if (!event.isCancelled() && event.getDamage() != 0) {
target.setHealth(Math.max(Math.min(target.getHealth() - event.getDamage(), target.getMaxHealth()), 0));
}
}

/**
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/sucy/skill/api/target/TargetHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.utilities.reflection.FakeBoundingBox;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
Expand Down Expand Up @@ -63,10 +62,6 @@ public static List<LivingEntity> getLivingTargets(LivingEntity source, double ra

AABB aabb = getAABB(entity);
aabb.expand(tolerance);
AABB.Vec3D min = aabb.getMin();
AABB.Vec3D max = aabb.getMax();
entity.getWorld().spawnParticle(Particle.CRIT,min.x, min.y, min.z,1,0,0,0,0,null);
entity.getWorld().spawnParticle(Particle.CRIT,max.x, max.y, max.z,1,0,0,0,0,null);
AABB.Vec3D collision = aabb.intersectsRay(ray, 0, range);
if (collision != null) {
targets.put(new Vector(collision.x, collision.y, collision.z).distance(origin), (LivingEntity) entity);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/sucy/skill/api/util/BuffData.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,13 @@ private double doApply(final double value, final String... types) {
}
}
}
Logger.log(LogType.BUFF, 1, "Result: x" + multiplier + ", +" + bonus + ", " + value + " -> " + Math.max(0, value * multiplier + bonus));
double result = Math.max(0, value * multiplier + bonus);
Logger.log(LogType.BUFF, 1, "Result: x" + multiplier + ", +" + bonus + ", " + value + " -> " + result);

// Negatives aren't well received by bukkit, so return 0 instead
if (multiplier <= 0) return 0;

return Math.max(0, value * multiplier + bonus);
return result;
}

private double getFlatBonus(final String... types) {
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/sucy/skill/api/util/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
package com.sucy.skill.api.util;

import com.rit.sucy.config.parse.DataSection;
import com.rit.sucy.text.TextFormatter;
import com.sucy.skill.SkillAPI;
import org.bukkit.ChatColor;
import org.bukkit.Material;
Expand Down Expand Up @@ -65,9 +64,8 @@ private static ItemStack parse(final String mat, final short dur, final int data
item.setData(new MaterialData(material, (byte) data));
}
if (lore != null && !lore.isEmpty()) {
final List<String> colored = TextFormatter.colorStringList(lore);
meta.setDisplayName(colored.remove(0));
meta.setLore(colored);
meta.setDisplayName(lore.remove(0));
meta.setLore(lore);
}
if (SkillAPI.getSettings().useOldDurability()) {
item.setItemMeta(meta);
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/com/sucy/skill/api/util/Nearby.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@ public static List<Entity> getNearby(Location loc, double radius)
* @return nearby entities
*/
public static List<LivingEntity> getLivingNearby(Location loc, double radius) {
return getLivingNearby(null, loc, radius);
return getLivingNearby(null, loc, radius, false);
}

private static List<LivingEntity> getLivingNearby(Entity source, Location loc, double radius) {
public static List<LivingEntity> getLivingNearby(Location loc, double radius, boolean includeCaster) {
return getLivingNearby(null, loc, radius, includeCaster);
}

private static List<LivingEntity> getLivingNearby(Entity source, Location loc, double radius, boolean includeCaster) {
TreeMap<Double, LivingEntity> result = new TreeMap<>();

int minX = (int) (loc.getX() - radius) >> 4;
Expand All @@ -93,7 +97,7 @@ private static List<LivingEntity> getLivingNearby(Entity source, Location loc, d
for (int i = minX; i <= maxX; i++)
for (int j = minZ; j <= maxZ; j++)
for (Entity entity : loc.getWorld().getChunkAt(i, j).getEntities())
if (entity != source
if ((includeCaster || entity != source)
&& entity instanceof LivingEntity
&& entity.getWorld() == loc.getWorld()
&& entity.getLocation().distanceSquared(loc) < radius)
Expand Down Expand Up @@ -123,9 +127,12 @@ public static List<Entity> getNearby(Entity entity, double radius)
*
* @return nearby entities
*/
public static List<LivingEntity> getLivingNearby(Entity entity, double radius)
{
return getLivingNearby(entity, entity.getLocation(), radius);
public static List<LivingEntity> getLivingNearby(Entity entity, double radius) {
return getLivingNearby(entity, entity.getLocation(), radius, false);
}

public static List<LivingEntity> getLivingNearby(Entity entity, double radius, boolean includeCaster) {
return getLivingNearby(entity, entity.getLocation(), radius, includeCaster);
}

public static List<Entity> getNearbyBox(Location loc, double radius)
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/sucy/skill/dynamic/TempEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ public boolean isOnGround() {
return true;
}

@Override
public boolean isInWater() { return false; }

public World getWorld() {
return target.getLocation().getWorld();
}
Expand Down
55 changes: 47 additions & 8 deletions src/main/java/com/sucy/skill/dynamic/mechanic/ArmorMechanic.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,56 @@ public boolean execute(LivingEntity caster, int level, List<LivingEntity> target
}
item.setItemMeta(meta);
}

boolean success = false;
for (LivingEntity target : targets) {
if (overwrite) {
target.getEquipment().setItem(slot, item);
} else {
EntityEquipment equipment = target.getEquipment();
if (equipment.getItem(slot).getType().equals(Material.AIR)) {
equipment.setItem(slot, item);
EntityEquipment equipment = target.getEquipment();
boolean proceed = overwrite;
if (!overwrite) {
switch (slot) {
case FEET:
proceed = equipment.getBoots().getType().equals(Material.AIR);
break;
case HAND:
proceed = equipment.getItemInMainHand().getType().equals(Material.AIR);
break;
case HEAD:
proceed = equipment.getHelmet().getType().equals(Material.AIR);
break;
case LEGS:
proceed = equipment.getLeggings().getType().equals(Material.AIR);
break;
case CHEST:
proceed = equipment.getChestplate().getType().equals(Material.AIR);
break;
case OFF_HAND:
proceed = equipment.getItemInOffHand().getType().equals(Material.AIR);
break;
}
}
if (proceed) {
switch (slot) {
case FEET:
equipment.setBoots(item);
break;
case HAND:
equipment.setItemInMainHand(item);
break;
case HEAD:
equipment.setHelmet(item);
break;
case LEGS:
equipment.setLeggings(item);
break;
case CHEST:
equipment.setChestplate(item);
break;
case OFF_HAND:
equipment.setItemInOffHand(item);
break;
}
success = true;
}
}
return targets.size() > 0;
return success;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,6 @@ public class ArmorStandMechanic extends MechanicComponent {
private static final String UPWARD = "upward";
private static final String RIGHT = "right";

private static boolean LEGACY;

public ArmorStandMechanic() {
try {
ArmorStand.class.getMethod("setMarker", boolean.class);
LEGACY = false;
} catch (NoSuchMethodException e) {
LEGACY = true;
}
}

@Override
public String getKey() { return "armor stand"; }

Expand Down Expand Up @@ -73,10 +62,13 @@ public boolean execute(LivingEntity caster, int level, List<LivingEntity> target
loc.add(dir.multiply(forward)).add(0, upward, 0).add(side.multiply(right));

ArmorStand armorStand = target.getWorld().spawn(loc, ArmorStand.class, as -> {
if (!LEGACY) {
try {
as.setMarker(marker);
as.setInvulnerable(true);
}
} catch (NoSuchMethodError ignored) {}
try {
as.setSilent(true);
} catch (NoSuchMethodError ignored) {}
as.setGravity(gravity);
as.setCustomName(name);
as.setCustomNameVisible(nameVisible);
Expand Down
Loading