From e23a269b8c8dd3e70a08399891bed6f59d522566 Mon Sep 17 00:00:00 2001 From: Charlie Wang Date: Sun, 30 Jun 2013 21:57:32 -0400 Subject: [PATCH] fixed anti-breeding --- ...earer.java => BaaBaaBlockSheepEvents.java} | 95 +++++++------- .../bukkit/discosheep/DiscoParty.java | 3 +- .../bukkit/discosheep/DiscoSheep.java | 117 +++++++++--------- 3 files changed, 108 insertions(+), 107 deletions(-) rename src/gibstick/bukkit/discosheep/{SheepDeshearer.java => BaaBaaBlockSheepEvents.java} (86%) diff --git a/src/gibstick/bukkit/discosheep/SheepDeshearer.java b/src/gibstick/bukkit/discosheep/BaaBaaBlockSheepEvents.java similarity index 86% rename from src/gibstick/bukkit/discosheep/SheepDeshearer.java rename to src/gibstick/bukkit/discosheep/BaaBaaBlockSheepEvents.java index 493b6e8..afa0318 100644 --- a/src/gibstick/bukkit/discosheep/SheepDeshearer.java +++ b/src/gibstick/bukkit/discosheep/BaaBaaBlockSheepEvents.java @@ -1,47 +1,48 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package gibstick.bukkit.discosheep; - -import org.bukkit.entity.Sheep; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.player.PlayerShearEntityEvent; - -/** - * - * @author Mauve - */ -public class SheepDeshearer implements Listener { - - DiscoSheep parent; - - public SheepDeshearer(DiscoSheep parent) { - this.parent = parent; - } - - @EventHandler - public void onPlayerShear(PlayerShearEntityEvent e) { - if (e.getEntity() instanceof Sheep) { - for (DiscoParty party : parent.getParties()) { - if (party.getSheep().contains((Sheep) e.getEntity())) { - e.setCancelled(true); - } - } - } - } - - @EventHandler - public void onCreatureSpawn(CreatureSpawnEvent e) { - if (e.getEntity() instanceof Sheep && - e.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.BREEDING)) { - for (DiscoParty party : parent.getParties()) { - if (party.getSheep().contains((Sheep) e.getEntity())) { - e.setCancelled(true); - } - } - } - } -} +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package gibstick.bukkit.discosheep; + +import org.bukkit.entity.Sheep; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.player.PlayerShearEntityEvent; + +/** + * + * @author Mauve + */ +public class BaaBaaBlockSheepEvents implements Listener { + + DiscoSheep parent; + + public BaaBaaBlockSheepEvents(DiscoSheep parent) { + this.parent = parent; + } + + @EventHandler + public void onPlayerShear(PlayerShearEntityEvent e) { + if (e.getEntity() instanceof Sheep) { + for (DiscoParty party : parent.getParties()) { + if (party.getSheep().contains((Sheep) e.getEntity())) { + e.setCancelled(true); + } + } + } + } + + @EventHandler + public void onCreatureSpawn(CreatureSpawnEvent e) { + if (e.getEntity() instanceof Sheep && + e.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.BREEDING)) { + for (DiscoParty party : parent.getParties()) { + if (party.getSheep().contains((Sheep) e.getEntity())) { + e.setCancelled(true); + + } + } + } + } +} diff --git a/src/gibstick/bukkit/discosheep/DiscoParty.java b/src/gibstick/bukkit/discosheep/DiscoParty.java index 31f71ed..540d289 100644 --- a/src/gibstick/bukkit/discosheep/DiscoParty.java +++ b/src/gibstick/bukkit/discosheep/DiscoParty.java @@ -55,6 +55,7 @@ public class DiscoParty { newSheep.setHealth(10000); newSheep.setColor(discoColours[(int) Math.round(Math.random() * (discoColours.length - 1))]); newSheep.setTarget(player); + newSheep.setAgeLock(true); getSheep().add(newSheep); } @@ -100,7 +101,7 @@ public class DiscoParty { if(this.state%3 == 0){ player.playSound(player.getLocation(), Sound.NOTE_STICKS, 1.0f, 1.0f); } - player.playSound(player.getLocation(), Sound.BURP, frequency, (float) Math.random() + 1); + player.playSound(player.getLocation(), Sound.BURP, 0.5f, (float) Math.random() + 1); } void update() { diff --git a/src/gibstick/bukkit/discosheep/DiscoSheep.java b/src/gibstick/bukkit/discosheep/DiscoSheep.java index c02e9fc..049516c 100644 --- a/src/gibstick/bukkit/discosheep/DiscoSheep.java +++ b/src/gibstick/bukkit/discosheep/DiscoSheep.java @@ -1,59 +1,58 @@ -package gibstick.bukkit.discosheep; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -public final class DiscoSheep extends JavaPlugin { - - Map parties = new HashMap(); - private SheepDeshearer deshear = new SheepDeshearer(this); - // array of accetable disco colours (order not important) - - @Override - public void onEnable() { - getCommand("ds").setExecutor(new DiscoSheepCommandExecutor(this)); - getServer().getPluginManager().registerEvents(deshear, this); - } - - @Override - public void onDisable() { - } - - public Map getPartyMap() { - return this.parties; - } - - public List getParties() { - return new ArrayList(this.parties.values()); - } - - public void stopParty(String name) { - if (this.hasParty(name)) { - this.getParty(name).stopDisco(); - } - } - - public boolean hasParty(String name) { - return this.parties.containsKey(name); - } - - public DiscoParty getParty(String name) { - return this.parties.get(name); - } - - public void removeParty(String name) { - if (this.hasParty(name)) { - this.parties.remove(name); - } - } - - public void startParty(Player player) { - if (!hasParty(player.getName())) { - new DiscoParty(this, player).startDisco(); - } - } -} +package gibstick.bukkit.discosheep; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +public final class DiscoSheep extends JavaPlugin { + + Map parties = new HashMap(); + private BaaBaaBlockSheepEvents deshear = new BaaBaaBlockSheepEvents(this); + + @Override + public void onEnable() { + getCommand("ds").setExecutor(new DiscoSheepCommandExecutor(this)); + getServer().getPluginManager().registerEvents(deshear, this); + } + + @Override + public void onDisable() { + } + + public Map getPartyMap() { + return this.parties; + } + + public List getParties() { + return new ArrayList(this.parties.values()); + } + + public void stopParty(String name) { + if (this.hasParty(name)) { + this.getParty(name).stopDisco(); + } + } + + public boolean hasParty(String name) { + return this.parties.containsKey(name); + } + + public DiscoParty getParty(String name) { + return this.parties.get(name); + } + + public void removeParty(String name) { + if (this.hasParty(name)) { + this.parties.remove(name); + } + } + + public void startParty(Player player) { + if (!hasParty(player.getName())) { + new DiscoParty(this, player).startDisco(); + } + } +}