Reformatting

This commit is contained in:
Paul Reilly
2023-06-02 17:58:08 -05:00
parent 9a56a404af
commit e160868967
27 changed files with 280 additions and 244 deletions

View File

@ -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);

View File

@ -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;

View File

@ -0,0 +1,6 @@
package me.totalfreedom.config;
public final class YamlWrapper
{
}

View File

@ -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());
}

View File

@ -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));
}
}

View File

@ -25,14 +25,14 @@ class SubscriptionBox<T extends FEvent>
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();
});
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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<T extends Service>
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<T extends Service>
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<T extends Service>
return serviceId;
}
@NotNull
public T getService()
{
return service;
}
public boolean isAsync()
{
return async;

View File

@ -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();

View File

@ -56,14 +56,6 @@ public class FreedomLogger implements Audience
public String infoComponent(final Supplier<Component> 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);
}
/**

View File

@ -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);
}
}

View File

@ -69,18 +69,18 @@ public final class InterpolationUtils
{
final LinkedHashSet<TextColor> base = new LinkedHashSet<>();
final Set<TextColor> redToOrange = componentRGBGradient(length, NamedTextColor.RED,
NamedTextColor.GOLD, InterpolationUtils::linear);
NamedTextColor.GOLD, InterpolationUtils::linear);
final Set<TextColor> orangeToYellow = componentRGBGradient(length, NamedTextColor.GOLD,
NamedTextColor.YELLOW, InterpolationUtils::linear);
NamedTextColor.YELLOW, InterpolationUtils::linear);
final Set<TextColor> yellowToGreen = componentRGBGradient(length, NamedTextColor.YELLOW,
NamedTextColor.GREEN, InterpolationUtils::linear);
NamedTextColor.GREEN, InterpolationUtils::linear);
final Set<TextColor> greenToBlue = componentRGBGradient(length, NamedTextColor.GREEN,
NamedTextColor.BLUE, InterpolationUtils::linear);
NamedTextColor.BLUE, InterpolationUtils::linear);
final Set<TextColor> blueToPurple = componentRGBGradient(length, NamedTextColor.BLUE,
NamedTextColor.LIGHT_PURPLE,
InterpolationUtils::linear);
NamedTextColor.LIGHT_PURPLE,
InterpolationUtils::linear);
final Set<TextColor> 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);