translation options

This commit is contained in:
Kiran Hart 2021-03-31 18:13:02 -04:00
parent fd48219c03
commit 02b66a0c24
5 changed files with 67 additions and 8 deletions

View File

@ -1,5 +1,6 @@
package ca.tweetzy.auctionhouse.api;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.auction.AuctionItem;
import ca.tweetzy.auctionhouse.auction.AuctionSaleType;
import ca.tweetzy.auctionhouse.settings.Settings;
@ -200,12 +201,12 @@ public class AuctionAPI {
hook.addEmbed(new DiscordWebhook.EmbedObject()
.setTitle(isNew ? Settings.DISCORD_MSG_START_TITLE.getString() : Settings.DISCORD_MSG_FINISH_TITLE.getString())
.setColor(colour)
.addField(Settings.DISCORD_MSG_FIELD_SELLER_NAME.getString(), Settings.DISCORD_MSG_FIELD_SELLER_VALUE.getString().replace("%seller%", seller.getName() != null ? seller.getName() : "Player Lost o.O"), Settings.DISCORD_MSG_FIELD_SELLER_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_BUYER_NAME.getString(), isNew ? "No Buyer" : Settings.DISCORD_MSG_FIELD_BUYER_VALUE.getString().replace("%buyer%", buyer.getName() != null ? buyer.getName() : "Player Lost o.O"), Settings.DISCORD_MSG_FIELD_BUYER_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_SELLER_NAME.getString(), Settings.DISCORD_MSG_FIELD_SELLER_VALUE.getString().replace("%seller%", seller.getName() != null ? seller.getName() : AuctionHouse.getInstance().getLocale().getMessage("discord.player_lost").getMessage()), Settings.DISCORD_MSG_FIELD_SELLER_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_BUYER_NAME.getString(), isNew ? AuctionHouse.getInstance().getLocale().getMessage("discord.no_buyer").getMessage() : Settings.DISCORD_MSG_FIELD_BUYER_VALUE.getString().replace("%buyer%", buyer.getName() != null ? buyer.getName() : AuctionHouse.getInstance().getLocale().getMessage("discord.player_lost").getMessage()), Settings.DISCORD_MSG_FIELD_BUYER_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_BUY_NOW_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_BUY_NOW_PRICE_VALUE.getString().replace("%buy_now_price%", this.getFriendlyNumber(auctionItem.getBasePrice())), Settings.DISCORD_MSG_FIELD_BUY_NOW_PRICE_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_FINAL_PRICE_NAME.getString(), isNew ? "Not Sold" : Settings.DISCORD_MSG_FIELD_FINAL_PRICE_VALUE.getString().replace("%final_price%", this.getFriendlyNumber(isBid ? auctionItem.getCurrentPrice() : auctionItem.getBasePrice())), Settings.DISCORD_MSG_FIELD_FINAL_PRICE_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_IS_BID_NAME.getString(), Settings.DISCORD_MSG_FIELD_IS_BID_VALUE.getString().replace("%is_bid%", String.valueOf(isBid)), Settings.DISCORD_MSG_FIELD_IS_BID_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_PURCHASE_TYPE_NAME.getString(), isNew ? "Was not bought" : Settings.DISCORD_MSG_FIELD_PURCHASE_TYPE_VALUE.getString().replace("%purchase_type%", saleType == AuctionSaleType.USED_BIDDING_SYSTEM ? "Won Bid" : "Bought Immediately"), Settings.DISCORD_MSG_FIELD_PURCHASE_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_FINAL_PRICE_NAME.getString(), isNew ? AuctionHouse.getInstance().getLocale().getMessage("discord.not_sold").getMessage() : Settings.DISCORD_MSG_FIELD_FINAL_PRICE_VALUE.getString().replace("%final_price%", this.getFriendlyNumber(isBid ? auctionItem.getCurrentPrice() : auctionItem.getBasePrice())), Settings.DISCORD_MSG_FIELD_FINAL_PRICE_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_IS_BID_NAME.getString(), Settings.DISCORD_MSG_FIELD_IS_BID_VALUE.getString().replace("%is_bid%", isBid ? AuctionHouse.getInstance().getLocale().getMessage("discord.is_bid_true").getMessage() : AuctionHouse.getInstance().getLocale().getMessage("discord.is_bid_false").getMessage()), Settings.DISCORD_MSG_FIELD_IS_BID_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_PURCHASE_TYPE_NAME.getString(), isNew ? AuctionHouse.getInstance().getLocale().getMessage("discord.not_bought").getMessage() : Settings.DISCORD_MSG_FIELD_PURCHASE_TYPE_VALUE.getString().replace("%purchase_type%", saleType == AuctionSaleType.USED_BIDDING_SYSTEM ? AuctionHouse.getInstance().getLocale().getMessage("discord.sale_bid_win").getMessage() : AuctionHouse.getInstance().getLocale().getMessage("discord.sale_immediate_buy").getMessage()), Settings.DISCORD_MSG_FIELD_PURCHASE_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_ITEM_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_VALUE.getString().replace("%item_name%", auctionItem.getItemName()), Settings.DISCORD_MSG_FIELD_ITEM_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_VALUE.getString().replace("%item_amount%", String.valueOf(this.deserializeItem(auctionItem.getRawItem()).getAmount())), Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_INLINE.getBoolean())
);

View File

@ -1,5 +1,7 @@
package ca.tweetzy.auctionhouse.auction;
import ca.tweetzy.auctionhouse.AuctionHouse;
/**
* The current file has been created by Kiran Hart
* Date Created: February 01 2021
@ -26,6 +28,24 @@ public enum AuctionItemCategory {
return type;
}
public String getTranslatedType() {
switch (this) {
case ALL:
return AuctionHouse.getInstance().getLocale().getMessage("auction_filter.categories.all").getMessage();
case FOOD:
return AuctionHouse.getInstance().getLocale().getMessage("auction_filter.categories.food").getMessage();
case ARMOR:
return AuctionHouse.getInstance().getLocale().getMessage("auction_filter.categories.armor").getMessage();
case BLOCKS:
return AuctionHouse.getInstance().getLocale().getMessage("auction_filter.categories.blocks").getMessage();
case TOOLS:
return AuctionHouse.getInstance().getLocale().getMessage("auction_filter.categories.tools").getMessage();
case MISC:
return AuctionHouse.getInstance().getLocale().getMessage("auction_filter.categories.misc").getMessage();
}
return getType();
}
public AuctionItemCategory next() {
return values()[(this.ordinal() + 1) % values().length];
}

View File

@ -1,5 +1,7 @@
package ca.tweetzy.auctionhouse.auction;
import ca.tweetzy.auctionhouse.AuctionHouse;
/**
* The current file has been created by Kiran Hart
* Date Created: January 17 2021
@ -22,6 +24,19 @@ public enum AuctionSaleType {
public String getType() {
return type;
}
public String getTranslatedType() {
switch (this) {
case USED_BIDDING_SYSTEM:
return AuctionHouse.getInstance().getLocale().getMessage("auction_filter.sale_types.biddable").getMessage();
case WITHOUT_BIDDING_SYSTEM:
return AuctionHouse.getInstance().getLocale().getMessage("auction_filter.sale_types.non_biddable").getMessage();
case BOTH:
return AuctionHouse.getInstance().getLocale().getMessage("auction_filter.sale_types.both").getMessage();
}
return getType();
}
public AuctionSaleType next() {
return values()[(this.ordinal() + 1) % values().length];
}

View File

@ -51,7 +51,7 @@ public class GUIAuctionHouse extends Gui {
public GUIAuctionHouse(AuctionPlayer auctionPlayer, String phrase) {
this(auctionPlayer);
// re-fetch the auction items since we wanna filter out any items that match the phrase
this.items = this.items.stream().filter(auctionItem -> AuctionAPI.getInstance().match(phrase, ChatColor.stripColor(auctionItem.getItemName())) || AuctionAPI.getInstance().match(phrase, auctionItem.getCategory().getType()) || AuctionAPI.getInstance().match(phrase, Bukkit.getOfflinePlayer(auctionItem.getOwner()).getName())).collect(Collectors.toList());
this.items = this.items.stream().filter(auctionItem -> AuctionAPI.getInstance().match(phrase, ChatColor.stripColor(auctionItem.getItemName())) || AuctionAPI.getInstance().match(phrase, auctionItem.getCategory().getType()) || AuctionAPI.getInstance().match(phrase, auctionItem.getCategory().getTranslatedType()) || AuctionAPI.getInstance().match(phrase, Bukkit.getOfflinePlayer(auctionItem.getOwner()).getName())).collect(Collectors.toList());
}
public GUIAuctionHouse(AuctionPlayer auctionPlayer, AuctionItemCategory filterCategory, AuctionSaleType filterAuctionType) {
@ -98,8 +98,8 @@ public class GUIAuctionHouse extends Gui {
});
setButton(5, 2, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_LORE.getStringList(), new HashMap<String, Object>() {{
put("%filter_category%", filterCategory.getType());
put("%filter_auction_type%", filterAuctionType.getType());
put("%filter_category%", filterCategory.getTranslatedType());
put("%filter_auction_type%", filterAuctionType.getTranslatedType());
}}), e -> {
switch (e.clickType) {
case LEFT:

View File

@ -20,6 +20,29 @@ pricing:
moneyremove: "&c&l- $%price%"
moneyadd: "&a&l+ $%price%"
discord:
player_lost: "Player Lost o.O"
no_buyer: "No Buyer"
not_sold: "Not Sold"
not_bought: "Was not bought"
sale_bid_win: "Won Bid"
sale_immediate_buy: "Bought Immediately"
is_bid_true: "true"
is_bid_false: "false"
auction_filter:
sale_types:
biddable: "Biddable"
non_biddable: "Not Biddable"
both: "All"
categories:
all: "All"
food: "Food"
armor: "Armor"
blocks: "Blocks"
tools: "Tools"
misc: "Misc"
auction:
listed:
withbid: "&eListed &fx%amount% &6%item% &e&lBuy Now&f: &a%base_price% &e&lStarting&f: &a%start_price% &e&lIncrement&f: &a%increment_price%"