Finish removing relocated libraries from API

This commit is contained in:
Draycia committed 2023-07-08 17:01:25 -07:00
1 parent 09054b7332
commit 4ce7a46391
28 files changed
+251 -180

No files matched your search

@@ -19,16 +19,17 @@
*/
package net.draycia.carbon.api.channels;
import net.draycia.carbon.api.util.DefaultedKeyValueRegistry;
import java.util.Set;
import net.kyori.adventure.key.Key;
import net.kyori.registry.Registry;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Registry for chat channels.
*
* @since 2.0.0
*/
public interface ChannelRegistry extends Registry<Key, ChatChannel>, DefaultedKeyValueRegistry<Key, ChatChannel> {
public interface ChannelRegistry {
/**
* Registers ingame commands for the channel.
@@ -38,4 +39,63 @@ public interface ChannelRegistry extends Registry<Key, ChatChannel>, DefaultedKe
*/
void registerChannelCommands(final ChatChannel channel);
/**
* Registers the chat channel with it's key.
*
* @param channel the channel to register
* @since 2.1.0
*/
void register(final ChatChannel channel);
/**
* Gets the channel with the matching key.
*
* @param key the channel's key
* @return the channel
* @since 2.1.0
*/
@Nullable ChatChannel channel(final Key key);
/**
* Gets the channel with the matching key's value.
*
* @param value the channel's key's value
* @return the channel
* @since 2.1.0
*/
@Nullable ChatChannel channelByValue(final String value);
/**
* Gets the default key.
*
* @return the default key
* @since 2.1.0
*/
@NonNull Key defaultKey();
/**
* Gets the default value.
*
* @return the default value
* @since 2.1.0
*/
@NonNull ChatChannel defaultChannel();
/**
* Gets the list of registered channel keys.
*
* @return the registered channel keys
* @since 2.1.0
*/
@NonNull Set<Key> keys();
/**
* Gets the channel with the matching key, otherwise the default channel.
*
* @param key the channel key
* @return the channel, or the default one
* @since 2.1.0
*/
ChatChannel keyOrDefault(final Key key);
}
@@ -19,10 +19,27 @@
*/
package net.draycia.carbon.api.event;
/**
* Marks an event as cancellable.
*
* @since 2.1.0
*/
public interface Cancellable {
/**
* Gets if the event is cancelled.
*
* @return if the event is cancelled
* @since 2.1.0
*/
boolean cancelled();
/**
* Sets the cancelled state.
*
* @param cancelled sets the cancelled state
* @since 2.1.0
*/
void cancelled(final boolean cancelled);
}
@@ -23,6 +23,12 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
import org.jetbrains.annotations.NotNull;
/**
* An EventSubscriber.
*
* @param <T> CarbonEvent implementations
* @since 2.1.0
*/
@DefaultQualifier(NonNull.class)
public interface CarbonEventSubscriber<T extends CarbonEvent> {
@@ -22,6 +22,12 @@ package net.draycia.carbon.api.event;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
/**
* An EventSubscription.
*
* @param <T> CarbonEvent implementations
* @since 2.1.0
*/
@DefaultQualifier(NonNull.class)
public interface CarbonEventSubscription<T extends CarbonEvent> {
@@ -19,6 +19,7 @@
*/
package net.draycia.carbon.api.event.events;
import java.util.Set;
import net.draycia.carbon.api.channels.ChatChannel;
import net.draycia.carbon.api.event.CarbonEvent;
import net.kyori.adventure.key.Key;
@@ -39,7 +40,7 @@ public interface CarbonChannelRegisterEvent extends CarbonEvent {
* @return the registered channels
* @since 2.1.0
*/
Iterable<ChatChannel> channels();
Set<Key> channelKeys();
/**
* Registers additional channels to the registry. Does not re-emit the event.
@@ -19,8 +19,7 @@
*/
package net.draycia.carbon.api.event.events;
import com.seiama.event.Cancellable;
import java.util.Objects;
import net.draycia.carbon.api.event.Cancellable;
import net.draycia.carbon.api.event.CarbonEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.kyori.adventure.text.Component;
@@ -33,28 +32,7 @@ import org.checkerframework.framework.qual.DefaultQualifier;
* @since 2.1.0
*/
@DefaultQualifier(NonNull.class)
public class CarbonPrivateChatEvent implements CarbonEvent, Cancellable {
private final CarbonPlayer sender;
private final CarbonPlayer recipient;
private Component message;
private boolean cancelled = false;
/**
* Called whenever a player privately messages another player.
*
* @param sender the message sender
* @param recipient the message recipient
* @param message the message
* @since 2.1.0
*/
public CarbonPrivateChatEvent(final CarbonPlayer sender, final CarbonPlayer recipient, final Component message) {
this.sender = sender;
this.recipient = recipient;
this.message = message;
}
public interface CarbonPrivateChatEvent extends CarbonEvent, Cancellable {
/**
* Sets the message that will be sent.
@@ -63,9 +41,7 @@ public class CarbonPrivateChatEvent implements CarbonEvent, Cancellable {
* @throws NullPointerException if message is null
* @since 2.1.0
*/
public void message(final Component message) {
this.message = Objects.requireNonNull(message);
}
void message(final Component message);
/**
* The message that will be sent.
@@ -73,9 +49,7 @@ public class CarbonPrivateChatEvent implements CarbonEvent, Cancellable {
* @return the message
* @since 2.1.0
*/
public Component message() {
return this.message;
}
Component message();
/**
* The message sender.
@@ -83,9 +57,7 @@ public class CarbonPrivateChatEvent implements CarbonEvent, Cancellable {
* @return the sender of the message
* @since 2.1.0
*/
public CarbonPlayer sender() {
return this.sender;
}
CarbonPlayer sender();
/**
* The message recipient.
@@ -93,18 +65,6 @@ public class CarbonPrivateChatEvent implements CarbonEvent, Cancellable {
* @return the recipient of the message
* @since 2.1.0
*/
public CarbonPlayer recipient() {
return this.recipient;
}
@Override
public boolean cancelled() {
return this.cancelled;
}
@Override
public void cancelled(final boolean cancelled) {
this.cancelled = cancelled;
}
CarbonPlayer recipient();
}
@@ -1,42 +0,0 @@
/*
* CarbonChat
*
* Copyright (c) 2023 Josua Parks (Vicarious)
* Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.draycia.carbon.api.util;
import net.kyori.registry.DefaultedRegistryGetter;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* An extension of the DefaultedRegistryGetter that declares a defaultValue method.
*
* @param <K> the key type
* @param <V> the value type
* @since 1.0.0
*/
public interface DefaultedKeyValueRegistry<K, V> extends DefaultedRegistryGetter<K, V> {
/**
* Gets the default value.
*
* @return the default value
* @since 1.0.0
*/
@NonNull V defaultValue();
}