Eggs no longer spawn chickens. :D

This commit is contained in:
GJ 2012-03-21 23:48:55 -04:00
parent 1b15828d08
commit abe01a84e5
3 changed files with 26 additions and 20 deletions

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.listeners;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -164,13 +165,24 @@ public class mcEntityListener implements Listener {
*
* @param event The event to monitor
*/
@EventHandler (priority = EventPriority.MONITOR)
@EventHandler (priority = EventPriority.LOW)
public void onCreatureSpawn(CreatureSpawnEvent event) {
SpawnReason reason = event.getSpawnReason();
if ((reason.equals(SpawnReason.SPAWNER) || reason.equals(SpawnReason.SPAWNER_EGG)) && !LoadProperties.xpGainsMobSpawners) {
event.getEntity().setMetadata("mcmmoFromMobSpawner", new FixedMetadataValue(plugin, true));
}
else if (event.getSpawnReason().equals(SpawnReason.EGG)) {
Location eLoc = event.getLocation();
for (Entity projectile : plugin.projectileTracker) {
Location pLoc = projectile.getLocation();
if (pLoc.getX() == eLoc.getX() && pLoc.getY() == eLoc.getY() && pLoc.getZ() == eLoc.getZ()) {
event.setCancelled(true);
}
}
}
}
/**
@ -320,25 +332,13 @@ public class mcEntityListener implements Listener {
/**
* Monitor ProjectileHit events.
*
* @param event The event to monitor
* @param event The event to watch
*/
@EventHandler (priority = EventPriority.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;
Entity projectile = event.getEntity();
if (plugin.projectileTracker.contains(projectile)) {
plugin.projectileTracker.remove(projectile);
}
}
}

View File

@ -23,6 +23,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -48,8 +49,11 @@ public class mcMMO extends JavaPlugin {
//Alias - Command
public HashMap<String, String> aliasMap = new HashMap<String, String>();
//Various trackers
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
public HashSet<Entity> projectileTracker = new HashSet<Entity>();
public static Database database = null;

View File

@ -59,7 +59,7 @@ public class Staves {
* @param plugin mcMMO plugin instance
*/
public static void altFire(Material type, Player attacker, mcMMO plugin) {
Projectile projectile = null;
Projectile projectile;
switch (type) {
case BLAZE_ROD:
@ -75,9 +75,10 @@ public class Staves {
break;
default:
break;
return;
}
plugin.projectileTracker.add(projectile);
projectile.setMetadata("mcmmoFiredFromStaff", new FixedMetadataValue(plugin, true));
}
@ -119,6 +120,7 @@ public class Staves {
duration = (TICKS_PER_SECOND * MAX_SPEED_DURATION_SECONDS);
}
shooter.setLevel(shooter.getLevel() - 2);
target.addPotionEffect(new PotionEffect(type, duration, amplifier));
if (type.equals(PotionEffectType.SLOW)) {