Use spaces instead of tabs

This commit is contained in:
kaboom 2022-05-20 04:44:37 +03:00
parent 648a636acb
commit 844f6f26df
16 changed files with 629 additions and 630 deletions

96
pom.xml
View file

@ -1,55 +1,55 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>pw.kaboom</groupId> <groupId>pw.kaboom</groupId>
<artifactId>Weapons</artifactId> <artifactId>Weapons</artifactId>
<version>master</version> <version>master</version>
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<maven.test.skip>true</maven.test.skip> <maven.test.skip>true</maven.test.skip>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.destroystokyo.paper</groupId> <groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId> <artifactId>paper-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version> <version>1.13.2-R0.1-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
<repositories> <repositories>
<repository> <repository>
<id>papermc</id> <id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url> <url>https://papermc.io/repo/repository/maven-public/</url>
</repository> </repository>
</repositories> </repositories>
<build> <build>
<finalName>${project.artifactId}</finalName> <finalName>${project.artifactId}</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version> <version>3.1.2</version>
<executions> <executions>
<execution> <execution>
<id>checkstyle</id> <id>checkstyle</id>
<phase>validate</phase> <phase>validate</phase>
<goals> <goals>
<goal>check</goal> <goal>check</goal>
</goals> </goals>
<configuration> <configuration>
<suppressionsLocation> <suppressionsLocation>
suppressions.xml suppressions.xml
</suppressionsLocation> </suppressionsLocation>
<failOnViolation>true</failOnViolation> <failOnViolation>true</failOnViolation>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View file

@ -19,65 +19,65 @@ import pw.kaboom.weapons.modules.weapons.WeaponGrenade;
import pw.kaboom.weapons.modules.weapons.WeaponMachineGun; import pw.kaboom.weapons.modules.weapons.WeaponMachineGun;
public final class Main extends JavaPlugin { public final class Main extends JavaPlugin {
private static HashSet<BlockFace> blockFaces = new HashSet<BlockFace>(); private static HashSet<BlockFace> blockFaces = new HashSet<BlockFace>();
private static List<Material> colors = new ArrayList<Material>(); private static List<Material> colors = new ArrayList<Material>();
@Override @Override
public void onLoad() { public void onLoad() {
/* Fill lists */ /* Fill lists */
Collections.addAll( Collections.addAll(
blockFaces, blockFaces,
BlockFace.NORTH, BlockFace.NORTH,
BlockFace.SOUTH, BlockFace.SOUTH,
BlockFace.WEST, BlockFace.WEST,
BlockFace.EAST, BlockFace.EAST,
BlockFace.UP, BlockFace.UP,
BlockFace.DOWN BlockFace.DOWN
); );
Collections.addAll( Collections.addAll(
colors, colors,
Material.BLACK_WOOL, Material.BLACK_WOOL,
Material.BLUE_WOOL, Material.BLUE_WOOL,
Material.BROWN_WOOL, Material.BROWN_WOOL,
Material.CYAN_WOOL, Material.CYAN_WOOL,
Material.GRAY_WOOL, Material.GRAY_WOOL,
Material.GREEN_WOOL, Material.GREEN_WOOL,
Material.LIGHT_BLUE_WOOL, Material.LIGHT_BLUE_WOOL,
Material.LIGHT_GRAY_WOOL, Material.LIGHT_GRAY_WOOL,
Material.LIME_WOOL, Material.LIME_WOOL,
Material.MAGENTA_WOOL, Material.MAGENTA_WOOL,
Material.ORANGE_WOOL, Material.ORANGE_WOOL,
Material.PINK_WOOL, Material.PINK_WOOL,
Material.PURPLE_WOOL, Material.PURPLE_WOOL,
Material.RED_WOOL, Material.RED_WOOL,
Material.WHITE_WOOL, Material.WHITE_WOOL,
Material.YELLOW_WOOL Material.YELLOW_WOOL
); );
} }
@Override @Override
public void onEnable() { public void onEnable() {
/* Commands */ /* Commands */
this.getCommand("weapons").setExecutor(new CommandWeapons()); this.getCommand("weapons").setExecutor(new CommandWeapons());
/* Player Events */ /* Player Events */
this.getServer().getPluginManager().registerEvents(new PlayerReceiveWeapon(), this); this.getServer().getPluginManager().registerEvents(new PlayerReceiveWeapon(), this);
this.getServer().getPluginManager().registerEvents(new PlayerUseWeapon(), this); this.getServer().getPluginManager().registerEvents(new PlayerUseWeapon(), this);
/* Weapon Events */ /* Weapon Events */
this.getServer().getPluginManager().registerEvents(new WeaponArcher(), this); this.getServer().getPluginManager().registerEvents(new WeaponArcher(), this);
this.getServer().getPluginManager().registerEvents(new WeaponArmageddon(), this); this.getServer().getPluginManager().registerEvents(new WeaponArmageddon(), this);
this.getServer().getPluginManager().registerEvents(new WeaponBlobinator(), this); this.getServer().getPluginManager().registerEvents(new WeaponBlobinator(), this);
this.getServer().getPluginManager().registerEvents(new WeaponGrenade(), this); this.getServer().getPluginManager().registerEvents(new WeaponGrenade(), this);
this.getServer().getPluginManager().registerEvents(new WeaponMachineGun(), this); this.getServer().getPluginManager().registerEvents(new WeaponMachineGun(), this);
} }
public static HashSet<BlockFace> getBlockFaces() { public static HashSet<BlockFace> getBlockFaces() {
return blockFaces; return blockFaces;
} }
public static List<Material> getColors() { public static List<Material> getColors() {
return colors; return colors;
} }
} }

