mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-02-01 11:11:21 +01:00
!MMOLib update 2
This commit is contained in:
parent
313ba0e21c
commit
38328fbbf8
BIN
lib/MMOCore.jar
BIN
lib/MMOCore.jar
Binary file not shown.
@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -27,7 +27,7 @@ public class Black_Hole extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
Location loc = getTargetLocation(stats.getPlayer(), target);
|
||||
if (loc == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -24,7 +24,7 @@ public class Blink extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
stats.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, stats.getPlayer().getLocation().add(0, 1, 0), 0);
|
||||
stats.getPlayer().getWorld().spawnParticle(Particle.SPELL_INSTANT, stats.getPlayer().getLocation().add(0, 1, 0), 32, 0, 0, 0, .1);
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
|
||||
|
@ -13,7 +13,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
public class Blizzard extends Ability implements Listener {
|
||||
@ -30,7 +30,7 @@ public class Blizzard extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration") * 10;
|
||||
double force = data.getModifier("force");
|
||||
double inaccuracy = data.getModifier("inaccuracy");
|
||||
|
@ -12,7 +12,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
@ -30,7 +30,7 @@ public class Bouncy_Fireball extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 2, 0);
|
||||
new BukkitRunnable() {
|
||||
int j = 0;
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -35,7 +35,7 @@ public class Bunny_Mode extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration") * 20;
|
||||
double y = data.getModifier("jump-force");
|
||||
double xz = data.getModifier("speed");
|
||||
|
@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
@ -29,7 +29,7 @@ public class Burning_Hands extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration") * 10;
|
||||
double damage = data.getModifier("damage") / 2;
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
public class Chicken_Wraith extends Ability implements Listener {
|
||||
@ -29,7 +29,7 @@ public class Chicken_Wraith extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration") * 10;
|
||||
double force = data.getModifier("force");
|
||||
double inaccuracy = data.getModifier("inaccuracy");
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
@ -29,7 +29,7 @@ public class Circular_Slash extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double damage = data.getModifier("damage");
|
||||
double radius = data.getModifier("radius");
|
||||
double knockback = data.getModifier("knockback");
|
||||
|
@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -29,7 +29,7 @@ public class Contamination extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
Location loc = getTargetLocation(stats.getPlayer(), target);
|
||||
if (loc == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -30,7 +30,7 @@ public class Corrupt extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
Location loc = getTargetLocation(stats.getPlayer(), target);
|
||||
if (loc == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -15,7 +15,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
@ -30,7 +30,7 @@ public class Corrupted_Fangs extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double damage1 = data.getModifier("damage");
|
||||
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
|
||||
@ -61,7 +61,7 @@ public class Corrupted_Fangs extends Ability implements Listener {
|
||||
|
||||
event.setCancelled(true);
|
||||
Object[] data = MMOItems.plugin.getEntities().getEntityData(damager);
|
||||
TemporaryStats stats = (TemporaryStats) data[0];
|
||||
CachedStats stats = (CachedStats) data[0];
|
||||
if (MMOUtils.canDamage(stats.getPlayer(), event.getEntity()))
|
||||
new ItemAttackResult((double) data[1], DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) event.getEntity());
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -33,7 +33,7 @@ public class Cursed_Beam extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration");
|
||||
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
|
||||
|
@ -17,7 +17,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
@ -34,7 +34,7 @@ public class Earthquake extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
if (!stats.getPlayer().isOnGround()) {
|
||||
result.setSuccessful(false);
|
||||
return;
|
||||
|
@ -17,7 +17,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
@ -37,7 +37,7 @@ public class Explosive_Turkey extends Ability implements Listener {
|
||||
Chicken chicken = null;
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration") * 10;
|
||||
double damage = data.getModifier("damage");
|
||||
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
|
||||
|
@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -31,7 +31,7 @@ public class Fire_Meteor extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 3, 1);
|
||||
new BukkitRunnable() {
|
||||
double ti = 0;
|
||||
|
@ -14,7 +14,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -31,7 +31,7 @@ public class Firebolt extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
|
||||
new BukkitRunnable() {
|
||||
Vector vec = getTargetDirection(stats.getPlayer(), target).multiply(.8);
|
||||
|
@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -31,7 +31,7 @@ public class Firefly extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration") * 20;
|
||||
|
||||
new BukkitRunnable() {
|
||||
|
@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -32,7 +32,7 @@ public class Freezing_Curse extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
Location loc = getTargetLocation(stats.getPlayer(), target);
|
||||
if (loc == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -26,7 +26,7 @@ public class Frog_Mode extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration") * 20;
|
||||
double y = data.getModifier("jump-force");
|
||||
double xz = data.getModifier("speed");
|
||||
|
@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
public class Frozen_Aura extends Ability implements Listener {
|
||||
@ -29,7 +29,7 @@ public class Frozen_Aura extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration") * 20;
|
||||
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
|
||||
double amplifier = data.getModifier("amplifier") - 1;
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
public class Grand_Heal extends Ability {
|
||||
@ -24,7 +24,7 @@ public class Grand_Heal extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double heal = data.getModifier("heal");
|
||||
double radius = data.getModifier("radius");
|
||||
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
public class Heal extends Ability {
|
||||
@ -21,7 +21,7 @@ public class Heal extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
|
||||
stats.getPlayer().getWorld().spawnParticle(Particle.HEART, stats.getPlayer().getLocation().add(0, .75, 0), 16, 1, 1, 1, 0);
|
||||
stats.getPlayer().getWorld().spawnParticle(Particle.VILLAGER_HAPPY, stats.getPlayer().getLocation().add(0, .75, 0), 16, 1, 1, 1, 0);
|
||||
|
@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
@ -27,7 +27,7 @@ public class Heavy_Charge extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double knockback = data.getModifier("knockback");
|
||||
|
||||
new BukkitRunnable() {
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
@ -29,7 +29,7 @@ public class Hoearthquake extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
if (!stats.getPlayer().isOnGround()) {
|
||||
result.setSuccessful(false);
|
||||
return;
|
||||
|
@ -14,7 +14,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -31,7 +31,7 @@ public class Holy_Missile extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration") * 10;
|
||||
double damage = data.getModifier("damage");
|
||||
|
||||
|
@ -17,7 +17,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -36,7 +36,7 @@ public class Ice_Crystal extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
|
||||
new BukkitRunnable() {
|
||||
Vector vec = getTargetDirection(stats.getPlayer(), target).multiply(.45);
|
||||
|
@ -15,7 +15,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -35,7 +35,7 @@ public class Item_Bomb extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
ItemStack itemStack = stats.getPlayer().getInventory().getItemInMainHand().clone();
|
||||
if (itemStack == null || itemStack.getType() == Material.AIR) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -30,7 +30,7 @@ public class Item_Throw extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
ItemStack itemStack = stats.getPlayer().getInventory().getItemInMainHand().clone();
|
||||
if (itemStack == null || itemStack.getType() == Material.AIR) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -23,7 +23,7 @@ public class Leap extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
if (!stats.getPlayer().isOnGround()) {
|
||||
result.setSuccessful(false);
|
||||
return;
|
||||
|
@ -12,7 +12,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -30,7 +30,7 @@ public class Life_Ender extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double damage = data.getModifier("damage");
|
||||
double knockback = data.getModifier("knockback");
|
||||
double radius = data.getModifier("radius");
|
||||
|
@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -30,7 +30,7 @@ public class Light_Dash extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double damage = data.getModifier("damage");
|
||||
double length = data.getModifier("length");
|
||||
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -26,7 +26,7 @@ public class Lightning_Beam extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
Location loc = getTargetLocation(stats.getPlayer(), target);
|
||||
if (loc == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -32,7 +32,7 @@ public class Magical_Path extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
stats.getPlayer().setAllowFlight(true);
|
||||
stats.getPlayer().setFlying(true);
|
||||
stats.getPlayer().setVelocity(stats.getPlayer().getVelocity().setY(.5));
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -32,7 +32,7 @@ public class Magical_Shield extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
if (!stats.getPlayer().isOnGround()) {
|
||||
result.setSuccessful(false);
|
||||
return;
|
||||
|
@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -29,7 +29,7 @@ public class Magma_Fissure extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -28,7 +28,7 @@ public class Overload extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double damage = data.getModifier("damage");
|
||||
double radius = data.getModifier("radius");
|
||||
|
||||
|
@ -20,7 +20,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -57,7 +57,7 @@ public class Present_Throw extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double damage = data.getModifier("damage");
|
||||
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
|
||||
|
||||
|
@ -10,7 +10,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
@ -26,7 +26,7 @@ public class Regen_Ally extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
|
||||
if (target == null || !(target instanceof Player)) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -19,7 +19,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -36,7 +36,7 @@ public class Shadow_Veil extends Ability implements Listener {
|
||||
public static List<UUID> shadowVeil = new ArrayList<UUID>();
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration");
|
||||
|
||||
shadowVeil.add(stats.getPlayer().getUniqueId());
|
||||
|
@ -17,7 +17,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
@ -33,7 +33,7 @@ public class Shockwave extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double knockUp = data.getModifier("knock-up");
|
||||
double length = data.getModifier("length");
|
||||
|
||||
|
@ -19,7 +19,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -38,7 +38,7 @@ public class Shulker_Missile extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration");
|
||||
|
||||
new BukkitRunnable() {
|
||||
@ -89,7 +89,7 @@ public class Shulker_Missile extends Ability implements Listener {
|
||||
|
||||
// void spirit
|
||||
if (data.length > 2)
|
||||
result.applyEffects((TemporaryStats) data[2], (NBTItem) data[3], entity);
|
||||
result.applyEffects((CachedStats) data[2], (NBTItem) data[3], entity);
|
||||
|
||||
event.setDamage(result.getDamage());
|
||||
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
@ -27,7 +27,7 @@ public class Sky_Smash extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double damage = data.getModifier("damage");
|
||||
double knockUp = data.getModifier("knock-up");
|
||||
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -21,7 +21,7 @@ public class Smite extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
target = target == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : target;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -16,7 +16,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -33,7 +33,7 @@ public class Snowman_Turret extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
Location loc = getTargetLocation(stats.getPlayer(), target);
|
||||
if (loc == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -29,7 +29,7 @@ public class Sparkle extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
target = target == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : target;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -23,7 +23,7 @@ public class Swiftness extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration");
|
||||
int amplifier = (int) data.getModifier("amplifier");
|
||||
|
||||
|
@ -15,7 +15,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
public class TNT_Throw extends Ability implements Listener {
|
||||
@ -29,7 +29,7 @@ public class TNT_Throw extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
Vector vec = getTargetDirection(stats.getPlayer(), target).multiply(2 * data.getModifier("force"));
|
||||
TNTPrimed tnt = (TNTPrimed) stats.getPlayer().getWorld().spawnEntity(stats.getPlayer().getLocation().add(0, 1, 0), EntityType.PRIMED_TNT);
|
||||
tnt.setFuseTicks(80);
|
||||
|
@ -15,7 +15,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -33,7 +33,7 @@ public class Tactical_Grenade extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -10,7 +10,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -28,7 +28,7 @@ public class Targeted_Fireball extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -15,7 +15,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
@ -34,7 +34,7 @@ public class Throw_Up extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double duration = data.getModifier("duration") * 10;
|
||||
double dps = data.getModifier("damage") / 2;
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
@ -27,7 +27,7 @@ public class Thrust extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
double damage = data.getModifier("damage");
|
||||
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, 0);
|
||||
|
@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -29,7 +29,7 @@ public class Arcane_Hail extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
Location loc = getTargetLocation(stats.getPlayer(), target);
|
||||
if (loc == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -16,7 +16,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -35,7 +35,7 @@ public class Arcane_Rift extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
if (!stats.getPlayer().isOnGround()) {
|
||||
result.setSuccessful(false);
|
||||
return;
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -27,7 +27,7 @@ public class Blind extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
target = target == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : target;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
@ -22,7 +22,7 @@ public class Bloodbath extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
target = target == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : target;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -10,7 +10,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
@ -25,7 +25,7 @@ public class Burn extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -10,7 +10,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
@ -24,7 +24,7 @@ public class Confuse extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
public class Corrosion extends Ability {
|
||||
@ -27,7 +27,7 @@ public class Corrosion extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
Location loc = getTargetLocation(stats.getPlayer(), target);
|
||||
if (loc == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -29,7 +29,7 @@ public class Death_Mark extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -27,7 +27,7 @@ public class Freeze extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
Location loc = getTargetLocation(stats.getPlayer(), target);
|
||||
if (loc == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -25,7 +25,7 @@ public class Ignite extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
Location loc = getTargetLocation(stats.getPlayer(), target);
|
||||
if (loc == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
@ -26,7 +26,7 @@ public class Minor_Explosion extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
Location loc = getTargetLocation(stats.getPlayer(), target);
|
||||
if (loc == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
@ -25,7 +25,7 @@ public class Poison extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
target = target == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : target;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -10,7 +10,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -26,7 +26,7 @@ public class Shock extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
@ -29,7 +29,7 @@ public class Slow extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -25,7 +25,7 @@ public class Starfall extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
return;
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
@ -24,7 +24,7 @@ public class Stun extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
|
||||
target = target == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : target;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
@ -26,7 +26,7 @@ public class Vampirism extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -23,7 +23,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -42,7 +42,7 @@ public class Weaken_Target extends Ability implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
|
||||
if (target == null || marked.containsKey(target.getUniqueId())) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
@ -29,7 +29,7 @@ public class Wither extends Ability {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
|
||||
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
public abstract class Ability {
|
||||
@ -99,7 +99,7 @@ public abstract class Ability {
|
||||
* these methods need to be overriden by ability classes depending on their
|
||||
* ability type
|
||||
*/
|
||||
public abstract void whenCast(TemporaryStats playerStats, LivingEntity target, AbilityData data, ItemAttackResult result);
|
||||
public abstract void whenCast(CachedStats playerStats, LivingEntity target, AbilityData data, ItemAttackResult result);
|
||||
|
||||
/*
|
||||
* util methods for abilities
|
||||
|
@ -18,7 +18,7 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.listener.ElementListener;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -27,7 +27,7 @@ import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public enum Element {
|
||||
FIRE(Material.BLAZE_POWDER, "Fire", ChatColor.DARK_RED, new ElementParticle(Particle.FLAME, .05f, 8), new ElementHandler() {
|
||||
public void elementAttack(TemporaryStats stats, ItemAttackResult result, LivingEntity target, double attack, double absolute) {
|
||||
public void elementAttack(CachedStats stats, ItemAttackResult result, LivingEntity target, double attack, double absolute) {
|
||||
target.getWorld().spawnParticle(Particle.LAVA, target.getLocation().add(0, target.getHeight() / 2, 0), 14);
|
||||
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_BLAZE_HURT, 2, .8f);
|
||||
target.setFireTicks((int) (attack * 2));
|
||||
@ -36,7 +36,7 @@ public enum Element {
|
||||
}),
|
||||
|
||||
ICE(VersionMaterial.SNOWBALL.toMaterial(), "Ice", ChatColor.AQUA, new ElementParticle(Particle.BLOCK_CRACK, .07f, 16, Material.ICE), new ElementHandler() {
|
||||
public void elementAttack(TemporaryStats stats, ItemAttackResult result, LivingEntity target, double attack, double absolute) {
|
||||
public void elementAttack(CachedStats stats, ItemAttackResult result, LivingEntity target, double attack, double absolute) {
|
||||
new BukkitRunnable() {
|
||||
double y = 0;
|
||||
Location loc = target.getLocation();
|
||||
@ -57,7 +57,7 @@ public enum Element {
|
||||
}),
|
||||
|
||||
WIND(Material.FEATHER, "Wind", ChatColor.GRAY, new ElementParticle(Particle.EXPLOSION_NORMAL, .06f, 8), new ElementHandler() {
|
||||
public void elementAttack(TemporaryStats stats, ItemAttackResult result, LivingEntity target, double attack, double absolute) {
|
||||
public void elementAttack(CachedStats stats, ItemAttackResult result, LivingEntity target, double attack, double absolute) {
|
||||
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_ENDER_DRAGON_GROWL.toSound(), 2, 2f);
|
||||
Vector vec = target.getLocation().subtract(stats.getPlayer().getLocation()).toVector().normalize().multiply(1.7).setY(.5);
|
||||
target.setVelocity(vec);
|
||||
@ -73,7 +73,7 @@ public enum Element {
|
||||
}),
|
||||
|
||||
EARTH(VersionMaterial.OAK_SAPLING.toMaterial(), "Earth", ChatColor.GREEN, new ElementParticle(Particle.BLOCK_CRACK, .05f, 24, Material.DIRT), new ElementHandler() {
|
||||
public void elementAttack(TemporaryStats stats, ItemAttackResult result, LivingEntity target, double attack, double absolute) {
|
||||
public void elementAttack(CachedStats stats, ItemAttackResult result, LivingEntity target, double attack, double absolute) {
|
||||
target.getWorld().playSound(target.getLocation(), Sound.BLOCK_GRASS_BREAK, 2, 0);
|
||||
MMOLib.plugin.getVersion().getWrapper().spawnParticle(Particle.BLOCK_CRACK, target.getLocation().add(0, .1, 0), 64, 1, 0, 1, 0, Material.DIRT);
|
||||
result.addDamage(absolute);
|
||||
@ -86,7 +86,7 @@ public enum Element {
|
||||
}),
|
||||
|
||||
THUNDER(VersionMaterial.GUNPOWDER.toMaterial(), "Thunder", ChatColor.YELLOW, new ElementParticle(Particle.FIREWORKS_SPARK, .05f, 8), new ElementHandler() {
|
||||
public void elementAttack(TemporaryStats stats, ItemAttackResult result, LivingEntity target, double attack, double absolute) {
|
||||
public void elementAttack(CachedStats stats, ItemAttackResult result, LivingEntity target, double attack, double absolute) {
|
||||
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_LARGE_BLAST.toSound(), 2, 0);
|
||||
for (Entity entity : target.getNearbyEntities(3, 2, 3))
|
||||
if (MMOUtils.canDamage(stats.getPlayer(), entity))
|
||||
@ -99,7 +99,7 @@ public enum Element {
|
||||
}),
|
||||
|
||||
WATER(VersionMaterial.LILY_PAD.toMaterial(), "Water", ChatColor.BLUE, new ElementParticle(Particle.BLOCK_CRACK, .07f, 32, Material.WATER), new ElementHandler() {
|
||||
public void elementAttack(TemporaryStats stats, ItemAttackResult result, LivingEntity target, double attack, double absolute) {
|
||||
public void elementAttack(CachedStats stats, ItemAttackResult result, LivingEntity target, double attack, double absolute) {
|
||||
ElementListener.weaken(target);
|
||||
new BukkitRunnable() {
|
||||
double step = Math.PI / 2;
|
||||
@ -156,7 +156,7 @@ public enum Element {
|
||||
}
|
||||
|
||||
public interface ElementHandler {
|
||||
public void elementAttack(TemporaryStats stats, ItemAttackResult result, LivingEntity target, double damage, double absolute);
|
||||
public void elementAttack(CachedStats stats, ItemAttackResult result, LivingEntity target, double damage, double absolute);
|
||||
}
|
||||
|
||||
public static class ElementParticle {
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
@ -53,7 +53,7 @@ public class ElementalAttack {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void apply(TemporaryStats stats) {
|
||||
public void apply(CachedStats stats) {
|
||||
|
||||
// elemental attacks
|
||||
double p = 1;
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability.CastingMode;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.AttackResult;
|
||||
@ -57,11 +57,11 @@ public class ItemAttackResult extends AttackResult {
|
||||
return (ItemAttackResult) super.multiplyDamage(coef);
|
||||
}
|
||||
|
||||
public void damage(TemporaryStats stats, LivingEntity target) {
|
||||
public void damage(CachedStats stats, LivingEntity target) {
|
||||
MMOLib.plugin.getDamage().damage(stats.getPlayer(), target, this);
|
||||
}
|
||||
|
||||
public void applyEffectsAndDamage(TemporaryStats stats, NBTItem item, LivingEntity target) {
|
||||
public void applyEffectsAndDamage(CachedStats stats, NBTItem item, LivingEntity target) {
|
||||
MMOLib.plugin.getDamage().damage(stats.getPlayer(), target, applyEffects(stats, item, target));
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ public class ItemAttackResult extends AttackResult {
|
||||
* this methods makes applying ALL effects including elemental damage easier
|
||||
* for untargeted weapons like staffs.
|
||||
*/
|
||||
public ItemAttackResult applyEffects(TemporaryStats stats, NBTItem item, LivingEntity target) {
|
||||
public ItemAttackResult applyEffects(CachedStats stats, NBTItem item, LivingEntity target) {
|
||||
if (hasType(DamageType.WEAPON)) {
|
||||
applyElementalEffects(stats, item, target);
|
||||
applyOnHitEffects(stats, target);
|
||||
@ -78,7 +78,7 @@ public class ItemAttackResult extends AttackResult {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemAttackResult applySkillEffects(TemporaryStats stats, LivingEntity target) {
|
||||
public ItemAttackResult applySkillEffects(CachedStats stats, LivingEntity target) {
|
||||
|
||||
for (DamageType type : DamageType.values())
|
||||
if (hasType(type))
|
||||
@ -91,7 +91,7 @@ public class ItemAttackResult extends AttackResult {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemAttackResult applyElementalEffects(TemporaryStats stats, NBTItem item, LivingEntity target) {
|
||||
public ItemAttackResult applyElementalEffects(CachedStats stats, NBTItem item, LivingEntity target) {
|
||||
new ElementalAttack(item, this).applyElementalArmor(target).apply(stats);
|
||||
return this;
|
||||
}
|
||||
@ -100,7 +100,7 @@ public class ItemAttackResult extends AttackResult {
|
||||
* vanilla melee weapons have no NBTTitems so this method only provides for
|
||||
* non-weapon specific effects like critical strikes and extra stat damage
|
||||
*/
|
||||
public ItemAttackResult applyOnHitEffects(TemporaryStats stats, LivingEntity target) {
|
||||
public ItemAttackResult applyOnHitEffects(CachedStats stats, LivingEntity target) {
|
||||
|
||||
// abilities
|
||||
stats.getPlayerData().castAbilities(stats, target, this, CastingMode.ON_HIT);
|
||||
|
@ -1,14 +1,14 @@
|
||||
package net.Indyuce.mmoitems.api;
|
||||
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public class ProjectileData {
|
||||
private final NBTItem sourceItem;
|
||||
private final TemporaryStats playerStats;
|
||||
private final CachedStats playerStats;
|
||||
private final boolean customWeapon;
|
||||
|
||||
public ProjectileData(NBTItem sourceItem, TemporaryStats playerStats, boolean customWeapon) {
|
||||
public ProjectileData(NBTItem sourceItem, CachedStats playerStats, boolean customWeapon) {
|
||||
this.playerStats = playerStats;
|
||||
this.sourceItem = sourceItem;
|
||||
this.customWeapon = customWeapon;
|
||||
@ -18,7 +18,7 @@ public class ProjectileData {
|
||||
return sourceItem;
|
||||
}
|
||||
|
||||
public TemporaryStats getPlayerStats() {
|
||||
public CachedStats getPlayerStats() {
|
||||
return playerStats;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
@ -116,18 +116,18 @@ public enum TypeSet {
|
||||
*/
|
||||
EXTRA;
|
||||
|
||||
private SetAttackHandler<TemporaryStats, LivingEntity, Weapon, ItemAttackResult> attackHandler;
|
||||
private SetAttackHandler<CachedStats, LivingEntity, Weapon, ItemAttackResult> attackHandler;
|
||||
|
||||
private TypeSet() {
|
||||
this((playerStats, target, weapon, result) -> {
|
||||
});
|
||||
}
|
||||
|
||||
private TypeSet(SetAttackHandler<TemporaryStats, LivingEntity, Weapon, ItemAttackResult> attackHandler) {
|
||||
private TypeSet(SetAttackHandler<CachedStats, LivingEntity, Weapon, ItemAttackResult> attackHandler) {
|
||||
this.attackHandler = attackHandler;
|
||||
}
|
||||
|
||||
public void applyAttackEffect(TemporaryStats playerStats, LivingEntity target, Weapon weapon, ItemAttackResult result) {
|
||||
public void applyAttackEffect(CachedStats playerStats, LivingEntity target, Weapon weapon, ItemAttackResult result) {
|
||||
attackHandler.apply(playerStats, target, weapon, result);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ import net.Indyuce.mmoitems.api.interaction.util.DurabilityItem;
|
||||
import net.Indyuce.mmoitems.api.interaction.util.InteractItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.comp.flags.FlagPlugin.CustomFlag;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
@ -70,7 +70,7 @@ public class Weapon extends UseItem {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemAttackResult targetedAttack(TemporaryStats stats, LivingEntity target, EquipmentSlot slot, ItemAttackResult result) {
|
||||
public ItemAttackResult targetedAttack(CachedStats stats, LivingEntity target, EquipmentSlot slot, ItemAttackResult result) {
|
||||
|
||||
// custom durability
|
||||
DurabilityItem durItem = new DurabilityItem(getPlayer(), getNBTItem());
|
||||
|
@ -16,7 +16,7 @@ import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.api.util.SoundReader;
|
||||
import net.Indyuce.mmoitems.stat.Lute_Attack_Effect.LuteAttackEffect;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
@ -31,7 +31,7 @@ public class Lute extends UntargetedWeapon {
|
||||
|
||||
@Override
|
||||
public void untargetedAttackEffects() {
|
||||
TemporaryStats stats = getPlayerData().getStats().newTemporary();
|
||||
CachedStats stats = getPlayerData().getStats().newTemporary();
|
||||
|
||||
double attackSpeed = 1 / getValue(stats.getStat(ItemStat.ATTACK_SPEED), MMOItems.plugin.getConfig().getDouble("default.attack-speed"));
|
||||
if (!hasEnoughResources(attackSpeed, CooldownType.ATTACK, false))
|
||||
|
@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -25,7 +25,7 @@ public class Musket extends UntargetedWeapon {
|
||||
|
||||
@Override
|
||||
public void untargetedAttackEffects() {
|
||||
TemporaryStats stats = getPlayerData().getStats().newTemporary();
|
||||
CachedStats stats = getPlayerData().getStats().newTemporary();
|
||||
|
||||
if (!hasEnoughResources(1 / getValue(stats.getStat(ItemStat.ATTACK_SPEED), MMOItems.plugin.getConfig().getDouble("default.attack-speed")), CooldownType.ATTACK, false))
|
||||
return;
|
||||
|
@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.Staff_Spirit.StaffSpirit;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
@ -29,7 +29,7 @@ public class Staff extends UntargetedWeapon {
|
||||
|
||||
@Override
|
||||
public void untargetedAttackEffects() {
|
||||
TemporaryStats stats = getPlayerData().getStats().newTemporary();
|
||||
CachedStats stats = getPlayerData().getStats().newTemporary();
|
||||
|
||||
if (!hasEnoughResources(1 / getValue(stats.getStat(ItemStat.ATTACK_SPEED), MMOItems.plugin.getConfig().getDouble("default.attack-speed")), CooldownType.ATTACK, false))
|
||||
return;
|
||||
|
@ -10,7 +10,7 @@ import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
@ -26,7 +26,7 @@ public class Whip extends UntargetedWeapon {
|
||||
@Override
|
||||
public void untargetedAttackEffects() {
|
||||
|
||||
TemporaryStats stats = getPlayerData().getStats().newTemporary();
|
||||
CachedStats stats = getPlayerData().getStats().newTemporary();
|
||||
if (!hasEnoughResources(1 / getValue(stats.getStat(ItemStat.ATTACK_SPEED), MMOItems.plugin.getConfig().getDouble("default.attack-speed")), CooldownType.ATTACK, false))
|
||||
return;
|
||||
|
||||
|
@ -13,14 +13,14 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public class BruteLuteAttack implements LuteAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
new BukkitRunnable() {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
|
@ -13,14 +13,14 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public class CircularLuteAttack implements LuteAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
new BukkitRunnable() {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
|
@ -5,11 +5,11 @@ import java.util.Random;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public interface LuteAttackHandler {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound);
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound);
|
||||
|
||||
static final Random random = new Random();
|
||||
}
|
||||
|
@ -13,14 +13,14 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public class SimpleLuteAttack implements LuteAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
new BukkitRunnable() {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
|
@ -11,14 +11,14 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public class SlashLuteAttack implements LuteAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
new BukkitRunnable() {
|
||||
final Vector vec = stats.getPlayer().getEyeLocation().getDirection();
|
||||
Location loc = stats.getPlayer().getLocation().add(0, 1.3, 0);
|
||||
|
@ -13,14 +13,14 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public class WaveLuteAttack implements LuteAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
new BukkitRunnable() {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -16,7 +16,7 @@ import net.mmogroup.mmolib.version.VersionSound;
|
||||
public class LightningSpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 2);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.75);
|
||||
|
@ -14,7 +14,7 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
@ -22,7 +22,7 @@ import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
public class ManaSpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
new BukkitRunnable() {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
|
@ -13,14 +13,14 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public class NetherSpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
new BukkitRunnable() {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.3);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
|
@ -4,11 +4,11 @@ import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public interface StaffAttackHandler {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range);
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range);
|
||||
|
||||
static final Random random = new Random();
|
||||
|
||||
|
@ -14,7 +14,7 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -22,7 +22,7 @@ import net.mmogroup.mmolib.version.VersionSound;
|
||||
public class SunfireSpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
|
||||
new BukkitRunnable() {
|
||||
Location target = getGround(stats.getPlayer().getTargetBlock((Set<Material>) null, (int) range * 2).getLocation()).add(0, 1.2, 0);
|
||||
|
@ -14,7 +14,7 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
@ -22,7 +22,7 @@ import net.mmogroup.mmolib.version.VersionSound;
|
||||
public class ThunderSpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
|
||||
new BukkitRunnable() {
|
||||
Location target = getGround(stats.getPlayer().getTargetBlock((Set<Material>) null, (int) range * 2).getLocation()).add(0, 1.2, 0);
|
||||
|
@ -8,14 +8,14 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public class VoidSpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection();
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
|
||||
ShulkerBullet shulkerBullet = (ShulkerBullet) stats.getPlayer().getWorld().spawnEntity(stats.getPlayer().getLocation().add(0, 1, 0), EntityType.valueOf("SHULKER_BULLET"));
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ItemAttackResult;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.api.MMORayTraceResult;
|
||||
@ -16,7 +16,7 @@ import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
public class XRaySpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
public void handle(CachedStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 2, 2);
|
||||
|
||||
double a = Math.toRadians(stats.getPlayer().getEyeLocation().getYaw() + 160);
|
||||
|
@ -34,7 +34,7 @@ import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.crafting.CraftingStatus;
|
||||
import net.Indyuce.mmoitems.api.event.AbilityUseEvent;
|
||||
import net.Indyuce.mmoitems.api.item.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.comp.flags.FlagPlugin.CustomFlag;
|
||||
import net.Indyuce.mmoitems.comp.inventory.PlayerInventory.EquippedItem;
|
||||
import net.Indyuce.mmoitems.particle.api.ParticleRunnable;
|
||||
@ -85,7 +85,7 @@ public class PlayerData {
|
||||
private Set<AbilityData> itemAbilities = new HashSet<>();
|
||||
|
||||
private SetBonuses setBonuses = null;
|
||||
private PlayerStats stats = new PlayerStats(this);
|
||||
private final PlayerStats stats;
|
||||
|
||||
private boolean fullHands = false;
|
||||
|
||||
@ -94,6 +94,7 @@ public class PlayerData {
|
||||
private PlayerData(Player player) {
|
||||
this.offline = player;
|
||||
setPlayer(player);
|
||||
stats = new PlayerStats(this);
|
||||
|
||||
load(new ConfigFile("/userdata", getUniqueId().toString()).getConfig());
|
||||
updateInventory();
|
||||
@ -146,8 +147,7 @@ public class PlayerData {
|
||||
|
||||
public void checkForInventoryUpdate() {
|
||||
PlayerInventory inv = player.getInventory();
|
||||
if (!equals(helmet, inv.getHelmet()) || !equals(chestplate, inv.getChestplate()) || !equals(leggings, inv.getLeggings()) || !equals(boots, inv.getBoots())
|
||||
|| !equals(hand, inv.getItemInMainHand()) || !equals(offhand, inv.getItemInOffHand()))
|
||||
if (!equals(helmet, inv.getHelmet()) || !equals(chestplate, inv.getChestplate()) || !equals(leggings, inv.getLeggings()) || !equals(boots, inv.getBoots()) || !equals(hand, inv.getItemInMainHand()) || !equals(offhand, inv.getItemInOffHand()))
|
||||
updateInventory();
|
||||
}
|
||||
|
||||
@ -172,8 +172,7 @@ public class PlayerData {
|
||||
public boolean areHandsFull() {
|
||||
NBTItem main = MMOLib.plugin.getNMS().getNBTItem(player.getInventory().getItemInMainHand());
|
||||
NBTItem off = MMOLib.plugin.getNMS().getNBTItem(player.getInventory().getItemInOffHand());
|
||||
return (main.getBoolean("MMOITEMS_TWO_HANDED") && (off.getItem() != null && off.getItem().getType() != Material.AIR))
|
||||
|| (off.getBoolean("MMOITEMS_TWO_HANDED") && (main.getItem() != null && main.getItem().getType() != Material.AIR));
|
||||
return (main.getBoolean("MMOITEMS_TWO_HANDED") && (off.getItem() != null && off.getItem().getType() != Material.AIR)) || (off.getBoolean("MMOITEMS_TWO_HANDED") && (main.getItem() != null && main.getItem().getType() != Material.AIR));
|
||||
}
|
||||
|
||||
public void updateInventory() {
|
||||
@ -245,7 +244,9 @@ public class PlayerData {
|
||||
* apply abilities
|
||||
*/
|
||||
if (item.hasData(ItemStat.ABILITIES)) {
|
||||
// if the item with the abilities is in the players offhand AND its disabled in the config then just move on, else add the ability
|
||||
// if the item with the abilities is in the players offhand AND
|
||||
// its disabled in the config then just move on, else add the
|
||||
// ability
|
||||
if (item.getNBTItem().getItem().equals(player.getInventory().getItemInOffHand()) && MMOItems.plugin.getConfig().getBoolean("disable-abilities-in-offhand")) {
|
||||
continue;
|
||||
} else
|
||||
@ -357,7 +358,7 @@ public class PlayerData {
|
||||
return castAbilities(getStats().newTemporary(), target, result, castMode);
|
||||
}
|
||||
|
||||
public ItemAttackResult castAbilities(TemporaryStats stats, LivingEntity target, ItemAttackResult result, CastingMode castMode) {
|
||||
public ItemAttackResult castAbilities(CachedStats stats, LivingEntity target, ItemAttackResult result, CastingMode castMode) {
|
||||
if (target == null) {
|
||||
if (!MMOItems.plugin.getFlags().isFlagAllowed(player, CustomFlag.MI_ABILITIES))
|
||||
return result.setSuccessful(false);
|
||||
@ -387,7 +388,7 @@ public class PlayerData {
|
||||
cast(getStats().newTemporary(), null, new ItemAttackResult(true, DamageType.SKILL), data, true);
|
||||
}
|
||||
|
||||
public void cast(TemporaryStats stats, LivingEntity target, ItemAttackResult result, AbilityData ability, boolean message) {
|
||||
public void cast(CachedStats stats, LivingEntity target, ItemAttackResult result, AbilityData ability, boolean message) {
|
||||
AbilityUseEvent event = new AbilityUseEvent(this, ability, target);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
@ -437,8 +438,7 @@ public class PlayerData {
|
||||
*/
|
||||
public void applyCooldown(CooldownType type, double value) {
|
||||
String mitigation;
|
||||
long extra = (long) (1000
|
||||
* (type.isMitigation() ? getMitigationCooldown(mitigation = type.name().toLowerCase()) * (1 - Math.min(getMaxMitigationCooldownReduction(mitigation), value) / 100) : value));
|
||||
long extra = (long) (1000 * (type.isMitigation() ? getMitigationCooldown(mitigation = type.name().toLowerCase()) * (1 - Math.min(getMaxMitigationCooldownReduction(mitigation), value) / 100) : value));
|
||||
extraCooldowns.put(type, System.currentTimeMillis() + extra);
|
||||
}
|
||||
|
||||
|
@ -1,34 +1,28 @@
|
||||
package net.Indyuce.mmoitems.api.player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.attribute.AttributeModifier.Operation;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.item.MMOItem;
|
||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.api.stat.StatInstance;
|
||||
import net.mmogroup.mmolib.api.stat.StatMap;
|
||||
|
||||
public class PlayerStats {
|
||||
private final PlayerData playerData;
|
||||
|
||||
private final Map<String, StatInstance> stats = new HashMap<>();
|
||||
private final StatMap map;
|
||||
|
||||
/*
|
||||
* This is not a player data class. This class is used to temporarily save
|
||||
* player stats in case of runnable-skills or item effects. This is to
|
||||
* prevent player stats from changing when skills/effects are not INSTANTLY
|
||||
* cast.
|
||||
*/
|
||||
public PlayerStats(PlayerData playerData) {
|
||||
this.playerData = playerData;
|
||||
|
||||
map = StatMap.get(playerData.getPlayer());
|
||||
map.getPlayerData().setMMOItems(playerData);
|
||||
}
|
||||
|
||||
public PlayerData getPlayerData() {
|
||||
@ -36,14 +30,14 @@ public class PlayerStats {
|
||||
}
|
||||
|
||||
public void update() {
|
||||
stats.values().forEach(ins -> {
|
||||
map.getInstances().forEach(ins -> {
|
||||
ins.remove("item");
|
||||
ins.remove("fullSetBonus");
|
||||
});
|
||||
|
||||
if (playerData.hasSetBonuses())
|
||||
for (Entry<ItemStat, Double> entry : playerData.getSetBonuses().getStats())
|
||||
getInstance(entry.getKey()).set("fullSetBonus", entry.getValue());
|
||||
getInstance(entry.getKey()).addModifier("fullSetBonus", entry.getValue());
|
||||
|
||||
for (ItemStat stat : MMOItems.plugin.getStats().getDoubleStats()) {
|
||||
double t = 0;
|
||||
@ -52,10 +46,8 @@ public class PlayerStats {
|
||||
t += item.getNBTItem().getStat(stat.getId());
|
||||
|
||||
if (t != 0)
|
||||
getInstance(stat).set("item", t);
|
||||
getInstance(stat).addModifier("item", t + (stat instanceof AttributeStat ? -((AttributeStat) stat).getOffset() : 0 ));
|
||||
}
|
||||
|
||||
updateAttributeModifiers();
|
||||
}
|
||||
|
||||
public double getStat(ItemStat stat) {
|
||||
@ -63,44 +55,34 @@ public class PlayerStats {
|
||||
}
|
||||
|
||||
public StatInstance getInstance(ItemStat stat) {
|
||||
if (stats.containsKey(stat.getId()))
|
||||
return stats.get(stat.getId());
|
||||
|
||||
StatInstance ins = new StatInstance();
|
||||
stats.put(stat.getId(), ins);
|
||||
return ins;
|
||||
return map.getInstance(stat.getId());
|
||||
}
|
||||
|
||||
public void updateAttributeModifiers() {
|
||||
for (AttributeStat stat : MMOItems.plugin.getStats().getAttributeStats()) {
|
||||
AttributeInstance ins = playerData.getPlayer().getAttribute(stat.getAttribute());
|
||||
removeAttributeModifiers(ins);
|
||||
// public void updateAttributeModifiers() {
|
||||
// for (AttributeStat stat : MMOItems.plugin.getStats().getAttributeStats()) {
|
||||
// AttributeInstance ins = playerData.getPlayer().getAttribute(stat.getAttribute());
|
||||
// removeAttributeModifiers(ins);
|
||||
//
|
||||
// double value = getStat(stat);
|
||||
// if (value != 0)
|
||||
// ins.addModifier(new AttributeModifier(UUID.randomUUID(), "mmoitems." + stat.getId(), value - stat.getOffset(), Operation.ADD_NUMBER));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void removeAttributeModifiers(AttributeInstance ins) {
|
||||
// for (Iterator<AttributeModifier> iterator = ins.getModifiers().iterator(); iterator.hasNext();) {
|
||||
// AttributeModifier attribute = iterator.next();
|
||||
// if (attribute.getName().startsWith("mmoitems."))
|
||||
// ins.removeModifier(attribute);
|
||||
// }
|
||||
// }
|
||||
|
||||
double value = getStat(stat);
|
||||
if (value != 0)
|
||||
ins.addModifier(new AttributeModifier(UUID.randomUUID(), "mmoitems." + stat.getId(), value - stat.getOffset(), Operation.ADD_NUMBER));
|
||||
}
|
||||
public CachedStats newTemporary() {
|
||||
return new CachedStats();
|
||||
}
|
||||
|
||||
private void removeAttributeModifiers(AttributeInstance ins) {
|
||||
for (Iterator<AttributeModifier> iterator = ins.getModifiers().iterator(); iterator.hasNext();) {
|
||||
AttributeModifier attribute = iterator.next();
|
||||
if (attribute.getName().startsWith("mmoitems."))
|
||||
ins.removeModifier(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
public TemporaryStats newTemporary() {
|
||||
return new TemporaryStats();
|
||||
}
|
||||
|
||||
private Map<String, Double> mapCurrentStats() {
|
||||
Map<String, Double> map = new HashMap<>();
|
||||
stats.forEach((id, ins) -> map.put(id, ins.getTotal()));
|
||||
return map;
|
||||
}
|
||||
|
||||
public class TemporaryStats {
|
||||
public class CachedStats {
|
||||
|
||||
/*
|
||||
* this field is made final so even when the player logs out, the
|
||||
@ -108,11 +90,13 @@ public class PlayerStats {
|
||||
* not to add a safe check in every ability loop.
|
||||
*/
|
||||
private final Player player;
|
||||
private final Map<String, Double> temp;
|
||||
|
||||
private final Map<String, Double> stats = new HashMap<>();
|
||||
|
||||
public TemporaryStats() {
|
||||
temp = mapCurrentStats();
|
||||
public CachedStats() {
|
||||
player = playerData.getPlayer();
|
||||
for (StatInstance ins : map.getInstances())
|
||||
this.stats.put(ins.getStat(), ins.getTotal());
|
||||
}
|
||||
|
||||
public PlayerData getPlayerData() {
|
||||
@ -124,42 +108,12 @@ public class PlayerStats {
|
||||
}
|
||||
|
||||
public double getStat(ItemStat stat) {
|
||||
return temp.containsKey(stat.getId()) ? temp.get(stat.getId()) : 0;
|
||||
return stats.containsKey(stat.getId()) ? stats.get(stat.getId()) : 0;
|
||||
}
|
||||
|
||||
public boolean hasStat(ItemStat stat) {
|
||||
return temp.containsKey(stat.getId());
|
||||
}
|
||||
|
||||
public void setStat(ItemStat stat, double value) {
|
||||
temp.put(stat.getId(), value);
|
||||
}
|
||||
}
|
||||
|
||||
public class StatInstance {
|
||||
private final Map<String, Double> extra = new HashMap<>();
|
||||
|
||||
public double getTotal() {
|
||||
double t = 0;
|
||||
for (double d : extra.values())
|
||||
t += d;
|
||||
return t;
|
||||
}
|
||||
|
||||
public double get(String source) {
|
||||
return extra.get(source);
|
||||
}
|
||||
|
||||
public void set(String source, double value) {
|
||||
extra.put(source, value);
|
||||
}
|
||||
|
||||
public void remove(String source) {
|
||||
extra.remove(source);
|
||||
}
|
||||
|
||||
public boolean has(String source) {
|
||||
return extra.containsKey(source);
|
||||
stats.put(stat.getId(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.comp;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.mmogroup.mmolib.comp.Metrics;
|
||||
|
||||
public class MMOItemsMetrics extends Metrics {
|
||||
public MMOItemsMetrics() {
|
||||
|
@ -1,710 +0,0 @@
|
||||
package net.Indyuce.mmoitems.comp;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
/**
|
||||
* bStats collects some data for plugin authors.
|
||||
*
|
||||
* Check out https://bStats.org/ to learn more about bStats!
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Metrics {
|
||||
|
||||
static {
|
||||
// You can use the property to disable the check in your test
|
||||
// environment
|
||||
if (System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) {
|
||||
// Maven's Relocate is clever and changes strings, too. So we have
|
||||
// to use this little "trick" ... :D
|
||||
final String defaultPackage = new String(new byte[] { 'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't' });
|
||||
final String examplePackage = new String(new byte[] { 'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e' });
|
||||
// We want to make sure nobody just copy & pastes the example and
|
||||
// use the wrong package names
|
||||
if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) {
|
||||
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The version of this bStats class
|
||||
public static final int B_STATS_VERSION = 1;
|
||||
|
||||
// The url to which the data is sent
|
||||
private static final String URL = "https://bStats.org/submitData/bukkit";
|
||||
|
||||
// Should failed requests be logged?
|
||||
private static boolean logFailedRequests;
|
||||
|
||||
// The uuid of the server
|
||||
private static String serverUUID;
|
||||
|
||||
// The plugin
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
// A list with all custom charts
|
||||
private final List<CustomChart> charts = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param plugin
|
||||
* The plugin which stats should be submitted.
|
||||
*/
|
||||
public Metrics(JavaPlugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null!");
|
||||
}
|
||||
this.plugin = plugin;
|
||||
|
||||
// Get the config file
|
||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
File configFile = new File(bStatsFolder, "config.yml");
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
// Check if the config file exists
|
||||
if (!config.isSet("serverUuid")) {
|
||||
|
||||
// Add default values
|
||||
config.addDefault("enabled", true);
|
||||
// Every server gets it's unique random id.
|
||||
config.addDefault("serverUuid", UUID.randomUUID().toString());
|
||||
// Should failed request be logged?
|
||||
config.addDefault("logFailedRequests", false);
|
||||
|
||||
// Inform the server owners about bStats
|
||||
config.options().header("bStats collects some data for plugin authors like how many servers are using their plugins.\n" + "To honor their work, you should not disable it.\n" + "This has nearly no effect on the server performance!\n" + "Check out https://bStats.org/ to learn more :)").copyDefaults(true);
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
// Load the data
|
||||
serverUUID = config.getString("serverUuid");
|
||||
logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
if (config.getBoolean("enabled", true)) {
|
||||
boolean found = false;
|
||||
// Search for all other bStats Metrics classes to see if we are the
|
||||
// first one
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
found = true; // We aren't the first
|
||||
break;
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
}
|
||||
}
|
||||
// Register our service
|
||||
Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
|
||||
if (!found) {
|
||||
// We are the first!
|
||||
startSubmitting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom chart.
|
||||
*
|
||||
* @param chart
|
||||
* The chart to add.
|
||||
*/
|
||||
public void addCustomChart(CustomChart chart) {
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Chart cannot be null!");
|
||||
}
|
||||
charts.add(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Scheduler which submits our data every 30 minutes.
|
||||
*/
|
||||
private void startSubmitting() {
|
||||
final Timer timer = new Timer(true); // We use a timer cause the Bukkit
|
||||
// scheduler is affected by
|
||||
// server lags
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!plugin.isEnabled()) { // Plugin was disabled
|
||||
timer.cancel();
|
||||
return;
|
||||
}
|
||||
// Nevertheless we want our code to run in the Bukkit main
|
||||
// thread, so we have to use the Bukkit scheduler
|
||||
// Don't be afraid! The connection to the bStats server is still
|
||||
// async, only the stats collection is sync ;)
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
submitData();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 1000 * 60 * 5, 1000 * 60 * 30);
|
||||
// Submit the data every 30 minutes, first time after 5 minutes to give
|
||||
// other plugins enough time to start
|
||||
// WARNING: Changing the frequency has no effect but your plugin WILL be
|
||||
// blocked/deleted!
|
||||
// WARNING: Just don't do it!
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the plugin specific data. This method is called using Reflection.
|
||||
*
|
||||
* @return The plugin specific data.
|
||||
*/
|
||||
public JSONObject getPluginData() {
|
||||
JSONObject data = new JSONObject();
|
||||
|
||||
String pluginName = plugin.getDescription().getName();
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
|
||||
data.put("pluginName", pluginName); // Append the name of the plugin
|
||||
data.put("pluginVersion", pluginVersion); // Append the version of the
|
||||
// plugin
|
||||
JSONArray customCharts = new JSONArray();
|
||||
for (CustomChart customChart : charts) {
|
||||
// Add the data of the custom charts
|
||||
JSONObject chart = customChart.getRequestJsonObject();
|
||||
if (chart == null) { // If the chart is null, we skip it
|
||||
continue;
|
||||
}
|
||||
customCharts.add(chart);
|
||||
}
|
||||
data.put("customCharts", customCharts);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server specific data.
|
||||
*
|
||||
* @return The server specific data.
|
||||
*/
|
||||
private JSONObject getServerData() {
|
||||
// Minecraft specific data
|
||||
int playerAmount;
|
||||
try {
|
||||
// Around MC 1.8 the return type was changed to a collection from an
|
||||
// array,
|
||||
// This fixes java.lang.NoSuchMethodError:
|
||||
// org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
|
||||
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
|
||||
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class) ? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size() : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
|
||||
} catch (Exception e) {
|
||||
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new
|
||||
// method if the
|
||||
// Reflection
|
||||
// failed
|
||||
}
|
||||
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||
String bukkitVersion = org.bukkit.Bukkit.getVersion();
|
||||
bukkitVersion = bukkitVersion.substring(bukkitVersion.indexOf("MC: ") + 4, bukkitVersion.length() - 1);
|
||||
|
||||
// OS/Java specific data
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
String osName = System.getProperty("os.name");
|
||||
String osArch = System.getProperty("os.arch");
|
||||
String osVersion = System.getProperty("os.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
|
||||
data.put("serverUUID", serverUUID);
|
||||
|
||||
data.put("playerAmount", playerAmount);
|
||||
data.put("onlineMode", onlineMode);
|
||||
data.put("bukkitVersion", bukkitVersion);
|
||||
|
||||
data.put("javaVersion", javaVersion);
|
||||
data.put("osName", osName);
|
||||
data.put("osArch", osArch);
|
||||
data.put("osVersion", osVersion);
|
||||
data.put("coreCount", coreCount);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the data and sends it afterwards.
|
||||
*/
|
||||
private void submitData() {
|
||||
final JSONObject data = getServerData();
|
||||
|
||||
JSONArray pluginData = new JSONArray();
|
||||
// Search for all other bStats Metrics classes to get their plugin data
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
|
||||
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
|
||||
try {
|
||||
pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
|
||||
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
|
||||
}
|
||||
}
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
data.put("plugins", pluginData);
|
||||
|
||||
// Create a new thread for the connection to the bStats server
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// Send the data
|
||||
sendData(data);
|
||||
} catch (Exception e) {
|
||||
// Something went wrong! :(
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the data to the bStats server.
|
||||
*
|
||||
* @param data
|
||||
* The data to send.
|
||||
* @throws Exception
|
||||
* If the request failed.
|
||||
*/
|
||||
private static void sendData(JSONObject data) throws Exception {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Data cannot be null!");
|
||||
}
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
throw new IllegalAccessException("This method must not be called from the main thread!");
|
||||
}
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
|
||||
|
||||
// Compress the data to save bandwidth
|
||||
byte[] compressedData = compress(data.toString());
|
||||
|
||||
// Add headers
|
||||
connection.setRequestMethod("POST");
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip
|
||||
// our
|
||||
// request
|
||||
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
|
||||
connection.setRequestProperty("Content-Type", "application/json"); // We
|
||||
// send
|
||||
// our
|
||||
// data
|
||||
// in
|
||||
// JSON
|
||||
// format
|
||||
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
|
||||
|
||||
// Send data
|
||||
connection.setDoOutput(true);
|
||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||
outputStream.write(compressedData);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
|
||||
connection.getInputStream().close(); // We don't care about the response
|
||||
// - Just send our data :)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gzips the given String.
|
||||
*
|
||||
* @param str
|
||||
* The string to gzip.
|
||||
* @return The gzipped String.
|
||||
* @throws IOException
|
||||
* If the compression failed.
|
||||
*/
|
||||
private static byte[] compress(final String str) throws IOException {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
|
||||
gzip.write(str.getBytes("UTF-8"));
|
||||
gzip.close();
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom chart.
|
||||
*/
|
||||
public static abstract class CustomChart {
|
||||
|
||||
// The id of the chart
|
||||
final String chartId;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId
|
||||
* The id of the chart.
|
||||
*/
|
||||
CustomChart(String chartId) {
|
||||
if (chartId == null || chartId.isEmpty()) {
|
||||
throw new IllegalArgumentException("ChartId cannot be null or empty!");
|
||||
}
|
||||
this.chartId = chartId;
|
||||
}
|
||||
|
||||
private JSONObject getRequestJsonObject() {
|
||||
JSONObject chart = new JSONObject();
|
||||
chart.put("chartId", chartId);
|
||||
try {
|
||||
JSONObject data = getChartData();
|
||||
if (data == null) {
|
||||
// If the data is null we don't send the chart.
|
||||
return null;
|
||||
}
|
||||
chart.put("data", data);
|
||||
} catch (Throwable t) {
|
||||
if (logFailedRequests) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return chart;
|
||||
}
|
||||
|
||||
protected abstract JSONObject getChartData() throws Exception;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom simple pie.
|
||||
*/
|
||||
public static class SimplePie extends CustomChart {
|
||||
|
||||
private final Callable<String> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId
|
||||
* The id of the chart.
|
||||
* @param callable
|
||||
* The callable which is used to request the chart data.
|
||||
*/
|
||||
public SimplePie(String chartId, Callable<String> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
String value = callable.call();
|
||||
if (value == null || value.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("value", value);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom advanced pie.
|
||||
*/
|
||||
public static class AdvancedPie extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId
|
||||
* The id of the chart.
|
||||
* @param callable
|
||||
* The callable which is used to request the chart data.
|
||||
*/
|
||||
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom drilldown pie.
|
||||
*/
|
||||
public static class DrilldownPie extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Map<String, Integer>>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId
|
||||
* The id of the chart.
|
||||
* @param callable
|
||||
* The callable which is used to request the chart data.
|
||||
*/
|
||||
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
Map<String, Map<String, Integer>> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean reallyAllSkipped = true;
|
||||
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
|
||||
JSONObject value = new JSONObject();
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
|
||||
value.put(valueEntry.getKey(), valueEntry.getValue());
|
||||
allSkipped = false;
|
||||
}
|
||||
if (!allSkipped) {
|
||||
reallyAllSkipped = false;
|
||||
values.put(entryValues.getKey(), value);
|
||||
}
|
||||
}
|
||||
if (reallyAllSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom single line chart.
|
||||
*/
|
||||
public static class SingleLineChart extends CustomChart {
|
||||
|
||||
private final Callable<Integer> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId
|
||||
* The id of the chart.
|
||||
* @param callable
|
||||
* The callable which is used to request the chart data.
|
||||
*/
|
||||
public SingleLineChart(String chartId, Callable<Integer> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
int value = callable.call();
|
||||
if (value == 0) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("value", value);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom multi line chart.
|
||||
*/
|
||||
public static class MultiLineChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId
|
||||
* The id of the chart.
|
||||
* @param callable
|
||||
* The callable which is used to request the chart data.
|
||||
*/
|
||||
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom simple bar chart.
|
||||
*/
|
||||
public static class SimpleBarChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId
|
||||
* The id of the chart.
|
||||
* @param callable
|
||||
* The callable which is used to request the chart data.
|
||||
*/
|
||||
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
JSONArray categoryValues = new JSONArray();
|
||||
categoryValues.add(entry.getValue());
|
||||
values.put(entry.getKey(), categoryValues);
|
||||
}
|
||||
data.put("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom advanced bar chart.
|
||||
*/
|
||||
public static class AdvancedBarChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, int[]>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId
|
||||
* The id of the chart.
|
||||
* @param callable
|
||||
* The callable which is used to request the chart data.
|
||||
*/
|
||||
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
Map<String, int[]> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, int[]> entry : map.entrySet()) {
|
||||
if (entry.getValue().length == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
JSONArray categoryValues = new JSONArray();
|
||||
for (int categoryValue : entry.getValue()) {
|
||||
categoryValues.add(categoryValue);
|
||||
}
|
||||
values.put(entry.getKey(), categoryValues);
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user