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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import fr.openmc.core.utils.messages.MessagesManager;
import fr.openmc.core.utils.messages.Prefix;
import net.kyori.adventure.text.Component;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

Expand All @@ -26,7 +27,7 @@ public static int calculateAywenite(int chunkCount) {

public static void startUnclaim(Player sender, int chunkX, int chunkZ) {
City city = CityManager.getPlayerCity(sender.getUniqueId());
org.bukkit.World bWorld = sender.getWorld();
World bWorld = sender.getWorld();
if (!bWorld.getName().equals("world")) {
MessagesManager.sendMessage(sender, Component.text("Tu ne peux pas étendre ta ville ici"), Prefix.CITY, MessageType.ERROR, false);
return;
Expand All @@ -42,14 +43,17 @@ public static void startUnclaim(Player sender, int chunkX, int chunkZ) {
return;
}

int price = calculatePrice(city.getChunks().size());
int ayweniteNb = calculateAywenite(city.getChunks().size());

EconomyManager.addBalance(sender.getUniqueId(), price, "Unclaim de chunk de ville");
ItemStack aywenite = ayweniteItemStack.clone();
aywenite.setAmount(ayweniteNb);
for (ItemStack item : ItemUtils.splitAmountIntoStack(aywenite)) {
sender.dropItem(item);
// si on unclaim des claims gratuits on ne rend rien, sinon on rend une partie de l'argent et d'aywenite
if (city.getChunks().size() > CityCreateAction.FREE_CLAIMS+1) {
int price = calculatePrice(city.getChunks().size());
int ayweniteNb = calculateAywenite(city.getChunks().size());

EconomyManager.addBalance(sender.getUniqueId(), price, "Unclaim de chunk de ville");
ItemStack aywenite = ayweniteItemStack.clone();
aywenite.setAmount(ayweniteNb);
for (ItemStack item : ItemUtils.splitAmountIntoStack(aywenite)) {
sender.dropItem(item);
}
}

city.removeChunk(chunkX, chunkZ);
Expand Down
21 changes: 17 additions & 4 deletions src/main/java/fr/openmc/core/features/city/menu/CityChunkMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import fr.openmc.core.features.city.CityManager;
import fr.openmc.core.features.city.CityPermission;
import fr.openmc.core.features.city.actions.CityClaimAction;
import fr.openmc.core.features.city.actions.CityCreateAction;
import fr.openmc.core.features.city.actions.CityUnclaimAction;
import fr.openmc.core.features.economy.EconomyManager;
import fr.openmc.core.utils.ChunkInfo;
Expand Down Expand Up @@ -264,9 +265,9 @@ private ItemBuilder createProtectedChunkItem(Material material, int chunkX, int
}

private ItemBuilder createPlayerCityChunkItem(Material material, City city, int chunkX, int chunkZ) {
return new ItemBuilder(this, material, itemMeta -> {
itemMeta.displayName(Component.text("§9Claim de votre ville"));
itemMeta.lore(List.of(
List<Component> lore;
if (city.getChunks().size() > CityCreateAction.FREE_CLAIMS+1) {
lore = List.of(
Component.text("§7Ville : §d" + city.getName()),
Component.text("§7Position : §f" + chunkX + ", " + chunkZ),
Component.empty(),
Expand All @@ -275,7 +276,19 @@ private ItemBuilder createPlayerCityChunkItem(Material material, City city, int
Component.text("§8- §d" + CityUnclaimAction.calculateAywenite(playerCity.getChunks().size()) + " d'Aywenite"),
Component.empty(),
Component.text("§e§lCLIQUEZ POUR UNCLAIM")
));
);
} else {
lore = List.of(
Component.text("§7Ville : §d" + city.getName()),
Component.text("§7Position : §f" + chunkX + ", " + chunkZ),
Component.empty(),
Component.text("§e§lCLIQUEZ POUR UNCLAIM")
);
}

return new ItemBuilder(this, material, itemMeta -> {
itemMeta.displayName(Component.text("§9Claim de votre ville"));
itemMeta.lore(lore);
}).setOnClick(event -> handleChunkUnclaimClick(player, chunkX, chunkZ, hasPermissionClaim));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.oliver.fancynpcs.api.FancyNpcsPlugin;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcManager;
import fr.openmc.api.hooks.FancyNpcsHook;
import fr.openmc.api.hooks.LuckPermsHook;
import fr.openmc.api.hooks.WorldGuardHook;
import fr.openmc.api.scoreboard.SternalBoard;
Expand Down Expand Up @@ -61,9 +62,6 @@ public void update(Player player, SternalBoard board) {
}

public static List<Component> getDefaultLines(Player player) {
NpcManager npcManager = FancyNpcsPlugin.get().getNpcManager();
Npc halloweenNPC = npcManager.getNpc("halloween_pumpkin_deposit_npc");

Component rank = LuckPermsHook.isHasLuckPerms()
? Component.text(LuckPermsHook.getFormattedPAPIPrefix(player))
: Component.text(textToSmall("aucun")).color(TextColor.color(0xFF1FCC));
Expand Down Expand Up @@ -102,13 +100,18 @@ public static List<Component> getDefaultLines(Player player) {
.appendSpace()
.append(text(textToSmall(location)).color(TextColor.color(0xFF06DC)))
);
if (halloweenNPC != null) {
String pumpkinCount = EconomyManager.getFormattedSimplifiedNumber(HalloweenManager.getPumpkinCount(player.getUniqueId()));
lines.add(text(" • ", NamedTextColor.DARK_GRAY)
.append(text(textToSmall("citrouilles:"), NamedTextColor.GRAY))
.appendSpace()
.append(text(textToSmall(pumpkinCount)).color(TextColor.color(0xFF7518)))
);

if (FancyNpcsHook.isHasFancyNpc()) {
NpcManager npcManager = FancyNpcsPlugin.get().getNpcManager();
Npc halloweenNPC = npcManager.getNpc("halloween_pumpkin_deposit_npc");
if (halloweenNPC != null) {
String pumpkinCount = EconomyManager.getFormattedSimplifiedNumber(HalloweenManager.getPumpkinCount(player.getUniqueId()));
lines.add(text(" • ", NamedTextColor.DARK_GRAY)
.append(text(textToSmall("citrouilles:"), NamedTextColor.GRAY))
.appendSpace()
.append(text(textToSmall(pumpkinCount)).color(TextColor.color(0xFF7518)))
);
}
}

lines.add(newline());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public static Component createContributorsTextLeaderboard() {
int rank = entry.getKey();
String contributorName = entry.getValue().getKey();
ContributorStats stats = entry.getValue().getValue();

if (contributorName == null || stats == null) continue;

int addLines = stats.added();
int removeLines = stats.removed();
Component line = Component.text("\n#")
Expand Down Expand Up @@ -126,6 +129,9 @@ public static Component createMoneyTextLeaderboard() {
int rank = entry.getKey();
String playerName = entry.getValue().getKey();
String money = entry.getValue().getValue();

if (playerName == null || money == null) continue;

Component line = Component.text("\n#")
.color(getRankColor(rank))
.append(Component.text(rank).color(getRankColor(rank)))
Expand Down Expand Up @@ -157,6 +163,9 @@ public static Component createCityMoneyTextLeaderboard() {
int rank = entry.getKey();
String cityName = entry.getValue().getKey();
String money = entry.getValue().getValue();

if (cityName == null || money == null) continue;

Component line = Component.text("\n#")
.color(getRankColor(rank))
.append(Component.text(rank).color(getRankColor(rank)))
Expand Down Expand Up @@ -188,6 +197,9 @@ public static Component createPlayTimeTextLeaderboard() {
int rank = entry.getKey();
String playerName = entry.getValue().getKey();
String time = entry.getValue().getValue();

if (playerName == null || time == null) continue;

Component line = Component.text("\n#")
.color(getRankColor(rank))
.append(Component.text(rank).color(getRankColor(rank)))
Expand All @@ -214,6 +226,9 @@ public static Component createPumpkinCountTextLeaderboard() {
int rank = entry.getKey();
String playerName = entry.getValue().getKey();
String pumpkinCount = entry.getValue().getValue();

if (playerName == null || pumpkinCount == null) continue;

Component line = Component.text("\n#")
.color(getRankColor(rank))
.append(Component.text(rank).color(getRankColor(rank)))
Expand Down
Loading