Fixes for Codacy;

These fixes are designed to satisfy codacy.

However, codacy reports a NPath Complexity of 649, whereas the current, recommended, and standardized threshold is 200.

This is caused by FreedomCommand#execute(CommandSender, String, String[]);
This commit is contained in:
Paldiu 2020-12-25 15:35:33 -05:00
parent 361aa4ee04
commit 97edce0a67
7 changed files with 22 additions and 27 deletions

View File

@ -182,22 +182,22 @@ public class Pterodactyl extends FreedomService
return URL; return URL;
} }
public String getSERVER_KEY() public String getServerKey()
{ {
return SERVER_KEY; return SERVER_KEY;
} }
public String getADMIN_KEY() public String getAdminKey()
{ {
return ADMIN_KEY; return ADMIN_KEY;
} }
public List<String> getSERVER_HEADERS() public List<String> getServerHeaders()
{ {
return SERVER_HEADERS; return SERVER_HEADERS;
} }
public List<String> getADMIN_HEADERS() public List<String> getAdminHeaders()
{ {
return ADMIN_HEADERS; return ADMIN_HEADERS;
} }

View File

@ -134,14 +134,12 @@ public class EventBlocker extends FreedomService
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event) public void onEntityDamage(EntityDamageEvent event)
{ {
if (event.getCause() == EntityDamageEvent.DamageCause.LAVA) if ((event.getCause() == EntityDamageEvent.DamageCause.LAVA)
{ && !ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
if (!ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
}
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean()) if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
{ {

View File

@ -126,7 +126,7 @@ public class CageData
this.innerMaterial = inner; this.innerMaterial = inner;
input = null; input = null;
buildHistory(location, fPlayer); buildHistory(location);
regenerate(); regenerate();
} }
@ -143,7 +143,7 @@ public class CageData
this.innerMaterial = inner; this.innerMaterial = inner;
CageData.input = input; CageData.input = input;
buildHistory(location, fPlayer); buildHistory(location);
regenerate(); regenerate();
} }
@ -197,7 +197,7 @@ public class CageData
} }
} }
private void buildHistory(Location location, FPlayer playerdata) private void buildHistory(Location location)
{ {
final Block center = location.getBlock(); final Block center = location.getBlock();
for (int xOffset = -2; xOffset <= 2; xOffset++) for (int xOffset = -2; xOffset <= 2; xOffset++)

View File

@ -187,7 +187,7 @@ public class Discord extends FreedomService
@Override @Override
public void onReady(@NotNull ReadyEvent event) public void onReady(@NotNull ReadyEvent event)
{ {
new StartEvent(event.getJDA()).start(); new StartEvent().start();
} }
}) })
.setAutoReconnect(true) .setAutoReconnect(true)
@ -503,7 +503,7 @@ public class Discord extends FreedomService
// Do no ask why this is here. I spent two hours trying to make a simple thing work // Do no ask why this is here. I spent two hours trying to make a simple thing work
public class StartEvent public class StartEvent
{ {
public StartEvent(JDA api) public StartEvent()
{ {
} }

View File

@ -324,15 +324,14 @@ public class ItemFun extends FreedomService
{ {
arrow = (Arrow)entity; arrow = (Arrow)entity;
} }
if (arrow != null && (arrow.getShooter() instanceof Player))
{
//Redundant Player cast is required to avoid suspicious method calls. //Redundant Player cast is required to avoid suspicious method calls.
if (explosivePlayers.contains(arrow.getShooter())) if (arrow != null
&& (arrow.getShooter() instanceof Player)
&& explosivePlayers.contains((Player)arrow.getShooter()))
{ {
Objects.requireNonNull(arrow.getLocation().getWorld()).createExplosion(arrow.getLocation().getX(), arrow.getLocation().getY(), arrow.getLocation().getZ(), ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue(), false, ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()); Objects.requireNonNull(arrow.getLocation().getWorld()).createExplosion(arrow.getLocation().getX(), arrow.getLocation().getY(), arrow.getLocation().getZ(), ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue(), false, ConfigEntry.ALLOW_EXPLOSIONS.getBoolean());
arrow.remove(); arrow.remove();
} }
}
if (entity instanceof Fireball) if (entity instanceof Fireball)
{ {

View File

@ -23,7 +23,7 @@ public class PermissionConfig extends FreedomService
{ {
entries = new EnumMap<>(PermissionEntry.class); entries = new EnumMap<>(PermissionEntry.class);
PermissionDefaults tempDefaults = null; PermissionDefaults tempDefaults;
try try
{ {
try try
@ -50,8 +50,6 @@ public class PermissionConfig extends FreedomService
{ {
FLog.severe(ex); FLog.severe(ex);
} }
PermissionDefaults defaults = tempDefaults;
} }
@Override @Override

View File

@ -133,12 +133,12 @@ public class Punishment implements IConfig
this.reason = reason; this.reason = reason;
} }
public Date getIssued_on() public Date getIssuedOn()
{ {
return issued_on; return issued_on;
} }
public void setIssued_on(Date issued_on) public void setIssuedOn(Date issued_on)
{ {
this.issued_on = issued_on; this.issued_on = issued_on;
} }