Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.entity.ArmorStand;
- import org.bukkit.entity.EntityType;
- public class CableLine {
- private ArmorStand start;
- private ArmorStand end;
- public CableLine() {
- }
- public Location getEnd() {
- return this.end.getLocation();
- }
- public Location getStart() {
- return this.start.getLocation();
- }
- public void move(Location newStart, Location newEnd) {
- delete();
- spawn(newStart, newEnd);
- }
- public void delete() {
- start.remove();
- end.remove();
- this.start = null;
- this.end = null;
- }
- public void spawn(Location start, Location end) {
- if (start.getWorld().getName().equals(end.getWorld().getName())) {
- World w = start.getWorld();
- ArmorStand ropeStart = (ArmorStand) w.spawnEntity(start, EntityType.ARMOR_STAND);
- ArmorStand ropeEnd = (ArmorStand) w.spawnEntity(end, EntityType.ARMOR_STAND);
- ropeStart.setGravity(false);
- ropeStart.setInvulnerable(true);
- ropeStart.setMarker(true);
- ropeStart.setVisible(false);
- ropeEnd.setGravity(false);
- ropeEnd.setInvulnerable(true);
- ropeEnd.setMarker(true);
- ropeEnd.setVisible(false);
- ropeStart.setLeashHolder(ropeEnd);
- this.start = ropeStart;
- this.end = ropeEnd;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement