Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/fr/openmc/core/features/city/CityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,17 @@ public static List<UUID> getAllCityUUIDs() {
public static boolean isChunkClaimed(int x, int z) {
return getCityFromChunk(x, z) != null;
}


/**
* Check if a chunk is claimed
*
* @param chunk The chunk
* @return true if the chunk is claimed, false otherwise
*/
public static boolean isChunkClaimed(Chunk chunk) {
return getCityFromChunk(chunk) != null;
}

/**
* Check if a chunk is claimed in radius
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,28 @@ public class AyweniterPerk implements Listener {

@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
if (random.nextDouble() >= DROP_CHANCE) return;

Block block = event.getBlock();
if (DreamUtils.isDreamWorld(block.getWorld())) return;
Player player = event.getPlayer();
City playerCity = CityManager.getPlayerCity(player.getUniqueId());

if (playerCity == null) return;

City blockCity = CityManager.getCityFromChunk(block.getChunk());
if (blockCity != null)
if (blockCity != playerCity) return;

if (MayorManager.phaseMayor==2) {
if (MayorManager.phaseMayor == 2) {
if (!PerkManager.hasPerk(playerCity.getMayor(), Perks.AYWENITER.getId())) return;

if (block.getType() == Material.STONE) {

if (random.nextDouble() < DROP_CHANCE) {
ItemStack ayweniteItem = CustomItemRegistry.getByName("omc_items:aywenite").getBest();
ayweniteItem.setAmount(2);
player.getInventory().addItem(ayweniteItem);
player.playSound(player.getEyeLocation(), Sound.BLOCK_AMETHYST_BLOCK_RESONATE, 10.0F, 0.6F);
MessagesManager.sendMessage(player, Component.text("§8§o*la bénédiction!*"), Prefix.MAYOR, MessageType.INFO, false);
}
ItemStack ayweniteItem = CustomItemRegistry.getByName("omc_items:aywenite").getBest();
ayweniteItem.setAmount(2);
player.getInventory().addItem(ayweniteItem);
player.playSound(player.getEyeLocation(), Sound.BLOCK_AMETHYST_BLOCK_RESONATE, 10.0F, 0.6F);
MessagesManager.sendMessage(player, Component.text("§8§o*la bénédiction!*"), Prefix.MAYOR, MessageType.INFO, false);
}
}
}
Expand Down
Loading