多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
>[danger] 这个工具可以自定义一些冷却时间 ``` import com.google.common.collect.HashBasedTable; import com.google.common.collect.Table; class CooldownUtil { static Table cooldown; static{ cooldown = HashBasedTable.create(); } /** * 判定玩家某个类型是否在冷却中 * * @param player 玩家 * @param type 自定义类型,如: "攻击冷却" * @return 在冷却中返回true */ static boolean isCooldown(Player player,String type){ int id = player.getEntityId(); if(!cooldown.contains(id,type)) return false; long cooldown = cooldown.get(id,type); return cooldown > System.currentTimeMillis(); } /** * 设置某个玩家的冷却 * * @param player 玩家 * @param type 自定义类型,如: "攻击冷却" * @param time 冷却时间,毫秒 */ static void setCooldown(Player player,String type,long time){ cooldown.put(player.getEntityId(),type,System.currentTimeMillis()+time); } } ```