JackOUT

Untitled

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