Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. package com.example;
  2.  
  3. import org.bukkit.Location;
  4. import org.bukkit.World;
  5. import org.bukkit.entity.ArmorStand;
  6. import org.bukkit.entity.EntityType;
  7.  
  8.  
  9. public class CableLine {
  10.  
  11. private ArmorStand start;
  12. private ArmorStand end;
  13.  
  14. public CableLine() {
  15. }
  16.  
  17. public Location getEnd() {
  18. return this.end.getLocation();
  19. }
  20.  
  21. public Location getStart() {
  22. return this.start.getLocation();
  23. }
  24.  
  25. public void move(Location newStart, Location newEnd) {
  26. delete();
  27. spawn(newStart, newEnd);
  28. }
  29.  
  30. public void delete() {
  31. start.remove();
  32. end.remove();
  33. this.start = null;
  34. this.end = null;
  35. }
  36.  
  37. public void spawn(Location start, Location end) {
  38. if (start.getWorld().getName().equals(end.getWorld().getName())) {
  39.  
  40.  
  41.  
  42. World w = start.getWorld();
  43.  
  44.  
  45. ArmorStand ropeStart = (ArmorStand) w.spawnEntity(start, EntityType.ARMOR_STAND);
  46. ArmorStand ropeEnd = (ArmorStand) w.spawnEntity(end, EntityType.ARMOR_STAND);
  47.  
  48. ropeStart.setGravity(false);
  49. ropeStart.setInvulnerable(true);
  50. ropeStart.setMarker(true);
  51. ropeStart.setVisible(false);
  52.  
  53. ropeEnd.setGravity(false);
  54. ropeEnd.setInvulnerable(true);
  55. ropeEnd.setMarker(true);
  56. ropeEnd.setVisible(false);
  57.  
  58. ropeStart.setLeashHolder(ropeEnd);
  59.  
  60. this.start = ropeStart;
  61. this.end = ropeEnd;
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement