Main class methods clean up

Former-commit-id: 2660db29bca5a0cef48fa518e275e84849f68f2b [formerly 1dc50307bcb5cb813f937d2e53d49d6e4125c5dc]
Former-commit-id: 92639827c262ce97c43f0a0e70193263c61f14a9
This commit is contained in:
Ghost_chu committed 2019-06-18 15:59:52 +08:00
1 parent 4fc8dbd74c
commit 1540d80ab1
7 files changed
+30 -52

No files matched your search

@@ -492,9 +492,9 @@ public class QS implements CommandExecutor {
double fee = 0;
if (plugin.isPriceChangeRequiresFee()) {
fee = plugin.getConfig().getDouble("shop.fee-for-price-change");
if (fee > 0 && plugin.getEcon().getBalance(p.getUniqueId()) < fee) {
if (fee > 0 && plugin.getEconomy().getBalance(p.getUniqueId()) < fee) {
sender.sendMessage(
MsgUtil.getMessage("you-cant-afford-to-change-price", plugin.getEcon().format(fee)));
MsgUtil.getMessage("you-cant-afford-to-change-price", plugin.getEconomy().format(fee)));
return;
}
}
@@ -511,15 +511,15 @@ public class QS implements CommandExecutor {
return;
}
if (fee > 0) {
if (!plugin.getEcon().withdraw(p.getUniqueId(), fee)) {
if (!plugin.getEconomy().withdraw(p.getUniqueId(), fee)) {
sender.sendMessage(MsgUtil.getMessage("you-cant-afford-to-change-price",
plugin.getEcon().format(fee)));
plugin.getEconomy().format(fee)));
return;
}
sender.sendMessage(
MsgUtil.getMessage("fee-charged-for-price-change", plugin.getEcon().format(fee)));
MsgUtil.getMessage("fee-charged-for-price-change", plugin.getEconomy().format(fee)));
try {
plugin.getEcon().deposit(Bukkit.getOfflinePlayer(plugin.getConfig().getString("tax-account"))
plugin.getEconomy().deposit(Bukkit.getOfflinePlayer(plugin.getConfig().getString("tax-account"))
.getUniqueId(), fee);
} catch (Exception e) {
e.getMessage();
@@ -532,7 +532,7 @@ public class QS implements CommandExecutor {
shop.setPrice(price);
//shop.setSignText();
shop.update();
sender.sendMessage(MsgUtil.getMessage("price-is-now", plugin.getEcon().format(shop.getPrice())));
sender.sendMessage(MsgUtil.getMessage("price-is-now", plugin.getEconomy().format(shop.getPrice())));
// Chest shops can be double shops.
if (shop instanceof ContainerShop) {
ContainerShop cs = (ContainerShop) shop;
@@ -875,7 +875,7 @@ public class QS implements CommandExecutor {
}
}
sender.sendMessage(ChatColor.RED + "QuickShop Statistics...");
sender.sendMessage(ChatColor.GREEN + "Server UniqueID: " + QuickShop.getUniqueID().toString());
sender.sendMessage(ChatColor.GREEN + "Server UniqueID: " + plugin.getServerUniqueID());
sender.sendMessage(ChatColor.GREEN + "" + (buying + selling) + " shops in " + chunks
+ " chunks spread over " + worlds + " worlds.");
sender.sendMessage(ChatColor.GREEN + "" + doubles + " double shops. ");
@@ -107,7 +107,7 @@ public class QuickShop extends JavaPlugin {
/** A util to call to check some actions permission **/
private PermissionChecker permissionChecker;
/** The server UniqueID, use to the ErrorReporter **/
private static UUID serverUniqueID;
private UUID serverUniqueID;
/** The error reporter to help devs report errors to Sentry.io **/
private SentryErrorReporter sentryErrorReporter;
@@ -823,15 +823,6 @@ public class QuickShop extends JavaPlugin {
Util.debugLog("All shutdown work is finished.");
}
/**
* Returns the economy for moving currency around
*
* @return The economy for moving currency around
*/
public EconomyCore getEcon() {
return economy;
}
/**
* Logs the given string to qs.log, if QuickShop is configured to do so.
*
@@ -845,16 +836,6 @@ public class QuickShop extends JavaPlugin {
this.logWatcher.add("[" + time.toString() + "] " + s);
}
/**
* Returns the ShopManager. This is used for fetching, adding and removing
* shops.
*
* @return The ShopManager.
*/
public ShopManager getShopManager() {
return this.shopManager;
}
/**
* Returns QS version, this method only exist on QSRR forks If running other
* QSRR forks,, result may not is "Reremake x.x.x" If running QS offical, Will
@@ -873,7 +854,4 @@ public class QuickShop extends JavaPlugin {
*/
public String getFork() { return "Reremake"; }
public static UUID getUniqueID() {
return QuickShop.serverUniqueID;
}
}
@@ -667,7 +667,7 @@ public class ContainerShop implements Shop {
String world = this.getLocation().getWorld().getName();
// Refund if necessary
if (plugin.getConfig().getBoolean("shop.refund")) {
plugin.getEcon().deposit(this.getOwner(), plugin.getConfig().getDouble("shop.cost"));
plugin.getEconomy().deposit(this.getOwner(), plugin.getConfig().getDouble("shop.cost"));
}
if (fromMemory) {
// Delete it from memory
@@ -440,26 +440,26 @@ public class ShopManager {
if (!shop.isUnlimited() || plugin.getConfig().getBoolean("shop.pay-unlimited-shop-owners")) {
// Tries to check their balance nicely to see if
// they can afford it.
if (plugin.getEcon().getBalance(shop.getOwner()) < amount * shop.getPrice()) {
if (plugin.getEconomy().getBalance(shop.getOwner()) < amount * shop.getPrice()) {
p.sendMessage(MsgUtil
.getMessage("the-owner-cant-afford-to-buy-from-you", format(amount * shop.getPrice()), format(plugin
.getEcon().getBalance(shop.getOwner()))));
.getEconomy().getBalance(shop.getOwner()))));
return;
}
// Check for plugins faking econ.has(amount)
if (!plugin.getEcon().withdraw(shop.getOwner(), total)) {
if (!plugin.getEconomy().withdraw(shop.getOwner(), total)) {
p.sendMessage(MsgUtil
.getMessage("the-owner-cant-afford-to-buy-from-you", format(amount * shop.getPrice()), format(plugin
.getEcon().getBalance(shop.getOwner()))));
.getEconomy().getBalance(shop.getOwner()))));
return;
}
if (tax != 0) {
plugin.getEcon().deposit(Bukkit.getOfflinePlayer(plugin.getConfig().getString("tax-account"))
plugin.getEconomy().deposit(Bukkit.getOfflinePlayer(plugin.getConfig().getString("tax-account"))
.getUniqueId(), total * tax);
}
}
// Give them the money after we know we succeeded
plugin.getEcon().deposit(p.getUniqueId(), total * (1 - tax));
plugin.getEconomy().deposit(p.getUniqueId(), total * (1 - tax));
// Notify the owner of the purchase.
String msg = MsgUtil.getMessage("player-sold-to-your-store", p.getName(), "" + amount, Util
.getItemStackName(shop.getItem()));
@@ -520,9 +520,9 @@ public class ShopManager {
if (!p.getUniqueId().equals(shop.getOwner())) {
// Check their balance. Works with *most* economy
// plugins*
if (plugin.getEcon().getBalance(p.getUniqueId()) < amount * shop.getPrice()) {
if (plugin.getEconomy().getBalance(p.getUniqueId()) < amount * shop.getPrice()) {
p.sendMessage(MsgUtil
.getMessage("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEcon()
.getMessage("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEconomy()
.getBalance(p.getUniqueId()))));
return;
}
@@ -532,16 +532,16 @@ public class ShopManager {
if (shop.getOwner().equals(p.getUniqueId())) {
tax = 0;
}
if (!plugin.getEcon().withdraw(p.getUniqueId(), total)) {
if (!plugin.getEconomy().withdraw(p.getUniqueId(), total)) {
p.sendMessage(MsgUtil
.getMessage("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEcon()
.getMessage("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEconomy()
.getBalance(p.getUniqueId()))));
return;
}
if (!shop.isUnlimited() || plugin.getConfig().getBoolean("shop.pay-unlimited-shop-owners")) {
plugin.getEcon().deposit(shop.getOwner(), total * (1 - tax));
plugin.getEconomy().deposit(shop.getOwner(), total * (1 - tax));
if (tax != 0) {
plugin.getEcon().deposit(Bukkit.getOfflinePlayer(plugin.getConfig().getString("tax-account"))
plugin.getEconomy().deposit(Bukkit.getOfflinePlayer(plugin.getConfig().getString("tax-account"))
.getUniqueId(), total * tax);
}
}
@@ -659,7 +659,7 @@ public class ShopManager {
double createCost = plugin.getConfig().getDouble("shop.cost");
// Tax refers to the cost to create a shop. Not actual
// tax, that would be silly
if (createCost != 0 && plugin.getEcon().getBalance(p.getUniqueId()) < createCost) {
if (createCost != 0 && plugin.getEconomy().getBalance(p.getUniqueId()) < createCost) {
p.sendMessage(MsgUtil.getMessage("you-cant-afford-a-new-shop", format(createCost)));
return;
}
@@ -678,13 +678,13 @@ public class ShopManager {
// Else, if the event is cancelled, they won't get their
// money back.
if (createCost != 0) {
if (!plugin.getEcon().withdraw(p.getUniqueId(), createCost)) {
if (!plugin.getEconomy().withdraw(p.getUniqueId(), createCost)) {
p.sendMessage(MsgUtil.getMessage("you-cant-afford-a-new-shop", format(createCost)));
shop.onUnload();
return;
}
try {
plugin.getEcon().deposit(
plugin.getEconomy().deposit(
Bukkit.getOfflinePlayer(plugin.getConfig().getString("tax-account")).getUniqueId(), createCost);
} catch (Exception e2) {
e2.printStackTrace();
@@ -744,7 +744,7 @@ public class ShopManager {
* @return formated price
*/
public String format(@NotNull double d) {
return plugin.getEcon().format(d);
return plugin.getEconomy().format(d);
}
public class ShopIterator implements Iterator<Shop> {
@@ -42,7 +42,7 @@ public class Paste {
finalReport.append("QuickShop:\n");
finalReport.append("\tVersion: " + QuickShop.getVersion() + "\n");
finalReport.append("\tFork: " + plugin.getFork() + "\n");
finalReport.append("\tServer ID: " + QuickShop.getUniqueID().toString() + "\n");
finalReport.append("\tServer ID: " + plugin.getServerUniqueID().toString() + "\n");
finalReport.append("\tOpenInv Hook: " + (plugin.getOpenInvPlugin() == null ? "Disabled" : "Enabled") + "\n");
//finalReport.append("Fork: "+plugin.+"\n");
finalReport.append("================================================\n");
@@ -54,7 +54,7 @@ public class SentryErrorReporter {
context.addTag("server_onlinemode", String.valueOf(serverData.get("onlineMode")));
context.addTag("server_bukkitversion", String.valueOf(serverData.get("bukkitVersion")));
context.addTag("server_plugins", getPluginInfo());
context.setUser(new UserBuilder().setId(QuickShop.getUniqueID().toString()).build());
context.setUser(new UserBuilder().setId(plugin.getServerUniqueID().toString()).build());
sentryClient.setServerName(Bukkit.getServer().getName() + " @ " + Bukkit.getServer().getVersion());
sentryClient.setRelease(QuickShop.getVersion());
sentryClient.setEnvironment(Util.isDevEdition() ? "Development" : "Production");
@@ -141,7 +141,7 @@ public class SentryErrorReporter {
plugin.getLogger().warning("====QuickShop Error Report BEGIN===");
plugin.getLogger().warning("Description: " + throwable.getMessage());
plugin.getLogger().warning("Event ID: " + this.context.getLastEventId().toString());
plugin.getLogger().warning("Server ID: " + QuickShop.getUniqueID().toString());
plugin.getLogger().warning("Server ID: " + plugin.getServerUniqueID().toString());
plugin.getLogger().warning("====QuickShop Error Report E N D===");
return this.context.getLastEventId();
}
@@ -419,7 +419,7 @@ public class Util {
return plugin.getConfig().getString("shop.alternate-currency-symbol") + n;
}
try {
String formated = plugin.getEcon().format(n);
String formated = plugin.getEconomy().format(n);
if (formated == null || formated.isEmpty()) {
Util.debugLog("Use alternate-currency-symbol to formatting, Cause economy plugin returned null");
return plugin.getConfig().getString("shop.alternate-currency-symbol") + n;