/**
* Applies the {@link MinerClass} invisibility {@link PotionEffect} depending on the {@link Player}s {@link Location}.
*
* @param player
* the {@link Player} to apply for
* @param from
* the from {@link Location}
* @param to
* the to {@link Location}
*/
@EventHandler(ignoreCancelled=false, priority=EventPriority.HIGH)
public void onMinerSpeedClick(PlayerInteractEvent event)
{
Action action = event.getAction();
if (((action == Action.RIGHT_CLICK_AIR) || (action == Action.RIGHT_CLICK_BLOCK)) &&
(event.hasItem()) && (event.getItem().getType() == Material.SUGAR))
{
if (this.plugin.getPvpClassManager().getEquippedClass(event.getPlayer()) != this) {
return;
}
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
long timestamp = this.minerSpeedCooldowns.get(uuid);
long millis = System.currentTimeMillis();
long remaining = timestamp == this.minerSpeedCooldowns.getNoEntryValue() ? -1L : timestamp - millis;
if (remaining > 0L)
{
player.sendMessage(ChatColor.RED + "Cannot use Speed Boost for another " + DurationFormatUtils.formatDurationWords(remaining, true, true) + ".");
}
else
{
ItemStack stack = player.getItemInHand();
if (stack.getAmount() == 1) {
player.setItemInHand(new ItemStack(Material.AIR, 1));
} else {
stack.setAmount(stack.getAmount() - 1);
}
player.sendMessage(ChatColor.GREEN + "Speed 3 activated for 10 seconds.");
this.plugin.getEffectRestorer().setRestoreEffect(player, MINER_SPEED_EFFECT);
this.minerSpeedCooldowns.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + MINER_SPEED_COOLDOWN_DELAY);
}
}
}
MinerClass.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:HCFCore
作者:
评论列表
文章目录