Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.greenadine.scarecrow;
- import org.bukkit.Chunk;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.entity.ArmorStand;
- import org.bukkit.entity.Entity;
- public class ScareCrow {
- private Main main;
- private String id;
- private ArmorStand armorstand = null;
- private Location location;
- private double x, y, z;
- public ScareCrow(Main main, ArmorStand armorstand) {
- this.main = main;
- this.armorstand = armorstand;
- location = armorstand.getLocation();
- x = armorstand.getLocation().getX();
- y = armorstand.getLocation().getY();
- z = armorstand.getLocation().getZ();
- String id = location.getWorld() + "@" + x + ";" + y + ";" + z;
- this.id = id;
- main.getScarecrows().add(this);
- }
- public void create(Location loc) {
- World w = loc.getWorld();
- try {
- w.spawn(loc, ArmorStand.class);
- } catch(Exception e) {
- return;
- }
- Chunk c = loc.getChunk();
- Entity[] entities = c.getEntities();
- for(Entity e : entities) {
- if(e instanceof ArmorStand) {
- ArmorStand am = (ArmorStand) e;
- int blockX = am.getLocation().getBlockX();
- int blockY = am.getLocation().getBlockY();
- int blockZ = am.getLocation().getBlockZ();
- if(loc.getBlockX() == blockX && loc.getBlockY() == blockY && loc.getBlockZ() == blockZ) {
- ScareCrow sc = new ScareCrow(main, am);
- return;
- } else {
- return;
- }
- } else {
- return;
- }
- }
- }
- public String getID() {
- return id;
- }
- public ArmorStand getStand() {
- return armorstand;
- }
- public Location getLocation() {
- return location;
- }
- public double getX() {
- return x;
- }
- public double gety() {
- return y;
- }
- public double getz() {
- return z;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment