Advertisement
JackOUT

Untitled

Aug 26th, 2022
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.21 KB | None | 0 0
  1. package games.coob.laserturrets.util;
  2.  
  3. import lombok.Getter;
  4. import org.bukkit.Location;
  5. import org.bukkit.entity.ArmorStand;
  6. import org.bukkit.entity.Entity;
  7. import org.bukkit.inventory.ItemStack;
  8. import org.bukkit.util.Consumer;
  9. import org.mineacademy.fo.menu.model.ItemCreator;
  10. import org.mineacademy.fo.remain.CompMaterial;
  11. import org.mineacademy.fo.remain.CompProperty;
  12.  
  13. /**
  14.  *
  15.  */
  16. @Getter
  17. public class SimpleHologramStand extends SimpleHologram {
  18.  
  19.     /**
  20.      * The item or material this hologram will have
  21.      */
  22.     private final Object itemOrMaterial;
  23.  
  24.     /**
  25.      * Is this item stand small?
  26.      */
  27.     private boolean small;
  28.  
  29.     /**
  30.      * Is this item stand glowing?
  31.      */
  32.     private boolean glowing;
  33.  
  34.     /**
  35.      * Create a new simple hologram using armor stand showing the given itemstack
  36.      *
  37.      * @param spawnLocation
  38.      * @param item
  39.      */
  40.     public SimpleHologramStand(final Location spawnLocation, final ItemStack item) {
  41.         super(spawnLocation);
  42.  
  43.         this.itemOrMaterial = item;
  44.     }
  45.  
  46.     /**
  47.      * Create a new simple hologram using armor stand showing the given material
  48.      *
  49.      * @param spawnLocation
  50.      * @param material
  51.      */
  52.     public SimpleHologramStand(final Location spawnLocation, final CompMaterial material) {
  53.         super(spawnLocation);
  54.  
  55.         this.itemOrMaterial = material;
  56.     }
  57.  
  58.     @Override
  59.     protected final Entity createEntity() {
  60.  
  61.         final ItemCreator item;
  62.  
  63.         if (this.itemOrMaterial instanceof ItemStack)
  64.             item = ItemCreator.of((ItemStack) this.itemOrMaterial);
  65.         else
  66.             item = ItemCreator.of((CompMaterial) this.itemOrMaterial);
  67.  
  68.         final Consumer<ArmorStand> consumer = armorStand -> {
  69.             CompProperty.GRAVITY.apply(armorStand, false);
  70.             armorStand.setHelmet(item.glow(this.glowing).make());
  71.             armorStand.setVisible(false);
  72.             armorStand.setSmall(this.small);
  73.         };
  74.  
  75.         return getLastTeleportLocation().getWorld().spawn(getLastTeleportLocation(), ArmorStand.class, consumer);
  76.     }
  77.  
  78.  
  79.     /**
  80.      * @param glowing
  81.      * @return
  82.      */
  83.     public final SimpleHologram setGlowing(final boolean glowing) {
  84.         this.glowing = glowing;
  85.  
  86.         return this;
  87.     }
  88.  
  89.     /**
  90.      * @param small the small to set
  91.      * @return
  92.      */
  93.     public final SimpleHologram setSmall(final boolean small) {
  94.         this.small = small;
  95.  
  96.         return this;
  97.     }
  98. }
  99.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement