Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.craft.plugin.commands;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Random;
- import java.util.Timer;
- import java.util.TimerTask;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemStack;
- import net.craft.plugin.main.Main;
- public class SchrottPlatz_Schrott implements Listener {
- private Main plugin2;
- Timer timer;
- private int temp = 0;
- public SchrottPlatz_Schrott(Main plugin2) {
- this.plugin2 = plugin2;
- }
- @EventHandler
- public void LootCrate_1(PlayerInteractEvent e) {
- Player p = e.getPlayer();
- if((e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
- if(e.getClickedBlock().getType() == Material.QUARTZ_ORE&&e.getMaterial().equals(Material.WOOD_PICKAXE)) {
- if(this.plugin2.Schrott.containsKey(e.getClickedBlock().getLocation())) {
- p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() + 2));
- }else {
- Random rndm = new Random();
- int n = 1;
- n=rndm.nextInt(3);
- List<ItemStack> items = new ArrayList<ItemStack>();
- items.add(new ItemStack(Material.IRON_INGOT));
- items.add(new ItemStack(Material.IRON_INGOT));
- String w1 = p.getLocation().getWorld().getName();
- World w2 = Bukkit.getServer().getWorld(w1);
- w2.getBlockAt(e.getClickedBlock().getLocation()).setType(Material.OBSIDIAN);
- while (n !=0) {
- n--;
- Random rndm2 = new Random();
- int n2 = rndm2.nextInt(items.size());
- p.getInventory().addItem((ItemStack)items.get(n2));
- if(this.plugin2.Schrott.containsKey(e.getClickedBlock().getLocation())) {
- }
- timer = new Timer();
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- Location min = new Location(Bukkit.getWorld("World"), 474, 1, 424);
- Location max = new Location(Bukkit.getWorld("World"), 683, 100, 634);
- for(int x = min.getBlockX(); x <= max.getBlockX(); x++){
- for(int y = min.getBlockY(); y <= max.getBlockY(); y++){
- for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){
- Location loc = new Location(min.getWorld(), x, y, z);
- if(loc.getBlock().getType().equals(Material.OBSIDIAN)){
- loc.getBlock().setType(Material.QUARTZ_ORE);
- }
- }
- }
- }
- }
- },1200,1200);
- }
- return;
- }
- return;
- }
- }
- }
- public void Brecheisen(PlayerInteractEvent e) {
- if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
- Player p = e.getPlayer();
- if(e.getMaterial().equals(Material.WOOD_PICKAXE)) {
- if(p.getItemInHand().getDurability()>=59) {
- p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement