Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.
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
89 changes: 44 additions & 45 deletions src/main/java/fr/communaywen/core/AywenCraftPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import fr.communaywen.core.claim.ClaimListener;
import fr.communaywen.core.claim.GamePlayer;
import fr.communaywen.core.claim.RegionManager;
import fr.communaywen.core.clockinfos.tasks.CompassClockTask;
import fr.communaywen.core.commands.credits.CreditCommand;
import fr.communaywen.core.commands.credits.FeatureCommand;
import fr.communaywen.core.commands.economy.AdminShopCommand;
Expand All @@ -16,26 +17,27 @@
import fr.communaywen.core.commands.explosion.ExplodeRandomCommand;
import fr.communaywen.core.commands.explosion.FBoomCommand;
import fr.communaywen.core.commands.fun.*;
import fr.communaywen.core.commands.staff.ReportCommands;
import fr.communaywen.core.commands.utils.*;
import fr.communaywen.core.commands.teleport.RTPCommand;
import fr.communaywen.core.commands.teleport.SpawnCommand;
import fr.communaywen.core.commands.link.LinkCommand;
import fr.communaywen.core.commands.link.ManualLinkCommand;
import fr.communaywen.core.commands.socials.DiscordCommand;
import fr.communaywen.core.commands.socials.GithubCommand;
import fr.communaywen.core.commands.staff.ReportCommands;
import fr.communaywen.core.commands.teams.TeamAdminCommand;
import fr.communaywen.core.commands.teams.TeamCommand;
import fr.communaywen.core.commands.teleport.RTPCommand;
import fr.communaywen.core.commands.teleport.SpawnCommand;
import fr.communaywen.core.commands.utils.*;
import fr.communaywen.core.customitems.commands.ShowCraftCommand;
import fr.communaywen.core.customitems.listeners.CIBreakBlockListener;
import fr.communaywen.core.customitems.listeners.CIEnchantListener;
import fr.communaywen.core.customitems.listeners.CIPrepareAnvilListener;
import fr.communaywen.core.fallblood.BandageRecipe;
import fr.communaywen.core.clockinfos.tasks.CompassClockTask;
import fr.communaywen.core.friends.commands.FriendsCommand;
import fr.communaywen.core.levels.LevelsCommand;
import fr.communaywen.core.levels.LevelsListeners;
import fr.communaywen.core.listeners.*;
import fr.communaywen.core.mailboxes.MailboxCommand;
import fr.communaywen.core.mailboxes.MailboxListener;
import fr.communaywen.core.quests.PlayerQuests;
import fr.communaywen.core.quests.QuestsListener;
import fr.communaywen.core.quests.QuestsManager;
Expand All @@ -50,7 +52,10 @@
import fr.communaywen.core.trade.TradeAcceptCommand;
import fr.communaywen.core.trade.TradeCommand;
import fr.communaywen.core.trade.TradeListener;
import fr.communaywen.core.utils.*;
import fr.communaywen.core.utils.DiscordWebhook;
import fr.communaywen.core.utils.LinkerAPI;
import fr.communaywen.core.utils.MOTDChanger;
import fr.communaywen.core.utils.PermissionCategory;
import fr.communaywen.core.utils.command.InteractiveHelpMenu;
import lombok.Getter;
import lombok.SneakyThrows;
Expand All @@ -59,6 +64,8 @@
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.Inventory;
Expand All @@ -68,46 +75,50 @@
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import revxrsal.commands.autocomplete.SuggestionProvider;
import revxrsal.commands.bukkit.BukkitCommandHandler;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.io.File;

