mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-08 19:51:05 +00:00
Fixed refund if economy transactions fail
This commit is contained in:
parent
3eef8250d2
commit
3e6207182a
@ -187,11 +187,12 @@ public class ShopInteractListener implements Listener {
|
|||||||
plugin.debug(p.getName() + " is resident in town");
|
plugin.debug(p.getName() + " is resident in town");
|
||||||
externalPluginsAllowed &= (config.towny_shop_plots_residents.contains(townBlock.getType().name()));
|
externalPluginsAllowed &= (config.towny_shop_plots_residents.contains(townBlock.getType().name()));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!residentFound) {
|
if (!residentFound) {
|
||||||
plugin.debug(p.getName() + " is not resident in town");
|
plugin.debug(p.getName() + " is not resident in town");
|
||||||
externalPluginsAllowed &= false;
|
externalPluginsAllowed = false;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.debug(ex);
|
plugin.debug(ex);
|
||||||
@ -445,14 +446,14 @@ public class ShopInteractListener implements Listener {
|
|||||||
Plot plot = plotLocation.getOwnedPlot();
|
Plot plot = plotLocation.getOwnedPlot();
|
||||||
Flag flag = (shop.getShopType() == Shop.ShopType.ADMIN ? PlotSquaredShopFlag.USE_ADMIN_SHOP : PlotSquaredShopFlag.USE_SHOP);
|
Flag flag = (shop.getShopType() == Shop.ShopType.ADMIN ? PlotSquaredShopFlag.USE_ADMIN_SHOP : PlotSquaredShopFlag.USE_SHOP);
|
||||||
|
|
||||||
externalPluginsAllowed &= Utils.isFlagAllowedOnPlot(plot, flag, p);
|
externalPluginsAllowed = Utils.isFlagAllowedOnPlot(plot, flag, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.hasWorldGuard() && config.enable_worldguard_integration) {
|
if (externalPluginsAllowed && plugin.hasWorldGuard() && config.enable_worldguard_integration) {
|
||||||
StateFlag flag = (shop.getShopType() == ShopType.ADMIN ? WorldGuardShopFlag.USE_ADMIN_SHOP : WorldGuardShopFlag.USE_SHOP);
|
StateFlag flag = (shop.getShopType() == ShopType.ADMIN ? WorldGuardShopFlag.USE_ADMIN_SHOP : WorldGuardShopFlag.USE_SHOP);
|
||||||
RegionContainer container = worldGuard.getRegionContainer();
|
RegionContainer container = worldGuard.getRegionContainer();
|
||||||
RegionQuery query = container.createQuery();
|
RegionQuery query = container.createQuery();
|
||||||
externalPluginsAllowed &= query.testState(b.getLocation(), p, flag);
|
externalPluginsAllowed = query.testState(b.getLocation(), p, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shop.getShopType() == ShopType.ADMIN) {
|
if (shop.getShopType() == ShopType.ADMIN) {
|
||||||
@ -514,15 +515,15 @@ public class ShopInteractListener implements Listener {
|
|||||||
Plot plot = plotLocation.getOwnedPlot();
|
Plot plot = plotLocation.getOwnedPlot();
|
||||||
Flag flag = (shop.getShopType() == Shop.ShopType.ADMIN ? PlotSquaredShopFlag.USE_ADMIN_SHOP : PlotSquaredShopFlag.USE_SHOP);
|
Flag flag = (shop.getShopType() == Shop.ShopType.ADMIN ? PlotSquaredShopFlag.USE_ADMIN_SHOP : PlotSquaredShopFlag.USE_SHOP);
|
||||||
|
|
||||||
externalPluginsAllowed &= Utils.isFlagAllowedOnPlot(plot, flag, p);
|
externalPluginsAllowed = Utils.isFlagAllowedOnPlot(plot, flag, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.hasWorldGuard() && config.enable_worldguard_integration) {
|
if (externalPluginsAllowed && plugin.hasWorldGuard() && config.enable_worldguard_integration) {
|
||||||
RegionContainer container = worldGuard.getRegionContainer();
|
RegionContainer container = worldGuard.getRegionContainer();
|
||||||
RegionQuery query = container.createQuery();
|
RegionQuery query = container.createQuery();
|
||||||
|
|
||||||
StateFlag flag = (shop.getShopType() == ShopType.ADMIN ? WorldGuardShopFlag.USE_ADMIN_SHOP : WorldGuardShopFlag.USE_SHOP);
|
StateFlag flag = (shop.getShopType() == ShopType.ADMIN ? WorldGuardShopFlag.USE_ADMIN_SHOP : WorldGuardShopFlag.USE_SHOP);
|
||||||
externalPluginsAllowed &= query.testState(b.getLocation(), p, flag);
|
externalPluginsAllowed = query.testState(b.getLocation(), p, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (externalPluginsAllowed || p.hasPermission(Permissions.BYPASS_EXTERNAL_PLUGIN)) {
|
if (externalPluginsAllowed || p.hasPermission(Permissions.BYPASS_EXTERNAL_PLUGIN)) {
|
||||||
@ -730,7 +731,8 @@ public class ShopInteractListener implements Listener {
|
|||||||
|
|
||||||
executor.openInventory(shop.getInventoryHolder().getInventory());
|
executor.openInventory(shop.getInventoryHolder().getInventory());
|
||||||
plugin.debug("Opened shop (#" + shop.getID() + ")");
|
plugin.debug("Opened shop (#" + shop.getID() + ")");
|
||||||
if (message) executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OPENED_SHOP, new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, shop.getVendor().getName())));
|
if (message) executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OPENED_SHOP,
|
||||||
|
new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, shop.getVendor().getName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -945,6 +947,7 @@ public class ShopInteractListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")");
|
plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")");
|
||||||
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r2.errorMessage)));
|
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r2.errorMessage)));
|
||||||
|
econ.withdrawPlayer(shop.getVendor(), worldName, newPrice);
|
||||||
econ.depositPlayer(executor, worldName, newPrice);
|
econ.depositPlayer(executor, worldName, newPrice);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -969,6 +972,7 @@ public class ShopInteractListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")");
|
plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")");
|
||||||
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r.errorMessage)));
|
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r.errorMessage)));
|
||||||
|
econ.depositPlayer(executor, worldName, newPrice);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NOT_ENOUGH_INVENTORY_SPACE));
|
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NOT_ENOUGH_INVENTORY_SPACE));
|
||||||
@ -1085,6 +1089,7 @@ public class ShopInteractListener implements Listener {
|
|||||||
plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")");
|
plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")");
|
||||||
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r2.errorMessage)));
|
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r2.errorMessage)));
|
||||||
econ.withdrawPlayer(executor, worldName, newPrice);
|
econ.withdrawPlayer(executor, worldName, newPrice);
|
||||||
|
econ.depositPlayer(shop.getVendor(), worldName, newPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -1110,6 +1115,7 @@ public class ShopInteractListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")");
|
plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")");
|
||||||
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r.errorMessage)));
|
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r.errorMessage)));
|
||||||
|
econ.withdrawPlayer(executor, worldName, newPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user