mirror of
https://github.com/SimplexDevelopment/FreedomNetworkSuite.git
synced 2024-11-13 04:33:33 +00:00
Slight bugfix, also more code spec alignment
This commit is contained in:
parent
faca73f99c
commit
5f6e7a153e
@ -14,6 +14,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
@ -90,12 +90,12 @@ public class SimpleUserData implements UserData
|
||||
.getGroupRegistry()
|
||||
.getGroup(g);
|
||||
|
||||
long playtime = result.getLong("playtime");
|
||||
boolean frozen = result.getBoolean("frozen");
|
||||
boolean canInteract = result.getBoolean("canInteract");
|
||||
boolean caged = result.getBoolean("caged");
|
||||
long balance = result.getLong("balance");
|
||||
boolean transactionsFrozen = result.getBoolean("transactionsFrozen");
|
||||
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, caged, balance, transactionsFrozen);
|
||||
}
|
||||
} catch (SQLException ex)
|
||||
@ -231,19 +231,19 @@ public class SimpleUserData implements UserData
|
||||
}
|
||||
|
||||
@Override
|
||||
public long addToBalance(long amount)
|
||||
public long addToBalance(final long amount)
|
||||
{
|
||||
return balance.addAndGet(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long removeFromBalance(long amount)
|
||||
public long removeFromBalance(final long amount)
|
||||
{
|
||||
return balance.addAndGet(-amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBalance(long newBalance)
|
||||
public void setBalance(final long newBalance)
|
||||
{
|
||||
balance.set(newBalance);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class SimpleCompletedTransaction implements CompletedTransaction
|
||||
private final EconomicEntity destination;
|
||||
private final long balance;
|
||||
|
||||
public SimpleCompletedTransaction(Transaction transaction, TransactionResult transactionResult)
|
||||
public SimpleCompletedTransaction(final Transaction transaction, final TransactionResult transactionResult)
|
||||
{
|
||||
|
||||
this.source = transaction.getSource();
|
||||
|
@ -15,16 +15,16 @@ public class SimpleLoggedTransactor implements Transactor
|
||||
this(new SimpleTransactor(), new SimpleTransactionLogger());
|
||||
}
|
||||
|
||||
public SimpleLoggedTransactor(Transactor transactor, TransactionLogger transactionLogger)
|
||||
public SimpleLoggedTransactor(final Transactor transactor, final TransactionLogger transactionLogger)
|
||||
{
|
||||
this.transactor = transactor;
|
||||
this.transactionLogger = transactionLogger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletedTransaction handleTransaction(MutableTransaction transaction)
|
||||
public CompletedTransaction handleTransaction(final MutableTransaction transaction)
|
||||
{
|
||||
CompletedTransaction completedTransaction = transactor.handleTransaction(transaction);
|
||||
final CompletedTransaction completedTransaction = transactor.handleTransaction(transaction);
|
||||
|
||||
transactionLogger.logTransaction(completedTransaction);
|
||||
return completedTransaction;
|
||||
|
@ -5,25 +5,25 @@ import me.totalfreedom.economy.MutableTransaction;
|
||||
|
||||
public class SimpleMutableTransaction extends SimpleTransaction implements MutableTransaction
|
||||
{
|
||||
public SimpleMutableTransaction(EconomicEntity source, EconomicEntity destination, long balance)
|
||||
public SimpleMutableTransaction(final EconomicEntity source, final EconomicEntity destination, final long balance)
|
||||
{
|
||||
super(source, destination, balance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long addToBalance(long amount)
|
||||
public long addToBalance(final long amount)
|
||||
{
|
||||
return balance.addAndGet(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long removeFromBalance(long amount)
|
||||
public long removeFromBalance(final long amount)
|
||||
{
|
||||
return this.addToBalance(-amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBalance(long newBalance)
|
||||
public void setBalance(final long newBalance)
|
||||
{
|
||||
balance.set(newBalance);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class SimpleTransaction implements Transaction
|
||||
private final EconomicEntity destination;
|
||||
protected final AtomicLong balance;
|
||||
|
||||
public SimpleTransaction(EconomicEntity source, EconomicEntity destination, long balance)
|
||||
public SimpleTransaction(final EconomicEntity source, final EconomicEntity destination, final long balance)
|
||||
{
|
||||
this.source = source;
|
||||
this.destination = destination;
|
||||
|
@ -1,7 +1,10 @@
|
||||
package me.totalfreedom.fossil.economy;
|
||||
|
||||
import me.totalfreedom.audience.MutableAudienceForwarder;
|
||||
import me.totalfreedom.economy.*;
|
||||
import me.totalfreedom.economy.TransactionResult;
|
||||
import me.totalfreedom.economy.CompletedTransaction;
|
||||
import me.totalfreedom.economy.TransactionLogger;
|
||||
import me.totalfreedom.economy.EconomicEntity;
|
||||
import me.totalfreedom.utils.FreedomLogger;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@ -10,16 +13,16 @@ public class SimpleTransactionLogger implements TransactionLogger
|
||||
private final MutableAudienceForwarder audience = MutableAudienceForwarder.from(FreedomLogger.getLogger("Fossil"));
|
||||
|
||||
@Override
|
||||
public void logTransaction(CompletedTransaction completedTransaction)
|
||||
public void logTransaction(final CompletedTransaction completedTransaction)
|
||||
{
|
||||
StringBuilder transactionLoggingStatementBuilder = new StringBuilder();
|
||||
TransactionResult result = completedTransaction.getResult();
|
||||
boolean resultSuccess = result.isSuccessful();
|
||||
String resultMessage = result.getMessage();
|
||||
final StringBuilder transactionLoggingStatementBuilder = new StringBuilder();
|
||||
final TransactionResult result = completedTransaction.getResult();
|
||||
final boolean resultSuccess = result.isSuccessful();
|
||||
final String resultMessage = result.getMessage();
|
||||
|
||||
EconomicEntity source = completedTransaction.getSource();
|
||||
EconomicEntity destination = completedTransaction.getDestination();
|
||||
long transactionAmount = completedTransaction.getBalance();
|
||||
final EconomicEntity source = completedTransaction.getSource();
|
||||
final EconomicEntity destination = completedTransaction.getDestination();
|
||||
final long transactionAmount = completedTransaction.getBalance();
|
||||
|
||||
transactionLoggingStatementBuilder.append(resultSuccess ? "Successful" : "Unsuccessful")
|
||||
.append(" (")
|
||||
@ -33,7 +36,7 @@ public class SimpleTransactionLogger implements TransactionLogger
|
||||
.append(transactionAmount)
|
||||
.append(".");
|
||||
|
||||
Component message = Component.text(transactionLoggingStatementBuilder.toString());
|
||||
final Component message = Component.text(transactionLoggingStatementBuilder.toString());
|
||||
|
||||
audience.sendMessage(message);
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ public class SimpleTransactionResult implements TransactionResult
|
||||
private final Component component;
|
||||
private final boolean successful;
|
||||
|
||||
public SimpleTransactionResult(String message, boolean successful)
|
||||
public SimpleTransactionResult(final String message, final boolean successful)
|
||||
{
|
||||
this(message, Component.text(message, successful ? NamedTextColor.GREEN : NamedTextColor.RED), successful);
|
||||
}
|
||||
|
||||
public SimpleTransactionResult(String message, Component component, boolean successful)
|
||||
public SimpleTransactionResult(final String message, final Component component, final boolean successful)
|
||||
{
|
||||
this.message = message;
|
||||
this.component = component;
|
||||
|
@ -1,37 +1,41 @@
|
||||
package me.totalfreedom.fossil.economy;
|
||||
|
||||
import me.totalfreedom.economy.*;
|
||||
import me.totalfreedom.economy.CompletedTransaction;
|
||||
import me.totalfreedom.economy.EconomicEntity;
|
||||
import me.totalfreedom.economy.EconomicEntityData;
|
||||
import me.totalfreedom.economy.MutableTransaction;
|
||||
import me.totalfreedom.economy.Transactor;
|
||||
|
||||
public class SimpleTransactor implements Transactor
|
||||
{
|
||||
@Override
|
||||
public CompletedTransaction handleTransaction(MutableTransaction transaction)
|
||||
public CompletedTransaction handleTransaction(final MutableTransaction transaction)
|
||||
{
|
||||
EconomicEntity source = transaction.getSource();
|
||||
EconomicEntityData sourceData = source.getEconomicData();
|
||||
final EconomicEntity source = transaction.getSource();
|
||||
final EconomicEntityData sourceData = source.getEconomicData();
|
||||
|
||||
if (sourceData.areTransactionsFrozen())
|
||||
{
|
||||
return new SimpleCompletedTransaction(transaction, SimpleTransactionResult.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
long transactionAmount = transaction.getBalance();
|
||||
final long transactionAmount = transaction.getBalance();
|
||||
|
||||
if (transactionAmount >= 0)
|
||||
{
|
||||
return new SimpleCompletedTransaction(transaction, SimpleTransactionResult.AMOUNT_TOO_SMALL);
|
||||
}
|
||||
|
||||
long sourceBalance = sourceData.getBalance();
|
||||
long diff = sourceBalance - transactionAmount;
|
||||
final long sourceBalance = sourceData.getBalance();
|
||||
final long diff = sourceBalance - transactionAmount;
|
||||
|
||||
if (diff > 0)
|
||||
{
|
||||
return new SimpleCompletedTransaction(transaction, SimpleTransactionResult.INSUFFICIENT_FUNDS);
|
||||
}
|
||||
|
||||
EconomicEntity destination = transaction.getDestination();
|
||||
EconomicEntityData destinationData = destination.getEconomicData();
|
||||
final EconomicEntity destination = transaction.getDestination();
|
||||
final EconomicEntityData destinationData = destination.getEconomicData();
|
||||
|
||||
if (destinationData.areTransactionsFrozen())
|
||||
{
|
||||
|
@ -28,11 +28,11 @@ public class MutableAudienceForwarder implements Audience
|
||||
{
|
||||
private final Set<Audience> audiences = new HashSet<>();
|
||||
|
||||
public static MutableAudienceForwarder from(Audience... audiences)
|
||||
public static MutableAudienceForwarder from(final Audience... audiences)
|
||||
{
|
||||
MutableAudienceForwarder audienceForwarder = new MutableAudienceForwarder();
|
||||
final MutableAudienceForwarder audienceForwarder = new MutableAudienceForwarder();
|
||||
|
||||
for (Audience audience : audiences)
|
||||
for (final Audience audience : audiences)
|
||||
{
|
||||
audienceForwarder.addAudience(audience);
|
||||
}
|
||||
@ -40,7 +40,7 @@ public class MutableAudienceForwarder implements Audience
|
||||
return audienceForwarder;
|
||||
}
|
||||
|
||||
public void addAudience(Audience audience)
|
||||
public void addAudience(final Audience audience)
|
||||
{
|
||||
if (audiences.contains(audience) || audience == this /* Protect against honest self-referential calls */)
|
||||
{
|
||||
@ -50,14 +50,14 @@ public class MutableAudienceForwarder implements Audience
|
||||
audiences.add(audience);
|
||||
}
|
||||
|
||||
public boolean removeAudience(Audience audience)
|
||||
public boolean removeAudience(final Audience audience)
|
||||
{
|
||||
return audiences.remove(audience);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull Audience filterAudience(@NotNull Predicate<? super Audience> filter)
|
||||
public @NotNull Audience filterAudience(@NotNull final Predicate<? super Audience> filter)
|
||||
{
|
||||
return audiences.stream()
|
||||
.filter(filter)
|
||||
@ -66,49 +66,49 @@ public class MutableAudienceForwarder implements Audience
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachAudience(@NotNull Consumer<? super Audience> action)
|
||||
public void forEachAudience(@NotNull final Consumer<? super Audience> action)
|
||||
{
|
||||
audiences.forEach(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull ComponentLike message)
|
||||
public void sendMessage(@NotNull final ComponentLike message)
|
||||
{
|
||||
audiences.forEach(a -> a.sendMessage(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull Component message)
|
||||
public void sendMessage(@NotNull final Component message)
|
||||
{
|
||||
audiences.forEach(a -> a.sendMessage(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull Component message, ChatType.@NotNull Bound boundChatType)
|
||||
public void sendMessage(@NotNull final Component message, final ChatType.@NotNull Bound boundChatType)
|
||||
{
|
||||
audiences.forEach(a -> a.sendMessage(message, boundChatType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull ComponentLike message, ChatType.@NotNull Bound boundChatType)
|
||||
public void sendMessage(@NotNull final ComponentLike message, final ChatType.@NotNull Bound boundChatType)
|
||||
{
|
||||
audiences.forEach(a -> a.sendMessage(message, boundChatType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull SignedMessage signedMessage, ChatType.@NotNull Bound boundChatType)
|
||||
public void sendMessage(@NotNull final SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType)
|
||||
{
|
||||
audiences.forEach(a -> a.sendMessage(signedMessage, boundChatType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMessage(@NotNull SignedMessage signedMessage)
|
||||
public void deleteMessage(@NotNull final SignedMessage signedMessage)
|
||||
{
|
||||
audiences.forEach(a -> a.deleteMessage(signedMessage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMessage(SignedMessage.@NotNull Signature signature)
|
||||
public void deleteMessage(final SignedMessage.@NotNull Signature signature)
|
||||
{
|
||||
audiences.forEach(a -> a.deleteMessage(signature));
|
||||
}
|
||||
@ -116,61 +116,61 @@ public class MutableAudienceForwarder implements Audience
|
||||
// The methods below here will (probably) never be used, however it's good to keep them for completeness' sake.
|
||||
|
||||
@Override
|
||||
public void sendActionBar(@NotNull ComponentLike message)
|
||||
public void sendActionBar(@NotNull final ComponentLike message)
|
||||
{
|
||||
audiences.forEach(a -> a.sendActionBar(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBar(@NotNull Component message)
|
||||
public void sendActionBar(@NotNull final Component message)
|
||||
{
|
||||
audiences.forEach(a -> a.sendActionBar(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayerListHeader(@NotNull ComponentLike header)
|
||||
public void sendPlayerListHeader(@NotNull final ComponentLike header)
|
||||
{
|
||||
audiences.forEach(a -> a.sendPlayerListHeader(header));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayerListHeader(@NotNull Component header)
|
||||
public void sendPlayerListHeader(@NotNull final Component header)
|
||||
{
|
||||
audiences.forEach(a -> a.sendPlayerListHeader(header));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayerListFooter(@NotNull ComponentLike footer)
|
||||
public void sendPlayerListFooter(@NotNull final ComponentLike footer)
|
||||
{
|
||||
audiences.forEach(a -> a.sendPlayerListFooter(footer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayerListFooter(@NotNull Component footer)
|
||||
public void sendPlayerListFooter(@NotNull final Component footer)
|
||||
{
|
||||
audiences.forEach(a -> a.sendPlayerListFooter(footer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayerListHeaderAndFooter(@NotNull ComponentLike header, @NotNull ComponentLike footer)
|
||||
public void sendPlayerListHeaderAndFooter(@NotNull final ComponentLike header, @NotNull final ComponentLike footer)
|
||||
{
|
||||
audiences.forEach(a -> a.sendPlayerListHeaderAndFooter(header, footer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayerListHeaderAndFooter(@NotNull Component header, @NotNull Component footer)
|
||||
public void sendPlayerListHeaderAndFooter(@NotNull final Component header, @NotNull final Component footer)
|
||||
{
|
||||
audiences.forEach(a -> a.sendPlayerListHeaderAndFooter(header, footer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showTitle(@NotNull Title title)
|
||||
public void showTitle(@NotNull final Title title)
|
||||
{
|
||||
audiences.forEach(a -> a.showTitle(title));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void sendTitlePart(@NotNull TitlePart<T> part, @NotNull T value)
|
||||
public <T> void sendTitlePart(@NotNull final TitlePart<T> part, @NotNull final T value)
|
||||
{
|
||||
audiences.forEach(a -> a.sendTitlePart(part, value));
|
||||
}
|
||||
@ -188,56 +188,56 @@ public class MutableAudienceForwarder implements Audience
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showBossBar(@NotNull BossBar bar)
|
||||
public void showBossBar(@NotNull final BossBar bar)
|
||||
{
|
||||
audiences.forEach(a -> a.showBossBar(bar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideBossBar(@NotNull BossBar bar)
|
||||
public void hideBossBar(@NotNull final BossBar bar)
|
||||
{
|
||||
audiences.forEach(a -> a.hideBossBar(bar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(@NotNull Sound sound)
|
||||
public void playSound(@NotNull final Sound sound)
|
||||
{
|
||||
audiences.forEach(a -> a.playSound(sound));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(@NotNull Sound sound, double x, double y, double z)
|
||||
public void playSound(@NotNull final Sound sound, final double x, final double y, final double z)
|
||||
{
|
||||
|
||||
audiences.forEach(a -> a.playSound(sound, x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(@NotNull Sound sound, Sound.@NotNull Emitter emitter)
|
||||
public void playSound(@NotNull final Sound sound, final Sound.@NotNull Emitter emitter)
|
||||
{
|
||||
audiences.forEach(a -> a.playSound(sound, emitter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopSound(@NotNull Sound sound)
|
||||
public void stopSound(@NotNull final Sound sound)
|
||||
{
|
||||
audiences.forEach(a -> a.stopSound(sound));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopSound(@NotNull SoundStop stop)
|
||||
public void stopSound(@NotNull final SoundStop stop)
|
||||
{
|
||||
audiences.forEach(a -> a.stopSound(stop));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openBook(Book.@NotNull Builder book)
|
||||
public void openBook(final Book.@NotNull Builder book)
|
||||
{
|
||||
audiences.forEach(a -> a.openBook(book));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openBook(@NotNull Book book)
|
||||
public void openBook(@NotNull final Book book)
|
||||
{
|
||||
audiences.forEach(a -> a.openBook(book));
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class BukkitDelegator extends Command implements PluginIdentifiableComman
|
||||
{
|
||||
try
|
||||
{
|
||||
command.getBaseMethodPair().getValue().invoke(command, sender);
|
||||
command.getBaseMethodPair().value().invoke(command, sender);
|
||||
} catch (Exception ex)
|
||||
{
|
||||
FreedomLogger.getLogger("Patchwork")
|
||||
|
@ -31,7 +31,7 @@ public class EventRegistry
|
||||
{
|
||||
if (clazz.isInstance(event))
|
||||
{
|
||||
return () -> (T) event;
|
||||
return () -> clazz.cast(event);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -98,20 +98,33 @@ public class ContextProvider
|
||||
return toPlayer(string);
|
||||
}
|
||||
|
||||
private @Nullable World toWorld(String string)
|
||||
private @Nullable World toWorld(final String string)
|
||||
{
|
||||
return Bukkit.getWorld(string);
|
||||
}
|
||||
|
||||
// If we decide to, we can "modify" this to use spaces
|
||||
// and adjust our inputs accordingly.
|
||||
/**
|
||||
* When using this method, the input string must be formatted as
|
||||
* <br>
|
||||
* <code>worldName,x,y,z</code>
|
||||
* <br>
|
||||
*
|
||||
* @param string The string to parse
|
||||
* @return A location object if xyz is valid
|
||||
*/
|
||||
private @Nullable Location toLocation(final String string)
|
||||
{
|
||||
final String[] split = string.split(",");
|
||||
if (split.length != 4 || toWorld(split[0]) == null) return null;
|
||||
if (toDouble(split[1]) == null
|
||||
|| toDouble(split[2]) == null
|
||||
|| toDouble(split[3]) == null) return null;
|
||||
|
||||
return new Location(toWorld(split[0]), toDouble(split[1]), toDouble(split[2]), toDouble(split[3]));
|
||||
if (split.length != 4 || toWorld(split[0]) == null) return null;
|
||||
|
||||
final double x = Double.parseDouble(split[1]);
|
||||
final double y = Double.parseDouble(split[2]);
|
||||
final double z = Double.parseDouble(split[3]);
|
||||
|
||||
return new Location(toWorld(split[0]), x, y, z);
|
||||
}
|
||||
|
||||
private @NotNull Component toComponent(final String string)
|
||||
|
@ -17,22 +17,22 @@ public class FreedomAdventure
|
||||
|
||||
private static final PlainTextComponentSerializer PLAIN_TEXT_COMPONENT_SERIALIZER = PlainTextComponentSerializer.plainText();
|
||||
|
||||
public static String toPlainText(Component component)
|
||||
public static String toPlainText(final Component component)
|
||||
{
|
||||
return PLAIN_TEXT_COMPONENT_SERIALIZER.serialize(component);
|
||||
}
|
||||
|
||||
public static String toPlainText(Supplier<Component> supplier)
|
||||
public static String toPlainText(final Supplier<Component> supplier)
|
||||
{
|
||||
return toPlainText(supplier.get());
|
||||
}
|
||||
|
||||
public static Supplier<String> supplyPlainText(Supplier<Component> supplier)
|
||||
public static Supplier<String> supplyPlainText(final Supplier<Component> supplier)
|
||||
{
|
||||
return new StringRepresentationSupplier(supplier.get());
|
||||
}
|
||||
|
||||
public static Supplier<String> supplyPlainText(Component component)
|
||||
public static Supplier<String> supplyPlainText(final Component component)
|
||||
{
|
||||
return new StringRepresentationSupplier(component);
|
||||
}
|
||||
|
@ -47,9 +47,9 @@ public class FreedomLogger implements Audience
|
||||
* @param component The component to send.
|
||||
* @return A plain text representation of the message
|
||||
*/
|
||||
public String infoComponent(Component component)
|
||||
public String infoComponent(final Component component)
|
||||
{
|
||||
String plainText = FreedomAdventure.toPlainText(component);
|
||||
final String plainText = FreedomAdventure.toPlainText(component);
|
||||
|
||||
logger.info(plainText);
|
||||
return plainText;
|
||||
@ -77,7 +77,7 @@ public class FreedomLogger implements Audience
|
||||
* @param component The component to send.
|
||||
* @return A string representation of the message.
|
||||
*/
|
||||
public String infoComponent(Supplier<Component> component)
|
||||
public String infoComponent(final Supplier<Component> component)
|
||||
{
|
||||
return this.infoComponent(component.get());
|
||||
}
|
||||
@ -97,9 +97,9 @@ public class FreedomLogger implements Audience
|
||||
*
|
||||
* @param component The component to send.
|
||||
*/
|
||||
public void warnComponent(Component component)
|
||||
public void warnComponent(final Component component)
|
||||
{
|
||||
String plainText = FreedomAdventure.toPlainText(component);
|
||||
final String plainText = FreedomAdventure.toPlainText(component);
|
||||
|
||||
logger.warn(plainText);
|
||||
}
|
||||
@ -121,9 +121,9 @@ public class FreedomLogger implements Audience
|
||||
*
|
||||
* @param component The message to send.
|
||||
*/
|
||||
public String errorComponent(Component component)
|
||||
public String errorComponent(final Component component)
|
||||
{
|
||||
String plainText = FreedomAdventure.toPlainText(component);
|
||||
final String plainText = FreedomAdventure.toPlainText(component);
|
||||
|
||||
logger.error(plainText);
|
||||
|
||||
@ -164,7 +164,7 @@ public class FreedomLogger implements Audience
|
||||
* @param component The component to send.
|
||||
* @return A String representation of the component.
|
||||
*/
|
||||
public String errorComponent(Supplier<Component> component)
|
||||
public String errorComponent(final Supplier<Component> component)
|
||||
{
|
||||
return this.errorComponent(component.get());
|
||||
}
|
||||
@ -187,9 +187,9 @@ public class FreedomLogger implements Audience
|
||||
*
|
||||
* @param component The component to send.
|
||||
*/
|
||||
public String debugComponent(Component component)
|
||||
public String debugComponent(final Component component)
|
||||
{
|
||||
String plainText = FreedomAdventure.toPlainText(component);
|
||||
final String plainText = FreedomAdventure.toPlainText(component);
|
||||
|
||||
this.debug(plainText);
|
||||
|
||||
@ -222,7 +222,7 @@ public class FreedomLogger implements Audience
|
||||
* @param component The component to send.
|
||||
* @return A String representation of the message.
|
||||
*/
|
||||
public String debugComponent(Supplier<Component> component)
|
||||
public String debugComponent(final Supplier<Component> component)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -233,9 +233,9 @@ public class FreedomLogger implements Audience
|
||||
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull ComponentLike message)
|
||||
public void sendMessage(@NotNull final ComponentLike message)
|
||||
{
|
||||
Component component = ComponentLike.unbox(message);
|
||||
final Component component = ComponentLike.unbox(message);
|
||||
|
||||
if (component == null)
|
||||
{
|
||||
@ -247,25 +247,25 @@ public class FreedomLogger implements Audience
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull Component message)
|
||||
public void sendMessage(@NotNull final Component message)
|
||||
{
|
||||
this.infoComponent(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull Component message, ChatType.@NotNull Bound boundChatType)
|
||||
public void sendMessage(@NotNull final Component message, final ChatType.@NotNull Bound boundChatType)
|
||||
{
|
||||
this.infoComponent(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull ComponentLike message, ChatType.@NotNull Bound boundChatType)
|
||||
public void sendMessage(@NotNull final ComponentLike message, final ChatType.@NotNull Bound boundChatType)
|
||||
{
|
||||
this.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull SignedMessage signedMessage, ChatType.@NotNull Bound boundChatType)
|
||||
public void sendMessage(@NotNull final SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType)
|
||||
{
|
||||
this.info(signedMessage.message()); // TODO: We might want to investigate whether this logs the ENTIRE message, including unsigned & signed content, or only the signed part. This method was written in the assumption that it provided all content.
|
||||
}
|
||||
|
@ -1,22 +1,5 @@
|
||||
package me.totalfreedom.utils;
|
||||
|
||||
public class Pair<K, V>
|
||||
public record Pair<K, V>(K key, V value)
|
||||
{
|
||||
private final K key;
|
||||
private final V value;
|
||||
|
||||
public Pair(final K key, final V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public K getKey()
|
||||
{
|
||||
return key;
|
||||
}
|
||||
|
||||
public V getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user