-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement rest of mana abilities and critical
- Loading branch information
Showing
17 changed files
with
995 additions
and
10 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
23 changes: 23 additions & 0 deletions
23
bukkit/src/main/java/dev/aurelium/auraskills/bukkit/hooks/TownyHook.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,23 @@ | ||
package dev.aurelium.auraskills.bukkit.hooks; | ||
|
||
import com.palmergames.bukkit.towny.object.TownyPermission; | ||
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil; | ||
import dev.aurelium.auraskills.common.AuraSkillsPlugin; | ||
import dev.aurelium.auraskills.common.hooks.Hook; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.Player; | ||
|
||
public class TownyHook extends Hook { | ||
|
||
public TownyHook(AuraSkillsPlugin plugin) { | ||
super(plugin); | ||
} | ||
|
||
public boolean canBreak(Player player, Block block) { | ||
try { | ||
return PlayerCacheUtil.getCachePermission(player, block.getLocation(), block.getType(), TownyPermission.ActionType.DESTROY); | ||
} catch (Exception ignored) { } | ||
return true; | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
bukkit/src/main/java/dev/aurelium/auraskills/bukkit/listeners/CriticalHandler.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,47 @@ | ||
package dev.aurelium.auraskills.bukkit.listeners; | ||
|
||
import dev.aurelium.auraskills.api.ability.Abilities; | ||
import dev.aurelium.auraskills.bukkit.AuraSkills; | ||
import dev.aurelium.auraskills.common.config.Option; | ||
import dev.aurelium.auraskills.common.user.User; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.entity.EntityDamageByEntityEvent; | ||
import org.bukkit.metadata.FixedMetadataValue; | ||
|
||
import java.util.Random; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class CriticalHandler { | ||
|
||
private final Random rand = new Random(); | ||
private final AuraSkills plugin; | ||
|
||
public CriticalHandler(AuraSkills plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
public void applyCrit(EntityDamageByEntityEvent event, Player player, User user) { | ||
if (!Abilities.CRIT_CHANCE.isEnabled()) { | ||
return; | ||
} | ||
|
||
if (isCrit(user)) { | ||
event.setDamage(event.getDamage() * getCritMultiplier(user)); | ||
player.setMetadata("skillsCritical", new FixedMetadataValue(plugin, true)); | ||
plugin.getScheduler().scheduleSync(() -> player.removeMetadata("skillsCritical", plugin), 50, TimeUnit.MILLISECONDS); | ||
} | ||
} | ||
|
||
private boolean isCrit(User user) { | ||
return rand.nextDouble() < (Abilities.CRIT_CHANCE.getValue(user.getAbilityLevel(Abilities.CRIT_CHANCE)) / 100); | ||
} | ||
|
||
private double getCritMultiplier(User user) { | ||
if (Abilities.CRIT_DAMAGE.isEnabled()) { | ||
double multiplier = Abilities.CRIT_DAMAGE.getValue(user.getAbilityLevel(Abilities.CRIT_DAMAGE)) / 100; | ||
return plugin.configDouble(Option.CRITICAL_BASE_MULTIPLIER) * (1 + multiplier); | ||
} | ||
return plugin.configDouble(Option.CRITICAL_BASE_MULTIPLIER); | ||
} | ||
|
||
} |
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.