Added refund to "Shop removed" message

+ Fixed refund option being ignored
This commit is contained in:
Eric 2019-06-03 16:53:23 +02:00
parent 9646bd0318
commit e6393ecd6c
8 changed files with 38 additions and 12 deletions

View File

@ -2177,6 +2177,7 @@ public class LanguageUtils {
messages.add(new LocalizedMessage(Message.CHEST_BLOCKED, langConfig.getString("message.chest-blocked", "&cThere must not be a block above the chest."))); messages.add(new LocalizedMessage(Message.CHEST_BLOCKED, langConfig.getString("message.chest-blocked", "&cThere must not be a block above the chest.")));
messages.add(new LocalizedMessage(Message.DOUBLE_CHEST_BLOCKED, langConfig.getString("message.double-chest-blocked", "&cThere must not be a block above the chest."))); messages.add(new LocalizedMessage(Message.DOUBLE_CHEST_BLOCKED, langConfig.getString("message.double-chest-blocked", "&cThere must not be a block above the chest.")));
messages.add(new LocalizedMessage(Message.SHOP_REMOVED, langConfig.getString("message.shop-removed", "&6Shop removed."))); messages.add(new LocalizedMessage(Message.SHOP_REMOVED, langConfig.getString("message.shop-removed", "&6Shop removed.")));
messages.add(new LocalizedMessage(Message.SHOP_REMOVED_REFUND, langConfig.getString("message.shop-removed-refund", "&6Shop removed. You were refunded &c%CREATION-PRICE%&6.")));
messages.add(new LocalizedMessage(Message.ALL_SHOPS_REMOVED, langConfig.getString("message.all-shops-removed", "&6Removed all (&c%AMOUNT%&6) shop/s of &c%VENDOR%&6."))); messages.add(new LocalizedMessage(Message.ALL_SHOPS_REMOVED, langConfig.getString("message.all-shops-removed", "&6Removed all (&c%AMOUNT%&6) shop/s of &c%VENDOR%&6.")));
messages.add(new LocalizedMessage(Message.CHEST_NO_SHOP, langConfig.getString("message.chest-no-shop", "&cChest is not a shop."))); messages.add(new LocalizedMessage(Message.CHEST_NO_SHOP, langConfig.getString("message.chest-no-shop", "&cChest is not a shop.")));
messages.add(new LocalizedMessage(Message.SHOP_CREATE_NOT_ENOUGH_MONEY, langConfig.getString("message.shop-create-not-enough-money", "&cNot enough money. You need &6%CREATION-PRICE% &cto create a shop."))); messages.add(new LocalizedMessage(Message.SHOP_CREATE_NOT_ENOUGH_MONEY, langConfig.getString("message.shop-create-not-enough-money", "&cNot enough money. You need &6%CREATION-PRICE% &cto create a shop.")));

View File

@ -7,6 +7,7 @@ public enum Message {
CHEST_BLOCKED, CHEST_BLOCKED,
DOUBLE_CHEST_BLOCKED, DOUBLE_CHEST_BLOCKED,
SHOP_REMOVED, SHOP_REMOVED,
SHOP_REMOVED_REFUND,
ALL_SHOPS_REMOVED, ALL_SHOPS_REMOVED,
CHEST_NO_SHOP, CHEST_NO_SHOP,
SHOP_CREATE_NOT_ENOUGH_MONEY, SHOP_CREATE_NOT_ENOUGH_MONEY,

View File

@ -64,19 +64,25 @@ public class ChestProtectListener implements Listener {
} }
}); });
} else { } else {
if (p.getUniqueId().equals(shop.getVendor().getUniqueId())) {
double creationPrice = shop.getShopType() == ShopType.ADMIN ? Config.shopCreationPriceAdmin : Config.shopCreationPriceNormal; double creationPrice = shop.getShopType() == ShopType.ADMIN ? Config.shopCreationPriceAdmin : Config.shopCreationPriceNormal;
if (creationPrice > 0 && Config.refundShopCreation && p.getUniqueId().equals(shop.getVendor().getUniqueId())) {
EconomyResponse r = plugin.getEconomy().depositPlayer(p, shop.getLocation().getWorld().getName(), creationPrice); EconomyResponse r = plugin.getEconomy().depositPlayer(p, shop.getLocation().getWorld().getName(), creationPrice);
if (!r.transactionSuccess()) { if (!r.transactionSuccess()) {
plugin.debug("Economy transaction failed: " + r.errorMessage); plugin.debug("Economy transaction failed: " + r.errorMessage);
p.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED, p.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED,
new Replacement(Placeholder.ERROR, r.errorMessage))); new Replacement(Placeholder.ERROR, r.errorMessage)));
p.sendMessage(LanguageUtils.getMessage(Message.SHOP_REMOVED_REFUND,
new Replacement(Placeholder.CREATION_PRICE, 0)));
} else {
p.sendMessage(LanguageUtils.getMessage(Message.SHOP_REMOVED_REFUND,
new Replacement(Placeholder.CREATION_PRICE, creationPrice)));
} }
} else {
p.sendMessage(LanguageUtils.getMessage(Message.SHOP_REMOVED));
} }
shopUtils.removeShop(shop, true); shopUtils.removeShop(shop, true);
plugin.debug(String.format("%s broke %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID())); plugin.debug(String.format("%s broke %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
p.sendMessage(LanguageUtils.getMessage(Message.SHOP_REMOVED));
} }
} }

