From 448a97bb82e5e3d366bb85c0d3eb004d2b02fd89 Mon Sep 17 00:00:00 2001 From: Sentropic <60368610+Sentropic@users.noreply.github.com> Date: Thu, 24 Dec 2020 12:46:00 -0600 Subject: [PATCH 01/10] Fixed 1.12 compatibility issues Fixed NoSuchMethodError in ArmorMechanic Fixed NoClassDefFoundError in arrow ProjectileMechanic --- pom.xml | 2 +- .../skill/dynamic/mechanic/ArmorMechanic.java | 55 ++++++++++++++++--- .../dynamic/mechanic/ProjectileMechanic.java | 22 +++++--- src/main/resources/plugin.yml | 2 +- 4 files changed, 63 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 0ba1f081..ec96aa1a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.sucy.skill SkillAPI - s1.97 + s1.98 jar SkillAPI diff --git a/src/main/java/com/sucy/skill/dynamic/mechanic/ArmorMechanic.java b/src/main/java/com/sucy/skill/dynamic/mechanic/ArmorMechanic.java index 0c0be0bd..14eb796e 100644 --- a/src/main/java/com/sucy/skill/dynamic/mechanic/ArmorMechanic.java +++ b/src/main/java/com/sucy/skill/dynamic/mechanic/ArmorMechanic.java @@ -80,17 +80,56 @@ public boolean execute(LivingEntity caster, int level, List 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; } } diff --git a/src/main/java/com/sucy/skill/dynamic/mechanic/ProjectileMechanic.java b/src/main/java/com/sucy/skill/dynamic/mechanic/ProjectileMechanic.java index be74b98a..0c1e5b75 100644 --- a/src/main/java/com/sucy/skill/dynamic/mechanic/ProjectileMechanic.java +++ b/src/main/java/com/sucy/skill/dynamic/mechanic/ProjectileMechanic.java @@ -37,6 +37,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -46,6 +47,7 @@ */ public class ProjectileMechanic extends MechanicComponent { + private static Class> PICKUP_STATUS_ENUM = null; private static final Vector UP = new Vector(0, 1, 0); private static final String PROJECTILE = "projectile"; @@ -131,17 +133,19 @@ public boolean execute(LivingEntity caster, int level, List target Projectile p = caster.launchProjectile(type); p.setTicksLived(1180); if (type.getName().contains("Arrow")) { - // Will fail under 1.12 try { - // Will fail under 1.14 + // Will fail under 1.12 try { + //1.14+ AbstractArrow arrow = (AbstractArrow) p; arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); } catch (NoClassDefFoundError e) { + //1.12+ Arrow arrow = (Arrow) p; - arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); + Class pickupStatusClass = Class.forName("org.bukkit.Arrow$PickupStatus"); + Arrow.class.getMethod("setPickupStatus", pickupStatusClass).invoke(arrow, pickupStatusClass.getMethod("valueOf", String.class).invoke(null, "DISALLOWED")); } - } catch (NoSuchMethodError ignored) {} + } catch (NoSuchMethodError | ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {} } p.setVelocity(new Vector(0, speed, 0)); p.teleport(loc); @@ -173,17 +177,19 @@ public boolean execute(LivingEntity caster, int level, List target Projectile p = caster.launchProjectile(type); p.setTicksLived(1180); if (type.getName().contains("Arrow")) { - // Will fail under 1.12 try { - // Will fail under 1.14 + // Will fail under 1.12 try { + //1.14+ AbstractArrow arrow = (AbstractArrow) p; arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); } catch (NoClassDefFoundError e) { + //1.12+ Arrow arrow = (Arrow) p; - arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); + Class pickupStatusClass = Class.forName("org.bukkit.Arrow$PickupStatus"); + Arrow.class.getMethod("setPickupStatus", pickupStatusClass).invoke(arrow, pickupStatusClass.getMethod("valueOf", String.class).invoke(null, "DISALLOWED")); } - } catch (NoSuchMethodError ignored) {} + } catch (NoSuchMethodError | ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {} } else { p.teleport(target.getLocation().add(looking).add(0, upward + 0.5, 0).add(p.getVelocity()).setDirection(d)); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a080752a..ae322c16 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: SkillAPI main: com.sucy.skill.SkillAPI -version: s1.97 +version: s1.98 authors: [Eniripsa96, Sentropic] depend: [MCCore] softdepend: [Vault, ProtocolLib, Parties, RPGInventory, LibsDisguises, PlaceholderAPI, NoCheatPlus, MythicMobs, WorldGuard, WorldEdit] From acaed1f3372a79f3c367078d5fd087acc3048bf0 Mon Sep 17 00:00:00 2001 From: Sentropic <60368610+Sentropic@users.noreply.github.com> Date: Thu, 24 Dec 2020 12:48:05 -0600 Subject: [PATCH 02/10] Made armor stands silent 1.10+ only Mostly because the ArmorMechanic was making the equip sound --- .../dynamic/mechanic/ArmorStandMechanic.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/sucy/skill/dynamic/mechanic/ArmorStandMechanic.java b/src/main/java/com/sucy/skill/dynamic/mechanic/ArmorStandMechanic.java index abf9d748..159ab649 100644 --- a/src/main/java/com/sucy/skill/dynamic/mechanic/ArmorStandMechanic.java +++ b/src/main/java/com/sucy/skill/dynamic/mechanic/ArmorStandMechanic.java @@ -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"; } @@ -73,10 +62,13 @@ public boolean execute(LivingEntity caster, int level, List 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); From ed8db4869294c1316e43bfbe04cac92022978af2 Mon Sep 17 00:00:00 2001 From: Sentropic <60368610+Sentropic@users.noreply.github.com> Date: Thu, 24 Dec 2020 12:48:28 -0600 Subject: [PATCH 03/10] Update TempEntity.java --- src/main/java/com/sucy/skill/dynamic/TempEntity.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/sucy/skill/dynamic/TempEntity.java b/src/main/java/com/sucy/skill/dynamic/TempEntity.java index 1e50cbdc..7a5a5035 100644 --- a/src/main/java/com/sucy/skill/dynamic/TempEntity.java +++ b/src/main/java/com/sucy/skill/dynamic/TempEntity.java @@ -508,6 +508,9 @@ public boolean isOnGround() { return true; } + @Override + public boolean isInWater() { return false; } + public World getWorld() { return target.getLocation().getWorld(); } From 1c92aa5be429175ee4446305a4c59862747be8ee Mon Sep 17 00:00:00 2001 From: Sentropic <60368610+Sentropic@users.noreply.github.com> Date: Thu, 24 Dec 2020 12:48:55 -0600 Subject: [PATCH 04/10] Removed rogue crit particles for previous testing --- src/main/java/com/sucy/skill/api/target/TargetHelper.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/sucy/skill/api/target/TargetHelper.java b/src/main/java/com/sucy/skill/api/target/TargetHelper.java index dfe6f771..a46cabf2 100644 --- a/src/main/java/com/sucy/skill/api/target/TargetHelper.java +++ b/src/main/java/com/sucy/skill/api/target/TargetHelper.java @@ -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; @@ -63,10 +62,6 @@ public static List 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); From 65f8ade64dc6990f3d058b5437f5736fddb106a9 Mon Sep 17 00:00:00 2001 From: Sentropic <60368610+Sentropic@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:49:33 -0600 Subject: [PATCH 05/10] Added 'In area' option to AreaTarget AreaTarget now uses the correct location if is run from a target other than the caster --- editor/js/component.js | 4 ++-- pom.xml | 2 +- .../java/com/sucy/skill/api/util/Nearby.java | 19 ++++++++++++------ .../sucy/skill/dynamic/target/AreaTarget.java | 2 +- .../skill/dynamic/target/TargetComponent.java | 20 ++++++++++--------- src/main/resources/plugin.yml | 2 +- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/editor/js/component.js b/editor/js/component.js index 6a5a5921..2366dd6f 100644 --- a/editor/js/component.js +++ b/editor/js/component.js @@ -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') diff --git a/pom.xml b/pom.xml index ec96aa1a..3b4eb151 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.sucy.skill SkillAPI - s1.98 + s1.98-SNAPSHOT jar SkillAPI diff --git a/src/main/java/com/sucy/skill/api/util/Nearby.java b/src/main/java/com/sucy/skill/api/util/Nearby.java index 9aa8323b..c5d77d65 100644 --- a/src/main/java/com/sucy/skill/api/util/Nearby.java +++ b/src/main/java/com/sucy/skill/api/util/Nearby.java @@ -77,10 +77,14 @@ public static List getNearby(Location loc, double radius) * @return nearby entities */ public static List getLivingNearby(Location loc, double radius) { - return getLivingNearby(null, loc, radius); + return getLivingNearby(null, loc, radius, false); } - private static List getLivingNearby(Entity source, Location loc, double radius) { + public static List getLivingNearby(Location loc, double radius, boolean includeCaster) { + return getLivingNearby(null, loc, radius, includeCaster); + } + + private static List getLivingNearby(Entity source, Location loc, double radius, boolean includeCaster) { TreeMap result = new TreeMap<>(); int minX = (int) (loc.getX() - radius) >> 4; @@ -93,7 +97,7 @@ private static List 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) @@ -123,9 +127,12 @@ public static List getNearby(Entity entity, double radius) * * @return nearby entities */ - public static List getLivingNearby(Entity entity, double radius) - { - return getLivingNearby(entity, entity.getLocation(), radius); + public static List getLivingNearby(Entity entity, double radius) { + return getLivingNearby(entity, entity.getLocation(), radius, false); + } + + public static List getLivingNearby(Entity entity, double radius, boolean includeCaster) { + return getLivingNearby(entity, entity.getLocation(), radius, includeCaster); } public static List getNearbyBox(Location loc, double radius) diff --git a/src/main/java/com/sucy/skill/dynamic/target/AreaTarget.java b/src/main/java/com/sucy/skill/dynamic/target/AreaTarget.java index c83a62b6..07c4aca1 100644 --- a/src/main/java/com/sucy/skill/dynamic/target/AreaTarget.java +++ b/src/main/java/com/sucy/skill/dynamic/target/AreaTarget.java @@ -52,7 +52,7 @@ List getTargets( final double radius = parseValues(caster, RADIUS, level, 3.0); final boolean random = settings.getBool(RANDOM, false); - return determineTargets(caster, level, targets, t -> shuffle(Nearby.getLivingNearby(caster, radius), random)); + return determineTargets(caster, level, targets, t -> shuffle(Nearby.getLivingNearby(t, radius, true), random)); } /** {@inheritDoc} */ diff --git a/src/main/java/com/sucy/skill/dynamic/target/TargetComponent.java b/src/main/java/com/sucy/skill/dynamic/target/TargetComponent.java index 6bb8f744..1239a5fe 100644 --- a/src/main/java/com/sucy/skill/dynamic/target/TargetComponent.java +++ b/src/main/java/com/sucy/skill/dynamic/target/TargetComponent.java @@ -31,7 +31,7 @@ public abstract class TargetComponent extends EffectComponent { boolean everyone; boolean allies; boolean throughWall; - boolean self; + IncludeCaster self; @Override public ComponentType getType() { @@ -61,7 +61,7 @@ public void load(DynamicSkill skill, DataSection config) { everyone = group.equals("both"); allies = group.equals("ally"); throughWall = settings.getString(WALL, "false").equalsIgnoreCase("true"); - self = settings.getString(CASTER, "false").equalsIgnoreCase("true"); + self = IncludeCaster.valueOf(settings.getString(CASTER, "false").toUpperCase().replace(' ', '_')); } abstract List getTargets( @@ -132,15 +132,13 @@ List determineTargets( for (LivingEntity entity : found) { if (count >= max) break; - if (!isValidTarget(caster, target, entity)) continue; - list.add(found.get(count)); - count++; + if (isValidTarget(caster, target, entity) || (self.equals(IncludeCaster.IN_AREA) && caster==entity)) { + list.add(entity); + count++; + } } }); - if (self) { - list.add(caster); - } - + if (self.equals(IncludeCaster.TRUE)) list.add(caster); return list; } @@ -152,4 +150,8 @@ boolean isValidTarget(final LivingEntity caster, final LivingEntity from, final && (throughWall || !TargetHelper.isObstructed(from.getEyeLocation(), target.getEyeLocation())) && (everyone || allies == SkillAPI.getSettings().isAlly(caster, target)); } + + public enum IncludeCaster { + TRUE, FALSE, IN_AREA + } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ae322c16..57e6ec94 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: SkillAPI main: com.sucy.skill.SkillAPI -version: s1.98 +version: s1.98-SNAPSHOT authors: [Eniripsa96, Sentropic] depend: [MCCore] softdepend: [Vault, ProtocolLib, Parties, RPGInventory, LibsDisguises, PlaceholderAPI, NoCheatPlus, MythicMobs, WorldGuard, WorldEdit] From f9122af44656ed2d8eada65840b826943f43692f Mon Sep 17 00:00:00 2001 From: Sentropic <60368610+Sentropic@users.noreply.github.com> Date: Sat, 30 Jan 2021 01:11:15 -0600 Subject: [PATCH 06/10] Fixed projectile launching ignoring lore requirements --- .../com/sucy/skill/listener/ItemListener.java | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/sucy/skill/listener/ItemListener.java b/src/main/java/com/sucy/skill/listener/ItemListener.java index 9665f154..9267175e 100644 --- a/src/main/java/com/sucy/skill/listener/ItemListener.java +++ b/src/main/java/com/sucy/skill/listener/ItemListener.java @@ -42,6 +42,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerDropItemEvent; @@ -50,6 +51,7 @@ import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.projectiles.ProjectileSource; import org.bukkit.scheduler.BukkitRunnable; import java.util.Set; @@ -164,8 +166,9 @@ public void onInteract(PlayerInteractEvent event) @EventHandler(priority = EventPriority.LOWEST) public void onAttack(EntityDamageByEntityEvent event) { - if (!SkillAPI.getSettings().isWorldEnabled(event.getEntity().getWorld())) + if (!SkillAPI.getSettings().isWorldEnabled(event.getEntity().getWorld())) { return; + } if (event.getDamager() instanceof Player) { @@ -196,26 +199,44 @@ public void onAttack(EntityDamageByEntityEvent event) @EventHandler(priority = EventPriority.LOWEST) public void onShoot(EntityShootBowEvent event) { + if (!SkillAPI.getSettings().isWorldEnabled(event.getEntity().getWorld())) { + return; + } + if (event.getEntity() instanceof Player) { final PlayerEquips equips = SkillAPI.getPlayerData((Player) event.getEntity()).getEquips(); - if (isMainhand(event.getBow(), event.getEntity())) - { + if (isMainhand(event.getBow(), event.getEntity())) { if (!equips.canHit()) { SkillAPI.getLanguage().sendMessage(ErrorNodes.CANNOT_USE, event.getEntity(), FilterType.COLOR); event.setCancelled(true); } - } - else if (!equips.canBlock()) { + } else if (!equips.canBlock()) { SkillAPI.getLanguage().sendMessage(ErrorNodes.CANNOT_USE, event.getEntity(), FilterType.COLOR); event.setCancelled(true); } } } + @EventHandler(priority = EventPriority.LOWEST) + public void onProjectileLaunch(ProjectileLaunchEvent event) { + if (!SkillAPI.getSettings().isWorldEnabled(event.getEntity().getWorld())) { + return; + } + ProjectileSource shooter = event.getEntity().getShooter(); + if (shooter instanceof Player) { + Player player = (Player) shooter; + final PlayerEquips equips = SkillAPI.getPlayerData(player).getEquips(); + if (!equips.canHit()) { + SkillAPI.getLanguage().sendMessage(ErrorNodes.CANNOT_USE, player, FilterType.COLOR); + event.setCancelled(true); + } + } + } + private boolean isMainhand(final ItemStack bow, final LivingEntity entity) { - return !VersionManager.isVersionAtLeast(VersionManager.V1_9_0) - || bow == entity.getEquipment().getItemInMainHand(); + ItemStack item = entity.getEquipment().getItemInMainHand(); + return bow == item || bow.equals(item); } public static final Set ARMOR_TYPES = getArmorMaterials(); From 49a214ece2c54dcbeb9f1b05f1b70be63d5aa6ba Mon Sep 17 00:00:00 2001 From: Sentropic <60368610+Sentropic@users.noreply.github.com> Date: Sat, 30 Jan 2021 01:37:30 -0600 Subject: [PATCH 07/10] Removed skill lore auto coloring Was messing up text involving colons, like attributes --- src/main/java/com/sucy/skill/api/util/Data.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sucy/skill/api/util/Data.java b/src/main/java/com/sucy/skill/api/util/Data.java index c01cc081..b1da5ce1 100644 --- a/src/main/java/com/sucy/skill/api/util/Data.java +++ b/src/main/java/com/sucy/skill/api/util/Data.java @@ -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; @@ -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 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); From 44fb03e74020a1613080a2b7e0d49920a5dbf24d Mon Sep 17 00:00:00 2001 From: Sentropic <60368610+Sentropic@users.noreply.github.com> Date: Sat, 30 Jan 2021 15:17:53 -0600 Subject: [PATCH 08/10] Fixed {attr:level} and {attr:cost} for certain system languages --- src/main/java/com/sucy/skill/api/skills/Skill.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sucy/skill/api/skills/Skill.java b/src/main/java/com/sucy/skill/api/skills/Skill.java index 7a93e82b..72f9de9e 100644 --- a/src/main/java/com/sucy/skill/api/skills/Skill.java +++ b/src/main/java/com/sucy/skill/api/skills/Skill.java @@ -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; } From 9aca81547bdfe47d1c1eaae13ddc23c3eee48ae0 Mon Sep 17 00:00:00 2001 From: Sentropic <60368610+Sentropic@users.noreply.github.com> Date: Sat, 30 Jan 2021 17:57:48 -0600 Subject: [PATCH 09/10] Added TODO message to silent console --- .../dynamic/mechanic/CommandMechanic.java | 121 +----------------- 1 file changed, 1 insertion(+), 120 deletions(-) diff --git a/src/main/java/com/sucy/skill/dynamic/mechanic/CommandMechanic.java b/src/main/java/com/sucy/skill/dynamic/mechanic/CommandMechanic.java index 98255c56..e8d7ff40 100644 --- a/src/main/java/com/sucy/skill/dynamic/mechanic/CommandMechanic.java +++ b/src/main/java/com/sucy/skill/dynamic/mechanic/CommandMechanic.java @@ -27,23 +27,10 @@ package com.sucy.skill.dynamic.mechanic; import org.bukkit.Bukkit; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.conversations.Conversation; -import org.bukkit.conversations.ConversationAbandonedEvent; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.permissions.Permission; -import org.bukkit.permissions.PermissionAttachment; -import org.bukkit.permissions.PermissionAttachmentInfo; -import org.bukkit.plugin.Plugin; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.List; -import java.util.Set; -import java.util.UUID; /** * Executes a command for each target @@ -98,115 +85,9 @@ public boolean execute(LivingEntity caster, int level, List target } break; case "silent console": - for (LivingEntity t : targets) { - worked = true; - String filteredCommand = filter(caster, t, command); - Bukkit.getServer().dispatchCommand(new SilentConsoleCommandSender(), filteredCommand); - } + //TODO figure out how to hide command output from console break; } return worked; } - - private static class SilentConsoleCommandSender implements ConsoleCommandSender { - - @Override - public void sendRawMessage(String paramString) {} - - @Override - public void sendRawMessage(@Nullable UUID sender, @NotNull String message) {} - - @Override - public boolean isConversing() { - return false; - } - - @Override - public boolean beginConversation(Conversation paramConversation) { - return false; - } - - @Override - public void acceptConversationInput(String paramString) {} - - @Override - public void abandonConversation(Conversation paramConversation, - ConversationAbandonedEvent paramConversationAbandonedEvent) {} - - @Override - public void abandonConversation(Conversation paramConversation) {} - - @Override - public void setOp(boolean paramBoolean) {} - - @Override - public boolean isOp() { return true; } - - @Override - public void removeAttachment(PermissionAttachment paramPermissionAttachment) {} - - @Override - public void recalculatePermissions() {} - - @Override - public boolean isPermissionSet(Permission paramPermission) { - return Bukkit.getServer().getConsoleSender().isPermissionSet(paramPermission); - } - - @Override - public boolean isPermissionSet(String paramString) { - return Bukkit.getServer().getConsoleSender().isPermissionSet(paramString); - } - - @Override - public boolean hasPermission(Permission paramPermission) { - return Bukkit.getServer().getConsoleSender().hasPermission(paramPermission); - } - - @Override - public boolean hasPermission(String paramString) { - return Bukkit.getServer().getConsoleSender().hasPermission(paramString); - } - - @Override - public Set getEffectivePermissions() { return null; } - - @Override - public PermissionAttachment addAttachment(Plugin paramPlugin, String paramString, boolean paramBoolean, int paramInt) { - return null; - } - - @Override - public PermissionAttachment addAttachment(Plugin paramPlugin, String paramString, boolean paramBoolean) { - return null; - } - - @Override - public PermissionAttachment addAttachment(Plugin paramPlugin, int paramInt) { return null; } - - @Override - public PermissionAttachment addAttachment(Plugin paramPlugin) { return null; } - - @Override - public Spigot spigot() { return null; } - - @Override - public void sendMessage(String[] paramArrayOfString) {} - - @Override - public void sendMessage(@Nullable UUID sender, @NotNull String message) {} - - @Override - public void sendMessage(@Nullable UUID sender, @NotNull String[] messages) { } - - @Override - public void sendMessage(String paramString) {} - - @Override - public Server getServer() { return Bukkit.getServer(); } - - @Override - public String getName() { return "SkillApi SilentConsoleCommandServer"; } - } - } From f7a5d20f5b3f2ab6a08bfe28d99266fbb29cd7c8 Mon Sep 17 00:00:00 2001 From: Sentropic <60368610+Sentropic@users.noreply.github.com> Date: Mon, 1 Feb 2021 20:05:53 -0600 Subject: [PATCH 10/10] Added knockback toggle for DamageMechanic --- editor/js/component.js | 7 ++- pom.xml | 2 +- .../java/com/sucy/skill/api/skills/Skill.java | 51 +++++++++++++++---- .../com/sucy/skill/api/util/BuffData.java | 5 +- .../dynamic/mechanic/DamageMechanic.java | 4 +- src/main/resources/plugin.yml | 2 +- 6 files changed, 53 insertions(+), 18 deletions(-) diff --git a/editor/js/component.js b/editor/js/component.js index 2366dd6f..dcdcd24a 100644 --- a/editor/js/component.js +++ b/editor/js/component.js @@ -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') ); } diff --git a/pom.xml b/pom.xml index 3b4eb151..ec96aa1a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.sucy.skill SkillAPI - s1.98-SNAPSHOT + s1.98 jar SkillAPI diff --git a/src/main/java/com/sucy/skill/api/skills/Skill.java b/src/main/java/com/sucy/skill/api/skills/Skill.java index 72f9de9e..ce2caf85 100644 --- a/src/main/java/com/sucy/skill/api/skills/Skill.java +++ b/src/main/java/com/sucy/skill/api/skills/Skill.java @@ -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; } } @@ -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)); + } } /** diff --git a/src/main/java/com/sucy/skill/api/util/BuffData.java b/src/main/java/com/sucy/skill/api/util/BuffData.java index 560747e0..b53985a4 100644 --- a/src/main/java/com/sucy/skill/api/util/BuffData.java +++ b/src/main/java/com/sucy/skill/api/util/BuffData.java @@ -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) { diff --git a/src/main/java/com/sucy/skill/dynamic/mechanic/DamageMechanic.java b/src/main/java/com/sucy/skill/dynamic/mechanic/DamageMechanic.java index 0d8968a9..c5d2d1d5 100644 --- a/src/main/java/com/sucy/skill/dynamic/mechanic/DamageMechanic.java +++ b/src/main/java/com/sucy/skill/dynamic/mechanic/DamageMechanic.java @@ -38,6 +38,7 @@ public class DamageMechanic extends MechanicComponent { private static final String DAMAGE = "value"; private static final String TRUE = "true"; private static final String CLASSIFIER = "classifier"; + private static final String KNOCKBACK = "knockback"; @Override public String getKey() { @@ -61,6 +62,7 @@ public boolean execute(LivingEntity caster, int level, List target boolean left = pString.equals("percent left"); boolean trueDmg = settings.getBool(TRUE, false); double damage = parseValues(caster, DAMAGE, level, 1.0); + boolean knockback = settings.getBool(KNOCKBACK, true); String classification = settings.getString(CLASSIFIER, "default"); if (damage < 0) { return false; } for (LivingEntity target : targets) { @@ -77,7 +79,7 @@ public boolean execute(LivingEntity caster, int level, List target amount = damage * target.getHealth() / 100; } if (trueDmg) { skill.trueDamage(target, amount, caster); } else { - skill.damage(target, amount, caster, classification); + skill.damage(target, amount, caster, classification, knockback); } } return targets.size() > 0; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 57e6ec94..ae322c16 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: SkillAPI main: com.sucy.skill.SkillAPI -version: s1.98-SNAPSHOT +version: s1.98 authors: [Eniripsa96, Sentropic] depend: [MCCore] softdepend: [Vault, ProtocolLib, Parties, RPGInventory, LibsDisguises, PlaceholderAPI, NoCheatPlus, MythicMobs, WorldGuard, WorldEdit]