danik159

Untitled

Aug 9th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. package com.chickenstyle.generator;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Location;
  7. import org.bukkit.Material;
  8. import org.bukkit.block.Block;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.event.block.BlockPlaceEvent;
  13. import org.bukkit.inventory.ItemStack;
  14. import org.bukkit.plugin.java.JavaPlugin;
  15. import org.bukkit.scheduler.BukkitRunnable;
  16. import org.bukkit.scheduler.BukkitTask;
  17.  
  18. public class Main extends JavaPlugin implements Listener{
  19. public void onEnable() {
  20. new GeneratorLocation(this);
  21. Bukkit.getPluginManager().registerEvents(this,this);
  22. }
  23. BukkitTask task;
  24. HashMap<Player,Location> location = new HashMap<>();
  25. @SuppressWarnings("deprecation")
  26. @EventHandler
  27. public void onplace(BlockPlaceEvent e) {
  28. Player player = e.getPlayer();
  29. ItemStack bedrock = new ItemStack(Material.BEDROCK);
  30. if (player.getItemInHand().equals(bedrock)) {
  31. Block block = e.getBlock();
  32. location.put(player, block.getLocation());
  33. Block normalblock = location.get(player).getBlock();
  34.  
  35. task = new BukkitRunnable() {
  36. @Override
  37. public void run() {
  38. if (normalblock != null) {
  39. if (normalblock.getType() ==Material.BEDROCK) {
  40. normalblock.setType(Material.COAL_ORE);
  41. player.sendMessage("1");
  42. } else if (normalblock.getType() ==Material.COAL_ORE) {
  43. normalblock.setType(Material.IRON_ORE);
  44. } else if (normalblock.getType() ==Material.IRON_ORE) {
  45. normalblock.setType(Material.GOLD_ORE);
  46.  
  47. } else if (normalblock.getType() ==Material.GOLD_ORE) {
  48. normalblock.setType(Material.DIAMOND_ORE);
  49. } else if (normalblock.getType() ==Material.DIAMOND_ORE) {
  50. return;
  51. }
  52.  
  53. } else {
  54. cancel();
  55. return;
  56. }
  57. }
  58.  
  59.  
  60.  
  61. }.runTaskTimerAsynchronously(this, 0, 40);
  62.  
  63. }
  64. }
  65. }
  66. /*
  67. Diamond-Block
  68. Gold-Block
  69. Iron-BLock
  70. Coal
  71. bedrock
  72.  
  73. Runnable 20 seconds check if the block == type ++
  74.  
  75.  
  76.  
  77.  
  78.  
  79. */
Advertisement
Add Comment
Please, Sign In to add comment