erikzimmermann / TradeSystem

A highly customizable, free and open-source Minecraft plugin for trading between players.
https://www.spigotmc.org/resources/trade-system-custom-layouts.58434/
MIT License
76 stars 48 forks source link

%player% placeholder doesn't exist in some messages #534

Open MissingReports opened 2 months ago

MissingReports commented 2 months ago

Is your feature request related to a problem? Please describe. I'm sure it is, when filling up 'Trade_Was_Cancelled' and 'Items_Dropped' and 'Trade_Was_Finished' you can't get the player that you were trading with using %player% because %player% doesn't in these messages.

Describe the solution you'd like %player% is supposed to be giving the opposite player, I've forked TradeSystem and solved the issue in Trade.class replace getPlaceholderMessage with

@NotNull
protected String getPlaceholderMessage(@NotNull Perspective perspective, @NotNull String message) {
    try {
        return Lang.get(message, getPlayerOpt(perspective).orElse(getPlayer(Perspective.PRIMARY)),
            new Lang.P("player", getPlayerOpt(perspective.flip()).orElse(null).getName()));
    } catch (NullPointerException ex) {
        return Lang.get(message, getPlayerOpt(perspective).orElse(getPlayer(Perspective.PRIMARY)));
    }
}

Additional context Let's say you made Trade_Was_Finished to be &6Trade completed with &e%player%&6! and you were trading with a player named Bob, it's supposed to send &6Trade completed with &eBob&6!, however it sends &6Trade completed with &e%player%&6!

Discord contact: missingreports