diff --git a/Datura/src/main/java/me/totalfreedom/datura/cmd/CageCommand.java b/Datura/src/main/java/me/totalfreedom/datura/cmd/CageCommand.java index 444ee23..e8ad5c1 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/cmd/CageCommand.java +++ b/Datura/src/main/java/me/totalfreedom/datura/cmd/CageCommand.java @@ -34,7 +34,7 @@ import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; @Info(name = "cage", description = "Cage a player.", - usage = "/cage [material]") + usage = "/cage [material]") @Permissive(perm = "datura.cage") public class CageCommand extends Commander { @@ -52,12 +52,14 @@ public class CageCommand extends Commander { case "on" -> { - ((Datura) getPlugin()).getCager().cagePlayer(player.getUniqueId()); + ((Datura) getPlugin()).getCager() + .cagePlayer(player.getUniqueId()); sender.sendPlainMessage("Caged " + player.getName() + "."); } case "off" -> { - ((Datura) getPlugin()).getCager().uncagePlayer(player.getUniqueId()); + ((Datura) getPlugin()).getCager() + .uncagePlayer(player.getUniqueId()); sender.sendPlainMessage("Liberated " + player.getName() + "."); } } @@ -65,18 +67,21 @@ public class CageCommand extends Commander @Completion(args = {"[material]"}, index = 2) @Subcommand(permission = "datura.cage.custom", args = {Player.class, String.class, Material.class}) - public void cagePlayer(final CommandSender sender, final Player player, final String string, final Material material) + public void cagePlayer(final CommandSender sender, final Player player, final String string, + final Material material) { switch (string.toLowerCase()) { case "on" -> { - ((Datura) getPlugin()).getCager().cagePlayer(player.getUniqueId(), material); + ((Datura) getPlugin()).getCager() + .cagePlayer(player.getUniqueId(), material); sender.sendPlainMessage("Caged " + player.getName() + "."); } case "off" -> { - ((Datura) getPlugin()).getCager().uncagePlayer(player.getUniqueId()); + ((Datura) getPlugin()).getCager() + .uncagePlayer(player.getUniqueId()); sender.sendPlainMessage("Liberated " + player.getName() + "."); } } diff --git a/Datura/src/main/java/me/totalfreedom/datura/cmd/LockerCommand.java b/Datura/src/main/java/me/totalfreedom/datura/cmd/LockerCommand.java index f1d7a99..f346e83 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/cmd/LockerCommand.java +++ b/Datura/src/main/java/me/totalfreedom/datura/cmd/LockerCommand.java @@ -31,8 +31,7 @@ public final class LockerCommand extends Commander .lock(player); sender.sendPlainMessage("Locked " + player.getName() + "."); - } - else if (string.equalsIgnoreCase("off")) + } else if (string.equalsIgnoreCase("off")) { ((Datura) getPlugin()).getLocker() .unlock(player); 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 7353c19..22fd39b 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/perms/PermissionNode.java +++ b/Datura/src/main/java/me/totalfreedom/datura/perms/PermissionNode.java @@ -16,9 +16,9 @@ record PermissionNode(String key, public Permission bukkit() { return new Permission(key(), - value() - ? PermissionDefault.TRUE - : PermissionDefault.FALSE); + value() + ? PermissionDefault.TRUE + : PermissionDefault.FALSE); } @Override 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 9662cfb..5827a8e 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/sql/MySQL.java +++ b/Datura/src/main/java/me/totalfreedom/datura/sql/MySQL.java @@ -62,42 +62,42 @@ public class MySQL implements SQL { return getConnection() .thenApplyAsync(connection -> - { - try - { - final PreparedStatement statement = connection.prepareStatement(query); - for (int i = 0; i < args.length; i++) - { - statement.setObject(i + 1, args[i]); - } - return statement; - } - catch (SQLException ex) - { - throw new CompletionException("Failed to prepare statement: " - + query + "\n", ex); - } - }, CommonsBase.getInstance() - .getExecutor() - .getAsync()); + { + try + { + final PreparedStatement statement = connection.prepareStatement(query); + for (int i = 0; i < args.length; i++) + { + statement.setObject(i + 1, args[i]); + } + return statement; + } + catch (SQLException ex) + { + throw new CompletionException("Failed to prepare statement: " + + query + "\n", ex); + } + }, CommonsBase.getInstance() + .getExecutor() + .getAsync()); } private CompletableFuture getConnection() { return CompletableFuture.supplyAsync(() -> - { - try - { - return DriverManager.getConnection(url.toString()); - } - catch (SQLException ex) - { - throw new CompletionException("Failed to connect to the database: " - + url.toString() + "\n", ex); - } - }, CommonsBase.getInstance() - .getExecutor() - .getAsync()); + { + try + { + return DriverManager.getConnection(url.toString()); + } + catch (SQLException ex) + { + throw new CompletionException("Failed to connect to the database: " + + url.toString() + "\n", ex); + } + }, CommonsBase.getInstance() + .getExecutor() + .getAsync()); } @Override @@ -105,20 +105,20 @@ public class MySQL implements SQL { return prepareStatement(query, args) .thenApplyAsync(statement -> - { - try - { - return statement.executeQuery(); - } - catch (SQLException ex) - { - throw new CompletionException( - "Failed to retrieve a result set from query: " - + query + "\n", ex); - } - }, CommonsBase.getInstance() - .getExecutor() - .getAsync()); + { + try + { + return statement.executeQuery(); + } + catch (SQLException ex) + { + throw new CompletionException( + "Failed to retrieve a result set from query: " + + query + "\n", ex); + } + }, CommonsBase.getInstance() + .getExecutor() + .getAsync()); } @Override @@ -126,19 +126,19 @@ public class MySQL implements SQL { return prepareStatement(query, args) .thenApplyAsync(statement -> - { - try - { - return statement.executeUpdate(); - } - catch (SQLException ex) - { - throw new CompletionException("Failed to execute update: " - + query + "\n", ex); - } - }, CommonsBase.getInstance() - .getExecutor() - .getAsync()); + { + try + { + return statement.executeUpdate(); + } + catch (SQLException ex) + { + throw new CompletionException("Failed to execute update: " + + query + "\n", ex); + } + }, CommonsBase.getInstance() + .getExecutor() + .getAsync()); } @Override @@ -146,19 +146,19 @@ public class MySQL implements SQL { return prepareStatement(query, args) .thenApplyAsync(statement -> - { - try - { - return statement.execute(); - } - catch (SQLException ex) - { - throw new CompletionException("Failed to execute statement: " - + query + "\n", ex); - } - }, CommonsBase.getInstance() - .getExecutor() - .getAsync()); + { + try + { + return statement.execute(); + } + catch (SQLException ex) + { + throw new CompletionException("Failed to execute statement: " + + query + "\n", ex); + } + }, CommonsBase.getInstance() + .getExecutor() + .getAsync()); } @Override @@ -185,25 +185,25 @@ public class MySQL implements SQL { return executeQuery("SELECT ? FROM ? WHERE ? = ?", column, table, key, identity.getId()) .thenApplyAsync(resultSet -> - { - try - { - if (resultSet.next()) - { - return resultSet.getObject(column, type); - } - } - catch (SQLException ex) - { - throw new CompletionException( - "Failed to retrieve column: " + column + " from table: " + table + " " + - "where primary key: " + key + " is equal to: " + identity.getId() + "\n", - ex); - } - return null; - }, CommonsBase.getInstance() - .getExecutor() - .getAsync()); + { + try + { + if (resultSet.next()) + { + return resultSet.getObject(column, type); + } + } + catch (SQLException ex) + { + throw new CompletionException( + "Failed to retrieve column: " + column + " from table: " + table + " " + + "where primary key: " + key + " is equal to: " + identity.getId() + "\n", + ex); + } + return null; + }, CommonsBase.getInstance() + .getExecutor() + .getAsync()); } public CompletableFuture updateColumn(final String table, final String column, final Object value, 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 ab8446e..2ecefd4 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/user/SimpleUserData.java +++ b/Datura/src/main/java/me/totalfreedom/datura/user/SimpleUserData.java @@ -26,9 +26,7 @@ public class SimpleUserData implements UserData private final UserDataUpdateEvent event = new UserDataUpdateEvent(this); private Group group; private long playtime; - private boolean frozen; private boolean canInteract; - private boolean caged; private AtomicLong balance; private boolean transactionsFrozen; @@ -49,7 +47,6 @@ public class SimpleUserData implements UserData final User user, final Group group, final long playtime, - final boolean frozen, final boolean canInteract, final long balance, final boolean transactionsFrozen) @@ -59,7 +56,6 @@ public class SimpleUserData implements UserData this.user = user; this.group = group; this.playtime = playtime; - this.frozen = frozen; this.canInteract = canInteract; this.balance = new AtomicLong(balance); this.transactionsFrozen = transactionsFrozen; @@ -69,61 +65,58 @@ public class SimpleUserData implements UserData { return sql.executeQuery("SELECT * FROM users WHERE UUID = ?", uuid) .thenApplyAsync(result -> - { - try - { - if (result.next()) - { - final String g = result.getString("group"); + { + try + { + if (result.next()) + { + final String g = result.getString("group"); - final UUID u = UUID.fromString(uuid); - final String username = result.getString("username"); + final UUID u = UUID.fromString(uuid); + final String username = result.getString("username"); - final 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!"); + if (player == null) + throw new IllegalStateException("Player should be online but they are not!"); - final User user = new FreedomUser(player); - final Group group = CommonsBase.getInstance() - .getRegistrations() - .getGroupRegistry() - .getGroup(g); + final User user = new FreedomUser(player); + final Group group = CommonsBase.getInstance() + .getRegistrations() + .getGroupRegistry() + .getGroup(g); - final long playtime = result.getLong("playtime"); - final boolean frozen = result.getBoolean("frozen"); - final boolean canInteract = result.getBoolean("canInteract"); - final boolean caged = result.getBoolean("caged"); - final long balance = result.getLong("balance"); - final boolean transactionsFrozen = result.getBoolean( - "transactionsFrozen"); - return new SimpleUserData(u, username, user, group, playtime, frozen, - canInteract, balance, transactionsFrozen); - } - } - catch (SQLException ex) - { - final String sb = "An error occurred while trying to retrieve user data for" + - " UUID " + - uuid + - " from the database." + - "\nCaused by: " + - ExceptionUtils.getRootCauseMessage(ex) + - "\nStack trace: " + - ExceptionUtils.getStackTrace(ex); + final long playtime = result.getLong("playtime"); + final boolean canInteract = result.getBoolean("canInteract"); + final long balance = result.getLong("balance"); + final boolean transactionsFrozen = result.getBoolean("transactionsFrozen"); + + return new SimpleUserData(u, username, user, group, playtime, + canInteract, balance, transactionsFrozen); + } + } + catch (SQLException ex) + { + final String sb = "An error occurred while trying to retrieve user data for" + + " UUID " + + uuid + + " from the database." + + "\nCaused by: " + + ExceptionUtils.getRootCauseMessage(ex) + + "\nStack trace: " + + ExceptionUtils.getStackTrace(ex); - FreedomLogger.getLogger("Datura") - .error(sb); - } + FreedomLogger.getLogger("Datura") + .error(sb); + } - 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() - .getExecutor() - .getAsync()) + 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() + .getExecutor() + .getAsync()) .join(); } @@ -185,19 +178,6 @@ public class SimpleUserData implements UserData this.playtime = 0L; } - @Override - public boolean isFrozen() - { - return frozen; - } - - @Override - public void setFrozen(final boolean frozen) - { - event.ping(); - this.frozen = true; - } - @Override public boolean canInteract() { diff --git a/Fossil/src/main/java/me/totalfreedom/fossil/cmd/CakeCommand.java b/Fossil/src/main/java/me/totalfreedom/fossil/cmd/CakeCommand.java index c4e5bd7..6c7c364 100644 --- a/Fossil/src/main/java/me/totalfreedom/fossil/cmd/CakeCommand.java +++ b/Fossil/src/main/java/me/totalfreedom/fossil/cmd/CakeCommand.java @@ -46,13 +46,17 @@ public class CakeCommand extends Commander @Base public void broadcastCake(final CommandSender sender) { - Bukkit.broadcast(FreedomMiniMessage.deserialize(true, "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.")); + Bukkit.broadcast(FreedomMiniMessage.deserialize(true, + "But there's no sense crying over every mistake. You just keep on trying till you run out of " + + "cake.")); final ItemStack stack = new ItemStack(Material.CAKE, 1); final ItemMeta meta = stack.getItemMeta(); meta.displayName(FreedomMiniMessage.deserialize(true, "The Lie")); stack.setItemMeta(meta); - Bukkit.getOnlinePlayers().forEach(player -> player.getInventory().addItem(stack)); + Bukkit.getOnlinePlayers() + .forEach(player -> player.getInventory() + .addItem(stack)); } } diff --git a/Fossil/src/main/java/me/totalfreedom/fossil/economy/SimpleTransactionResult.java b/Fossil/src/main/java/me/totalfreedom/fossil/economy/SimpleTransactionResult.java index 381936c..eeb629c 100644 --- a/Fossil/src/main/java/me/totalfreedom/fossil/economy/SimpleTransactionResult.java +++ b/Fossil/src/main/java/me/totalfreedom/fossil/economy/SimpleTransactionResult.java @@ -8,7 +8,7 @@ public class SimpleTransactionResult implements TransactionResult { public static final TransactionResult SUCCESSFUL = new SimpleTransactionResult("Successful transaction.", true); public static final TransactionResult UNAUTHORIZED = new SimpleTransactionResult("Unauthorized transaction.", - false); + false); public static final TransactionResult AMOUNT_TOO_SMALL = new SimpleTransactionResult( "Transaction balance too small.", false); public static final TransactionResult INSUFFICIENT_FUNDS = new SimpleTransactionResult( diff --git a/Fossil/src/main/java/me/totalfreedom/fossil/items/ClownfishItem.java b/Fossil/src/main/java/me/totalfreedom/fossil/items/ClownfishItem.java index 834d8c1..0bf1131 100644 --- a/Fossil/src/main/java/me/totalfreedom/fossil/items/ClownfishItem.java +++ b/Fossil/src/main/java/me/totalfreedom/fossil/items/ClownfishItem.java @@ -20,8 +20,10 @@ public final class ClownfishItem extends ShopItem { if (target == null) return; - final Location location = user.getEyeLocation().clone(); - final Vector vector = location.getDirection().multiply(2); + final Location location = user.getEyeLocation() + .clone(); + final Vector vector = location.getDirection() + .multiply(2); target.setVelocity(vector); } diff --git a/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/BasicTrail.java b/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/BasicTrail.java index 94fbb46..6d6ee9b 100644 --- a/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/BasicTrail.java +++ b/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/BasicTrail.java @@ -27,6 +27,7 @@ public final class BasicTrail extends SimpleTrail final Location location = player.getLocation() .clone() .subtract(0, 1, 0); - location.getWorld().spawnParticle(particle, location, 1, 0.0, 0.5, 0.0, options); + location.getWorld() + .spawnParticle(particle, location, 1, 0.0, 0.5, 0.0, options); } } diff --git a/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/FlameTrail.java b/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/FlameTrail.java index fad995d..d8e7ba9 100644 --- a/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/FlameTrail.java +++ b/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/FlameTrail.java @@ -24,6 +24,6 @@ public final class FlameTrail extends SimpleTrail final Vector direction = location.getDirection(); location.getWorld() .spawnParticle(getTrailType().getType(), location, 0, direction.getX(), direction.getY(), - direction.getZ(), 0.1); + direction.getZ(), 0.1); } } diff --git a/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/HeartTrail.java b/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/HeartTrail.java index b8a83cc..968a6ef 100644 --- a/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/HeartTrail.java +++ b/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/HeartTrail.java @@ -20,6 +20,7 @@ public final class HeartTrail extends SimpleTrail final Location location = player.getLocation() .clone() .subtract(0, 1, 0); - location.getWorld().spawnParticle(getTrailType().getType(), location, 1, 0.0, 0.5, 0.0); + location.getWorld() + .spawnParticle(getTrailType().getType(), location, 1, 0.0, 0.5, 0.0); } } diff --git a/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/SimpleTrail.java b/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/SimpleTrail.java index c217c64..6988ba5 100644 --- a/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/SimpleTrail.java +++ b/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/SimpleTrail.java @@ -21,7 +21,8 @@ public abstract class SimpleTrail implements Trail private Set gradientColor = null; private boolean active = false; - protected SimpleTrail(final Player player, final TrailType trailType) { + protected SimpleTrail(final Player player, final TrailType trailType) + { this.associatedPlayerUUID = player.getUniqueId(); this.trailType = trailType; } diff --git a/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/StrobeTrail.java b/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/StrobeTrail.java index 54b167d..1e444c5 100644 --- a/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/StrobeTrail.java +++ b/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/StrobeTrail.java @@ -25,6 +25,7 @@ public final class StrobeTrail extends SimpleTrail final Location location = player.getLocation() .clone() .subtract(0, 1, 0); - location.getWorld().spawnParticle(getTrailType().getType(), location, 1, 0.0, 0.5, 0.0, dustTransition); + location.getWorld() + .spawnParticle(getTrailType().getType(), location, 1, 0.0, 0.5, 0.0, dustTransition); } } diff --git a/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/TrailProvider.java b/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/TrailProvider.java index 2e7d8d5..1110266 100644 --- a/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/TrailProvider.java +++ b/Fossil/src/main/java/me/totalfreedom/fossil/trail/types/TrailProvider.java @@ -4,7 +4,8 @@ import org.bukkit.entity.Player; public final class TrailProvider { - public BasicTrail basicTrail(final Player player) { + public BasicTrail basicTrail(final Player player) + { return new BasicTrail(player); } diff --git a/Patchwork/src/main/java/me/totalfreedom/base/CommonsBase.java b/Patchwork/src/main/java/me/totalfreedom/base/CommonsBase.java index 1bc35bf..b75d402 100644 --- a/Patchwork/src/main/java/me/totalfreedom/base/CommonsBase.java +++ b/Patchwork/src/main/java/me/totalfreedom/base/CommonsBase.java @@ -20,9 +20,10 @@ public class CommonsBase extends JavaPlugin @Override public void onDisable() { - Bukkit.getScheduler().runTaskLater(this, () -> getRegistrations() - .getServiceRegistry() - .stopAllServices(), 1L); + Bukkit.getScheduler() + .runTaskLater(this, () -> getRegistrations() + .getServiceRegistry() + .stopAllServices(), 1L); getRegistrations().getServiceRegistry() .unregisterService(EventBus.class); diff --git a/Patchwork/src/main/java/me/totalfreedom/config/Configuration.java b/Patchwork/src/main/java/me/totalfreedom/config/Configuration.java index 41e9674..6b551c1 100644 --- a/Patchwork/src/main/java/me/totalfreedom/config/Configuration.java +++ b/Patchwork/src/main/java/me/totalfreedom/config/Configuration.java @@ -1,15 +1,11 @@ package me.totalfreedom.config; -import org.bukkit.configuration.file.YamlConfiguration; - import java.io.File; import java.io.IOException; import java.util.List; public interface Configuration { - YamlConfiguration asYaml(); - void save() throws IOException; void load() throws IOException; diff --git a/Patchwork/src/main/java/me/totalfreedom/config/YamlWrapper.java b/Patchwork/src/main/java/me/totalfreedom/config/YamlWrapper.java new file mode 100644 index 0000000..eefd27c --- /dev/null +++ b/Patchwork/src/main/java/me/totalfreedom/config/YamlWrapper.java @@ -0,0 +1,6 @@ +package me.totalfreedom.config; + +public final class YamlWrapper +{ + +} diff --git a/Patchwork/src/main/java/me/totalfreedom/display/AbstractMenu.java b/Patchwork/src/main/java/me/totalfreedom/display/AbstractMenu.java index d39e5dc..697f7eb 100644 --- a/Patchwork/src/main/java/me/totalfreedom/display/AbstractMenu.java +++ b/Patchwork/src/main/java/me/totalfreedom/display/AbstractMenu.java @@ -76,13 +76,13 @@ public abstract class AbstractMenu { Bukkit.getOnlinePlayers() .forEach(player -> - { - if (openInvs.get(player.getUniqueId()) - .equals(getDisplayableUUID())) - { - close(player); - } - }); + { + if (openInvs.get(player.getUniqueId()) + .equals(getDisplayableUUID())) + { + close(player); + } + }); invByUUID.remove(getDisplayableUUID()); } diff --git a/Patchwork/src/main/java/me/totalfreedom/display/Displayable.java b/Patchwork/src/main/java/me/totalfreedom/display/Displayable.java index 2ae19e8..c550877 100644 --- a/Patchwork/src/main/java/me/totalfreedom/display/Displayable.java +++ b/Patchwork/src/main/java/me/totalfreedom/display/Displayable.java @@ -30,7 +30,9 @@ public final class Displayable implements Inventory, InventoryHolder // If the size is not a multiple of nine, find the difference to the next highest multiple of 9 and make up // the difference. - this.size = (size % 9 == 0) ? size : size + (9 - size % 9); + this.size = (size % 9 == 0) + ? size + : size + (9 - size % 9); this.contents = new ItemStack[size]; } @@ -152,7 +154,7 @@ public final class Displayable implements Inventory, InventoryHolder if (remainingAmount < item.getAmount()) { removedItems.put(removedItems.size(), - new ItemStack(item.getType(), item.getAmount() - remainingAmount)); + new ItemStack(item.getType(), item.getAmount() - remainingAmount)); } } diff --git a/Patchwork/src/main/java/me/totalfreedom/event/SubscriptionBox.java b/Patchwork/src/main/java/me/totalfreedom/event/SubscriptionBox.java index 6feb564..c93a230 100644 --- a/Patchwork/src/main/java/me/totalfreedom/event/SubscriptionBox.java +++ b/Patchwork/src/main/java/me/totalfreedom/event/SubscriptionBox.java @@ -25,14 +25,14 @@ class SubscriptionBox public void tick() { subscriptions.forEach(s -> - { - if (!s.event() - .shouldCall()) return; + { + if (!s.event() + .shouldCall()) return; - s.callback() - .call(s.event()); - s.event() - .reset(); - }); + s.callback() + .call(s.event()); + s.event() + .reset(); + }); } } diff --git a/Patchwork/src/main/java/me/totalfreedom/particle/Trail.java b/Patchwork/src/main/java/me/totalfreedom/particle/Trail.java index 2581463..dc3c517 100644 --- a/Patchwork/src/main/java/me/totalfreedom/particle/Trail.java +++ b/Patchwork/src/main/java/me/totalfreedom/particle/Trail.java @@ -3,10 +3,8 @@ package me.totalfreedom.particle; import me.totalfreedom.api.Interpolator; import me.totalfreedom.utils.InterpolationUtils; import org.bukkit.Color; -import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.Particle; -import org.bukkit.World; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/Patchwork/src/main/java/me/totalfreedom/provider/ContextProvider.java b/Patchwork/src/main/java/me/totalfreedom/provider/ContextProvider.java index 189fe37..aa61ac0 100644 --- a/Patchwork/src/main/java/me/totalfreedom/provider/ContextProvider.java +++ b/Patchwork/src/main/java/me/totalfreedom/provider/ContextProvider.java @@ -3,6 +3,7 @@ package me.totalfreedom.provider; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -21,6 +22,7 @@ public class ContextProvider toInt(string), toLong(string), toFloat(string), + toMaterial(string), toPlayer(string), toWorld(string), toLocation(string), @@ -92,6 +94,11 @@ public class ContextProvider } } + private @Nullable Material toMaterial(final String string) + { + return Material.matchMaterial(string); + } + private @Nullable Player toPlayer(final String string) { return Bukkit.getPlayer(string); diff --git a/Patchwork/src/main/java/me/totalfreedom/service/ServiceSubscription.java b/Patchwork/src/main/java/me/totalfreedom/service/ServiceSubscription.java index 8cc99cf..f6c4a83 100644 --- a/Patchwork/src/main/java/me/totalfreedom/service/ServiceSubscription.java +++ b/Patchwork/src/main/java/me/totalfreedom/service/ServiceSubscription.java @@ -3,6 +3,7 @@ package me.totalfreedom.service; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitTask; +import org.jetbrains.annotations.NotNull; import java.util.concurrent.Executor; @@ -15,7 +16,7 @@ public final class ServiceSubscription private boolean isActive = false; - ServiceSubscription(final JavaPlugin plugin, final T service, final boolean async) + ServiceSubscription(@NotNull final JavaPlugin plugin, @NotNull final T service, final boolean async) { this.service = service; this.async = async; @@ -52,12 +53,8 @@ public final class ServiceSubscription public void stop() { this.isActive = false; - Bukkit.getScheduler().cancelTask(this.getServiceId()); - } - - public T getService() - { - return service; + Bukkit.getScheduler() + .cancelTask(this.getServiceId()); } public int getServiceId() @@ -65,6 +62,12 @@ public final class ServiceSubscription return serviceId; } + @NotNull + public T getService() + { + return service; + } + public boolean isAsync() { return async; diff --git a/Patchwork/src/main/java/me/totalfreedom/sql/SQLProperties.java b/Patchwork/src/main/java/me/totalfreedom/sql/SQLProperties.java index 2a3a448..2127b1d 100644 --- a/Patchwork/src/main/java/me/totalfreedom/sql/SQLProperties.java +++ b/Patchwork/src/main/java/me/totalfreedom/sql/SQLProperties.java @@ -22,10 +22,10 @@ public interface SQLProperties default String toURLPlain() { return String.format("jdbc:%s://%s:%s/%s", - this.getDriver(), - this.getHost(), - this.getPort(), - this.getDatabase()); + this.getDriver(), + this.getHost(), + this.getPort(), + this.getDatabase()); } String getDriver(); @@ -39,12 +39,12 @@ public interface SQLProperties default String toURLWithLogin() { return String.format("jdbc:%s://%s:%s/%s?user=%s&password=%s", - this.getDriver(), - this.getHost(), - this.getPort(), - this.getDatabase(), - this.getUsername(), - this.getPassword()); + this.getDriver(), + this.getHost(), + this.getPort(), + this.getDatabase(), + this.getUsername(), + this.getPassword()); } String getUsername(); diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/FreedomLogger.java b/Patchwork/src/main/java/me/totalfreedom/utils/FreedomLogger.java index 0f2345e..9fd27ad 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/FreedomLogger.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/FreedomLogger.java @@ -56,14 +56,6 @@ public class FreedomLogger implements Audience public String infoComponent(final Supplier component) { return this.infoComponent(component.get()); - } /** - * This method allows you to log a message to the console. - * - * @param message The message to send. - */ - public void info(final String message) - { - logger.info(message); } /** @@ -78,6 +70,14 @@ public class FreedomLogger implements Audience logger.info(plainText); return plainText; + } /** + * This method allows you to log a message to the console. + * + * @param message The message to send. + */ + public void info(final String message) + { + logger.info(message); } /** diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/FreedomMiniMessage.java b/Patchwork/src/main/java/me/totalfreedom/utils/FreedomMiniMessage.java index e615906..a3c1e34 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/FreedomMiniMessage.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/FreedomMiniMessage.java @@ -32,46 +32,54 @@ import net.kyori.adventure.text.minimessage.tag.standard.StandardTags; */ public class FreedomMiniMessage { + private static final MiniMessage unsafe = MiniMessage.miniMessage(); + private static final MiniMessage safe = MiniMessage.builder() + .tags(TagResolver.resolver( + StandardTags.color(), + StandardTags.rainbow(), + StandardTags.gradient(), + StandardTags.newline(), + StandardTags.decorations(TextDecoration.ITALIC), + StandardTags.decorations(TextDecoration.BOLD), + StandardTags.decorations(TextDecoration.STRIKETHROUGH), + StandardTags.decorations(TextDecoration.UNDERLINED) + )) + .build(); + private FreedomMiniMessage() { throw new UnsupportedOperationException("Instantiation of a static utility class is not supported."); } - private static final MiniMessage unsafe = MiniMessage.miniMessage(); - - private static final MiniMessage safe = MiniMessage.builder().tags(TagResolver.resolver( - StandardTags.color(), - StandardTags.rainbow(), - StandardTags.gradient(), - StandardTags.newline(), - StandardTags.decorations(TextDecoration.ITALIC), - StandardTags.decorations(TextDecoration.BOLD), - StandardTags.decorations(TextDecoration.STRIKETHROUGH), - StandardTags.decorations(TextDecoration.UNDERLINED) - )).build(); - /** - * Deserializes an input string using an instance of MiniMessage that is either safe (resolves only a specific set of tags) - * or unsafe (resolves all tags). - * @param safe Whether to use a safe instance of MiniMessage - * @param input An input string formatted with MiniMessage's input - * @param placeholders Custom placeholders to use when processing the input - * @return A processed Component + * Deserializes an input string using an instance of MiniMessage that is either safe (resolves only a specific + * set of tags) + * or unsafe (resolves all tags). + * + * @param safe Whether to use a safe instance of MiniMessage + * @param input An input string formatted with MiniMessage's input + * @param placeholders Custom placeholders to use when processing the input + * @return A processed Component */ public static Component deserialize(boolean safe, String input, TagResolver... placeholders) { - return (safe ? FreedomMiniMessage.safe : unsafe).deserialize(input, placeholders); + return (safe + ? FreedomMiniMessage.safe + : unsafe).deserialize(input, placeholders); } /** * Serializes an input component using an instance of MiniMessage that is either safe (resolves only a specific set - * of tags) or unsafe (resolves all tags). - * @param safe Whether to use a safe instance of MiniMessage - * @param input An already processed component - * @return A processed Component + * of tags) or unsafe (resolves all tags). + * + * @param safe Whether to use a safe instance of MiniMessage + * @param input An already processed component + * @return A processed Component */ public static String serialize(boolean safe, Component input) { - return (safe ? FreedomMiniMessage.safe : unsafe).serialize(input); + return (safe + ? FreedomMiniMessage.safe + : unsafe).serialize(input); } } diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/InterpolationUtils.java b/Patchwork/src/main/java/me/totalfreedom/utils/InterpolationUtils.java index 9f839ed..2e282cb 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/InterpolationUtils.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/InterpolationUtils.java @@ -69,18 +69,18 @@ public final class InterpolationUtils { final LinkedHashSet base = new LinkedHashSet<>(); final Set redToOrange = componentRGBGradient(length, NamedTextColor.RED, - NamedTextColor.GOLD, InterpolationUtils::linear); + NamedTextColor.GOLD, InterpolationUtils::linear); final Set orangeToYellow = componentRGBGradient(length, NamedTextColor.GOLD, - NamedTextColor.YELLOW, InterpolationUtils::linear); + NamedTextColor.YELLOW, InterpolationUtils::linear); final Set yellowToGreen = componentRGBGradient(length, NamedTextColor.YELLOW, - NamedTextColor.GREEN, InterpolationUtils::linear); + NamedTextColor.GREEN, InterpolationUtils::linear); final Set greenToBlue = componentRGBGradient(length, NamedTextColor.GREEN, - NamedTextColor.BLUE, InterpolationUtils::linear); + NamedTextColor.BLUE, InterpolationUtils::linear); final Set blueToPurple = componentRGBGradient(length, NamedTextColor.BLUE, - NamedTextColor.LIGHT_PURPLE, - InterpolationUtils::linear); + NamedTextColor.LIGHT_PURPLE, + InterpolationUtils::linear); final Set purpleToRed = componentRGBGradient(length, TextColor.color(75, 0, 130), - TextColor.color(255, 0, 0), InterpolationUtils::linear); + TextColor.color(255, 0, 0), InterpolationUtils::linear); base.addAll(redToOrange); base.addAll(orangeToYellow); base.addAll(yellowToGreen);