weapons/src/main/java/pw/kaboom/weapons/modules/weapons/WeaponLightningStick.java

31 lines
1 KiB
Java
Raw Normal View History

2019-12-17 15:12:51 +00:00
package pw.kaboom.weapons.modules.weapons;
2019-09-19 15:33:22 +00:00
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.event.player.PlayerInteractEvent;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextDecoration;
2019-12-17 15:12:51 +00:00
public final class WeaponLightningStick {
2022-05-20 01:44:37 +00:00
private WeaponLightningStick() {
}
2019-12-17 15:12:51 +00:00
public static void leftClick(final Material item, final Component name,
final PlayerInteractEvent event) {
if (item == Material.STICK && Component.text("Lightning Stick")
.decoration(TextDecoration.ITALIC, false).equals(name)) {
2022-05-20 01:44:37 +00:00
final int maxDistance = 100;
final Location lookLocation = event.getPlayer().getTargetBlock(
(Set<Material>) null, maxDistance).getLocation();
2022-05-20 01:44:37 +00:00
final World world = event.getPlayer().getWorld();
2019-09-19 15:33:22 +00:00
2022-05-20 01:44:37 +00:00
world.strikeLightning(lookLocation);
event.setCancelled(true);
}
}
2019-09-19 15:33:22 +00:00
}