fixed anti-breeding
This commit is contained in:
parent
8acf96fc34
commit
e23a269b8c
@ -1,47 +1,48 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* To change this template, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package gibstick.bukkit.discosheep;
|
package gibstick.bukkit.discosheep;
|
||||||
|
|
||||||
import org.bukkit.entity.Sheep;
|
import org.bukkit.entity.Sheep;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Mauve
|
* @author Mauve
|
||||||
*/
|
*/
|
||||||
public class SheepDeshearer implements Listener {
|
public class BaaBaaBlockSheepEvents implements Listener {
|
||||||
|
|
||||||
DiscoSheep parent;
|
DiscoSheep parent;
|
||||||
|
|
||||||
public SheepDeshearer(DiscoSheep parent) {
|
public BaaBaaBlockSheepEvents(DiscoSheep parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerShear(PlayerShearEntityEvent e) {
|
public void onPlayerShear(PlayerShearEntityEvent e) {
|
||||||
if (e.getEntity() instanceof Sheep) {
|
if (e.getEntity() instanceof Sheep) {
|
||||||
for (DiscoParty party : parent.getParties()) {
|
for (DiscoParty party : parent.getParties()) {
|
||||||
if (party.getSheep().contains((Sheep) e.getEntity())) {
|
if (party.getSheep().contains((Sheep) e.getEntity())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent e) {
|
public void onCreatureSpawn(CreatureSpawnEvent e) {
|
||||||
if (e.getEntity() instanceof Sheep &&
|
if (e.getEntity() instanceof Sheep &&
|
||||||
e.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.BREEDING)) {
|
e.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.BREEDING)) {
|
||||||
for (DiscoParty party : parent.getParties()) {
|
for (DiscoParty party : parent.getParties()) {
|
||||||
if (party.getSheep().contains((Sheep) e.getEntity())) {
|
if (party.getSheep().contains((Sheep) e.getEntity())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -55,6 +55,7 @@ public class DiscoParty {
|
|||||||
newSheep.setHealth(10000);
|
newSheep.setHealth(10000);
|
||||||
newSheep.setColor(discoColours[(int) Math.round(Math.random() * (discoColours.length - 1))]);
|
newSheep.setColor(discoColours[(int) Math.round(Math.random() * (discoColours.length - 1))]);
|
||||||
newSheep.setTarget(player);
|
newSheep.setTarget(player);
|
||||||
|
newSheep.setAgeLock(true);
|
||||||
getSheep().add(newSheep);
|
getSheep().add(newSheep);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ public class DiscoParty {
|
|||||||
if(this.state%3 == 0){
|
if(this.state%3 == 0){
|
||||||
player.playSound(player.getLocation(), Sound.NOTE_STICKS, 1.0f, 1.0f);
|
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() {
|
void update() {
|
||||||
|
@ -1,59 +1,58 @@
|
|||||||
package gibstick.bukkit.discosheep;
|
package gibstick.bukkit.discosheep;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public final class DiscoSheep extends JavaPlugin {
|
public final class DiscoSheep extends JavaPlugin {
|
||||||
|
|
||||||
Map<String, DiscoParty> parties = new HashMap<String, DiscoParty>();
|
Map<String, DiscoParty> parties = new HashMap<String, DiscoParty>();
|
||||||
private SheepDeshearer deshear = new SheepDeshearer(this);
|
private BaaBaaBlockSheepEvents deshear = new BaaBaaBlockSheepEvents(this);
|
||||||
// array of accetable disco colours (order not important)
|
|
||||||
|
@Override
|
||||||
@Override
|
public void onEnable() {
|
||||||
public void onEnable() {
|
getCommand("ds").setExecutor(new DiscoSheepCommandExecutor(this));
|
||||||
getCommand("ds").setExecutor(new DiscoSheepCommandExecutor(this));
|
getServer().getPluginManager().registerEvents(deshear, this);
|
||||||
getServer().getPluginManager().registerEvents(deshear, this);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void onDisable() {
|
||||||
public void onDisable() {
|
}
|
||||||
}
|
|
||||||
|
public Map<String, DiscoParty> getPartyMap() {
|
||||||
public Map<String, DiscoParty> getPartyMap() {
|
return this.parties;
|
||||||
return this.parties;
|
}
|
||||||
}
|
|
||||||
|
public List<DiscoParty> getParties() {
|
||||||
public List<DiscoParty> getParties() {
|
return new ArrayList(this.parties.values());
|
||||||
return new ArrayList(this.parties.values());
|
}
|
||||||
}
|
|
||||||
|
public void stopParty(String name) {
|
||||||
public void stopParty(String name) {
|
if (this.hasParty(name)) {
|
||||||
if (this.hasParty(name)) {
|
this.getParty(name).stopDisco();
|
||||||
this.getParty(name).stopDisco();
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public boolean hasParty(String name) {
|
||||||
public boolean hasParty(String name) {
|
return this.parties.containsKey(name);
|
||||||
return this.parties.containsKey(name);
|
}
|
||||||
}
|
|
||||||
|
public DiscoParty getParty(String name) {
|
||||||
public DiscoParty getParty(String name) {
|
return this.parties.get(name);
|
||||||
return this.parties.get(name);
|
}
|
||||||
}
|
|
||||||
|
public void removeParty(String name) {
|
||||||
public void removeParty(String name) {
|
if (this.hasParty(name)) {
|
||||||
if (this.hasParty(name)) {
|
this.parties.remove(name);
|
||||||
this.parties.remove(name);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void startParty(Player player) {
|
||||||
public void startParty(Player player) {
|
if (!hasParty(player.getName())) {
|
||||||
if (!hasParty(player.getName())) {
|
new DiscoParty(this, player).startDisco();
|
||||||
new DiscoParty(this, player).startDisco();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user