Search in sources :

Example 1 with KitEvent

use of de.hglabor.plugins.kitapi.kit.events.KitEvent in project kit-api by HGLabor.

the class FahrradKit method onPlayerLeftClickKitItem.

@KitEvent
public void onPlayerLeftClickKitItem(PlayerInteractEvent event, KitPlayer kitPlayer) {
    Player player = event.getPlayer();
    if (player.isInsideVehicle()) {
        player.sendMessage(ChatColor.RED + "Du befindest dich bereits in einem Fahrzeug");
        return;
    }
    BukkitUtils.playSound(player, Sound.BLOCK_CHAIN_PLACE);
    Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class);
    horse.setOwner(player);
    horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
    horse.setCustomName("Fahrrad von " + player.getName());
    horse.setCustomNameVisible(true);
    horse.setMetadata(fahrradOwner, new FixedMetadataValue(KitApi.getInstance().getPlugin(), player.getUniqueId()));
    kitPlayer.putKitAttribute(fahrradId, horse.getUniqueId());
    horse.addPassenger(player);
}
Also used : Player(org.bukkit.entity.Player) KitPlayer(de.hglabor.plugins.kitapi.player.KitPlayer) Horse(org.bukkit.entity.Horse) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) ItemStack(org.bukkit.inventory.ItemStack) KitEvent(de.hglabor.plugins.kitapi.kit.events.KitEvent)

Example 2 with KitEvent

use of de.hglabor.plugins.kitapi.kit.events.KitEvent in project kit-api by HGLabor.

the class FalcoKit method onPlayerRightClickKitItem.

@KitEvent
@Override
public void onPlayerRightClickKitItem(PlayerInteractEvent event, KitPlayer kitPlayer) {
    kitPlayer.getBukkitPlayer().ifPresent(it -> {
        Phantom phantom = it.getWorld().spawn(it.getLocation(), Phantom.class);
        phantom.setShouldBurnInDay(false);
        phantom.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 25, false, false));
        phantom.setVelocity(it.getLocation().getDirection().multiply(2));
        AtomicInteger tick = new AtomicInteger();
        Bukkit.getScheduler().runTaskLater(KitApi.getInstance().getPlugin(), () -> {
            phantom.getWorld().playSound(phantom.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1f, 10f);
        }, 40);
        Bukkit.getScheduler().runTaskTimer(KitApi.getInstance().getPlugin(), task -> {
            tick.getAndIncrement();
            if (tick.get() == flashDuration) {
                task.cancel();
                phantom.remove();
            } else {
                for (Entity nearby : phantom.getNearbyEntities(flashRadius, flashRadius, flashRadius)) {
                    nearby.getWorld().spawnParticle(Particle.FLASH, nearby.getLocation().clone().add(0, 1, 0), 0);
                }
            }
        }, 40, 1);
    });
    kitPlayer.activateKitCooldown(this);
}
Also used : Entity(org.bukkit.entity.Entity) PotionEffect(org.bukkit.potion.PotionEffect) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Phantom(org.bukkit.entity.Phantom) KitEvent(de.hglabor.plugins.kitapi.kit.events.KitEvent)

Example 3 with KitEvent

use of de.hglabor.plugins.kitapi.kit.events.KitEvent in project kit-api by HGLabor.

the class FrostyKit method onPlayerMoveEvent.

@KitEvent
@Override
public void onPlayerMoveEvent(PlayerMoveEvent event, KitPlayer kitPlayer) {
    Player player = event.getPlayer();
    Material type = player.getLocation().clone().subtract(0, 1, 0).getBlock().getType();
    if (type == Material.SNOW_BLOCK || type == Material.SNOW) {
        player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20, potionAmpflier));
        player.setFreezeTicks(60);
    }
}
Also used : KitPlayer(de.hglabor.plugins.kitapi.player.KitPlayer) Player(org.bukkit.entity.Player) PotionEffect(org.bukkit.potion.PotionEffect) Material(org.bukkit.Material) KitEvent(de.hglabor.plugins.kitapi.kit.events.KitEvent)

Example 4 with KitEvent

use of de.hglabor.plugins.kitapi.kit.events.KitEvent in project kit-api by HGLabor.

the class GamblerKit method onPlayerRightClickKitItem.

@KitEvent
@Override
public void onPlayerRightClickKitItem(PlayerInteractEvent event, KitPlayer kitPlayer) {
    Player player = event.getPlayer();
    int tick = 2;
    kitPlayer.activateKitCooldown(this);
    GambleWin gambleWin = new GambleWin(kitPlayer, player, 3, tick);
    kitPlayer.putKitAttribute(attributeKey, gambleWin);
    gambleWin.runTaskTimer(KitApi.getInstance().getPlugin(), 0, tick);
}
Also used : KitPlayer(de.hglabor.plugins.kitapi.player.KitPlayer) KitEvent(de.hglabor.plugins.kitapi.kit.events.KitEvent)

Example 5 with KitEvent

use of de.hglabor.plugins.kitapi.kit.events.KitEvent in project kit-api by HGLabor.

the class GhostKit method onPlayerMoveEvent.

@KitEvent(ignoreCooldown = true)
@Override
public void onPlayerMoveEvent(PlayerMoveEvent event, KitPlayer kitPlayer) {
    if (kitPlayer.getKitAttributeOrDefault(isGhostModeKey, false)) {
        Player player = event.getPlayer();
        player.getWorld().spawnParticle(this.particle, player.getLocation(), this.trailParticleAmount);
    }
}
Also used : KitPlayer(de.hglabor.plugins.kitapi.player.KitPlayer) Player(org.bukkit.entity.Player) KitEvent(de.hglabor.plugins.kitapi.kit.events.KitEvent)

Aggregations

KitEvent (de.hglabor.plugins.kitapi.kit.events.KitEvent)81 KitPlayer (de.hglabor.plugins.kitapi.player.KitPlayer)67 Player (org.bukkit.entity.Player)62 PotionEffect (org.bukkit.potion.PotionEffect)18 Block (org.bukkit.block.Block)16 ItemStack (org.bukkit.inventory.ItemStack)12 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)12 LivingEntity (org.bukkit.entity.LivingEntity)11 EventHandler (org.bukkit.event.EventHandler)9 KitEventHandler (de.hglabor.plugins.kitapi.kit.events.KitEventHandler)7 Location (org.bukkit.Location)6 Entity (org.bukkit.entity.Entity)6 Material (org.bukkit.Material)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 CraftPlayer (org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer)4 ArmorStand (org.bukkit.entity.ArmorStand)4 RotationUtils (de.hglabor.plugins.kitapi.util.RotationUtils)3 ItemBuilder (de.hglabor.utils.noriskutils.ItemBuilder)3 World (org.bukkit.World)3 Snowball (org.bukkit.entity.Snowball)3