Separate plugin into modules
This commit is contained in:
parent
545790a598
commit
8ee75e8129
|
@ -1,490 +0,0 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.entity.SpectralArrow;
|
||||
import org.bukkit.entity.TippedArrow;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
|
||||
|
||||
class Events implements Listener {
|
||||
Main main;
|
||||
Events(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onInventoryClick(InventoryClickEvent event) {
|
||||
if ("Weapons".equals(event.getView().getTitle())) {
|
||||
final ItemStack item = event.getCurrentItem();
|
||||
|
||||
if (item.getItemMeta().hasDisplayName() == true) {
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
|
||||
player.getInventory().addItem(item);
|
||||
player.closeInventory();
|
||||
player.sendMessage("You have received the " + item.getItemMeta().getDisplayName().toLowerCase() + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerEggThrow(PlayerEggThrowEvent event) {
|
||||
final PlayerInventory inventory = event.getPlayer().getInventory();
|
||||
final String name = inventory.getItemInMainHand().getItemMeta().getDisplayName();
|
||||
|
||||
if ("§rGrenade".equals(name)) {
|
||||
final Egg egg = event.getEgg();
|
||||
egg.setCustomName("weaponsGrenade");
|
||||
event.setHatching(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.hasItem() == true &&
|
||||
event.getItem().getItemMeta().hasDisplayName() == true) {
|
||||
final Action action = event.getAction();
|
||||
final Material item = event.getMaterial();
|
||||
final String name = event.getItem().getItemMeta().getDisplayName();
|
||||
|
||||
if (action == Action.LEFT_CLICK_AIR ||
|
||||
action == Action.LEFT_CLICK_BLOCK) {
|
||||
if (item == Material.ANVIL &&
|
||||
"§rAnvil Dropper".equals(name)) {
|
||||
for (int x = -2; x <= 2; x++) {
|
||||
for (int z = -2; z <= 2; 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);
|
||||
} else if (item == Material.SPECTRAL_ARROW &&
|
||||
"§rArcher".equals(name)) {
|
||||
final World world = event.getPlayer().getWorld();
|
||||
|
||||
for (int i = 0; i <= 20; 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 Player player = event.getPlayer();
|
||||
final Vector randomDirection = new Vector(
|
||||
randomX,
|
||||
randomY,
|
||||
randomZ).normalize().multiply(8);
|
||||
|
||||
final SpectralArrow arrow = (SpectralArrow) world.spawnEntity(
|
||||
player.getLocation(),
|
||||
EntityType.SPECTRAL_ARROW
|
||||
);
|
||||
arrow.setCustomName("weaponsCancelCollision");
|
||||
arrow.setShooter(player);
|
||||
arrow.setVelocity(randomDirection);
|
||||
}
|
||||
|
||||
final Location eyeLocation = event.getPlayer().getEyeLocation();
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 1.5F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.BLOCK_ANVIL_DESTROY,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
event.setCancelled(true);
|
||||
} else if (item == Material.FIRE_CHARGE &&
|
||||
"§rArmageddon".equals(name)) {
|
||||
final World world = event.getPlayer().getWorld();
|
||||
|
||||
for (int i = -12; i <= 12; i += 4) {
|
||||
final Player player = event.getPlayer();
|
||||
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 Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
|
||||
final Fireball fireball = (Fireball) world.spawnEntity(
|
||||
eyeLocation.add(x, 0, z),
|
||||
EntityType.FIREBALL
|
||||
);
|
||||
|
||||
fireball.setBounce(false);
|
||||
fireball.setCustomName("weaponsArmegaddonBall");
|
||||
fireball.setDirection(velocity);
|
||||
fireball.setShooter(player);
|
||||
fireball.setYield(5);
|
||||
}
|
||||
|
||||
final Location eyeLocation = event.getPlayer().getEyeLocation();
|
||||
final float volume = 0.9F;
|
||||
final float pitch = 1.5F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GHAST_SHOOT,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
event.setCancelled(true);
|
||||
} else if (item == Material.MAGMA_CREAM &&
|
||||
"§rBlobinator".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("weaponsBlobinatorBall");
|
||||
snowball.setShooter(player);
|
||||
snowball.setVelocity(velocity);
|
||||
|
||||
final World world = event.getPlayer().getWorld();
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 0.8F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ITEM_BOTTLE_EMPTY,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
event.setCancelled(true);
|
||||
} else if (item == Material.STICK &&
|
||||
"§rLightning Stick".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location lookLocation = player.getTargetBlock((Set<Material>) null, 100).getLocation();
|
||||
final World world = player.getWorld();
|
||||
|
||||
world.strikeLightning(lookLocation);
|
||||
|
||||
event.setCancelled(true);
|
||||
} else if (item == Material.BLAZE_ROD &&
|
||||
"§rNuker".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(10);
|
||||
|
||||
final Fireball fireball = player.launchProjectile(Fireball.class);
|
||||
fireball.setCustomName("weaponsCancelCollision");
|
||||
fireball.setShooter(player);
|
||||
fireball.setVelocity(velocity);
|
||||
fireball.setYield(8);
|
||||
|
||||
final World world = event.getPlayer().getWorld();
|
||||
final float volume1 = 0.9F;
|
||||
final float pitch1 = 1.5F;
|
||||
final float volume2 = 0.8F;
|
||||
final float pitch2 = 2.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GHAST_SHOOT,
|
||||
volume1,
|
||||
pitch1
|
||||
);
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_BAT_TAKEOFF,
|
||||
volume2,
|
||||
pitch2
|
||||
);
|
||||
event.setCancelled(true);
|
||||
} else if (item == Material.IRON_HORSE_ARMOR &&
|
||||
"§rSniper".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.setCustomName("weaponsCancelCollision");
|
||||
snowball.setShooter(player);
|
||||
snowball.setVelocity(velocity);
|
||||
|
||||
final World world = event.getPlayer().getWorld();
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 63.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.BLOCK_PISTON_CONTRACT,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (action == Action.RIGHT_CLICK_AIR ||
|
||||
action == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (item == Material.BLAZE_POWDER &&
|
||||
"§rLaser".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector direction = eyeLocation.getDirection();
|
||||
final Location lookLocation = player.getTargetBlock(
|
||||
(Set<Material>) null,
|
||||
100).getLocation();
|
||||
double distance = eyeLocation.distance(lookLocation);
|
||||
final Location particleLocation = player.getEyeLocation();
|
||||
final World world = player.getWorld();
|
||||
|
||||
if (lookLocation == null) {
|
||||
distance = 50;
|
||||
}
|
||||
|
||||
for (double 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 Particle.DustOptions dustOptions = new Particle.DustOptions(Color.RED, 1);
|
||||
|
||||
world.spawnParticle(
|
||||
Particle.REDSTONE,
|
||||
particleLocation,
|
||||
count,
|
||||
offsetX,
|
||||
offsetY,
|
||||
offsetZ,
|
||||
dustOptions
|
||||
);
|
||||
}
|
||||
|
||||
world.getBlockAt(lookLocation).breakNaturally();
|
||||
|
||||
final float volume1 = 0.8F;
|
||||
final float pitch1 = 63.0F;
|
||||
final float volume2 = 1.0F;
|
||||
final float pitch2 = 20.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR,
|
||||
volume1,
|
||||
pitch1
|
||||
);
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_FIREWORK_ROCKET_BLAST,
|
||||
volume2,
|
||||
pitch2
|
||||
);
|
||||
event.setCancelled(true);
|
||||
} else if (item == Material.GOLDEN_HORSE_ARMOR &&
|
||||
"§rMachine Gun".equals(name)) {
|
||||
final UUID playerUUID = event.getPlayer().getUniqueId();
|
||||
|
||||
if (!main.machineGunActive.contains(playerUUID)) {
|
||||
main.machineGunActive.add(playerUUID);
|
||||
final PlayerInteractEvent eventMachine = event;
|
||||
|
||||
new BukkitRunnable() {
|
||||
int i = 0;
|
||||
public void run() {
|
||||
i++;
|
||||
|
||||
final Player player = eventMachine.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final World world = player.getWorld();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
|
||||
final TippedArrow arrow = player.launchProjectile(TippedArrow.class);
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
arrow.setCustomName("weaponsProjectileBlock");
|
||||
arrow.addCustomEffect(harm, true);
|
||||
arrow.setShooter(player);
|
||||
arrow.setVelocity(velocity);
|
||||
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 63.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GENERIC_EXPLODE,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
|
||||
if (i == 20) {
|
||||
main.machineGunActive.remove(playerUUID);
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(main, 0L, 1L);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
} else if (item == Material.IRON_HORSE_ARMOR &&
|
||||
"§rSniper".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;
|
||||
|
||||
final PotionEffect effect = new PotionEffect(
|
||||
PotionEffectType.SLOW,
|
||||
duration,
|
||||
amplifier
|
||||
);
|
||||
player.addPotionEffect(effect);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onProjectileCollide(ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.FIREBALL) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("weaponsArmegaddonBall".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.getType() == EntityType.FIREBALL) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else if (event.getEntityType() == EntityType.SNOWBALL) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("weaponsBlobinatorBall".equals(projectile.getCustomName())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (event.getEntityType() == EntityType.SPECTRAL_ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("weaponsProjectileBlock".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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onProjectileHit(ProjectileHitEvent event) {
|
||||
if (event.getEntityType() == EntityType.EGG) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("weaponsGrenade".equals(projectile.getCustomName())) {
|
||||
final Location location = projectile.getLocation();
|
||||
final World world = location.getWorld();
|
||||
final float power = 6;
|
||||
|
||||
world.createExplosion(location, power);
|
||||
}
|
||||
} else if (event.getEntityType() == EntityType.TIPPED_ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("weaponsProjectileBlock".equals(projectile.getCustomName())) {
|
||||
projectile.remove();
|
||||
}
|
||||
} else if (event.getEntityType() == EntityType.SNOWBALL) {
|
||||
final Block hitBlock = event.getHitBlock();
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if (hitBlock != null &&
|
||||
"weaponsBlobinatorBall".equals(projectile.getCustomName())) {
|
||||
final int radius = 4;
|
||||
final World world = projectile.getWorld();
|
||||
final Random random = new Random();
|
||||
final Material color = main.colors.get(random.nextInt(main.colors.size()));
|
||||
|
||||
for (int x = -radius; x < radius; x++) {
|
||||
for (int y = -radius; y < radius; y++) {
|
||||
for (int z = -radius; z < radius; z++) {
|
||||
final Location blockLocation = hitBlock.getLocation().add(x, y, z);
|
||||
|
||||
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.faces) {
|
||||
if (block.getRelative(face).getType() == Material.AIR ||
|
||||
block.getRelative(face).getType() == Material.CAVE_AIR) {
|
||||
block.setType(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -15,27 +15,10 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
public class Main extends JavaPlugin {
|
||||
HashSet<BlockFace> faces = new HashSet<>();
|
||||
HashSet<UUID> machineGunActive = new HashSet<>();
|
||||
List<Material> colors = new ArrayList<>();
|
||||
|
||||
List<Material> colors = Arrays.asList(
|
||||
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
|
||||
);
|
||||
|
||||
public void onEnable() {
|
||||
public void onLoad() {
|
||||
/* Fill lists */
|
||||
Collections.addAll(
|
||||
faces,
|
||||
BlockFace.NORTH,
|
||||
|
@ -46,7 +29,40 @@ public class Main extends JavaPlugin {
|
|||
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
|
||||
);
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
/* Commands */
|
||||
this.getCommand("weapons").setExecutor(new CommandWeapons());
|
||||
this.getServer().getPluginManager().registerEvents(new Events(this), 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);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponGrenade(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponMachineGun(this), this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
class PlayerReceiveWeapon implements Listener {
|
||||
@EventHandler
|
||||
void onInventoryClick(InventoryClickEvent event) {
|
||||
if ("Weapons".equals(event.getView().getTitle())) {
|
||||
final ItemStack item = event.getCurrentItem();
|
||||
|
||||
if (item.getItemMeta().hasDisplayName() == true) {
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
|
||||
player.getInventory().addItem(item);
|
||||
player.closeInventory();
|
||||
player.sendMessage("You have received the " + item.getItemMeta().getDisplayName().toLowerCase() + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
class PlayerUseWeapon implements Listener {
|
||||
@EventHandler
|
||||
void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.hasItem() == true &&
|
||||
event.getItem().getItemMeta().hasDisplayName() == true) {
|
||||
final Action action = event.getAction();
|
||||
final Material item = event.getMaterial();
|
||||
final String name = event.getItem().getItemMeta().getDisplayName();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
class WeaponAnvilDropper {
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.ANVIL &&
|
||||
"§rAnvil Dropper".equals(name)) {
|
||||
for (int x = -2; x <= 2; x++) {
|
||||
for (int z = -2; z <= 2; 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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.SpectralArrow;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
|
||||
|
||||
class WeaponArcher implements Listener {
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.SPECTRAL_ARROW &&
|
||||
"§rArcher".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final World world = player.getWorld();
|
||||
|
||||
for (int i = 0; i <= 20; 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 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;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.BLOCK_ANVIL_DESTROY,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* Make shooter invulnerable to weapon projectiles */
|
||||
@EventHandler
|
||||
void onProjectileCollide(ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.SPECTRAL_ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
|
||||
|
||||
class WeaponArmageddon implements Listener {
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.FIRE_CHARGE &&
|
||||
"§rArmageddon".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final World world = player.getWorld();
|
||||
|
||||
for (int i = -12; i <= 12; i += 4) {
|
||||
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 Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
|
||||
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(5);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* Make shooter invulnerable to weapon projectiles, and prevent charges from colliding with each other */
|
||||
@EventHandler
|
||||
void onProjectileCollide(ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.FIREBALL) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Snowball;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
|
||||
|
||||
class WeaponBlobinator implements Listener {
|
||||
Main main;
|
||||
WeaponBlobinator(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.MAGMA_CREAM &&
|
||||
"§rBlobinator".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 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);
|
||||
}
|
||||
}
|
||||
|
||||
private void createBlobSplash(World world, int x, int y, int z, int radius, Block hitBlock, Material color) {
|
||||
final Location blockLocation = hitBlock.getLocation().add(x, y, z);
|
||||
|
||||
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.faces) {
|
||||
if (block.getRelative(face).getType() == Material.AIR ||
|
||||
block.getRelative(face).getType() == Material.CAVE_AIR) {
|
||||
block.setType(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onProjectileCollide(ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.SNOWBALL) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("WeaponBlobinatorBall".equals(projectile.getCustomName())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onProjectileHit(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.colors.get(random.nextInt(main.colors.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
class WeaponGrenade implements Listener {
|
||||
static void rightClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.EGG &&
|
||||
"§rGrenade".equals(name)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
|
||||
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;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_EGG_THROW,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerEggThrow(PlayerEggThrowEvent event) {
|
||||
if ("WeaponGrenade".equals(event.getEgg().getCustomName())) {
|
||||
event.setHatching(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onProjectileHit(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;
|
||||
|
||||
world.createExplosion(location, power);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
class WeaponLaser {
|
||||
static void rightClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.BLAZE_POWDER &&
|
||||
"§rLaser".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector direction = eyeLocation.getDirection();
|
||||
final Location lookLocation = player.getTargetBlock(
|
||||
(Set<Material>) null,
|
||||
100).getLocation();
|
||||
double distance = eyeLocation.distance(lookLocation);
|
||||
final Location particleLocation = player.getEyeLocation();
|
||||
final World world = player.getWorld();
|
||||
|
||||
if (lookLocation == null) {
|
||||
distance = 50;
|
||||
}
|
||||
|
||||
for (double 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 Particle.DustOptions dustOptions = new Particle.DustOptions(Color.RED, 1);
|
||||
|
||||
world.spawnParticle(
|
||||
Particle.REDSTONE,
|
||||
particleLocation,
|
||||
count,
|
||||
offsetX,
|
||||
offsetY,
|
||||
offsetZ,
|
||||
dustOptions
|
||||
);
|
||||
}
|
||||
|
||||
world.getBlockAt(lookLocation).breakNaturally();
|
||||
|
||||
final float volume1 = 0.8F;
|
||||
final float pitch1 = 63.0F;
|
||||
final float volume2 = 1.0F;
|
||||
final float pitch2 = 20.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR,
|
||||
volume1,
|
||||
pitch1
|
||||
);
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_FIREWORK_ROCKET_BLAST,
|
||||
volume2,
|
||||
pitch2
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
class WeaponLightningStick {
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.STICK &&
|
||||
"§rLightning Stick".equals(name)) {
|
||||
final Location lookLocation = event.getPlayer().getTargetBlock((Set<Material>) null, 100).getLocation();
|
||||
final World world = event.getPlayer().getWorld();
|
||||
|
||||
world.strikeLightning(lookLocation);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.TippedArrow;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
class WeaponMachineGun implements Listener {
|
||||
static Main main;
|
||||
WeaponMachineGun(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
static void rightClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.GOLDEN_HORSE_ARMOR &&
|
||||
"§rMachine Gun".equals(name)) {
|
||||
final UUID playerUUID = event.getPlayer().getUniqueId();
|
||||
|
||||
if (!main.machineGunActive.contains(playerUUID)) {
|
||||
main.machineGunActive.add(playerUUID);
|
||||
final PlayerInteractEvent eventMachine = event;
|
||||
|
||||
new BukkitRunnable() {
|
||||
int i = 0;
|
||||
public void run() {
|
||||
i++;
|
||||
|
||||
final Player player = eventMachine.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final World world = player.getWorld();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
|
||||
final TippedArrow arrow = player.launchProjectile(TippedArrow.class);
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
arrow.setCustomName("WeaponMachineGunBullet");
|
||||
arrow.addCustomEffect(harm, true);
|
||||
arrow.setShooter(player);
|
||||
arrow.setVelocity(velocity);
|
||||
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 63.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GENERIC_EXPLODE,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
|
||||
if (i == 20) {
|
||||
main.machineGunActive.remove(playerUUID);
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(main, 0L, 1L);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onProjectileHit(ProjectileHitEvent event) {
|
||||
if (event.getEntityType() == EntityType.TIPPED_ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("WeaponMachineGunBullet".equals(projectile.getCustomName())) {
|
||||
projectile.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
class WeaponNuker {
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.BLAZE_ROD &&
|
||||
"§rNuker".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(10);
|
||||
|
||||
final Fireball fireball = player.launchProjectile(Fireball.class);
|
||||
fireball.setShooter(player);
|
||||
fireball.setVelocity(velocity);
|
||||
fireball.setYield(8);
|
||||
|
||||
final World world = player.getWorld();
|
||||
final float volume1 = 0.9F;
|
||||
final float pitch1 = 1.5F;
|
||||
final float volume2 = 0.8F;
|
||||
final float pitch2 = 2.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GHAST_SHOOT,
|
||||
volume1,
|
||||
pitch1
|
||||
);
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_BAT_TAKEOFF,
|
||||
volume2,
|
||||
pitch2
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package pw.kaboom.weapons;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Snowball;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
class WeaponSniper {
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.IRON_HORSE_ARMOR &&
|
||||
"§rSniper".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 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);
|
||||
}
|
||||
}
|
||||
|
||||
static void rightClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.IRON_HORSE_ARMOR &&
|
||||
"§rSniper".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;
|
||||
|
||||
final PotionEffect effect = new PotionEffect(
|
||||
PotionEffectType.SLOW,
|
||||
duration,
|
||||
amplifier
|
||||
);
|
||||
player.addPotionEffect(effect);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,5 +8,4 @@ commands:
|
|||
weapons:
|
||||
aliases: weapon
|
||||
description: Gives you a weapon
|
||||
usage: /weapons
|
||||
permission: weapons.command
|
||||
|
|
Loading…
Reference in New Issue