Permalink
Browse files

Updated to 1.2.5

  • Loading branch information...
Butkicker12 committed May 6, 2012
1 parent ff77499 commit 82ae6ef7745c61d7d727e04994f66c80bd8586e2
View
@@ -1,2 +0,0 @@
-Shotgun
-=======
View
@@ -13,8 +13,14 @@ permissions:
description: Uses the airstrike command
default: op
shotgun.shotgun:
- description: Uses the shotgun command
+ description: Uses the shotgun
default: op
shotgun.nuke:
description: Uses the nuke command
+ default: op
+ shotgun.grenade:
+ description: Uses the grenade
+ default: op
+ shotgun.smoke:
+ description: Uses the smoke grenade
default: op
@@ -1,14 +1,38 @@
package com.thebkkingdom.Shotgun;
+import org.bukkit.Effect;
+import org.bukkit.entity.Egg;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent;
public class EntityListener implements Listener {
-
@EventHandler
public void ProjectileHit(ProjectileHitEvent event) {
// if egg hits create explosion, snowball smoke
+ Entity entity = event.getEntity();
+ Player player = (Player) entity;
+
+ if (entity instanceof Egg) {
+ if (player.hasPermission("shotgun.grenade")) {
+ entity.getWorld().createExplosion(entity.getLocation(), 5F);
+ entity.getWorld().playEffect(entity.getLocation(),
+ Effect.MOBSPAWNER_FLAMES, 100);
+ }
+ }
+
+ if (entity instanceof Snowball) {
+ if (player.hasPermission("shotgun.smoke")) {
+ entity.getWorld().createExplosion(entity.getLocation(), -10F);
+ for (int i = 0; i < 20; i++) {
+ entity.getWorld().playEffect(entity.getLocation(),
+ Effect.SMOKE, 1);
+ }
+ }
+ }
}
}
@@ -25,61 +25,47 @@ public void playerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_AIR) {
if (player.getItemInHand().getType() == Material.BOOK) {
if (player.hasPermission("shotgun.shotgun")) {
+ /*
+ * Checks if player has 5 arrows. If they do then it fires.
+ */
+ if (player.getInventory().contains(Material.ARROW, 5)) {
- world.playEffect(playerLocation, Effect.BOW_FIRE, 50);
- world.playEffect(playerLocation, Effect.SMOKE, 105);
+ player.getInventory().removeItem(new ItemStack(Material.ARROW, 5));
- // run task twice
- for (int i = 0; i < 2; i++) {
- world.createExplosion(playerLocation, -1);
- }
+ world.playEffect(playerLocation, Effect.BOW_FIRE, 50);
+ world.playEffect(playerLocation, Effect.SMOKE, 105);
- // Runs the task 5 times
- for (int i = 0; i < 5; i++) {
- player.launchProjectile(Arrow.class);
- }
+ // run task twice
+ for (int i = 0; i < 2; i++) {
+ world.createExplosion(playerLocation, -1);
+ }
-
- // Checks if player has exactly five arrows. Needs to check if player has 5 or more arrows.
- if (player.getInventory().contains(
- new ItemStack(Material.ARROW, 5))) {
- player.getInventory().removeItem(
- new ItemStack(Material.ARROW, 5));
-
- //fire arrow now
+ // Runs the task 5 times
+ for (int i = 0; i < 5; i++) {
+ player.launchProjectile(Arrow.class);
+ }
} else {
player.sendMessage(ChatColor.BLUE
+ "[Shotgun] You need at least 5 arrows to use the shotgun!");
}
}
}
- if (player.getItemInHand().getType() == Material.SNOW_BALL) {
- player.getWorld().playEffect(playerLocation, Effect.EXTINGUISH,
- 100);
- }
-
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
if (player.getItemInHand().getType() == Material.BOOK) {
+ player.sendMessage(ChatColor.BLUE
+ + "[Shotgun] Sorry this feature does not work right now. :( It will be back soon!");
//world.spawnCreature(playerLocation, EntityType.FIREBALL);
/*
- Fireball fb = this.b.getEntity().launchProjectile(
- Fireball.class);
- fb.setYield(200);
- fb.setBounce(false);
- fb.setDirection(p
- .getPlayer()
- .getVelocity()
- .add(p.getPlayer()
- .getLocation()
- .toVector()
- .subtract(
- this.b.getEntity().getLocation()
- .toVector()).normalize()
- .multiply(Integer.MAX_VALUE)));
- */
+ * Fireball fb = this.b.getEntity().launchProjectile(
+ * Fireball.class); fb.setYield(200); fb.setBounce(false);
+ * fb.setDirection(p .getPlayer() .getVelocity()
+ * .add(p.getPlayer() .getLocation() .toVector() .subtract(
+ * this.b.getEntity().getLocation() .toVector()).normalize()
+ * .multiply(Integer.MAX_VALUE)));
+ */
}
}
}
@@ -13,7 +13,6 @@
public void onEnable() {
this.registerEvents();
- System.out.println("[Shotgun enabled]");
}

0 comments on commit 82ae6ef

Please sign in to comment.