Use spaces instead of tabs
This commit is contained in:
parent
648a636acb
commit
844f6f26df
96
pom.xml
96
pom.xml
|
@ -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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.kaboom</groupId>
|
||||
<artifactId>Weapons</artifactId>
|
||||
<version>master</version>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.kaboom</groupId>
|
||||
<artifactId>Weapons</artifactId>
|
||||
<version>master</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>checkstyle</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<suppressionsLocation>
|
||||
suppressions.xml
|
||||
</suppressionsLocation>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>checkstyle</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<suppressionsLocation>
|
||||
suppressions.xml
|
||||
</suppressionsLocation>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
|
|
|
@ -19,65 +19,65 @@ import pw.kaboom.weapons.modules.weapons.WeaponGrenade;
|
|||
import pw.kaboom.weapons.modules.weapons.WeaponMachineGun;
|
||||
|
||||
public final class Main extends JavaPlugin {
|
||||
private static HashSet<BlockFace> blockFaces = new HashSet<BlockFace>();
|
||||
private static List<Material> colors = new ArrayList<Material>();
|
||||
private static HashSet<BlockFace> blockFaces = new HashSet<BlockFace>();
|
||||
private static List<Material> colors = new ArrayList<Material>();
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
/* Fill lists */
|
||||
Collections.addAll(
|
||||
blockFaces,
|
||||
BlockFace.NORTH,
|
||||
BlockFace.SOUTH,
|
||||
BlockFace.WEST,
|
||||
BlockFace.EAST,
|
||||
BlockFace.UP,
|
||||
BlockFace.DOWN
|
||||
);
|
||||
@Override
|
||||
public void onLoad() {
|
||||
/* Fill lists */
|
||||
Collections.addAll(
|
||||
blockFaces,
|
||||
BlockFace.NORTH,
|
||||
BlockFace.SOUTH,
|
||||
BlockFace.WEST,
|
||||
BlockFace.EAST,
|
||||
BlockFace.UP,
|
||||
BlockFace.DOWN
|
||||
);
|
||||
|
||||
Collections.addAll(
|
||||
colors,
|
||||
Material.BLACK_WOOL,
|
||||
Material.BLUE_WOOL,
|
||||
Material.BROWN_WOOL,
|
||||
Material.CYAN_WOOL,
|
||||
Material.GRAY_WOOL,
|
||||
Material.GREEN_WOOL,
|
||||
Material.LIGHT_BLUE_WOOL,
|
||||
Material.LIGHT_GRAY_WOOL,
|
||||
Material.LIME_WOOL,
|
||||
Material.MAGENTA_WOOL,
|
||||
Material.ORANGE_WOOL,
|
||||
Material.PINK_WOOL,
|
||||
Material.PURPLE_WOOL,
|
||||
Material.RED_WOOL,
|
||||
Material.WHITE_WOOL,
|
||||
Material.YELLOW_WOOL
|
||||
);
|
||||
}
|
||||
Collections.addAll(
|
||||
colors,
|
||||
Material.BLACK_WOOL,
|
||||
Material.BLUE_WOOL,
|
||||
Material.BROWN_WOOL,
|
||||
Material.CYAN_WOOL,
|
||||
Material.GRAY_WOOL,
|
||||
Material.GREEN_WOOL,
|
||||
Material.LIGHT_BLUE_WOOL,
|
||||
Material.LIGHT_GRAY_WOOL,
|
||||
Material.LIME_WOOL,
|
||||
Material.MAGENTA_WOOL,
|
||||
Material.ORANGE_WOOL,
|
||||
Material.PINK_WOOL,
|
||||
Material.PURPLE_WOOL,
|
||||
Material.RED_WOOL,
|
||||
Material.WHITE_WOOL,
|
||||
Material.YELLOW_WOOL
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
/* Commands */
|
||||
this.getCommand("weapons").setExecutor(new CommandWeapons());
|
||||
@Override
|
||||
public void onEnable() {
|
||||
/* Commands */
|
||||
this.getCommand("weapons").setExecutor(new CommandWeapons());
|
||||
|
||||
/* Player Events */
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerReceiveWeapon(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerUseWeapon(), this);
|
||||
/* Player Events */
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerReceiveWeapon(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerUseWeapon(), this);
|
||||
|
||||
/* Weapon Events */
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponArcher(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponArmageddon(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponBlobinator(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponGrenade(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponMachineGun(), this);
|
||||
}
|
||||
/* Weapon Events */
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponArcher(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponArmageddon(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponBlobinator(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponGrenade(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponMachineGun(), this);
|
||||
}
|
||||
|
||||
public static HashSet<BlockFace> getBlockFaces() {
|
||||
return blockFaces;
|
||||
}
|
||||
public static HashSet<BlockFace> getBlockFaces() {
|
||||
return blockFaces;
|
||||
}
|
||||
|
||||
public static List<Material> getColors() {
|
||||
return colors;
|
||||
}
|
||||
public static List<Material> getColors() {
|
||||
return colors;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,35 +12,35 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public final class CommandWeapons implements CommandExecutor {
|
||||
private void addWeapon(final Inventory inventory, final Material material, final String name) {
|
||||
final ItemStack item = new ItemStack(material, 1);
|
||||
final ItemMeta itemMeta = item.getItemMeta();
|
||||
private void addWeapon(final Inventory inventory, final Material material, final String name) {
|
||||
final ItemStack item = new ItemStack(material, 1);
|
||||
final ItemMeta itemMeta = item.getItemMeta();
|
||||
|
||||
itemMeta.setDisplayName(name);
|
||||
item.setItemMeta(itemMeta);
|
||||
inventory.addItem(item);
|
||||
}
|
||||
itemMeta.setDisplayName(name);
|
||||
item.setItemMeta(itemMeta);
|
||||
inventory.addItem(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
} else {
|
||||
final Player player = (Player) sender;
|
||||
final Inventory inventory = Bukkit.createInventory(null, 18, "Weapons");
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
} else {
|
||||
final Player player = (Player) sender;
|
||||
final Inventory inventory = Bukkit.createInventory(null, 18, "Weapons");
|
||||
|
||||
addWeapon(inventory, Material.ANVIL, "§rAnvil Dropper");
|
||||
addWeapon(inventory, Material.SPECTRAL_ARROW, "§rArcher");
|
||||
addWeapon(inventory, Material.FIRE_CHARGE, "§rArmageddon");
|
||||
addWeapon(inventory, Material.MAGMA_CREAM, "§rBlobinator");
|
||||
addWeapon(inventory, Material.EGG, "§rGrenade");
|
||||
addWeapon(inventory, Material.BLAZE_POWDER, "§rLaser");
|
||||
addWeapon(inventory, Material.STICK, "§rLightning Stick");
|
||||
addWeapon(inventory, Material.GOLDEN_HORSE_ARMOR, "§rMachine Gun");
|
||||
addWeapon(inventory, Material.BLAZE_ROD, "§rNuker");
|
||||
addWeapon(inventory, Material.IRON_HORSE_ARMOR, "§rSniper");
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
addWeapon(inventory, Material.ANVIL, "§rAnvil Dropper");
|
||||
addWeapon(inventory, Material.SPECTRAL_ARROW, "§rArcher");
|
||||
addWeapon(inventory, Material.FIRE_CHARGE, "§rArmageddon");
|
||||
addWeapon(inventory, Material.MAGMA_CREAM, "§rBlobinator");
|
||||
addWeapon(inventory, Material.EGG, "§rGrenade");
|
||||
addWeapon(inventory, Material.BLAZE_POWDER, "§rLaser");
|
||||
addWeapon(inventory, Material.STICK, "§rLightning Stick");
|
||||
addWeapon(inventory, Material.GOLDEN_HORSE_ARMOR, "§rMachine Gun");
|
||||
addWeapon(inventory, Material.BLAZE_ROD, "§rNuker");
|
||||
addWeapon(inventory, Material.IRON_HORSE_ARMOR, "§rSniper");
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,18 +7,18 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public final class PlayerReceiveWeapon implements Listener {
|
||||
@EventHandler
|
||||
void onInventoryClick(final InventoryClickEvent event) {
|
||||
if (event.isCancelled() || !"Weapons".equals(event.getView().getTitle())) {
|
||||
return;
|
||||
}
|
||||
@EventHandler
|
||||
void onInventoryClick(final InventoryClickEvent event) {
|
||||
if (event.isCancelled() || !"Weapons".equals(event.getView().getTitle())) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemStack item = event.getCurrentItem();
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
final ItemStack item = event.getCurrentItem();
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
|
||||
player.getInventory().addItem(item);
|
||||
player.closeInventory();
|
||||
player.sendMessage("You have received the " + item.getItemMeta().getDisplayName().toLowerCase() + "!");
|
||||
}
|
||||
player.getInventory().addItem(item);
|
||||
player.closeInventory();
|
||||
player.sendMessage("You have received the " + item.getItemMeta().getDisplayName().toLowerCase() + "!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,39 +19,39 @@ import pw.kaboom.weapons.modules.weapons.WeaponNuker;
|
|||
import pw.kaboom.weapons.modules.weapons.WeaponSniper;
|
||||
|
||||
public final class PlayerUseWeapon implements Listener {
|
||||
@EventHandler
|
||||
void onPlayerInteract(final PlayerInteractEvent event) {
|
||||
if ((event.useInteractedBlock() == Result.DENY && event.useItemInHand() == Result.DENY)
|
||||
|| !event.hasItem()) {
|
||||
return;
|
||||
}
|
||||
@EventHandler
|
||||
void onPlayerInteract(final PlayerInteractEvent event) {
|
||||
if ((event.useInteractedBlock() == Result.DENY && event.useItemInHand() == Result.DENY)
|
||||
|| !event.hasItem()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String name = "";
|
||||
String name = "";
|
||||
|
||||
try {
|
||||
name = event.getItem().getItemMeta().getDisplayName();
|
||||
} catch (Exception ignored) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
name = event.getItem().getItemMeta().getDisplayName();
|
||||
} catch (Exception ignored) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Action action = event.getAction();
|
||||
final Material item = event.getMaterial();
|
||||
final Action action = event.getAction();
|
||||
final Material item = event.getMaterial();
|
||||
|
||||
if (action == Action.LEFT_CLICK_AIR
|
||||
|| action == Action.LEFT_CLICK_BLOCK) {
|
||||
WeaponAnvilDropper.leftClick(item, name, event);
|
||||
WeaponArcher.leftClick(item, name, event);
|
||||
WeaponArmageddon.leftClick(item, name, event);
|
||||
WeaponBlobinator.leftClick(item, name, event);
|
||||
WeaponLightningStick.leftClick(item, name, event);
|
||||
WeaponNuker.leftClick(item, name, event);
|
||||
WeaponSniper.leftClick(item, name, event);
|
||||
} else if (action == Action.RIGHT_CLICK_AIR
|
||||
|| action == Action.RIGHT_CLICK_BLOCK) {
|
||||
WeaponGrenade.rightClick(item, name, event);
|
||||
WeaponLaser.rightClick(item, name, event);
|
||||
WeaponMachineGun.rightClick(item, name, event);
|
||||
WeaponSniper.rightClick(item, name, event);
|
||||
}
|
||||
}
|
||||
if (action == Action.LEFT_CLICK_AIR
|
||||
|| action == Action.LEFT_CLICK_BLOCK) {
|
||||
WeaponAnvilDropper.leftClick(item, name, event);
|
||||
WeaponArcher.leftClick(item, name, event);
|
||||
WeaponArmageddon.leftClick(item, name, event);
|
||||
WeaponBlobinator.leftClick(item, name, event);
|
||||
WeaponLightningStick.leftClick(item, name, event);
|
||||
WeaponNuker.leftClick(item, name, event);
|
||||
WeaponSniper.leftClick(item, name, event);
|
||||
} else if (action == Action.RIGHT_CLICK_AIR
|
||||
|| action == Action.RIGHT_CLICK_BLOCK) {
|
||||
WeaponGrenade.rightClick(item, name, event);
|
||||
WeaponLaser.rightClick(item, name, event);
|
||||
WeaponMachineGun.rightClick(item, name, event);
|
||||
WeaponSniper.rightClick(item, name, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,27 +6,27 @@ import org.bukkit.World;
|
|||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public final class WeaponAnvilDropper {
|
||||
private WeaponAnvilDropper() {
|
||||
}
|
||||
private WeaponAnvilDropper() {
|
||||
}
|
||||
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.ANVIL
|
||||
&& ("§rAnvil Dropper".equals(name) || "Anvil Dropper".equals(name))) {
|
||||
final int min = -2;
|
||||
final int max = 2;
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.ANVIL
|
||||
&& ("§rAnvil Dropper".equals(name) || "Anvil Dropper".equals(name))) {
|
||||
final int min = -2;
|
||||
final int max = 2;
|
||||
|
||||
for (int x = min; x <= max; x++) {
|
||||
for (int z = min; z <= max; z++) {
|
||||
final Location blockLocation = event.getPlayer().getLocation().subtract(x, 0, z);
|
||||
final World world = event.getPlayer().getWorld();
|
||||
for (int x = min; x <= max; x++) {
|
||||
for (int z = min; z <= max; z++) {
|
||||
final Location blockLocation = event.getPlayer().getLocation().subtract(x, 0, z);
|
||||
final World world = event.getPlayer().getWorld();
|
||||
|
||||
world.spawnFallingBlock(
|
||||
blockLocation,
|
||||
Material.ANVIL.createBlockData()
|
||||
);
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
world.spawnFallingBlock(
|
||||
blockLocation,
|
||||
Material.ANVIL.createBlockData()
|
||||
);
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,62 +17,62 @@ import org.bukkit.util.Vector;
|
|||
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
|
||||
|
||||
public final class WeaponArcher implements Listener {
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.SPECTRAL_ARROW
|
||||
&& ("§rArcher".equals(name) || "Archer".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
final World world = player.getWorld();
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.SPECTRAL_ARROW
|
||||
&& ("§rArcher".equals(name) || "Archer".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
final World world = player.getWorld();
|
||||
|
||||
final int maxArrowCount = 20;
|
||||
final int maxArrowCount = 20;
|
||||
|
||||
for (int i = 0; i <= maxArrowCount; i++) {
|
||||
final double randomX = (Math.random() * ((15 + 15) + 1)) - 15;
|
||||
final double randomY = (Math.random() * ((15 + 15) + 1)) - 15;
|
||||
final double randomZ = (Math.random() * ((15 + 15) + 1)) - 15;
|
||||
for (int i = 0; i <= maxArrowCount; i++) {
|
||||
final double randomX = (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 Vector randomDirection = new Vector(
|
||||
randomX,
|
||||
randomY,
|
||||
randomZ).normalize().multiply(8);
|
||||
final Vector randomDirection = new Vector(
|
||||
randomX,
|
||||
randomY,
|
||||
randomZ).normalize().multiply(8);
|
||||
|
||||
final SpectralArrow arrow = (SpectralArrow) world.spawnEntity(
|
||||
player.getLocation(),
|
||||
EntityType.SPECTRAL_ARROW
|
||||
);
|
||||
arrow.setCustomName("WeaponArcherArrow");
|
||||
arrow.setShooter(player);
|
||||
arrow.setVelocity(randomDirection);
|
||||
}
|
||||
final SpectralArrow arrow = (SpectralArrow) world.spawnEntity(
|
||||
player.getLocation(),
|
||||
EntityType.SPECTRAL_ARROW
|
||||
);
|
||||
arrow.setCustomName("WeaponArcherArrow");
|
||||
arrow.setShooter(player);
|
||||
arrow.setVelocity(randomDirection);
|
||||
}
|
||||
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 1.5F;
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 1.5F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.BLOCK_ANVIL_DESTROY,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.BLOCK_ANVIL_DESTROY,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* Make shooter invulnerable to weapon projectiles */
|
||||
@EventHandler
|
||||
private void onProjectileCollide(final ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.SPECTRAL_ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
/* Make shooter invulnerable to weapon projectiles */
|
||||
@EventHandler
|
||||
private void onProjectileCollide(final ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.SPECTRAL_ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("WeaponArcherArrow".equals(projectile.getCustomName())) {
|
||||
final Entity collidedWith = event.getCollidedWith();
|
||||
if ("WeaponArcherArrow".equals(projectile.getCustomName())) {
|
||||
final Entity collidedWith = event.getCollidedWith();
|
||||
|
||||
if (collidedWith.getType() == EntityType.PLAYER
|
||||
&& projectile.getShooter() instanceof Player
|
||||
&& ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (collidedWith.getType() == EntityType.PLAYER
|
||||
&& projectile.getShooter() instanceof Player
|
||||
&& ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,67 +17,67 @@ import org.bukkit.util.Vector;
|
|||
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
|
||||
|
||||
public final class WeaponArmageddon implements Listener {
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.FIRE_CHARGE
|
||||
&& ("§rArmageddon".equals(name) || "Armageddon".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
final World world = player.getWorld();
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.FIRE_CHARGE
|
||||
&& ("§rArmageddon".equals(name) || "Armageddon".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
final World world = player.getWorld();
|
||||
|
||||
final int min = -12;
|
||||
final int max = 12;
|
||||
final int iteratorSpacing = 4;
|
||||
final int min = -12;
|
||||
final int max = 12;
|
||||
final int iteratorSpacing = 4;
|
||||
|
||||
for (int i = min; i <= max; i += iteratorSpacing) {
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
for (int i = min; i <= max; i += iteratorSpacing) {
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
|
||||
final double x = i * Math.cos(Math.toRadians(eyeLocation.getYaw()));
|
||||
final double z = i * Math.sin(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 Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
final int yield = 5;
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
final int yield = 5;
|
||||
|
||||
final Fireball fireball = (Fireball) world.spawnEntity(
|
||||
eyeLocation.add(x, 0, z),
|
||||
EntityType.FIREBALL
|
||||
);
|
||||
final Fireball fireball = (Fireball) world.spawnEntity(
|
||||
eyeLocation.add(x, 0, z),
|
||||
EntityType.FIREBALL
|
||||
);
|
||||
|
||||
fireball.setBounce(false);
|
||||
fireball.setCustomName("WeaponArmegaddonCharge");
|
||||
fireball.setDirection(velocity);
|
||||
fireball.setShooter(player);
|
||||
fireball.setYield(yield);
|
||||
}
|
||||
fireball.setBounce(false);
|
||||
fireball.setCustomName("WeaponArmegaddonCharge");
|
||||
fireball.setDirection(velocity);
|
||||
fireball.setShooter(player);
|
||||
fireball.setYield(yield);
|
||||
}
|
||||
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final float volume = 0.9F;
|
||||
final float pitch = 1.5F;
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final float volume = 0.9F;
|
||||
final float pitch = 1.5F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GHAST_SHOOT,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GHAST_SHOOT,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* Make shooter invulnerable to weapon projectiles, and prevent charges from colliding with each other */
|
||||
@EventHandler
|
||||
private void onProjectileCollide(final ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.FIREBALL) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
/* Make shooter invulnerable to weapon projectiles, and prevent charges from colliding with each other */
|
||||
@EventHandler
|
||||
private void onProjectileCollide(final ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.FIREBALL) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("WeaponArmegaddonCharge".equals(projectile.getCustomName())) {
|
||||
final Entity collidedWith = event.getCollidedWith();
|
||||
if ("WeaponArmegaddonCharge".equals(projectile.getCustomName())) {
|
||||
final Entity collidedWith = event.getCollidedWith();
|
||||
|
||||
if ((collidedWith.getType() == EntityType.PLAYER
|
||||
&& projectile.getShooter() instanceof Player
|
||||
&& ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId()))
|
||||
|| collidedWith.getType() == EntityType.FIREBALL) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((collidedWith.getType() == EntityType.PLAYER
|
||||
&& projectile.getShooter() instanceof Player
|
||||
&& ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId()))
|
||||
|| collidedWith.getType() == EntityType.FIREBALL) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,82 +23,82 @@ import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
|
|||
import pw.kaboom.weapons.Main;
|
||||
|
||||
public final class WeaponBlobinator implements Listener {
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.MAGMA_CREAM
|
||||
&& ("§rBlobinator".equals(name) || "Blobinator".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(8);
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.MAGMA_CREAM
|
||||
&& ("§rBlobinator".equals(name) || "Blobinator".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(8);
|
||||
|
||||
final Snowball snowball = player.launchProjectile(Snowball.class);
|
||||
snowball.setCustomName("WeaponBlobinatorBall");
|
||||
snowball.setShooter(player);
|
||||
snowball.setVelocity(velocity);
|
||||
final Snowball snowball = player.launchProjectile(Snowball.class);
|
||||
snowball.setCustomName("WeaponBlobinatorBall");
|
||||
snowball.setShooter(player);
|
||||
snowball.setVelocity(velocity);
|
||||
|
||||
final World world = player.getWorld();
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 0.8F;
|
||||
final World world = player.getWorld();
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 0.8F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ITEM_BOTTLE_EMPTY,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ITEM_BOTTLE_EMPTY,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
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) {
|
||||
final Location blockLocation = hitBlock.getLocation().add(x, y, z);
|
||||
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);
|
||||
|
||||
if (blockLocation.distance(hitBlock.getLocation()) <= radius) {
|
||||
final Block block = world.getBlockAt(blockLocation);
|
||||
if (blockLocation.distance(hitBlock.getLocation()) <= radius) {
|
||||
final Block block = world.getBlockAt(blockLocation);
|
||||
|
||||
if (block.getType() != Material.AIR
|
||||
&& block.getType() != Material.CAVE_AIR) {
|
||||
for (BlockFace face : Main.getBlockFaces()) {
|
||||
if (block.getRelative(face).getType() == Material.AIR
|
||||
|| block.getRelative(face).getType() == Material.CAVE_AIR) {
|
||||
block.setType(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (block.getType() != Material.AIR
|
||||
&& block.getType() != Material.CAVE_AIR) {
|
||||
for (BlockFace face : Main.getBlockFaces()) {
|
||||
if (block.getRelative(face).getType() == Material.AIR
|
||||
|| block.getRelative(face).getType() == Material.CAVE_AIR) {
|
||||
block.setType(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onProjectileCollide(final ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.SNOWBALL) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
@EventHandler
|
||||
private void onProjectileCollide(final ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.SNOWBALL) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("WeaponBlobinatorBall".equals(projectile.getCustomName())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ("WeaponBlobinatorBall".equals(projectile.getCustomName())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onProjectileHit(final ProjectileHitEvent event) {
|
||||
if (event.getEntityType() == EntityType.SNOWBALL) {
|
||||
final Block hitBlock = event.getHitBlock();
|
||||
final Projectile projectile = event.getEntity();
|
||||
@EventHandler
|
||||
private void onProjectileHit(final ProjectileHitEvent event) {
|
||||
if (event.getEntityType() == EntityType.SNOWBALL) {
|
||||
final Block hitBlock = event.getHitBlock();
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if (hitBlock != null
|
||||
&& "WeaponBlobinatorBall".equals(projectile.getCustomName())) {
|
||||
final int radius = 4;
|
||||
final World world = projectile.getWorld();
|
||||
final Random random = new Random();
|
||||
final Material color = Main.getColors().get(random.nextInt(Main.getColors().size()));
|
||||
if (hitBlock != null
|
||||
&& "WeaponBlobinatorBall".equals(projectile.getCustomName())) {
|
||||
final int radius = 4;
|
||||
final World world = projectile.getWorld();
|
||||
final Random random = new Random();
|
||||
final Material color = Main.getColors().get(random.nextInt(Main.getColors().size()));
|
||||
|
||||
for (int x = -radius; x < radius; x++) {
|
||||
for (int y = -radius; y < radius; y++) {
|
||||
for (int z = -radius; z < radius; z++) {
|
||||
createBlobSplash(world, x, y, z, radius, hitBlock, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int x = -radius; x < radius; x++) {
|
||||
for (int y = -radius; y < radius; y++) {
|
||||
for (int z = -radius; z < radius; z++) {
|
||||
createBlobSplash(world, x, y, z, radius, hitBlock, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,50 +15,50 @@ import org.bukkit.event.player.PlayerEggThrowEvent;
|
|||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public final class WeaponGrenade implements Listener {
|
||||
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.EGG
|
||||
&& ("§rGrenade".equals(name) || "Grenade".equals(name))) {
|
||||
event.setCancelled(true);
|
||||
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.EGG
|
||||
&& ("§rGrenade".equals(name) || "Grenade".equals(name))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
|
||||
final Egg egg = player.launchProjectile(Egg.class);
|
||||
egg.setCustomName("WeaponGrenade");
|
||||
egg.setShooter(player);
|
||||
final Egg egg = player.launchProjectile(Egg.class);
|
||||
egg.setCustomName("WeaponGrenade");
|
||||
egg.setShooter(player);
|
||||
|
||||
final World world = player.getWorld();
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 1.0F;
|
||||
final World world = player.getWorld();
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 1.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_EGG_THROW,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
}
|
||||
}
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_EGG_THROW,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onPlayerEggThrow(final PlayerEggThrowEvent event) {
|
||||
if ("WeaponGrenade".equals(event.getEgg().getCustomName())) {
|
||||
event.setHatching(false);
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void onPlayerEggThrow(final PlayerEggThrowEvent event) {
|
||||
if ("WeaponGrenade".equals(event.getEgg().getCustomName())) {
|
||||
event.setHatching(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onProjectileHit(final ProjectileHitEvent event) {
|
||||
if (event.getEntityType() == EntityType.EGG) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
@EventHandler
|
||||
private void onProjectileHit(final ProjectileHitEvent event) {
|
||||
if (event.getEntityType() == EntityType.EGG) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("WeaponGrenade".equals(projectile.getCustomName())) {
|
||||
final Location location = projectile.getLocation();
|
||||
final World world = location.getWorld();
|
||||
final float power = 6;
|
||||
if ("WeaponGrenade".equals(projectile.getCustomName())) {
|
||||
final Location location = projectile.getLocation();
|
||||
final World world = location.getWorld();
|
||||
final float power = 6;
|
||||
|
||||
world.createExplosion(location, power);
|
||||
}
|
||||
}
|
||||
}
|
||||
world.createExplosion(location, power);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,80 +14,80 @@ import org.bukkit.util.BlockIterator;
|
|||
import org.bukkit.util.Vector;
|
||||
|
||||
public final class WeaponLaser {
|
||||
private WeaponLaser() {
|
||||
}
|
||||
private WeaponLaser() {
|
||||
}
|
||||
|
||||
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.BLAZE_POWDER
|
||||
&& ("§rLaser".equals(name) || "Laser".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector direction = eyeLocation.getDirection();
|
||||
final int distance = 100;
|
||||
final Location particleLocation = player.getEyeLocation();
|
||||
final World world = player.getWorld();
|
||||
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.BLAZE_POWDER
|
||||
&& ("§rLaser".equals(name) || "Laser".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector direction = eyeLocation.getDirection();
|
||||
final int distance = 100;
|
||||
final Location particleLocation = player.getEyeLocation();
|
||||
final World world = player.getWorld();
|
||||
|
||||
for (int i = 0; i <= distance; i++) {
|
||||
particleLocation.add(direction);
|
||||
for (int i = 0; i <= distance; i++) {
|
||||
particleLocation.add(direction);
|
||||
|
||||
final int count = 1;
|
||||
final double offsetX = 0;
|
||||
final double offsetY = 0;
|
||||
final double offsetZ = 0;
|
||||
final int count = 1;
|
||||
final double offsetX = 0;
|
||||
final double offsetY = 0;
|
||||
final double offsetZ = 0;
|
||||
|
||||
final Random random = new Random();
|
||||
final int size = 1;
|
||||
final Particle.DustOptions dustOptions = new Particle.DustOptions(
|
||||
random.nextBoolean() ? Color.TEAL : Color.RED,
|
||||
size
|
||||
);
|
||||
final Random random = new Random();
|
||||
final int size = 1;
|
||||
final Particle.DustOptions dustOptions = new Particle.DustOptions(
|
||||
random.nextBoolean() ? Color.TEAL : Color.RED,
|
||||
size
|
||||
);
|
||||
|
||||
world.spawnParticle(
|
||||
Particle.REDSTONE,
|
||||
particleLocation,
|
||||
count,
|
||||
offsetX,
|
||||
offsetY,
|
||||
offsetZ,
|
||||
dustOptions
|
||||
);
|
||||
}
|
||||
world.spawnParticle(
|
||||
Particle.REDSTONE,
|
||||
particleLocation,
|
||||
count,
|
||||
offsetX,
|
||||
offsetY,
|
||||
offsetZ,
|
||||
dustOptions
|
||||
);
|
||||
}
|
||||
|
||||
final Vector start = eyeLocation.toVector();
|
||||
final int yOffset = 0;
|
||||
final Vector start = eyeLocation.toVector();
|
||||
final int yOffset = 0;
|
||||
|
||||
final BlockIterator blockIterator = new BlockIterator(
|
||||
world,
|
||||
start,
|
||||
direction,
|
||||
yOffset,
|
||||
distance
|
||||
);
|
||||
final BlockIterator blockIterator = new BlockIterator(
|
||||
world,
|
||||
start,
|
||||
direction,
|
||||
yOffset,
|
||||
distance
|
||||
);
|
||||
|
||||
while (blockIterator.hasNext()) {
|
||||
blockIterator.next().breakNaturally();
|
||||
}
|
||||
while (blockIterator.hasNext()) {
|
||||
blockIterator.next().breakNaturally();
|
||||
}
|
||||
|
||||
final float volume = 0.8F;
|
||||
final float pitch = 63.0F;
|
||||
final float volume = 0.8F;
|
||||
final float pitch = 63.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
|
||||
final float volume2 = 1.0F;
|
||||
final float pitch2 = 20.0F;
|
||||
final float volume2 = 1.0F;
|
||||
final float pitch2 = 20.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_FIREWORK_ROCKET_BLAST,
|
||||
volume2,
|
||||
pitch2
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_FIREWORK_ROCKET_BLAST,
|
||||
volume2,
|
||||
pitch2
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,18 +8,18 @@ import org.bukkit.World;
|
|||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public final class WeaponLightningStick {
|
||||
private WeaponLightningStick() {
|
||||
}
|
||||
private WeaponLightningStick() {
|
||||
}
|
||||
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.STICK
|
||||
&& ("§rLightning Stick".equals(name) || "Lightning Stick".equals(name))) {
|
||||
final int maxDistance = 100;
|
||||
final Location lookLocation = event.getPlayer().getTargetBlock((Set<Material>) null, maxDistance).getLocation();
|
||||
final World world = event.getPlayer().getWorld();
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.STICK
|
||||
&& ("§rLightning Stick".equals(name) || "Lightning Stick".equals(name))) {
|
||||
final int maxDistance = 100;
|
||||
final Location lookLocation = event.getPlayer().getTargetBlock((Set<Material>) null, maxDistance).getLocation();
|
||||
final World world = event.getPlayer().getWorld();
|
||||
|
||||
world.strikeLightning(lookLocation);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
world.strikeLightning(lookLocation);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,98 +28,98 @@ import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
|
|||
import pw.kaboom.weapons.Main;
|
||||
|
||||
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) {
|
||||
if (item == Material.GOLDEN_HORSE_ARMOR
|
||||
&& ("§rMachine Gun".equals(name) || "Machine Gun".equals(name))) {
|
||||
final UUID playerUUID = event.getPlayer().getUniqueId();
|
||||
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.GOLDEN_HORSE_ARMOR
|
||||
&& ("§rMachine Gun".equals(name) || "Machine Gun".equals(name))) {
|
||||
final UUID playerUUID = event.getPlayer().getUniqueId();
|
||||
|
||||
if (!machineGunActive.contains(playerUUID)) {
|
||||
machineGunActive.add(playerUUID);
|
||||
final int maxBulletCount = 20;
|
||||
if (!machineGunActive.contains(playerUUID)) {
|
||||
machineGunActive.add(playerUUID);
|
||||
final int maxBulletCount = 20;
|
||||
|
||||
new BukkitRunnable() {
|
||||
private int i;
|
||||
new BukkitRunnable() {
|
||||
private int i;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final World world = player.getWorld();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
@Override
|
||||
public void run() {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final World world = player.getWorld();
|
||||
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.setShooter(player);
|
||||
arrow.setVelocity(velocity);
|
||||
arrow.setCustomName("WeaponMachineGunBullet");
|
||||
arrow.setShooter(player);
|
||||
arrow.setVelocity(velocity);
|
||||
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 63.0F;
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 63.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GENERIC_EXPLODE,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GENERIC_EXPLODE,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
|
||||
i++;
|
||||
i++;
|
||||
|
||||
if (i >= maxBulletCount) {
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(JavaPlugin.getPlugin(Main.class), 0, 1);
|
||||
if (i >= maxBulletCount) {
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(JavaPlugin.getPlugin(Main.class), 0, 1);
|
||||
|
||||
machineGunActive.remove(playerUUID);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
machineGunActive.remove(playerUUID);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* Make shooter invulnerable to weapon projectiles */
|
||||
@EventHandler
|
||||
private void onProjectileCollide(final ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
/* Make shooter invulnerable to weapon projectiles */
|
||||
@EventHandler
|
||||
private void onProjectileCollide(final ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("WeaponMachineGunBullet".equals(projectile.getCustomName())) {
|
||||
final Entity collidedWith = event.getCollidedWith();
|
||||
if ("WeaponMachineGunBullet".equals(projectile.getCustomName())) {
|
||||
final Entity collidedWith = event.getCollidedWith();
|
||||
|
||||
if (collidedWith.getType() == EntityType.PLAYER
|
||||
&& projectile.getShooter() instanceof Player
|
||||
&& ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
} else if (collidedWith instanceof LivingEntity) {
|
||||
final int duration = 90000;
|
||||
final int amplifier = 3;
|
||||
final boolean ambient = true;
|
||||
final boolean particles = false;
|
||||
if (collidedWith.getType() == EntityType.PLAYER
|
||||
&& projectile.getShooter() instanceof Player
|
||||
&& ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
} else if (collidedWith instanceof LivingEntity) {
|
||||
final int duration = 90000;
|
||||
final int amplifier = 3;
|
||||
final boolean ambient = true;
|
||||
final boolean particles = false;
|
||||
|
||||
final PotionEffect harm = new PotionEffect(
|
||||
PotionEffectType.HARM,
|
||||
duration,
|
||||
amplifier,
|
||||
ambient,
|
||||
particles
|
||||
);
|
||||
final PotionEffect harm = new PotionEffect(
|
||||
PotionEffectType.HARM,
|
||||
duration,
|
||||
amplifier,
|
||||
ambient,
|
||||
particles
|
||||
);
|
||||
|
||||
((LivingEntity) collidedWith).addPotionEffect(harm, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
((LivingEntity) collidedWith).addPotionEffect(harm, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onProjectileHit(final ProjectileHitEvent event) {
|
||||
if (event.getEntityType() == EntityType.ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
@EventHandler
|
||||
private void onProjectileHit(final ProjectileHitEvent event) {
|
||||
if (event.getEntityType() == EntityType.ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("WeaponMachineGunBullet".equals(projectile.getCustomName())) {
|
||||
projectile.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
if ("WeaponMachineGunBullet".equals(projectile.getCustomName())) {
|
||||
projectile.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,43 +10,43 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||
import org.bukkit.util.Vector;
|
||||
|
||||
public final class WeaponNuker {
|
||||
private WeaponNuker() {
|
||||
}
|
||||
private WeaponNuker() {
|
||||
}
|
||||
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.BLAZE_ROD
|
||||
&& ("§rNuker".equals(name) || "Nuker".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(10);
|
||||
final int yield = 8;
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.BLAZE_ROD
|
||||
&& ("§rNuker".equals(name) || "Nuker".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(10);
|
||||
final int yield = 8;
|
||||
|
||||
final Fireball fireball = player.launchProjectile(Fireball.class);
|
||||
fireball.setShooter(player);
|
||||
fireball.setVelocity(velocity);
|
||||
fireball.setYield(yield);
|
||||
final Fireball fireball = player.launchProjectile(Fireball.class);
|
||||
fireball.setShooter(player);
|
||||
fireball.setVelocity(velocity);
|
||||
fireball.setYield(yield);
|
||||
|
||||
final World world = player.getWorld();
|
||||
final float volume = 0.9F;
|
||||
final float pitch = 1.5F;
|
||||
final World world = player.getWorld();
|
||||
final float volume = 0.9F;
|
||||
final float pitch = 1.5F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GHAST_SHOOT,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GHAST_SHOOT,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
|
||||
final float volume2 = 0.8F;
|
||||
final float pitch2 = 2.0F;
|
||||
final float volume2 = 0.8F;
|
||||
final float pitch2 = 2.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_BAT_TAKEOFF,
|
||||
volume2,
|
||||
pitch2
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_BAT_TAKEOFF,
|
||||
volume2,
|
||||
pitch2
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,53 +12,53 @@ import org.bukkit.potion.PotionEffectType;
|
|||
import org.bukkit.util.Vector;
|
||||
|
||||
public final class WeaponSniper {
|
||||
private WeaponSniper() {
|
||||
}
|
||||
private WeaponSniper() {
|
||||
}
|
||||
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.IRON_HORSE_ARMOR
|
||||
&& ("§rSniper".equals(name) || "Sniper".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.IRON_HORSE_ARMOR
|
||||
&& ("§rSniper".equals(name) || "Sniper".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
|
||||
final Snowball snowball = player.launchProjectile(Snowball.class);
|
||||
snowball.setShooter(player);
|
||||
snowball.setVelocity(velocity);
|
||||
final Snowball snowball = player.launchProjectile(Snowball.class);
|
||||
snowball.setShooter(player);
|
||||
snowball.setVelocity(velocity);
|
||||
|
||||
final World world = player.getWorld();
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 63.0F;
|
||||
final World world = player.getWorld();
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 63.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.BLOCK_PISTON_CONTRACT,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.BLOCK_PISTON_CONTRACT,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.IRON_HORSE_ARMOR
|
||||
&& ("§rSniper".equals(name) || "Sniper".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.IRON_HORSE_ARMOR
|
||||
&& ("§rSniper".equals(name) || "Sniper".equals(name))) {
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (player.hasPotionEffect(PotionEffectType.SLOW)) {
|
||||
player.removePotionEffect(PotionEffectType.SLOW);
|
||||
} else {
|
||||
final int duration = 90000;
|
||||
final int amplifier = 7;
|
||||
if (player.hasPotionEffect(PotionEffectType.SLOW)) {
|
||||
player.removePotionEffect(PotionEffectType.SLOW);
|
||||
} else {
|
||||
final int duration = 90000;
|
||||
final int amplifier = 7;
|
||||
|
||||
final PotionEffect effect = new PotionEffect(
|
||||
PotionEffectType.SLOW,
|
||||
duration,
|
||||
amplifier
|
||||
);
|
||||
player.addPotionEffect(effect);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
final PotionEffect effect = new PotionEffect(
|
||||
PotionEffectType.SLOW,
|
||||
duration,
|
||||
amplifier
|
||||
);
|
||||
player.addPotionEffect(effect);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!DOCTYPE suppressions PUBLIC
|
||||
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
|
||||
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
|
||||
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
|
||||
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
|
||||
|
||||
<suppressions>
|
||||
<suppress checks="FileTabCharacter" files="."/>
|
||||
<suppress checks="Javadoc" files="."/>
|
||||
<suppress checks="LineLength" files="."/>
|
||||
<suppress checks="Javadoc" files="."/>
|
||||
<suppress checks="LineLength" files="."/>
|
||||
</suppressions>
|
||||
|
|
Loading…
Reference in New Issue