View file

@ -12,35 +12,35 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
public final class CommandWeapons implements CommandExecutor { public final class CommandWeapons implements CommandExecutor {
private void addWeapon(final Inventory inventory, final Material material, final String name) { private void addWeapon(final Inventory inventory, final Material material, final String name) {
final ItemStack item = new ItemStack(material, 1); final ItemStack item = new ItemStack(material, 1);
final ItemMeta itemMeta = item.getItemMeta(); final ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(name); itemMeta.setDisplayName(name);
item.setItemMeta(itemMeta); item.setItemMeta(itemMeta);
inventory.addItem(item); inventory.addItem(item);
} }
@Override @Override
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) { public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (sender instanceof ConsoleCommandSender) { if (sender instanceof ConsoleCommandSender) {
sender.sendMessage("Command has to be run by a player"); sender.sendMessage("Command has to be run by a player");
} else { } else {
final Player player = (Player) sender; final Player player = (Player) sender;
final Inventory inventory = Bukkit.createInventory(null, 18, "Weapons"); final Inventory inventory = Bukkit.createInventory(null, 18, "Weapons");
addWeapon(inventory, Material.ANVIL, "§rAnvil Dropper"); addWeapon(inventory, Material.ANVIL, "§rAnvil Dropper");
addWeapon(inventory, Material.SPECTRAL_ARROW, "§rArcher"); addWeapon(inventory, Material.SPECTRAL_ARROW, "§rArcher");
addWeapon(inventory, Material.FIRE_CHARGE, "§rArmageddon"); addWeapon(inventory, Material.FIRE_CHARGE, "§rArmageddon");
addWeapon(inventory, Material.MAGMA_CREAM, "§rBlobinator"); addWeapon(inventory, Material.MAGMA_CREAM, "§rBlobinator");
addWeapon(inventory, Material.EGG, "§rGrenade"); addWeapon(inventory, Material.EGG, "§rGrenade");
addWeapon(inventory, Material.BLAZE_POWDER, "§rLaser"); addWeapon(inventory, Material.BLAZE_POWDER, "§rLaser");
addWeapon(inventory, Material.STICK, "§rLightning Stick"); addWeapon(inventory, Material.STICK, "§rLightning Stick");
addWeapon(inventory, Material.GOLDEN_HORSE_ARMOR, "§rMachine Gun"); addWeapon(inventory, Material.GOLDEN_HORSE_ARMOR, "§rMachine Gun");
addWeapon(inventory, Material.BLAZE_ROD, "§rNuker"); addWeapon(inventory, Material.BLAZE_ROD, "§rNuker");
addWeapon(inventory, Material.IRON_HORSE_ARMOR, "§rSniper"); addWeapon(inventory, Material.IRON_HORSE_ARMOR, "§rSniper");
player.openInventory(inventory); player.openInventory(inventory);
} }
return true; return true;
} }
} }

View file

@ -7,18 +7,18 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public final class PlayerReceiveWeapon implements Listener { public final class PlayerReceiveWeapon implements Listener {
@EventHandler @EventHandler
void onInventoryClick(final InventoryClickEvent event) { void onInventoryClick(final InventoryClickEvent event) {
if (event.isCancelled() || !"Weapons".equals(event.getView().getTitle())) { if (event.isCancelled() || !"Weapons".equals(event.getView().getTitle())) {
return; return;
} }
final ItemStack item = event.getCurrentItem(); final ItemStack item = event.getCurrentItem();
final Player player = (Player) event.getWhoClicked(); final Player player = (Player) event.getWhoClicked();
player.getInventory().addItem(item); player.getInventory().addItem(item);
player.closeInventory(); player.closeInventory();
player.sendMessage("You have received the " + item.getItemMeta().getDisplayName().toLowerCase() + "!"); player.sendMessage("You have received the " + item.getItemMeta().getDisplayName().toLowerCase() + "!");
} }
} }

View file

