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;
|
|
|
|
|
2022-11-04 22:10:41 +00:00
|
|
|
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
|
|
|
|
2022-11-04 22:10:41 +00:00
|
|
|
public static void leftClick(final Material item, final Component name,
|
2022-05-20 02:05:54 +00:00
|
|
|
final PlayerInteractEvent event) {
|
2022-11-04 22:10:41 +00:00
|
|
|
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;
|
2022-05-20 02:05:54 +00:00
|
|
|
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
|
|
|
}
|