Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.lucaazalim.commands;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.Sound;
- import org.bukkit.block.Block;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import me.lucaazalim.listeners.Fertilizar_Delay;
- public class CommandFertilizar implements CommandExecutor{
- private int i = 0;
- public Fertilizar_Delay time = new Fertilizar_Delay();
- @Override
- public boolean onCommand(CommandSender sender, Command arg1, String label, String[] arg3) {
- if (sender instanceof Player){
- Player p = (Player) sender;
- if (p.hasPermission("vip")){
- Location loc = p.getLocation();
- if (time.hasDelay(p) && !p.hasPermission("f.bypass")){
- //p.sendMessage(Main.plugin.getMsg("msg_delay").replaceAll("@tempo", time.getDelayString(p)));
- p.sendMessage("§cVocê terá que esperar "+ time.getDelayString(p) +" para fertilizar suas plantações novamente!");
- return false;
- } else {
- //time.setDelay(p, Main.config.getConfig().getInt("fertilizar_delay"));
- time.setDelay(p,(1));// 1hora
- }
- int xx = 20;
- int yy = 20;
- int zz = 20;
- for (int x = -xx; x <= xx; x++) {
- for (int y = -yy; y <= yy; y++) {
- for (int z = -zz; z <= zz; z++)
- {
- Block b = loc.clone().add(x, y, z).getBlock();
- f(b, p);
- }
- }
- }
- if (i > 0){
- p.playSound(p.getLocation(), Sound.LEVEL_UP, 10, (float) 2.0);
- p.sendMessage("§aSuas plantações foram fertilizadas com sucesso!");
- } else {
- p.sendMessage("§cNão há plantações por perto para ser fertilizadas!");
- }
- i = 0;
- } else {
- p.sendMessage("§cRecurso não disponível para seu grupo!");
- p.playSound(p.getLocation(), Sound.CLICK, 1, 1);
- }
- }
- return false;
- }
- public void f(Block b, Player p) {
- switch (b.getTypeId())
- {
- case 115:
- b.setData((byte) 7);
- i++;
- break;
- case 59:
- b.setData((byte) 7);
- i++;
- break;
- case 142:
- b.setData((byte) 7);
- i++;
- break;
- case 141:
- i++;
- switch (b.getData())
- {
- case 0:
- b.setData((byte) 8);
- i++;
- break;
- case 1:
- b.setData((byte) 9);
- i++;
- break;
- case 2:
- b.setData((byte) 10);
- i++;
- break;
- case 3:
- b.setData((byte) 11);
- i++;
- break;
- }
- case 176:
- b.setData((byte) 7);
- Location bLoc = b.getLocation();
- Block z1 = bLoc.clone().add(0.0D, 0.0D, 1.0D).getBlock();
- Block z2 = bLoc.clone().add(0.0D, 0.0D, -1.0D).getBlock();
- Block x1 = bLoc.clone().add(1.0D, 0.0D, 0.0D).getBlock();
- Block x2 = bLoc.clone().add(-1.0D, 0.0D, 0.0D).getBlock();
- if (z1.getType() == Material.AIR) {
- z1.setType(Material.MELON_BLOCK);
- } else if (z2.getType() == Material.AIR) {
- z2.setType(Material.MELON_BLOCK);
- } else if (x1.getType() == Material.AIR) {
- x1.setType(Material.MELON_BLOCK); } else {
- if (x2.getType() != Material.AIR) break;
- x2.setType(Material.MELON_BLOCK);
- }
- i++;
- break;
- case 104:
- b.setData((byte) 7);
- Location pumpkinLoc = b.getLocation();
- Block z1_ = pumpkinLoc.clone().add(0.0D, 0.0D, 1.0D).getBlock();
- Block z2_ = pumpkinLoc.clone().add(0.0D, 0.0D, -1.0D).getBlock();
- Block x1_ = pumpkinLoc.clone().add(1.0D, 0.0D, 0.0D).getBlock();
- Block x2_ = pumpkinLoc.clone().add(-1.0D, 0.0D, 0.0D).getBlock();
- if (z1_.getType() == Material.AIR) {
- z1_.setType(Material.PUMPKIN);
- } else if (z2_.getType() == Material.AIR) {
- z2_.setType(Material.PUMPKIN);
- } else if (x1_.getType() == Material.AIR) {
- x1_.setType(Material.PUMPKIN); } else {
- if (x2_.getType() != Material.AIR) break;
- x2_.setType(Material.PUMPKIN);
- }
- i++;
- break;
- case 105:
- b.setData((byte) 7);
- Location melonLoc = b.getLocation();
- Block mz1 = melonLoc.clone().add(0.0D, 0.0D, 1.0D).getBlock();
- Block mz2 = melonLoc.clone().add(0.0D, 0.0D, -1.0D).getBlock();
- Block mx1 = melonLoc.clone().add(1.0D, 0.0D, 0.0D).getBlock();
- Block mx2 = melonLoc.clone().add(-1.0D, 0.0D, 0.0D).getBlock();
- if (mz1.getType() == Material.AIR) {
- mz1.setType(Material.MELON);
- } else if (mz2.getType() == Material.AIR) {
- mz2.setType(Material.MELON);
- } else if (mx1.getType() == Material.AIR) {
- mx1.setType(Material.MELON); } else {
- if (mx2.getType() != Material.AIR) break;
- mx2.setType(Material.MELON);
- }
- i++;
- break;
- case 83:
- Location bLocz = b.getLocation();
- Block c1 = bLocz.clone().add(0.0D, 1.0D, 0.0D).getBlock();
- Block c2 = c1.getLocation().add(0.0D, 1.0D, 0.0D).getBlock();
- Block c3 = c1.getLocation().subtract(0.0, 2.0, 0.0).getBlock();
- if (c3.getType() != Material.SUGAR_CANE_BLOCK){
- if (c1.getType() == Material.AIR)
- {
- c1.setType(Material.SUGAR_CANE_BLOCK);
- c2.setType(Material.SUGAR_CANE_BLOCK);
- c3 = c1.getLocation().add(0.0, 1, 0).getBlock();
- if (c3.getType() == Material.AIR){
- c3.setType(Material.SUGAR_CANE_BLOCK);
- }
- } else {
- if (c1.getType() != Material.AIR)
- break;
- c1.setType(Material.SUGAR_CANE_BLOCK);
- }
- i++;
- }
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement