From dfeab6b558582a6ea9221f4c7bc6e27655e36c99 Mon Sep 17 00:00:00 2001 From: Mixpa <514518274@qq.com> Date: Sun, 25 Aug 2019 21:51:19 +0800 Subject: [PATCH] simply if code --- .../java/com/gmail/nossr50/api/DatabaseAPI.java | 5 +---- .../nossr50/datatypes/player/McMMOPlayer.java | 5 +---- .../java/com/gmail/nossr50/util/EventUtils.java | 5 +---- .../nossr50/util/random/RandomChanceUtil.java | 5 +---- .../com/gmail/nossr50/util/skills/CombatUtils.java | 14 +++----------- 5 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/api/DatabaseAPI.java b/src/main/java/com/gmail/nossr50/api/DatabaseAPI.java index 76caad65b..544a23124 100644 --- a/src/main/java/com/gmail/nossr50/api/DatabaseAPI.java +++ b/src/main/java/com/gmail/nossr50/api/DatabaseAPI.java @@ -24,10 +24,7 @@ public class DatabaseAPI { public boolean doesPlayerExistInDB(UUID uuid) { PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid); - if(playerProfile.isLoaded()) - return true; - else - return false; + return playerProfile.isLoaded(); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 219b1df16..3495bbab4 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -491,10 +491,7 @@ public class McMMOPlayer { if(hasReachedPowerLevelCap()) return true; - if(getSkillLevel(primarySkillType) >= Config.getInstance().getLevelCap(primarySkillType)) - return true; - - return false; + return getSkillLevel(primarySkillType) >= Config.getInstance().getLevelCap(primarySkillType); } /** diff --git a/src/main/java/com/gmail/nossr50/util/EventUtils.java b/src/main/java/com/gmail/nossr50/util/EventUtils.java index 026dabd60..6c9317185 100644 --- a/src/main/java/com/gmail/nossr50/util/EventUtils.java +++ b/src/main/java/com/gmail/nossr50/util/EventUtils.java @@ -62,10 +62,7 @@ public class EventUtils { * @return true if damage is NOT from an unnatural mcMMO skill (such as bleed DOTs) */ public static boolean isDamageFromMcMMOComplexBehaviour(Event event) { - if (event instanceof FakeEntityDamageEvent) { - return true; - } - return false; + return event instanceof FakeEntityDamageEvent; } /** diff --git a/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java b/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java index cf4817a65..ae9511bd0 100644 --- a/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java +++ b/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java @@ -80,10 +80,7 @@ public class RandomChanceUtil public static boolean rollDice(double chanceOfSuccess, int bound) { Random random = new Random(); - if (chanceOfSuccess > random.nextInt(bound)) - return true; - else - return false; + return chanceOfSuccess > random.nextInt(bound); } /** diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 201ac00ec..2995b9d4e 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -777,18 +777,14 @@ public final class CombatUtils { } // It may seem a bit redundant but we need a check here to prevent bleed from being applied in applyAbilityAoE() - if (getFakeDamageFinalResult(player, entity, 1.0) == 0) { - return false; - } + return getFakeDamageFinalResult(player, entity, 1.0) != 0; } else if (entity instanceof Tameable) { if (isFriendlyPet(player, (Tameable) entity)) { // isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party // So we can make some assumptions here, about our casting and our check Player owner = (Player) ((Tameable) entity).getOwner(); - if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire(owner))) { - return false; - } + return Permissions.friendlyFire(player) && Permissions.friendlyFire(owner); } } @@ -850,11 +846,7 @@ public final class CombatUtils { public static boolean canDamage(Entity attacker, Entity target, DamageCause damageCause, double damage) { EntityDamageEvent damageEvent = sendEntityDamageEvent(attacker, target, damageCause, damage); - if (damageEvent.isCancelled()) { - return false; - } - - return true; + return !damageEvent.isCancelled(); } public static EntityDamageEvent sendEntityDamageEvent(Entity attacker, Entity target, DamageCause damageCause, double damage) {