Implemented shear prevention on spawned sheep
This commit is contained in:
parent
9dba2a1be3
commit
572cb5a9d6
@ -13,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
public final class DiscoSheep extends JavaPlugin {
|
public final class DiscoSheep extends JavaPlugin {
|
||||||
|
|
||||||
private ArrayList<Sheep> sheepArray = new ArrayList<Sheep>();
|
private ArrayList<Sheep> sheepArray = new ArrayList<Sheep>();
|
||||||
|
private SheepDeshearer deshear = new SheepDeshearer(sheepArray);
|
||||||
private static final DyeColor[] discoColours = {
|
private static final DyeColor[] discoColours = {
|
||||||
DyeColor.RED,
|
DyeColor.RED,
|
||||||
DyeColor.ORANGE,
|
DyeColor.ORANGE,
|
||||||
@ -33,11 +34,12 @@ public final class DiscoSheep extends JavaPlugin {
|
|||||||
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// Watashi Wa Kawaii, Ne?
|
getServer().getPluginManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Sheep> getSheep() {
|
ArrayList<Sheep> getSheep() {
|
||||||
|
@ -4,14 +4,28 @@
|
|||||||
*/
|
*/
|
||||||
package gibstick.bukkit.discosheep;
|
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.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Mauve
|
* @author Mauve
|
||||||
*/
|
*/
|
||||||
public class SheepDeshearer implements Listener {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user