Rename bukkit module to paper

This commit is contained in:
Draycia committed 2022-06-08 15:19:46 -07:00
1 parent a7a9dddf89
commit 5661cc293f
24 files changed
+156 -143

No files matched your search

+4 -4
View File
@@ -27,12 +27,12 @@
"http://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<!-- add any necessary suppressions here -->
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](bukkit|sponge|common|velocity|fabric)[\\/].*"
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](paper|sponge|common|velocity|fabric)[\\/].*"
checks="FilteringWriteTag"/>
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](bukkit|sponge|common|velocity|fabric)[\\/].*"
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](paper|sponge|common|velocity|fabric)[\\/].*"
checks="MissingJavadocMethod"/>
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](bukkit|sponge|common|velocity|fabric)[\\/].*"
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](paper|sponge|common|velocity|fabric)[\\/].*"
checks="MissingJavadocPackage"/>
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](bukkit|sponge|common|velocity|fabric)[\\/].*"
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](paper|sponge|common|velocity|fabric)[\\/].*"
checks="MissingJavadocType"/>
</suppressions>
@@ -36,7 +36,8 @@ public final class ConfigChannelSettings {
You only need to change the second part of the key. "global" by default.
The value is what's used in commands, this is probably what you want to change.
""")
private @Nullable Key key = Key.key("carbon", "basic");
private @Nullable
final Key key = Key.key("carbon", "basic");
@Comment("""
The permission required to use the channel.
@@ -44,19 +45,25 @@ public final class ConfigChannelSettings {
To send messages you must have the permission carbon.channel.basic.speak
If you want to give both, grant carbon.channel.basic or carbon.channel.basic.*
""")
private @Nullable String permission = "carbon.channel.basic";
private @Nullable
final String permission = "carbon.channel.basic";
@Setting("format")
@Comment("The chat formats for this channel.")
private @Nullable ConfigChannelMessageSource messageSource = new ConfigChannelMessageSource();
private @Nullable
final ConfigChannelMessageSource messageSource = new ConfigChannelMessageSource();
@Comment("Messages will be sent in this channel if they start with this prefix.")
private @Nullable String quickPrefix = "";
private @Nullable
final String quickPrefix = "";
private @Nullable Boolean shouldRegisterCommands = true;
private @Nullable
final Boolean shouldRegisterCommands = true;
private @Nullable String commandName = null;
private @Nullable
final String commandName = null;
private @Nullable List<String> commandAliases = Collections.emptyList();
private @Nullable
final List<String> commandAliases = Collections.emptyList();
}
@@ -75,7 +75,8 @@ public final class ConfigChatChannel implements ChatChannel {
You only need to change the second part of the key. "global" by default.
The value is what's used in commands, this is probably what you want to change.
""")
private @Nullable Key key = Key.key("carbon", "global");
private @Nullable
final Key key = Key.key("carbon", "global");
@Comment("""
The permission required to use the /channel <channelname> and /<channelname> commands.
@@ -84,20 +85,26 @@ public final class ConfigChatChannel implements ChatChannel {
To read messages you must have the permission carbon.channel.global.see
To send messages you must have the permission carbon.channel.global.speak
""")
private @Nullable String permission = "carbon.channel.global";
private @Nullable
final String permission = "carbon.channel.global";
@Setting("format")
@Comment("The chat formats for this channel.")
private @Nullable ConfigChannelMessageSource messageSource = new ConfigChannelMessageSource();
private @Nullable
final ConfigChannelMessageSource messageSource = new ConfigChannelMessageSource();
@Comment("Messages will be sent in this channel if they start with this prefix.")
private @Nullable String quickPrefix = "";
private @Nullable
final String quickPrefix = "";
private @Nullable Boolean shouldRegisterCommands = true;
private @Nullable
final Boolean shouldRegisterCommands = true;
private @Nullable String commandName = null;
private @Nullable
final String commandName = null;
private @Nullable List<String> commandAliases = Collections.emptyList();
private @Nullable
final List<String> commandAliases = Collections.emptyList();
private transient @Nullable ConfigChannelMessages carbonMessages = null;
@@ -106,9 +113,9 @@ public final class ConfigChatChannel implements ChatChannel {
A value of '0' requires that both players are in the same world.
On velocity, '0' requires that both players are in the same server.
""")
private int radius = -1;
private final int radius = -1;
private transient @Nullable ConfigChannelMessages messageService = null;
private final transient @Nullable ConfigChannelMessages messageService = null;
@Override
public @Nullable String quickPrefix() {
@@ -152,7 +159,7 @@ public final class ConfigChatChannel implements ChatChannel {
);
}
private transient Map<String, TagResolver> DEFAULT_TAGS = Map.ofEntries(
private final transient Map<String, TagResolver> DEFAULT_TAGS = Map.ofEntries(
Map.entry("hover", StandardTags.hoverEvent()),
Map.entry("click", StandardTags.clickEvent()),
Map.entry("color", StandardTags.color()),
@@ -35,13 +35,13 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
public class ClearChatSettings {
@Comment("The message that will be sent to each player.")
private String message = "";
private final String message = "";
@Comment("The number of times the message will be sent to each player.")
private int iterations = 50;
private final int iterations = 50;
@Comment("The message to be sent after chat is cleared.")
private String broadcast = "<gold>Chat has been cleared by </gold><green><display_name><green><gold>.";
private final String broadcast = "<gold>Chat has been cleared by </gold><green><display_name><green><gold>.";
private @MonotonicNonNull Component messageComponent = null;
@@ -29,13 +29,13 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
public class DatabaseSettings {
@Comment("JDBC URL")
private String url = "jdbc:mysql://localhost:3306/carbon";
private final String url = "jdbc:mysql://localhost:3306/carbon";
@Comment("")
private String username = "username";
private final String username = "username";
@Comment("")
private String password = "password";
private final String password = "password";
public String url() {
return this.url;
@@ -30,28 +30,28 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
@ConfigSerializable
public class MessagingSettings {
private boolean enabled = false;
private final boolean enabled = false;
@Comment("Options: RABBITMQ, NATS, REDIS")
private MessagingManager.@NonNull BrokerType brokerType = MessagingManager.BrokerType.NONE;
private final MessagingManager.@NonNull BrokerType brokerType = MessagingManager.BrokerType.NONE;
@Comment("")
private String url = "127.0.0.1";
private final String url = "127.0.0.1";
@Comment("")
private int port = 5672; // RabbitMQ 5672, NATS 4222, Redis 6379
private final int port = 5672; // RabbitMQ 5672, NATS 4222, Redis 6379
@Comment("RabbitMQ VHost")
private String vhost = "/"; // RabbitMQ only
private final String vhost = "/"; // RabbitMQ only
@Comment("NATS credentials file")
private String credentialsFile = ""; // NATS only
private final String credentialsFile = ""; // NATS only
@Comment("RabbitMQ username")
private String username = "username"; // RabbitMQ only
private final String username = "username"; // RabbitMQ only
@Comment("RabbitMQ and Redis password")
private String password = "password"; // RabbitMQ and Redis only
private final String password = "password"; // RabbitMQ and Redis only
public boolean enabled() {
return this.enabled;
@@ -30,15 +30,15 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
public class PingSettings {
@Comment("The color your name will be when another player mentions you.")
private TextColor highlightTextColor = NamedTextColor.YELLOW;
private final TextColor highlightTextColor = NamedTextColor.YELLOW;
private String prefix = "@";
private final String prefix = "@";
private boolean playSound = false;
private Key name = Key.key("block.anvil.use");
private Sound.Source source = Sound.Source.MASTER;
private float volume = 1.0f; // 0.0 -> infinity
private float pitch = 1.0f; // 0.0 -> 2.0
private final boolean playSound = false;
private final Key name = Key.key("block.anvil.use");
private final Sound.Source source = Sound.Source.MASTER;
private final float volume = 1.0f; // 0.0 -> infinity
private final float pitch = 1.0f; // 0.0 -> 2.0
public TextColor highlightTextColor() {
return this.highlightTextColor;
@@ -32,22 +32,22 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
public class PrimaryConfig {
@Comment("The default locale for plugin messages.")
private Locale defaultLocale = Locale.US;
private final Locale defaultLocale = Locale.US;
@Comment("""
The default channel that new players will be in when they join.
If the channel is not found or the player cannot use the channel, they will speak in basic non-channel chat.
""")
private Key defaultChannel = Key.key("carbon", "global");
private final Key defaultChannel = Key.key("carbon", "global");
@Comment("The service that will be used to store and load player information.")
private StorageType storageType = StorageType.JSON;
private final StorageType storageType = StorageType.JSON;
@Comment("")
private DatabaseSettings databaseSettings = new DatabaseSettings();
private final DatabaseSettings databaseSettings = new DatabaseSettings();
@Comment("Various ClearChat command settings.")
private ClearChatSettings clearChatSettings = new ClearChatSettings();
private final ClearChatSettings clearChatSettings = new ClearChatSettings();
@Comment("""
Plugin-wide custom placeholders.
@@ -56,12 +56,12 @@ public class PrimaryConfig {
Make sure to close your tags so they do not bleed into other formats.
Only a single pass is done so custom placeholders will not work within each other.
""")
private Map<String, String> customPlaceholders = Map.of();
private final Map<String, String> customPlaceholders = Map.of();
@Comment("Various settings related to pinging players in channels.")
private PingSettings pingSettings = new PingSettings();
private final PingSettings pingSettings = new PingSettings();
private MessagingSettings messagingSettings = new MessagingSettings();
private final MessagingSettings messagingSettings = new MessagingSettings();
public Locale defaultLocale() {
return this.defaultLocale;
@@ -188,7 +188,7 @@ public class MessagingManager {
this.messagingService = builder.build();
}
case NONE -> throw new IllegalStateException("MessagingManager initialized with no messaging broker selected!");
};
}
}
public enum BrokerType {
@@ -41,7 +41,7 @@ tasks {
bukkit {
name = rootProject.name
version = project.version as String
main = "net.draycia.carbon.bukkit.CarbonChatBukkit"
main = "net.draycia.carbon.paper.CarbonChatPaper"
apiVersion = "1.18"
author = "Draycia"
depend = listOf("LuckPerms")
@@ -17,7 +17,7 @@
* 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.bukkit;
package net.draycia.carbon.paper;
import com.google.inject.Guice;
import com.google.inject.Injector;
@@ -36,11 +36,6 @@ import net.draycia.carbon.api.channels.ChannelRegistry;
import net.draycia.carbon.api.events.CarbonEventHandler;
import net.draycia.carbon.api.users.UserManager;
import net.draycia.carbon.api.util.RenderedMessage;
import net.draycia.carbon.bukkit.listeners.BukkitChatListener;
import net.draycia.carbon.bukkit.listeners.BukkitPlayerJoinListener;
import net.draycia.carbon.bukkit.listeners.DiscordMessageListener;
import net.draycia.carbon.bukkit.util.BukkitMessageRenderer;
import net.draycia.carbon.bukkit.util.CarbonChatHook;
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
import net.draycia.carbon.common.listeners.RadiusListener;
import net.draycia.carbon.common.messages.CarbonMessages;
@@ -49,6 +44,10 @@ import net.draycia.carbon.common.users.CarbonPlayerCommon;
import net.draycia.carbon.common.util.CloudUtils;
import net.draycia.carbon.common.util.ListenerUtils;
import net.draycia.carbon.common.util.PlayerUtils;
import net.draycia.carbon.paper.listeners.DiscordMessageListener;
import net.draycia.carbon.paper.listeners.PaperChatListener;
import net.draycia.carbon.paper.listeners.PaperPlayerJoinListener;
import net.draycia.carbon.paper.util.PaperMessageRenderer;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.moonshine.message.IMessageRenderer;
@@ -66,18 +65,18 @@ import org.checkerframework.framework.qual.DefaultQualifier;
@Singleton
@DefaultQualifier(NonNull.class)
public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
public final class CarbonChatPaper extends JavaPlugin implements CarbonChat {
private static final Set<Class<? extends Listener>> LISTENER_CLASSES = Set.of(
BukkitChatListener.class,
BukkitPlayerJoinListener.class
PaperChatListener.class,
PaperPlayerJoinListener.class
);
private static final int BSTATS_PLUGIN_ID = 8720;
private final CarbonEventHandler eventHandler = new CarbonEventHandler();
private @MonotonicNonNull Injector injector;
private @MonotonicNonNull UserManager<CarbonPlayerCommon> userManager;
private @MonotonicNonNull Logger logger;
private @MonotonicNonNull CarbonServerBukkit carbonServerBukkit;
private @MonotonicNonNull CarbonServerPaper carbonServerPaper;
private @MonotonicNonNull CarbonMessages carbonMessages;
private @MonotonicNonNull ChannelRegistry channelRegistry;
private final UUID serverId = UUID.randomUUID();
@@ -99,11 +98,11 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
CarbonChatProvider.register(this);
this.injector = Guice.createInjector(new CarbonChatBukkitModule(this, this.dataDirectory()));
this.injector = Guice.createInjector(new CarbonChatPaperModule(this, this.dataDirectory()));
this.logger = LogManager.getLogger("CarbonChat");
this.carbonMessages = this.injector.getInstance(CarbonMessages.class);
this.channelRegistry = this.injector.getInstance(ChannelRegistry.class);
this.carbonServerBukkit = this.injector.getInstance(CarbonServerBukkit.class);
this.carbonServerPaper = this.injector.getInstance(CarbonServerPaper.class);
this.userManager = this.injector.getInstance(com.google.inject.Key.get(new TypeLiteral<UserManager<CarbonPlayerCommon>>() {}));
this.packetService();
@@ -134,7 +133,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
final long saveDelay = 5 * 60 * 20;
Bukkit.getScheduler().runTaskTimerAsynchronously(this,
() -> PlayerUtils.saveLoggedInPlayers(this.carbonServerBukkit, this.userManager), saveDelay, saveDelay);
() -> PlayerUtils.saveLoggedInPlayers(this.carbonServerPaper, this.userManager), saveDelay, saveDelay);
// Load channels
((CarbonChannelRegistry) this.channelRegistry()).loadConfigChannels(this.carbonMessages);
@@ -157,7 +156,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
@Override
public void onDisable() {
PlayerUtils.saveLoggedInPlayers(this.carbonServerBukkit, this.userManager).forEach(CompletableFuture::join);
PlayerUtils.saveLoggedInPlayers(this.carbonServerPaper, this.userManager).forEach(CompletableFuture::join);
}
@Override
@@ -185,8 +184,8 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
}
@Override
public CarbonServerBukkit server() {
return this.carbonServerBukkit;
public CarbonServerPaper server() {
return this.carbonServerPaper;
}
@Override
@@ -205,7 +204,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
@Override
public IMessageRenderer<Audience, String, RenderedMessage, Component> messageRenderer() {
return this.injector.getInstance(BukkitMessageRenderer.class);
return this.injector.getInstance(PaperMessageRenderer.class);
}
public boolean papiLoaded() {
@@ -17,7 +17,7 @@
* 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.bukkit;
package net.draycia.carbon.paper;
import cloud.commandframework.CommandManager;
import cloud.commandframework.brigadier.CloudBrigadierManager;
@@ -33,14 +33,14 @@ import net.draycia.carbon.api.CarbonChat;
import net.draycia.carbon.api.CarbonServer;
import net.draycia.carbon.api.util.RenderedMessage;
import net.draycia.carbon.api.util.SourcedAudience;
import net.draycia.carbon.bukkit.command.BukkitCommander;
import net.draycia.carbon.bukkit.command.BukkitPlayerCommander;
import net.draycia.carbon.bukkit.util.BukkitMessageRenderer;
import net.draycia.carbon.common.CarbonCommonModule;
import net.draycia.carbon.common.ForCarbon;
import net.draycia.carbon.common.command.Commander;
import net.draycia.carbon.common.command.argument.PlayerSuggestions;
import net.draycia.carbon.common.util.CloudUtils;
import net.draycia.carbon.paper.command.PaperCommander;
import net.draycia.carbon.paper.command.PaperPlayerCommander;
import net.draycia.carbon.paper.util.PaperMessageRenderer;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.moonshine.message.IMessageRenderer;
@@ -52,14 +52,14 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class)
public final class CarbonChatBukkitModule extends AbstractModule {
public final class CarbonChatPaperModule extends AbstractModule {
private final Logger logger = LogManager.getLogger("CarbonChat");
private final CarbonChatBukkit carbonChat;
private final CarbonChatPaper carbonChat;
private final Path dataDirectory;
CarbonChatBukkitModule(
final CarbonChatBukkit carbonChat,
CarbonChatPaperModule(
final CarbonChatPaper carbonChat,
final Path dataDirectory
) {
this.carbonChat = carbonChat;
@@ -77,11 +77,11 @@ public final class CarbonChatBukkitModule extends AbstractModule {
AsynchronousCommandExecutionCoordinator.<Commander>newBuilder().build(),
commandSender -> {
if (commandSender instanceof Player player) {
return new BukkitPlayerCommander(this.carbonChat, player);
return new PaperPlayerCommander(this.carbonChat, player);
}
return BukkitCommander.from(commandSender);
return PaperCommander.from(commandSender);
},
commander -> ((BukkitCommander) commander).commandSender()
commander -> ((PaperCommander) commander).commandSender()
);
} catch (final Exception ex) {
throw new RuntimeException("Failed to initialize command manager.", ex);
@@ -105,13 +105,13 @@ public final class CarbonChatBukkitModule extends AbstractModule {
@Provides
@Singleton
public IMessageRenderer<Audience, String, RenderedMessage, Component> messageRenderer(final Injector injector) {
return injector.getInstance(BukkitMessageRenderer.class);
return injector.getInstance(PaperMessageRenderer.class);
}
@Provides
@Singleton
public IMessageRenderer<SourcedAudience, String, RenderedMessage, Component> sourcedRenderer(final Injector injector) {
return injector.getInstance(BukkitMessageRenderer.class);
return injector.getInstance(PaperMessageRenderer.class);
}
@Override
@@ -119,10 +119,10 @@ public final class CarbonChatBukkitModule extends AbstractModule {
this.install(new CarbonCommonModule());
this.bind(CarbonChat.class).toInstance(this.carbonChat);
this.bind(CarbonChatBukkit.class).toInstance(this.carbonChat);
this.bind(CarbonChatPaper.class).toInstance(this.carbonChat);
this.bind(Logger.class).toInstance(this.logger);
this.bind(Path.class).annotatedWith(ForCarbon.class).toInstance(this.dataDirectory);
this.bind(CarbonServer.class).to(CarbonServerBukkit.class);
this.bind(CarbonServer.class).to(CarbonServerPaper.class);
this.bind(PlayerSuggestions.class).toInstance(new PlayerArgument.PlayerParser<Commander>()::suggestions);
}
@@ -17,7 +17,7 @@
* 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.bukkit;
package net.draycia.carbon.paper;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -29,8 +29,8 @@ import net.draycia.carbon.api.CarbonServer;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.users.ComponentPlayerResult;
import net.draycia.carbon.api.users.UserManager;
import net.draycia.carbon.bukkit.users.CarbonPlayerBukkit;
import net.draycia.carbon.common.users.CarbonPlayerCommon;
import net.draycia.carbon.paper.users.CarbonPlayerPaper;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.audience.ForwardingAudience;
import org.bukkit.Bukkit;
@@ -41,33 +41,33 @@ import org.checkerframework.framework.qual.DefaultQualifier;
@Singleton
@DefaultQualifier(NonNull.class)
public final class CarbonServerBukkit implements CarbonServer, ForwardingAudience.Single {
public final class CarbonServerPaper implements CarbonServer, ForwardingAudience.Single {
private final CarbonChatBukkit chatBukkitEntry;
private final UserManager<CarbonPlayerBukkit> userManager;
private final CarbonChatPaper carbonChatPaper;
private final UserManager<CarbonPlayerPaper> userManager;
@Inject
private CarbonServerBukkit(final CarbonChatBukkit chatBukkitEntry, final UserManager<CarbonPlayerCommon> userManager) {
this.chatBukkitEntry = chatBukkitEntry;
this.userManager = new BukkitUserManager(userManager);
private CarbonServerPaper(final CarbonChatPaper carbonChatPaper, final UserManager<CarbonPlayerCommon> userManager) {
this.carbonChatPaper = carbonChatPaper;
this.userManager = new PaperUserManager(userManager);
}
@Override
public Audience audience() {
return this.chatBukkitEntry.getServer();
return this.carbonChatPaper.getServer();
}
@Override
public Audience console() {
return this.chatBukkitEntry.getServer().getConsoleSender();
return this.carbonChatPaper.getServer().getConsoleSender();
}
@Override
public List<? extends CarbonPlayer> players() {
final var players = new ArrayList<CarbonPlayer>();
for (final var player : this.chatBukkitEntry.getServer().getOnlinePlayers()) {
final ComponentPlayerResult<CarbonPlayerBukkit> result = this.userManager.carbonPlayer(player.getUniqueId()).join();
for (final var player : this.carbonChatPaper.getServer().getOnlinePlayers()) {
final ComponentPlayerResult<CarbonPlayerPaper> result = this.userManager.carbonPlayer(player.getUniqueId()).join();
if (result.player() != null) {
players.add(result.player());
@@ -78,7 +78,7 @@ public final class CarbonServerBukkit implements CarbonServer, ForwardingAudienc
}
@Override
public UserManager<CarbonPlayerBukkit> userManager() {
public UserManager<CarbonPlayerPaper> userManager() {
return this.userManager;
}
@@ -17,15 +17,15 @@
* 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.bukkit;
package net.draycia.carbon.paper;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import net.draycia.carbon.api.users.ComponentPlayerResult;
import net.draycia.carbon.api.users.UserManager;
import net.draycia.carbon.bukkit.users.CarbonPlayerBukkit;
import net.draycia.carbon.common.users.CarbonPlayerCommon;
import net.draycia.carbon.common.users.SaveOnChange;
import net.draycia.carbon.paper.users.CarbonPlayerPaper;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -33,44 +33,44 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class)
public class BukkitUserManager implements UserManager<CarbonPlayerBukkit>, SaveOnChange {
public class PaperUserManager implements UserManager<CarbonPlayerPaper>, SaveOnChange {
protected final UserManager<CarbonPlayerCommon> proxiedUserManager;
public BukkitUserManager(final UserManager<CarbonPlayerCommon> proxiedUserManager) {
public PaperUserManager(final UserManager<CarbonPlayerCommon> proxiedUserManager) {
this.proxiedUserManager = proxiedUserManager;
}
@Override
public CompletableFuture<ComponentPlayerResult<CarbonPlayerBukkit>> carbonPlayer(final UUID uuid) {
public CompletableFuture<ComponentPlayerResult<CarbonPlayerPaper>> carbonPlayer(final UUID uuid) {
return this.proxiedUserManager.carbonPlayer(uuid).thenApply(result -> {
if (result.player() == null) {
return new ComponentPlayerResult<>(null, result.reason());
}
return new ComponentPlayerResult<>(new CarbonPlayerBukkit(result.player()), result.reason());
return new ComponentPlayerResult<>(new CarbonPlayerPaper(result.player()), result.reason());
});
}
@Override
public CompletableFuture<ComponentPlayerResult<CarbonPlayerBukkit>> savePlayer(final CarbonPlayerBukkit player) {
public CompletableFuture<ComponentPlayerResult<CarbonPlayerPaper>> savePlayer(final CarbonPlayerPaper player) {
return this.proxiedUserManager.savePlayer(player.carbonPlayerCommon()).thenApply(result -> {
if (result.player() == null) {
return new ComponentPlayerResult<>(null, result.reason());
}
return new ComponentPlayerResult<>(new CarbonPlayerBukkit(result.player()), result.reason());
return new ComponentPlayerResult<>(new CarbonPlayerPaper(result.player()), result.reason());
});
}
@Override
public CompletableFuture<ComponentPlayerResult<CarbonPlayerBukkit>> saveAndInvalidatePlayer(final CarbonPlayerBukkit player) {
public CompletableFuture<ComponentPlayerResult<CarbonPlayerPaper>> saveAndInvalidatePlayer(final CarbonPlayerPaper player) {
return this.proxiedUserManager.saveAndInvalidatePlayer(player.carbonPlayerCommon()).thenApply(result -> {
if (result.player() == null) {
return new ComponentPlayerResult<>(null, result.reason());
}
return new ComponentPlayerResult<>(new CarbonPlayerBukkit(result.player()), result.reason());
return new ComponentPlayerResult<>(new CarbonPlayerPaper(result.player()), result.reason());
});
}
@@ -17,7 +17,7 @@
* 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.bukkit.command;
package net.draycia.carbon.paper.command;
import net.draycia.carbon.common.command.Commander;
import net.kyori.adventure.audience.Audience;
@@ -27,15 +27,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class)
public interface BukkitCommander extends Commander, ForwardingAudience.Single {
public interface PaperCommander extends Commander, ForwardingAudience.Single {
static BukkitCommander from(final CommandSender sender) {
return new BukkitCommanderImpl(sender);
static PaperCommander from(final CommandSender sender) {
return new PaperCommanderImpl(sender);
}
CommandSender commandSender();
record BukkitCommanderImpl(CommandSender commandSender) implements BukkitCommander {
record PaperCommanderImpl(CommandSender commandSender) implements PaperCommander {
@Override
public Audience audience() {
@@ -17,7 +17,7 @@
* 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.bukkit.command;
package net.draycia.carbon.paper.command;
import net.draycia.carbon.api.CarbonChat;
import net.draycia.carbon.api.users.CarbonPlayer;
@@ -29,10 +29,10 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import static java.util.Objects.requireNonNull;
public record BukkitPlayerCommander(
public record PaperPlayerCommander(
@NonNull CarbonChat carbon,
@NonNull Player player
) implements PlayerCommander, BukkitCommander {
) implements PlayerCommander, PaperCommander {
@Override
public @NonNull CommandSender commandSender() {
@@ -17,13 +17,13 @@
* 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.bukkit.listeners;
package net.draycia.carbon.paper.listeners;
import com.google.inject.Inject;
import java.util.HashMap;
import java.util.Map;
import net.draycia.carbon.api.CarbonChat;
import net.draycia.carbon.bukkit.CarbonChatBukkit;
import net.draycia.carbon.paper.CarbonChatPaper;
import net.essentialsx.api.v2.events.discord.DiscordMessageEvent;
import net.essentialsx.api.v2.events.discord.DiscordRelayEvent;
import net.essentialsx.api.v2.services.discord.DiscordService;
@@ -81,7 +81,7 @@ public class DiscordMessageListener implements Listener {
if (discord != null) {
this.carbonChat.channelRegistry().forEach(channel -> {
final MessageType channelMessageType = new MessageType(channel.key().value());
discord.registerMessageType((CarbonChatBukkit) this.carbonChat, channelMessageType);
discord.registerMessageType((CarbonChatPaper) this.carbonChat, channelMessageType);
this.channelMessageTypes.put(channel.key(), channelMessageType);
});
}
@@ -17,7 +17,7 @@
* 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.bukkit.listeners;
package net.draycia.carbon.paper.listeners;
import com.google.inject.Inject;
import io.papermc.paper.event.player.AsyncChatEvent;
@@ -30,8 +30,8 @@ import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.users.ComponentPlayerResult;
import net.draycia.carbon.api.util.KeyedRenderer;
import net.draycia.carbon.api.util.RenderedMessage;
import net.draycia.carbon.bukkit.CarbonChatBukkit;
import net.draycia.carbon.bukkit.users.CarbonPlayerBukkit;
import net.draycia.carbon.paper.CarbonChatPaper;
import net.draycia.carbon.paper.users.CarbonPlayerPaper;
import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.TextReplacementConfig;
@@ -51,16 +51,16 @@ import static net.kyori.adventure.text.Component.empty;
import static net.kyori.adventure.text.Component.text;
@DefaultQualifier(NonNull.class)
public final class BukkitChatListener implements Listener {
public final class PaperChatListener implements Listener {
private final CarbonChatBukkit carbonChat;
private final CarbonChatPaper carbonChat;
private final ChannelRegistry registry;
private static final Pattern DEFAULT_URL_PATTERN = Pattern.compile("(?:(https?)://)?([-\\w_.]+\\.\\w{2,})(/\\S*)?");
@Inject
public BukkitChatListener(final CarbonChat carbonChat, final ChannelRegistry registry) {
this.carbonChat = (CarbonChatBukkit) carbonChat;
public PaperChatListener(final CarbonChat carbonChat, final ChannelRegistry registry) {
this.carbonChat = (CarbonChatPaper) carbonChat;
this.registry = registry;
}
@@ -136,7 +136,7 @@ public final class BukkitChatListener implements Listener {
for (final var renderer : chatEvent.renderers()) {
try {
if (recipient instanceof Player player) {
final ComponentPlayerResult<CarbonPlayerBukkit> targetPlayer = this.carbonChat.server().userManager().carbonPlayer(player.getUniqueId()).join();
final ComponentPlayerResult<CarbonPlayerPaper> targetPlayer = this.carbonChat.server().userManager().carbonPlayer(player.getUniqueId()).join();
renderedMessage = renderer.render(sender, targetPlayer.player(), renderedMessage.component(), chatEvent.message());
} else {
@@ -162,7 +162,7 @@ public final class BukkitChatListener implements Listener {
for (final var renderer : chatEvent.renderers()) {
try {
if (viewer instanceof Player player) {
final ComponentPlayerResult<CarbonPlayerBukkit> targetPlayer = this.carbonChat.server().userManager().carbonPlayer(player.getUniqueId()).join();
final ComponentPlayerResult<CarbonPlayerPaper> targetPlayer = this.carbonChat.server().userManager().carbonPlayer(player.getUniqueId()).join();
renderedMessage = renderer.render(sender, targetPlayer.player(), renderedMessage.component(), message);
} else {
renderedMessage = renderer.render(sender, viewer, renderedMessage.component(), message);
@@ -17,14 +17,14 @@
* 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.bukkit.listeners;
package net.draycia.carbon.paper.listeners;
import com.google.inject.Inject;
import net.draycia.carbon.api.CarbonChat;
import net.draycia.carbon.api.users.UserManager;
import net.draycia.carbon.bukkit.users.CarbonPlayerBukkit;
import net.draycia.carbon.common.users.CarbonPlayerCommon;
import net.draycia.carbon.common.util.PlayerUtils;
import net.draycia.carbon.paper.users.CarbonPlayerPaper;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -33,13 +33,13 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class)
public class BukkitPlayerJoinListener implements Listener {
public class PaperPlayerJoinListener implements Listener {
private final CarbonChat carbonChat;
private final UserManager<CarbonPlayerCommon> userManager;
@Inject
public BukkitPlayerJoinListener(
public PaperPlayerJoinListener(
final CarbonChat carbonChat,
final UserManager<CarbonPlayerCommon> userManager
) {
@@ -54,7 +54,7 @@ public class BukkitPlayerJoinListener implements Listener {
return;
}
PlayerUtils.saveAndInvalidatePlayer(this.carbonChat.server(), this.userManager, (CarbonPlayerBukkit) result.player());
PlayerUtils.saveAndInvalidatePlayer(this.carbonChat.server(), this.userManager, (CarbonPlayerPaper) result.player());
});
}
@@ -17,7 +17,7 @@
* 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.bukkit.users;
package net.draycia.carbon.paper.users;
import io.papermc.paper.event.player.AsyncChatEvent;
import java.util.Collection;
@@ -44,11 +44,11 @@ import org.checkerframework.framework.qual.DefaultQualifier;
import org.jetbrains.annotations.NotNull;
@DefaultQualifier(NonNull.class)
public final class CarbonPlayerBukkit extends WrappedCarbonPlayer implements ForwardingAudience.Single {
public final class CarbonPlayerPaper extends WrappedCarbonPlayer implements ForwardingAudience.Single {
private final CarbonPlayerCommon carbonPlayerCommon;
public CarbonPlayerBukkit(final CarbonPlayerCommon carbonPlayerCommon) {
public CarbonPlayerPaper(final CarbonPlayerCommon carbonPlayerCommon) {
this.carbonPlayerCommon = carbonPlayerCommon;
}
@@ -17,7 +17,7 @@
* 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.bukkit.util;
package net.draycia.carbon.paper.util;
import github.scarsz.discordsrv.Debug;
import github.scarsz.discordsrv.DiscordSRV;
@@ -17,7 +17,7 @@
* 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.bukkit.util;
package net.draycia.carbon.paper.util;
import com.google.inject.Inject;
import java.lang.reflect.Method;
@@ -27,9 +27,9 @@ import net.draycia.carbon.api.CarbonChatProvider;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.RenderedMessage;
import net.draycia.carbon.api.util.SourcedAudience;
import net.draycia.carbon.bukkit.CarbonChatBukkit;
import net.draycia.carbon.common.config.ConfigFactory;
import net.draycia.carbon.common.util.ChatType;
import net.draycia.carbon.paper.CarbonChatPaper;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.text.Component;
@@ -44,7 +44,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class)
public class BukkitMessageRenderer<T extends Audience> implements IMessageRenderer<T, String, RenderedMessage, Component> {
public class PaperMessageRenderer<T extends Audience> implements IMessageRenderer<T, String, RenderedMessage, Component> {
private @MonotonicNonNull PlaceholderAPIMiniMessageParser parser = null;
@@ -52,11 +52,11 @@ public class BukkitMessageRenderer<T extends Audience> implements IMessageRender
private final ConfigFactory configFactory;
@Inject
public BukkitMessageRenderer(final ConfigFactory configFactory) {
public PaperMessageRenderer(final ConfigFactory configFactory) {
this.miniMessage = MiniMessage.miniMessage();
this.configFactory = configFactory;
if (((CarbonChatBukkit) CarbonChatProvider.carbonChat()).papiLoaded()) {
if (((CarbonChatPaper) CarbonChatProvider.carbonChat()).papiLoaded()) {
this.parser = PlaceholderAPIMiniMessageParser.create(MiniMessage.miniMessage());
}
}
@@ -17,7 +17,7 @@
* 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.bukkit.util;
package net.draycia.carbon.paper.util;
import java.util.function.UnaryOperator;
import java.util.regex.Matcher;
+1 -1
View File
@@ -72,7 +72,7 @@ rootProject.name = "CarbonChat"
sequenceOf(
"api",
"common",
"bukkit",
"paper",
"sponge",
"fabric",
"velocity"