View File

@ -527,19 +527,25 @@ public class ShopInteractListener implements Listener {
return; return;
} }
if (executor.getUniqueId().equals(shop.getVendor().getUniqueId())) {
double creationPrice = shop.getShopType() == ShopType.ADMIN ? Config.shopCreationPriceAdmin : Config.shopCreationPriceNormal; double creationPrice = shop.getShopType() == ShopType.ADMIN ? Config.shopCreationPriceAdmin : Config.shopCreationPriceNormal;
if (creationPrice > 0 && Config.refundShopCreation && executor.getUniqueId().equals(shop.getVendor().getUniqueId())) {
EconomyResponse r = plugin.getEconomy().depositPlayer(executor, shop.getLocation().getWorld().getName(), creationPrice); EconomyResponse r = plugin.getEconomy().depositPlayer(executor, shop.getLocation().getWorld().getName(), creationPrice);
if (!r.transactionSuccess()) { if (!r.transactionSuccess()) {
plugin.debug("Economy transaction failed: " + r.errorMessage); plugin.debug("Economy transaction failed: " + r.errorMessage);
executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED, executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED,
new Replacement(Placeholder.ERROR, r.errorMessage))); new Replacement(Placeholder.ERROR, r.errorMessage)));
executor.sendMessage(LanguageUtils.getMessage(Message.SHOP_REMOVED_REFUND,
new Replacement(Placeholder.CREATION_PRICE, 0)));
} else {
executor.sendMessage(LanguageUtils.getMessage(Message.SHOP_REMOVED_REFUND,
new Replacement(Placeholder.CREATION_PRICE, creationPrice)));
} }
} else {
executor.sendMessage(LanguageUtils.getMessage(Message.SHOP_REMOVED));
} }
shopUtils.removeShop(shop, true); shopUtils.removeShop(shop, true);
plugin.debug("Removed shop (#" + shop.getID() + ")"); plugin.debug("Removed shop (#" + shop.getID() + ")");
executor.sendMessage(LanguageUtils.getMessage(Message.SHOP_REMOVED));
} }
/** /**

View File

@ -4,7 +4,8 @@ message.chest-already-shop=&cTruhe ist bereits ein Shop.
message.chest-blocked=&cÜber der Truhe ist kein Platz. message.chest-blocked=&cÜber der Truhe ist kein Platz.
message.double-chest-blocked=&cÜber der Truhe ist kein Platz. message.double-chest-blocked=&cÜber der Truhe ist kein Platz.
message.shop-removed=&6Shop entfernt. message.shop-removed=&6Shop entfernt.
message.all-shops-removed=&6Alle (&c%AMOUNT%&6) Shop/s von &c%VENDOR%&6 wurden entfernt. message.shop-removed-refund=&6Shop entfernt. Dir wurden &c%CREATION-PRICE%&6 erstattet.
message.all-shops-removed=&6Alle (&c%AMOUNT%&6) Shops von &c%VENDOR%&6 wurden entfernt.
message.chest-no-shop=&cTruhe ist kein Shop. message.chest-no-shop=&cTruhe ist kein Shop.
message.shop-create-not-enough-money=&cNicht genug Geld. Du brauchst &6%CREATION-PRICE% &cum einen Shop zu erstellen. message.shop-create-not-enough-money=&cNicht genug Geld. Du brauchst &6%CREATION-PRICE% &cum einen Shop zu erstellen.
message.shopInfo.vendor=&6Verkäufer: &e%VENDOR% message.shopInfo.vendor=&6Verkäufer: &e%VENDOR%

View File

@ -4,7 +4,8 @@ message.chest-already-shop=&cTruhe ist bereits ein Shop.
message.chest-blocked=&cÜber der Truhe ist kein Platz. message.chest-blocked=&cÜber der Truhe ist kein Platz.
message.double-chest-blocked=&cÜber der Truhe ist kein Platz. message.double-chest-blocked=&cÜber der Truhe ist kein Platz.
message.shop-removed=&6Shop entfernt. message.shop-removed=&6Shop entfernt.
message.all-shops-removed=&6Alle (&c%AMOUNT%&6) Shop/s von &c%VENDOR%&6 wurden entfernt. message.shop-removed-refund=&6Shop entfernt. Dir wurden &c%CREATION-PRICE%&6 erstattet.
message.all-shops-removed=&6Alle (&c%AMOUNT%&6) Shops von &c%VENDOR%&6 wurden entfernt.
message.chest-no-shop=&cTruhe ist kein Shop. message.chest-no-shop=&cTruhe ist kein Shop.
message.shop-create-not-enough-money=&cNicht genug Geld. Du brauchst &6%CREATION-PRICE% &cum einen Shop zu erstellen. message.shop-create-not-enough-money=&cNicht genug Geld. Du brauchst &6%CREATION-PRICE% &cum einen Shop zu erstellen.
message.shopInfo.vendor=&6Verkäufer: &e%VENDOR% message.shopInfo.vendor=&6Verkäufer: &e%VENDOR%

View File

@ -23,12 +23,17 @@ message.chest-blocked=&cThere must not be a block above the chest.
# to create a double chest shop, but there is a block above the placed chest. # to create a double chest shop, but there is a block above the placed chest.
message.double-chest-blocked=&cThere must not be a block above the chest. message.double-chest-blocked=&cThere must not be a block above the chest.
# Set the message when the clicked shop is removed. # Set the message when the clicked shop is removed but no refund was given.
message.shop-removed=&6Shop removed. message.shop-removed=&6Shop removed.
# Set the message when the clicked shop is removed and the player is refunded
# the creation price.
# Usable Placeholders: %CREATION-PRICE%
message.shop-removed-refund=&6Shop removed. You were refunded &c%CREATION-PRICE%&6.
# Set the message when all shops of a player were removed. # Set the message when all shops of a player were removed.
# Usable Placeholders: %AMOUNT%, %VENDOR% # Usable Placeholders: %AMOUNT%, %VENDOR%
message.all-shops-removed=&6Removed all (&c%AMOUNT%&6) shop/s of &c%VENDOR%&6. message.all-shops-removed=&6Removed all (&c%AMOUNT%&6) shops of &c%VENDOR%&6.
# Set the message when the clicked chest is not a shop. # Set the message when the clicked chest is not a shop.
message.chest-no-shop=&cChest is not a shop. message.chest-no-shop=&cChest is not a shop.

View File

@ -16,12 +16,17 @@ message.chest-blocked=&cThere must not be a block above the chest.
# to create a double chest shop, but there is a block above the placed chest. # to create a double chest shop, but there is a block above the placed chest.
message.double-chest-blocked=&cThere must not be a block above the chest. message.double-chest-blocked=&cThere must not be a block above the chest.
# Set the message when the clicked shop is removed. # Set the message when the clicked shop is removed but no refund was given.
message.shop-removed=&6Shop removed. message.shop-removed=&6Shop removed.
# Set the message when the clicked shop is removed and the player is refunded
# the creation price.
# Usable Placeholders: %CREATION-PRICE%
message.shop-removed-refund=&6Shop removed. You were refunded &c%CREATION-PRICE%&6.
# Set the message when all shops of a player were removed. # Set the message when all shops of a player were removed.
# Usable Placeholders: %AMOUNT%, %VENDOR% # Usable Placeholders: %AMOUNT%, %VENDOR%
message.all-shops-removed=&6Removed all (&c%AMOUNT%&6) shop/s of &c%VENDOR%&6. message.all-shops-removed=&6Removed all (&c%AMOUNT%&6) shops of &c%VENDOR%&6.
# Set the message when the clicked chest is not a shop. # Set the message when the clicked chest is not a shop.
message.chest-no-shop=&cChest is not a shop. message.chest-no-shop=&cChest is not a shop.