ChanceSD / PvPManager

Function with cyclomatic complexity higher than threshold found JAVA-R1000
Anti-pattern
Minor
a month ago6 months old
onPlayerInteract has a cyclomatic complexity of 17 with "High" risk
205	}
206
207	@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) // cancel on low since some plugins check cancels on normal instead of monitor
208	public final void onPlayerInteract(final PlayerInteractEvent e) {209		final Player player = e.getPlayer();
210		if (CombatUtils.isWorldExcluded(player.getWorld().getName()) || e.getAction() != Action.RIGHT_CLICK_BLOCK)
211			return;
onPlaceholderRequest has a cyclomatic complexity of 18 with "High" risk
 36	}
 37
 38	@Override
 39	public String onPlaceholderRequest(final Player player, final String identifier) { 40		if (player == null)
 41			return "";
 42
disableActions has a cyclomatic complexity of 16 with "High" risk
142		}
143	}
144
145	private void disableActions(final Player attacker, final Player defender, final PvPlayer pvpAttacker, final PvPlayer pvpDefender) {146		final boolean hasExemptPerm = pvpAttacker.hasPerm(Permissions.EXEMPT_DISABLE_ACTIONS);
147		if (Settings.isDisableFly()) {
148			if (CombatUtils.canFly(attacker) && !hasExemptPerm) {
setup has a cyclomatic complexity of 15 with "Medium" risk
 28		setup();
 29	}
 30
 31	private void setup() { 32		if (!combatPrefix.isEmpty() || !combatSuffix.isEmpty()) {
 33			if (scoreboard.getTeam(combatTeamID) != null) {
 34				inCombat = scoreboard.getTeam(combatTeamID);
debug has a cyclomatic complexity of 20 with "High" risk
160		});
161	}
162
163	private void debug(final CommandSender sender, final String[] args) {164		PvPlayer p = null;
165		if (args.length == 2 && sender instanceof Player) {
166			p = plugin.getPlayerHandler().get((Player) sender);