ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
>[danger] 需要 PlayerPoints 插件 ![](https://img.kancloud.cn/d8/19/d8196407ee55193b2b3575422c25c385_613x23.png) 文件名: `pxtools.util.PointAPI.java` ``` import org.black_ixx.playerpoints.PlayerPoints; import org.black_ixx.playerpoints.PlayerPointsAPI; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; class PointAPI { static PlayerPointsAPI api; static PlayerPointsAPI getAPI() { if (api == null) { Plugin plugin = Bukkit.getPluginManager().getPlugin("PlayerPoints"); if (plugin != null) { PlayerPoints playerPoints = (PlayerPoints)plugin; api = playerPoints.getAPI(); } } return api; } /** * 获取玩家的点券数量 * * @param player * @return */ static int get(Player player) { PlayerPointsAPI api = getAPI(); if (api == null) { System.out.println("未找到PlayerPoints,无法获取玩家的点券数量"); return 0; } return api.look(player.getUniqueId()); } /** * 添加或减少玩家的点券 * * @param player * @param amount 负数为减少 * @return 成功返回true */ static boolean add(Player player, int amount) { if (amount == 0) return true; PlayerPointsAPI api = getAPI(); if (api == null) { System.out.println("未找到PlayerPoints,无法更改玩家的点券数量"); return false; } if (amount > 0) return api.give(player.getUniqueId(), amount); else return api.take(player.getUniqueId(), amount); } } ```