public final class AywenCraftPlugin extends JavaPlugin {
public static ArrayList<Player> frozenPlayers = new ArrayList<>();
public static ArrayList<Player> playerClaimsByPass = new ArrayList<>();

@Getter
private static AywenCraftPlugin instance;
@Getter
private final Managers managers = new Managers();

public EventsManager eventsManager; // TODO: include to Managers.java

@Getter
private static AywenCraftPlugin instance;
public LuckPerms api;

public List<RegionManager> regions;
public MultiverseCore mvCore;
@Getter
private BukkitAudiences adventure;
@Getter
private InteractiveHelpMenu interactiveHelpMenu;

@Getter
private BukkitCommandHandler handler;

@Getter
private TabList tabList;

public List<RegionManager> regions;
public MultiverseCore mvCore;
/**
* Format a permission with the permission prefix.
*
* @param category the permission category
* @param suffix the permission suffix
* @return The formatted permission.
* @see PermissionCategory #PERMISSION_PREFIX
*/
public static @NotNull String formatPermission(final @NotNull PermissionCategory category,
final @NotNull String suffix) {
return category.formatPermission(suffix);
}

@SneakyThrows
@Override
public void onEnable() {
Expand All @@ -120,8 +131,7 @@ public void onEnable() {
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
api = provider.getProvider();
}
else {
} else {
getLogger().severe("LuckPerms not found !");
getServer().getPluginManager().disablePlugin(this);
return;
Expand Down Expand Up @@ -204,7 +214,8 @@ public void onEnable() {
new DiscordCommand(this),
new ShowCraftCommand(managers.getCustomItemsManager()),
new ReportCommands(),
new ChatChannelCMD()
new ChatChannelCMD(),
new MailboxCommand()
);

/* -------- */
Expand Down Expand Up @@ -251,11 +262,12 @@ public void run() {
new CIBreakBlockListener(managers.getCustomItemsManager()),
new CIEnchantListener(managers.getCustomItemsManager()),
new CIPrepareAnvilListener(managers.getCustomItemsManager()),
new BabyFuzeListener()
new BabyFuzeListener(),
new MailboxListener()
);

getServer().getPluginManager().registerEvents(eventsManager, this); // TODO: refactor

/* --------- */

saveDefaultConfig();
Expand All @@ -277,8 +289,8 @@ public void run() {
@SneakyThrows
@Override
public void onDisable() {
for(Player player : Bukkit.getOnlinePlayers()) {
for(QUESTS quests : QUESTS.values()) {
for (Player player : Bukkit.getOnlinePlayers()) {
for (QUESTS quests : QUESTS.values()) {
PlayerQuests pq = QuestsManager.getPlayerQuests(player); // Load quest progress
QuestsManager.savePlayerQuestProgress(player, quests, pq.getProgress(quests)); // Save quest progress
player.closeInventory(); // Close inventory
Expand All @@ -297,13 +309,13 @@ public ArrayList<Player> getFrozenPlayers() {
return frozenPlayers;
}


// Farine pour fabriquer du pain

public int getBanDuration() {
return getConfig().getInt("deco_freeze_nombre_de_jours_ban", 30);
}


// Farine pour fabriquer du pain

private void createFarineRecipe() {
ItemStack farine = new ItemStack(Material.SUGAR);
ItemMeta meta = farine.getItemMeta();
Expand All @@ -319,7 +331,7 @@ private void createFarineRecipe() {
Bukkit.addRecipe(recipe);
}

private void createCrazyPotion(){
private void createCrazyPotion() {
ItemStack crazyPotion = new ItemStack(Material.POTION);
PotionMeta meta = (PotionMeta) crazyPotion.getItemMeta();

Expand Down Expand Up @@ -370,17 +382,4 @@ private FileConfiguration loadEventsManager() {
}
return YamlConfiguration.loadConfiguration(eventsFile);
}

/**
* Format a permission with the permission prefix.
*
* @param category the permission category
* @param suffix the permission suffix
* @return The formatted permission.
* @see PermissionCategory #PERMISSION_PREFIX
*/
public static @NotNull String formatPermission(final @NotNull PermissionCategory category,
final @NotNull String suffix) {
return category.formatPermission(suffix);
}
}
91 changes: 91 additions & 0 deletions src/main/java/fr/communaywen/core/mailboxes/MailboxCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package fr.communaywen.core.mailboxes;

import fr.communaywen.core.credit.Credit;
import fr.communaywen.core.mailboxes.letter.LetterHead;
import fr.communaywen.core.mailboxes.menu.HomeMailbox;
import fr.communaywen.core.mailboxes.menu.PendingMailbox;
import fr.communaywen.core.mailboxes.menu.PlayerMailbox;
import fr.communaywen.core.mailboxes.menu.letter.Letter;
import fr.communaywen.core.mailboxes.menu.letter.SendingLetter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import revxrsal.commands.annotation.*;
import revxrsal.commands.autocomplete.SuggestionProvider;
import revxrsal.commands.bukkit.annotation.CommandPermission;

import static fr.communaywen.core.mailboxes.utils.MailboxUtils.sendFailureMessage;
import static fr.communaywen.core.mailboxes.utils.MailboxUtils.sendWarningMessage;

@Command({"mailbox", "mb", "letter", "mail", "lettre", "boite", "courrier"})
@CommandPermission("ayw.command.mailbox")
@Credit("Gexary")
public class MailboxCommand {

@Subcommand("home")
@Description("Ouvrir la page d'accueil de la boite aux lettres")
public void homeMailbox(Player player) {
HomeMailbox homeMailbox = new HomeMailbox(player);
homeMailbox.openInventory();
}

@Subcommand("send")
@Description("Envoyer une lettre à un joueur")
@AutoComplete("@players")
public void sendMailbox(Player player, @Named("player") String receiver) {
OfflinePlayer receiverPlayer = Bukkit.getPlayerExact(receiver);
if (receiverPlayer == null) receiverPlayer = Bukkit.getOfflinePlayerIfCached(receiver);
if (receiverPlayer == null || !(receiverPlayer.hasPlayedBefore() || receiverPlayer.isOnline())) {
Component message = Component.text("Le joueur ", NamedTextColor.DARK_RED)
.append(Component.text(receiver, NamedTextColor.RED))
.append(Component.text(" n'existe pas ou ne s'est jamais connecté !", NamedTextColor.DARK_RED));
sendFailureMessage(player, message);
} else if (receiverPlayer.getPlayer() == player) {
sendWarningMessage(player, "Vous ne pouvez pas vous envoyer à vous-même !");
} else if (MailboxManager.canSend(player, receiverPlayer)) {
SendingLetter sendingLetter = new SendingLetter(player, receiverPlayer);
sendingLetter.openInventory();
} else {
sendFailureMessage(player, "Vous n'avez pas les droits pour envoyer à cette personne !");
}
}

@Subcommand("pending")
@Description("Ouvrir les lettres en attente de réception")
public void pendingMailbox(Player player) {
PendingMailbox pendingMailbox = new PendingMailbox(player);
pendingMailbox.openInventory();
}

@SecretCommand
@Subcommand("open")
@Description("Ouvrir une lettre")
public void openMailbox(Player player, @Named("id") @Range(min = 1, max = Integer.MAX_VALUE) int id) {
LetterHead letterHead = Letter.getById(player, id);
if (letterHead == null) return;
Letter mailbox = new Letter(player, letterHead);
mailbox.openInventory();
}

@Subcommand("refuse")
@SecretCommand
@Description("Refuser une lettre")
public void refuseMailbox(Player player, @Named("id") @Range(min = 1, max = Integer.MAX_VALUE) int id) {
Letter.refuseLetter(player, id);
}

@Subcommand("cancel")
@SecretCommand
@Description("Annuler une lettre")
public void cancelMailbox(Player player, @Named("id") @Range(min = 1, max = Integer.MAX_VALUE) int id) {
PendingMailbox.cancelLetter(player, id);
}

@DefaultFor("~")
public void mailbox(Player player) {
PlayerMailbox playerMailbox = new PlayerMailbox(player);
playerMailbox.openInventory();
}
}
Loading