Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(event.getDamager() instanceof Player && event.getEntity() instanceof Player){
- Player entity = (Player) event.getEntity();
- ItemStack is;
- Potion p = null;
- is = new ItemStack(Material.POTION);
- // Apply Potion Effect
- // [!] Make sure to not apply damage effect
- Random ran = new Random();
- int ranNum = ran.nextInt(3);
- if (ranNum == 0) {
- p = new Potion(PotionType.INSTANT_DAMAGE, 1);
- } else if (ranNum == 1){
- p = new Potion(PotionType.SLOWNESS, 1);
- } else if (ranNum == 2) {
- p = new Potion(PotionType.POISON, 1);
- }
- p.setSplash(true);
- p.apply(is);
- ThrownPotion tp = (ThrownPotion) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.SPLASH_POTION);
- tp.setMetadata("player", new FixedMetadataValue(SpecialWeapons.getInstance(), entity.getName()));
- tp.setItem(is);
- tp.setShooter(entity);
- }
- }
- @EventHandler
- public void onPotionSplash(PotionSplashEvent event) {
- ThrownPotion tp = event.getPotion();
- for (LivingEntity livingEntityList : event.getAffectedEntities()) {
- if (livingEntityList.getType() == EntityType.PLAYER) {
- final Player targetPlayer = (Player) livingEntityList;
- Player shooterPlayer = (Player) tp.getShooter();
- if (!(shooterPlayer.getName() == targetPlayer.getName())) {
- event.getAffectedEntities().remove(livingEntityList);
- for (PotionEffect potionEffectList : event.getPotion().getEffects()) {
- final PotionEffectType potionEffectType = potionEffectList.getType();
- new BukkitRunnable() {
- public void run() {
- targetPlayer.removePotionEffect(potionEffectType);
- }
- }.runTaskLater(SpecialWeapons.getInstance(), 3L);
- }
- }
- } else {
- event.getAffectedEntities().remove(livingEntityList);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement