Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9da4777
update: 1.21.5-1.21.7
iambibi Jul 10, 2025
77f5e53
update: librairies
iambibi Jul 10, 2025
f488374
Merge branch 'ServerOpenMC:master' into feat/1.21.7
iambibi Jul 10, 2025
d92d10f
chore: remove BlockVector2
iambibi Jul 10, 2025
a8bafc4
Merge remote-tracking branch 'origin/feat/1.21.7' into feat/1.21.7
iambibi Jul 10, 2025
76c3ae7
fix: claiming
iambibi Jul 11, 2025
19a67b9
add: DialogInput
iambibi Jul 11, 2025
3042c6d
remove SignGUI
iambibi Jul 11, 2025
9fdecec
Update src/main/java/fr/openmc/core/features/contest/menu/TradeMenu.java
iambibi Jul 11, 2025
56ff62e
Update src/main/java/fr/openmc/core/features/contest/menu/TradeMenu.java
iambibi Jul 11, 2025
17c2150
add: BACK button
iambibi Jul 12, 2025
505534e
Merge remote-tracking branch 'origin/feat/1.21.7' into feat/1.21.7
iambibi Jul 12, 2025
92a7c28
Merge branch 'master' into feat/1.21.8
iambibi Jul 23, 2025
74b3d9e
1.21.8 update
iambibi Jul 23, 2025
13b9eb2
add: increase speed of happy ghast by 1.5
iambibi Jul 23, 2025
3789d50
rewrite: speed modifier for happy ghast
iambibi Jul 25, 2025
49449fd
Merge branch 'master' into feat/1.21.8
iambibi Jul 25, 2025
4726413
change: particle in spawn
iambibi Jul 25, 2025
bf33d70
remove: debug
iambibi Jul 25, 2025
84030c9
build: fix
iambibi Jul 25, 2025
af0ef60
fix: "cityAtLoc" is null
iambibi Jul 25, 2025
1f4e13f
change: dialog.send(.., Component, ...)
iambibi Jul 27, 2025
499d33d
change: 100 to constant MAX_LENGTH
iambibi Jul 27, 2025
7966b82
change: MAX_LENGTH_PLAYERNAME use in isInputPlayer
iambibi Jul 27, 2025
3572673
change: Integer to int
iambibi Jul 27, 2025
2a14afc
change: minLocation to minHeight (idem for maxHeight)
iambibi Jul 27, 2025
5861b89
change: ChunkPos to record
iambibi Jul 27, 2025
85fe0e0
fix: identation
iambibi Jul 27, 2025
b1213bb
fix: space
iambibi Jul 27, 2025
dd909ea
fix: chunkpos record
iambibi Jul 27, 2025
74f4450
change: name of spawnIronMan
iambibi Jul 27, 2025
f21fb2d
change: util randomBetween
iambibi Jul 29, 2025
aed843b
fix: removal
iambibi Jul 29, 2025
81c0120
rename launchEvent to startEvent
iambibi Jul 29, 2025
d6b5226
remove toString
iambibi Jul 29, 2025
f59f06a
remove debug
iambibi Jul 29, 2025
494ce44
fix: forgot
iambibi Jul 29, 2025
485ebb8
addd: field for 100 * 100
iambibi Jul 30, 2025
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
4 changes: 2 additions & 2 deletions src/main/java/fr/openmc/api/input/DialogInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

