Implemented shear prevention on spawned sheep

This commit is contained in:
RangerMauve 2013-06-30 16:13:29 -04:00
parent 9dba2a1be3
commit 572cb5a9d6
2 changed files with 24 additions and 8 deletions

View File

@ -13,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin;
public final class DiscoSheep extends JavaPlugin {
private ArrayList<Sheep> sheepArray = new ArrayList<Sheep>();
private SheepDeshearer deshear = new SheepDeshearer(sheepArray);
private static final DyeColor[] discoColours = {
DyeColor.RED,
DyeColor.ORANGE,
@ -33,11 +34,12 @@ public final class DiscoSheep extends JavaPlugin {
@Override
public void onEnable() {
getCommand("ds").setExecutor(new DiscoSheepCommandExecutor(this));
getServer().getPluginManager().registerEvents(deshear, this);
}
@Override
public void onDisable() {
// Watashi Wa Kawaii, Ne?
getServer().getPluginManager();
}
ArrayList<Sheep> getSheep() {

View File

@ -4,14 +4,28 @@
*/
package gibstick.bukkit.discosheep;
import java.util.List;
import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerShearEntityEvent;
/**
*
* @author Mauve
*/
public class SheepDeshearer implements Listener {
public SheepDeshearer(DiscoSheep parent){
List<Sheep> sheep;
public SheepDeshearer(List sheep) {
this.sheep = sheep;
}
@EventHandler
public void onPlayerShear(PlayerShearEntityEvent e) {
if (e.getEntity() instanceof Sheep && sheep.contains((Sheep) e.getEntity())) {
e.setCancelled(true);
}
}
}