@ -19,39 +19,39 @@ import pw.kaboom.weapons.modules.weapons.WeaponNuker;
import pw.kaboom.weapons.modules.weapons.WeaponSniper; import pw.kaboom.weapons.modules.weapons.WeaponSniper;
public final class PlayerUseWeapon implements Listener { public final class PlayerUseWeapon implements Listener {
@EventHandler @EventHandler
void onPlayerInteract(final PlayerInteractEvent event) { void onPlayerInteract(final PlayerInteractEvent event) {
if ((event.useInteractedBlock() == Result.DENY && event.useItemInHand() == Result.DENY) if ((event.useInteractedBlock() == Result.DENY && event.useItemInHand() == Result.DENY)
|| !event.hasItem()) { || !event.hasItem()) {
return; return;
} }
String name = ""; String name = "";
try { try {
name = event.getItem().getItemMeta().getDisplayName(); name = event.getItem().getItemMeta().getDisplayName();
} catch (Exception ignored) { } catch (Exception ignored) {
return; return;
} }
final Action action = event.getAction(); final Action action = event.getAction();
final Material item = event.getMaterial(); final Material item = event.getMaterial();
if (action == Action.LEFT_CLICK_AIR if (action == Action.LEFT_CLICK_AIR
|| action == Action.LEFT_CLICK_BLOCK) { || action == Action.LEFT_CLICK_BLOCK) {
WeaponAnvilDropper.leftClick(item, name, event); WeaponAnvilDropper.leftClick(item, name, event);
WeaponArcher.leftClick(item, name, event); WeaponArcher.leftClick(item, name, event);
WeaponArmageddon.leftClick(item, name, event); WeaponArmageddon.leftClick(item, name, event);
WeaponBlobinator.leftClick(item, name, event); WeaponBlobinator.leftClick(item, name, event);
WeaponLightningStick.leftClick(item, name, event); WeaponLightningStick.leftClick(item, name, event);
WeaponNuker.leftClick(item, name, event); WeaponNuker.leftClick(item, name, event);
WeaponSniper.leftClick(item, name, event); WeaponSniper.leftClick(item, name, event);
} else if (action == Action.RIGHT_CLICK_AIR } else if (action == Action.RIGHT_CLICK_AIR
|| action == Action.RIGHT_CLICK_BLOCK) { || action == Action.RIGHT_CLICK_BLOCK) {
WeaponGrenade.rightClick(item, name, event); WeaponGrenade.rightClick(item, name, event);
WeaponLaser.rightClick(item, name, event); WeaponLaser.rightClick(item, name, event);
WeaponMachineGun.rightClick(item, name, event); WeaponMachineGun.rightClick(item, name, event);
WeaponSniper.rightClick(item, name, event); WeaponSniper.rightClick(item, name, event);
} }
} }
} }

View file

