Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to change pumpkin item name and lore #999

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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 @@ -460,6 +460,9 @@ public class Messages {
public static final String SHOP_CONTENT_TIER_ITEM_LORE = SHOP_PATH + ".%category%.content-item-%content%-lore";
public static final String SHOP_CAN_BUY_COLOR = SHOP_PATH + ".can-buy-color";
public static final String SHOP_CANT_BUY_COLOR = SHOP_PATH + ".cant-buy-color";
public static final String SHOP_CATEGORY_PUMPKIN_NAME = SHOP_PATH + ".blocks-category.content-item-pumpkin-name";

public static final String SHOP_CATEGORY_PUMPKIN_LORE = SHOP_PATH + ".blocks-category.content-item-pumpkin-lore";

/* MultiArena Lobby Item Messages */
public static final String GENERAL_CONFIGURATION_LOBBY_ITEMS_NAME = ConfigPath.GENERAL_CONFIGURATION_LOBBY_ITEMS_PATH + "-%path%-name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public MainConfig(Plugin plugin, String name) {

yml.options().header(plugin.getDescription().getName() + " by andrei1058. https://www.spigotmc.org/members/39904/\n" +
"Documentation here: https://gitlab.com/andrei1058/BedWars1058/wikis/home\n");
yml.addDefault("timeZone", "Europe/Rome");
yml.addDefault("serverType", "MULTIARENA");
yml.addDefault("language", "en");
yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_DISABLED_LANGUAGES, Collections.singletonList("your language iso here"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
import java.time.ZoneId;
import java.util.Date;

import static com.andrei1058.bedwars.BedWars.config;

public class HalloweenSpecial {

private static HalloweenSpecial INSTANCE;

private HalloweenSpecial() {
BedWars.plugin.getLogger().info(ChatColor.AQUA + "Loaded Halloween Special <3");
BedWars.plugin.getLogger().info(ChatColor.AQUA + "Loaded Halloween Special");
// pumpkin hats
Bukkit.getPluginManager().registerEvents(new HalloweenListener(), BedWars.plugin);

Expand All @@ -56,7 +58,7 @@ private HalloweenSpecial() {
* Initialize Halloween Special.
*/
public static void init() {
var enable = BedWars.config.getBoolean(ConfigPath.GENERAL_CONFIGURATION_ENABLE_HALLOWEEN);
var enable = config.getBoolean(ConfigPath.GENERAL_CONFIGURATION_ENABLE_HALLOWEEN);
if (enable) {
if (INSTANCE == null && checkAvailabilityDate()) {
//noinspection InstantiationOfUtilityClass
Expand All @@ -68,7 +70,7 @@ public static void init() {

protected static boolean checkAvailabilityDate() {
// check date
ZoneId zone = ZoneId.of("Europe/Rome");
ZoneId zone = ZoneId.of(config.getString("timeZone"));
Date date = new Date();
LocalDate localDate = date.toInstant().atZone(zone).toLocalDate();
int month = localDate.getMonthValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@
import com.andrei1058.bedwars.api.arena.IArena;
import com.andrei1058.bedwars.api.arena.shop.IBuyItem;
import com.andrei1058.bedwars.api.arena.shop.IContentTier;
import com.andrei1058.bedwars.api.language.Language;
import com.andrei1058.bedwars.api.language.Messages;
import com.andrei1058.bedwars.shop.ShopCache;
import com.andrei1058.bedwars.shop.main.CategoryContent;
import com.andrei1058.bedwars.shop.main.ShopCategory;
import com.andrei1058.bedwars.shop.quickbuy.PlayerQuickBuyCache;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -102,7 +105,10 @@ public ItemStack getItemStack(Player player) {
ItemStack pumpkin = tier.getItemStack();

boolean canAfford = calculateMoney(player, tier.getCurrency()) >= tier.getPrice();
String color = getMsg(player, canAfford ? Messages.SHOP_CAN_BUY_COLOR : Messages.SHOP_CANT_BUY_COLOR);
String translatedCurrency = getMsg(player, getCurrencyMsgPath(tier));
PlayerQuickBuyCache qbc = PlayerQuickBuyCache.getQuickBuyCache(player.getUniqueId());
boolean hasQuick = qbc != null && hasQuick(qbc);

String buyStatus;

Expand All @@ -113,10 +119,24 @@ public ItemStack getItemStack(Player player) {
}
ChatColor cColor = getCurrencyColor(tier.getCurrency());

List<String> lore = new ArrayList<>();
for (String s : Language.getList(player, Messages.SHOP_CATEGORY_PUMPKIN_LORE)) {
if (s.contains("{quick_buy}")) {
if (hasQuick) {
s = getMsg(player, Messages.SHOP_LORE_QUICK_REMOVE);
} else {
s = getMsg(player, Messages.SHOP_LORE_QUICK_ADD);
}
}
s = s.replace("{color}", color).replace("{cost}", cColor + String.valueOf(tier.getPrice()))
.replace("{currency}", cColor + translatedCurrency).replace("{buy_status}", buyStatus);
lore.add(s);
}

pumpkin.setAmount(12);
ItemMeta itemMeta = pumpkin.getItemMeta();
itemMeta.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "Happy Halloween!");
itemMeta.setLore(Arrays.asList("", cColor + String.valueOf(tier.getPrice()) + " " + cColor + translatedCurrency, " ", buyStatus));
itemMeta.setDisplayName(getMsg(player, Messages.SHOP_CATEGORY_PUMPKIN_NAME).replace("{color}", color));
itemMeta.setLore(lore);
pumpkin.setItemMeta(itemMeta);
return pumpkin;
}
Expand Down Expand Up @@ -183,6 +203,7 @@ public boolean isLoaded() {

@Override
public void give(Player player, IArena arena) {
player.sendMessage(getMsg(player, Messages.SHOP_NEW_PURCHASE).replace("{item}", getMsg(player, Messages.SHOP_CATEGORY_PUMPKIN_NAME).replace("{color}", "")));
player.getInventory().addItem(new ItemStack(Material.PUMPKIN, 12));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,8 @@ public Bangla() {
yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aMAXED!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&7Quick Buy te add korte &bSneal Click &7korun");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&7Quick Buy theke remove korte &bSneak Click &7korun!");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));


addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Blocks", "&aBlocks", Collections.singletonList("&eClick to view!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,8 @@ public English() {
yml.addDefault(Messages.SHOP_LORE_STATUS_ARMOR, "&aEQUIPPED!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bSneak Click to add to Quick Buy");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bSneak Click to remove from Quick Buy!");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));


addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Blocks", "&aBlocks", Collections.singletonList("&eClick to view!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,8 @@ public Hindi() {
yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aMAXED!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&7Quick Buy pe add karne ke liye &bSneak Click &7kare");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&7Quick Buy se remove karne ke liye &bSneak Click &7kare");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));


addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Blocks", "&aBlocks", Collections.singletonList("&eClick to view!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,8 @@ public Indonesia() {
yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aMAKSIMAL!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bJongkok Klik untuk menambahkan ke Beli Cepat!");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bJongkok Klik untuk menhapus dari Beli Cepat!");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));


addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Blok", "&aBlok", Collections.singletonList("&eKlik untuk melihat!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,8 @@ public Italian() {
yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aMAXED!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bShift Click per aggiungere al Quick Buy");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bShift Click per rimuovere dal Quick Buy!");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));

addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Blocchi", "&aBlocchi", Collections.singletonList("&eClicca per sfogliare!"));
addContentMessages(yml, "wool", ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "{color}Lana", Arrays.asList("&7Costo: &f{cost} {currency}", "", "&7Buono per costruire ponti tra", "&7le isole. Prende il colore", "&7del tuo team.", "", "{quick_buy}", "{buy_status}"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,8 @@ public Persian() {
yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aAKHARIN LEVEL!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bBaraye ezafe kardan be Kharid Sari SNEAK Click konid");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bBaraye hazf az Kharid Sari SNEAK Click konid!");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));


addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Block Ha", "&aBlock Ha", Collections.singletonList("&eBaraye moshahede Click konid!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,8 @@ public Polish() {
yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aMAX!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bKucnij &7by dodać do szybkiego kupowania");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bKucnij &7by usunąć z szybkiego kupowania");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));


addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Bloki", "&aBloki", Collections.singletonList("&eKliknij aby przegladac!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,8 @@ public Portuguese() {
yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aMÁXIMO!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bClique + shift para por na Compra Rápida");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bClique + shift para tirar da Compra Rápida");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));


addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Blocos", "&aBlocos", Collections.singletonList("&eClique para ver!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,8 @@ public Romanian() {
yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aNIVEL MAXIM!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bShift Click pentru Shop Rapid");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bShift Click pentru a șterge din Shop Rapid!");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));


addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Blocuri", "&aBlocuri", Collections.singletonList("&eClick pentru a afișa!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,8 @@ public Russian() {
yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aМАКСИМАЛЬНО!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bШифт-клик для добавления в быструю покупку");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bШифт-клик для удаления из быстрой покупки!");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));


addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Блоки", "&aБлоки", Collections.singletonList("&eНажмите для просмотра!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,8 @@ public SimplifiedChinese() {
yml.addDefault(Messages.SHOP_LORE_STATUS_ARMOR, "&a已装备!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bShift+点击 来添加快速购买");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bShift+点击 来从快速购买中移除!");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));


addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8方块", "&a方块", Collections.singletonList("&e点击查看!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,8 @@ public Spanish() {
yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aMAXIMIZADO!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bHaga shift + click para agregar a la compra rapida!");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bHaga shift + click para remover de la compra rapida!");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));


addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Bloques", "&aBloques", Collections.singletonList("&eClick para ver!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,8 @@ public Turkish() {
yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aEN YÜKSEK SEVİYEDE!");
yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bHızlı Alıma eklemek için eğilerek tıkla");
yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bHızlı Alımdan kaldırmak için eğilerek tıkla");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_NAME, "{color}Happy Halloween");
yml.addDefault(Messages.SHOP_CATEGORY_PUMPKIN_LORE, Arrays.asList("&7Cost: &f{cost} {currency}", "", "{quick_buy}", "{buy_status}"));


addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Bloklar", "&aBloklar", Collections.singletonList("&eGörmek için tıkla!"));
Expand Down
Loading