Ir para conteúdo
  • 0

[Resolvido] Como faço pra verificar se o lugar ta claimado?


Pergunta

Postado

Tenho esse codigo

@SuppressWarnings("deprecation")
	@EventHandler
	public void minerar(BlockBreakEvent e) {
		Block bloco = e.getBlock();
		Player p = e.getPlayer();
		if (p.getItemInHand().getType() == Material.WOOD_PICKAXE || p.getItemInHand().getType() == Material.STONE_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE || p.getItemInHand().getType() == Material.GOLD_PICKAXE || p.getItemInHand().getType() == Material.DIAMOND_PICKAXE) {
			if (p.getItemInHand().getItemMeta().getEnchants().get(Enchantment.SILK_TOUCH) != null) {
				if (bloco.getType().getId() == 52) {
					p.getInventory().addItem(new ItemStack(Material.MOB_SPAWNER));
				}
			}
		}
	}

Como faço pra ele verificar se o chão ta claimado?

Porque mesmo quebrando um local claimado, ele manda o item pro inventário.

 

Plugin que eu uso: https://www.spigotmc.org/resources/griefprevention.1884/

Talvez isso aqui seja a API n sei ;-;: https://github.com/ryanhamshire/GriefPrevention/blob/master/src/me/ryanhamshire/GriefPrevention

 

 

9 respostass a esta questão

Posts Recomendados

Postado

// Verificar se player pode quebrar bloco em

public static boolean canBreakAt(Location loc, Player p, Material m) {

// WorldGuard & GriefPrevention

Claim claim = GriefPrevention.instance.dataStore.getClaimAt(loc, false, null);

String canBuildClaim = null;

if (claim != null) {

canBuildClaim = claim.allowBreak(p, m);

}

if (getWorldGuard().canBuild(p, loc) && canBuildClaim == null) {

return true;

}

return false;

}

 

public static WorldGuardPlugin getWorldGuard() {

Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");

 

// WorldGuard may not be loaded

if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {

return null; // Maybe you want throw an exception instead

}

 

return (WorldGuardPlugin) plugin;

}

 

Postado

 

Tenho esse codigo

@SuppressWarnings("deprecation")
	@EventHandler
	public void minerar(BlockBreakEvent e) {
		Block bloco = e.getBlock();
		Player p = e.getPlayer();
		if (p.getItemInHand().getType() == Material.WOOD_PICKAXE || p.getItemInHand().getType() == Material.STONE_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE || p.getItemInHand().getType() == Material.GOLD_PICKAXE || p.getItemInHand().getType() == Material.DIAMOND_PICKAXE) {
			if (p.getItemInHand().getItemMeta().getEnchants().get(Enchantment.SILK_TOUCH) != null) {
				if (bloco.getType().getId() == 52) {
					p.getInventory().addItem(new ItemStack(Material.MOB_SPAWNER));
				}
			}
		}
	}

Como faço pra ele verificar se o chão ta claimado?

 

Porque mesmo quebrando um local claimado, ele manda o item pro inventário.

 

Plugin que eu uso: https://www.spigotmc.org/resources/griefprevention.1884/

Talvez isso aqui seja a API n sei ;-;: https://github.com/ryanhamshire/GriefPrevention/blob/master/src/me/ryanhamshire/GriefPrevention

 

Testa o do MrPower...

Postado (editado)

eu nao seii

poura vei

 

Adiciona akeles métodos...

@SuppressWarnings("deprecation")
	@EventHandler
	public void minerar(BlockBreakEvent e) {
		Block bloco = e.getBlock();
		Player p = e.getPlayer();
		if (p.getItemInHand().getType() == Material.WOOD_PICKAXE || p.getItemInHand().getType() == Material.STONE_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE || p.getItemInHand().getType() == Material.GOLD_PICKAXE || p.getItemInHand().getType() == Material.DIAMOND_PICKAXE) {
			if (p.getItemInHand().getItemMeta().getEnchants().get(Enchantment.SILK_TOUCH) != null) {
                                if (!canBreak(bloco.getLocation(), p, p.getItemInHand().getType())) {
                                    // voce n pode kebra essa budega;...
                                    return; 
                                }
				if (bloco.getType().getId() == 52) {
					p.getInventory().addItem(new ItemStack(Material.MOB_SPAWNER));
				}
			}
		}
	}
Editado por leonardosc
Postado

 

poura vei

 

Adiciona akeles métodos...

@SuppressWarnings("deprecation")
	@EventHandler
	public void minerar(BlockBreakEvent e) {
		Block bloco = e.getBlock();
		Player p = e.getPlayer();
		if (p.getItemInHand().getType() == Material.WOOD_PICKAXE || p.getItemInHand().getType() == Material.STONE_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE || p.getItemInHand().getType() == Material.GOLD_PICKAXE || p.getItemInHand().getType() == Material.DIAMOND_PICKAXE) {
			if (p.getItemInHand().getItemMeta().getEnchants().get(Enchantment.SILK_TOUCH) != null) {
                                if (!canBreak(bloco.getLocation(), p, p.getItemInHand().getType())) {
                                    // voce n pode kebra essa budega;...
                                    return; 
                                }
				if (bloco.getType().getId() == 52) {
					p.getInventory().addItem(new ItemStack(Material.MOB_SPAWNER));
				}
			}
		}
	}

Deu erro no no erro !canBreak

j9xsDB1.png

The method canBreak(Location, Player, Material) is undefined for the type Main

Postado

Deu erro no no erro !canBreak

j9xsDB1.png

The method canBreak(Location, Player, Material) is undefined for the type Main

Muda pra canBreakAt

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...