Search in sources :

Example 1 with ComboCompletedEvent

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));
}
Also used : KeyStreak(net.laboulangerie.laboulangeriemmo.core.combo.KeyStreak) ComboCompletedEvent(net.laboulangerie.laboulangeriemmo.events.ComboCompletedEvent) ItemStack(org.bukkit.inventory.ItemStack)

Example 2 with ComboCompletedEvent

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();
    }
}
Also used : BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ComboCompletedEvent(net.laboulangerie.laboulangeriemmo.events.ComboCompletedEvent)

Example 3 with ComboCompletedEvent

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);
    });
}
Also used : EventHandler(org.bukkit.event.EventHandler) MmoPlayer(net.laboulangerie.laboulangeriemmo.player.MmoPlayer) PlayerItemConsumeEvent(org.bukkit.event.player.PlayerItemConsumeEvent) BlockBreakEvent(org.bukkit.event.block.BlockBreakEvent) Player(org.bukkit.entity.Player) ComboCompletedEvent(net.laboulangerie.laboulangeriemmo.events.ComboCompletedEvent) PlayerInteractEvent(org.bukkit.event.player.PlayerInteractEvent) LaBoulangerieMmo(net.laboulangerie.laboulangeriemmo.LaBoulangerieMmo) PlayerInteractEntityEvent(org.bukkit.event.player.PlayerInteractEntityEvent) BlockPlaceEvent(org.bukkit.event.block.BlockPlaceEvent) EntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent) Listener(org.bukkit.event.Listener) MmoPlayer(net.laboulangerie.laboulangeriemmo.player.MmoPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 4 with ComboCompletedEvent

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);
}
Also used : Player(org.bukkit.entity.Player) PotionEffect(org.bukkit.potion.PotionEffect) ComboCompletedEvent(net.laboulangerie.laboulangeriemmo.events.ComboCompletedEvent)

Example 5 with ComboCompletedEvent

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);
}
Also used : EntityHuman(net.minecraft.world.entity.player.EntityHuman) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) Player(org.bukkit.entity.Player) ComboCompletedEvent(net.laboulangerie.laboulangeriemmo.events.ComboCompletedEvent) Vector(org.bukkit.util.Vector)

Aggregations

ComboCompletedEvent (net.laboulangerie.laboulangeriemmo.events.ComboCompletedEvent)5 Player (org.bukkit.entity.Player)3 LaBoulangerieMmo (net.laboulangerie.laboulangeriemmo.LaBoulangerieMmo)1 KeyStreak (net.laboulangerie.laboulangeriemmo.core.combo.KeyStreak)1 MmoPlayer (net.laboulangerie.laboulangeriemmo.player.MmoPlayer)1 EntityHuman (net.minecraft.world.entity.player.EntityHuman)1 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)1 EventHandler (org.bukkit.event.EventHandler)1 Listener (org.bukkit.event.Listener)1 BlockBreakEvent (org.bukkit.event.block.BlockBreakEvent)1 BlockPlaceEvent (org.bukkit.event.block.BlockPlaceEvent)1 EntityDamageByEntityEvent (org.bukkit.event.entity.EntityDamageByEntityEvent)1 PlayerInteractEntityEvent (org.bukkit.event.player.PlayerInteractEntityEvent)1 PlayerInteractEvent (org.bukkit.event.player.PlayerInteractEvent)1 PlayerItemConsumeEvent (org.bukkit.event.player.PlayerItemConsumeEvent)1 ItemStack (org.bukkit.inventory.ItemStack)1 PotionEffect (org.bukkit.potion.PotionEffect)1 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)1 Vector (org.bukkit.util.Vector)1