Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
777
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. package net.craft.plugin.commands;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.Random;
  6. import java.util.Timer;
  7. import java.util.TimerTask;
  8.  
  9. import org.bukkit.Bukkit;
  10. import org.bukkit.Location;
  11. import org.bukkit.Material;
  12. import org.bukkit.World;
  13. import org.bukkit.entity.Player;
  14. import org.bukkit.event.EventHandler;
  15. import org.bukkit.event.Listener;
  16. import org.bukkit.event.block.Action;
  17. import org.bukkit.event.player.PlayerInteractEvent;
  18. import org.bukkit.inventory.Inventory;
  19. import org.bukkit.inventory.ItemStack;
  20.  
  21. import net.craft.plugin.main.Main;
  22.  
  23. public class SchrottPlatz_Schrott implements Listener {
  24. private Main plugin2;
  25. Timer timer;
  26. private int temp = 0;
  27. public SchrottPlatz_Schrott(Main plugin2) {
  28. this.plugin2 = plugin2;
  29. }
  30. @EventHandler
  31. public void LootCrate_1(PlayerInteractEvent e) {
  32. Player p = e.getPlayer();
  33.  
  34. if((e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
  35. if(e.getClickedBlock().getType() == Material.QUARTZ_ORE&&e.getMaterial().equals(Material.WOOD_PICKAXE)) {
  36. if(this.plugin2.Schrott.containsKey(e.getClickedBlock().getLocation())) {
  37. p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() + 2));
  38.  
  39. }else {
  40. Random rndm = new Random();
  41. int n = 1;
  42. n=rndm.nextInt(3);
  43.  
  44. List<ItemStack> items = new ArrayList<ItemStack>();
  45.  
  46. items.add(new ItemStack(Material.IRON_INGOT));
  47. items.add(new ItemStack(Material.IRON_INGOT));
  48. String w1 = p.getLocation().getWorld().getName();
  49. World w2 = Bukkit.getServer().getWorld(w1);
  50. w2.getBlockAt(e.getClickedBlock().getLocation()).setType(Material.OBSIDIAN);
  51. while (n !=0) {
  52. n--;
  53. Random rndm2 = new Random();
  54. int n2 = rndm2.nextInt(items.size());
  55.  
  56. p.getInventory().addItem((ItemStack)items.get(n2));
  57.  
  58. if(this.plugin2.Schrott.containsKey(e.getClickedBlock().getLocation())) {
  59.  
  60. }
  61.  
  62. timer = new Timer();
  63. timer.scheduleAtFixedRate(new TimerTask() {
  64.  
  65. @Override
  66. public void run() {
  67. Location min = new Location(Bukkit.getWorld("World"), 474, 1, 424);
  68. Location max = new Location(Bukkit.getWorld("World"), 683, 100, 634);
  69. for(int x = min.getBlockX(); x <= max.getBlockX(); x++){
  70. for(int y = min.getBlockY(); y <= max.getBlockY(); y++){
  71. for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){
  72. Location loc = new Location(min.getWorld(), x, y, z);
  73. if(loc.getBlock().getType().equals(Material.OBSIDIAN)){
  74. loc.getBlock().setType(Material.QUARTZ_ORE);
  75. }
  76. }
  77. }
  78.  
  79. }
  80.  
  81. }
  82.  
  83. },1200,1200);
  84.  
  85. }
  86. return;
  87. }
  88. return;
  89. }
  90. }
  91.  
  92. }
  93. public void Brecheisen(PlayerInteractEvent e) {
  94. if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
  95. Player p = e.getPlayer();
  96. if(e.getMaterial().equals(Material.WOOD_PICKAXE)) {
  97. if(p.getItemInHand().getDurability()>=59) {
  98. p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
  99. }
  100. }
  101. }
  102.  
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement