fix all style issues

This commit is contained in:
Draycia authored and Josua Parks committed 2021-11-16 20:48:23 -08:00
1 parent 07da847864
commit 304f13b0f9
40 files changed
+224 -164

No files matched your search

@@ -62,6 +62,12 @@ public interface CarbonChat {
*/
ChannelRegistry channelRegistry();
/**
* The message renderer, tailored for the current platform.
*
* @return the message renderer
* @since 2.0.0
*/
IMessageRenderer<SourcedAudience, String, RenderedMessage, Component> messageRenderer();
// TODO: Redis as MariaDB cache
@@ -1,7 +1,6 @@
package net.draycia.carbon.api.events;
import java.util.List;
import net.draycia.carbon.api.channels.ChatChannel;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.KeyedRenderer;
@@ -44,7 +43,7 @@ public class CarbonChatEvent implements ResultedCarbonEvent<CarbonChatEvent.Resu
final List<? extends Audience> recipients,
final List<KeyedRenderer> renderers,
final ChatChannel chatChannel
) {
) {
this.sender = sender;
this.originalMessage = originalMessage;
this.message = originalMessage;
@@ -22,6 +22,13 @@ import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class)
public interface CarbonPlayer extends Audience, Identified {
/**
* Returns the appropriate {@link Component} to represent the player's name.
*
* @param player the player
* @return the player's name
* @since 2.0.0
*/
static Component renderName(final CarbonPlayer player) {
if (player.hasActiveTemporaryDisplayName()) {
return Objects.requireNonNull(player.temporaryDisplayName());
@@ -41,9 +48,10 @@ public interface CarbonPlayer extends Audience, Identified {
String username();
/**
* Checks if the player has a display name set through {@link CarbonPlayer#displayName(Component)}
* Checks if the player has a display name set through {@link CarbonPlayer#displayName(Component)}.
*
* @return if the player has a display name set through {@link CarbonPlayer#displayName(Component)}
* @since 2.0.0
*/
boolean hasCustomDisplayName();
@@ -80,6 +88,7 @@ public interface CarbonPlayer extends Audience, Identified {
* The player's temporary display name.
*
* @return the player's temporary display name.
* @since 2.0.0
*/
// TODO: improve javadocs here
@Nullable Component temporaryDisplayName();
@@ -88,9 +97,16 @@ public interface CarbonPlayer extends Audience, Identified {
* The expiration date in milliseconds for the temporary display name.
*
* @return the temporary display name's expiration in MS since Unix Epoch
* @since 2.0.0
*/
long temporaryDisplayNameExpiration();
/**
* If the player has a temporary display name and it is not expired.
*
* @return if the player's temporary display name is active
* @since 2.0.0
*/
boolean hasActiveTemporaryDisplayName();
/**
@@ -229,7 +245,6 @@ public interface CarbonPlayer extends Audience, Identified {
* Sends the message as the player.
*
* @param message the message to be sent
* //@return the message result
* @since 2.0.0
*/
// TODO: change return type, provide information useful like what message was actually sent?
@@ -1,12 +1,16 @@
package net.draycia.carbon.api.users.punishments;
import java.util.UUID;
import net.kyori.adventure.key.Key;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
import java.util.UUID;
/**
* An entry describing when and why and how a player was muted.
*
* @since 2.0.0
*/
@DefaultQualifier(NonNull.class)
public record MuteEntry(
long muteEpoch,
@@ -17,8 +21,14 @@ public record MuteEntry(
UUID muteId
) {
/**
* Returns if this entry is still active and should be enforced.
*
* @return if this entry is still valid
* @since 2.0.0
*/
public boolean valid() {
return System.currentTimeMillis() < expirationEpoch;
return this.expirationEpoch == -1 || System.currentTimeMillis() < this.expirationEpoch;
}
}
@@ -2,8 +2,20 @@ package net.draycia.carbon.api.util;
import java.util.List;
/**
* A slot in a player's inventory.
*
* @since 2.0.0
*/
public final class InventorySlot {
/**
* An {@link InventorySlot} instance, usable in chat with the given placeholders.
*
* @param placeholders the placeholders that can be used in chat
* @return the instance
* @since 2.0.0
*/
public static InventorySlot of(final String... placeholders) {
return new InventorySlot(placeholders);
}
@@ -18,8 +30,23 @@ public final class InventorySlot {
this.placeholders = List.of(placeholders);
}
/**
* Returns this slot's placeholders, which can be used in chat to show the item in said slot.
*
* @return this slot's placeholders
* @since 2.0.0
*/
public List<String> placeholders() {
return this.placeholders;
}
public static final InventorySlot HELMET = InventorySlot.of("helm", "helmet", "hat", "head");
public static final InventorySlot CHEST = InventorySlot.of("chest", "chestplate");
public static final InventorySlot LEGS = InventorySlot.of("legs", "leggings");
public static final InventorySlot BOOTS = InventorySlot.of("boots", "feet");
public static final InventorySlot MAIN_HAND = InventorySlot.of("main_hand", "hand", "item");
public static final InventorySlot OFF_HAND = InventorySlot.of("off_hand");
public static List<InventorySlot> SLOTS = List.of(HELMET, CHEST, LEGS, BOOTS, MAIN_HAND, OFF_HAND);
}
@@ -1,16 +0,0 @@
package net.draycia.carbon.api.util;
import java.util.List;
public final class InventorySlots {
public static final InventorySlot HELMET = InventorySlot.of("helm", "helmet", "hat", "head");
public static final InventorySlot CHEST = InventorySlot.of("chest", "chestplate");
public static final InventorySlot LEGS = InventorySlot.of("legs", "leggings");
public static final InventorySlot BOOTS = InventorySlot.of("boots", "feet");
public static final InventorySlot MAIN_HAND = InventorySlot.of("main_hand", "hand", "item");
public static final InventorySlot OFF_HAND = InventorySlot.of("off_hand");
public static List<InventorySlot> VALUES = List.of(HELMET, CHEST, LEGS, BOOTS, MAIN_HAND, OFF_HAND);
}
@@ -3,6 +3,11 @@ package net.draycia.carbon.api.util;
import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.text.Component;
/**
* A message that's been rendered.
*
* @since 2.0.0
*/
public record RenderedMessage(Component component, MessageType messageType) {
}
@@ -4,17 +4,28 @@ import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.audience.ForwardingAudience;
import org.jetbrains.annotations.NotNull;
/**
* An audience, where messages are sent from another Audience.
*
* @since 2.0.0
*/
public record SourcedAudience(Audience sender, Audience recipient) implements ForwardingAudience.Single {
public static final SourcedAudience EMPTY = new SourcedAudience(Audience.empty(), Audience.empty());
/**
* An empty {@link SourcedAudience}, with an empty sender and recipient.
*
* @return an empty sourced audience
* @since 2.0.0
*/
public static SourcedAudience empty() {
return EMPTY;
}
@Override
public @NotNull Audience audience() {
return Audience.audience(sender, recipient);
return Audience.audience(this.sender, this.recipient);
}
}