Added way to show prices in hologram below each other

This commit is contained in:
Eric 2016-08-09 22:10:44 +02:00
parent be17d366d9
commit 5a975661eb
4 changed files with 39 additions and 8 deletions

View File

@ -82,6 +82,9 @@ public class Config {
/** Whether admin shops should be excluded of the shop limits **/
public boolean exclude_admin_shops;
/** Whether the buy- and sell price should be arranged below each other **/
public boolean two_line_prices;
/** Whether the extension of a potion or tipped arrow (if available) should be appended to the item name. **/
public boolean append_potion_level_to_item_name;
@ -97,6 +100,9 @@ public class Config {
*/
public boolean remove_shop_on_error;
/** Amount the hologram should be lifted **/
public double hologram_lift;
/** The maximum distance between a player and a shop to see the hologram **/
public double maximal_distance;
@ -271,12 +277,14 @@ public class Config {
blacklist = (plugin.getConfig().getStringList("blacklist") == null) ? new ArrayList<String>() : plugin.getConfig().getStringList("blacklist");
buy_greater_or_equal_sell = plugin.getConfig().getBoolean("buy-greater-or-equal-sell");
hopper_protection = plugin.getConfig().getBoolean("hopper-protection");
two_line_prices = plugin.getConfig().getBoolean("two-line-prices");
enable_debug_log = plugin.getConfig().getBoolean("enable-debug-log");
explosion_protection = plugin.getConfig().getBoolean("explosion-protection");
exclude_admin_shops = plugin.getConfig().getBoolean("shop-limits.exclude-admin-shops");
append_potion_level_to_item_name = plugin.getConfig().getBoolean("append-potion-level-to-item-name");
show_shop_items = plugin.getConfig().getBoolean("show-shop-items");
remove_shop_on_error = plugin.getConfig().getBoolean("remove-shop-on-error");
hologram_lift = plugin.getConfig().getDouble("hologram-lift");
maximal_distance = plugin.getConfig().getDouble("maximal-distance");
shop_creation_price_normal = plugin.getConfig().getDouble("shop-creation-price.normal");
shop_creation_price_admin = plugin.getConfig().getDouble("shop-creation-price.admin");

View File

@ -49,6 +49,9 @@ public class Hologram {
private void create() {
for (String text : this.text) {
if (text == null)
continue;
try {
Object craftWorld = this.location.getWorld().getClass().cast(this.location.getWorld());
Object nmsWorld = nmsWorldClass.cast(craftWorld.getClass().getMethod("getHandle").invoke(craftWorld));

View File

@ -156,7 +156,7 @@ public class Shop {
}
Location holoLocation;
String[] holoText = new String[2];
String[] holoText = new String[plugin.getShopChestConfig().two_line_prices ? 3 : 2];
if (doubleChest) {
@ -183,18 +183,25 @@ public class Shop {
} else holoLocation = new Location(b.getWorld(), b.getX() + 0.5, b.getY() - 0.6, b.getZ() + 0.5);
if (holoText.length == 3)
holoLocation.add(0, plugin.getShopChestConfig().hologram_lift, 0);
holoText[0] = LanguageUtils.getMessage(LocalizedMessage.Message.HOLOGRAM_FORMAT, new LocalizedMessage.ReplacedRegex(Regex.AMOUNT, String.valueOf(product.getAmount())),
new LocalizedMessage.ReplacedRegex(Regex.ITEM_NAME, LanguageUtils.getItemName(product)));
if ((buyPrice <= 0) && (sellPrice > 0))
if ((buyPrice <= 0) && (sellPrice > 0)) {
holoText[1] = LanguageUtils.getMessage(LocalizedMessage.Message.HOLOGRAM_SELL, new LocalizedMessage.ReplacedRegex(Regex.SELL_PRICE, String.valueOf(sellPrice)));
else if ((buyPrice > 0) && (sellPrice <= 0))
} else if ((buyPrice > 0) && (sellPrice <= 0)) {
holoText[1] = LanguageUtils.getMessage(LocalizedMessage.Message.HOLOGRAM_BUY, new LocalizedMessage.ReplacedRegex(Regex.BUY_PRICE, String.valueOf(buyPrice)));
else if ((buyPrice > 0) && (sellPrice > 0))
holoText[1] = LanguageUtils.getMessage(LocalizedMessage.Message.HOLOGRAM_BUY_SELL, new LocalizedMessage.ReplacedRegex(Regex.BUY_PRICE, String.valueOf(buyPrice)),
new LocalizedMessage.ReplacedRegex(Regex.SELL_PRICE, String.valueOf(sellPrice)));
else holoText[1] = LanguageUtils.getMessage(LocalizedMessage.Message.HOLOGRAM_BUY_SELL, new LocalizedMessage.ReplacedRegex(Regex.BUY_PRICE, String.valueOf(buyPrice)),
new LocalizedMessage.ReplacedRegex(Regex.SELL_PRICE, String.valueOf(sellPrice)));
} else {
if (holoText.length == 2) {
holoText[1] = LanguageUtils.getMessage(LocalizedMessage.Message.HOLOGRAM_BUY_SELL, new LocalizedMessage.ReplacedRegex(Regex.BUY_PRICE, String.valueOf(buyPrice)),
new LocalizedMessage.ReplacedRegex(Regex.SELL_PRICE, String.valueOf(sellPrice)));
} else {
holoText[1] = LanguageUtils.getMessage(LocalizedMessage.Message.HOLOGRAM_BUY, new LocalizedMessage.ReplacedRegex(Regex.BUY_PRICE, String.valueOf(buyPrice)));
holoText[2] = LanguageUtils.getMessage(LocalizedMessage.Message.HOLOGRAM_SELL, new LocalizedMessage.ReplacedRegex(Regex.SELL_PRICE, String.valueOf(sellPrice)));
}
}
hologram = new Hologram(plugin, holoText, holoLocation);
}

View File

@ -18,6 +18,19 @@ show-shop-items: true
# The file may get large! Please enable this setting when reporting bugs.
enable-debug-log: false
# Set whether the buy- and sell price should be arranged below each other.
# The first line will be the buy price with the message "message.hologram.only-buy",
# the second line will be the sell price with the message "message.hologram.only-sell".
# If buying or selling is disabled, a line for that price will not be created.
# (The messages can be found and modified in the specified language file)
two-line-prices: false
# Set the amount (may be negative) the hologram should be lifted
# in the y-axis (a higher number lifts the hologram more up, '1' equals to one block).
# It's recommended to change the value (to around 0.2) if "two-line-prices" is set to true, to prevent
# the floating item to intersect with the hologram.
hologram-lift: 0
# Set whether players should be allowed to sell/buy broken items
allow-broken-items: false