mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-28 16:16:47 +01:00
Changed to have all alt-fire be a projectile. Need to implement on-hit
effects.
This commit is contained in:
parent
00fc5b93d2
commit
4965cb2b68
@ -20,6 +20,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
|||||||
import org.bukkit.event.entity.EntityTameEvent;
|
import org.bukkit.event.entity.EntityTameEvent;
|
||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import com.gmail.nossr50.Combat;
|
import com.gmail.nossr50.Combat;
|
||||||
@ -313,4 +314,29 @@ public class mcEntityListener implements Listener {
|
|||||||
Skills.XpCheckSkill(SkillType.TAMING, player);
|
Skills.XpCheckSkill(SkillType.TAMING, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Monitor ProjectileHit events.
|
||||||
|
*
|
||||||
|
* @param event The event to monitor
|
||||||
|
*/
|
||||||
|
public void onProjectileHit(ProjectileHitEvent event) {
|
||||||
|
if (!event.getEntity().hasMetadata("mcmmoFiredFromStaff")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (event.getEntityType()) {
|
||||||
|
case EGG:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FIREBALL:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SNOWBALL:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ public class mcPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* STAFF CHECKS */
|
/* STAFF CHECKS */
|
||||||
Staves.altFire(is.getType(), player);
|
Staves.altFire(is.getType(), player, plugin);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ public class mcPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* STAFF CHECKS */
|
/* STAFF CHECKS */
|
||||||
Staves.altFire(is.getType(), player);
|
Staves.altFire(is.getType(), player, plugin);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1,52 +1,44 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
import org.bukkit.entity.Egg;
|
||||||
import org.bukkit.entity.Fireball;
|
import org.bukkit.entity.Fireball;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Projectile;
|
||||||
|
import org.bukkit.entity.Snowball;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import com.gmail.nossr50.m;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
public class Staves {
|
public class Staves {
|
||||||
|
|
||||||
public static void altFire(Material type, Player attacker) {
|
/**
|
||||||
|
* Fire a projectile on alt-fire from a staff.
|
||||||
|
*
|
||||||
|
* @param type The type of staff
|
||||||
|
* @param attacker The attacking player
|
||||||
|
* @param plugin mcMMO plugin instance
|
||||||
|
*/
|
||||||
|
public static void altFire(Material type, Player attacker, mcMMO plugin) {
|
||||||
|
Projectile projectile = null;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BLAZE_ROD:
|
case BLAZE_ROD:
|
||||||
attacker.launchProjectile(Fireball.class);
|
projectile = attacker.launchProjectile(Fireball.class);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BONE:
|
case BONE:
|
||||||
for (Player y : attacker.getWorld().getPlayers()) {
|
projectile = attacker.launchProjectile(Snowball.class);
|
||||||
if (y != attacker && m.isNear(attacker.getLocation(), y.getLocation(), 10) && y.getLevel() > 0) {
|
|
||||||
y.setLevel((int) (y.getLevel() * .75));
|
|
||||||
attacker.sendMessage("You drained your opponent of XP!");
|
|
||||||
y.sendMessage("You feel some of your power leave you...");
|
|
||||||
|
|
||||||
for (int i = 0; i <= 100; i++) {
|
|
||||||
Location dropLocation = y.getLocation();
|
|
||||||
dropLocation.setX(dropLocation.getX() + (Math.random() * 2));
|
|
||||||
dropLocation.setZ(dropLocation.getZ() + (Math.random() * 2));
|
|
||||||
ExperienceOrb orb = y.getWorld().spawn(dropLocation, ExperienceOrb.class);
|
|
||||||
orb.setExperience((int) (Math.random() * 5));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STICK:
|
case STICK:
|
||||||
for (Player y : attacker.getWorld().getPlayers()) {
|
projectile = attacker.launchProjectile(Egg.class);
|
||||||
if (y != attacker && m.isNear(attacker.getLocation(), y.getLocation(), 10)) {
|
|
||||||
attacker.sendMessage("You slowed your opponent!");
|
|
||||||
y.sendMessage("You were suddenly slowed...");
|
|
||||||
|
|
||||||
y.setVelocity(y.getVelocity().multiply(0.5));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
projectile.setMetadata("mcmmoFiredFromStaff", new FixedMetadataValue(plugin, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user