本文整理匯總了Java中net.milkbowl.vault.economy.Economy.withdrawPlayer方法的典型用法代碼示例。如果您正苦於以下問題:Java Economy.withdrawPlayer方法的具體用法?Java Economy.withdrawPlayer怎麽用?Java Economy.withdrawPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.milkbowl.vault.economy.Economy
的用法示例。
在下文中一共展示了Economy.withdrawPlayer方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: pay
import net.milkbowl.vault.economy.Economy; //導入方法依賴的package包/類
public boolean pay(Player player) {
double c = cost.resolve(player);
if (c > 0) {
Economy eco = EconomyManager.getEconomy();
if (eco == null) {
Uppercore.logger().severe("Cannot use economy: vault not found!");
return true;
}
EconomyResponse res = eco.withdrawPlayer(player, c);
if (!res.transactionSuccess()) {
noMoneyError.send(player);
if (noMoneySound != null)
noPermissionSound.play(player);
Uppercore.logger().log(Level.INFO, res.errorMessage);
return false;
} else return true;
}
return true;
}
示例2: deserialize
import net.milkbowl.vault.economy.Economy; //導入方法依賴的package包/類
/**
* Deserialize all aspects of a player, and apply their data. See {@link PlayerSerializer#serialize(PWIPlayer)}
* for an explanation of the data format number.
*
* @param data The saved player information.
* @param player The Player to apply the deserialized information to.
*/
public void deserialize(final JsonObject data, final Player player, DeserializeCause cause) {
ConsoleLogger.debug("[SERIALIZER] Deserializing player '" + player.getName()+ "'");
int format = 0;
if (data.has("data-format"))
format = data.get("data-format").getAsInt();
if (settings.getProperty(PwiProperties.LOAD_ENDER_CHESTS) && data.has("ender-chest"))
player.getEnderChest().setContents(inventorySerializer.deserializeInventory(data.getAsJsonArray("ender-chest"),
player.getEnderChest().getSize(), format));
if (settings.getProperty(PwiProperties.LOAD_INVENTORY) && data.has("inventory"))
inventorySerializer.setInventory(player, data.getAsJsonObject("inventory"), format);
if (data.has("stats"))
statSerializer.deserialize(player, data.getAsJsonObject("stats"), format);
if (plugin.isEconEnabled()) {
Economy econ = plugin.getEconomy();
if (econ == null) {
ConsoleLogger.warning("Economy saving is turned on, but no economy found!");
return;
}
ConsoleLogger.debug("[ECON] Withdrawing " + econ.getBalance(player) + " from '" + player.getName() + "'!");
EconomyResponse er = econ.withdrawPlayer(player, econ.getBalance(player));
if (!er.transactionSuccess()) {
ConsoleLogger.warning("[ECON] Unable to withdraw funds from '" + player.getName() + "': " + er.errorMessage);
}
if (data.has("economy") && er.transactionSuccess()) {
EconomySerializer.deserialize(econ, data.getAsJsonObject("economy"), player);
}
}
ConsoleLogger.debug("[SERIALIZER] Done deserializing player '" + player.getName()+ "'");
// Call event to signal loading is done
InventoryLoadCompleteEvent event = new InventoryLoadCompleteEvent(player, cause);
bukkitService.callEvent(event);
}
示例3: zeroPlayer
import net.milkbowl.vault.economy.Economy; //導入方法依賴的package包/類
/**
* Set a player's stats to defaults, and optionally clear their inventory.
*
* @param plugin {@link PerWorldInventory} for econ.
* @param player The player to zero.
* @param clearInventory Clear the player's inventory.
*/
public static void zeroPlayer(PerWorldInventory plugin, Player player, boolean clearInventory) {
if (clearInventory) {
player.getInventory().clear();
player.getEnderChest().clear();
}
player.setExp(0f);
player.setFoodLevel(20);
if (checkServerVersion(Bukkit.getVersion(), 1, 9, 0)) {
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
} else {
player.setHealth(player.getMaxHealth());
}
player.setLevel(0);
for (PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}
player.setSaturation(5f);
player.setFallDistance(0f);
player.setFireTicks(0);
if (plugin.isEconEnabled()) {
Economy econ = plugin.getEconomy();
econ.bankWithdraw(player.getName(), econ.bankBalance(player.getName()).amount);
econ.withdrawPlayer(player, econ.getBalance(player));
}
}
示例4: setEconomy
import net.milkbowl.vault.economy.Economy; //導入方法依賴的package包/類
public static void setEconomy(Economy econ, JSONObject data, Player player) {
try {
if (data.has("bank-balance")) {
econ.bankWithdraw(player.getName(), econ.bankBalance(player.getName()).balance);
econ.bankDeposit(player.getName(), data.getDouble("bank-balance"));
}
econ.withdrawPlayer(String.valueOf(player), econ.getBalance(String.valueOf(player)));
econ.depositPlayer(String.valueOf(player), data.getDouble("balance"));
} catch (JSONException ex) {
ex.printStackTrace();
}
}
示例5: complete
import net.milkbowl.vault.economy.Economy; //導入方法依賴的package包/類
@Override
public CompletionStatus complete(Craft c) {
Economy e = SQContracts.get().getEconomy();
OfflinePlayer plr = Bukkit.getOfflinePlayer(player);
double bal = e.getBalance(plr);
if(bal >= cost){
e.withdrawPlayer(plr, cost);
return CompletionStatus.COMPLETE;
} else if(bal <= 0){
return CompletionStatus.INCOMPLETE;
} else {
e.withdrawPlayer(plr, bal);
return CompletionStatus.PARTIAL;
}
}