public class DialogInput {

public static void send(Player player, String lore, int maxLength, Consumer<String> callback) {
public static void send(Player player, Component lore, int maxLength, Consumer<String> callback) {

List<DialogBody> body = new ArrayList<>();

body.add(DialogBody.plainMessage(Component.text(lore)));
body.add(DialogBody.plainMessage(lore));

Dialog inputDialog = Dialog.create(builder -> builder.empty()
.base(DialogBase.builder(Component.text("Rentrer du Texte"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public static void unclaimChunk(City city, ChunkPos chunk) {
Bukkit.getScheduler().runTaskAsynchronously(OMCPlugin.getInstance(), () -> {
try {
DeleteBuilder<DBCityClaim, String> delete = claimsDao.deleteBuilder();
delete.where().eq("city", city.getUUID()).and().eq("x", chunk.getX()).and().eq("z", chunk.getZ());
delete.where().eq("city", city.getUUID()).and().eq("x", chunk.x()).and().eq("z", chunk.z());

claimsDao.delete(delete.prepare());
} catch (SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void beginCreateRank(Player player) {
return;
}

DialogInput.send(player, "Entrez le nom de votre grade", MAX_LENGTH_RANK_NAME, input ->
DialogInput.send(player, Component.text("Entrez le nom de votre grade"), MAX_LENGTH_RANK_NAME, input ->
CityRankAction.afterCreateRank(player, input)
);
}
Expand All @@ -52,7 +52,7 @@ public static void renameRank(Player player, String oldName) {
return;
}

DialogInput.send(player, "Entrez le nouveau nom de votre grade", MAX_LENGTH_RANK_NAME, input -> {
DialogInput.send(player, Component.text("Entrez le nouveau nom de votre grade"), MAX_LENGTH_RANK_NAME, input -> {
if (!CityRankCondition.canRenameRank(city, player, oldName)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void create(Player player, @Optional String name) {
return;
}

DialogInput.send(player, "Entrez le nom de la ville", MAX_LENGTH_CITY, input ->
DialogInput.send(player, Component.text("Entrez le nom de la ville"), MAX_LENGTH_CITY, input ->
CityCreateAction.beginCreateCity(player, input)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void onInventoryClick(InventoryClickEvent click) {
City cityCheck = CityManager.getPlayerCity(player.getUniqueId());
if (!CityManageConditions.canCityRename(cityCheck, player)) return;

DialogInput.send(player, "Entrez le nom de la ville", MAX_LENGTH_CITY, input -> {
DialogInput.send(player, Component.text("Entrez le nom de la ville"), MAX_LENGTH_CITY, input -> {
if (InputUtils.isInputCityName(input)) {
City playerCity = CityManager.getPlayerCity(player.getUniqueId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void onInventoryClick(InventoryClickEvent click) {
}).setOnClick(inventoryClickEvent -> {
if (!DynamicCooldownManager.isReady(player.getUniqueId().toString(), "city:big")) return;

DialogInput.send(player, "Entrez le nom de la ville", MAX_LENGTH_CITY, input ->
DialogInput.send(player, Component.text("Entrez le nom de la ville"), MAX_LENGTH_CITY, input ->
CityCreateAction.beginCreateCity(player, input)
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import fr.openmc.core.features.city.actions.CityKickAction;
import fr.openmc.core.features.city.commands.CityCommands;
import fr.openmc.core.features.city.menu.CitizensPermsMenu;
import fr.openmc.core.features.city.sub.mayor.managers.MayorManager;
import fr.openmc.core.items.CustomItemRegistry;
import fr.openmc.core.utils.CacheOfflinePlayer;
import fr.openmc.core.utils.InputUtils;
Expand Down Expand Up @@ -175,7 +174,7 @@ public Map<Integer, ItemStack> getButtons() {
itemMeta.displayName(Component.text("§7Inviter des §dpersonnes"));
itemMeta.lore(List.of(Component.text("§7Vous pouvez inviter des personnes à votre ville pour la remplir !")));
}).setOnClick(inventoryClickEvent -> {
DialogInput.send(player, "Entrez le nom du joueur", MAX_LENGTH_PLAYERNAME, input -> {
DialogInput.send(player, Component.text("Entrez le nom du joueur"), MAX_LENGTH_PLAYERNAME, input -> {
if (InputUtils.isInputPlayer(input)) {
Player playerToInvite = Bukkit.getPlayer(input);
CityCommands.invite(player, playerToInvite);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import java.util.*;

import static fr.openmc.core.utils.InputUtils.MAX_LENGTH;

public class CityRankIconMenu extends PaginatedMenu {

private final CityRank rank;
Expand Down Expand Up @@ -115,7 +117,7 @@ public Map<Integer, ItemStack> getButtons() {
itemMeta.displayName(Component.text("§bRechercher une icône"));
itemMeta.lore(List.of(Component.text("§7Cliquez pour saisir un mot-clé")));
}).setOnClick(event -> {
DialogInput.send(getOwner(), "Entrez le nom d'un mot clé pour l'icône", 100, input -> {
DialogInput.send(getOwner(), Component.text("Entrez le nom d'un mot clé pour l'icône"), MAX_LENGTH, input -> {
new CityRankIconMenu(getOwner(), city, 0, rank, input).open();
});
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class DBCityClaim {

public DBCityClaim(ChunkPos chunk, String city) {
this.city = city;
this.x = chunk.getX();
this.z = chunk.getZ();
this.x = chunk.x();
this.z = chunk.z();
}

public ChunkPos getChunkPos() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.util.List;
import java.util.Map;

import static fr.openmc.core.utils.InputUtils.MAX_LENGTH;

public class CityBankDepositMenu extends Menu {

public CityBankDepositMenu(Player owner) {
Expand Down Expand Up @@ -142,7 +144,7 @@ public void onInventoryClick(InventoryClickEvent click) {
}).setOnClick(inventoryClickEvent -> {
if (!CityBankConditions.canCityDeposit(city, player)) return;

DialogInput.send(player, "Entrez le montant que vous voulez déposer", 100, input ->
DialogInput.send(player, Component.text("Entrez le montant que vous voulez déposer"), MAX_LENGTH, input ->
city.depositCityBank(player, input)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.util.List;
import java.util.Map;

import static fr.openmc.core.utils.InputUtils.MAX_LENGTH;

public class CityBankWithdrawMenu extends Menu {

public CityBankWithdrawMenu(Player owner) {
Expand Down Expand Up @@ -144,7 +146,7 @@ public void onInventoryClick(InventoryClickEvent click) {
}).setOnClick(inventoryClickEvent -> {
if (!CityBankConditions.canCityWithdraw(city, player)) return;

DialogInput.send(player, "Entrez le montant que vous voulez retirer", 100, input ->
DialogInput.send(player, Component.text("Entrez le montant que vous voulez retirer"), MAX_LENGTH, input ->
city.withdrawCityBank(player, input)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public void onClose(InventoryCloseEvent event) {
MessagesManager.sendMessage(member, Component.text("Le §6Maire §fa déclenché la §eDissuasion Militaire §f!"), Prefix.MAYOR, MessageType.INFO, false);
}

MilitaryDissuasion.spawnIronMan(city, 10);
MilitaryDissuasion.launchEvent(city, 10);
DynamicCooldownManager.use(city.getUUID(), "city:military_dissuasion", 10 * 60 * 1000L); // 10 minutes
DynamicCooldownManager.use(mayor.getUUID().toString(), "mayor:law-perk-event", PerkManager.getPerkEvent(mayor).getCooldown());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import fr.openmc.core.OMCPlugin;
import fr.openmc.core.features.city.City;
import fr.openmc.core.features.city.CityManager;
import fr.openmc.core.utils.ChunkPos;
import fr.openmc.core.items.CustomItemRegistry;
import fr.openmc.core.utils.ChunkPos;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
Expand Down Expand Up @@ -54,8 +54,8 @@ public void run() {
}

ChunkPos chunk = chunkList.get(random.nextInt(chunkList.size()));
int chunkX = chunk.getX();
int chunkZ = chunk.getZ();
int chunkX = chunk.x();
int chunkZ = chunk.z();

int x = (chunkX << 4) + random.nextInt(16);
int z = (chunkZ << 4) + random.nextInt(16);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class MilitaryDissuasion implements Listener {
* @param city The city where the golems will be spawned.
* @param golemsToSpawn The number of golems to spawn.
*/
public static void spawnIronMan(City city, int golemsToSpawn) {
public static void launchEvent(City city, int golemsToSpawn) {
Comment thread
iambibi marked this conversation as resolved.
Outdated
Set<ChunkPos> chunks = city.getChunks();
if (chunks.isEmpty()) return;

Expand All @@ -45,8 +45,8 @@ public static void spawnIronMan(City city, int golemsToSpawn) {

ChunkPos chunk = chunkList.get(spawned % chunkList.size());

int chunkX = chunk.getX();
int chunkZ = chunk.getZ();
int chunkX = chunk.x();
int chunkZ = chunk.z();

int x = (chunkX << 4) + 8 + random.nextInt(8);
int z = (chunkZ << 4) + 8 + random.nextInt(8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public static int transferChunksAfterWar(City winner, City loser, int claimAmoun

Set<ChunkPos> adjacentChunks = new HashSet<>();
for (ChunkPos wChunk : winner.getChunks()) {
int wx = wChunk.getX(), wz = wChunk.getZ();
int wx = wChunk.x(), wz = wChunk.z();

ChunkPos[] neighbors = {
new ChunkPos(wx + 1, wz),
Expand All @@ -348,7 +348,7 @@ public static int transferChunksAfterWar(City winner, City loser, int claimAmoun
BiConsumer<Queue<ChunkPos>, Set<ChunkPos>> bfsCapture = (queue, visited) -> {
while (!queue.isEmpty() && transferred[0] < claimAmount) {
ChunkPos current = queue.poll();
int cx = current.getX(), cz = current.getZ();
int cx = current.x(), cz = current.z();

ChunkPos[] neighs = {
new ChunkPos(cx + 1, cz),
Expand All @@ -360,8 +360,8 @@ public static int transferChunksAfterWar(City winner, City loser, int claimAmoun
if (visited.contains(nb) || nb.equals(mascotVec)) continue;

if (loser.getChunks().contains(nb)) {
loser.removeChunk(nb.getX(), nb.getZ());
winner.addChunk(nb.getX(), nb.getZ());
loser.removeChunk(nb.x(), nb.z());
winner.addChunk(nb.x(), nb.z());
visited.add(nb);
queue.add(nb);
transferred[0]++;
Expand All @@ -378,8 +378,8 @@ public static int transferChunksAfterWar(City winner, City loser, int claimAmoun
Set<ChunkPos> visited = new HashSet<>();
for (int i = 0; i < initialSteal; i++) {
ChunkPos c = toSteal.get(i);
loser.removeChunk(c.getX(), c.getZ());
winner.addChunk(c.getX(), c.getZ());
loser.removeChunk(c.x(), c.z());
winner.addChunk(c.x(), c.z());
queue.add(c);
visited.add(c);
transferred[0]++;
Expand All @@ -390,7 +390,7 @@ public static int transferChunksAfterWar(City winner, City loser, int claimAmoun
List<ChunkPos> borderChunks = new ArrayList<>();
for (ChunkPos lChunk : loser.getChunks()) {
if (lChunk.equals(mascotVec)) continue;
int lx = lChunk.getX(), lz = lChunk.getZ();
int lx = lChunk.x(), lz = lChunk.z();
ChunkPos[] neighs = {
new ChunkPos(lx + 1, lz),
new ChunkPos(lx - 1, lz),
Expand All @@ -409,8 +409,8 @@ public static int transferChunksAfterWar(City winner, City loser, int claimAmoun
Collections.shuffle(borderChunks);
ChunkPos seed = borderChunks.get(0);

loser.removeChunk(seed.getX(), seed.getZ());
winner.addChunk(seed.getX(), seed.getZ());
loser.removeChunk(seed.x(), seed.z());
winner.addChunk(seed.x(), seed.z());
Queue<ChunkPos> queue = new LinkedList<>();
Set<ChunkPos> visited = new HashSet<>();
queue.add(seed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

import java.util.*;



public class TradeMenu extends Menu {

public TradeMenu(Player owner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import java.util.List;
import java.util.Map;

import static fr.openmc.core.utils.InputUtils.MAX_LENGTH;

public class ShopSearchMenu extends PaginatedMenu {

public ShopSearchMenu(Player owner) {
Expand Down Expand Up @@ -95,7 +97,7 @@ public Map<Integer, ItemStack> getButtons() {
.setPreviousPageButton());
buttons.put(50, nextPageButton.setNextPageButton());
buttons.put(45, searchButton.setOnClick(inventoryClick -> {
DialogInput.send(getOwner(), "Entrez le nom du shop ou bien du joueur pour le rechercher", 100, input -> {
DialogInput.send(getOwner(), Component.text("Entrez le nom du shop ou bien du joueur pour le rechercher"), MAX_LENGTH, input -> {
boolean shopFind = false;

for (Shop shop : CompanyManager.shops) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.List;
import java.util.Map;

import static fr.openmc.core.utils.InputUtils.MAX_LENGTH;

public class PersonalBankDepositMenu extends Menu {

public PersonalBankDepositMenu(Player owner) {
Expand Down Expand Up @@ -105,7 +107,7 @@ public void onInventoryClick(InventoryClickEvent click) {
itemMeta.itemName(Component.text("§7Déposer un §6montant précis"));
itemMeta.lore(loreBankDepositInput);
}).setOnClick(inventoryClickEvent -> {
DialogInput.send(player, "Entrez le montant que vous voulez déposer", 100, input ->
DialogInput.send(player, Component.text("Entrez le montant que vous voulez déposer"), MAX_LENGTH, input ->
BankManager.addBankBalance(player, input)
);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.List;
import java.util.Map;

import static fr.openmc.core.utils.InputUtils.MAX_LENGTH;

public class PersonalBankWithdrawMenu extends Menu {

public PersonalBankWithdrawMenu(Player owner) {
Expand Down Expand Up @@ -107,7 +109,7 @@ public void onInventoryClick(InventoryClickEvent click) {
itemMeta.itemName(Component.text("§7Prendre un §6montant précis"));
itemMeta.lore(loreBankWithdrawInput);
}).setOnClick(inventoryClickEvent -> {
DialogInput.send(player, "Entrez le montant que vous voulez retirer", 100, input ->
DialogInput.send(player, Component.text("Entrez le montant que vous voulez retirer"), MAX_LENGTH, input ->
BankManager.withdrawBankBalance(player, input)
);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

import static fr.openmc.core.utils.InputUtils.MAX_LENGTH;

public class HomeChangeIconMenu extends PaginatedMenu {

private final Home home;
Expand Down Expand Up @@ -110,7 +112,7 @@ public Map<Integer, ItemStack> getButtons() {
if (event.getClick().isLeftClick()) {
getOwner().closeInventory();

DialogInput.send(getOwner(), "Entrez votre recherche pour un item", 100, input -> {
DialogInput.send(getOwner(), Component.text("Entrez votre recherche pour un item"), MAX_LENGTH, input -> {
searchQuery = input;
currentCategory = IconCategory.ALL;
setPage(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public HomeConfigMenu(Player owner, Home home) {
.build();
itemMeta.lore(Collections.singletonList(lore));
}).setOnClick(e -> {
DialogInput.send(getOwner(), "Entrez votre nouveau nom de home", MAX_LENGTH_HOME_NAME, input -> {
DialogInput.send(getOwner(), Component.text("Entrez votre nouveau nom de home"), MAX_LENGTH_HOME_NAME, input -> {
if (!HomeUtil.isValidHomeName(input)) return;

if (HomesManager.getHomesNames(getOwner().getUniqueId()).contains(input)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static boolean isValidHomeName(String name) {
name == null ||
name.trim().isEmpty() ||
name.length() < 3 ||
name.length() > MAX_LENGTH_HOME_NAME
name.length() > MAX_LENGTH_HOME_NAME
) return false;

long alphanumericCount = name.chars().filter(Character::isLetterOrDigit).count();
Expand Down
20 changes: 1 addition & 19 deletions src/main/java/fr/openmc/core/utils/ChunkPos.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
package fr.openmc.core.utils;

import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;

@Getter
public class ChunkPos {

final int x, z;
public ChunkPos(int x, int z) { this.x = x; this.z = z; }

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ChunkPos chunkPos = (ChunkPos) o;
return x == chunkPos.x && z == chunkPos.z;
}
public record ChunkPos(int x, int z) {

public Chunk getChunkInWorld() {
World world = Bukkit.getWorld("world");
Expand Down Expand Up @@ -50,11 +37,6 @@ public int distanceSq(ChunkPos other) {
return dx * dx + dz * dz;
}

@Override
public int hashCode() {
return 31 * x + z;
}

@Override
Comment thread
iambibi marked this conversation as resolved.
Outdated
public String toString() {
return x + "," + z;
Expand Down
Loading