add debug message

Former-commit-id: 094224394e2b648e6989fe3fa804b205a7c7c962
This commit is contained in:
Ghost_chu committed 2018-08-01 21:19:15 +08:00
1 parent 31ca2baed6
commit 8cd0245eab
2 files changed
+36 -8

No files matched your search

@@ -4,12 +4,15 @@ import java.util.UUID;
import net.milkbowl.vault.economy.Economy;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.maxgamer.quickshop.QuickShop;
public class Economy_Vault implements EconomyCore {
private Economy vault;
QuickShop plugin;
public Economy_Vault() {
setupEconomy();
@@ -30,12 +33,16 @@ public class Economy_Vault implements EconomyCore {
@Deprecated
public boolean deposit(String name, double amount) {
return this.vault.depositPlayer(name, amount).transactionSuccess();
boolean result = this.vault.depositPlayer(name, amount).transactionSuccess();
if(QuickShop.debug) {plugin.getLogger().info("Economy debug: Vault return Deprecated deposit result:"+result);}
return result;
}
@Deprecated
public boolean withdraw(String name, double amount) {
return this.vault.withdrawPlayer(name, amount).transactionSuccess();
boolean result = this.vault.withdrawPlayer(name, amount).transactionSuccess();
if(QuickShop.debug) {plugin.getLogger().info("Economy debug: Vault return Deprecated withdraw result:"+result);}
return result;
}
@Deprecated
@@ -44,12 +51,16 @@ public class Economy_Vault implements EconomyCore {
if (this.vault.withdrawPlayer(from, amount).transactionSuccess()) {
if (!this.vault.depositPlayer(to, amount).transactionSuccess()) {
this.vault.depositPlayer(from, amount);
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Deprecated transfer failed");}
return false;
}
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Deprecated transfer success");}
return true;
}
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Deprecated transfer failed");}
return false;
}
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Deprecated transfer failed");}
return false;
}
@@ -70,13 +81,17 @@ public class Economy_Vault implements EconomyCore {
@Override
public boolean deposit(UUID name, double amount) {
OfflinePlayer p = Bukkit.getOfflinePlayer(name);
return this.vault.depositPlayer(p, amount).transactionSuccess();
boolean result = this.vault.depositPlayer(p, amount).transactionSuccess();
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Vault report deposit "+result);}
return result;
}
@Override
public boolean withdraw(UUID name, double amount) {
OfflinePlayer p = Bukkit.getOfflinePlayer(name);
return this.vault.withdrawPlayer(p, amount).transactionSuccess();
boolean result = this.vault.withdrawPlayer(p, amount).transactionSuccess();
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Vault report withdraw "+result);}
return result;
}
@Override
@@ -87,12 +102,16 @@ public class Economy_Vault implements EconomyCore {
if (this.vault.withdrawPlayer(pFrom, amount).transactionSuccess()) {
if (!this.vault.depositPlayer(pTo, amount).transactionSuccess()) {
this.vault.depositPlayer(pFrom, amount);
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Deprecated transfer failed");}
return false;
}
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Deprecated transfer success");}
return true;
}
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Deprecated transfer failed");}
return false;
}
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Deprecated transfer failed");}
return false;
}
@@ -29,6 +29,8 @@ import org.maxgamer.quickshop.Util.MsgUtil;
import org.maxgamer.quickshop.Util.Permissions;
import org.maxgamer.quickshop.Util.Util;
import com.sk89q.worldguard.protection.FlagValueCalculator.Result;
public class ShopManager {
private QuickShop plugin;
private HashMap<UUID, Info> actions = new HashMap<UUID, Info>();
@@ -435,6 +437,7 @@ public class ShopManager {
}
/* Purchase Handling */
else if (info.getAction() == ShopAction.BUY) {
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Starting buy");}
int amount = 0;
try {
amount = Integer.parseInt(message);
@@ -475,8 +478,9 @@ public class ShopManager {
}
ShopPurchaseEvent e = new ShopPurchaseEvent(shop, p, amount);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled())
return; // Cancelled
if (e.isCancelled()) {
return;
} // Cancelled
// Money handling
if (!p.getUniqueId().equals(shop.getOwner())) {
// Check their balance. Works with *most* economy
@@ -494,12 +498,14 @@ public class ShopManager {
}
double total = amount * shop.getPrice();
if(QuickShop.debug) {plugin.getLogger().info("Economy debug: trade total: "+total);}
if (!plugin.getEcon().withdraw(p.getUniqueId(), total)) {
p.sendMessage(MsgUtil.getMessage("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(p.getUniqueId()))));
return;
}
if (!shop.isUnlimited() || plugin.getConfig().getBoolean("shop.pay-unlimited-shop-owners")) {
plugin.getEcon().deposit(shop.getOwner(), total * (1 - tax));
boolean depositresult = plugin.getEcon().deposit(shop.getOwner(), total * (1 - tax));
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:deposit in shop manager result:"+depositresult);}
if (tax != 0) {
try {
for(OfflinePlayer player : Bukkit.getOfflinePlayers()) {
@@ -529,6 +535,7 @@ public class ShopManager {
// Transfers the item from A to B
shop.sell(p, amount);
MsgUtil.sendPurchaseSuccess(p, shop, amount);
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Trade purchase success completed.");}
plugin.log(p.getName() + " bought " + amount + " for " + (shop.getPrice() * amount) + " from " + shop.toString());
} else if (shop.isBuying()) {
int space = shop.getRemainingSpace();
@@ -588,7 +595,8 @@ public class ShopManager {
}
}
// Give them the money after we know we succeeded
plugin.getEcon().deposit(p.getUniqueId(), total * (1 - tax));
boolean depositresult = plugin.getEcon().deposit(p.getUniqueId(), total * (1 - tax));
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:deposit2 in shopmanager result:"+depositresult);}
// Notify the owner of the purchase.
String msg = MsgUtil.getMessage("player-sold-to-your-store", p.getName(), "" + amount, shop.getDataName());
if (space == amount)
@@ -597,6 +605,7 @@ public class ShopManager {
}
shop.buy(p, amount);
MsgUtil.sendSellSuccess(p, shop, amount);
if(QuickShop.debug) {plugin.getLogger().info("Economy debug:Trade sell success completed");}
plugin.log(p.getName() + " sold " + amount + " for " + (shop.getPrice() * amount) + " to " + shop.toString());
}
shop.setSignText(); // Update the signs count