JackOUT

Untitled

Feb 4th, 2023
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.17 KB | None | 0 0
  1. package games.coob.laserturrets.sequence;
  2.  
  3. import games.coob.laserturrets.model.TurretRegistry;
  4. import games.coob.laserturrets.settings.TurretSettings;
  5. import games.coob.laserturrets.util.SkullCreator;
  6. import org.bukkit.block.Block;
  7. import org.bukkit.block.BlockFace;
  8. import org.bukkit.block.Skull;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.inventory.ItemStack;
  11. import org.mineacademy.fo.Common;
  12. import org.mineacademy.fo.PlayerUtil;
  13. import org.mineacademy.fo.menu.model.ItemCreator;
  14. import org.mineacademy.fo.plugin.SimplePlugin;
  15. import org.mineacademy.fo.remain.CompParticle;
  16.  
  17. public final class TurretCreationSequence extends Sequence {
  18.  
  19.     private final Player player;
  20.  
  21.     private final Block block;
  22.  
  23.     private final String type;
  24.  
  25.     TurretCreationSequence(final Player player, final Block block, final String type) {
  26.         super("turret-creation");
  27.  
  28.         this.player = player;
  29.         this.block = block;
  30.         this.type = type;
  31.     }
  32.  
  33.     /*
  34.      * Start this sequence
  35.      */
  36.     @Override
  37.     protected void onStart() {
  38.         this.getLastLocation().add(0.5, 1.2, 0.5);
  39.  
  40.         final TurretSettings turretSettings = TurretSettings.findTurretSettings(this.type);
  41.         final ItemStack item = ItemCreator.of(SkullCreator.itemFromBase64(turretSettings.getBase64Texture())).make();
  42.  
  43.         this.lightning();
  44.         this.glowingStand(item);
  45.         this.lightning();
  46.         this.getLastStand().setAnimated(true);
  47.  
  48.         this.nextSequence(this::onFinish);
  49.     }
  50.  
  51.     @Override
  52.     public void disable() {
  53.         this.removeLast();
  54.     }
  55.  
  56.     private void onFinish() {
  57.         CompParticle.EXPLOSION_LARGE.spawn(this.block.getLocation().add(0.5, 1, 0.5), 2);
  58.  
  59.         final TurretSettings turretSettings = TurretSettings.findTurretSettings(this.type);
  60.         final Block skullBlock = this.block.getRelative(BlockFace.UP);
  61.         final TurretRegistry registry = TurretRegistry.getInstance();
  62.  
  63.         SkullCreator.blockWithBase64(skullBlock, turretSettings.getBase64Texture());
  64.         SkullCreator.rotateSkull((Skull) skullBlock.getState(), PlayerUtil.getFacing(this.player).getOppositeFace());
  65.         Common.runLater(() -> registry.register(this.player, this.block, this.type));
  66.  
  67.         this.removeLast();
  68.         this.block.removeMetadata("IsCreating", SimplePlugin.getInstance());
  69.     }
  70. }
  71.  
Add Comment
Please, Sign In to add comment