Skip to content

Commit

Permalink
Refactor Do not call cooldowns if cooldowns are 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigerpanzer02 committed Jan 15, 2024
1 parent d2e92d1 commit 8606226
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public void onBowShot(EntityShootBowEvent event) {
return;
}
int bowCooldown = plugin.getConfig().getInt("Bow.Cooldown", 5);
if(bowCooldown <= 0) {
return;
}
user.setCooldown("bow_shot", bowCooldown);
plugin.getBukkitHelper().applyActionBarCooldown(player, bowCooldown);
VersionUtils.setMaterialCooldown(player, event.getBow().getType(), 20 * (plugin.getConfig().getInt("Bow.Cooldown", 5)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ public void onSwordThrow(PlayerInteractEvent event) {
if(attackerUser.getCooldown("sword_shoot") > 0) {
return;
}
createFlyingSword(attacker, attackerUser);

int swordFlyCooldown = plugin.getConfig().getInt("Sword.Cooldown.Fly", 5);

if(swordFlyCooldown <= 0) {
return;
}
attackerUser.setCooldown("sword_shoot", swordFlyCooldown);

if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_10_R1)) {
if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_11_R1)) {
attackerUser.setCooldown("sword_attack", (plugin.getConfig().getInt("Sword.Cooldown.Attack", 1)));
} else {
VersionUtils.setMaterialCooldown(attacker ,plugin.getSwordSkinManager().getMurdererSword(attacker).getType(), 20 * (plugin.getConfig().getInt("Sword.Cooldown.Attack", 1)));
}

createFlyingSword(attacker, attackerUser);
plugin.getBukkitHelper().applyActionBarCooldown(attacker, swordFlyCooldown);
}

Expand Down

0 comments on commit 8606226

Please sign in to comment.