Advertisement
iSach

Test of converting an array to particle shape.

Nov 8th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.17 KB | None | 0 0
  1. package be.isach.particletests.command.commands;
  2.  
  3. import be.isach.particletests.ParticleTests;
  4. import be.isach.particletests.command.SubCommand;
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Effect;
  7. import org.bukkit.Location;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.scheduler.BukkitRunnable;
  11.  
  12. /**
  13.  * Created by Sacha on 08/11/15.
  14.  */
  15. public class TestCommand extends SubCommand {
  16.  
  17.     public TestCommand() {
  18.         super("test", "", "t");
  19.     }
  20.  
  21.     private int[][] shape = {
  22.             {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  23.             {0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  24.             {0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
  25.             {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
  26.             {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
  27.             {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
  28.             {0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
  29.             {0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  30.             {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  31.     };
  32.  
  33.     @Override
  34.     public void onCommand(CommandSender sender, String[] args) {
  35.         BukkitRunnable task = new BukkitRunnable() {
  36.             @Override
  37.             public void run() {
  38.                 drawParticles(((Player)sender).getLocation());
  39.             }
  40.         };
  41.         task.runTaskTimerAsynchronously(ParticleTests.instance, 0, 5);
  42.         Bukkit.getScheduler().runTaskLater(ParticleTests.instance, () -> task.cancel(), 100);
  43.     }
  44.  
  45.     private void drawParticles(Location location) {
  46.         double defX = location.getX() - 1;
  47.         double x = defX;
  48.         double y = location.clone().getY() + 4;
  49.         for(int i = 0; i < shape.length; i++) {
  50.             for(int j = 0; j < shape[i].length; j++) {
  51.                 if(shape[i][j] == 1)
  52.                     location.getWorld().spigot().playEffect(new Location(location.getWorld(), x, y, location.getZ()), Effect.FLAME, 0, 0, 0, 0, 0, 0, 1, 64);
  53.                 x += 0.1;
  54.             }
  55.             y -= 0.1;
  56.             x = defX;
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement