Now displays if a potion is extended

This commit is contained in:
Eric 2016-08-05 22:16:14 +02:00
parent 20badd36fb
commit d99f63a8e5
6 changed files with 30 additions and 6 deletions

View File

@ -17,7 +17,8 @@ public enum Regex {
POTION_EFFECT("%POTION-EFFECT%"),
MUSIC_TITLE("%MUSIC-TITLE%"),
PROPERTY("%PROPERTY%"),
VALUE("%VALUE%");
VALUE("%VALUE%"),
EXTENDED("%EXTENDED%");
private String name;

View File

@ -856,13 +856,14 @@ public class LanguageUtils {
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_PRODUCT, langConfig.getString("message.shopInfo.product", "&6Product: &e%AMOUNT% x %ITEMNAME%"), Regex.AMOUNT, Regex.ITEM_NAME));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_STOCK, langConfig.getString("message.shopInfo.stock", "&6In Stock: &e%AMOUNT%"), Regex.AMOUNT));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_ENCHANTMENTS, langConfig.getString("message.shopInfo.enchantments", "&6Enchantments: &e%ENCHANTMENT%"), Regex.ENCHANTMENT));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_POTION_EFFECT, langConfig.getString("message.shopInfo.potion-effect", "&6Potion Effect: &e%POTION-EFFECT%"), Regex.POTION_EFFECT));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_POTION_EFFECT, langConfig.getString("message.shopInfo.potion-effect", "&6Potion Effect: &e%POTION-EFFECT% %EXTENDED%"), Regex.POTION_EFFECT, Regex.EXTENDED));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_MUSIC_TITLE, langConfig.getString("message.shopInfo.music-disc-title", "&6Music Disc Title: &e%MUSIC-TITLE%"), Regex.MUSIC_TITLE));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_NONE, langConfig.getString("message.shopInfo.none", "&7None")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_PRICE, langConfig.getString("message.shopInfo.price", "&6Price: Buy: &e%BUY-PRICE%&6 Sell: &e%SELL-PRICE%"), Regex.BUY_PRICE, Regex.SELL_PRICE));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED, langConfig.getString("message.shopInfo.disabled", "&7Disabled")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_NORMAL, langConfig.getString("message.shopInfo.is-normal", "&6Type: &eNormal")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_ADMIN, langConfig.getString("message.shopInfo.is-admin", "&6Type: &eAdmin")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_EXTENDED, langConfig.getString("message.shopInfo.extended", "(Extended)")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.BUY_SELL_DISABLED, langConfig.getString("message.buy-and-sell-disabled", "&cYou can't create a shop with buying and selling disabled.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.BUY_SUCCESS, langConfig.getString("message.buy-success", "&aYou bought &6%AMOUNT% x %ITEMNAME%&a for &6%BUY-PRICE%&a from &6%VENDOR%&a."), Regex.AMOUNT, Regex.ITEM_NAME, Regex.BUY_PRICE, Regex.VENDOR));
messages.add(new LocalizedMessage(LocalizedMessage.Message.BUY_SUCESS_ADMIN, langConfig.getString("message.buy-success-admin", "&aYou bought &6%AMOUNT% x %ITEMNAME%&a for &6%BUY-PRICE%&a."), Regex.AMOUNT, Regex.ITEM_NAME, Regex.BUY_PRICE));

View File

@ -60,6 +60,7 @@ public class LocalizedMessage {
SHOP_INFO_DISABLED,
SHOP_INFO_NORMAL,
SHOP_INFO_ADMIN,
SHOP_INFO_EXTENDED,
BUY_SELL_DISABLED,
BUY_SUCCESS,
BUY_SUCESS_ADMIN,

View File

@ -35,6 +35,8 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.Potion;
import java.util.HashMap;
import java.util.Map;
@ -331,11 +333,16 @@ public class ShopInteractListener implements Listener {
String shopType = LanguageUtils.getMessage(shop.getShopType() == ShopType.NORMAL ? LocalizedMessage.Message.SHOP_INFO_NORMAL : LocalizedMessage.Message.SHOP_INFO_ADMIN);
String stock = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_STOCK, new LocalizedMessage.ReplacedRegex(Regex.AMOUNT, String.valueOf(amount)));
boolean potionExtended = false;
Map<Enchantment, Integer> enchantmentMap;
if (Utils.getMajorVersion() >= 9) {
if (type == Material.TIPPED_ARROW || type == Material.LINGERING_POTION || type == Material.SPLASH_POTION) {
potionEffectString = LanguageUtils.getPotionEffectName(shop.getProduct());
PotionMeta potionMeta = (PotionMeta) shop.getProduct().getItemMeta();
potionExtended = potionMeta.getBasePotionData().isExtended();
if (potionEffectString == null)
potionEffectString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_NONE);
}
@ -343,6 +350,14 @@ public class ShopInteractListener implements Listener {
if (type == Material.POTION) {
potionEffectString = LanguageUtils.getPotionEffectName(shop.getProduct());
if (Utils.getMajorVersion() < 9) {
Potion potion = Potion.fromItemStack(shop.getProduct());
potionExtended = potion.hasExtendedDuration();
} else {
PotionMeta potionMeta = (PotionMeta) shop.getProduct().getItemMeta();
potionExtended = potionMeta.getBasePotionData().isExtended();
}
if (potionEffectString == null)
potionEffectString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_NONE);
}
@ -374,7 +389,8 @@ public class ShopInteractListener implements Listener {
if (enchantmentString.length() > 0)
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_ENCHANTMENTS, new LocalizedMessage.ReplacedRegex(Regex.ENCHANTMENT, enchantmentString)));
if (potionEffectString.length() > 0)
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_POTION_EFFECT, new LocalizedMessage.ReplacedRegex(Regex.POTION_EFFECT, potionEffectString)));
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_POTION_EFFECT, new LocalizedMessage.ReplacedRegex(Regex.POTION_EFFECT, potionEffectString),
new LocalizedMessage.ReplacedRegex(Regex.EXTENDED, (potionExtended ? LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_EXTENDED) : ""))));
if (musicDiscName.length() > 0)
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_MUSIC_TITLE, new LocalizedMessage.ReplacedRegex(Regex.MUSIC_TITLE, musicDiscName)));
executor.sendMessage(price);

View File

@ -9,13 +9,14 @@ message.shopInfo.vendor=&6Verkäufer: &e%VENDOR%
message.shopInfo.product=&6Produkt: &e%AMOUNT% x %ITEMNAME%
message.shopInfo.stock=&6Auf Lager: &e%AMOUNT%
message.shopInfo.enchantments=&6Verzauberungen: &e%ENCHANTMENT%
message.shopInfo.potion-effect=&6Trank-Effekte: &e%POTION-EFFECT%
message.shopInfo.potion-effect=&6Trank-Effekte: &e%POTION-EFFECT% %EXTENDED%
message.shopInfo.music-disc-title=&6Schallplattentitel: &e%MUSIC-TITLE%
message.shopInfo.none=&7Keine
message.shopInfo.price=&6Preis: Kauf: &e%BUY-PRICE%&6 Verkauf: &e%SELL-PRICE%
message.shopInfo.disabled=&7Deaktiviert
message.shopInfo.is-normal=&6Typ: &eNormal
message.shopInfo.is-admin=&6Typ: &eAdmin
message.shopInfo.extended=(Verlängert)
message.buy-and-sell-disabled=&cDu kannst keinen Shop ohne Kauf- und Verkaufspreis erstellen.
message.buy-success=&aDu hast &6%AMOUNT% x %ITEMNAME%&a für &6%BUY-PRICE%&a von &6%VENDOR% &agekauft.
message.buy-success-admin=&aDu hast &6%AMOUNT% x %ITEMNAME%&a für &6%BUY-PRICE% &agekauft.

View File

@ -38,8 +38,8 @@ message.shopInfo.stock=&6In Stock: &e%AMOUNT%
message.shopInfo.enchantments=&6Enchantments: &e%ENCHANTMENT%
# Set the potion effect message the player gets after entering '/shop info' if the product has a potion effect
# Usable regex: %POTION-EFFECT%
message.shopInfo.potion-effect=&6Potion Effect: &e%POTION-EFFECT%
# Usable regex: %POTION-EFFECT%, %EXTENDED%
message.shopInfo.potion-effect=&6Potion Effect: &e%POTION-EFFECT% %EXTENDED%
# Set the music disc title message the player gets after entering '/shop info' if the product is a music disc
# Usable regex: %MUSIC-TITLE%
@ -62,6 +62,10 @@ message.shopInfo.is-normal=&6Type: &eNormal
# ... when the shop is an admin shop.
message.shopInfo.is-admin=&6Type: &eAdmin
# If the potion effect it extended, %EXTENDED% will be replaced by this.
# If not, this will be empty.
message.shopInfo.extended=(Extended)
# Set the message when the player tries to create a shop with sell price and buy price set to 0
message.buy-and-sell-disabled=&cYou can't create a shop with buying and selling disabled.