fixed anti-breeding
This commit is contained in:
parent
8acf96fc34
commit
e23a269b8c
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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() {
|
||||
|
@ -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<String, DiscoParty> parties = new HashMap<String, DiscoParty>();
|
||||
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<String, DiscoParty> getPartyMap() {
|
||||
return this.parties;
|
||||
}
|
||||
|
||||
public List<DiscoParty> 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<String, DiscoParty> parties = new HashMap<String, DiscoParty>();
|
||||
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<String, DiscoParty> getPartyMap() {
|
||||
return this.parties;
|
||||
}
|
||||
|
||||
public List<DiscoParty> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user