Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. package me.EldarGuard.WitherWars;
  2.  
  3. import java.util.List;
  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.block.Block;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.EventHandler;
  12. import org.bukkit.event.block.BlockBreakEvent;
  13. import org.bukkit.event.block.BlockPlaceEvent;
  14.  
  15. public class WitherHandler {
  16.  
  17. Main plugin;
  18. public String[] args1;
  19. public Player playerone;
  20.  
  21. public WitherHandler(Main plugin) {
  22. this.plugin = plugin;
  23.  
  24. }
  25.  
  26.  
  27. public void BuildWither(Player player, String[] args){
  28. args1 = args;
  29. playerone = player;
  30. List<String> list = plugin.getConfig().getStringList(args1 + ".WitherPoint");
  31. String witherpointstring = list.get(0);
  32. String[] arg = witherpointstring.split(",");
  33. int one = Integer.parseInt(arg[0]);
  34. int two = Integer.parseInt(arg[1]);
  35. int three = Integer.parseInt(arg[2]);
  36.  
  37. String World = plugin.getConfig().getString(args1 + ".World");
  38. World world = Bukkit.getServer().getWorld(World);
  39. Location l1 = new Location (world, one, two, three);
  40. setBlock(l1);
  41. l1.setY(l1.getY() + 1);
  42. setBlock(l1);
  43. l1.setX(l1.getX() + 1);
  44. setBlock(l1);
  45. l1.setX(l1.getX() - 2);
  46. setBlock(l1);
  47. Location l2 = new Location (world, one, two, three);
  48. l2.setY(l2.getY() + 1);
  49. l2.setY(l2.getY() + 1);
  50. l2.setX(l1.getX() + 1);
  51. setBlock(l2);
  52. }
  53.  
  54.  
  55. public void setBlock(Location location){
  56.  
  57. Block block = location.getBlock();
  58.  
  59. block.setType(Material.SOUL_SAND, true);
  60.  
  61. }
  62. @EventHandler
  63. public void BlockBreak(BlockBreakEvent e){
  64.  
  65. if(args1 != null){
  66.  
  67. Block block = e.getBlock();
  68.  
  69. Location loc1 = block.getLocation();
  70. List<String> list = plugin.getConfig().getStringList(args1[0] + ".WitherPoint");
  71. String witherpointstring = list.get(0);
  72. String[] arg = witherpointstring.split(",");
  73. int one1 = Integer.parseInt(arg[0]);
  74. int two2 = Integer.parseInt(arg[1]);
  75. int three3 = Integer.parseInt(arg[2]);
  76. String World = plugin.getConfig().getString(args1[0] + ".World");
  77. World world = Bukkit.getServer().getWorld(World);
  78. Location loc2 = new Location (world, one1, two2, three3);
  79. if(loc1.distance(loc2) <= 5){
  80.  
  81. BuildWither(playerone, args1);
  82.  
  83. }
  84.  
  85. }}
  86.  
  87. @EventHandler
  88. public void BlockPlaced(BlockPlaceEvent e){
  89.  
  90. if(args1 != null){
  91. if(plugin.getConfig().getString(args1[0] + ".State") != null){
  92. if(plugin.getConfig().getString(args1[0] + ".State") == "Open"){
  93.  
  94. Block block = e.getBlock();
  95.  
  96. List<String> list = plugin.getConfig().getStringList(args1[0] + ".WitherPoint");
  97. String witherpointstring = list.get(0);
  98. String[] arg = witherpointstring.split(",");
  99. int one1 = Integer.parseInt(arg[0]);
  100. int two2 = Integer.parseInt(arg[1]);
  101. int three3 = Integer.parseInt(arg[2]);
  102. String World = plugin.getConfig().getString(args1[0] + ".World");
  103. World world = Bukkit.getServer().getWorld(World);
  104.  
  105. Location loca1 = new Location (world, one1, two2, three3);
  106. loca1.setY(loca1.getY() + 2);
  107.  
  108. Location loca2 = new Location (world, one1, two2, three3);
  109. loca2.setY(loca2.getY() + 2);
  110. loca2.setX(loca2.getX() + 1);
  111.  
  112. Location loca3 = new Location (world, one1, two2, three3);
  113. loca3.setY(loca3.getY() + 2);
  114. loca3.setX(loca3.getX() - 2);
  115.  
  116. if(block.getLocation() == loca1 || block.getLocation() == loca2 || block.getLocation() == loca3){
  117. if(block.getType() != Material.AIR || block.getType() != Material.SKULL){
  118. block.setType(Material.AIR);
  119. }
  120. }
  121. }
  122. }
  123. }
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement