use of net.laboulangerie.laboulangeriemmo.events.ComboCompletedEvent in project LaBoulangerieMmo by LaBoulangerie.
the class FastMine method shouldTrigger.
@Override
public boolean shouldTrigger(Event baseEvent) {
ComboCompletedEvent event = (ComboCompletedEvent) baseEvent;
ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
return item != null && (item.getType() == Material.NETHERITE_PICKAXE || item.getType() == Material.DIAMOND_PICKAXE || item.getType() == Material.IRON_PICKAXE) && event.getKeyStreak().match(new KeyStreak(ComboKey.LEFT, ComboKey.LEFT, ComboKey.LEFT));
}
use of net.laboulangerie.laboulangeriemmo.events.ComboCompletedEvent in project LaBoulangerieMmo by LaBoulangerie.
the class ComboDispatcher method handleKey.
private void handleKey(Player player, ComboKey key) {
if (!LaBoulangerieMmo.PLUGIN.getMmoPlayerManager().getPlayer(player).hasEnabledCombo())
return;
KeyStreak streak = comboStreaks.get(player);
if (streak == null) {
streak = new KeyStreak();
comboStreaks.put(player, streak);
}
BukkitRunnable timer = new BukkitRunnable() {
@Override
public void run() {
// Fail the streak if there is no new key during 10 ticks
comboStreaks.get(player).fail();
}
};
timer.runTaskLaterAsynchronously(LaBoulangerieMmo.PLUGIN, 10);
// A streak is full when there is 3 keys in it
boolean isFull = streak.addKey(key, timer);
player.sendActionBar(Component.text("§6" + streak.getKeyQueue().stream().map(Object::toString).collect(Collectors.joining(" §r-§6 "))));
if (isFull) {
Bukkit.getPluginManager().callEvent(new ComboCompletedEvent(player, streak));
// the combo didn't fail but we use that to empty it
streak.fail();
}
}
use of net.laboulangerie.laboulangeriemmo.events.ComboCompletedEvent in project LaBoulangerieMmo by LaBoulangerie.
the class AbilitiesManager method onComboCompleted.
@EventHandler
public void onComboCompleted(ComboCompletedEvent event) {
MmoPlayer player = LaBoulangerieMmo.PLUGIN.getMmoPlayerManager().getPlayer(event.getPlayer());
Abilities.supplier().get().filter(x -> x.getExecutor().getAbilityTrigger() == AbilityTrigger.COMBO && player.canUseAbility(x) && x.getExecutor().shouldTrigger(event)).forEach(x -> {
x.getExecutor().trigger(event, player.getTalent(x.getParentTalent()).getLevel(LaBoulangerieMmo.XP_MULTIPLIER));
player.useAbility(x);
});
}
use of net.laboulangerie.laboulangeriemmo.events.ComboCompletedEvent in project LaBoulangerieMmo by LaBoulangerie.
the class FastMine method trigger.
@Override
public void trigger(Event baseEvent, int level) {
ComboCompletedEvent event = (ComboCompletedEvent) baseEvent;
Player player = event.getPlayer();
int duration = 0;
int amplifier = 0;
if (level >= 75) {
duration = 300;
amplifier = 3;
} else if (level >= 45) {
duration = 60;
amplifier = 2;
} else {
duration = 20;
amplifier = 1;
}
player.sendMessage("§eVous gagnez Haste " + (amplifier + 1) + " pendant " + duration + " secondes");
player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, duration * 20, amplifier, true));
EffectRegistry.playEffect("default", player);
}
use of net.laboulangerie.laboulangeriemmo.events.ComboCompletedEvent in project LaBoulangerieMmo by LaBoulangerie.
the class Dodging method trigger.
@Override
public void trigger(Event baseEvent, int level) {
ComboCompletedEvent event = (ComboCompletedEvent) baseEvent;
Player player = event.getPlayer();
EntityHuman human = (EntityHuman) ((CraftPlayer) event.getPlayer()).getHandle();
/**
* See ItemTrident.java in craftbukkit or TridentItem.java in paper
* Mapping:
* k -> power (originally the riptide level)
* f -> yRot
* f1 -> xRot
*/
float power = 1;
float yRot = human.getYRot();
float xRot = human.getXRot();
float f2 = -MathHelper.sin(yRot * 0.017453292F) * MathHelper.cos(xRot * 0.017453292F);
float f3 = -MathHelper.sin(xRot * 0.017453292F);
float f4 = MathHelper.cos(yRot * 0.017453292F) * MathHelper.cos(xRot * 0.017453292F);
float f5 = MathHelper.c(f2 * f2 + f3 * f3 + f4 * f4);
float f6 = 3.0F * ((1.0F + power) / 4.0F);
f2 *= f6 / f5;
f3 *= f6 / f5;
f4 *= f6 / f5;
// human.i((double) f2, (double) f3, (double) f4); // = human.push doesn't work
// but next line replaced it maybe try again in 1.18
player.setVelocity(new Vector((double) f2, (double) f3, (double) f4));
human.s(20);
player.getWorld().playSound(player.getLocation(), Sound.ITEM_TRIDENT_RIPTIDE_1, 1, 1);
}
Aggregations