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 @@ -244,8 +244,10 @@ public enum Permission {
ESSENTIALS_SUDO,
ESSENTIALS_SUDO_BYPASS,
ESSENTIALS_MAIL_GIVE,
ESSENTIALS_MAIL_GIVE_HAND,
ESSENTIALS_MAIL_CLEAR,
ESSENTIALS_MAIL_GIVEALL,
ESSENTIALS_MAIL_GIVEALL_HAND,
ESSENTIALS_WORLDEDIT_USE,
ESSENTIALS_WORLDEDIT_GIVE,
ESSENTIALS_WORLDEDIT_SET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ public enum Message {
DESCRIPTION_MAIL("Open mailbox"),
DESCRIPTION_MAIL_OPEN("Open player's mailbox"),
DESCRIPTION_MAIL_GIVE("Give an item to player's mailbox"),
DESCRIPTION_MAIL_GIVE_HAND("Send the item in your hand to a player's mailbox"),
DESCRIPTION_MAIL_CLEAR("Removes items from the player’s mailbox"),
DESCRIPTION_MAIL_GIVEALL("Give an items to players mailbox"),
DESCRIPTION_MAIL_GIVEALL_HAND("Send the item in your hand to players mailboxes"),
DESCRIPTION_RULES("Read server rules"),
DESCRIPTION_SUICIDE("Kill yourself"),
DESCRIPTION_HOLOGRAM("Show hologram commands"),
Expand Down Expand Up @@ -738,6 +740,8 @@ public enum Message {
MAILBOX_GIVE_ERROR("<error>Can’t find the item &f%item%<error>."),
MAILBOX_GIVE("<success>You just gave &n&fx%amount% %item%&r <success>to player &f%player%<success> mailbox."),
MAILBOX_GIVE_ALL("<success>You just gave &n&fx%amount% %item%&r <success>to online player mailbox."),
MAILBOX_GIVE_HAND("<success>You just sent the item in your hand to &f%player%<success>'s mailbox (&fx%amount% %item%<success>)."),
MAILBOX_GIVE_ALL_HAND("<success>You just sent the item in your hand (&fx%amount% %item%<success>) to every online player's mailbox."),
MAILBOX_CLEAR("<success>You have just cleared the mailbox of &f%player%<success>."),


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public CommandMail(EssentialsPlugin plugin) {
this.setPermission(Permission.ESSENTIALS_MAIL);
this.addSubCommand(new CommandMailOpen(plugin));
this.addSubCommand(new CommandMailGive(plugin));
this.addSubCommand(new CommandMailGiveHand(plugin));
this.addSubCommand(new CommandMailGiveAll(plugin));
this.addSubCommand(new CommandMailGiveAllHand(plugin));
this.addSubCommand(new CommandMailClear(plugin));
this.onlyPlayers();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package fr.maxlego08.essentials.commands.commands.mail;

import fr.maxlego08.essentials.api.EssentialsPlugin;
import fr.maxlego08.essentials.api.commands.CommandResultType;
import fr.maxlego08.essentials.api.commands.Permission;
import fr.maxlego08.essentials.api.messages.Message;
import fr.maxlego08.essentials.module.modules.MailBoxModule;
import fr.maxlego08.essentials.zutils.utils.commands.VCommand;
import org.bukkit.inventory.ItemStack;

public class CommandMailGiveAllHand extends VCommand {

public CommandMailGiveAllHand(EssentialsPlugin plugin) {
super(plugin);
this.setModule(MailBoxModule.class);
this.setDescription(Message.DESCRIPTION_MAIL_GIVEALL_HAND);
this.setPermission(Permission.ESSENTIALS_MAIL_GIVEALL_HAND);
this.addSubCommand("giveall-hand");
this.onlyPlayers();
}

@Override
protected CommandResultType perform(EssentialsPlugin plugin) {

ItemStack itemStack = this.player.getInventory().getItemInMainHand();
if (itemStack == null || itemStack.getType().isAir()) {
message(this.sender, Message.COMMAND_ITEM_EMPTY);
return CommandResultType.DEFAULT;
}

var module = plugin.getModuleManager().getModule(MailBoxModule.class);
module.giveAllItemFromHand(this.sender, itemStack.clone());

return CommandResultType.SUCCESS;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package fr.maxlego08.essentials.commands.commands.mail;

import fr.maxlego08.essentials.api.EssentialsPlugin;
import fr.maxlego08.essentials.api.commands.CommandResultType;
import fr.maxlego08.essentials.api.commands.Permission;
import fr.maxlego08.essentials.api.messages.Message;
import fr.maxlego08.essentials.module.modules.MailBoxModule;
import fr.maxlego08.essentials.zutils.utils.commands.VCommand;
import org.bukkit.inventory.ItemStack;

public class CommandMailGiveHand extends VCommand {

public CommandMailGiveHand(EssentialsPlugin plugin) {
super(plugin);
this.setModule(MailBoxModule.class);
this.setDescription(Message.DESCRIPTION_MAIL_GIVE_HAND);
this.setPermission(Permission.ESSENTIALS_MAIL_GIVE_HAND);
this.addSubCommand("give-hand");
this.addRequireOfflinePlayerNameArg();
this.onlyPlayers();
}

@Override
protected CommandResultType perform(EssentialsPlugin plugin) {

ItemStack itemStack = this.player.getInventory().getItemInMainHand();
if (itemStack == null || itemStack.getType().isAir()) {
message(this.sender, Message.COMMAND_ITEM_EMPTY);
return CommandResultType.DEFAULT;
}

String username = this.argAsString(0);
ItemStack itemToGive = itemStack.clone();

var module = plugin.getModuleManager().getModule(MailBoxModule.class);
this.fetchUniqueId(username, uuid -> module.giveItemFromHand(this.sender, uuid, username, itemToGive));

return CommandResultType.SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,51 @@ public void giveAllItem(CommandSender sender, String itemName, int amount) {
message(sender, Message.MAILBOX_GIVE_ALL, "%item%", itemName, "%amount%", amount);
}

public void giveItemFromHand(CommandSender sender, UUID uuid, String username, ItemStack itemStack) {

if (itemStack == null || itemStack.getType().isAir()) {
message(sender, Message.COMMAND_ITEM_EMPTY);
return;
}

ItemStack clonedItemStack = itemStack.clone();
addItemAndFix(uuid, clonedItemStack);

message(sender, Message.MAILBOX_GIVE_HAND,
"%item%", getItemName(clonedItemStack),
"%player%", username,
"%amount%", clonedItemStack.getAmount());
}

public void giveAllItemFromHand(CommandSender sender, ItemStack itemStack) {

if (itemStack == null || itemStack.getType().isAir()) {
message(sender, Message.COMMAND_ITEM_EMPTY);
return;
}

String itemName = getItemName(itemStack);
int amount = itemStack.getAmount();

for (Player player : Bukkit.getOnlinePlayers()) {
addItemAndFix(player.getUniqueId(), itemStack.clone());
}

message(sender, Message.MAILBOX_GIVE_ALL_HAND,
"%item%", itemName,
"%amount%", amount);
}

private String getItemName(ItemStack itemStack) {
if (itemStack.hasItemMeta()) {
var itemMeta = itemStack.getItemMeta();
if (itemMeta != null && itemMeta.hasDisplayName()) {
return itemMeta.getDisplayName();
}
}
return name(itemStack.getType().name());
}

public void clear(CommandSender sender, UUID uuid, String username) {
getStorage().clearMailBox(uuid);
var user = getUser(uuid);
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/messages/message_zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ description-balance-top: 显示财富排行榜
description-balance-top-refresh: 刷新财富排行榜
description-mail-open: 打开玩家的邮箱
description-mail-give: 给玩家的邮箱赠送一个物品
description-mail-give-hand: 将你手中的物品发送到玩家的邮箱
description-mail-giveall: 给所有玩家的邮箱赠送物品
description-mail-giveall-hand: 将你手中的物品发送到所有在线玩家的邮箱
description-voteparty-information: 显示投票派对
description-voteparty-set: 设置投票派对所需的票数
description-voteparty-add: 向投票派对添加票数
Expand Down Expand Up @@ -820,6 +822,8 @@ mailbox-add:
mailbox-give-error: <error>找不到物品 &f%item%<error>。
mailbox-give: <success>你刚刚给了 &n&fx%amount% %item%&r <success>给玩家 &f%player%<success>的邮箱。
mailbox-give-all: <success>你刚刚给了 &n&fx%amount% %item%&r <success>给在线玩家的邮箱。
mailbox-give-hand: <success>你已将手中的物品发送到 &f%player%<success> 的邮箱 (&fx%amount% %item%<success>)。
mailbox-give-all-hand: <success>你已将手中的物品 (&fx%amount% %item%<success>) 发送到所有在线玩家的邮箱。
hologram-create-error: <error>全息图 &f%name% <error>已经存在。
hologram-create:
type: WITHOUT_PREFIX
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/messages/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ description-balance-top: "Show baltop"
description-balance-top-refresh: "Refresh baltop"
description-mail-open: "Open player's mailbox"
description-mail-give: "Give an item to player's mailbox"
description-mail-give-hand: "Send the item in your hand to a player's mailbox"
description-mail-giveall: "Give items to players' mailboxes"
description-mail-giveall-hand: "Send the item in your hand to players' mailboxes"
description-mail-clear: "Removes items from the player’s mailbox"
description-voteparty-information: "Show the vote party"
description-voteparty-set: "Set the number of votes in the vote party"
Expand Down Expand Up @@ -815,6 +817,8 @@ mailbox-add:
mailbox-give-error: "<error>Can’t find the item &f%item%<error>."
mailbox-give: "<success>You just gave &n&fx%amount% %item%&r <success>to player &f%player%<success>'s mailbox."
mailbox-give-all: "<success>You just gave &n&fx%amount% %item%&r <success>to online players' mailboxes."
mailbox-give-hand: "<success>You just sent the item in your hand to &f%player%<success>'s mailbox (&fx%amount% %item%<success>)."
mailbox-give-all-hand: "<success>You just sent the item in your hand (&fx%amount% %item%<success>) to every online player's mailbox."
mailbox-clear: "<success>You have just cleared the mailbox of &f%player%<success>."


Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/messages/messages_de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ description-balance-top: "Baltop anzeigen"
description-balance-top-refresh: "Baltop aktualisieren"
description-mail-open: "Postfach eines Spielers öffnen"
description-mail-give: "Einem Spieler einen Gegenstand ins Postfach legen"
description-mail-give-hand: "Den Gegenstand in deiner Hand in das Postfach eines Spielers senden"
description-mail-giveall: "Gegenstände in die Postfächer der Spieler legen"
description-mail-giveall-hand: "Den Gegenstand in deiner Hand in die Postfächer der Spieler senden"
description-voteparty-information: "Stimmenparty anzeigen"
description-voteparty-set: "Anzahl der Stimmen in der Stimmenparty festlegen"
description-voteparty-add: "Zur Stimmenparty hinzufügen"
Expand Down Expand Up @@ -753,6 +755,8 @@ mailbox-add:
mailbox-give-error: "<error>Der Gegenstand &f%item%<error> konnte nicht gefunden werden."
mailbox-give: "<success>Du hast gerade &n&fx%amount% %item%&r <success>an das Postfach von &f%player%<success> gegeben."
mailbox-give-all: "<success>Du hast gerade &n&fx%amount% %item%&r <success>an die Postfächer aller Online-Spieler gegeben."
mailbox-give-hand: "<success>Du hast den Gegenstand in deiner Hand an das Postfach von &f%player%<success> gesendet (&fx%amount% %item%<success>)."
mailbox-give-all-hand: "<success>Du hast den Gegenstand in deiner Hand (&fx%amount% %item%<success>) an die Postfächer aller Online-Spieler gesendet."



Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/messages/messages_es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ description-balance-top: "Mostrar el top de balance"
description-balance-top-refresh: "Actualizar el top de balance"
description-mail-open: "Abrir el buzón del jugador"
description-mail-give: "Dar un objeto al buzón del jugador"
description-mail-give-hand: "Enviar el objeto en tu mano al buzón de un jugador"
description-mail-giveall: "Dar objetos a los buzones de los jugadores"
description-mail-giveall-hand: "Enviar el objeto en tu mano a los buzones de los jugadores conectados"
description-voteparty-information: "Mostrar la fiesta de votación"
description-voteparty-set: "Establecer el número de votos en la fiesta de votación"
description-voteparty-add: "Agregar a la fiesta de votación"
Expand Down Expand Up @@ -712,6 +714,8 @@ mailbox-add:
mailbox-give-error: "<error>No se puede encontrar el objeto &f%item%<error>."
mailbox-give: "<success>Acabas de dar &n&fx%amount% %item%&r <success>al buzón del jugador &f%player%<success>."
mailbox-give-all: "<success>Acabas de dar &n&fx%amount% %item%&r <success>a los buzones de los jugadores en línea."
mailbox-give-hand: "<success>Acabas de enviar el objeto en tu mano al buzón de &f%player%<success> (&fx%amount% %item%<success>)."
mailbox-give-all-hand: "<success>Acabas de enviar el objeto en tu mano (&fx%amount% %item%<success>) a los buzones de todos los jugadores conectados."

hologram-create-error: "<error>El holograma &f%name% <error>ya existe."
hologram-create:
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/messages/messages_fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ description-balance-top: "Afficher le classement des soldes"
description-balance-top-refresh: "Actualiser le classement des soldes"
description-mail-open: "Ouvrir la boite mail d'un joueur"
description-mail-give: "Donner un objet à la boîte aux lettres du joueur"
description-mail-give-hand: "Envoyer l'objet dans votre main dans la boîte aux lettres d'un joueur"
description-mail-giveall: "Donner des objets aux boîtes aux lettres des joueurs"
description-mail-giveall-hand: "Envoyer l'objet dans votre main dans la boîte aux lettres des joueurs connectés"
description-mail-clear: "Removes items from the player’s mailbox"
description-voteparty-information: "Afficher le vote party"
description-voteparty-set: "Définir le nombre de votes dans le vote party"
Expand Down Expand Up @@ -778,6 +780,8 @@ mailbox-add:
mailbox-give-error: "<error>Impossible de trouver l'objet &f%item%<error>."
mailbox-give: "<success>Vous venez de donner &n&fx%amount% %item%&r <success> à la boîte aux lettres du joueur &f%player%<success>."
mailbox-give-all: "<success>Vous venez de donner &n&fx%amount% %item%&r <success> aux boîtes aux lettres des joueurs en ligne."
mailbox-give-hand: "<success>Vous venez d'envoyer l'objet dans votre main dans la boîte aux lettres de &f%player%<success> (&fx%amount% %item%<success>)."
mailbox-give-all-hand: "<success>Vous venez d'envoyer l'objet dans votre main (&fx%amount% %item%<success>) dans la boîte aux lettres de tous les joueurs connectés."
mailbox-clear: "<success>Vous venez d’effacer la boîte aux lettres de &f%player%<success>."

hologram-create-error: "<error>Le hologramme &f%name% <error>existe déjà."
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/messages/messages_it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ description-balance-top: "Mostra il baltop"
description-balance-top-refresh: "Aggiorna il baltop"
description-mail-open: "Apre la mailbox del giocatore"
description-mail-give: "Da un oggetto nella mailbox del giocatore"
description-mail-give-hand: "Invia l'oggetto nella tua mano alla mailbox di un giocatore"
description-mail-giveall: "Dai un oggetto nella mailbox di tutti i giocatori"
description-mail-giveall-hand: "Invia l'oggetto nella tua mano alle mailbox dei giocatori online"
description-voteparty-information: "Mostra il vote party"
description-voteparty-set: "Imposta il numero di voti nel vote party"
description-voteparty-add: "Aggiungi voti al vote party"
Expand Down Expand Up @@ -710,6 +712,8 @@ mailbox-add:
mailbox-give-error: "<error>Non si riesce a trovare l'oggetto &f%item%<error>."
mailbox-give: "<success>Hai dato &n&fx%amount% %item%&r <success>alla mailbox di &f%player%<success>."
mailbox-give-all: "<success>Hai dato &n&fx%amount% %item%&r <success>a tutte le mailbox dei giocatori online."
mailbox-give-hand: "<success>Hai inviato l'oggetto nella tua mano alla mailbox di &f%player%<success> (&fx%amount% %item%<success>)."
mailbox-give-all-hand: "<success>Hai inviato l'oggetto nella tua mano (&fx%amount% %item%<success>) alle mailbox di tutti i giocatori online."


hologram-create-error: "<error>Ologramma di nome &f%name% <error>esiste già."
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/messages/messages_nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ description-balance-top: "Toon de baltop"
description-balance-top-refresh: "Vernieuw de baltop"
description-mail-open: "Open de mailbox van een speler"
description-mail-give: "Geef een item aan een speler hun postbus"
description-mail-give-hand: "Stuur het item in je hand naar de mailbox van een speler"
description-mail-giveall: "Geef items aan spelers hun postbus"
description-mail-giveall-hand: "Stuur het item in je hand naar de mailboxes van online spelers"
description-voteparty-information: "Toon de vote party"
description-voteparty-set: "Stel het aantal stemmen in de vote party in"
description-voteparty-add: "Voeg toe aan de vote party"
Expand Down Expand Up @@ -791,6 +793,8 @@ mailbox-add:
mailbox-give-error: "<error>Kan het item &f%item%<error> niet vinden."
mailbox-give: "<success>Je hebt zojuist &n&fx%amount% %item%&r <success>gegeven aan de mailbox van speler &f%player%<success>."
mailbox-give-all: "<success>Je hebt zojuist &n&fx%amount% %item%&r <success>gegeven aan de mailboxes van alle online spelers."
mailbox-give-hand: "<success>Je hebt het item in je hand naar de mailbox van &f%player%<success> gestuurd (&fx%amount% %item%<success>)."
mailbox-give-all-hand: "<success>Je hebt het item in je hand (&fx%amount% %item%<success>) naar de mailboxes van alle online spelers gestuurd."


hologram-create-error: "<error>Hologram &f%name% <error>bestaat al."
Expand Down