@ -6,27 +6,27 @@ import org.bukkit.World;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
public final class WeaponAnvilDropper { public final class WeaponAnvilDropper {
private WeaponAnvilDropper() { private WeaponAnvilDropper() {
} }
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) { public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
if (item == Material.ANVIL if (item == Material.ANVIL
&& ("§rAnvil Dropper".equals(name) || "Anvil Dropper".equals(name))) { && ("§rAnvil Dropper".equals(name) || "Anvil Dropper".equals(name))) {
final int min = -2; final int min = -2;
final int max = 2; final int max = 2;
for (int x = min; x <= max; x++) { for (int x = min; x <= max; x++) {
for (int z = min; z <= max; z++) { for (int z = min; z <= max; z++) {
final Location blockLocation = event.getPlayer().getLocation().subtract(x, 0, z); final Location blockLocation = event.getPlayer().getLocation().subtract(x, 0, z);
final World world = event.getPlayer().getWorld(); final World world = event.getPlayer().getWorld();
world.spawnFallingBlock( world.spawnFallingBlock(
blockLocation, blockLocation,
Material.ANVIL.createBlockData() Material.ANVIL.createBlockData()
); );
} }
} }
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }

View file

@ -17,62 +17,62 @@ import org.bukkit.util.Vector;
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent; import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
public final class WeaponArcher implements Listener { public final class WeaponArcher implements Listener {
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) { public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
if (item == Material.SPECTRAL_ARROW if (item == Material.SPECTRAL_ARROW
&& ("§rArcher".equals(name) || "Archer".equals(name))) { && ("§rArcher".equals(name) || "Archer".equals(name))) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final World world = player.getWorld(); final World world = player.getWorld();
final int maxArrowCount = 20; final int maxArrowCount = 20;
for (int i = 0; i <= maxArrowCount; i++) { for (int i = 0; i <= maxArrowCount; i++) {
final double randomX = (Math.random() * ((15 + 15) + 1)) - 15; final double randomX = (Math.random() * ((15 + 15) + 1)) - 15;
final double randomY = (Math.random() * ((15 + 15) + 1)) - 15; final double randomY = (Math.random() * ((15 + 15) + 1)) - 15;
final double randomZ = (Math.random() * ((15 + 15) + 1)) - 15; final double randomZ = (Math.random() * ((15 + 15) + 1)) - 15;
final Vector randomDirection = new Vector( final Vector randomDirection = new Vector(
randomX, randomX,
randomY, randomY,
randomZ).normalize().multiply(8); randomZ).normalize().multiply(8);
final SpectralArrow arrow = (SpectralArrow) world.spawnEntity( final SpectralArrow arrow = (SpectralArrow) world.spawnEntity(
player.getLocation(), player.getLocation(),
EntityType.SPECTRAL_ARROW EntityType.SPECTRAL_ARROW
); );
arrow.setCustomName("WeaponArcherArrow"); arrow.setCustomName("WeaponArcherArrow");
arrow.setShooter(player); arrow.setShooter(player);
arrow.setVelocity(randomDirection); arrow.setVelocity(randomDirection);
} }
final Location eyeLocation = player.getEyeLocation(); final Location eyeLocation = player.getEyeLocation();
final float volume = 1.0F; final float volume = 1.0F;
final float pitch = 1.5F; final float pitch = 1.5F;
world.playSound( world.playSound(
eyeLocation, eyeLocation,
Sound.BLOCK_ANVIL_DESTROY, Sound.BLOCK_ANVIL_DESTROY,
volume, volume,
pitch pitch
); );
event.setCancelled(true); event.setCancelled(true);
} }
} }
/* Make shooter invulnerable to weapon projectiles */ /* Make shooter invulnerable to weapon projectiles */
@EventHandler @EventHandler
private void onProjectileCollide(final ProjectileCollideEvent event) { private void onProjectileCollide(final ProjectileCollideEvent event) {
if (event.getEntityType() == EntityType.SPECTRAL_ARROW) { if (event.getEntityType() == EntityType.SPECTRAL_ARROW) {
final Projectile projectile = event.getEntity(); final Projectile projectile = event.getEntity();
if ("WeaponArcherArrow".equals(projectile.getCustomName())) { if ("WeaponArcherArrow".equals(projectile.getCustomName())) {
final Entity collidedWith = event.getCollidedWith(); final Entity collidedWith = event.getCollidedWith();
if (collidedWith.getType() == EntityType.PLAYER if (collidedWith.getType() == EntityType.PLAYER
&& projectile.getShooter() instanceof Player && projectile.getShooter() instanceof Player
&& ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) { && ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }
} }
} }

View file

@ -17,67 +17,67 @@ import org.bukkit.util.Vector;
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent; import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
public final class WeaponArmageddon implements Listener { public final class WeaponArmageddon implements Listener {
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) { public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
if (item == Material.FIRE_CHARGE if (item == Material.FIRE_CHARGE
&& ("§rArmageddon".equals(name) || "Armageddon".equals(name))) { && ("§rArmageddon".equals(name) || "Armageddon".equals(name))) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final World world = player.getWorld(); final World world = player.getWorld();
final int min = -12; final int min = -12;
final int max = 12; final int max = 12;
final int iteratorSpacing = 4; final int iteratorSpacing = 4;
for (int i = min; i <= max; i += iteratorSpacing) { for (int i = min; i <= max; i += iteratorSpacing) {
final Location eyeLocation = player.getEyeLocation(); final Location eyeLocation = player.getEyeLocation();
final double x = i * Math.cos(Math.toRadians(eyeLocation.getYaw())); final double x = i * Math.cos(Math.toRadians(eyeLocation.getYaw()));
final double z = i * Math.sin(Math.toRadians(eyeLocation.getYaw())); final double z = i * Math.sin(Math.toRadians(eyeLocation.getYaw()));
final Vector velocity = eyeLocation.getDirection().multiply(12); final Vector velocity = eyeLocation.getDirection().multiply(12);
final int yield = 5; final int yield = 5;
final Fireball fireball = (Fireball) world.spawnEntity( final Fireball fireball = (Fireball) world.spawnEntity(
eyeLocation.add(x, 0, z), eyeLocation.add(x, 0, z),
EntityType.FIREBALL EntityType.FIREBALL
); );
fireball.setBounce(false); fireball.setBounce(false);
fireball.setCustomName("WeaponArmegaddonCharge"); fireball.setCustomName("WeaponArmegaddonCharge");
fireball.setDirection(velocity); fireball.setDirection(velocity);
fireball.setShooter(player); fireball.setShooter(player);
fireball.setYield(yield); fireball.setYield(yield);
} }
final Location eyeLocation = player.getEyeLocation(); final Location eyeLocation = player.getEyeLocation();
final float volume = 0.9F; final float volume = 0.9F;
final float pitch = 1.5F; final float pitch = 1.5F;
world.playSound( world.playSound(
eyeLocation, eyeLocation,
Sound.ENTITY_GHAST_SHOOT, Sound.ENTITY_GHAST_SHOOT,
volume, volume,
pitch pitch
); );
event.setCancelled(true); event.setCancelled(true);
} }
} }
/* Make shooter invulnerable to weapon projectiles, and prevent charges from colliding with each other */ /* Make shooter invulnerable to weapon projectiles, and prevent charges from colliding with each other */
@EventHandler @EventHandler
private void onProjectileCollide(final ProjectileCollideEvent event) { private void onProjectileCollide(final ProjectileCollideEvent event) {
if (event.getEntityType() == EntityType.FIREBALL) { if (event.getEntityType() == EntityType.FIREBALL) {
final Projectile projectile = event.getEntity(); final Projectile projectile = event.getEntity();
if ("WeaponArmegaddonCharge".equals(projectile.getCustomName())) { if ("WeaponArmegaddonCharge".equals(projectile.getCustomName())) {
final Entity collidedWith = event.getCollidedWith(); final Entity collidedWith = event.getCollidedWith();
if ((collidedWith.getType() == EntityType.PLAYER if ((collidedWith.getType() == EntityType.PLAYER
&& projectile.getShooter() instanceof Player && projectile.getShooter() instanceof Player
&& ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) && ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId()))
|| collidedWith.getType() == EntityType.FIREBALL) { || collidedWith.getType() == EntityType.FIREBALL) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }
} }
} }

View file

@ -23,82 +23,82 @@ import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
import pw.kaboom.weapons.Main; import pw.kaboom.weapons.Main;
public final class WeaponBlobinator implements Listener { public final class WeaponBlobinator implements Listener {
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) { public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
if (item == Material.MAGMA_CREAM if (item == Material.MAGMA_CREAM
&& ("§rBlobinator".equals(name) || "Blobinator".equals(name))) { && ("§rBlobinator".equals(name) || "Blobinator".equals(name))) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final Location eyeLocation = player.getEyeLocation(); final Location eyeLocation = player.getEyeLocation();
final Vector velocity = eyeLocation.getDirection().multiply(8); final Vector velocity = eyeLocation.getDirection().multiply(8);
final Snowball snowball = player.launchProjectile(Snowball.class); final Snowball snowball = player.launchProjectile(Snowball.class);
snowball.setCustomName("WeaponBlobinatorBall"); snowball.setCustomName("WeaponBlobinatorBall");
snowball.setShooter(player); snowball.setShooter(player);
snowball.setVelocity(velocity); snowball.setVelocity(velocity);
final World world = player.getWorld(); final World world = player.getWorld();
final float volume = 1.0F; final float volume = 1.0F;
final float pitch = 0.8F; final float pitch = 0.8F;
world.playSound( world.playSound(
eyeLocation, eyeLocation,
Sound.ITEM_BOTTLE_EMPTY, Sound.ITEM_BOTTLE_EMPTY,
volume, volume,
pitch pitch
); );
event.setCancelled(true); event.setCancelled(true);
} }
} }
private void createBlobSplash(final World world, final int x, final int y, final int z, final int radius, final Block hitBlock, final Material color) { private void createBlobSplash(final World world, final int x, final int y, final int z, final int radius, final Block hitBlock, final Material color) {
final Location blockLocation = hitBlock.getLocation().add(x, y, z); final Location blockLocation = hitBlock.getLocation().add(x, y, z);
if (blockLocation.distance(hitBlock.getLocation()) <= radius) { if (blockLocation.distance(hitBlock.getLocation()) <= radius) {
final Block block = world.getBlockAt(blockLocation); final Block block = world.getBlockAt(blockLocation);
if (block.getType() != Material.AIR if (block.getType() != Material.AIR
&& block.getType() != Material.CAVE_AIR) { && block.getType() != Material.CAVE_AIR) {
for (BlockFace face : Main.getBlockFaces()) { for (BlockFace face : Main.getBlockFaces()) {
if (block.getRelative(face).getType() == Material.AIR if (block.getRelative(face).getType() == Material.AIR
|| block.getRelative(face).getType() == Material.CAVE_AIR) { || block.getRelative(face).getType() == Material.CAVE_AIR) {
block.setType(color); block.setType(color);
} }
} }
} }
} }
} }
@EventHandler @EventHandler
private void onProjectileCollide(final ProjectileCollideEvent event) { private void onProjectileCollide(final ProjectileCollideEvent event) {
if (event.getEntityType() == EntityType.SNOWBALL) { if (event.getEntityType() == EntityType.SNOWBALL) {
final Projectile projectile = event.getEntity(); final Projectile projectile = event.getEntity();
if ("WeaponBlobinatorBall".equals(projectile.getCustomName())) { if ("WeaponBlobinatorBall".equals(projectile.getCustomName())) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }
@EventHandler @EventHandler
private void onProjectileHit(final ProjectileHitEvent event) { private void onProjectileHit(final ProjectileHitEvent event) {
if (event.getEntityType() == EntityType.SNOWBALL) { if (event.getEntityType() == EntityType.SNOWBALL) {
final Block hitBlock = event.getHitBlock(); final Block hitBlock = event.getHitBlock();
final Projectile projectile = event.getEntity(); final Projectile projectile = event.getEntity();
if (hitBlock != null if (hitBlock != null
&& "WeaponBlobinatorBall".equals(projectile.getCustomName())) { && "WeaponBlobinatorBall".equals(projectile.getCustomName())) {
final int radius = 4; final int radius = 4;
final World world = projectile.getWorld(); final World world = projectile.getWorld();
final Random random = new Random(); final Random random = new Random();
final Material color = Main.getColors().get(random.nextInt(Main.getColors().size())); final Material color = Main.getColors().get(random.nextInt(Main.getColors().size()));
for (int x = -radius; x < radius; x++) { for (int x = -radius; x < radius; x++) {
for (int y = -radius; y < radius; y++) { for (int y = -radius; y < radius; y++) {
for (int z = -radius; z < radius; z++) { for (int z = -radius; z < radius; z++) {
createBlobSplash(world, x, y, z, radius, hitBlock, color); createBlobSplash(world, x, y, z, radius, hitBlock, color);
} }
} }
} }
} }
} }
} }
} }

View file

@ -15,50 +15,50 @@ import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
public final class WeaponGrenade implements Listener { public final class WeaponGrenade implements Listener {
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) { public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
if (item == Material.EGG if (item == Material.EGG
&& ("§rGrenade".equals(name) || "Grenade".equals(name))) { && ("§rGrenade".equals(name) || "Grenade".equals(name))) {
event.setCancelled(true); event.setCancelled(true);
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final Location eyeLocation = player.getEyeLocation(); final Location eyeLocation = player.getEyeLocation();
final Egg egg = player.launchProjectile(Egg.class); final Egg egg = player.launchProjectile(Egg.class);
egg.setCustomName("WeaponGrenade"); egg.setCustomName("WeaponGrenade");
egg.setShooter(player); egg.setShooter(player);
final World world = player.getWorld(); final World world = player.getWorld();
final float volume = 1.0F; final float volume = 1.0F;
final float pitch = 1.0F; final float pitch = 1.0F;
world.playSound( world.playSound(
eyeLocation, eyeLocation,
Sound.ENTITY_EGG_THROW, Sound.ENTITY_EGG_THROW,
volume, volume,
pitch pitch
); );
} }
} }
@EventHandler @EventHandler
private void onPlayerEggThrow(final PlayerEggThrowEvent event) { private void onPlayerEggThrow(final PlayerEggThrowEvent event) {
if ("WeaponGrenade".equals(event.getEgg().getCustomName())) { if ("WeaponGrenade".equals(event.getEgg().getCustomName())) {
event.setHatching(false); event.setHatching(false);
} }
} }
@EventHandler @EventHandler
private void onProjectileHit(final ProjectileHitEvent event) { private void onProjectileHit(final ProjectileHitEvent event) {
if (event.getEntityType() == EntityType.EGG) { if (event.getEntityType() == EntityType.EGG) {
final Projectile projectile = event.getEntity(); final Projectile projectile = event.getEntity();
if ("WeaponGrenade".equals(projectile.getCustomName())) { if ("WeaponGrenade".equals(projectile.getCustomName())) {
final Location location = projectile.getLocation(); final Location location = projectile.getLocation();
final World world = location.getWorld(); final World world = location.getWorld();
final float power = 6; final float power = 6;
world.createExplosion(location, power); world.createExplosion(location, power);
} }
} }
} }
} }

View file

@ -14,80 +14,80 @@ import org.bukkit.util.BlockIterator;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public final class WeaponLaser { public final class WeaponLaser {
private WeaponLaser() { private WeaponLaser() {
} }
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) { public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
if (item == Material.BLAZE_POWDER if (item == Material.BLAZE_POWDER
&& ("§rLaser".equals(name) || "Laser".equals(name))) { && ("§rLaser".equals(name) || "Laser".equals(name))) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final Location eyeLocation = player.getEyeLocation(); final Location eyeLocation = player.getEyeLocation();
final Vector direction = eyeLocation.getDirection(); final Vector direction = eyeLocation.getDirection();
final int distance = 100; final int distance = 100;
final Location particleLocation = player.getEyeLocation(); final Location particleLocation = player.getEyeLocation();
final World world = player.getWorld(); final World world = player.getWorld();
for (int i = 0; i <= distance; i++) { for (int i = 0; i <= distance; i++) {
particleLocation.add(direction); particleLocation.add(direction);
final int count = 1; final int count = 1;
final double offsetX = 0; final double offsetX = 0;
final double offsetY = 0; final double offsetY = 0;
final double offsetZ = 0; final double offsetZ = 0;
final Random random = new Random(); final Random random = new Random();
final int size = 1; final int size = 1;
final Particle.DustOptions dustOptions = new Particle.DustOptions( final Particle.DustOptions dustOptions = new Particle.DustOptions(
random.nextBoolean() ? Color.TEAL : Color.RED, random.nextBoolean() ? Color.TEAL : Color.RED,
size size
); );
world.spawnParticle( world.spawnParticle(
Particle.REDSTONE, Particle.REDSTONE,
particleLocation, particleLocation,
count, count,
offsetX, offsetX,
offsetY, offsetY,
offsetZ, offsetZ,
dustOptions dustOptions
); );
} }
final Vector start = eyeLocation.toVector(); final Vector start = eyeLocation.toVector();
final int yOffset = 0; final int yOffset = 0;
final BlockIterator blockIterator = new BlockIterator( final BlockIterator blockIterator = new BlockIterator(
world, world,
start, start,
direction, direction,
yOffset, yOffset,
distance distance
); );
while (blockIterator.hasNext()) { while (blockIterator.hasNext()) {
blockIterator.next().breakNaturally(); blockIterator.next().breakNaturally();
} }
final float volume = 0.8F; final float volume = 0.8F;
final float pitch = 63.0F; final float pitch = 63.0F;
world.playSound( world.playSound(
eyeLocation, eyeLocation,
Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR, Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR,
volume, volume,
pitch pitch
); );
final float volume2 = 1.0F; final float volume2 = 1.0F;
final float pitch2 = 20.0F; final float pitch2 = 20.0F;
world.playSound( world.playSound(
eyeLocation, eyeLocation,
Sound.ENTITY_FIREWORK_ROCKET_BLAST, Sound.ENTITY_FIREWORK_ROCKET_BLAST,
volume2, volume2,
pitch2 pitch2
); );
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }

View file

@ -8,18 +8,18 @@ import org.bukkit.World;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
public final class WeaponLightningStick { public final class WeaponLightningStick {
private WeaponLightningStick() { private WeaponLightningStick() {
} }
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) { public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
if (item == Material.STICK if (item == Material.STICK
&& ("§rLightning Stick".equals(name) || "Lightning Stick".equals(name))) { && ("§rLightning Stick".equals(name) || "Lightning Stick".equals(name))) {
final int maxDistance = 100; final int maxDistance = 100;
final Location lookLocation = event.getPlayer().getTargetBlock((Set<Material>) null, maxDistance).getLocation(); final Location lookLocation = event.getPlayer().getTargetBlock((Set<Material>) null, maxDistance).getLocation();
final World world = event.getPlayer().getWorld(); final World world = event.getPlayer().getWorld();
world.strikeLightning(lookLocation); world.strikeLightning(lookLocation);
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }

View file

@ -28,98 +28,98 @@ import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
import pw.kaboom.weapons.Main; import pw.kaboom.weapons.Main;
public final class WeaponMachineGun implements Listener { public final class WeaponMachineGun implements Listener {
private static HashSet<UUID> machineGunActive = new HashSet<UUID>(); private static HashSet<UUID> machineGunActive = new HashSet<UUID>();
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) { public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
if (item == Material.GOLDEN_HORSE_ARMOR if (item == Material.GOLDEN_HORSE_ARMOR
&& ("§rMachine Gun".equals(name) || "Machine Gun".equals(name))) { && ("§rMachine Gun".equals(name) || "Machine Gun".equals(name))) {
final UUID playerUUID = event.getPlayer().getUniqueId(); final UUID playerUUID = event.getPlayer().getUniqueId();
if (!machineGunActive.contains(playerUUID)) { if (!machineGunActive.contains(playerUUID)) {
machineGunActive.add(playerUUID); machineGunActive.add(playerUUID);
final int maxBulletCount = 20; final int maxBulletCount = 20;
new BukkitRunnable() { new BukkitRunnable() {
private int i; private int i;
@Override @Override
public void run() { public void run() {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final Location eyeLocation = player.getEyeLocation(); final Location eyeLocation = player.getEyeLocation();
final World world = player.getWorld(); final World world = player.getWorld();
final Vector velocity = eyeLocation.getDirection().multiply(12); final Vector velocity = eyeLocation.getDirection().multiply(12);
final Arrow arrow = player.launchProjectile(Arrow.class); final Arrow arrow = player.launchProjectile(Arrow.class);
arrow.setCustomName("WeaponMachineGunBullet"); arrow.setCustomName("WeaponMachineGunBullet");
arrow.setShooter(player); arrow.setShooter(player);
arrow.setVelocity(velocity); arrow.setVelocity(velocity);
final float volume = 1.0F; final float volume = 1.0F;
final float pitch = 63.0F; final float pitch = 63.0F;
world.playSound( world.playSound(
eyeLocation, eyeLocation,
Sound.ENTITY_GENERIC_EXPLODE, Sound.ENTITY_GENERIC_EXPLODE,
volume, volume,
pitch pitch
); );
i++; i++;
if (i >= maxBulletCount) { if (i >= maxBulletCount) {
this.cancel(); this.cancel();
} }
} }
}.runTaskTimer(JavaPlugin.getPlugin(Main.class), 0, 1); }.runTaskTimer(JavaPlugin.getPlugin(Main.class), 0, 1);
machineGunActive.remove(playerUUID); machineGunActive.remove(playerUUID);
} }
event.setCancelled(true); event.setCancelled(true);
} }
} }
/* Make shooter invulnerable to weapon projectiles */ /* Make shooter invulnerable to weapon projectiles */
@EventHandler @EventHandler
private void onProjectileCollide(final ProjectileCollideEvent event) { private void onProjectileCollide(final ProjectileCollideEvent event) {
if (event.getEntityType() == EntityType.ARROW) { if (event.getEntityType() == EntityType.ARROW) {
final Projectile projectile = event.getEntity(); final Projectile projectile = event.getEntity();
if ("WeaponMachineGunBullet".equals(projectile.getCustomName())) { if ("WeaponMachineGunBullet".equals(projectile.getCustomName())) {
final Entity collidedWith = event.getCollidedWith(); final Entity collidedWith = event.getCollidedWith();
if (collidedWith.getType() == EntityType.PLAYER if (collidedWith.getType() == EntityType.PLAYER
&& projectile.getShooter() instanceof Player && projectile.getShooter() instanceof Player
&& ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) { && ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) {
event.setCancelled(true); event.setCancelled(true);
} else if (collidedWith instanceof LivingEntity) { } else if (collidedWith instanceof LivingEntity) {
final int duration = 90000; final int duration = 90000;
final int amplifier = 3; final int amplifier = 3;
final boolean ambient = true; final boolean ambient = true;
final boolean particles = false; final boolean particles = false;
final PotionEffect harm = new PotionEffect( final PotionEffect harm = new PotionEffect(
PotionEffectType.HARM, PotionEffectType.HARM,
duration, duration,
amplifier, amplifier,
ambient, ambient,
particles particles
); );
((LivingEntity) collidedWith).addPotionEffect(harm, true); ((LivingEntity) collidedWith).addPotionEffect(harm, true);
} }
} }
} }
} }
@EventHandler @EventHandler
private void onProjectileHit(final ProjectileHitEvent event) { private void onProjectileHit(final ProjectileHitEvent event) {
if (event.getEntityType() == EntityType.ARROW) { if (event.getEntityType() == EntityType.ARROW) {
final Projectile projectile = event.getEntity(); final Projectile projectile = event.getEntity();
if ("WeaponMachineGunBullet".equals(projectile.getCustomName())) { if ("WeaponMachineGunBullet".equals(projectile.getCustomName())) {
projectile.remove(); projectile.remove();
} }
} }
} }
} }

View file

@ -10,43 +10,43 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public final class WeaponNuker { public final class WeaponNuker {
private WeaponNuker() { private WeaponNuker() {
} }
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) { public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
if (item == Material.BLAZE_ROD if (item == Material.BLAZE_ROD
&& ("§rNuker".equals(name) || "Nuker".equals(name))) { && ("§rNuker".equals(name) || "Nuker".equals(name))) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final Location eyeLocation = player.getEyeLocation(); final Location eyeLocation = player.getEyeLocation();
final Vector velocity = eyeLocation.getDirection().multiply(10); final Vector velocity = eyeLocation.getDirection().multiply(10);
final int yield = 8; final int yield = 8;
final Fireball fireball = player.launchProjectile(Fireball.class); final Fireball fireball = player.launchProjectile(Fireball.class);
fireball.setShooter(player); fireball.setShooter(player);
fireball.setVelocity(velocity); fireball.setVelocity(velocity);
fireball.setYield(yield); fireball.setYield(yield);
final World world = player.getWorld(); final World world = player.getWorld();
final float volume = 0.9F; final float volume = 0.9F;
final float pitch = 1.5F; final float pitch = 1.5F;
world.playSound( world.playSound(
eyeLocation, eyeLocation,
Sound.ENTITY_GHAST_SHOOT, Sound.ENTITY_GHAST_SHOOT,
volume, volume,
pitch pitch
); );
final float volume2 = 0.8F; final float volume2 = 0.8F;
final float pitch2 = 2.0F; final float pitch2 = 2.0F;
world.playSound( world.playSound(
eyeLocation, eyeLocation,
Sound.ENTITY_BAT_TAKEOFF, Sound.ENTITY_BAT_TAKEOFF,
volume2, volume2,
pitch2 pitch2
); );
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }

View file

@ -12,53 +12,53 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public final class WeaponSniper { public final class WeaponSniper {
private WeaponSniper() { private WeaponSniper() {
} }
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) { public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
if (item == Material.IRON_HORSE_ARMOR if (item == Material.IRON_HORSE_ARMOR
&& ("§rSniper".equals(name) || "Sniper".equals(name))) { && ("§rSniper".equals(name) || "Sniper".equals(name))) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final Location eyeLocation = player.getEyeLocation(); final Location eyeLocation = player.getEyeLocation();
final Vector velocity = eyeLocation.getDirection().multiply(12); final Vector velocity = eyeLocation.getDirection().multiply(12);
final Snowball snowball = player.launchProjectile(Snowball.class); final Snowball snowball = player.launchProjectile(Snowball.class);
snowball.setShooter(player); snowball.setShooter(player);
snowball.setVelocity(velocity); snowball.setVelocity(velocity);
final World world = player.getWorld(); final World world = player.getWorld();
final float volume = 1.0F; final float volume = 1.0F;
final float pitch = 63.0F; final float pitch = 63.0F;
world.playSound( world.playSound(
eyeLocation, eyeLocation,
Sound.BLOCK_PISTON_CONTRACT, Sound.BLOCK_PISTON_CONTRACT,
volume, volume,
pitch pitch
); );
event.setCancelled(true); event.setCancelled(true);
} }
} }
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) { public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
if (item == Material.IRON_HORSE_ARMOR if (item == Material.IRON_HORSE_ARMOR
&& ("§rSniper".equals(name) || "Sniper".equals(name))) { && ("§rSniper".equals(name) || "Sniper".equals(name))) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (player.hasPotionEffect(PotionEffectType.SLOW)) { if (player.hasPotionEffect(PotionEffectType.SLOW)) {
player.removePotionEffect(PotionEffectType.SLOW); player.removePotionEffect(PotionEffectType.SLOW);
} else { } else {
final int duration = 90000; final int duration = 90000;
final int amplifier = 7; final int amplifier = 7;
final PotionEffect effect = new PotionEffect( final PotionEffect effect = new PotionEffect(
PotionEffectType.SLOW, PotionEffectType.SLOW,
duration, duration,
amplifier amplifier
); );
player.addPotionEffect(effect); player.addPotionEffect(effect);
} }
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }

View file

@ -1,11 +1,10 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC <!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.0//EN" "-//Puppy Crawl//DTD Suppressions 1.0//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd"> "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
<suppressions> <suppressions>
<suppress checks="FileTabCharacter" files="."/> <suppress checks="Javadoc" files="."/>
<suppress checks="Javadoc" files="."/> <suppress checks="LineLength" files="."/>
<suppress checks="LineLength" files="."/>
</suppressions> </suppressions>