diff --git a/Datura/src/main/java/me/totalfreedom/datura/banning/BanUID.java b/Datura/src/main/java/me/totalfreedom/datura/banning/BanUID.java index 1869664..7f0c4b5 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/banning/BanUID.java +++ b/Datura/src/main/java/me/totalfreedom/datura/banning/BanUID.java @@ -22,7 +22,7 @@ public final class BanUID implements BanID final Instant instant = Instant.now(); - String stringBuilder = String.valueOf(instant.get(ChronoField.DAY_OF_YEAR)) + // The first three numbers between 001 -> 365 + final String stringBuilder = String.valueOf(instant.get(ChronoField.DAY_OF_YEAR)) + // The first three numbers between 001 -> 365 instant.get(ChronoField.HOUR_OF_DAY) + // next two numbers between 00 -> 23 instant.get(ChronoField.MINUTE_OF_HOUR) + // next two numbers between 00 -> 59 instant.get(ChronoField.MILLI_OF_SECOND); // last three numbers between 000 -> 999 diff --git a/Datura/src/main/java/me/totalfreedom/datura/event/UserDataUpdateEvent.java b/Datura/src/main/java/me/totalfreedom/datura/event/UserDataUpdateEvent.java index 3679532..b3ef7b4 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/event/UserDataUpdateEvent.java +++ b/Datura/src/main/java/me/totalfreedom/datura/event/UserDataUpdateEvent.java @@ -7,7 +7,7 @@ public class UserDataUpdateEvent extends FEvent { private final UserData data; - public UserDataUpdateEvent(UserData data) + public UserDataUpdateEvent(final UserData data) { this.data = data; } diff --git a/Datura/src/main/java/me/totalfreedom/datura/perms/FreedomGroup.java b/Datura/src/main/java/me/totalfreedom/datura/perms/FreedomGroup.java index 4ffd8c1..c22f124 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/perms/FreedomGroup.java +++ b/Datura/src/main/java/me/totalfreedom/datura/perms/FreedomGroup.java @@ -27,12 +27,12 @@ public class FreedomGroup implements Group private final Set permissions; private final PermissionAttachment attachment; - public FreedomGroup(Component name, - Component prefix, - Component abbreviation, - int weight, - boolean isDefault, - boolean isHidden) + public FreedomGroup(final Component name, + final Component prefix, + final Component abbreviation, + final int weight, + final boolean isDefault, + final boolean isHidden) { this.name = name; this.prefix = prefix; @@ -94,21 +94,21 @@ public class FreedomGroup implements Group } @Override - public boolean addPermission(Node node) + public boolean addPermission(final Node node) { return permissions().add(node); } @Override - public boolean removePermission(Node node) + public boolean removePermission(final Node node) { return permissions().remove(node); } @Override - public boolean isPermissionSet(@NotNull String name) + public boolean isPermissionSet(@NotNull final String name) { - Node node = permissions().stream() + final Node node = permissions().stream() .filter(n -> n.key().equalsIgnoreCase(name)) .findFirst() .orElse(null); @@ -117,9 +117,9 @@ public class FreedomGroup implements Group } @Override - public boolean isPermissionSet(@NotNull Permission perm) + public boolean isPermissionSet(@NotNull final Permission perm) { - Node node = permissions() + final Node node = permissions() .stream() .filter(n -> n.bukkit().equals(perm)) .findFirst() @@ -129,9 +129,9 @@ public class FreedomGroup implements Group } @Override - public boolean hasPermission(@NotNull String name) + public boolean hasPermission(@NotNull final String name) { - Node node = permissions().stream() + final Node node = permissions().stream() .filter(n -> n.key().equalsIgnoreCase(name)) .findFirst() .orElse(null); @@ -140,9 +140,9 @@ public class FreedomGroup implements Group } @Override - public boolean hasPermission(@NotNull Permission perm) + public boolean hasPermission(@NotNull final Permission perm) { - Node node = permissions() + final Node node = permissions() .stream() .filter(n -> n.bukkit().equals(perm)) .findFirst() @@ -164,33 +164,33 @@ public class FreedomGroup implements Group * @return This group's PermissionAttachment. */ @Override - public @NotNull PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) + public @NotNull PermissionAttachment addAttachment(@NotNull final Plugin plugin, @NotNull final String name, final boolean value) { attachment.setPermission(name, value); return attachment; } @Override - public @NotNull PermissionAttachment addAttachment(@NotNull Plugin plugin) + public @NotNull PermissionAttachment addAttachment(@NotNull final Plugin plugin) { return new PermissionAttachment(plugin, this); } @Override - public @Nullable PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) + public @Nullable PermissionAttachment addAttachment(@NotNull final Plugin plugin, @NotNull final String name, final boolean value, final int ticks) { attachment.setPermission(name, value); return attachment; } @Override - public @Nullable PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) + public @Nullable PermissionAttachment addAttachment(@NotNull final Plugin plugin, final int ticks) { return new PermissionAttachment(plugin, this); } @Override - public void removeAttachment(@NotNull PermissionAttachment attachment) + public void removeAttachment(@NotNull final PermissionAttachment attachment) { // This method shouldn't do anything, because we don't want to remove our attachment. } @@ -217,7 +217,7 @@ public class FreedomGroup implements Group @Override public boolean isOp() { - Node node = permissions() + final Node node = permissions() .stream() .filter(n -> n.equals(DefaultNodes.OP)) .findFirst() @@ -227,7 +227,7 @@ public class FreedomGroup implements Group } @Override - public void setOp(boolean value) + public void setOp(final boolean value) { if (value) { diff --git a/Datura/src/main/java/me/totalfreedom/datura/perms/FreedomUser.java b/Datura/src/main/java/me/totalfreedom/datura/perms/FreedomUser.java index f77b201..3bef6b8 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/perms/FreedomUser.java +++ b/Datura/src/main/java/me/totalfreedom/datura/perms/FreedomUser.java @@ -16,7 +16,11 @@ import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.UUID; /** * The superinterface User extends PermissionHolder, @@ -32,13 +36,13 @@ public class FreedomUser implements User private final String NOT_ONLINE = "Player is not online"; private final UserData userData; - public FreedomUser(Player player) + public FreedomUser(final Player player) { this.uuid = player.getUniqueId(); this.permissions = new HashSet<>(); this.displayName = player.displayName(); - Datura datura = CommonsBase.getInstance() + final Datura datura = CommonsBase.getInstance() .getRegistrations() .getModuleRegistry() .getModule(Datura.class) @@ -77,15 +81,15 @@ public class FreedomUser implements User } @Override - public boolean addPermission(Node node) + public boolean addPermission(final Node node) { - PermissionAttachment attachment = addAttachment(CommonsBase.getInstance(), node.key(), node.value()); + final PermissionAttachment attachment = addAttachment(CommonsBase.getInstance(), node.key(), node.value()); bukkitAttachments.put(node, attachment); return permissions().add(node); } @Override - public boolean removePermission(Node node) + public boolean removePermission(final Node node) { removeAttachment(bukkitAttachments.get(node)); bukkitAttachments.remove(node); @@ -105,37 +109,37 @@ public class FreedomUser implements User } @Override - public boolean isPermissionSet(@NotNull String name) + public boolean isPermissionSet(@NotNull final String name) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); return player != null && player.isPermissionSet(name); } @Override - public boolean isPermissionSet(@NotNull Permission perm) + public boolean isPermissionSet(@NotNull final Permission perm) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); return player != null && player.isPermissionSet(perm); } @Override - public boolean hasPermission(@NotNull String name) + public boolean hasPermission(@NotNull final String name) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); return player != null && player.hasPermission(name); } @Override - public boolean hasPermission(@NotNull Permission perm) + public boolean hasPermission(@NotNull final Permission perm) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); return player != null && player.hasPermission(perm); } @Override - public @NotNull PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) + public @NotNull PermissionAttachment addAttachment(@NotNull final Plugin plugin, @NotNull final String name, final boolean value) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); if (player != null) { return player.addAttachment(plugin, name, value); @@ -145,9 +149,9 @@ public class FreedomUser implements User } @Override - public @NotNull PermissionAttachment addAttachment(@NotNull Plugin plugin) + public @NotNull PermissionAttachment addAttachment(@NotNull final Plugin plugin) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); if (player != null) { return player.addAttachment(plugin); @@ -157,9 +161,9 @@ public class FreedomUser implements User } @Override - public @Nullable PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) + public @Nullable PermissionAttachment addAttachment(@NotNull final Plugin plugin, @NotNull final String name, final boolean value, final int ticks) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); if (player != null) { return player.addAttachment(plugin, name, value, ticks); @@ -169,9 +173,9 @@ public class FreedomUser implements User } @Override - public @Nullable PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) + public @Nullable PermissionAttachment addAttachment(@NotNull final Plugin plugin, final int ticks) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); if (player != null) { return player.addAttachment(plugin, ticks); @@ -181,9 +185,9 @@ public class FreedomUser implements User } @Override - public void removeAttachment(@NotNull PermissionAttachment attachment) + public void removeAttachment(@NotNull final PermissionAttachment attachment) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); if (player != null) { player.removeAttachment(attachment); @@ -195,7 +199,7 @@ public class FreedomUser implements User @Override public void recalculatePermissions() { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); if (player != null) { player.recalculatePermissions(); @@ -207,7 +211,7 @@ public class FreedomUser implements User @Override public @NotNull Set getEffectivePermissions() { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); if (player != null) { return player.getEffectivePermissions(); @@ -223,7 +227,7 @@ public class FreedomUser implements User } @Override - public void setOp(boolean value) + public void setOp(final boolean value) { if (value) { diff --git a/Datura/src/main/java/me/totalfreedom/datura/perms/PermissionNode.java b/Datura/src/main/java/me/totalfreedom/datura/perms/PermissionNode.java index 255da0a..1f2b91e 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/perms/PermissionNode.java +++ b/Datura/src/main/java/me/totalfreedom/datura/perms/PermissionNode.java @@ -21,7 +21,7 @@ record PermissionNode(String key, } @Override - public boolean compare(Node node) + public boolean compare(final Node node) { return node.key().equalsIgnoreCase(key()) && node.value() == value() diff --git a/Datura/src/main/java/me/totalfreedom/datura/perms/PermissionNodeBuilder.java b/Datura/src/main/java/me/totalfreedom/datura/perms/PermissionNodeBuilder.java index 11606fe..3ac7361 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/perms/PermissionNodeBuilder.java +++ b/Datura/src/main/java/me/totalfreedom/datura/perms/PermissionNodeBuilder.java @@ -14,42 +14,42 @@ public class PermissionNodeBuilder implements NodeBuilder private boolean negated = false; @Override - public NodeBuilder key(String key) + public NodeBuilder key(final String key) { this.key = key; return this; } @Override - public NodeBuilder value(boolean value) + public NodeBuilder value(final boolean value) { this.value = value; return this; } @Override - public NodeBuilder expiry(long expiry) + public NodeBuilder expiry(final long expiry) { this.expiry = expiry; return this; } @Override - public NodeBuilder type(NodeType type) + public NodeBuilder type(final NodeType type) { this.type = type; return this; } @Override - public NodeBuilder wildcard(boolean wildcard) + public NodeBuilder wildcard(final boolean wildcard) { this.wildcard = wildcard; return this; } @Override - public NodeBuilder negated(boolean negated) + public NodeBuilder negated(final boolean negated) { this.negated = negated; return this; diff --git a/Datura/src/main/java/me/totalfreedom/datura/punishment/Cager.java b/Datura/src/main/java/me/totalfreedom/datura/punishment/Cager.java index 332e169..b84a9c4 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/punishment/Cager.java +++ b/Datura/src/main/java/me/totalfreedom/datura/punishment/Cager.java @@ -12,7 +12,11 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.player.PlayerQuitEvent; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import java.util.function.DoubleUnaryOperator; public class Cager extends Service @@ -34,18 +38,18 @@ public class Cager extends Service * * @param uuid The UUID of the player to cage. */ - public void cagePlayer(UUID uuid) + public void cagePlayer(final UUID uuid) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); if (player == null) return; cagedPlayers.add(uuid); cageLocations.put(uuid, createCage(player.getLocation(), Material.GLASS)); } - public void cagePlayer(UUID uuid, Material material) + public void cagePlayer(final UUID uuid, final Material material) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); if (player == null) return; cagedPlayers.add(uuid); @@ -57,10 +61,10 @@ public class Cager extends Service * * @param uuid The UUID of the player to uncage. */ - public void uncagePlayer(UUID uuid) + public void uncagePlayer(final UUID uuid) { cagedPlayers.remove(uuid); - Location location = cageLocations.get(uuid); + final Location location = cageLocations.get(uuid); createCage(location, Material.AIR); // Remove the cage (set all blocks to air). @@ -78,12 +82,12 @@ public class Cager extends Service @Override public void tick() { - for (UUID uuid : cagedPlayers) + for (final UUID uuid : cagedPlayers) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); if (player == null) continue; - Location cageLocation = getCageLocation(player); + final Location cageLocation = getCageLocation(player); final boolean inside; if (!player.getWorld().equals(cageLocation.getWorld())) @@ -108,7 +112,7 @@ public class Cager extends Service * @param player The player to check. * @return Whether the player is caged. */ - public Location getCageLocation(Player player) + public Location getCageLocation(final Player player) { return cageLocations.get(player.getUniqueId()); } @@ -119,16 +123,16 @@ public class Cager extends Service * We use the {@link Shaper} class to generate the cube, which allows us to define * custom shapes using {@link DoubleUnaryOperator}s. * - * @param location The location to center the cube around. + * @param location The location to center the cube around. * @param material The material to use for the cube. * @return The center location of the cube (the passed location). * @see Shaper * @see DoubleUnaryOperator */ - public Location createCage(Location location, Material material) + public Location createCage(final Location location, final Material material) { - Shaper shaper = new Shaper(location.getWorld(), 0.0, 4.0); - List cubed = new LinkedList<>(); + final Shaper shaper = new Shaper(location.getWorld(), 0.0, 4.0); + final List cubed = new LinkedList<>(); cubed.addAll(shaper.generate(5, t -> t, t -> 4.0, t -> t)); cubed.addAll(shaper.generate(5, t -> t, t -> 0.0, t -> t)); cubed.addAll(shaper.generate(5, t -> 0.0, t -> t, t -> t)); @@ -136,7 +140,7 @@ public class Cager extends Service cubed.addAll(shaper.generate(5, t -> t, t -> t, t -> 0.0)); cubed.addAll(shaper.generate(5, t -> t, t -> t, t -> 4.0)); - for (Location l : cubed) + for (final Location l : cubed) { location.getWorld().getBlockAt(l).setType(material); } @@ -147,7 +151,7 @@ public class Cager extends Service private final class CageListener implements Listener { @EventHandler - public void blockBreakEvent(BlockBreakEvent event) + public void blockBreakEvent(final BlockBreakEvent event) { if (cagedPlayers.contains(event.getPlayer().getUniqueId())) { @@ -156,7 +160,8 @@ public class Cager extends Service } @EventHandler - public void playerLeaveEvent(PlayerQuitEvent event) { + public void playerLeaveEvent(final PlayerQuitEvent event) + { if (cagedPlayers.contains(event.getPlayer().getUniqueId())) { uncagePlayer(event.getPlayer().getUniqueId()); diff --git a/Datura/src/main/java/me/totalfreedom/datura/punishment/Halter.java b/Datura/src/main/java/me/totalfreedom/datura/punishment/Halter.java index 62051b5..73047d1 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/punishment/Halter.java +++ b/Datura/src/main/java/me/totalfreedom/datura/punishment/Halter.java @@ -23,7 +23,7 @@ public class Halter implements Listener } @EventHandler - public void playerMove(PlayerMoveEvent event) + public void playerMove(final PlayerMoveEvent event) { if (haltedPlayers.contains(event.getPlayer().getUniqueId())) { diff --git a/Datura/src/main/java/me/totalfreedom/datura/punishment/Locker.java b/Datura/src/main/java/me/totalfreedom/datura/punishment/Locker.java index 320e931..36fda9b 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/punishment/Locker.java +++ b/Datura/src/main/java/me/totalfreedom/datura/punishment/Locker.java @@ -22,7 +22,7 @@ public class Locker extends Service super("locker-service"); } - public void lock(UUID uuid) + public void lock(final UUID uuid) { lockedPlayers.add(uuid); } @@ -32,19 +32,19 @@ public class Locker extends Service { lockedPlayers.removeIf(uuid -> !CommonsBase.getInstance().getServer().getOfflinePlayer(uuid).isOnline()); - for (UUID uuid : lockedPlayers) + for (final UUID uuid : lockedPlayers) { - Player player = Bukkit.getPlayer(uuid); + final Player player = Bukkit.getPlayer(uuid); if (player == null) continue; lockingMethod(player); } } - private void lockingMethod(@NotNull Player player) + private void lockingMethod(@NotNull final Player player) { - double x = player.getLocation().getX(); - double z = player.getLocation().getZ(); + final double x = player.getLocation().getX(); + final double z = player.getLocation().getZ(); if ((x / z % 0.001) < 1) { diff --git a/Datura/src/main/java/me/totalfreedom/datura/sql/DBBan.java b/Datura/src/main/java/me/totalfreedom/datura/sql/DBBan.java index efc99ba..2f2fb13 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/sql/DBBan.java +++ b/Datura/src/main/java/me/totalfreedom/datura/sql/DBBan.java @@ -16,12 +16,12 @@ public class DBBan { private final SQL sql; - public DBBan(SQL sql) + public DBBan(final SQL sql) { this.sql = sql; } - public CompletableFuture fromSQL(BanID id) + public CompletableFuture fromSQL(final BanID id) { return sql.executeQuery("SELECT * FROM bans WHERE id = ?", id.getID()) .thenApplyAsync(result -> @@ -30,11 +30,11 @@ public class DBBan { if (result.next()) { - UUID uuid = UUID.fromString(result.getString("uuid")); - Instant timestamp = Instant.parse(result.getString("timestamp")); + final UUID uuid = UUID.fromString(result.getString("uuid")); + final Instant timestamp = Instant.parse(result.getString("timestamp")); final Instant expiry; - String ex = result.getString("expiry"); + final String ex = result.getString("expiry"); if (ex.equals("-1")) { expiry = null; @@ -58,7 +58,7 @@ public class DBBan }, CommonsBase.getInstance().getExecutor().getAsync()); } - public void addBan(Ban ban) + public void addBan(final Ban ban) { sql.executeUpdate("INSERT INTO bans (id, uuid, reason, issuer, timestamp, expiry) VALUES (?, ?, ?, ?, ?, ?)", ban.getBanID().getID(), @@ -70,7 +70,7 @@ public class DBBan ); } - public boolean hasEntry(UUID uuid) { + public boolean hasEntry(final UUID uuid) { return sql.executeQuery("SELECT * FROM bans WHERE uuid = ?", uuid.toString()) .thenApplyAsync(result -> { diff --git a/Datura/src/main/java/me/totalfreedom/datura/sql/MySQL.java b/Datura/src/main/java/me/totalfreedom/datura/sql/MySQL.java index baaf132..68ca550 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/sql/MySQL.java +++ b/Datura/src/main/java/me/totalfreedom/datura/sql/MySQL.java @@ -3,7 +3,11 @@ package me.totalfreedom.datura.sql; import me.totalfreedom.base.CommonsBase; import me.totalfreedom.sql.SQL; -import java.sql.*; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; @@ -11,7 +15,7 @@ public class MySQL implements SQL { private String url = "jdbc:mysql://"; - public MySQL(String host, int port, String database) { + public MySQL(final String host, final int port, final String database) { url += host + ":" + port + "/" + database; } @@ -22,7 +26,7 @@ public class MySQL implements SQL * @param username The username to add * @param password The password to add */ - public void addCredentials(String username, String password) { + public void addCredentials(final String username, final String password) { if (url.contains("?user=")) { url = url.split("\\x3f")[0]; } @@ -31,7 +35,7 @@ public class MySQL implements SQL } @Override - public CompletableFuture getConnection(String url) + public CompletableFuture getConnection(final String url) { return CompletableFuture.supplyAsync(() -> { try { @@ -44,12 +48,12 @@ public class MySQL implements SQL } @Override - public CompletableFuture prepareStatement(String query, Object... args) + public CompletableFuture prepareStatement(final String query, final Object... args) { return getConnection(url) .thenApplyAsync(connection -> { try { - PreparedStatement statement = connection.prepareStatement(query); + final PreparedStatement statement = connection.prepareStatement(query); for (int i = 0; i < args.length; i++) { statement.setObject(i + 1, args[i]); } @@ -62,7 +66,7 @@ public class MySQL implements SQL } @Override - public CompletableFuture executeQuery(String query, Object... args) + public CompletableFuture executeQuery(final String query, final Object... args) { return prepareStatement(query, args) .thenApplyAsync(statement -> { @@ -76,7 +80,7 @@ public class MySQL implements SQL } @Override - public CompletableFuture executeUpdate(String query, Object... args) + public CompletableFuture executeUpdate(final String query, final Object... args) { return prepareStatement(query, args) .thenApplyAsync(statement -> { @@ -90,7 +94,7 @@ public class MySQL implements SQL } @Override - public CompletableFuture execute(String query, Object... args) + public CompletableFuture execute(final String query, final Object... args) { return prepareStatement(query, args) .thenApplyAsync(statement -> { @@ -104,9 +108,9 @@ public class MySQL implements SQL } @Override - public CompletableFuture createTable(String table, String... columns) + public CompletableFuture createTable(final String table, final String... columns) { - StringBuilder query = new StringBuilder(); + final StringBuilder query = new StringBuilder(); query.append("CREATE TABLE IF NOT EXISTS ? ("); for (int i = 0; i < columns.length; i++) { diff --git a/Datura/src/main/java/me/totalfreedom/datura/user/SimpleUserData.java b/Datura/src/main/java/me/totalfreedom/datura/user/SimpleUserData.java index ad3b174..dc4b17e 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/user/SimpleUserData.java +++ b/Datura/src/main/java/me/totalfreedom/datura/user/SimpleUserData.java @@ -58,7 +58,7 @@ public class SimpleUserData implements UserData this.caged = caged; } - public static SimpleUserData fromSQL(SQL sql, String uuid) + public static SimpleUserData fromSQL(final SQL sql, final String uuid) { return sql.executeQuery("SELECT * FROM users WHERE UUID = ?", uuid) .thenApplyAsync(result -> @@ -67,30 +67,30 @@ public class SimpleUserData implements UserData { if (result.next()) { - String g = result.getString("group"); + final String g = result.getString("group"); - UUID u = UUID.fromString(uuid); - String username = result.getString("username"); + final UUID u = UUID.fromString(uuid); + final String username = result.getString("username"); - Player player = Bukkit.getPlayer(u); + final Player player = Bukkit.getPlayer(u); if (player == null) throw new IllegalStateException("Player should be online but they are not!"); - User user = new FreedomUser(player); - Group group = CommonsBase.getInstance() + final User user = new FreedomUser(player); + final Group group = CommonsBase.getInstance() .getRegistrations() .getGroupRegistry() .getGroup(g); - long playtime = result.getLong("playtime"); - boolean frozen = result.getBoolean("frozen"); - boolean canInteract = result.getBoolean("canInteract"); - boolean caged = result.getBoolean("caged"); + final long playtime = result.getLong("playtime"); + final boolean frozen = result.getBoolean("frozen"); + final boolean canInteract = result.getBoolean("canInteract"); + final boolean caged = result.getBoolean("caged"); return new SimpleUserData(u, username, user, group, playtime, frozen, canInteract, caged); } } catch (SQLException ex) { - String sb = "An error occurred while trying to retrieve user data for UUID " + + final String sb = "An error occurred while trying to retrieve user data for UUID " + uuid + " from the database." + "\nCaused by: " + @@ -102,7 +102,7 @@ public class SimpleUserData implements UserData .error(sb); } - Player player = Bukkit.getPlayer(UUID.fromString(uuid)); + final Player player = Bukkit.getPlayer(UUID.fromString(uuid)); if (player == null) throw new IllegalStateException("Player should be online but they are not!"); return new SimpleUserData(player); }, CommonsBase.getInstance() @@ -136,7 +136,7 @@ public class SimpleUserData implements UserData } @Override - public void setGroup(@Nullable Group group) + public void setGroup(@Nullable final Group group) { event.ping(); this.group = group; @@ -149,14 +149,14 @@ public class SimpleUserData implements UserData } @Override - public void setPlaytime(long playtime) + public void setPlaytime(final long playtime) { event.ping(); this.playtime = playtime; } @Override - public void addPlaytime(long playtime) + public void addPlaytime(final long playtime) { event.ping(); this.playtime += playtime; @@ -176,7 +176,7 @@ public class SimpleUserData implements UserData } @Override - public void setFrozen(boolean frozen) + public void setFrozen(final boolean frozen) { event.ping(); this.frozen = true; @@ -189,7 +189,7 @@ public class SimpleUserData implements UserData } @Override - public void setInteractionState(boolean canInteract) + public void setInteractionState(final boolean canInteract) { event.ping(); this.canInteract = canInteract; @@ -202,7 +202,7 @@ public class SimpleUserData implements UserData } @Override - public void setCaged(boolean caged) + public void setCaged(final boolean caged) { event.ping(); this.caged = caged; diff --git a/Fossil/src/main/java/me/totalfreedom/fossil/command/KickCommand.java b/Fossil/src/main/java/me/totalfreedom/fossil/command/KickCommand.java index 8efbf00..898f1aa 100644 --- a/Fossil/src/main/java/me/totalfreedom/fossil/command/KickCommand.java +++ b/Fossil/src/main/java/me/totalfreedom/fossil/command/KickCommand.java @@ -1,6 +1,6 @@ package me.totalfreedom.fossil.command; -import me.totalfreedom.command.*; +import me.totalfreedom.command.CommandBase; import me.totalfreedom.command.annotation.Base; import me.totalfreedom.command.annotation.Info; import me.totalfreedom.command.annotation.Permissive; @@ -14,23 +14,17 @@ import org.bukkit.entity.Player; @Permissive(perm = "fossil.kick") public class KickCommand extends CommandBase { - public KickCommand(Fossil plugin) { + public KickCommand(final Fossil plugin) { super(plugin); } @Base - public void run(CommandSender sender) { + public void run(final CommandSender sender) { sender.sendMessage(Component.text("You must specify a player to kick.")); } @Subcommand(permission = "fossil.kick", args = {Player.class, String.class}) - public void kickPlayer(Player player, String string) { + public void kickPlayer(final Player player, final String string) { player.kick(Component.text(string)); } - - // TODO: Write the code to make this work properly. - @Subcommand(name = "info", permission = "fossil.kick.info", args = {Player.class}) - public void playerinfo(Player player) { - - } } diff --git a/Patchwork/src/main/java/me/totalfreedom/base/Registration.java b/Patchwork/src/main/java/me/totalfreedom/base/Registration.java index 64159c7..03c4dd3 100644 --- a/Patchwork/src/main/java/me/totalfreedom/base/Registration.java +++ b/Patchwork/src/main/java/me/totalfreedom/base/Registration.java @@ -1,6 +1,12 @@ package me.totalfreedom.base; -import me.totalfreedom.data.*; +import me.totalfreedom.data.GroupRegistry; +import me.totalfreedom.data.BanRegistry; +import me.totalfreedom.data.ConfigRegistry; +import me.totalfreedom.data.ModuleRegistry; +import me.totalfreedom.data.ServiceRegistry; +import me.totalfreedom.data.UserRegistry; +import me.totalfreedom.data.EventRegistry; public class Registration { @@ -9,6 +15,8 @@ public class Registration private final ServiceRegistry serviceRegistry; private final ModuleRegistry moduleRegistry; private final GroupRegistry groupRegistry; + private final BanRegistry banRegistry; + private final ConfigRegistry configRegistry; public Registration() { @@ -17,6 +25,8 @@ public class Registration this.serviceRegistry = new ServiceRegistry(); this.moduleRegistry = new ModuleRegistry(); this.groupRegistry = new GroupRegistry(); + this.banRegistry = new BanRegistry(); + this.configRegistry = new ConfigRegistry(); } public ModuleRegistry getModuleRegistry() @@ -43,4 +53,14 @@ public class Registration { return groupRegistry; } + + public BanRegistry getBanRegistry() + { + return banRegistry; + } + + public ConfigRegistry getConfigRegistry() + { + return configRegistry; + } } diff --git a/Patchwork/src/main/java/me/totalfreedom/command/BukkitDelegator.java b/Patchwork/src/main/java/me/totalfreedom/command/BukkitDelegator.java index fdaeb3f..e34c95d 100644 --- a/Patchwork/src/main/java/me/totalfreedom/command/BukkitDelegator.java +++ b/Patchwork/src/main/java/me/totalfreedom/command/BukkitDelegator.java @@ -1,6 +1,5 @@ package me.totalfreedom.command; -import jdk.jshell.MethodSnippet; import me.totalfreedom.api.Context; import me.totalfreedom.command.annotation.Subcommand; import me.totalfreedom.provider.ContextProvider; @@ -14,11 +13,7 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; import java.util.Set; public class BukkitDelegator extends Command implements PluginIdentifiableCommand @@ -41,7 +36,9 @@ public class BukkitDelegator extends Command implements PluginIdentifiableComman } @Override - public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) + public boolean execute(@NotNull final CommandSender sender, + @NotNull final String commandLabel, + @NotNull final String[] args) { if (commandLabel.isEmpty() || !commandLabel.equalsIgnoreCase(getName())) return false; @@ -63,23 +60,26 @@ public class BukkitDelegator extends Command implements PluginIdentifiableComman if (args.length > 0) { - ContextProvider provider = new ContextProvider(); - Set nodes = command.getSubcommands().keySet(); - for (Subcommand node : nodes) { - Class[] argTypes = node.args(); + final ContextProvider provider = new ContextProvider(); + final Set nodes = command.getSubcommands().keySet(); + for (final Subcommand node : nodes) + { + final Class[] argTypes = node.args(); if (argTypes.length != args.length) continue; Object[] objects = new Object[0]; - for (int i = 0; i < argTypes.length; i++) { - Class argType = argTypes[i]; - String arg = args[i]; + for (int i = 0; i < argTypes.length; i++) + { + final Class argType = argTypes[i]; + final String arg = args[i]; if (argType == String.class) continue; - Context context = () -> provider.fromString(arg); - if (!argType.isInstance(context.get())) { + final Context context = () -> provider.fromString(arg); + if (!argType.isInstance(context.get())) + { throw new IllegalStateException(); } objects = Arrays.copyOf(objects, objects.length + 1); @@ -98,7 +98,8 @@ public class BukkitDelegator extends Command implements PluginIdentifiableComman return false; } - if (command.getBaseMethodPair() != null) { + if (command.getBaseMethodPair() != null) + { try { command.getBaseMethodPair().getValue().invoke(command, sender); diff --git a/Patchwork/src/main/java/me/totalfreedom/command/CommandBase.java b/Patchwork/src/main/java/me/totalfreedom/command/CommandBase.java index 7c6a9ee..9b90197 100644 --- a/Patchwork/src/main/java/me/totalfreedom/command/CommandBase.java +++ b/Patchwork/src/main/java/me/totalfreedom/command/CommandBase.java @@ -29,7 +29,7 @@ public abstract class CommandBase if (this.getClass().isAnnotationPresent(Base.class)) { - Method method = Stream.of(this.getClass().getDeclaredMethods()) + final Method method = Stream.of(this.getClass().getDeclaredMethods()) .filter(m -> m.isAnnotationPresent(Base.class)) .findFirst() .orElseThrow(() -> new RuntimeException("Base annotation present but no method found.")); diff --git a/Patchwork/src/main/java/me/totalfreedom/command/CommandHandler.java b/Patchwork/src/main/java/me/totalfreedom/command/CommandHandler.java index a2bd595..9471dc7 100644 --- a/Patchwork/src/main/java/me/totalfreedom/command/CommandHandler.java +++ b/Patchwork/src/main/java/me/totalfreedom/command/CommandHandler.java @@ -1,14 +1,13 @@ package me.totalfreedom.command; import org.bukkit.Bukkit; -import org.bukkit.command.PluginCommand; import org.bukkit.plugin.java.JavaPlugin; public class CommandHandler { private final JavaPlugin plugin; - public CommandHandler(JavaPlugin plugin) + public CommandHandler(final JavaPlugin plugin) { this.plugin = plugin; } @@ -17,8 +16,9 @@ public class CommandHandler // We need to find a way to resolve PluginCommands so we can // set the executor and tab completer as necessary. // OR we need to find an alternative way to process tab completions. - public void registerCommand(T command) { - BukkitDelegator delegate = new BukkitDelegator(plugin, command); + public void registerCommand(final T command) + { + final BukkitDelegator delegate = new BukkitDelegator(plugin, command); Bukkit.getCommandMap().register(plugin.getName(), delegate); } diff --git a/Patchwork/src/main/java/me/totalfreedom/data/BanRegistry.java b/Patchwork/src/main/java/me/totalfreedom/data/BanRegistry.java index b2ad3cf..ad2c159 100644 --- a/Patchwork/src/main/java/me/totalfreedom/data/BanRegistry.java +++ b/Patchwork/src/main/java/me/totalfreedom/data/BanRegistry.java @@ -2,7 +2,6 @@ package me.totalfreedom.data; import me.totalfreedom.security.ban.Ban; import me.totalfreedom.security.ban.BanID; -import me.totalfreedom.sql.SQL; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -12,18 +11,18 @@ public class BanRegistry { private final List bansList = new ArrayList<>(); - public boolean addBan(Ban ban) { + public boolean addBan(final Ban ban) { return bansList.add(ban); } - public boolean removeBan(Ban ban) { + public boolean removeBan(final Ban ban) { return bansList.remove(ban); } @Nullable - public Ban getBan(BanID banID) + public Ban getBan(final BanID banID) { - for (Ban ban : bansList) + for (final Ban ban : bansList) { if (ban.getBanID().matches(banID)) { diff --git a/Patchwork/src/main/java/me/totalfreedom/data/ConfigRegistry.java b/Patchwork/src/main/java/me/totalfreedom/data/ConfigRegistry.java index 2395758..2c54b02 100644 --- a/Patchwork/src/main/java/me/totalfreedom/data/ConfigRegistry.java +++ b/Patchwork/src/main/java/me/totalfreedom/data/ConfigRegistry.java @@ -9,17 +9,17 @@ public class ConfigRegistry { private final Map configurationList = new HashMap<>(); - public void register(String name, Configuration configuration) + public void register(final String name, final Configuration configuration) { configurationList.put(name, configuration); } - public void unregister(String name) + public void unregister(final String name) { configurationList.remove(name); } - public Configuration getConfiguration(String name) + public Configuration getConfiguration(final String name) { return configurationList.get(name); } diff --git a/Patchwork/src/main/java/me/totalfreedom/data/GroupRegistry.java b/Patchwork/src/main/java/me/totalfreedom/data/GroupRegistry.java index 578d422..990e878 100644 --- a/Patchwork/src/main/java/me/totalfreedom/data/GroupRegistry.java +++ b/Patchwork/src/main/java/me/totalfreedom/data/GroupRegistry.java @@ -15,18 +15,18 @@ public class GroupRegistry this.groups = new ArrayList<>(); } - public boolean registerGroup(Group group) { + public boolean registerGroup(final Group group) { return groups.add(group); } - public boolean unregisterGroup(Group group) { + public boolean unregisterGroup(final Group group) { return groups.remove(group); } - public Group getGroup(String name) { - PlainTextComponentSerializer s = PlainTextComponentSerializer.plainText(); - for (Group group : groups) { - String n = s.serialize(group.getName()); + public Group getGroup(final String name) { + final PlainTextComponentSerializer s = PlainTextComponentSerializer.plainText(); + for (final Group group : groups) { + final String n = s.serialize(group.getName()); if (n.equalsIgnoreCase(name)) { return group; } diff --git a/Patchwork/src/main/java/me/totalfreedom/data/ModuleRegistry.java b/Patchwork/src/main/java/me/totalfreedom/data/ModuleRegistry.java index b3d6d8d..06d3e19 100644 --- a/Patchwork/src/main/java/me/totalfreedom/data/ModuleRegistry.java +++ b/Patchwork/src/main/java/me/totalfreedom/data/ModuleRegistry.java @@ -29,9 +29,9 @@ public class ModuleRegistry } @SuppressWarnings("unchecked") - public ModuleProvider getModule(Class clazz) + public ModuleProvider getModule(final Class clazz) { - for (JavaPlugin plugin : plugins) + for (final JavaPlugin plugin : plugins) { if (clazz.isInstance(plugin)) { diff --git a/Patchwork/src/main/java/me/totalfreedom/data/ServiceRegistry.java b/Patchwork/src/main/java/me/totalfreedom/data/ServiceRegistry.java index c91e4d6..7381779 100644 --- a/Patchwork/src/main/java/me/totalfreedom/data/ServiceRegistry.java +++ b/Patchwork/src/main/java/me/totalfreedom/data/ServiceRegistry.java @@ -20,7 +20,7 @@ public class ServiceRegistry public void startAll() { - for (Service service : this.services) + for (final Service service : this.services) { service.start(); } @@ -28,7 +28,7 @@ public class ServiceRegistry public void stopAll() { - for (Service service : this.services) + for (final Service service : this.services) { service.stop(); } @@ -39,7 +39,7 @@ public class ServiceRegistry // and calling getClass() on this object would effectively be Class, though we may lose // the identity of the code signature in the process. // In this case, that is fine. - public void register(Plugin plugin, final T service) + public void register(final Plugin plugin, final T service) { this.services.add(service); if (!service.getClass().isInstance(service)) @@ -57,12 +57,12 @@ public class ServiceRegistry ServicePriority.Normal); } - public RegisteredServiceProvider getService(Class clazz) + public RegisteredServiceProvider getService(final Class clazz) { return Bukkit.getServicesManager().getRegistration(clazz); } - public void unregister(Class clazz, Service service) + public void unregister(final Class clazz, final Service service) { this.services.remove(service); Bukkit.getServicesManager().unregister(clazz, service); diff --git a/Patchwork/src/main/java/me/totalfreedom/data/UserRegistry.java b/Patchwork/src/main/java/me/totalfreedom/data/UserRegistry.java index 89fe42a..24bffa1 100644 --- a/Patchwork/src/main/java/me/totalfreedom/data/UserRegistry.java +++ b/Patchwork/src/main/java/me/totalfreedom/data/UserRegistry.java @@ -15,17 +15,17 @@ public class UserRegistry this.userDataMap = new HashMap<>(); } - public UserData getUserData(User user) + public UserData getUserData(final User user) { return userDataMap.get(user); } - public void registerUserData(User user, UserData userData) + public void registerUserData(final User user, final UserData userData) { userDataMap.put(user, userData); } - public void unregisterUserData(User user) + public void unregisterUserData(final User user) { userDataMap.remove(user); } diff --git a/Patchwork/src/main/java/me/totalfreedom/event/EventBus.java b/Patchwork/src/main/java/me/totalfreedom/event/EventBus.java index e4b0461..ad4c006 100644 --- a/Patchwork/src/main/java/me/totalfreedom/event/EventBus.java +++ b/Patchwork/src/main/java/me/totalfreedom/event/EventBus.java @@ -13,20 +13,20 @@ public class EventBus extends Service private final Set eventSet = new HashSet<>(); private final SubscriptionBox runningSubscriptions = new SubscriptionBox<>(); - public EventBus(CommonsBase plugin) + public EventBus(final CommonsBase plugin) { super("event_bus"); this.plugin = plugin; } - public void addEvent(FEvent event) + public void addEvent(final FEvent event) { eventSet.add(event); } - public T getEvent(Class eventClass) + public T getEvent(final Class eventClass) { - FEvent e = eventSet.stream() + final FEvent e = eventSet.stream() .filter(event -> event.getEventClass().equals(eventClass)) .findFirst() .orElse(null); @@ -34,9 +34,9 @@ public class EventBus extends Service return eventClass.cast(e); } - public EventSubscription subscribe(Class eventClass, Callback callback) + public EventSubscription subscribe(final Class eventClass, final Callback callback) { - Context eventContext = () -> eventSet.stream() + final Context eventContext = () -> eventSet.stream() .filter(event -> event.getEventClass().equals(eventClass)) .findFirst() .map(eventClass::cast) @@ -50,7 +50,7 @@ public class EventBus extends Service return new EventSubscription<>(eventContext.get(), callback); } - public void unsubscribe(EventSubscription subscription) + public void unsubscribe(final EventSubscription subscription) { runningSubscriptions.removeSubscription(subscription); } diff --git a/Patchwork/src/main/java/me/totalfreedom/event/SubscriptionBox.java b/Patchwork/src/main/java/me/totalfreedom/event/SubscriptionBox.java index ffb6bef..f072e3c 100644 --- a/Patchwork/src/main/java/me/totalfreedom/event/SubscriptionBox.java +++ b/Patchwork/src/main/java/me/totalfreedom/event/SubscriptionBox.java @@ -1,7 +1,5 @@ package me.totalfreedom.event; -import com.sun.source.tree.ContinueTree; - import java.util.ArrayList; import java.util.List; @@ -13,11 +11,11 @@ class SubscriptionBox this.subscriptions = new ArrayList<>(); } - public void addSubscription(EventSubscription subscription) { + public void addSubscription(final EventSubscription subscription) { subscriptions.add(subscription); } - public void removeSubscription(EventSubscription subscription) { + public void removeSubscription(final EventSubscription subscription) { subscriptions.remove(subscription); } diff --git a/Patchwork/src/main/java/me/totalfreedom/provider/ContextProvider.java b/Patchwork/src/main/java/me/totalfreedom/provider/ContextProvider.java index 0e7c76b..8651c83 100644 --- a/Patchwork/src/main/java/me/totalfreedom/provider/ContextProvider.java +++ b/Patchwork/src/main/java/me/totalfreedom/provider/ContextProvider.java @@ -14,7 +14,7 @@ import java.util.stream.Stream; public class ContextProvider { - public Object fromString(String string) + public Object fromString(final String string) { return Stream.of(toBoolean(string), toDouble(string), @@ -31,7 +31,7 @@ public class ContextProvider .orElse(string); } - private @Nullable Boolean toBoolean(String string) + private @Nullable Boolean toBoolean(final String string) { try { @@ -42,7 +42,7 @@ public class ContextProvider } } - private @Nullable Double toDouble(String string) + private @Nullable Double toDouble(final String string) { try { @@ -53,7 +53,7 @@ public class ContextProvider } } - private @Nullable Integer toInt(String string) + private @Nullable Integer toInt(final String string) { try { @@ -64,7 +64,7 @@ public class ContextProvider } } - private @Nullable Long toLong(String string) + private @Nullable Long toLong(final String string) { try { @@ -75,7 +75,7 @@ public class ContextProvider } } - private @Nullable Float toFloat(String string) + private @Nullable Float toFloat(final String string) { try { @@ -86,12 +86,12 @@ public class ContextProvider } } - private @Nullable Player toPlayer(String string) + private @Nullable Player toPlayer(final String string) { return Bukkit.getPlayer(string); } - private @Nullable CommandSender toCommandSender(String string) + private @Nullable CommandSender toCommandSender(final String string) { if (toPlayer(string) == null) return null; @@ -103,9 +103,9 @@ public class ContextProvider return Bukkit.getWorld(string); } - private @Nullable Location toLocation(String string) + private @Nullable Location toLocation(final String string) { - String[] split = string.split(","); + final String[] split = string.split(","); if (split.length != 4 || toWorld(split[0]) == null) return null; if (toDouble(split[1]) == null || toDouble(split[2]) == null @@ -114,7 +114,7 @@ public class ContextProvider return new Location(toWorld(split[0]), toDouble(split[1]), toDouble(split[2]), toDouble(split[3])); } - private @NotNull Component toComponent(String string) + private @NotNull Component toComponent(final String string) { return Component.text(string); } diff --git a/Patchwork/src/main/java/me/totalfreedom/service/FreedomExecutor.java b/Patchwork/src/main/java/me/totalfreedom/service/FreedomExecutor.java index e26451a..bc728ff 100644 --- a/Patchwork/src/main/java/me/totalfreedom/service/FreedomExecutor.java +++ b/Patchwork/src/main/java/me/totalfreedom/service/FreedomExecutor.java @@ -2,6 +2,7 @@ package me.totalfreedom.service; import me.totalfreedom.base.CommonsBase; import org.bukkit.Bukkit; +import org.jetbrains.annotations.NotNull; import java.util.concurrent.Executor; @@ -26,7 +27,7 @@ public class FreedomExecutor return asyncExecutor; } - public Executor scheduled(long delay, long period) + public Executor scheduled(final long delay, final long period) { return r -> Bukkit.getScheduler() .runTaskTimer( @@ -36,7 +37,7 @@ public class FreedomExecutor period); } - public Executor scheduledAsync(long delay, long period) + public Executor scheduledAsync(final long delay, final long period) { return r -> Bukkit.getScheduler() .runTaskTimerAsynchronously( @@ -46,12 +47,12 @@ public class FreedomExecutor period); } - public void runSync(Task task) + public void runSync(@NotNull final Task task) { getSync().execute(task); } - public void runAsync(Task task) + public void runAsync(@NotNull final Task task) { getAsync().execute(task); } diff --git a/Patchwork/src/main/java/me/totalfreedom/service/Service.java b/Patchwork/src/main/java/me/totalfreedom/service/Service.java index 54e83bd..ff4c9fc 100644 --- a/Patchwork/src/main/java/me/totalfreedom/service/Service.java +++ b/Patchwork/src/main/java/me/totalfreedom/service/Service.java @@ -7,7 +7,7 @@ public abstract class Service private final String name; private boolean isActive = false; - protected Service(String name) + protected Service(final String name) { this.name = name; diff --git a/Patchwork/src/main/java/me/totalfreedom/sql/SQL.java b/Patchwork/src/main/java/me/totalfreedom/sql/SQL.java index db0f176..717f685 100644 --- a/Patchwork/src/main/java/me/totalfreedom/sql/SQL.java +++ b/Patchwork/src/main/java/me/totalfreedom/sql/SQL.java @@ -7,15 +7,15 @@ import java.util.concurrent.CompletableFuture; public interface SQL { - CompletableFuture getConnection(String url); + CompletableFuture getConnection(final String url); - CompletableFuture prepareStatement(String query, Object... args); + CompletableFuture prepareStatement(final String query, final Object... args); - CompletableFuture executeQuery(String query, Object... args); + CompletableFuture executeQuery(final String query, final Object... args); - CompletableFuture executeUpdate(String query, Object... args); + CompletableFuture executeUpdate(final String query, final Object... args); - CompletableFuture execute(String query, Object... args); + CompletableFuture execute(final String query, final Object... args); - CompletableFuture createTable(String table, String... columns); + CompletableFuture createTable(final String table, final String... columns); } diff --git a/Patchwork/src/main/java/me/totalfreedom/sql/SQLProperties.java b/Patchwork/src/main/java/me/totalfreedom/sql/SQLProperties.java index 8d16faf..b7ee58d 100644 --- a/Patchwork/src/main/java/me/totalfreedom/sql/SQLProperties.java +++ b/Patchwork/src/main/java/me/totalfreedom/sql/SQLProperties.java @@ -9,7 +9,7 @@ public interface SQLProperties default Properties getDefaultProperties() { - Properties properties = new Properties(); + final Properties properties = new Properties(); properties.setProperty("driver", "sqlite"); properties.setProperty("host", "localhost"); properties.setProperty("port", "3306"); diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/FreedomLogger.java b/Patchwork/src/main/java/me/totalfreedom/utils/FreedomLogger.java index c0deaa1..104ce87 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/FreedomLogger.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/FreedomLogger.java @@ -11,17 +11,17 @@ public class FreedomLogger private final Logger logger; private boolean debug = false; - private FreedomLogger(String moduleName) + private FreedomLogger(final String moduleName) { this.logger = LoggerFactory.getLogger("FreedomNetworkSuite::" + moduleName); } - public static FreedomLogger getLogger(String moduleName) + public static FreedomLogger getLogger(final String moduleName) { return new FreedomLogger(moduleName); } - public void setDebugMode(boolean debug) + public void setDebugMode(final boolean debug) { this.debug = debug; } @@ -31,7 +31,7 @@ public class FreedomLogger * * @param message The message to send. */ - public void info(String message) + public void info(final String message) { logger.info(message); } @@ -44,7 +44,7 @@ public class FreedomLogger * @param message The message to send. * @return A component representation of the message. */ - public Component info(Supplier message) + public Component info(final Supplier message) { logger.info(message.get()); return Component.text(message.get()); @@ -55,7 +55,7 @@ public class FreedomLogger * * @param message The message to send. */ - public void warn(String message) + public void warn(final String message) { logger.warn(message); } @@ -67,7 +67,7 @@ public class FreedomLogger * * @param message The message to send. */ - public void error(String message) + public void error(final String message) { logger.error(message); } @@ -77,7 +77,7 @@ public class FreedomLogger * * @param th The exception to log. */ - public void error(Throwable th) + public void error(final Throwable th) { logger.error("An error occurred:\n", th); } @@ -92,7 +92,7 @@ public class FreedomLogger * @param message The message to send. * @return A component representation of the message. */ - public Component error(Supplier message) + public Component error(final Supplier message) { logger.error(message.get()); return Component.text(message.get()); @@ -104,7 +104,7 @@ public class FreedomLogger * * @param message The message to send. */ - public void debug(String message) + public void debug(final String message) { if (debug) logger.debug(message); @@ -119,7 +119,7 @@ public class FreedomLogger * @param message The message to send. * @return A component representation of the message. */ - public Component debug(Supplier message) + public Component debug(final Supplier message) { if (debug) { diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/Identity.java b/Patchwork/src/main/java/me/totalfreedom/utils/Identity.java index 40d0735..d186093 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/Identity.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/Identity.java @@ -8,7 +8,7 @@ public class Identity private final UUID id; - public Identity(String key) + public Identity(final String key) { this.key = key; this.id = UUID.nameUUIDFromBytes(key.getBytes()); diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/MICheck.java b/Patchwork/src/main/java/me/totalfreedom/utils/MICheck.java deleted file mode 100644 index f9210e8..0000000 --- a/Patchwork/src/main/java/me/totalfreedom/utils/MICheck.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.totalfreedom.utils; - -public class MICheck -{ - public double maintainabilityIndex(double fileLength, double vocabulary, double cyclomaticComplexity, double linesOfCode) { - double halsteadVolume = fileLength * (Math.log(vocabulary) / Math.log(2)); - double maintainabilityIndexUnbounded = 171 - 5.2 * Math.log(halsteadVolume) - 0.23 * cyclomaticComplexity - 16.2 * Math.log(linesOfCode); - return Math.max(0, maintainabilityIndexUnbounded * 100 / 171); - } - - public double complexity(double decisionPoints) { - return decisionPoints + 1; - } -} diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/Pair.java b/Patchwork/src/main/java/me/totalfreedom/utils/Pair.java index 681d640..029adad 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/Pair.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/Pair.java @@ -5,7 +5,7 @@ public class Pair private final K key; private final V value; - public Pair(K key, V value) { + public Pair(final K key, final V value) { this.key = key; this.value = value; } diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/Shaper.java b/Patchwork/src/main/java/me/totalfreedom/utils/Shaper.java index dbf9dd4..66ecd9d 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/Shaper.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/Shaper.java @@ -13,24 +13,24 @@ public class Shaper private final double end; private final World world; - public Shaper(World world, double start, double end) + public Shaper(final World world, final double start, final double end) { this.start = start; this.end = end; this.world = world; } - public List generate(int count, DoubleUnaryOperator x, DoubleUnaryOperator y, DoubleUnaryOperator z) + public List generate(final int count, final DoubleUnaryOperator x, final DoubleUnaryOperator y, final DoubleUnaryOperator z) { - double step = (start - end) / (count - 1); - LinkedList lset = new LinkedList<>(); + final double step = (start - end) / (count - 1); + final LinkedList lset = new LinkedList<>(); for (int i = 0; i < count; i++) { - double t = start + i * step; - double xp = x.applyAsDouble(t); - double yp = y.applyAsDouble(t); - double zp = z.applyAsDouble(t); + final double t = start + i * step; + final double xp = x.applyAsDouble(t); + final double yp = y.applyAsDouble(t); + final double zp = z.applyAsDouble(t); lset.add(new Location(world, xp, yp, zp)); } diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 0000000..54f1f03 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + +