Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. package ctmain;
  2.  
  3.  
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Location;
  7. import org.bukkit.Material;
  8. import org.bukkit.World;
  9. import org.bukkit.entity.FallingBlock;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.event.block.BlockDispenseEvent;
  13. import org.bukkit.util.Vector;
  14.  
  15.  
  16.  
  17.  
  18. public class EventListener implements Listener {
  19.  
  20. public EventListener(ClayTargetPlugin plugin) {
  21. plugin.getServer().getPluginManager().registerEvents(this,plugin);
  22. }
  23.  
  24. @SuppressWarnings("deprecation")
  25. @EventHandler
  26. public void onDispense(BlockDispenseEvent e) {
  27. try{
  28. String something = new String(e.getBlock().getState().getData().toString());
  29. String[] face = something.split(" ");
  30. World world = Bukkit.getWorld("world");
  31. int x = e.getBlock().getX();
  32. int y = e.getBlock().getY();
  33. int z = e.getBlock().getZ();
  34. int vx = 0;
  35. int vy = 0;
  36. int vz = 0;
  37.  
  38.  
  39. if(face[2].equals("NORTH")) {
  40. z = z - 1 ;
  41. System.out.print(z);
  42. vz = z - 1;
  43. System.out.print(vz);
  44. } if(face[2].equals("SOUTH")) {
  45. System.out.println("Test");
  46. z = z + 1 ;
  47. System.out.print(z);
  48. vz = z + 1;
  49. System.out.print(vz);
  50. } if(face[2].equals("WEST")) {
  51. x = x - 1 ;
  52. System.out.print(x);
  53. vx = x - 1 ;
  54. System.out.print(vx);
  55. } if(face[2].equals("EAST")) {
  56. x = x + 1 ;
  57. System.out.print(x);
  58. vx = x - 1 ;
  59. System.out.print(vx);
  60. } if(face[2].equals("UP")) {
  61. System.out.print("Incorrect Block Placement");
  62. return;
  63. } if(face[2].equals("DOWN")) {
  64. System.out.print("Incorrect Block Placement");
  65. return;
  66. }
  67. Location newpos = new Location(world, x, y, z);
  68. FallingBlock block = world.spawnFallingBlock(newpos, Material.SAND,(byte) 0);
  69. block.setVelocity(new Vector(vx,vy,vz));
  70. Thread.sleep(3000);
  71. System.out.println(block.getLocation());
  72.  
  73. }
  74. catch(InterruptedException xf) {
  75. xf.printStackTrace();
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement