Skip to content

Commit

Permalink
Fix marry gift command
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgH93 committed Jun 8, 2022
1 parent 608d303 commit a827c4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
import at.pcgamingfreaks.Bukkit.ItemFilter;
import at.pcgamingfreaks.Bukkit.ItemNameResolver;
import at.pcgamingfreaks.Bukkit.Message.Message;
import at.pcgamingfreaks.Bukkit.Message.Placeholder.Processors.GameModePlaceholderProcessor;
import at.pcgamingfreaks.Bukkit.Message.Placeholder.Processors.ItemAmountPlaceholderProcessor;
import at.pcgamingfreaks.Bukkit.Message.Placeholder.Processors.ItemMetadataPlaceholderProcessor;
import at.pcgamingfreaks.Bukkit.Message.Placeholder.Processors.ItemNamePlaceholderProcessor;
import at.pcgamingfreaks.Bukkit.Message.Placeholder.Processors.*;
import at.pcgamingfreaks.Bukkit.Message.Placeholder.Processors.Wrappers.ItemStackWrapper;
import at.pcgamingfreaks.Bukkit.Util.InventoryUtils;
import at.pcgamingfreaks.MarriageMaster.Bukkit.API.AcceptPendingRequest;
Expand All @@ -35,6 +32,7 @@
import at.pcgamingfreaks.MarriageMaster.Bukkit.Range;
import at.pcgamingfreaks.MarriageMaster.Permissions;
import at.pcgamingfreaks.MarriageMaster.Placeholder.Placeholders;
import at.pcgamingfreaks.MarriageMaster.Placeholder.Processors.NamePlaceholderProcessor;
import at.pcgamingfreaks.Message.Placeholder.Placeholder;

import org.bukkit.Bukkit;
Expand Down Expand Up @@ -80,18 +78,19 @@ public GiftCommand(MarriageMaster plugin)
worldBlacklist = plugin.getConfiguration().getGiftBlackListedWorlds();
blacklistEnabled = !worldBlacklist.isEmpty();

final Placeholder itemNamePlaceholder = new Placeholder("ItemName", new ItemNamePlaceholderProcessor(itemNameResolver));
final Placeholder[] itemNamePlaceholder = { new Placeholder("ItemName", new ItemNamePlaceholderProcessor(itemNameResolver)),
new Placeholder("ItemDisplayName", new ItemDisplayNamePlaceholderProcessor(itemNameResolver)) };
final Placeholder currentGameModePlaceholder = new Placeholder("CurrentGameMode", new GameModePlaceholderProcessor()); // TODO translate
final Placeholder[] itemPlaceholders = { new Placeholder("ItemAmount", ItemAmountPlaceholderProcessor.INSTANCE),
itemNamePlaceholder,
itemNamePlaceholder[0], itemNamePlaceholder[1],
new Placeholder("ItemMetaJSON", new ItemMetadataPlaceholderProcessor(plugin.getLogger())) };

messageGameModeNotAllowedSender = plugin.getLanguage().getMessage("Ingame.Gift.GameModeNotAllowedSender").replaceAll("\\{AllowedGameModes}", currentGameModePlaceholder.getProcessor().process(allowedSendGameModes)).placeholders(currentGameModePlaceholder);
messageGameModeNotAllowedReceiver = plugin.getLanguage().getMessage("Ingame.Gift.GameModeNotAllowedReceiver").replaceAll("\\{AllowedGameModes}", currentGameModePlaceholder.getProcessor().process(allowedReceiveGameModes)).placeholders(currentGameModePlaceholder);
messageNoItemInHand = plugin.getLanguage().getMessage("Ingame.Gift.NoItemInHand");
messagePartnerInvFull = plugin.getLanguage().getMessage("Ingame.Gift.PartnerInvFull");
messageItemSent = plugin.getLanguage().getMessage("Ingame.Gift.ItemSent").placeholders(Placeholders.PLAYER_NAME).placeholders(itemPlaceholders);
messageItemReceived = plugin.getLanguage().getMessage("Ingame.Gift.ItemReceived").placeholders(Placeholders.PLAYER_NAME).placeholders(itemPlaceholders);
messageItemReceived = plugin.getLanguage().getMessage("Ingame.Gift.ItemReceived").placeholders(new Placeholder("Name", NamePlaceholderProcessor.INSTANCE), new Placeholder("DisplayName", NamePlaceholderProcessor.INSTANCE)).placeholders(itemPlaceholders);
messageWorldNotAllowed = plugin.getLanguage().getMessage("Ingame.Gift.WorldNotAllowed");
messageItemNotAllowed = plugin.getLanguage().getMessage("Ingame.Gift.ItemNotAllowed").placeholders(itemNamePlaceholder);

Expand Down Expand Up @@ -196,9 +195,9 @@ public void execute(@NotNull CommandSender sender, @NotNull String mainCommandAl
}
else
{
bPartner.getInventory().setItem(slot, its);
messageItemSent.send(sender, partner, wrappedItemStack);
messageItemReceived.send(bPartner, partner, wrappedItemStack);
bPartner.getInventory().setItem(slot, its);
}
InventoryUtils.setItemInMainHand(bPlayer, null);
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<packaging>pom</packaging>

<properties>
<revision>2.6</revision>
<revision>2.6.1</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<bukkitVersion>1.15.2-R0.1-SNAPSHOT</bukkitVersion>
Expand Down

0 comments on commit a827c4a

Please sign in to comment.