-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
320 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/main/java/cn/handyplus/menu/hook/PlayerCurrencyUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package cn.handyplus.menu.hook; | ||
|
||
import cn.handyplus.currency.api.PlayerCurrencyApi; | ||
import cn.handyplus.lib.core.StrUtil; | ||
import cn.handyplus.lib.util.BaseUtil; | ||
import cn.handyplus.lib.util.MessageUtil; | ||
import cn.handyplus.menu.PlayerMenu; | ||
import org.bukkit.entity.Player; | ||
|
||
/** | ||
* 玩家多货币插件 PlayerCurrency 兼容 | ||
* | ||
* @author handy | ||
* @since 1.4.2 | ||
*/ | ||
public class PlayerCurrencyUtil { | ||
|
||
/** | ||
* 点击购买 | ||
* | ||
* @param player 玩家 | ||
* @param type 类型 | ||
* @param price 价格 | ||
*/ | ||
public static boolean buy(Player player, String type, long price) { | ||
// 多经济是否加载 | ||
if (!PlayerMenu.USE_PLY) { | ||
MessageUtil.sendMessage(player, BaseUtil.getMsgNotColor("playerCurrencyFailureMsg")); | ||
return false; | ||
} | ||
// 扣除点券 | ||
return PlayerCurrencyApi.take(player.getUniqueId(), type, price); | ||
} | ||
|
||
/** | ||
* 点击给予 | ||
* | ||
* @param player 玩家 | ||
* @param type 类型 | ||
* @param price 价格 | ||
*/ | ||
public static boolean give(Player player, String type, long price) { | ||
if (price == 0) { | ||
return false; | ||
} | ||
// 多经济是否加载 | ||
if (!PlayerMenu.USE_PLY) { | ||
MessageUtil.sendMessage(player, BaseUtil.getMsgNotColor("playerCurrencyFailureMsg")); | ||
return false; | ||
} | ||
// 给予点券 | ||
return PlayerCurrencyApi.give(player.getUniqueId(), type, price); | ||
} | ||
|
||
/** | ||
* 查询玩家余额 | ||
* | ||
* @param player 玩家 | ||
* @return 玩家余额 | ||
*/ | ||
public static long getPlayerBalance(Player player, String type) { | ||
if (!PlayerMenu.USE_PLY || player == null || StrUtil.isEmpty(type)) { | ||
return 0; | ||
} | ||
return PlayerCurrencyApi.look(player.getUniqueId(), type); | ||
} | ||
|
||
/** | ||
* 获取货币描述 | ||
* | ||
* @param type 类型 | ||
* @return 描述 | ||
*/ | ||
public static String getDesc(String type) { | ||
if (!PlayerMenu.USE_PLY || StrUtil.isEmpty(type)) { | ||
return type; | ||
} | ||
return PlayerCurrencyApi.getDesc(type); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.