Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.chickenstyle.generator;
- import java.util.HashMap;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Block;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.BlockPlaceEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.scheduler.BukkitRunnable;
- import org.bukkit.scheduler.BukkitTask;
- public class Main extends JavaPlugin implements Listener{
- public void onEnable() {
- new GeneratorLocation(this);
- Bukkit.getPluginManager().registerEvents(this,this);
- }
- BukkitTask task;
- HashMap<Player,Location> location = new HashMap<>();
- @SuppressWarnings("deprecation")
- @EventHandler
- public void onplace(BlockPlaceEvent e) {
- Player player = e.getPlayer();
- ItemStack bedrock = new ItemStack(Material.BEDROCK);
- if (player.getItemInHand().equals(bedrock)) {
- Block block = e.getBlock();
- location.put(player, block.getLocation());
- Block normalblock = location.get(player).getBlock();
- task = new BukkitRunnable() {
- @Override
- public void run() {
- if (normalblock != null) {
- if (normalblock.getType() ==Material.BEDROCK) {
- normalblock.setType(Material.COAL_ORE);
- player.sendMessage("1");
- } else if (normalblock.getType() ==Material.COAL_ORE) {
- normalblock.setType(Material.IRON_ORE);
- } else if (normalblock.getType() ==Material.IRON_ORE) {
- normalblock.setType(Material.GOLD_ORE);
- } else if (normalblock.getType() ==Material.GOLD_ORE) {
- normalblock.setType(Material.DIAMOND_ORE);
- } else if (normalblock.getType() ==Material.DIAMOND_ORE) {
- return;
- }
- } else {
- cancel();
- return;
- }
- }
- }.runTaskTimerAsynchronously(this, 0, 40);
- }
- }
- }
- /*
- Diamond-Block
- Gold-Block
- Iron-BLock
- Coal
- bedrock
- Runnable 20 seconds check if the block == type ++
- */
Advertisement
Add Comment
Please, Sign In to add comment